From bonefish at mail.berlios.de Thu May 1 03:53:09 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 May 2008 03:53:09 +0200 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel Message-ID: <200805010153.m411r95k031376@sheep.berlios.de> Author: bonefish Date: 2008-05-01 03:53:07 +0200 (Thu, 01 May 2008) New Revision: 25276 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25276&view=rev Added: haiku/trunk/src/system/kernel/lock.cpp Removed: haiku/trunk/src/system/kernel/lock.c Modified: haiku/trunk/headers/private/kernel/lock.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/headers/private/kernel/util/AutoLock.h haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/main.c haiku/trunk/src/system/kernel/thread.cpp Log: * Introduced a new locking primitive I called "cutex" (sorry for the name, couldn't resist :-P). It's semantically equivalent to a mutex, but doesn't need a semaphore (it uses thread blocking and a simple queue instead). Initialization can't fail. In fact it is ready to use without initialization when living in the bss segment, also in the early boot process. It's as fast as a benaphore in cases of low lock contention, and faster otherwise. Only disadvantage is the higher immediate memory footprint of 16 bytes. * Changed how the "thread" and "threads" debugger commands list the objects they are waiting for. Cutexes are also included. Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/headers/private/kernel/lock.h 2008-05-01 01:53:07 UTC (rev 25276) @@ -39,13 +39,29 @@ #define RW_MAX_READERS 1000000 +struct cutex_waiter; + +typedef struct cutex { + const char* name; + struct cutex_waiter* waiters; +#ifdef KDEBUG + thread_id holder; +#else + int32 count; +#endif + int32 release_count; +} cutex; + + #if 0 && KDEBUG // XXX disable this for now, it causes problems when including thread.h here # include #define ASSERT_LOCKED_RECURSIVE(r) { ASSERT(thread_get_current_thread_id() == (r)->holder); } #define ASSERT_LOCKED_MUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); } +#define ASSERT_LOCKED_CUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); } #else #define ASSERT_LOCKED_RECURSIVE(r) #define ASSERT_LOCKED_MUTEX(m) +#define ASSERT_LOCKED_CUTEX(m) #endif @@ -103,6 +119,54 @@ extern status_t rw_lock_write_lock(rw_lock *lock); extern status_t rw_lock_write_unlock(rw_lock *lock); +extern void cutex_init(cutex* lock, const char *name); + // name is *not* cloned nor freed in cutex_destroy() +extern void cutex_destroy(cutex* lock); + +// implementation private: +extern void _cutex_lock(cutex* lock); +extern void _cutex_unlock(cutex* lock); +extern status_t _cutex_trylock(cutex* lock); + + +static inline void +cutex_lock(cutex* lock) +{ +#ifdef KDEBUG + _cutex_lock(lock); +#else + if (atomic_add(&lock->count, -1) < 0) + _cutex_lock(lock); +#endif +} + + +static inline status_t +cutex_trylock(cutex* lock) +{ +#ifdef KDEBUG + return _cutex_trylock(lock); +#else + if (atomic_test_and_set(&lock->count, -1, 0) != 0) + return B_WOULD_BLOCK; +#endif +} + + +static inline void +cutex_unlock(cutex* lock) +{ +#ifdef KDEBUG + _cutex_unlock(lock); +#else + if (atomic_add(&lock->count, 1) < -1) + _cutex_unlock(lock); +#endif +} + + +extern void lock_debug_init(); + #ifdef __cplusplus } #endif Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-05-01 01:53:07 UTC (rev 25276) @@ -62,6 +62,7 @@ THREAD_BLOCK_TYPE_CONDITION_VARIABLE = 1, THREAD_BLOCK_TYPE_SNOOZE = 2, THREAD_BLOCK_TYPE_SIGNAL = 3, + THREAD_BLOCK_TYPE_CUTEX = 4, THREAD_BLOCK_TYPE_OTHER = 9999, THREAD_BLOCK_TYPE_USER_BASE = 10000 Modified: haiku/trunk/headers/private/kernel/util/AutoLock.h =================================================================== --- haiku/trunk/headers/private/kernel/util/AutoLock.h 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/headers/private/kernel/util/AutoLock.h 2008-05-01 01:53:07 UTC (rev 25276) @@ -67,6 +67,24 @@ // BenaphoreLocker typedef AutoLocker BenaphoreLocker; +// CutexLocking +class CutexLocking { +public: + inline bool Lock(cutex *lockable) + { + cutex_lock(lockable); + return true; + } + + inline void Unlock(cutex *lockable) + { + cutex_unlock(lockable); + } +}; + +// CutexLocker +typedef AutoLocker CutexLocker; + // InterruptsLocking class InterruptsLocking { public: @@ -153,6 +171,7 @@ using BPrivate::MutexLocker; using BPrivate::RecursiveLocker; using BPrivate::BenaphoreLocker; +using BPrivate::CutexLocker; using BPrivate::InterruptsLocker; using BPrivate::SpinLocker; using BPrivate::InterruptsSpinLocker; Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-01 01:53:07 UTC (rev 25276) @@ -27,7 +27,7 @@ int.c kernel_daemon.c linkhack.c - lock.c + lock.cpp main.c module.cpp Notifications.cpp Deleted: haiku/trunk/src/system/kernel/lock.c Copied: haiku/trunk/src/system/kernel/lock.cpp (from rev 25274, haiku/trunk/src/system/kernel/lock.c) =================================================================== --- haiku/trunk/src/system/kernel/lock.c 2008-04-30 16:14:42 UTC (rev 25274) +++ haiku/trunk/src/system/kernel/lock.cpp 2008-05-01 01:53:07 UTC (rev 25276) @@ -0,0 +1,458 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + +/* Mutex and recursive_lock code */ + +#include + +#include + +#include +#include +#include +#include +#include + + +struct cutex_waiter { + struct thread* thread; + cutex_waiter* next; // next in queue + cutex_waiter* last; // last in queue (valid for the first in queue) +}; + + +int32 +recursive_lock_get_recursion(recursive_lock *lock) +{ + if (lock->holder == thread_get_current_thread_id()) + return lock->recursion; + + return -1; +} + + +status_t +recursive_lock_init(recursive_lock *lock, const char *name) +{ + if (lock == NULL) + return B_BAD_VALUE; + + if (name == NULL) + name = "recursive lock"; + + lock->holder = -1; + lock->recursion = 0; + lock->sem = create_sem(1, name); + + if (lock->sem >= B_OK) + return B_OK; + + return lock->sem; +} + + +void +recursive_lock_destroy(recursive_lock *lock) +{ + if (lock == NULL) + return; + + delete_sem(lock->sem); + lock->sem = -1; +} + + +status_t +recursive_lock_lock(recursive_lock *lock) +{ + thread_id thread = thread_get_current_thread_id(); + + if (!kernel_startup && !are_interrupts_enabled()) + panic("recursive_lock_lock: called with interrupts disabled for lock %p, sem %#lx\n", lock, lock->sem); + + if (thread != lock->holder) { + status_t status = acquire_sem(lock->sem); + if (status < B_OK) + return status; + + lock->holder = thread; + } + lock->recursion++; + return B_OK; +} + + +void +recursive_lock_unlock(recursive_lock *lock) +{ + if (thread_get_current_thread_id() != lock->holder) + panic("recursive_lock %p unlocked by non-holder thread!\n", lock); + + if (--lock->recursion == 0) { + lock->holder = -1; + release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/); + } +} + + +// #pragma mark - + + +status_t +mutex_init(mutex *m, const char *name) +{ + if (m == NULL) + return EINVAL; + + if (name == NULL) + name = "mutex_sem"; + + m->holder = -1; + + m->sem = create_sem(1, name); + if (m->sem >= B_OK) + return B_OK; + + return m->sem; +} + + +void +mutex_destroy(mutex *mutex) +{ + if (mutex == NULL) + return; + + if (mutex->sem >= 0) { + delete_sem(mutex->sem); + mutex->sem = -1; + } + mutex->holder = -1; +} + + +status_t +mutex_trylock(mutex *mutex) +{ + thread_id me = thread_get_current_thread_id(); + status_t status; + + if (kernel_startup) + return B_OK; + + status = acquire_sem_etc(mutex->sem, 1, B_RELATIVE_TIMEOUT, 0); + if (status < B_OK) + return status; + + if (me == mutex->holder) { + panic("mutex_trylock failure: mutex %p (sem = 0x%lx) acquired twice by" + " thread 0x%lx\n", mutex, mutex->sem, me); + } + + mutex->holder = me; + return B_OK; +} + + +status_t +mutex_lock(mutex *mutex) +{ + thread_id me = thread_get_current_thread_id(); + status_t status; + + if (kernel_startup) + return B_OK; + + status = acquire_sem(mutex->sem); + if (status < B_OK) + return status; + + if (me == mutex->holder) { + panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by" + " thread 0x%lx\n", mutex, mutex->sem, me); + } + + mutex->holder = me; + return B_OK; +} + + +void +mutex_unlock(mutex *mutex) +{ + thread_id me = thread_get_current_thread_id(); + + if (kernel_startup) + return; + + if (me != mutex->holder) { + panic("mutex_unlock failure: thread 0x%lx is trying to release mutex %p" + " (current holder 0x%lx)\n", me, mutex, mutex->holder); + } + + mutex->holder = -1; + release_sem_etc(mutex->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/); +} + + +// #pragma mark - + + +status_t +benaphore_init(benaphore *ben, const char *name) +{ + if (ben == NULL || name == NULL) + return B_BAD_VALUE; + + ben->count = 1; +#ifdef KDEBUG + ben->sem = create_sem(1, name); +#else + ben->sem = create_sem(0, name); +#endif + if (ben->sem >= B_OK) + return B_OK; + + return ben->sem; +} + + +void +benaphore_destroy(benaphore *ben) +{ + delete_sem(ben->sem); + ben->sem = -1; +} + + +// #pragma mark - + + +status_t +rw_lock_init(rw_lock *lock, const char *name) +{ + if (lock == NULL) + return B_BAD_VALUE; + + if (name == NULL) + name = "r/w lock"; + + lock->sem = create_sem(RW_MAX_READERS, name); + if (lock->sem >= B_OK) + return B_OK; + + return lock->sem; +} + + +void +rw_lock_destroy(rw_lock *lock) +{ + if (lock == NULL) + return; + + delete_sem(lock->sem); +} + + +status_t +rw_lock_read_lock(rw_lock *lock) +{ + return acquire_sem(lock->sem); +} + + +status_t +rw_lock_read_unlock(rw_lock *lock) +{ + return release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/); +} + + +status_t +rw_lock_write_lock(rw_lock *lock) +{ + return acquire_sem_etc(lock->sem, RW_MAX_READERS, 0, 0); +} + + +status_t +rw_lock_write_unlock(rw_lock *lock) +{ + return release_sem_etc(lock->sem, RW_MAX_READERS, 0); +} + + +// #pragma mark - + + +void +cutex_init(cutex* lock, const char *name) +{ + lock->name = name; + lock->waiters = NULL; +#ifdef KDEBUG + lock->holder = -1; +#else + lock->count = 0; +#endif + lock->release_count = 0; +} + + +void +cutex_destroy(cutex* lock) +{ + // no-op +} + + +void +_cutex_lock(cutex* lock) +{ +#ifdef KDEBUG + if (!kernel_startup && !are_interrupts_enabled()) { + panic("_cutex_unlock: called with interrupts disabled for lock %p", + lock); + } +#endif + + InterruptsSpinLocker _(thread_spinlock); + + // Might have been released after we decremented the count, but before + // we acquired the spinlock. +#ifdef KDEBUG + if (lock->release_count >= 0) { + lock->holder = thread_get_current_thread_id(); +#else + if (lock->release_count > 0) { +#endif + lock->release_count--; + return; + } + + // enqueue in waiter list + cutex_waiter waiter; + waiter.thread = thread_get_current_thread(); + waiter.next = NULL; + + if (lock->waiters != NULL) { + lock->waiters->last->next = &waiter; + } else + lock->waiters = &waiter; + + lock->waiters->last = &waiter; + + // block + thread_prepare_to_block(waiter.thread, 0, THREAD_BLOCK_TYPE_CUTEX, lock); + thread_block_locked(waiter.thread); + +#ifdef KDEBUG + lock->holder = waiter.thread->id; +#endif +} + + +void +_cutex_unlock(cutex* lock) +{ + InterruptsSpinLocker _(thread_spinlock); + +#ifdef KDEBUG + if (thread_get_current_thread_id() != lock->holder) { + panic("_cutex_unlock() failure: thread %ld is trying to release " + "cutex %p (current holder %ld)\n", thread_get_current_thread_id(), + lock, lock->holder); + return; + } + + lock->holder = -1; +#endif + + cutex_waiter* waiter = lock->waiters; + if (waiter != NULL) { + // dequeue the first waiter + lock->waiters = waiter->next; + if (lock->waiters != NULL) + lock->waiters->last = waiter->last; + + // unblock thread + thread_unblock_locked(waiter->thread, B_OK); + } else { + // We acquired the spinlock before the locker that is going to wait. + // Just increment the release count. + lock->release_count++; + } +} + + +status_t +_cutex_trylock(cutex* lock) +{ +#ifdef KDEBUG + InterruptsSpinLocker _(thread_spinlock); + + if (lock->release_count >= 0) { + lock->holder = thread_get_current_thread_id(); + lock->release_count--; + return B_OK; + } +#endif + return B_WOULD_BLOCK; +} + + +static int +dump_cutex_info(int argc, char** argv) +{ + if (argc < 2) { + print_debugger_command_usage(argv[0]); + return 0; + } + + cutex* lock = (cutex*)strtoul(argv[1], NULL, 0); + + if (!IS_KERNEL_ADDRESS(lock)) { + kprintf("invalid address: %p\n", lock); + return 0; + } + + kprintf("cutex %p:\n", lock); + kprintf(" name: %s\n", lock->name); + kprintf(" release count: %ld\n", lock->release_count); +#ifdef KDEBUG + kprintf(" holder: %ld\n", lock->holder); +#else + kprintf(" count: %ld\n", lock->count); +#endif + + kprintf(" waiting threads:"); + cutex_waiter* waiter = lock->waiters; + while (waiter != NULL) { + kprintf(" %ld", waiter->thread->id); + waiter = waiter->next; + } + kputs("\n"); + + return 0; +} + + +// #pragma mark - + + +void +lock_debug_init() +{ + add_debugger_command_etc("cutex", &dump_cutex_info, + "Dump info about a cutex", + "\n" + "Prints info about the specified cutex.\n" + " - pointer to the cutex to print the info for.\n", 0); +} Modified: haiku/trunk/src/system/kernel/main.c =================================================================== --- haiku/trunk/src/system/kernel/main.c 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/src/system/kernel/main.c 2008-05-01 01:53:07 UTC (rev 25276) @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,7 @@ // now we can use the heap and create areas arch_platform_init_post_vm(&sKernelArgs); + lock_debug_init(); TRACE("init driver_settings\n"); boot_item_init(); driver_settings_init(&sKernelArgs); Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-04-30 18:47:11 UTC (rev 25275) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-05-01 01:53:07 UTC (rev 25276) @@ -667,17 +667,6 @@ } -static ConditionVariable* -get_thread_wait_cvar(struct thread* thread) -{ - if (thread->state == B_THREAD_WAITING - && thread->wait.type == THREAD_BLOCK_TYPE_CONDITION_VARIABLE) { - return (ConditionVariable*)thread->wait.object; - } - return NULL; -} - - /*! Fills the thread_info structure with information from the specified thread. @@ -1091,10 +1080,6 @@ return "receive"; break; } - - case THREAD_BLOCK_TYPE_CONDITION_VARIABLE: - default: - break; } return "waiting"; @@ -1133,8 +1118,47 @@ kprintf("sig_pending: %#lx (blocked: %#lx)\n", thread->sig_pending, thread->sig_block_mask); kprintf("in_kernel: %d\n", thread->in_kernel); - kprintf("sem blocking: %ld\n", get_thread_wait_sem(thread)); - kprintf("condition variable: %p\n", get_thread_wait_cvar(thread)); + + kprintf("waiting for: "); + + if (thread->state == B_THREAD_WAITING) { + switch (thread->wait.type) { + case THREAD_BLOCK_TYPE_SEMAPHORE: + { + sem_id sem = (sem_id)(addr_t)thread->wait.object; + if (sem == thread->msg.read_sem) + kprintf("data\n"); + else + kprintf("semaphore %ld\n", sem); + break; + } + + case THREAD_BLOCK_TYPE_CONDITION_VARIABLE: + kprintf("condition variable %p\n", thread->wait.object); + break; + + case THREAD_BLOCK_TYPE_SNOOZE: + kprintf("snooze()\n"); + break; + + case THREAD_BLOCK_TYPE_SIGNAL: + kprintf("signal\n"); + break; + + case THREAD_BLOCK_TYPE_CUTEX: + kprintf("cutex %p\n", thread->wait.object); + break; + + case THREAD_BLOCK_TYPE_OTHER: + kprintf("other (%s)\n", (char*)thread->wait.object); + break; + + default: + kprintf("unknown (%p)\n", thread->wait.object); + break; + } + } + kprintf("fault_handler: %p\n", (void *)thread->fault_handler); kprintf("args: %p %p\n", thread->args1, thread->args2); kprintf("entry: %p\n", (void *)thread->entry); @@ -1254,8 +1278,8 @@ kprintf("ignoring invalid team argument.\n"); } - kprintf("thread id state sem/cv cpu pri stack team " - "name\n"); + kprintf("thread id state wait for object cpu pri stack " + " team name\n"); hash_open(sThreadHash, &i); while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { @@ -1268,17 +1292,48 @@ || (realTimeOnly && thread->priority < B_REAL_TIME_DISPLAY_PRIORITY)) continue; - kprintf("%p %6ld %-9s", thread, thread->id, state_to_text(thread, + kprintf("%p %6ld %-10s", thread, thread->id, state_to_text(thread, thread->state)); // does it block on a semaphore or a condition variable? if (thread->state == B_THREAD_WAITING) { - if (get_thread_wait_cvar(thread)) - kprintf("%p ", get_thread_wait_cvar(thread)); - else - kprintf("%10ld ", get_thread_wait_sem(thread)); + switch (thread->wait.type) { + case THREAD_BLOCK_TYPE_SEMAPHORE: + { + sem_id sem = (sem_id)(addr_t)thread->wait.object; + if (sem == thread->msg.read_sem) + kprintf(" "); + else + kprintf("sem %12ld ", sem); + break; + } + + case THREAD_BLOCK_TYPE_CONDITION_VARIABLE: + kprintf("cvar %p ", thread->wait.object); + break; + + case THREAD_BLOCK_TYPE_SNOOZE: + kprintf(" "); + break; + + case THREAD_BLOCK_TYPE_SIGNAL: + kprintf("signal "); + break; + + case THREAD_BLOCK_TYPE_CUTEX: + kprintf("cutex %p ", thread->wait.object); + break; + + case THREAD_BLOCK_TYPE_OTHER: + kprintf("other "); + break; + + default: + kprintf("??? %p ", thread->wait.object); + break; + } } else - kprintf(" - "); + kprintf(" - "); // on which CPU does it run? if (thread->cpu) From bonefish at mail.berlios.de Thu May 1 03:59:10 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 May 2008 03:59:10 +0200 Subject: [Haiku-commits] r25277 - in haiku/trunk: headers/private/kernel src/system/kernel/cache src/system/kernel/vm Message-ID: <200805010159.m411xA3Y031717@sheep.berlios.de> Author: bonefish Date: 2008-05-01 03:59:09 +0200 (Thu, 01 May 2008) New Revision: 25277 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25277&view=rev Modified: haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/system/kernel/vm/vm_daemons.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: Replaced the vm_cache mutex by a cutex. This should save quite a few semaphores. Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/headers/private/kernel/vm_types.h 2008-05-01 01:59:09 UTC (rev 25277) @@ -135,7 +135,7 @@ }; struct vm_cache { - mutex lock; + cutex lock; struct vm_area *areas; vint32 ref_count; struct list_link consumer_link; Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-05-01 01:59:09 UTC (rev 25277) @@ -119,7 +119,7 @@ { if (vm_low_memory_state() != B_NO_LOW_MEMORY) { vm_cache *cache = ref->cache; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (list_is_empty(&cache->consumers) && cache->areas == NULL && access_is_sequential(ref)) { @@ -153,7 +153,7 @@ } } } - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); } vm_page_reserve_pages(reservePages); @@ -208,7 +208,7 @@ } push_access(ref, offset, bufferSize, false); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_page_unreserve_pages(lastReservedPages); // read file into reserved pages @@ -229,7 +229,7 @@ } } - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); for (int32 i = 0; i < pageIndex; i++) { busyConditions[i].Unpublish(); @@ -263,7 +263,7 @@ } reserve_pages(ref, reservePages, false); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); // make the pages accessible in the cache for (int32 i = pageIndex; i-- > 0;) { @@ -292,7 +292,7 @@ vec.iov_len = bufferSize; push_access(ref, offset, bufferSize, false); - mutex_unlock(&ref->cache->lock); + cutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); status_t status = vfs_read_pages(ref->vnode, cookie, offset + pageOffset, @@ -300,7 +300,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, false); - mutex_lock(&ref->cache->lock); + cutex_lock(&ref->cache->lock); return status; } @@ -351,7 +351,7 @@ } push_access(ref, offset, bufferSize, true); - mutex_unlock(&ref->cache->lock); + cutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); // copy contents (and read in partially written pages first) @@ -433,7 +433,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, true); - mutex_lock(&ref->cache->lock); + cutex_lock(&ref->cache->lock); // unmap the pages again @@ -482,7 +482,7 @@ vec.iov_len = bufferSize; push_access(ref, offset, bufferSize, true); - mutex_unlock(&ref->cache->lock); + cutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); status_t status = B_OK; @@ -508,7 +508,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, true); - mutex_lock(&ref->cache->lock); + cutex_lock(&ref->cache->lock); return status; } @@ -604,7 +604,7 @@ size_t reservePages = 0; reserve_pages(ref, lastReservedPages, doWrite); - MutexLocker locker(cache->lock); + CutexLocker locker(cache->lock); while (bytesLeft > 0) { // check if this page is already in memory @@ -780,7 +780,7 @@ off_t lastOffset = offset; size_t lastSize = 0; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); for (; bytesLeft > 0; offset += B_PAGE_SIZE) { // check if this page is already in memory @@ -792,9 +792,9 @@ // if busy retry again later ConditionVariableEntry entry; entry.Add(page); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); entry.Wait(); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); goto restart; } @@ -825,7 +825,7 @@ read_into_cache(ref, lastOffset, lastLeft, NULL, 0); out: - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); #endif } @@ -985,7 +985,7 @@ if (ref == NULL) return B_OK; - MutexLocker _(ref->cache->lock); + CutexLocker _(ref->cache->lock); off_t offset = ref->cache->virtual_size; off_t size = newSize; Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-01 01:59:09 UTC (rev 25277) @@ -1236,7 +1236,7 @@ TRACE(("map_backing_store: aspace %p, cache %p, *vaddr %p, offset 0x%Lx, size %lu, addressSpec %ld, wiring %d, protection %d, _area %p, area_name '%s'\n", addressSpace, cache, *_virtualAddress, offset, size, addressSpec, wiring, protection, _area, areaName)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); vm_area *area = create_area_struct(addressSpace, areaName, wiring, protection); @@ -1267,7 +1267,7 @@ goto err1; } - mutex_lock(&newCache->lock); + cutex_lock(&newCache->lock); newCache->type = CACHE_TYPE_RAM; newCache->temporary = 1; newCache->scan_skip = cache->scan_skip; @@ -1310,7 +1310,7 @@ // point the cache back to the area vm_cache_insert_area_locked(cache, area); if (mapping == REGION_PRIVATE_MAP) - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); // insert the area in the global area hash table acquire_sem_etc(sAreaHashLock, WRITE_COUNT, 0 ,0); @@ -1328,10 +1328,10 @@ // We created this cache, so we must delete it again. Note, that we // need to temporarily unlock the source cache or we'll otherwise // deadlock, since vm_cache_remove_consumer will try to lock it too. - mutex_unlock(&cache->lock); - mutex_unlock(&sourceCache->lock); + cutex_unlock(&cache->lock); + cutex_unlock(&sourceCache->lock); vm_cache_release_ref(cache); - mutex_lock(&sourceCache->lock); + cutex_lock(&sourceCache->lock); } err1: free(area->name); @@ -1525,13 +1525,13 @@ break; } - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); status = map_backing_store(addressSpace, cache, address, 0, size, addressSpec, wiring, protection, REGION_NO_PRIVATE_MAP, &area, name, unmapAddressRange); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); if (status < B_OK) { vm_cache_release_ref(cache); @@ -1554,7 +1554,7 @@ vm_page_reserve_pages(reservePages); // Allocate and map all pages for this area - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); off_t offset = 0; for (addr_t address = area->base; address < area->base + (area->size - 1); @@ -1579,7 +1579,7 @@ vm_map_page(area, page, address, protection); } - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_page_unreserve_pages(reservePages); break; } @@ -1595,7 +1595,7 @@ if (!kernel_startup) panic("ALREADY_WIRED flag used outside kernel startup\n"); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); map->ops->lock(map); for (addr_t virtualAddress = area->base; virtualAddress < area->base @@ -1622,7 +1622,7 @@ } map->ops->unlock(map); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); break; } @@ -1638,7 +1638,7 @@ off_t offset = 0; vm_page_reserve_pages(reservePages); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); map->ops->lock(map); for (virtualAddress = area->base; virtualAddress < area->base @@ -1660,7 +1660,7 @@ } map->ops->unlock(map); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_page_unreserve_pages(reservePages); break; } @@ -1739,13 +1739,13 @@ cache->type = CACHE_TYPE_DEVICE; cache->virtual_size = size; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); status_t status = map_backing_store(locker.AddressSpace(), cache, _address, 0, size, addressSpec & ~B_MTR_MASK, B_FULL_LOCK, protection, REGION_NO_PRIVATE_MAP, &area, name, false); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); if (status < B_OK) vm_cache_release_ref(cache); @@ -1821,13 +1821,13 @@ cache->type = CACHE_TYPE_NULL; cache->virtual_size = size; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); status = map_backing_store(locker.AddressSpace(), cache, address, 0, size, addressSpec, 0, B_KERNEL_READ_AREA, REGION_NO_PRIVATE_MAP, &area, name, false); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); if (status < B_OK) { vm_cache_release_ref(cache); @@ -1929,14 +1929,14 @@ if (status < B_OK) return status; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); vm_area *area; status = map_backing_store(locker.AddressSpace(), cache, _address, offset, size, addressSpec, 0, protection, mapping, &area, name, addressSpec == B_EXACT_ADDRESS); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); if (status < B_OK || mapping == REGION_PRIVATE_MAP) { // map_backing_store() cannot know we no longer need the ref @@ -1971,14 +1971,14 @@ vm_cache_acquire_ref(cache); locker.Unlock(); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); locker.Lock(); if (cache == area->cache) return cache; // the cache changed in the meantime - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); } } @@ -1987,7 +1987,7 @@ void vm_area_put_locked_cache(vm_cache *cache) { - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); } @@ -2207,7 +2207,7 @@ return B_NO_MEMORY; } - mutex_lock(&upperCache->lock); + cutex_lock(&upperCache->lock); upperCache->type = CACHE_TYPE_RAM; upperCache->temporary = 1; @@ -3040,8 +3040,10 @@ kprintf(" virtual_size: 0x%Lx\n", cache->virtual_size); kprintf(" temporary: %ld\n", cache->temporary); kprintf(" scan_skip: %ld\n", cache->scan_skip); + kprintf(" lock: %p\n", &cache->lock); +#ifdef KDEBUG kprintf(" lock.holder: %ld\n", cache->lock.holder); - kprintf(" lock.sem: 0x%lx\n", cache->lock.sem); +#endif kprintf(" areas:\n"); for (vm_area *area = cache->areas; area != NULL; area = area->cache_next) { @@ -3689,15 +3691,6 @@ arch_vm_translation_map_init_post_sem(args); vm_address_space_init_post_sem(); - for (area = vm_kernel_address_space()->areas; area; - area = area->address_space_next) { - if (area->id == RESERVED_AREA_ID) - continue; - - if (area->cache->lock.sem < 0) - mutex_init(&area->cache->lock, "vm_cache"); - } - sAreaHashLock = create_sem(WRITE_COUNT, "area hash"); mutex_init(&sAreaCacheLock, "area->cache"); mutex_init(&sMappingLock, "page mappings"); @@ -3859,10 +3852,10 @@ vm_cache_acquire_ref(source); - mutex_lock(&source->lock); + cutex_lock(&source->lock); if (source->busy) { - mutex_unlock(&source->lock); + cutex_unlock(&source->lock); vm_cache_release_ref(source); goto retry; } @@ -3896,7 +3889,7 @@ { vm_cache *cache = dummyPage.cache; if (!isLocked) - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (dummyPage.state == PAGE_STATE_BUSY) { vm_cache_remove_page(cache, &dummyPage); @@ -3905,7 +3898,7 @@ } if (!isLocked) - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); } @@ -3930,7 +3923,7 @@ vm_page *page = NULL; vm_cache_acquire_ref(cache); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); // we release this later in the loop while (cache != NULL) { @@ -3954,9 +3947,9 @@ { ConditionVariableEntry entry; entry.Add(page); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); entry.Wait(); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); } if (cache->busy) { @@ -3965,7 +3958,7 @@ // the top cache. ConditionVariableEntry entry; entry.Add(cache); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); entry.Wait(); *_restart = true; @@ -3989,7 +3982,7 @@ ConditionVariable busyCondition; busyCondition.Publish(page, "page"); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); // get a virtual address for the page iovec vec; @@ -4004,7 +3997,7 @@ map->ops->put_physical_page((addr_t)vec.iov_base); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (status < B_OK) { // on error remove and free the page @@ -4015,7 +4008,7 @@ vm_cache_remove_page(cache, page); vm_page_set_state(page, PAGE_STATE_FREE); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); return status; } @@ -4038,16 +4031,16 @@ // the source cache is currently in the process of being merged // with his only consumer (cacheRef); since its pages are moved // upwards, too, we try this cache again - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); thread_yield(true); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (cache->busy) { // The cache became busy, which means, it is about to be // removed by vm_cache_remove_consumer(). We start again with // the top cache. ConditionVariableEntry entry; entry.Add(cache); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); entry.Wait(); *_restart = true; @@ -4058,7 +4051,7 @@ } else if (status < B_OK) nextCache = NULL; - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); // at this point, we still hold a ref to this cache (through lastCacheRef) cache = nextCache; @@ -4073,7 +4066,7 @@ // Read-only pages come in the deepest cache - only the // top most cache may have direct write access. vm_cache_acquire_ref(cache); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (cache->busy) { // The cache became busy, which means, it is about to be @@ -4081,7 +4074,7 @@ // the top cache. ConditionVariableEntry entry; entry.Add(cache); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); entry.Wait(); *_restart = true; @@ -4092,7 +4085,7 @@ // for, but it could as well be a dummy page from someone // else or an otherwise busy page. We can't really handle // that here. Hence we completely restart this functions. - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); *_restart = true; } @@ -4135,7 +4128,7 @@ break; // Remove the dummy page, if it has been inserted. - mutex_lock(&topCache->lock); + cutex_lock(&topCache->lock); if (dummyPage.state == PAGE_STATE_BUSY) { ASSERT_PRINT(dummyPage.cache == topCache, "dummy page: %p\n", @@ -4143,7 +4136,7 @@ fault_remove_dummy_page(dummyPage, true); } - mutex_unlock(&topCache->lock); + cutex_unlock(&topCache->lock); } if (page == NULL) { @@ -4182,9 +4175,9 @@ // This is not the top cache into which we inserted the dummy page, // let's remove it from there. We need to temporarily unlock our // cache to comply with the cache locking policy. - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); fault_remove_dummy_page(dummyPage, false); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); } } @@ -4232,8 +4225,8 @@ if (sourcePage->state != PAGE_STATE_MODIFIED) vm_page_set_state(sourcePage, PAGE_STATE_ACTIVE); - mutex_unlock(&cache->lock); - mutex_lock(&topCache->lock); + cutex_unlock(&cache->lock); + cutex_lock(&topCache->lock); // Since the top cache has been unlocked for a while, someone else // (vm_cache_remove_consumer()) might have replaced our dummy page. @@ -4251,9 +4244,9 @@ // The page is busy, wait till it becomes unbusy. ConditionVariableEntry entry; entry.Add(newPage); - mutex_unlock(&topCache->lock); + cutex_unlock(&topCache->lock); entry.Wait(); - mutex_lock(&topCache->lock); + cutex_lock(&topCache->lock); } if (newPage) { @@ -4365,7 +4358,7 @@ } } - mutex_unlock(&topCache->lock); + cutex_unlock(&topCache->lock); // The top most cache has no fault handler, so let's see if the cache or its sources // already have the page we're searching for (we're going from top to bottom) @@ -4415,7 +4408,7 @@ vm_map_page(area, page, address, newProtection); - mutex_unlock(&pageSource->lock); + cutex_unlock(&pageSource->lock); vm_cache_release_ref(pageSource); } Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-05-01 01:59:09 UTC (rev 25277) @@ -159,7 +159,7 @@ if (cache->source) vm_cache_remove_consumer(cache->source, cache); - mutex_destroy(&cache->lock); + cutex_destroy(&cache->lock); free(cache); } @@ -194,14 +194,7 @@ if (cache == NULL) return NULL; - status_t status = mutex_init(&cache->lock, "vm_cache"); - if (status < B_OK && (!kernel_startup || status != B_NO_MORE_SEMS)) { - // During early boot, we cannot create semaphores - they are - // created later in vm_init_post_sem() - free(cache); - return NULL; - } - + cutex_init(&cache->lock, "vm_cache"); list_init_etc(&cache->consumers, offsetof(vm_cache, consumer_link)); cache->page_list = NULL; cache->areas = NULL; @@ -272,7 +265,7 @@ vm_cache* c; bool locked = false; if (cacheRef->lock.holder != find_thread(NULL)) { - mutex_lock(&cacheRef->lock); + cutex_lock(&cacheRef->lock); locked = true; } for (a = cacheRef->areas; a != NULL; a = a->cache_next) @@ -285,7 +278,7 @@ if (cacheRef->ref_count < min) panic("cache_ref %p has too little ref_count!!!!", cacheRef); if (locked) - mutex_unlock(&cacheRef->lock); + cutex_unlock(&cacheRef->lock); } #endif return; @@ -317,7 +310,7 @@ vm_page* vm_cache_lookup_page(vm_cache* cache, off_t offset) { - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); struct page_lookup_key key; key.offset = (uint32)(offset >> PAGE_SHIFT); @@ -343,7 +336,7 @@ { TRACE(("vm_cache_insert_page: cache %p, page %p, offset %Ld\n", cache, page, offset)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); if (page->cache != NULL) { panic("insert page %p into cache %p: page cache is set to %p\n", @@ -390,7 +383,7 @@ vm_cache_remove_page(vm_cache* cache, vm_page* page) { TRACE(("vm_cache_remove_page: cache %p, page %p\n", cache, page)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); if (page->cache != cache) { panic("remove page %p from cache %p: page cache is set to %p\n", page, @@ -428,9 +421,9 @@ if (cache->temporary) return B_OK; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); status_t status = vm_page_write_modified_pages(cache, fsReenter); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); return status; } @@ -445,7 +438,7 @@ { TRACE(("vm_cache_set_minimal_commitment_locked(cache %p, commitment %Ld)\n", cache, commitment)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); vm_store* store = cache->store; status_t status = B_OK; @@ -478,7 +471,7 @@ { TRACE(("vm_cache_resize(cache %p, newSize %Ld) old size %Ld\n", cache, newSize, cache->virtual_size)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); status_t status = cache->store->ops->commit(cache->store, newSize); if (status != B_OK) @@ -509,9 +502,9 @@ // wait for page to become unbusy ConditionVariableEntry entry; entry.Add(page); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); entry.Wait(); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); // restart from the start of the list page = cache->page_list; @@ -541,7 +534,7 @@ vm_cache_remove_consumer(vm_cache* cache, vm_cache* consumer) { TRACE(("remove consumer vm cache %p from cache %p\n", consumer, cache)); - ASSERT_LOCKED_MUTEX(&consumer->lock); + ASSERT_LOCKED_CUTEX(&consumer->lock); // Remove the store ref before locking the cache. Otherwise we'd call into // the VFS while holding the cache lock, which would reverse the usual @@ -550,7 +543,7 @@ cache->store->ops->release_ref(cache->store); // remove the consumer from the cache, but keep its reference until later - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); list_remove_item(&cache->consumers, consumer); consumer->source = NULL; @@ -576,10 +569,10 @@ // need to unlock our cache now busyCondition.Publish(cache, "cache"); cache->busy = true; - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); - mutex_lock(&consumer->lock); - mutex_lock(&cache->lock); + cutex_lock(&consumer->lock); + cutex_lock(&cache->lock); if (cache->areas != NULL || cache->source == NULL || list_is_empty(&cache->consumers) @@ -590,7 +583,7 @@ merge = false; cache->busy = false; busyCondition.Unpublish(); - mutex_unlock(&consumer->lock); + cutex_unlock(&consumer->lock); vm_cache_release_ref(consumer); } } @@ -644,14 +637,14 @@ vm_cache* newSource = cache->source; // The remaining consumer has gotten a new source - mutex_lock(&newSource->lock); + cutex_lock(&newSource->lock); list_remove_item(&newSource->consumers, cache); list_add_item(&newSource->consumers, consumer); consumer->source = newSource; cache->source = NULL; - mutex_unlock(&newSource->lock); + cutex_unlock(&newSource->lock); // Release the other reference to the cache - we take over // its reference of its source cache; we can do this here @@ -661,7 +654,7 @@ panic("cacheRef %p ref count too low!\n", cache); vm_cache_release_ref(cache); - mutex_unlock(&consumer->lock); + cutex_unlock(&consumer->lock); vm_cache_release_ref(consumer); } @@ -669,7 +662,7 @@ busyCondition.Unpublish(); } - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); } @@ -683,8 +676,8 @@ vm_cache_add_consumer_locked(vm_cache* cache, vm_cache* consumer) { TRACE(("add consumer vm cache %p to cache %p\n", consumer, cache)); - ASSERT_LOCKED_MUTEX(&cache->lock); - ASSERT_LOCKED_MUTEX(&consumer->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&consumer->lock); consumer->source = cache; list_add_item(&cache->consumers, consumer); @@ -703,7 +696,7 @@ vm_cache_insert_area_locked(vm_cache* cache, vm_area* area) { TRACE(("vm_cache_insert_area_locked(cache %p, area %p)\n", cache, area)); - ASSERT_LOCKED_MUTEX(&cache->lock); + ASSERT_LOCKED_CUTEX(&cache->lock); area->cache_next = cache->areas; if (area->cache_next) @@ -723,7 +716,7 @@ { TRACE(("vm_cache_remove_area(cache %p, area %p)\n", cache, area)); - MutexLocker locker(cache->lock); + CutexLocker locker(cache->lock); if (area->cache_prev) area->cache_prev->cache_next = area->cache_next; Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2008-05-01 01:59:09 UTC (rev 25277) @@ -66,15 +66,15 @@ return false; if (dontWait) { - if (mutex_trylock(&cache->lock) != B_OK) { + if (cutex_trylock(&cache->lock) != B_OK) { vm_cache_release_ref(cache); return false; } } else - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (cache != page->cache || _IgnorePage(page)) { - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); return false; } @@ -91,7 +91,7 @@ return; vm_cache* cache = fPage->cache; - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); vm_cache_release_ref(cache); fPage = NULL; Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-05-01 01:53:07 UTC (rev 25276) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-05-01 01:59:09 UTC (rev 25277) @@ -1043,7 +1043,7 @@ for (uint32 i = 0; i < numPages; i++) { vm_cache *cache = u.pages[i]->cache; - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); if (writeStatus[i] == B_OK) { // put it into the active queue @@ -1069,7 +1069,7 @@ busyConditions[i].Unpublish(); u.caches[i] = cache; - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); } for (uint32 i = 0; i < numPages; i++) { @@ -1156,12 +1156,10 @@ { fCache = vm_cache_acquire_page_cache_ref(page); if (fCache != NULL) { - if (fCache->lock.holder != thread_get_current_thread_id()) { - if (mutex_trylock(&fCache->lock) != B_OK) - return; + if (cutex_trylock(&fCache->lock) != B_OK) + return; - fOwnsLock = true; - } + fOwnsLock = true; if (fCache == page->cache) fIsLocked = true; @@ -1171,7 +1169,7 @@ ~PageCacheTryLocker() { if (fOwnsLock) - mutex_unlock(&fCache->lock); + cutex_unlock(&fCache->lock); if (fCache != NULL) vm_cache_release_ref(fCache); } @@ -1347,9 +1345,9 @@ // clear the modified flag vm_clear_map_flags(page, PAGE_MODIFIED); - mutex_unlock(&cache->lock); + cutex_unlock(&cache->lock); status_t status = write_page(page, fsReenter); - mutex_lock(&cache->lock); + cutex_lock(&cache->lock); InterruptsSpinLocker locker(&sPageLock); From leavengood at gmail.com Thu May 1 04:11:20 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Wed, 30 Apr 2008 22:11:20 -0400 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <200805010153.m411r95k031376@sheep.berlios.de> References: <200805010153.m411r95k031376@sheep.berlios.de> Message-ID: On 4/30/08, bonefish at BerliOS wrote: > Author: bonefish > > * Introduced a new locking primitive I called "cutex" (sorry for the > name, couldn't resist :-P). Look at you, inventing new locking primitives! Pretty cool. Ryan From umccullough at gmail.com Thu May 1 05:41:04 2008 From: umccullough at gmail.com (Urias McCullough) Date: Wed, 30 Apr 2008 20:41:04 -0700 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: References: <200805010153.m411r95k031376@sheep.berlios.de> Message-ID: <1e80d8750804302041g21bc0fc8vf4e79f775d6c86de@mail.gmail.com> 2008/4/30 Ryan Leavengood : > On 4/30/08, bonefish at BerliOS wrote: > > Author: bonefish > > > > > * Introduced a new locking primitive I called "cutex" (sorry for the > > name, couldn't resist :-P). > > Look at you, inventing new locking primitives! Pretty cool. I had the pleasure of googling it before I saw this message: http://www.cutexnails.com/ From axeld at pinc-software.de Thu May 1 13:05:20 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 01 May 2008 13:05:20 +0200 CEST Subject: [Haiku-commits] =?iso-8859-15?q?r25276_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel_headers/private/kernel/util__src/system/?= =?iso-8859-15?q?kernel?= In-Reply-To: <200805010153.m411r95k031376@sheep.berlios.de> Message-ID: <2402113769-BeMail@zon> bonefish at BerliOS wrote: > Log: > * Introduced a new locking primitive I called "cutex" (sorry for the > name, couldn't resist :-P). It's semantically equivalent to a > mutex, > but doesn't need a semaphore (it uses thread blocking and a simple > queue instead). Initialization can't fail. In fact it is ready to > use > without initialization when living in the bss segment, also in the > early boot process. It's as fast as a benaphore in cases of low > lock > contention, and faster otherwise. Only disadvantage is the higher > immediate memory footprint of 16 bytes. Not that I have anything against your cute little cutexes, but why not just replace the mutex locking primitive with this one? The only potential problem I would see is that the name is no longer allocated, but directly adopted (which would need some review, I wouldn't change that). Later, we could move the r/w locker, too, and eventually remove benaphores completely. The 16 byte footprint is not really a disadvantage, as it's still considerably cheaper than semaphores (which currently weigh in with 40 bytes). Bye, Axel. From axeld at pinc-software.de Thu May 1 13:09:31 2008 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 01 May 2008 13:09:31 +0200 CEST Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <4818C83B.7060404@digintrans.com> Message-ID: <2653991081-BeMail@zon> "Jorge G. Mare (aka Koki)" wrote: > > I don't think there is even a need to specify the format in the UI > > at > > all - it should always use the best and common available, and for > > screen shots, that's clearly a lossless format like PNG. > > If you then need another format, feel free to change that using > > ShowImage. > That's not very user-friendly, particularly in situations where you > need > to take multiple screenshots in a graphic format other than the > default. > By providing the optional popup menu, you save the user the extra > step > of having to do the conversion using a separate app. But how likely a case is that? I would bet that 99% of our users will never get into this situation either. PNG is test best suited format for this task, anyway. IMO one shouldn't bloat any software with functionality that is never going to be used. Bye, Axel. From axeld at mail.berlios.de Thu May 1 13:44:20 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 1 May 2008 13:44:20 +0200 Subject: [Haiku-commits] r25278 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200805011144.m41BiKug018384@sheep.berlios.de> Author: axeld Date: 2008-05-01 13:44:19 +0200 (Thu, 01 May 2008) New Revision: 25278 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25278&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp Log: * As Ingo pointed out to me earlier, TCP could now delete its socket too early when using the shutdown() command. * If TCP no longer needs a socket, it will now set the flag FLAG_DELETE_ON_CLOSE; when the socket is closed from the upper layers, it will set the FLAG_CLOSED flag - and only if both are set, TCP will now delete the socket itself on receive. * This fixes bug #2189. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-01 01:59:09 UTC (rev 25277) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-01 11:44:19 UTC (rev 25278) @@ -219,7 +219,7 @@ // is performed on a listen()ing socket. FLAG_NO_RECEIVE = 0x04, FLAG_CLOSED = 0x08, - FLAG_DELETE = 0x10, + FLAG_DELETE_ON_CLOSE = 0x10, }; @@ -500,7 +500,6 @@ fSendQueue.Used()); } - fFlags |= FLAG_CLOSED; return B_OK; } @@ -512,11 +511,16 @@ MutexLocker _(fLock); - if (fState <= SYNCHRONIZE_SENT || fState == TIME_WAIT) + if (fState <= SYNCHRONIZE_SENT) return B_OK; // we are only interested in the timer, not in changing state _EnterTimeWait(); + + fFlags |= FLAG_CLOSED; + if ((fFlags & FLAG_DELETE_ON_CLOSE) != 0) + return B_OK; + return B_BUSY; // we'll be freed later when the 2MSL timer expires } @@ -1009,14 +1013,15 @@ { TRACE("_EnterTimeWait()\n"); + _CancelConnectionTimers(); + if (fState == TIME_WAIT && fRoute != NULL && (fRoute->flags & RTF_LOCAL) != 0) { // we do not use TIME_WAIT state for local connections - fFlags |= FLAG_DELETE; + fFlags |= FLAG_DELETE_ON_CLOSE; return; } - _CancelConnectionTimers(); _UpdateTimeWait(); } @@ -1106,11 +1111,7 @@ fState = CLOSED; T(State(this)); - if ((fFlags & FLAG_CLOSED) != 0) { - // this socket has been closed already, we don't need to keep - // it around anymore - fFlags |= FLAG_DELETE; - } + fFlags |= FLAG_DELETE_ON_CLOSE; } @@ -1671,7 +1672,8 @@ else if (segmentAction & ACKNOWLEDGE) DelayedAcknowledge(); - if ((fFlags & FLAG_DELETE) != 0) { + if ((fFlags & (FLAG_CLOSED | FLAG_DELETE_ON_CLOSE)) + == (FLAG_CLOSED | FLAG_DELETE_ON_CLOSE)) { locker.Unlock(); gSocketModule->delete_socket(socket); // this will also delete us From ingo_weinhold at gmx.de Thu May 1 14:06:06 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 01 May 2008 14:06:06 +0200 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <2653991081-BeMail@zon> References: <2653991081-BeMail@zon> Message-ID: <20080501140606.566.1@knochen-vm.1209643267.fake> On 2008-05-01 at 13:09:31 [+0200], Axel D?rfler wrote: > "Jorge G. Mare (aka Koki)" wrote: > > > I don't think there is even a need to specify the format in the UI > > > at > > > all - it should always use the best and common available, and for > > > screen shots, that's clearly a lossless format like PNG. > > > If you then need another format, feel free to change that using > > > ShowImage. > > That's not very user-friendly, particularly in situations where you > > need > > to take multiple screenshots in a graphic format other than the > > default. > > By providing the optional popup menu, you save the user the extra > > step > > of having to do the conversion using a separate app. > > But how likely a case is that? I would bet that 99% of our users will > never get into this situation either. PNG is test best suited format > for this task, anyway. > IMO one shouldn't bloat any software with functionality that is never > going to be used. And wasn't there a tool that does batch conversions? CU, Ingo From ingo_weinhold at gmx.de Thu May 1 14:16:53 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 01 May 2008 14:16:53 +0200 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <2402113769-BeMail@zon> References: <2402113769-BeMail@zon> Message-ID: <20080501141653.596.2@knochen-vm.1209643267.fake> On 2008-05-01 at 13:05:20 [+0200], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > Log: > > * Introduced a new locking primitive I called "cutex" (sorry for the > > name, couldn't resist :-P). It's semantically equivalent to a > > mutex, > > but doesn't need a semaphore (it uses thread blocking and a simple > > queue instead). Initialization can't fail. In fact it is ready to > > use > > without initialization when living in the bss segment, also in the > > early boot process. It's as fast as a benaphore in cases of low > > lock > > contention, and faster otherwise. Only disadvantage is the higher > > immediate memory footprint of 16 bytes. > > Not that I have anything against your cute little cutexes, but why not > just replace the mutex locking primitive with this one? > The only potential problem I would see is that the name is no longer > allocated, but directly adopted (which would need some review, I > wouldn't change that). > > Later, we could move the r/w locker, too, and eventually remove > benaphores completely. > The 16 byte footprint is not really a disadvantage, as it's still > considerably cheaper than semaphores > (which currently weigh in with 40 bytes). My thoughts. But exactly because the initialization and the structure size change, and mutex_destroy() wouldn't necessarily unblock anymore, this is a job that involves quite a bit of review, and I also first wanted to see, if my implementation worked at all. :-) CU, Ingo From bonefish at mail.berlios.de Thu May 1 14:43:44 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 May 2008 14:43:44 +0200 Subject: [Haiku-commits] r25279 - haiku/trunk/src/tools/fs_shell Message-ID: <200805011243.m41ChiTg001790@sheep.berlios.de> Author: bonefish Date: 2008-05-01 14:43:29 +0200 (Thu, 01 May 2008) New Revision: 25279 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25279&view=rev Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp Log: Added support for option '-L' (always dereference symbolic links). Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/command_cp.cpp 2008-05-01 11:44:19 UTC (rev 25278) +++ haiku/trunk/src/tools/fs_shell/command_cp.cpp 2008-05-01 12:43:29 UTC (rev 25279) @@ -45,6 +45,7 @@ attributesOnly(false), ignoreAttributes(false), dereference(true), + alwaysDereference(false), force(false), recursive(false) { @@ -54,6 +55,7 @@ bool attributesOnly; bool ignoreAttributes; bool dereference; + bool alwaysDereference; bool force; bool recursive; }; @@ -966,7 +968,7 @@ PathDeleter targetDeleter(targetEntry); fssh_status_t error = copy_entry(sourceDomain, sourceEntry, - targetDomain, targetEntry, options, false); + targetDomain, targetEntry, options, options.alwaysDereference); if (error != FSSH_B_OK) return error; } @@ -1260,6 +1262,10 @@ case 'f': options.force = true; break; + case 'L': + options.dereference = true; + options.alwaysDereference = true; + break; case 'r': options.recursive = true; break; From axeld at pinc-software.de Thu May 1 15:56:30 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 01 May 2008 15:56:30 +0200 CEST Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <20080501141653.596.2@knochen-vm.1209643267.fake> Message-ID: <12672133583-BeMail@zon> Ingo Weinhold wrote: > > Not that I have anything against your cute little cutexes, but why > > not > > just replace the mutex locking primitive with this one? > > The only potential problem I would see is that the name is no > > longer > > allocated, but directly adopted (which would need some review, I > > wouldn't change that). > > > > Later, we could move the r/w locker, too, and eventually remove > > benaphores completely. > > The 16 byte footprint is not really a disadvantage, as it's still > > considerably cheaper than semaphores > > (which currently weigh in with 40 bytes). > My thoughts. But exactly because the initialization and the structure > size > change, and mutex_destroy() wouldn't necessarily unblock anymore, > this is a > job that involves quite a bit of review, and I also first wanted to > see, if > my implementation worked at all. :-) Okay, so you would be okay with removing the cutexes again at a later point? The term "mutex" is just a bit more common, so I would rather keep that one in the long run :-) Anyway, would there be any problem in automatically unblocking on cutext_destroy(), too? I find that is a rather important feature. Bye, Axel. From ingo_weinhold at gmx.de Thu May 1 16:58:06 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 01 May 2008 16:58:06 +0200 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <12672133583-BeMail@zon> References: <12672133583-BeMail@zon> Message-ID: <20080501165806.851.5@knochen-vm.1209643267.fake> On 2008-05-01 at 15:56:30 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > Okay, so you would be okay with removing the cutexes again at a later > point? The term "mutex" is just a bit more common, so I would rather > keep that one in the long run :-) Sure, my plan was exactly what you wrote, i.e. change the mutex code to the new implementation (and also get rid of benaphore). I just didn't want to do that in one go. > Anyway, would there be any problem in automatically unblocking on > cutext_destroy(), too? I find that is a rather important feature. No problem at all. I'm just not quite convinced that's it is not dangerous to use it this way (and really needed anywhere). It would at least require cutex_unblock() to have a return value and the user to actually check it in those cases. CU, Ingo From koki at digintrans.com Thu May 1 17:53:15 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Thu, 01 May 2008 08:53:15 -0700 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <2653991081-BeMail@zon> References: <2653991081-BeMail@zon> Message-ID: <4819E76B.6050200@digintrans.com> Hi Axel, Axel D?rfler wrote: > "Jorge G. Mare (aka Koki)" wrote: > >>> I don't think there is even a need to specify the format in the UI >>> at >>> all - it should always use the best and common available, and for >>> screen shots, that's clearly a lossless format like PNG. >>> If you then need another format, feel free to change that using >>> ShowImage. >>> >> That's not very user-friendly, particularly in situations where you >> need >> to take multiple screenshots in a graphic format other than the >> default. >> By providing the optional popup menu, you save the user the extra >> step >> of having to do the conversion using a separate app. >> > > But how likely a case is that? I would bet that 99% of our users will > never get into this situation either. PNG is test best suited format > for this task, anyway. > IMO one shouldn't bloat any software with functionality that is never > going to be used. > Yes, it is not a very frequent situation; but it does not mean that it will never happen, though. We don't remove the JPEG (or TIFF, or TGA, or...) data translator(s) from Haiku for some reason, don't we? :) I know, for example, of an online service where it is very common for users to upload screenshots that requires JPEG as the format. It is also not that unheard of users asking if it is possible to change the default format used for screenshots by their OS and how. There may be users who prefer to use JPEG to save space too. Another aspect is that this sort of functionality would be a very nice way of showcasing the data translators, something that is unique to BeOS/Haiku, and that can help us differentiate ourselves from other platforms in a way that is compelling. Since we have the data translators, we might as well use them where we can. The ability to select the format selectively and on the fly (as opposed to a global setting) would also add to the Haiku uniqueness. :) All that being said, I don't like code bloat either. So if adding this functionality constitutes code bloat (I don't know, so I will trust the dev's judgment), then I agree that this is not something that we would want. For some reason, though, my guts tell me that the code bloat claim may be a bit exaggerated (please, forgive my candidness :) ). Cheers, Koki From anevilyak at gmail.com Thu May 1 18:38:08 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 1 May 2008 11:38:08 -0500 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <4819E76B.6050200@digintrans.com> References: <2653991081-BeMail@zon> <4819E76B.6050200@digintrans.com> Message-ID: On Thu, May 1, 2008 at 10:53 AM, Jorge G. Mare (aka Koki) wrote: > Yes, it is not a very frequent situation; but it does not mean that it > will never happen, though. We don't remove the JPEG (or TIFF, or TGA, > or...) data translator(s) from Haiku for some reason, don't we? :) > Yes but those translators aren't loaded or anything unless they're actually needed for a translation. That having been said, in my opnion it's an infrequent enough situation that it shouldn't be part of the general UI everyone uses, and should rather be relegated to a batch conversion tool as previously suggested. Adding a setting / popup menu for everything that's going to be used in 1 out of 100 cases is precisely the kind of design that results in bloated apps. Regards, Rene From koki at digintrans.com Thu May 1 18:48:52 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Thu, 01 May 2008 09:48:52 -0700 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <20080501140606.566.1@knochen-vm.1209643267.fake> References: <2653991081-BeMail@zon> <20080501140606.566.1@knochen-vm.1209643267.fake> Message-ID: <4819F474.9070801@digintrans.com> Ingo Weinhold wrote: > On 2008-05-01 at 13:09:31 [+0200], Axel D?rfler > wrote: > >> "Jorge G. Mare (aka Koki)" wrote: >> >>>> I don't think there is even a need to specify the format in the UI >>>> at >>>> all - it should always use the best and common available, and for >>>> screen shots, that's clearly a lossless format like PNG. >>>> If you then need another format, feel free to change that using >>>> ShowImage. >>>> >>> That's not very user-friendly, particularly in situations where you >>> need >>> to take multiple screenshots in a graphic format other than the >>> default. >>> By providing the optional popup menu, you save the user the extra >>> step >>> of having to do the conversion using a separate app. >>> >> But how likely a case is that? I would bet that 99% of our users will >> never get into this situation either. PNG is test best suited format >> for this task, anyway. >> IMO one shouldn't bloat any software with functionality that is never >> going to be used. >> > > And wasn't there a tool that does batch conversions? > Like ImageMagik? :) I am sure there is a batch conversion tool; if there isn't one now, there will most like be one in the future. But let me ask a (less technical and) more fundamental question: Why do we have to force the user to look for and use a separate application, when the need could be addressed in a very subtle and obtrusive way (which is the BeOS/Haiku way) using services already available in the OS for the most part (the data translators, that is)? ShowImage, which can do this trick already when right-click drag-and-dropping onto the desktop, is a good example. One could argue that the drag-and-drop and the ability to select the save format in this app are unnecessary code bloat, as the user could use the menus instead, converting formats is not that frequently used anyway, and the purpose of ShowImage is, well, to show images. :) But ShowImage still provides these features. Why is that? The reason for this, IMO, is that the feature sets of the bundled apps serve two purposes. They provide the user different/better/easier/simpler/more intuitive means to handle the data in their computers, while at the same time they are also a showcase for the unique features and ways that can set Haiku apart from other platforms. IOW, this is one of those opportunities where you could use a common OS feature (screenshot capture) to showcase a unique and powerful aspect of Haiku (data translators). Cheers, Koki From anevilyak at gmail.com Thu May 1 19:25:44 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 1 May 2008 12:25:44 -0500 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <4819F474.9070801@digintrans.com> References: <2653991081-BeMail@zon> <20080501140606.566.1@knochen-vm.1209643267.fake> <4819F474.9070801@digintrans.com> Message-ID: On Thu, May 1, 2008 at 11:48 AM, Jorge G. Mare (aka Koki) wrote: > Why do we have to force the user to look for and use a separate > application, when the need could be addressed in a very subtle and > obtrusive way (which is the BeOS/Haiku way) using services already > available in the OS for the most part (the data translators, that is)? > Because it's not unobtrusive. You're adding an extra step to the process that 90% of people are never, ever going to use. If you're suddenly going to have to take 100 screenshots in a different format for whatever reason, that's precisely the kind of case where something like a batch converter would be a good thing, unless you think picking the format from the context menu 100 times in a row is a friendly way to do it. Regards, Rene From koki at digintrans.com Thu May 1 18:56:09 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Thu, 01 May 2008 09:56:09 -0700 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: References: <2653991081-BeMail@zon> <4819E76B.6050200@digintrans.com> Message-ID: <4819F629.4010507@digintrans.com> Howdy, Rene Gollent wrote: > On Thu, May 1, 2008 at 10:53 AM, Jorge G. Mare (aka Koki) > wrote: > >> Yes, it is not a very frequent situation; but it does not mean that it >> will never happen, though. We don't remove the JPEG (or TIFF, or TGA, >> or...) data translator(s) from Haiku for some reason, don't we? :) >> >> > > Yes but those translators aren't loaded or anything unless they're > actually needed for a translation. Would screen capture require to preload all the translators then? > That having been said, in my opnion > it's an infrequent enough situation that it shouldn't be part of the > general UI everyone uses, You would have to invoke the popup menu, so it does not add to the UI by default. From a UI point of view, it is totally unobtrusive. > and should rather be relegated to a batch > conversion tool as previously suggested. Adding a setting / popup menu > for everything that's going to be used in 1 out of 100 cases is > precisely the kind of design that results in bloated apps. > Feature-wise, this is not much different from the right-click + DND in ShowImage, which has always been there. Please see my response to Ingo. :) Cheers, Koki From bonefish at mail.berlios.de Thu May 1 20:06:09 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 May 2008 20:06:09 +0200 Subject: [Haiku-commits] r25280 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200805011806.m41I69QJ019287@sheep.berlios.de> Author: bonefish Date: 2008-05-01 20:06:09 +0200 (Thu, 01 May 2008) New Revision: 25280 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25280&view=rev Modified: haiku/trunk/headers/private/kernel/lock.h haiku/trunk/src/system/kernel/lock.cpp Log: * Replaced cutex::release_count by flags field. It is only one thread that can unlock the mutex, so one bit is sufficient. * Added cutex_init_etc() which has an additional "flags" parameter. The only specifyable flag is CUTEX_FLAG_CLONE_NAME, which causes the function to strdup() the given name and free() its copy in cutex_destroy(). * cutex_destroy() does now unblock waiting threads. Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2008-05-01 12:43:29 UTC (rev 25279) +++ haiku/trunk/headers/private/kernel/lock.h 2008-05-01 18:06:09 UTC (rev 25280) @@ -49,10 +49,12 @@ #else int32 count; #endif - int32 release_count; + uint8 flags; } cutex; +#define CUTEX_FLAG_CLONE_NAME 0x1 + #if 0 && KDEBUG // XXX disable this for now, it causes problems when including thread.h here # include #define ASSERT_LOCKED_RECURSIVE(r) { ASSERT(thread_get_current_thread_id() == (r)->holder); } @@ -121,22 +123,24 @@ extern void cutex_init(cutex* lock, const char *name); // name is *not* cloned nor freed in cutex_destroy() +extern void cutex_init_etc(cutex* lock, const char *name, uint32 flags); extern void cutex_destroy(cutex* lock); // implementation private: -extern void _cutex_lock(cutex* lock); +extern status_t _cutex_lock(cutex* lock); extern void _cutex_unlock(cutex* lock); extern status_t _cutex_trylock(cutex* lock); -static inline void +static inline status_t cutex_lock(cutex* lock) { #ifdef KDEBUG - _cutex_lock(lock); + return _cutex_lock(lock); #else if (atomic_add(&lock->count, -1) < 0) - _cutex_lock(lock); + return _cutex_lock(lock); + return B_OK; #endif } @@ -149,6 +153,7 @@ #else if (atomic_test_and_set(&lock->count, -1, 0) != 0) return B_WOULD_BLOCK; + return B_OK; #endif } Modified: haiku/trunk/src/system/kernel/lock.cpp =================================================================== --- haiku/trunk/src/system/kernel/lock.cpp 2008-05-01 12:43:29 UTC (rev 25279) +++ haiku/trunk/src/system/kernel/lock.cpp 2008-05-01 18:06:09 UTC (rev 25280) @@ -11,6 +11,9 @@ #include +#include +#include + #include #include @@ -26,7 +29,10 @@ cutex_waiter* last; // last in queue (valid for the first in queue) }; +#define CUTEX_FLAG_OWNS_NAME CUTEX_FLAG_CLONE_NAME +#define CUTEX_FLAG_RELEASED 0x2 + int32 recursive_lock_get_recursion(recursive_lock *lock) { @@ -302,23 +308,67 @@ #else lock->count = 0; #endif - lock->release_count = 0; + lock->flags = 0; } void +cutex_init_etc(cutex* lock, const char *name, uint32 flags) +{ + lock->name = (flags & CUTEX_FLAG_CLONE_NAME) != 0 ? strdup(name) : name; + lock->waiters = NULL; +#ifdef KDEBUG + lock->holder = -1; +#else + lock->count = 0; +#endif + lock->flags = flags & CUTEX_FLAG_CLONE_NAME; +} + + +void cutex_destroy(cutex* lock) { - // no-op + char* name = (lock->flags & CUTEX_FLAG_CLONE_NAME) != 0 + ? (char*)lock->name : NULL; + + // unblock all waiters + InterruptsSpinLocker locker(thread_spinlock); + +#ifdef KDEBUG + if (lock->waiters != NULL && thread_get_current_thread_id() + != lock->holder) { + panic("cutex_destroy(): there are blocking threads, but caller doesn't " + "hold the lock (%p)", lock); + locker.Unlock(); + if (_cutex_lock(lock) != B_OK) + return; + locker.Lock(); + } +#endif + + while (cutex_waiter* waiter = lock->waiters) { + // dequeue + lock->waiters = waiter->next; + + // unblock thread + thread_unblock_locked(waiter->thread, B_ERROR); + } + + lock->name = NULL; + + locker.Unlock(); + + free(name); } -void +status_t _cutex_lock(cutex* lock) { #ifdef KDEBUG if (!kernel_startup && !are_interrupts_enabled()) { - panic("_cutex_unlock: called with interrupts disabled for lock %p", + panic("_cutex_unlock(): called with interrupts disabled for lock %p", lock); } #endif @@ -328,14 +378,16 @@ // Might have been released after we decremented the count, but before // we acquired the spinlock. #ifdef KDEBUG - if (lock->release_count >= 0) { + if (lock->holder <= 0) { lock->holder = thread_get_current_thread_id(); + return B_OK; + } #else - if (lock->release_count > 0) { + if ((lock->flags & CUTEX_FLAG_RELEASED) != 0) { + lock->flags &= ~CUTEX_FLAG_RELEASED; + return B_OK; + } #endif - lock->release_count--; - return; - } // enqueue in waiter list cutex_waiter waiter; @@ -351,11 +403,14 @@ // block thread_prepare_to_block(waiter.thread, 0, THREAD_BLOCK_TYPE_CUTEX, lock); - thread_block_locked(waiter.thread); + status_t error = thread_block_locked(waiter.thread); #ifdef KDEBUG - lock->holder = waiter.thread->id; + if (error == B_OK) + lock->holder = waiter.thread->id; #endif + + return error; } @@ -371,8 +426,6 @@ lock, lock->holder); return; } - - lock->holder = -1; #endif cutex_waiter* waiter = lock->waiters; @@ -384,10 +437,22 @@ // unblock thread thread_unblock_locked(waiter->thread, B_OK); + +#ifdef KDEBUG + // Already set the holder to the unblocked thread. Besides that this + // actually reflects the current situation, setting it to -1 would + // cause a race condition, since another locker could think the lock + // is not held by anyone. + lock->holder = waiter->thread->id; +#endif } else { - // We acquired the spinlock before the locker that is going to wait. - // Just increment the release count. - lock->release_count++; + // We've acquired the spinlock before the locker that is going to wait. + // Just mark the lock as released. +#ifdef KDEBUG + lock->holder = -1; +#else + lock->flags |= CUTEX_FLAG_RELEASED; +#endif } } @@ -398,9 +463,8 @@ #ifdef KDEBUG InterruptsSpinLocker _(thread_spinlock); - if (lock->release_count >= 0) { + if (lock->holder <= 0) { lock->holder = thread_get_current_thread_id(); - lock->release_count--; return B_OK; } #endif @@ -425,7 +489,7 @@ kprintf("cutex %p:\n", lock); kprintf(" name: %s\n", lock->name); - kprintf(" release count: %ld\n", lock->release_count); + kprintf(" flags: 0x%x\n", lock->flags); #ifdef KDEBUG kprintf(" holder: %ld\n", lock->holder); #else From axeld at pinc-software.de Thu May 1 20:14:24 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 01 May 2008 20:14:24 +0200 CEST Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <20080501165806.851.5@knochen-vm.1209643267.fake> Message-ID: <28146281925-BeMail@zon> Ingo Weinhold wrote: > > Okay, so you would be okay with removing the cutexes again at a > > later > > point? The term "mutex" is just a bit more common, so I would > > rather > > keep that one in the long run :-) > Sure, my plan was exactly what you wrote, i.e. change the mutex code > to the > new implementation (and also get rid of benaphore). I just didn't > want to > do that in one go. Ah, great :-) So cutex is also a temputex ;-) > > Anyway, would there be any problem in automatically unblocking on > > cutext_destroy(), too? I find that is a rather important feature. > No problem at all. I'm just not quite convinced that's it is not > dangerous > to use it this way (and really needed anywhere). It would at least > require > cutex_unblock() to have a return value and the user to actually check > it in > those cases. Maybe we're not on the same page. I'm talking about a situation like this: timer try to lock exit if fail else do some work app lock cancel timer destroy lock delete object Incidently, that would be a situation that could happen in TCP :-) If the timer would block forever it couldn't be cancelled (ie. network timer), and you cannot know if the timer fired off and is currently waiting when you would want to destroy the object. But maybe this needs a different solution for cutexes anyway, since the timer must not access the object anymore when it regains control after cutex_lock() failed. Bye, Axel. From superstippi at gmx.de Thu May 1 20:34:09 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 01 May 2008 20:34:09 +0200 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <4819E76B.6050200@digintrans.com> References: <2653991081-BeMail@zon> <4819E76B.6050200@digintrans.com> Message-ID: <20080501183409.3420@gmx.net> -------- Original-Nachricht -------- > Datum: Thu, 01 May 2008 08:53:15 -0700 > Von: "Jorge G. Mare (aka Koki)" > An: SVN commits to the Haiku source repository > Betreff: Re: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app > Hi Axel, > > Axel D?rfler wrote: > > "Jorge G. Mare (aka Koki)" wrote: > > > >>> I don't think there is even a need to specify the format in the UI > >>> at > >>> all - it should always use the best and common available, and for > >>> screen shots, that's clearly a lossless format like PNG. > >>> If you then need another format, feel free to change that using > >>> ShowImage. > >>> > >> That's not very user-friendly, particularly in situations where you > >> need > >> to take multiple screenshots in a graphic format other than the > >> default. > >> By providing the optional popup menu, you save the user the extra > >> step > >> of having to do the conversion using a separate app. > >> > > > > But how likely a case is that? I would bet that 99% of our users will > > never get into this situation either. PNG is test best suited format > > for this task, anyway. > > IMO one shouldn't bloat any software with functionality that is never > > going to be used. > > > > Yes, it is not a very frequent situation; but it does not mean that it > will never happen, though. We don't remove the JPEG (or TIFF, or TGA, > or...) data translator(s) from Haiku for some reason, don't we? :) > > I know, for example, of an online service where it is very common for > users to upload screenshots that requires JPEG as the format. It is also > not that unheard of users asking if it is possible to change the default > format used for screenshots by their OS and how. There may be users who > prefer to use JPEG to save space too. > > Another aspect is that this sort of functionality would be a very nice > way of showcasing the data translators, something that is unique to > BeOS/Haiku, and that can help us differentiate ourselves from other > platforms in a way that is compelling. Since we have the data > translators, we might as well use them where we can. The ability to > select the format selectively and on the fly (as opposed to a global > setting) would also add to the Haiku uniqueness. :) > > All that being said, I don't like code bloat either. So if adding this > functionality constitutes code bloat (I don't know, so I will trust the > dev's judgment), then I agree that this is not something that we would > want. For some reason, though, my guts tell me that the code bloat claim > may be a bit exaggerated (please, forgive my candidness :) ). FWIW, I see it like Koki. I believe it should be doable in a way that it is not bloated, and one could still select the screen shot format. How about the interface kit implements this so that the screenshot is taken, and then sent to the separate screenshot saving app (private clipboard even?)? That way, it wouldn't be a problem even if the app made a Deskbar entry. It could popup a window that has a persistent setting for the format and location, so that one can change it, but doesn't have to. It would simply remember the last used settings and one only has to press ok (or even cancel, if it was unintentional). The window popping up is not such a bad idea, because there would be no feedback otherwise at all, which is a bad thing in itself. How are people supposed to know that something even happend when they pressed Print-Screen? Best regards, -Stephan From koki at digintrans.com Thu May 1 20:45:02 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Thu, 01 May 2008 11:45:02 -0700 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: References: <2653991081-BeMail@zon> <20080501140606.566.1@knochen-vm.1209643267.fake> <4819F474.9070801@digintrans.com> Message-ID: <481A0FAE.4060602@digintrans.com> Rene Gollent wrote: > On Thu, May 1, 2008 at 11:48 AM, Jorge G. Mare (aka Koki) > wrote: > >> Why do we have to force the user to look for and use a separate >> application, when the need could be addressed in a very subtle and >> obtrusive way (which is the BeOS/Haiku way) using services already >> available in the OS for the most part (the data translators, that is)? >> >> > > Because it's not unobtrusive. You're adding an extra step to the > process that 90% of people are never, ever going to use. You seem to have missed this message... https://lists.berlios.de/pipermail/haiku-commits/2008-April/013548.html Modifier keys do wonders, don't they? :) > If you're > suddenly going to have to take 100 screenshots in a different format > for whatever reason, that's precisely the kind of case where something > like a batch converter would be a good thing, unless you think picking > the format from the context menu 100 times in a row is a friendly way > to do it. > I did say "multiple screenshots," but I certainly did not mean 100 screenshots; I was thinking more along the lines of a few screenshots, which would probably be the most common case. For the extreme cases such as the one you bring up, it would be nice if one could come up with a way for Haiku to somehow remember what format you want, as that would make the batch processor unnecessary. Wouldn't that be nice? (I realize this is R2 stuff though.) And even if we were talking about taking only one screenshot, I would still prefer the *option* of invoking a popup menu at the time of taking the screenshot rather than having to go through a multiple step process of opening the captured file in yet another app and making multiple mouse movements/clicks to save it in the format that I want/need. :) Cheers, Koki From axeld at pinc-software.de Thu May 1 23:19:08 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 01 May 2008 23:19:08 +0200 CEST Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <20080501183409.3420@gmx.net> Message-ID: <39230643589-BeMail@zon> "Stephan Assmus" wrote: > FWIW, I see it like Koki. I believe it should be doable in a way that > it is not bloated, > and one could still select the screen shot format. > > How about the interface kit implements this so that the screenshot is > taken, and then > sent to the separate screenshot saving app (private clipboard even?)? > That way, it > wouldn't be a problem even if the app made a Deskbar entry. It could > popup a window > that has a persistent setting for the format and location, so that > one can change it, > but doesn't have to. It would simply remember the last used settings > and one only > has to press ok (or even cancel, if it was unintentional). The window > popping up is > not such a bad idea, because there would be no feedback otherwise at > all, which is a > bad thing in itself. How are people supposed to know that something > even happend > when they pressed Print-Screen? That's a very good point! I didn't know about the screenshot feature on Windows for a long time, and I occasionally took some unintended screenshots in BeOS, when I accidently hit the Print key. I like the private clipboard idea, too, but I don't know how long they are preserved; maybe it would be better to pass the data directly to the app, so that not too much memory is wasted (although the screenshot app could probably also simply delete it afterwards). And this also solves the potential problem that you need to access the disk before actually taking the shot. The current window (which triggers the screenshot) could then also pass its current location and size to the screenshot app, so that you could then decide in the screenshot app wether or not the whole screen or just the active window should be saved. Well, you two managed to convince me, thanks :-) But what's Ryan's opinion who wanted to actually implement it? Bye, Axel. From ingo_weinhold at gmx.de Thu May 1 23:46:03 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 01 May 2008 23:46:03 +0200 Subject: [Haiku-commits] r25276 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/system/kernel In-Reply-To: <28146281925-BeMail@zon> References: <28146281925-BeMail@zon> Message-ID: <20080501234603.1294.6@knochen-vm.1209643267.fake> On 2008-05-01 at 20:14:24 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > > Okay, so you would be okay with removing the cutexes again at a > > > later > > > point? The term "mutex" is just a bit more common, so I would > > > rather > > > keep that one in the long run :-) > > Sure, my plan was exactly what you wrote, i.e. change the mutex code > > to the > > new implementation (and also get rid of benaphore). I just didn't > > want to > > do that in one go. > > Ah, great :-) > So cutex is also a temputex ;-) Yeah, even more so than I originally thought. I intended to let things simmer for a few weeks, but after grepping through the sources, the overall work seems to be less than expected. > > > Anyway, would there be any problem in automatically unblocking on > > > cutext_destroy(), too? I find that is a rather important feature. > > No problem at all. I'm just not quite convinced that's it is not > > dangerous > > to use it this way (and really needed anywhere). It would at least > > require > > cutex_unblock() to have a return value and the user to actually check > > it in > > those cases. > > Maybe we're not on the same page. I'm talking about a situation like > this: > > timer > try to lock > exit if fail > else > do some work > > app > lock > cancel timer > destroy lock > delete object > > Incidently, that would be a situation that could happen in TCP :-) > If the timer would block forever it couldn't be cancelled (ie. network > timer), and you cannot know if the timer fired off and is currently > waiting when you would want to destroy the object. If the lock is located on the object and the above "delete object" actually deletes the object (and not just decrements its ref count), then I'd say it is indeed buggy. Since "cancel timer" obviously cannot wait for the timer thread to complete the work (deadlock chance), you could be deleting the object before the timer thread accesses the lock (and thus the object). That's of course the problem of the code using the locking API, not of the API itself. I was just wondering whether it might be a good idea to make such code impossible in the first place by restricting the API. As in the case above I believe it's generally possible to use ref counting and a flag to mark the object invalid instead. > But maybe this needs a different solution for cutexes anyway, since the > timer must not access the object anymore when it regains control after > cutex_lock() failed. Nor before it is even called, which is the actual problem here. :-) CU, Ingo From leavengood at gmail.com Thu May 1 23:49:26 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 1 May 2008 17:49:26 -0400 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <39230643589-BeMail@zon> References: <20080501183409.3420@gmx.net> <39230643589-BeMail@zon> Message-ID: On 5/1/08, Axel D?rfler wrote: > > Well, you two managed to convince me, thanks :-) > But what's Ryan's opinion who wanted to actually implement it? For now I am starting with something simple: a command-line application that takes a screenshot when invoked. The BWindow keyboard handler will just Launch that with be_roster. There will be no passing of bitmaps around. I have a simple version working already. I figure I can add options for what part of the screen to capture, what format to save in, and a delay before taking the screenshot. The defaults will be the full screen in PNG with no delay. If the person holds shift when pressing Print Screen only the current window will be captured (by sending it's frame as the frame to capture.) This does not capture the decorators though, but that is for another day I think :) I may add some kind of notification that a screenshot was taken, but that is probably it for now. Ryan From bonefish at mail.berlios.de Thu May 1 23:53:14 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 1 May 2008 23:53:14 +0200 Subject: [Haiku-commits] r25281 - haiku/trunk/src/system/kernel Message-ID: <200805012153.m41LrED7015791@sheep.berlios.de> Author: bonefish Date: 2008-05-01 23:53:12 +0200 (Thu, 01 May 2008) New Revision: 25281 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25281&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: Also hold the threads lock when removing a team from the team hash table. This is not necessary, but allows for a better solution fo how to lock the IO context of another team. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-01 18:06:09 UTC (rev 25280) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-01 21:53:12 UTC (rev 25281) @@ -2159,7 +2159,14 @@ 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, + // grab threads lock, unlock teams lock, + // mutex_lock_threads_lock(), as used in the VFS code to + // lock another team's IO context. + GRAB_THREAD_LOCK(); hash_remove(sTeamHash, team); + RELEASE_THREAD_LOCK(); sUsedTeams--; team->state = TEAM_STATE_DEATH; From anevilyak at gmail.com Thu May 1 23:53:52 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 1 May 2008 16:53:52 -0500 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: References: <20080501183409.3420@gmx.net> <39230643589-BeMail@zon> Message-ID: On Thu, May 1, 2008 at 4:49 PM, Ryan Leavengood wrote: > I may add some kind of notification that a screenshot was taken, but > that is probably it for now. > If I'm remembering correctly, pre-OSX MacOS used to do this by making a camera sound when you hit the button, perhaps something along those lines could work as a nice, reasonably unobtrusive cue? Or maybe a notification along the lines of what's possible with infopopper? Regards, Rene From anevilyak at gmail.com Thu May 1 23:54:41 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 1 May 2008 16:54:41 -0500 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <39230643589-BeMail@zon> References: <20080501183409.3420@gmx.net> <39230643589-BeMail@zon> Message-ID: On Thu, May 1, 2008 at 4:19 PM, Axel D?rfler wrote: > That's a very good point! I didn't know about the screenshot feature on > Windows for a long time, and I occasionally took some unintended > screenshots in BeOS, when I accidently hit the Print key. > I like the private clipboard idea, too, but I don't know how long they > are preserved; maybe it would be better to pass the data directly to > the app, so that not too much memory is wasted (although the screenshot > app could probably also simply delete it afterwards). And this also > solves the potential problem that you need to access the disk before > actually taking the shot. > > The current window (which triggers the screenshot) could then also pass > its current location and size to the screenshot app, so that you could > then decide in the screenshot app wether or not the whole screen or > just the active window should be saved. > > Well, you two managed to convince me, thanks :-) +1, those are very good points. Sorry if I came off a bit antagonistic there, but I really really dislike feature creep :) Regards, Rene From koki at digintrans.com Thu May 1 23:56:00 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Thu, 01 May 2008 14:56:00 -0700 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <39230643589-BeMail@zon> References: <39230643589-BeMail@zon> Message-ID: <481A3C70.9090301@digintrans.com> Axel D?rfler wrote: > "Stephan Assmus" wrote: > >> FWIW, I see it like Koki. I believe it should be doable in a way that >> it is not bloated, >> and one could still select the screen shot format. >> >> How about the interface kit implements this so that the screenshot is >> taken, and then >> sent to the separate screenshot saving app (private clipboard even?)? >> That way, it >> wouldn't be a problem even if the app made a Deskbar entry. It could >> popup a window >> that has a persistent setting for the format and location, so that >> one can change it, >> but doesn't have to. It would simply remember the last used settings >> and one only >> has to press ok (or even cancel, if it was unintentional). The window >> popping up is >> not such a bad idea, because there would be no feedback otherwise at >> all, which is a >> bad thing in itself. How are people supposed to know that something >> even happend >> when they pressed Print-Screen? >> > > That's a very good point! I didn't know about the screenshot feature on > Windows for a long time, and I occasionally took some unintended > screenshots in BeOS, when I accidently hit the Print key. > I like the private clipboard idea, too, but I don't know how long they > are preserved; maybe it would be better to pass the data directly to > the app, so that not too much memory is wasted (although the screenshot > app could probably also simply delete it afterwards). And this also > solves the potential problem that you need to access the disk before > actually taking the shot. > > The current window (which triggers the screenshot) could then also pass > its current location and size to the screenshot app, so that you could > then decide in the screenshot app wether or not the whole screen or > just the active window should be saved. > > Well, you two managed to convince me, thanks :-) > Yay! :) > But what's Ryan's opinion who wanted to actually implement it? > Yes, of course, the one million dollar question. :) Cheers, Koki From mmu_man at mail.berlios.de Thu May 1 23:59:46 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 1 May 2008 23:59:46 +0200 Subject: [Haiku-commits] r25282 - haiku/trunk/src/bin/strace Message-ID: <200805012159.m41LxkOu016681@sheep.berlios.de> Author: mmu_man Date: 2008-05-01 23:59:46 +0200 (Thu, 01 May 2008) New Revision: 25282 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25282&view=rev Modified: haiku/trunk/src/bin/strace/Jamfile haiku/trunk/src/bin/strace/ioctl.cpp Log: Some more ioctls... Modified: haiku/trunk/src/bin/strace/Jamfile =================================================================== --- haiku/trunk/src/bin/strace/Jamfile 2008-05-01 21:53:12 UTC (rev 25281) +++ haiku/trunk/src/bin/strace/Jamfile 2008-05-01 21:59:46 UTC (rev 25282) @@ -1,6 +1,8 @@ SubDir HAIKU_TOP src bin strace ; UseArchHeaders $(TARGET_ARCH) ; +UsePrivateHeaders device ; +UsePrivateHeaders drivers ; UsePrivateHeaders kernel ; UsePrivateHeaders shared ; UsePrivateHeaders net ; Modified: haiku/trunk/src/bin/strace/ioctl.cpp =================================================================== --- haiku/trunk/src/bin/strace/ioctl.cpp 2008-05-01 21:53:12 UTC (rev 25281) +++ haiku/trunk/src/bin/strace/ioctl.cpp 2008-05-01 21:59:46 UTC (rev 25282) @@ -8,6 +8,9 @@ #include #include +#include +#include +#include #include "strace.h" #include "Syscall.h" @@ -26,6 +29,40 @@ { name, #name, TypeHandlerFactory::Create() } static const ioctl_info kIOCtls[] = { + // + IOCTL_INFO_ENTRY_TYPE(B_GET_DEVICE_SIZE, size_t *), + IOCTL_INFO_ENTRY_TYPE(B_SET_DEVICE_SIZE, size_t *), + IOCTL_INFO_ENTRY(B_SET_NONBLOCKING_IO), + IOCTL_INFO_ENTRY(B_SET_BLOCKING_IO), + IOCTL_INFO_ENTRY(B_GET_READ_STATUS), + IOCTL_INFO_ENTRY(B_GET_WRITE_STATUS), + IOCTL_INFO_ENTRY(B_GET_GEOMETRY), + IOCTL_INFO_ENTRY(B_GET_DRIVER_FOR_DEVICE), + IOCTL_INFO_ENTRY(B_GET_PARTITION_INFO), + IOCTL_INFO_ENTRY(B_SET_PARTITION), + IOCTL_INFO_ENTRY(B_FORMAT_DEVICE), + IOCTL_INFO_ENTRY(B_EJECT_DEVICE), + IOCTL_INFO_ENTRY(B_GET_ICON), + IOCTL_INFO_ENTRY(B_GET_BIOS_GEOMETRY), + IOCTL_INFO_ENTRY(B_GET_MEDIA_STATUS), + IOCTL_INFO_ENTRY(B_LOAD_MEDIA), + IOCTL_INFO_ENTRY(B_GET_BIOS_DRIVE_ID), + IOCTL_INFO_ENTRY(B_SET_UNINTERRUPTABLE_IO), + IOCTL_INFO_ENTRY(B_SET_INTERRUPTABLE_IO), + IOCTL_INFO_ENTRY(B_FLUSH_DRIVE_CACHE), + IOCTL_INFO_ENTRY(B_GET_PATH_FOR_DEVICE), + IOCTL_INFO_ENTRY(B_GET_NEXT_OPEN_DEVICE), + IOCTL_INFO_ENTRY(B_ADD_FIXED_DRIVER), + IOCTL_INFO_ENTRY(B_REMOVE_FIXED_DRIVER), + + /* + IOCTL_INFO_ENTRY(B_AUDIO_DRIVER_BASE), // conflicts + IOCTL_INFO_ENTRY(B_MIDI_DRIVER_BASE), + IOCTL_INFO_ENTRY(B_JOYSTICK_DRIVER_BASE), + IOCTL_INFO_ENTRY(B_GRAPHIC_DRIVER_BASE), + IOCTL_INFO_ENTRY(B_DEVICE_OP_CODES_END), + */ + // IOCTL_INFO_ENTRY(SIOCADDRT), IOCTL_INFO_ENTRY(SIOCDELRT), @@ -85,7 +122,30 @@ IOCTL_INFO_ENTRY(TCVTIME), IOCTL_INFO_ENTRY(TIOCGPGRP), IOCTL_INFO_ENTRY(TIOCSPGRP), + // private termios + IOCTL_INFO_ENTRY(B_IOCTL_GET_TTY_INDEX), + IOCTL_INFO_ENTRY(B_IOCTL_GRANT_TTY), + // scsi ioctls + IOCTL_INFO_ENTRY(B_SCSI_SCAN_FOR_DEVICES), + IOCTL_INFO_ENTRY(B_SCSI_ENABLE_PROFILING), + IOCTL_INFO_ENTRY(B_SCSI_INQUIRY), + IOCTL_INFO_ENTRY(B_SCSI_EJECT), + IOCTL_INFO_ENTRY(B_SCSI_PREVENT_ALLOW), + IOCTL_INFO_ENTRY(B_RAW_DEVICE_COMMAND), + IOCTL_INFO_ENTRY(B_SCSI_GET_TOC), + IOCTL_INFO_ENTRY(B_SCSI_PLAY_TRACK), + IOCTL_INFO_ENTRY(B_SCSI_PLAY_POSITION), + IOCTL_INFO_ENTRY(B_SCSI_STOP_AUDIO), + IOCTL_INFO_ENTRY(B_SCSI_PAUSE_AUDIO), + IOCTL_INFO_ENTRY(B_SCSI_RESUME_AUDIO), + IOCTL_INFO_ENTRY(B_SCSI_GET_POSITION), + IOCTL_INFO_ENTRY(B_SCSI_SET_VOLUME), + IOCTL_INFO_ENTRY(B_SCSI_GET_VOLUME), + IOCTL_INFO_ENTRY(B_SCSI_READ_CD), + IOCTL_INFO_ENTRY(B_SCSI_SCAN), + IOCTL_INFO_ENTRY(B_SCSI_DATA_MODE), + { -1, NULL, NULL } }; From bonefish at mail.berlios.de Fri May 2 00:07:41 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 00:07:41 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os Message-ID: <200805012207.m41M7fFS017717@sheep.berlios.de> Author: bonefish Date: 2008-05-02 00:07:36 +0200 (Fri, 02 May 2008) New Revision: 25283 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25283&view=rev Modified: haiku/trunk/headers/private/kernel/lock.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/headers/private/kernel/util/AutoLock.h haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp haiku/trunk/src/add-ons/kernel/file_cache/log.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h haiku/trunk/src/libs/compat/freebsd_network/mutex.c haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c haiku/trunk/src/system/kernel/Notifications.cpp haiku/trunk/src/system/kernel/arch/generic/generic_vm_physical_page_mapper.cpp haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/fs/IOScheduler.cpp haiku/trunk/src/system/kernel/fs/rootfs.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/kernel/heap.cpp haiku/trunk/src/system/kernel/image.c haiku/trunk/src/system/kernel/kernel_daemon.c haiku/trunk/src/system/kernel/lock.cpp haiku/trunk/src/system/kernel/syscalls.cpp haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/kernel/util/cbuf.c haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/system/kernel/vm/vm_daemons.cpp haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp haiku/trunk/src/system/libroot/os/driver_settings.c Log: * Removed old mutex implementation and renamed cutex to mutex. * Trivial adjustments of code using mutexes. Mostly removing the mutex_init() return value check. * Added mutex_lock_threads_locked(), which is called with the threads spinlock being held. The spinlock is released while waiting, of course. This function is useful in cases where the existence of the mutex object is ensured by holding the threads spinlock. * Changed the two instances in the VFS code where an IO context of another team needs to be locked to use mutex_lock_threads_locked(). Before it required a semaphore-based mutex implementation. Modified: haiku/trunk/headers/private/kernel/lock.h =================================================================== --- haiku/trunk/headers/private/kernel/lock.h 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/headers/private/kernel/lock.h 2008-05-01 22:07:36 UTC (rev 25283) @@ -1,4 +1,5 @@ /* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * @@ -18,11 +19,6 @@ int recursion; } recursive_lock; -typedef struct mutex { - sem_id sem; - thread_id holder; -} mutex; - typedef struct benaphore { sem_id sem; int32 count; @@ -39,31 +35,29 @@ #define RW_MAX_READERS 1000000 -struct cutex_waiter; +struct mutex_waiter; -typedef struct cutex { +typedef struct mutex { const char* name; - struct cutex_waiter* waiters; + struct mutex_waiter* waiters; #ifdef KDEBUG thread_id holder; #else int32 count; #endif uint8 flags; -} cutex; +} mutex; -#define CUTEX_FLAG_CLONE_NAME 0x1 +#define MUTEX_FLAG_CLONE_NAME 0x1 #if 0 && KDEBUG // XXX disable this for now, it causes problems when including thread.h here # include #define ASSERT_LOCKED_RECURSIVE(r) { ASSERT(thread_get_current_thread_id() == (r)->holder); } #define ASSERT_LOCKED_MUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); } -#define ASSERT_LOCKED_CUTEX(m) { ASSERT(thread_get_current_thread_id() == (m)->holder); } #else #define ASSERT_LOCKED_RECURSIVE(r) #define ASSERT_LOCKED_MUTEX(m) -#define ASSERT_LOCKED_CUTEX(m) #endif @@ -77,12 +71,6 @@ extern void recursive_lock_unlock(recursive_lock *lock); extern int32 recursive_lock_get_recursion(recursive_lock *lock); -extern status_t mutex_init(mutex *m, const char *name); -extern void mutex_destroy(mutex *m); -extern status_t mutex_trylock(mutex *mutex); -extern status_t mutex_lock(mutex *m); -extern void mutex_unlock(mutex *m); - extern status_t benaphore_init(benaphore *ben, const char *name); extern void benaphore_destroy(benaphore *ben); @@ -121,36 +109,49 @@ extern status_t rw_lock_write_lock(rw_lock *lock); extern status_t rw_lock_write_unlock(rw_lock *lock); -extern void cutex_init(cutex* lock, const char *name); - // name is *not* cloned nor freed in cutex_destroy() -extern void cutex_init_etc(cutex* lock, const char *name, uint32 flags); -extern void cutex_destroy(cutex* lock); +extern void mutex_init(mutex* lock, const char *name); + // name is *not* cloned nor freed in mutex_destroy() +extern void mutex_init_etc(mutex* lock, const char *name, uint32 flags); +extern void mutex_destroy(mutex* lock); // implementation private: -extern status_t _cutex_lock(cutex* lock); -extern void _cutex_unlock(cutex* lock); -extern status_t _cutex_trylock(cutex* lock); +extern status_t _mutex_lock(mutex* lock, bool threadsLocked); +extern void _mutex_unlock(mutex* lock); +extern status_t _mutex_trylock(mutex* lock); static inline status_t -cutex_lock(cutex* lock) +mutex_lock(mutex* lock) { #ifdef KDEBUG - return _cutex_lock(lock); + return _mutex_lock(lock, false); #else if (atomic_add(&lock->count, -1) < 0) - return _cutex_lock(lock); + return _mutex_lock(lock, false); return B_OK; #endif } static inline status_t -cutex_trylock(cutex* lock) +mutex_lock_threads_locked(mutex* lock) { #ifdef KDEBUG - return _cutex_trylock(lock); + return _mutex_lock(lock, true); #else + if (atomic_add(&lock->count, -1) < 0) + return _mutex_lock(lock, true); + return B_OK; +#endif +} + + +static inline status_t +mutex_trylock(mutex* lock) +{ +#ifdef KDEBUG + return _mutex_trylock(lock); +#else if (atomic_test_and_set(&lock->count, -1, 0) != 0) return B_WOULD_BLOCK; return B_OK; @@ -159,13 +160,13 @@ static inline void -cutex_unlock(cutex* lock) +mutex_unlock(mutex* lock) { #ifdef KDEBUG - _cutex_unlock(lock); + _mutex_unlock(lock); #else if (atomic_add(&lock->count, 1) < -1) - _cutex_unlock(lock); + _mutex_unlock(lock); #endif } Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-05-01 22:07:36 UTC (rev 25283) @@ -62,7 +62,7 @@ THREAD_BLOCK_TYPE_CONDITION_VARIABLE = 1, THREAD_BLOCK_TYPE_SNOOZE = 2, THREAD_BLOCK_TYPE_SIGNAL = 3, - THREAD_BLOCK_TYPE_CUTEX = 4, + THREAD_BLOCK_TYPE_MUTEX = 4, THREAD_BLOCK_TYPE_OTHER = 9999, THREAD_BLOCK_TYPE_USER_BASE = 10000 Modified: haiku/trunk/headers/private/kernel/util/AutoLock.h =================================================================== --- haiku/trunk/headers/private/kernel/util/AutoLock.h 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/headers/private/kernel/util/AutoLock.h 2008-05-01 22:07:36 UTC (rev 25283) @@ -67,24 +67,6 @@ // BenaphoreLocker typedef AutoLocker BenaphoreLocker; -// CutexLocking -class CutexLocking { -public: - inline bool Lock(cutex *lockable) - { - cutex_lock(lockable); - return true; - } - - inline void Unlock(cutex *lockable) - { - cutex_unlock(lockable); - } -}; - -// CutexLocker -typedef AutoLocker CutexLocker; - // InterruptsLocking class InterruptsLocking { public: @@ -171,7 +153,6 @@ using BPrivate::MutexLocker; using BPrivate::RecursiveLocker; using BPrivate::BenaphoreLocker; -using BPrivate::CutexLocker; using BPrivate::InterruptsLocker; using BPrivate::SpinLocker; using BPrivate::InterruptsSpinLocker; Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/headers/private/kernel/vm_types.h 2008-05-01 22:07:36 UTC (rev 25283) @@ -135,7 +135,7 @@ }; struct vm_cache { - cutex lock; + mutex lock; struct vm_area *areas; vint32 ref_count; struct list_link consumer_link; Modified: haiku/trunk/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c 2008-05-01 22:07:36 UTC (rev 25283) @@ -265,8 +265,7 @@ if (keyboard_sem < 0) panic("could not create keyboard sem!\n"); - if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0) - panic("could not create keyboard read mutex!\n"); + mutex_init(&keyboard_read_mutex, "keyboard_read_mutex"); shift = false; sControl = false; Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -51,26 +51,17 @@ memset(gDeviceNames, 0, sizeof(gDeviceNames)); - // create the global mutex - status_t error = mutex_init(&gGlobalTTYLock, "tty global"); + // create the request mutex + status_t error = recursive_lock_init(&gTTYRequestLock, "tty requests"); if (error != B_OK) return error; + // create the global mutex + mutex_init(&gGlobalTTYLock, "tty global"); + // create the cookie mutex - error = mutex_init(&gTTYCookieLock, "tty cookies"); - if (error != B_OK) { - mutex_destroy(&gGlobalTTYLock); - return error; - } + mutex_init(&gTTYCookieLock, "tty cookies"); - // create the request mutex - error = recursive_lock_init(&gTTYRequestLock, "tty requests"); - if (error != B_OK) { - mutex_destroy(&gTTYCookieLock); - mutex_destroy(&gGlobalTTYLock); - return error; - } - // create driver name array and initialize basic TTY structures char letter = 'p'; Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/master.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -42,13 +42,9 @@ if (cookie == NULL) return B_NO_MEMORY; - status_t error = mutex_init(&cookie->lock, "tty lock"); - if (error != B_OK) { - free(cookie); - return error; - } + mutex_init(&cookie->lock, "tty lock"); - error = init_tty_cookie(cookie, master, slave, openMode); + status_t error = init_tty_cookie(cookie, master, slave, openMode); if (error != B_OK) { mutex_destroy(&cookie->lock); free(cookie); Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -1866,7 +1866,7 @@ kprintf(" open_count: %ld\n", tty.open_count); kprintf(" select_pool: %p\n", tty.select_pool); kprintf(" pending_eof: %lu\n", tty.pending_eof); - kprintf(" lock.sem: %ld\n", tty.lock->sem); + kprintf(" lock: %ld\n", &tty.lock); kprintf(" input_buffer:\n"); kprintf(" first: %ld\n", tty.input_buffer.first); Modified: haiku/trunk/src/add-ons/kernel/file_cache/log.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_cache/log.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/file_cache/log.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -386,14 +386,12 @@ sLogEntrySem = create_sem(kNumLogEntries, "cache log entries"); if (sLogEntrySem >= B_OK) { - if (mutex_init(&sLock, "log cache module") >= B_OK) { - register_kernel_daemon(log_writer_daemon, NULL, kLogWriterFrequency); - register_generic_syscall(CACHE_LOG_SYSCALLS, log_control, 1, 0); + mutex_init(&sLock, "log cache module"); + register_kernel_daemon(log_writer_daemon, NULL, kLogWriterFrequency); + register_generic_syscall(CACHE_LOG_SYSCALLS, log_control, 1, 0); - TRACE(("** - log init\n")); - return B_OK; - } - delete_sem(sLogEntrySem); + TRACE(("** - log init\n")); + return B_OK; } close(sLogFile); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -429,9 +429,6 @@ status_t TCPEndpoint::InitCheck() const { - if (fLock.sem < B_OK) - return fLock.sem; - if (fReceiveList.InitCheck() < B_OK) return fReceiveList.InitCheck(); @@ -2175,7 +2172,9 @@ kprintf("TCP endpoint %p\n", this); kprintf(" state: %s\n", name_for_state(fState)); kprintf(" flags: 0x%lx\n", fFlags); - kprintf(" lock: { sem: %ld, holder: %ld }\n", fLock.sem, fLock.holder); +#ifdef KDEBUG + kprintf(" lock: { %p, holder: %ld }\n", &fLock, fLock.holder); +#endif kprintf(" accept sem: %ld\n", fAcceptSemaphore); kprintf(" options: 0x%lx\n", (uint32)fOptions); kprintf(" send\n"); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/tcp.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -721,13 +721,10 @@ static status_t tcp_init() { - status_t status = mutex_init(&sEndpointManagersLock, - "endpoint managers lock"); + mutex_init(&sEndpointManagersLock, "endpoint managers lock"); - if (status < B_OK) - return status; - - status = gStackModule->register_domain_protocols(AF_INET, SOCK_STREAM, 0, + status_t status = gStackModule->register_domain_protocols(AF_INET, + SOCK_STREAM, 0, "network/protocols/tcp/v1", "network/protocols/ipv4/v1", NULL); Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/haiku-module.h 2008-05-01 22:07:36 UTC (rev 25283) @@ -9,7 +9,7 @@ #include #include -#include +#include #include #undef ASSERT Modified: haiku/trunk/src/libs/compat/freebsd_network/mutex.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/mutex.c 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/libs/compat/freebsd_network/mutex.c 2008-05-01 22:07:36 UTC (rev 25283) @@ -20,8 +20,7 @@ mtx_init(struct mtx *m, const char *name, const char *type, int opts) { if (opts == MTX_DEF) { - if (mutex_init(&m->u.mutex, name) < B_OK) - panic("Panic! Dance like it's 1979, we ran out of semaphores"); + mutex_init_etc(&m->u.mutex, name, MUTEX_FLAG_CLONE_NAME); } else if (opts == MTX_RECURSE) { if (recursive_lock_init(&m->u.recursive, name) < B_OK) panic("Hell just froze as someone was trying to init a recursive mutex."); Modified: haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/libs/compat/freebsd_network/taskqueue.c 2008-05-01 22:07:36 UTC (rev 25283) @@ -45,10 +45,7 @@ if (fast) { tq->tq_spinlock = 0; } else { - if (mutex_init(&tq->tq_mutex, name) < B_OK) { - free(tq); - return NULL; - } + mutex_init_etc(&tq->tq_mutex, name, MUTEX_FLAG_CLONE_NAME); } strlcpy(tq->tq_name, name, sizeof(tq->tq_name)); Modified: haiku/trunk/src/system/kernel/Notifications.cpp =================================================================== --- haiku/trunk/src/system/kernel/Notifications.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/Notifications.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -154,9 +154,7 @@ status_t NotificationManager::_Init() { - status_t status = mutex_init(&fLock, "notification manager"); - if (status < B_OK) - return status; + mutex_init(&fLock, "notification manager"); return fServiceHash.InitCheck(); } Modified: haiku/trunk/src/system/kernel/arch/generic/generic_vm_physical_page_mapper.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/generic/generic_vm_physical_page_mapper.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/arch/generic/generic_vm_physical_page_mapper.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -282,8 +282,7 @@ memset(virtual_pmappings, 0, sizeof(paddr_chunk_desc *) * num_virtual_chunks); first_free_vmapping = 0; queue_init(&mapped_paddr_lru); - sMutex.sem = -1; - sMutex.holder = -1; + mutex_init(&sMutex, "iospace_mutex"); sChunkAvailableSem = -1; TRACE(("generic_vm_physical_page_mapper_init: done\n")); @@ -332,7 +331,6 @@ status_t generic_vm_physical_page_mapper_init_post_sem(kernel_args *args) { - mutex_init(&sMutex, "iospace_mutex"); sChunkAvailableSem = create_sem(1, "iospace chunk available"); return sChunkAvailableSem >= B_OK ? B_OK : sChunkAvailableSem; Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -119,7 +119,7 @@ { if (vm_low_memory_state() != B_NO_LOW_MEMORY) { vm_cache *cache = ref->cache; - cutex_lock(&cache->lock); + mutex_lock(&cache->lock); if (list_is_empty(&cache->consumers) && cache->areas == NULL && access_is_sequential(ref)) { @@ -153,7 +153,7 @@ } } } - cutex_unlock(&cache->lock); + mutex_unlock(&cache->lock); } vm_page_reserve_pages(reservePages); @@ -208,7 +208,7 @@ } push_access(ref, offset, bufferSize, false); - cutex_unlock(&cache->lock); + mutex_unlock(&cache->lock); vm_page_unreserve_pages(lastReservedPages); // read file into reserved pages @@ -229,7 +229,7 @@ } } - cutex_lock(&cache->lock); + mutex_lock(&cache->lock); for (int32 i = 0; i < pageIndex; i++) { busyConditions[i].Unpublish(); @@ -263,7 +263,7 @@ } reserve_pages(ref, reservePages, false); - cutex_lock(&cache->lock); + mutex_lock(&cache->lock); // make the pages accessible in the cache for (int32 i = pageIndex; i-- > 0;) { @@ -292,7 +292,7 @@ vec.iov_len = bufferSize; push_access(ref, offset, bufferSize, false); - cutex_unlock(&ref->cache->lock); + mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); status_t status = vfs_read_pages(ref->vnode, cookie, offset + pageOffset, @@ -300,7 +300,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, false); - cutex_lock(&ref->cache->lock); + mutex_lock(&ref->cache->lock); return status; } @@ -351,7 +351,7 @@ } push_access(ref, offset, bufferSize, true); - cutex_unlock(&ref->cache->lock); + mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); // copy contents (and read in partially written pages first) @@ -433,7 +433,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, true); - cutex_lock(&ref->cache->lock); + mutex_lock(&ref->cache->lock); // unmap the pages again @@ -482,7 +482,7 @@ vec.iov_len = bufferSize; push_access(ref, offset, bufferSize, true); - cutex_unlock(&ref->cache->lock); + mutex_unlock(&ref->cache->lock); vm_page_unreserve_pages(lastReservedPages); status_t status = B_OK; @@ -508,7 +508,7 @@ if (status == B_OK) reserve_pages(ref, reservePages, true); - cutex_lock(&ref->cache->lock); + mutex_lock(&ref->cache->lock); return status; } @@ -604,7 +604,7 @@ size_t reservePages = 0; reserve_pages(ref, lastReservedPages, doWrite); - CutexLocker locker(cache->lock); + MutexLocker locker(cache->lock); while (bytesLeft > 0) { // check if this page is already in memory @@ -780,7 +780,7 @@ off_t lastOffset = offset; size_t lastSize = 0; - cutex_lock(&cache->lock); + mutex_lock(&cache->lock); for (; bytesLeft > 0; offset += B_PAGE_SIZE) { // check if this page is already in memory @@ -792,9 +792,9 @@ // if busy retry again later ConditionVariableEntry entry; entry.Add(page); - cutex_unlock(&cache->lock); + mutex_unlock(&cache->lock); entry.Wait(); - cutex_lock(&cache->lock); + mutex_lock(&cache->lock); goto restart; } @@ -825,7 +825,7 @@ read_into_cache(ref, lastOffset, lastLeft, NULL, 0); out: - cutex_unlock(&cache->lock); + mutex_unlock(&cache->lock); vm_cache_release_ref(cache); #endif } @@ -985,7 +985,7 @@ if (ref == NULL) return B_OK; - CutexLocker _(ref->cache->lock); + MutexLocker _(ref->cache->lock); off_t offset = ref->cache->virtual_size; off_t size = newSize; Modified: haiku/trunk/src/system/kernel/fs/IOScheduler.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/IOScheduler.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/fs/IOScheduler.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -66,9 +66,6 @@ status_t IOScheduler::InitCheck() const { - if (fLock.sem < B_OK) - return fLock.sem; - if (fThread < B_OK) return fThread; Modified: haiku/trunk/src/system/kernel/fs/rootfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/rootfs.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/fs/rootfs.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -357,9 +357,7 @@ fs->id = volume->id; fs->next_vnode_id = 1; - err = mutex_init(&fs->lock, "rootfs_mutex"); - if (err < B_OK) - goto err1; + mutex_init(&fs->lock, "rootfs_mutex"); fs->vnode_list_hash = hash_init(ROOTFS_HASH_SIZE, (addr_t)&vnode->all_next - (addr_t)vnode, &rootfs_vnode_compare_func, &rootfs_vnode_hash_func); @@ -388,7 +386,6 @@ hash_uninit(fs->vnode_list_hash); err2: mutex_destroy(&fs->lock); -err1: free(fs); return err; Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -1514,12 +1514,12 @@ while (true) { struct io_context *context = NULL; - sem_id contextMutex = -1; + bool contextLocked = false; struct team *team = NULL; team_id lastTeamID; cpu_status state = disable_interrupts(); - GRAB_TEAM_LOCK(); + SpinLocker teamsLock(team_spinlock); lastTeamID = peek_next_thread_id(); if (nextTeamID < lastTeamID) { @@ -1531,12 +1531,20 @@ if (team) { context = (io_context *)team->io_context; - contextMutex = context->io_mutex.sem; + + // Some acrobatics to lock the context in a safe way + // (cf. _kern_get_next_fd_info() for details). + GRAB_THREAD_LOCK(); + teamsLock.Unlock(); + contextLocked = mutex_lock_threads_locked(&context->io_mutex) + == B_OK; + RELEASE_THREAD_LOCK(); + nextTeamID++; } } - RELEASE_TEAM_LOCK(); + teamsLock.Unlock(); restore_interrupts(state); if (context == NULL) @@ -1546,7 +1554,7 @@ // safe access to the team structure, we now need to lock the mutex // manually - if (acquire_sem(contextMutex) != B_OK) { + if (!contextLocked) { // team seems to be gone, go over to the next team continue; } @@ -1554,8 +1562,6 @@ // the team cannot be deleted completely while we're owning its // io_context mutex, so we can safely play with it now - context->io_mutex.holder = thread_get_current_thread_id(); - replace_vnode_if_disconnected(mount, vnodeToDisconnect, context->root, sRoot, true); replace_vnode_if_disconnected(mount, vnodeToDisconnect, context->cwd, @@ -4141,11 +4147,7 @@ + sizeof(struct select_sync*) * tableSize + (tableSize + 7) / 8); - if (mutex_init(&context->io_mutex, "I/O context") < 0) { - free(context->fds); - free(context); - return NULL; - } + mutex_init(&context->io_mutex, "I/O context"); // Copy all parent file descriptors @@ -4403,21 +4405,15 @@ sRoot = NULL; - if (mutex_init(&sFileSystemsMutex, "vfs_lock") < 0) - panic("vfs_init: error allocating file systems lock\n"); + mutex_init(&sFileSystemsMutex, "vfs_lock"); if (recursive_lock_init(&sMountOpLock, "vfs_mount_op_lock") < 0) panic("vfs_init: error allocating mount op lock\n"); - if (mutex_init(&sMountMutex, "vfs_mount_lock") < 0) - panic("vfs_init: error allocating mount lock\n"); + mutex_init(&sMountMutex, "vfs_mount_lock"); + mutex_init(&sVnodeCoveredByMutex, "vfs_vnode_covered_by_lock"); + mutex_init(&sVnodeMutex, "vfs_vnode_lock"); - if (mutex_init(&sVnodeCoveredByMutex, "vfs_vnode_covered_by_lock") < 0) - panic("vfs_init: error allocating vnode::covered_by lock\n"); - - if (mutex_init(&sVnodeMutex, "vfs_vnode_lock") < 0) - panic("vfs_init: error allocating vnode lock\n"); - if (benaphore_init(&sIOContextRootLock, "io_context::root lock") < 0) panic("vfs_init: error allocating io_context::root lock\n"); @@ -7000,26 +6996,31 @@ return B_BAD_VALUE; struct io_context *context = NULL; - sem_id contextMutex = -1; struct team *team = NULL; cpu_status state = disable_interrupts(); GRAB_TEAM_LOCK(); + bool contextLocked = false; team = team_get_team_struct_locked(teamID); if (team) { + // We cannot lock the IO context while holding the team lock, nor can + // we just drop the team lock, since it might be deleted in the + // meantime. team_remove_team() acquires the thread lock when removing + // the team from the team hash table, though. Hence we switch to the + // thread lock and use mutex_lock_threads_locked(). context = (io_context *)team->io_context; - contextMutex = context->io_mutex.sem; - } - RELEASE_TEAM_LOCK(); + GRAB_THREAD_LOCK(); + RELEASE_TEAM_LOCK(); + contextLocked = mutex_lock_threads_locked(&context->io_mutex) == B_OK; + RELEASE_THREAD_LOCK(); + } else + RELEASE_TEAM_LOCK(); + restore_interrupts(state); - // we now have a context - since we couldn't lock it while having - // safe access to the team structure, we now need to lock the mutex - // manually - - if (context == NULL || acquire_sem(contextMutex) != B_OK) { + if (!contextLocked) { // team doesn't exit or seems to be gone return B_BAD_TEAM_ID; } @@ -7027,8 +7028,6 @@ // the team cannot be deleted completely while we're owning its // io_context mutex, so we can safely play with it now - context->io_mutex.holder = thread_get_current_thread_id(); - uint32 slot = *_cookie; struct file_descriptor *descriptor; Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -469,8 +469,8 @@ // #pragma mark - Heap functions -heap_allocator * -heap_attach(addr_t base, size_t size, bool postSem) +static heap_allocator * +heap_attach(addr_t base, size_t size) { heap_allocator *heap = (heap_allocator *)base; base += sizeof(heap_allocator); @@ -517,16 +517,7 @@ heap->free_pages = &heap->page_table[0]; heap->page_table[0].prev = NULL; - if (postSem) { - if (mutex_init(&heap->lock, "heap_mutex") < 0) { - panic("heap_attach(): error creating heap mutex\n"); - return NULL; - } - } else { - // pre-init the mutex to at least fall through any semaphore calls - heap->lock.sem = -1; - heap->lock.holder = -1; - } + mutex_init(&heap->lock, "heap_mutex"); heap->next = NULL; dprintf("heap_attach: attached to %p - usable range 0x%08lx - 0x%08lx\n", @@ -1014,7 +1005,7 @@ } heap_allocator *newHeap = heap_attach((addr_t)heapAddress, - HEAP_GROW_SIZE, true); + HEAP_GROW_SIZE); if (newHeap == NULL) { panic("heap_grower: could not attach additional heap!\n"); delete_area(heapArea); @@ -1038,7 +1029,7 @@ status_t heap_init(addr_t base, size_t size) { - sHeapList = heap_attach(base, size, false); + sHeapList = heap_attach(base, size); // set up some debug commands add_debugger_command_etc("heap", &dump_heap_list, @@ -1063,12 +1054,6 @@ status_t heap_init_post_sem() { - // create the lock for the initial heap - if (mutex_init(&sHeapList->lock, "heap_mutex") < B_OK) { - panic("heap_init_post_sem(): error creating heap mutex\n"); - return B_ERROR; - } - sHeapGrowSem = create_sem(0, "heap_grow_sem"); if (sHeapGrowSem < 0) { panic("heap_init_post_sem(): failed to create heap grow sem\n"); @@ -1097,7 +1082,7 @@ return area; } - sGrowHeap = heap_attach((addr_t)dedicated, HEAP_DEDICATED_GROW_SIZE, true); + sGrowHeap = heap_attach((addr_t)dedicated, HEAP_DEDICATED_GROW_SIZE); if (sGrowHeap == NULL) { panic("heap_init_post_thread(): failed to attach dedicated grow heap\n"); delete_area(area); Modified: haiku/trunk/src/system/kernel/image.c =================================================================== --- haiku/trunk/src/system/kernel/image.c 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/image.c 2008-05-01 22:07:36 UTC (rev 25283) @@ -274,7 +274,8 @@ add_debugger_command("team_images", &dump_images_list, "Dump all registered images from the current team"); #endif - return mutex_init(&sImageMutex, "image"); + mutex_init(&sImageMutex, "image"); + return B_OK; } Modified: haiku/trunk/src/system/kernel/kernel_daemon.c =================================================================== --- haiku/trunk/src/system/kernel/kernel_daemon.c 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/kernel_daemon.c 2008-05-01 22:07:36 UTC (rev 25283) @@ -127,8 +127,7 @@ { thread_id thread; - if (mutex_init(&sDaemonMutex, "kernel daemon") < B_OK) - return B_ERROR; + mutex_init(&sDaemonMutex, "kernel daemon"); list_init(&sDaemons); Modified: haiku/trunk/src/system/kernel/lock.cpp =================================================================== --- haiku/trunk/src/system/kernel/lock.cpp 2008-05-01 21:59:46 UTC (rev 25282) +++ haiku/trunk/src/system/kernel/lock.cpp 2008-05-01 22:07:36 UTC (rev 25283) @@ -23,14 +23,14 @@ #include -struct cutex_waiter { +struct mutex_waiter { struct thread* thread; - cutex_waiter* next; // next in queue - cutex_waiter* last; // last in queue (valid for the first in queue) + mutex_waiter* next; // next in queue + mutex_waiter* last; // last in queue (valid for the first in queue) }; -#define CUTEX_FLAG_OWNS_NAME CUTEX_FLAG_CLONE_NAME -#define CUTEX_FLAG_RELEASED 0x2 +#define MUTEX_FLAG_OWNS_NAME MUTEX_FLAG_CLONE_NAME +#define MUTEX_FLAG_RELEASED 0x2 int32 @@ -111,106 +111,6 @@ status_t -mutex_init(mutex *m, const char *name) -{ - if (m == NULL) - return EINVAL; - - if (name == NULL) - name = "mutex_sem"; - - m->holder = -1; - - m->sem = create_sem(1, name); - if (m->sem >= B_OK) - return B_OK; - - return m->sem; -} - - -void -mutex_destroy(mutex *mutex) -{ - if (mutex == NULL) - return; - - if (mutex->sem >= 0) { - delete_sem(mutex->sem); - mutex->sem = -1; - } - mutex->holder = -1; -} - - -status_t -mutex_trylock(mutex *mutex) -{ - thread_id me = thread_get_current_thread_id(); - status_t status; - - if (kernel_startup) - return B_OK; - - status = acquire_sem_etc(mutex->sem, 1, B_RELATIVE_TIMEOUT, 0); - if (status < B_OK) - return status; - - if (me == mutex->holder) { - panic("mutex_trylock failure: mutex %p (sem = 0x%lx) acquired twice by" - " thread 0x%lx\n", mutex, mutex->sem, me); - } - - mutex->holder = me; - return B_OK; -} - - -status_t -mutex_lock(mutex *mutex) -{ - thread_id me = thread_get_current_thread_id(); - status_t status; - - if (kernel_startup) - return B_OK; [... truncated: 1046 lines follow ...] From ingo_weinhold at gmx.de Fri May 2 00:29:52 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 00:29:52 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <200805012207.m41M7fFS017717@sheep.berlios.de> References: <200805012207.m41M7fFS017717@sheep.berlios.de> Message-ID: <20080502002952.1379.7@knochen-vm.1209643267.fake> On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS wrote: [...] > Log: > * Removed old mutex implementation and renamed cutex to mutex. BTW, this seems to make the problems with the OpenSSH "forwarding" test less likely. CU, Ingo From ingo_weinhold at gmx.de Fri May 2 00:46:58 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 00:46:58 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080502002952.1379.7@knochen-vm.1209643267.fake> References: <200805012207.m41M7fFS017717@sheep.berlios.de> <20080502002952.1379.7@knochen-vm.1209643267.fake> Message-ID: <20080502004658.1421.8@knochen-vm.1209643267.fake> On 2008-05-02 at 00:29:52 [+0200], Ingo Weinhold wrote: > > On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS > wrote: > [...] > > Log: > > * Removed old mutex implementation and renamed cutex to mutex. > > BTW, this seems to make the problems with the OpenSSH "forwarding" test less > likely. ... to reproduce. The problems themselves are just as likely, I guess. :-) CU, Ingo From bonefish at mail.berlios.de Fri May 2 03:13:55 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 03:13:55 +0200 Subject: [Haiku-commits] r25284 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805020113.m421Dt9j025249@sheep.berlios.de> Author: bonefish Date: 2008-05-02 03:13:53 +0200 (Fri, 02 May 2008) New Revision: 25284 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25284&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp Log: In Shutdown() pass an actual error code to notify(). B_OK is just ignored. This fixes the hanging OpenSSH "multiplex" test. Save for the "forwarding" test, which sometimes hangs due to a TCP bug, the complete test suite passes, now. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-01 22:07:36 UTC (rev 25283) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-02 01:13:53 UTC (rev 25284) @@ -687,12 +687,12 @@ // send select notifications if (direction == SHUT_RD || direction == SHUT_RDWR) { - gSocketModule->notify(socket, B_SELECT_READ, B_OK); - gSocketModule->notify(fPeerEndpoint->socket, B_SELECT_WRITE, B_OK); + gSocketModule->notify(socket, B_SELECT_READ, EPIPE); + gSocketModule->notify(fPeerEndpoint->socket, B_SELECT_WRITE, EPIPE); } if (direction == SHUT_WR || direction == SHUT_RDWR) { - gSocketModule->notify(socket, B_SELECT_WRITE, B_OK); - gSocketModule->notify(fPeerEndpoint->socket, B_SELECT_READ, B_OK); + gSocketModule->notify(socket, B_SELECT_WRITE, EPIPE); + gSocketModule->notify(fPeerEndpoint->socket, B_SELECT_READ, EPIPE); } RETURN_ERROR(B_OK); From bonefish at mail.berlios.de Fri May 2 03:22:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 03:22:17 +0200 Subject: [Haiku-commits] r25285 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805020122.m421MHXx025595@sheep.berlios.de> Author: bonefish Date: 2008-05-02 03:22:16 +0200 (Fri, 02 May 2008) New Revision: 25285 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25285&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp Log: Added a bit more debug output in UnixFifo, but disabled debug output in all files by default. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-02 01:13:53 UTC (rev 25284) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-02 01:22:16 UTC (rev 25285) @@ -16,7 +16,7 @@ #include "UnixFifo.h" -#define UNIX_ENDPOINT_DEBUG_LEVEL 2 +#define UNIX_ENDPOINT_DEBUG_LEVEL 0 #define UNIX_DEBUG_LEVEL UNIX_ENDPOINT_DEBUG_LEVEL #include "UnixDebug.h" Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-02 01:13:53 UTC (rev 25284) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-02 01:22:16 UTC (rev 25285) @@ -10,7 +10,7 @@ #include "unix.h" -#define UNIX_FIFO_DEBUG_LEVEL 2 +#define UNIX_FIFO_DEBUG_LEVEL 0 #define UNIX_DEBUG_LEVEL UNIX_FIFO_DEBUG_LEVEL #include "UnixDebug.h" @@ -359,6 +359,9 @@ void UnixFifo::Shutdown(uint32 shutdown) { + TRACE("[%ld] %p->UnixFifo::Shutdown(0x%lx)\n", find_thread(NULL), this, + shutdown); + fShutdown |= shutdown; if (shutdown != 0) { @@ -372,8 +375,8 @@ status_t UnixFifo::Read(size_t numBytes, bigtime_t timeout, net_buffer** _buffer) { - TRACE("[%ld] UnixFifo::Read(%lu, %lld)\n", find_thread(NULL), numBytes, - timeout); + TRACE("[%ld] %p->UnixFifo::Read(%lu, %lld)\n", find_thread(NULL), this, + numBytes, timeout); if (IsReadShutdown()) return UNIX_FIFO_SHUTDOWN; @@ -408,6 +411,9 @@ status_t UnixFifo::Write(net_buffer* buffer, bigtime_t timeout) { + TRACE("[%ld] %p->UnixFifo::Write(%p (%lu), %lld)\n", find_thread(NULL), + this, buffer, buffer->size, timeout); + if (IsWriteShutdown()) return UNIX_FIFO_SHUTDOWN; Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-02 01:13:53 UTC (rev 25284) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-02 01:22:16 UTC (rev 25285) @@ -25,7 +25,7 @@ #define UNIX_FIFO_MAXIMAL_CAPACITY (128 * 1024) -#define TRACE_BUFFER_QUEUE 1 +#define TRACE_BUFFER_QUEUE 0 class UnixBufferQueue { Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-02 01:13:53 UTC (rev 25284) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-02 01:22:16 UTC (rev 25285) @@ -24,7 +24,7 @@ #include "UnixEndpoint.h" -#define UNIX_MODULE_DEBUG_LEVEL 2 +#define UNIX_MODULE_DEBUG_LEVEL 0 #define UNIX_DEBUG_LEVEL UNIX_MODULE_DEBUG_LEVEL #include "UnixDebug.h" From bonefish at mail.berlios.de Fri May 2 04:20:19 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 04:20:19 +0200 Subject: [Haiku-commits] r25286 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805020220.m422KJoa028114@sheep.berlios.de> Author: bonefish Date: 2008-05-02 04:20:17 +0200 (Fri, 02 May 2008) New Revision: 25286 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25286&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h Log: Use a mutex instead of a benaphore. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-02 01:22:16 UTC (rev 25285) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-02 02:20:17 UTC (rev 25286) @@ -338,21 +338,20 @@ { fReadCondition.Init(this, "unix fifo read"); fWriteCondition.Init(this, "unix fifo write"); - fLock.sem = -1; + mutex_init(&fLock, "unix fifo"); } UnixFifo::~UnixFifo() { - if (fLock.sem >= 0) - benaphore_destroy(&fLock); + mutex_destroy(&fLock); } status_t UnixFifo::Init() { - return benaphore_init(&fLock, "unix fifo"); + return B_OK; } @@ -498,9 +497,9 @@ ConditionVariableEntry entry; fReadCondition.Add(&entry, B_CAN_INTERRUPT); - benaphore_unlock(&fLock); + mutex_unlock(&fLock); status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout); - benaphore_lock(&fLock); + mutex_lock(&fLock); if (error != B_OK) RETURN_ERROR(error); @@ -526,9 +525,9 @@ ConditionVariableEntry entry; fReadCondition.Add(&entry, B_CAN_INTERRUPT); - benaphore_unlock(&fLock); + mutex_unlock(&fLock); status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout); - benaphore_lock(&fLock); + mutex_lock(&fLock); if (error != B_OK) RETURN_ERROR(error); @@ -558,9 +557,9 @@ ConditionVariableEntry entry; fWriteCondition.Add(&entry, B_CAN_INTERRUPT); - benaphore_unlock(&fLock); + mutex_unlock(&fLock); status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout); - benaphore_lock(&fLock); + mutex_lock(&fLock); if (error != B_OK) RETURN_ERROR(error); @@ -585,9 +584,9 @@ ConditionVariableEntry entry; fWriteCondition.Add(&entry, B_CAN_INTERRUPT); - benaphore_unlock(&fLock); + mutex_unlock(&fLock); error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout); - benaphore_lock(&fLock); + mutex_lock(&fLock); if (error != B_OK) RETURN_ERROR(error); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-02 01:22:16 UTC (rev 25285) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-02 02:20:17 UTC (rev 25286) @@ -74,12 +74,12 @@ bool Lock() { - return benaphore_lock(&fLock) == B_OK; + return mutex_lock(&fLock) == B_OK; } void Unlock() { - benaphore_unlock(&fLock); + mutex_unlock(&fLock); } void Shutdown(uint32 shutdown); @@ -124,7 +124,7 @@ size_t& bytesWritten); private: - benaphore fLock; + mutex fLock; UnixBufferQueue fBuffer; RequestList fReaders; RequestList fWriters; From bonefish at mail.berlios.de Fri May 2 04:26:59 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 04:26:59 +0200 Subject: [Haiku-commits] r25287 - haiku/trunk/src/add-ons/kernel/network/stack Message-ID: <200805020226.m422QxZY028341@sheep.berlios.de> Author: bonefish Date: 2008-05-02 04:26:58 +0200 (Fri, 02 May 2008) New Revision: 25287 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25287&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/stack/link.cpp Log: This fixes the crashes when calling {g,s}etsockopt() on an AF_LINK socket. Not sure, if there are any cases where there is a next protocol, though. Please review. Modified: haiku/trunk/src/add-ons/kernel/network/stack/link.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/link.cpp 2008-05-02 02:20:17 UTC (rev 25286) +++ haiku/trunk/src/add-ons/kernel/network/stack/link.cpp 2008-05-02 02:26:58 UTC (rev 25287) @@ -323,8 +323,13 @@ link_getsockopt(net_protocol *protocol, int level, int option, void *value, int *length) { - return protocol->next->module->getsockopt(protocol, level, option, - value, length); + if (protocol->next != NULL) { + return protocol->next->module->getsockopt(protocol, level, option, + value, length); + } + + return gNetSocketModule.get_option(protocol->socket, level, option, value, + length); } @@ -332,7 +337,12 @@ link_setsockopt(net_protocol *protocol, int level, int option, const void *value, int length) { - return protocol->next->module->setsockopt(protocol, level, option, + if (protocol->next != NULL) { + return protocol->next->module->setsockopt(protocol, level, option, + value, length); + } + + return gNetSocketModule.set_option(protocol->socket, level, option, value, length); } From bonefish at mail.berlios.de Fri May 2 04:30:18 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 04:30:18 +0200 Subject: [Haiku-commits] r25288 - haiku/trunk/src/system/kernel/fs Message-ID: <200805020230.m422UIEL028499@sheep.berlios.de> Author: bonefish Date: 2008-05-02 04:30:16 +0200 (Fri, 02 May 2008) New Revision: 25288 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25288&view=rev Modified: haiku/trunk/src/system/kernel/fs/socket.cpp Log: When creating a socket file descriptor fetch the SO_NONBLOCK value from the socket first, so the FD open flags are in sync with that. Fixes situations where a socket accept()ed from a non-blocking listener socket wouldn't have O_NONBLOCK set. Modified: haiku/trunk/src/system/kernel/fs/socket.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/socket.cpp 2008-05-02 02:26:58 UTC (rev 25287) +++ haiku/trunk/src/system/kernel/fs/socket.cpp 2008-05-02 02:30:16 UTC (rev 25288) @@ -326,6 +326,15 @@ static int create_socket_fd(net_socket* socket, bool kernel) { + // Get the socket's non-blocking flag, so we can set the respective + // open mode flag. + int32 nonBlock; + socklen_t nonBlockLen = sizeof(int32); + status_t error = sStackInterface->getsockopt(socket, SOL_SOCKET, + SO_NONBLOCK, &nonBlock, &nonBlockLen); + if (error != B_OK) + return error; + // allocate a file descriptor file_descriptor* descriptor = alloc_fd(); if (descriptor == NULL) @@ -335,7 +344,7 @@ descriptor->type = FDTYPE_SOCKET; descriptor->ops = &sSocketFDOps; descriptor->u.socket = socket; - descriptor->open_mode = O_RDWR; + descriptor->open_mode = O_RDWR | (nonBlock ? O_NONBLOCK : 0); // publish it int fd = new_fd(get_current_io_context(kernel), descriptor); From michael.pfeiffer at utanet.at Fri May 2 07:51:03 2008 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Fri, 2 May 2008 07:51:03 +0200 Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: References: <20080501183409.3420@gmx.net> <39230643589-BeMail@zon> Message-ID: <3EFAE4BC-57E9-4A46-B4B5-A61B3E078E33@utanet.at> Am 01.05.2008 um 23:53 schrieb Rene Gollent: > On Thu, May 1, 2008 at 4:49 PM, Ryan Leavengood > wrote: >> I may add some kind of notification that a screenshot was taken, but >> that is probably it for now. >> > > If I'm remembering correctly, pre-OSX MacOS used to do this by making > a camera sound when you hit the button, perhaps something along those > lines could work as a nice, reasonably unobtrusive cue? +1, and OS X still does that. On OS X there is also a shortcut key combination where you can select a rectangular area for the screenshot. Tho, so far, I have used that only as a replacement for taking a screenshot for the active window. > Or maybe a notification along the lines of what's possible with > infopopper? -1, maybe OK if you can disable it. Per default the image should be saved to the desktop, that would be a visual feedback in case the file icon is not overlapped by a window. And you have immediate access to it without the need to open another Tracker window. If there is a confirmation dialog, it should be possible to disable it. - Michael From axeld at pinc-software.de Fri May 2 12:14:57 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 12:14:57 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25287_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/network/stack?= In-Reply-To: <200805020226.m422QxZY028341@sheep.berlios.de> Message-ID: <4133468669-BeMail@zon> bonefish at BerliOS wrote: > Log: > This fixes the crashes when calling {g,s}etsockopt() on an AF_LINK > socket. Not sure, if there are any cases where there is a next > protocol, > though. Please review. Actually the link level should always sit directly on top of the data link. I didn't really like that Hugo separated the control() hook from {get,set}sockopt(), but now that we have extra syscall for them, it may make more sense; I didn't review it that much back then, because I thought we would end up reverting that change. Bye, Axel. From axeld at pinc-software.de Fri May 2 13:19:06 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 13:19:06 +0200 CEST Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080502002952.1379.7@knochen-vm.1209643267.fake> Message-ID: <7982451176-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS > wrote: > [...] > > Log: > > * Removed old mutex implementation and renamed cutex to mutex. > BTW, this seems to make the problems with the OpenSSH "forwarding" > test less > likely. I could finally run the test ("make tests" plus adding the ssh user did the trick) - thanks! :-) However, what exactly happens with this test? I had it wait for closing connections, but they were all left established. Also, the open sockets used up more than 27 MB - which doesn't really look good. Bye, Axel. From axeld at pinc-software.de Fri May 2 13:20:11 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 13:20:11 +0200 CEST Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080502002952.1379.7@knochen-vm.1209643267.fake> Message-ID: <8047973326-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS > wrote: > [...] > > Log: > > * Removed old mutex implementation and renamed cutex to mutex. > BTW, this seems to make the problems with the OpenSSH "forwarding" > test less > likely. BTW "automake --add-missing" did fail after I updated the tree (from before your cutex changes, IIRC); I had to manually copy config.{guess| sub}. Bye, Axel. From axeld at mail.berlios.de Fri May 2 14:39:31 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 May 2008 14:39:31 +0200 Subject: [Haiku-commits] r25289 - haiku/trunk/src/system/libroot/os Message-ID: <200805021239.m42CdVSl020123@sheep.berlios.de> Author: axeld Date: 2008-05-02 14:39:17 +0200 (Fri, 02 May 2008) New Revision: 25289 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25289&view=rev Modified: haiku/trunk/src/system/libroot/os/find_directory.c Log: Fixed warnings. Modified: haiku/trunk/src/system/libroot/os/find_directory.c =================================================================== --- haiku/trunk/src/system/libroot/os/find_directory.c 2008-05-02 02:30:16 UTC (rev 25288) +++ haiku/trunk/src/system/libroot/os/find_directory.c 2008-05-02 12:39:17 UTC (rev 25289) @@ -280,10 +280,6 @@ err = B_OK; if (template) { if (!strncmp(template, "$h", 2)) { - struct passwd pwBuffer; - char pwStringBuffer[MAX_PASSWD_BUFFER_SIZE]; - struct passwd *pw; - if (bootDevice > -1 && device != bootDevice) { int l = pathLength - strlen(buffer); if (l > 5) @@ -291,6 +287,10 @@ } else { #ifndef _KERNEL_MODE #ifdef USE_PWENTS + struct passwd pwBuffer; + char pwStringBuffer[MAX_PASSWD_BUFFER_SIZE]; + struct passwd *pw; + if (getpwuid_r(geteuid(), &pwBuffer, pwStringBuffer, sizeof(pwStringBuffer), &pw) == 0) { home = pw->pw_dir; @@ -309,9 +309,9 @@ } else strlcat(buffer, "/", pathLength); - if (!err && strlen(buffer) + 2 + strlen(template) < (uint32)pathLength) { + if (!err && strlen(buffer) + 2 + strlen(template) < (uint32)pathLength) strcat(buffer, template); - } else + else err = err ? err : E2BIG; } else err = err ? err : ENOENT; From ingo_weinhold at gmx.de Fri May 2 14:55:58 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 14:55:58 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <8047973326-BeMail@zon> References: <8047973326-BeMail@zon> Message-ID: <20080502145558.508.1@knochen-vm.1209732708.fake> On 2008-05-02 at 13:20:11 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS > > wrote: > > [...] > > > Log: > > > * Removed old mutex implementation and renamed cutex to mutex. > > BTW, this seems to make the problems with the OpenSSH "forwarding" > > test less > > likely. > > BTW "automake --add-missing" did fail after I updated the tree (from > before your cutex changes, IIRC); I had to manually copy config.{guess| > sub}. automake should indeed fail, but it should still replace config.guess and config.sub. Worked and still (r25288) works for me: /Transfer/ports/openssh> tar xf openssh-5.0p1.tar.gz /Transfer/ports/openssh> cd openssh-5.0p1 /Transfer/ports/openssh/openssh-5.0p1> rm config.guess config.sub /Transfer/ports/openssh/openssh-5.0p1> automake --add-missing configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found. configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE, configure.ac: that aclocal.m4 is present in the top-level directory, configure.ac: and that aclocal.m4 was recently regenerated (using aclocal). configure.ac:23: installing `./config.guess' configure.ac:23: installing `./config.sub' automake: no `Makefile.am' found for any configure output CU, Ingo From axeld at mail.berlios.de Fri May 2 15:00:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 May 2008 15:00:27 +0200 Subject: [Haiku-commits] r25290 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200805021300.m42D0RQI022554@sheep.berlios.de> Author: axeld Date: 2008-05-02 15:00:27 +0200 (Fri, 02 May 2008) New Revision: 25290 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25290&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_system_info.c Log: * Fixed warning and bad coding style. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_system_info.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_system_info.c 2008-05-02 12:39:17 UTC (rev 25289) +++ haiku/trunk/src/system/kernel/arch/x86/arch_system_info.c 2008-05-02 13:00:27 UTC (rev 25290) @@ -1,28 +1,30 @@ /* - * Copyright 2004-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ +#include + +#include + #include #include +#include +#include #include #include -#include -#include -#include -#include - uint32 sCpuType; int32 sCpuRevision; int64 sCpuClockSpeed; static bool -get_cpuid_for(cpuid_info *info, uint32 currentCPU, uint32 eaxRegister, uint32 forCPU) +get_cpuid_for(cpuid_info *info, uint32 currentCPU, uint32 eaxRegister, + uint32 forCPU) { if (currentCPU != forCPU) return false; @@ -81,7 +83,7 @@ uint32 base; uint32 model = 0; cpu_ent *cpu = get_cpu_struct(); - + switch (cpu->arch.vendor) { case VENDOR_INTEL: base = B_CPU_INTEL_x86; @@ -114,29 +116,30 @@ base = B_CPU_x86; } - if (base != B_CPU_x86) - if (base == B_CPU_INTEL_x86) - model = (cpu->arch.extended_family << 20) + (cpu->arch.extended_model << 16) + - (cpu->arch.family << 4) + cpu->arch.model; - else + if (base != B_CPU_x86) { + if (base == B_CPU_INTEL_x86) { + model = (cpu->arch.extended_family << 20) + + (cpu->arch.extended_model << 16) + + (cpu->arch.family << 4) + cpu->arch.model; + } else { model = (cpu->arch.family << 4) + cpu->arch.model; - /* There isn't much useful information yet in the extended - family and extended model fields of AMD processors - and is probably undefined for others */ + // There isn't much useful information yet in the extended + // family and extended model fields of AMD processors + // and is probably undefined for others + } + } sCpuRevision = (cpu->arch.extended_family << 18) - | (cpu->arch.extended_model << 14) - | (cpu->arch.type << 12) - | (cpu->arch.family << 8) - | (cpu->arch.model << 4) - | cpu->arch.stepping; + | (cpu->arch.extended_model << 14) | (cpu->arch.type << 12) + | (cpu->arch.family << 8) | (cpu->arch.model << 4) | cpu->arch.stepping; sCpuType = base + model; sCpuClockSpeed = args->arch_args.cpu_clock_speed; return B_OK; } + // #pragma mark - From ingo_weinhold at gmx.de Fri May 2 15:04:26 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 15:04:26 +0200 Subject: [Haiku-commits] r25287 - haiku/trunk/src/add-ons/kernel/network/stack In-Reply-To: <4133468669-BeMail@zon> References: <4133468669-BeMail@zon> Message-ID: <20080502150426.540.2@knochen-vm.1209732708.fake> On 2008-05-02 at 12:14:57 [+0200], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > Log: > > This fixes the crashes when calling {g,s}etsockopt() on an AF_LINK > > socket. Not sure, if there are any cases where there is a next > > protocol, > > though. Please review. > > Actually the link level should always sit directly on top of the data > link. I haven't tried to understand yet how the protocols and datalink_protocols are supposed to work together. So, if the situation that the next protocol is NULL should never occur in link_{g,s}etsockopt() I trust you will fix it. :-) > I didn't really like that Hugo separated the control() hook from > {get,set}sockopt(), but now that we have extra syscall for them, it may > make more sense; I didn't review it that much back then, because I > thought we would end up reverting that change. Mmh, I've just used what was already there. If you think it is nicer to let the socket descriptor ioctl() hook translate to {g,s}etsockopt(), we can do that. CU, Ingo From revol at free.fr Fri May 2 15:05:16 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 02 May 2008 15:05:16 +0200 CEST Subject: [Haiku-commits] r25269 - in haiku/trunk/src: kits kits/interface servers/app In-Reply-To: <39230643589-BeMail@zon> Message-ID: <2386045883-BeMail@laptop> > "Stephan Assmus" wrote: > > FWIW, I see it like Koki. I believe it should be doable in a way > > that > > it is not bloated, > > and one could still select the screen shot format. > > > > How about the interface kit implements this so that the screenshot > > is > > taken, and then > > sent to the separate screenshot saving app (private clipboard > > even?)? > > That way, it > > wouldn't be a problem even if the app made a Deskbar entry. It > > could > > popup a window > > that has a persistent setting for the format and location, so that > > one can change it, > > but doesn't have to. It would simply remember the last used > > settings > > and one only > > has to press ok (or even cancel, if it was unintentional). The > > window > > popping up is > > not such a bad idea, because there would be no feedback otherwise > > at > > all, which is a > > bad thing in itself. How are people supposed to know that something > > even happend > > when they pressed Print-Screen? > > That's a very good point! I didn't know about the screenshot feature > on > Windows for a long time, and I occasionally took some unintended > screenshots in BeOS, when I accidently hit the Print key. > I like the private clipboard idea, too, but I don't know how long > they > are preserved; maybe it would be better to pass the data directly to > the app, so that not too much memory is wasted (although the > screenshot > app could probably also simply delete it afterwards). And this also > solves the potential problem that you need to access the disk before > actually taking the shot. The clipboards just live until you shut down. Just empty it when you're done. > The current window (which triggers the screenshot) could then also > pass > its current location and size to the screenshot app, so that you > could > then decide in the screenshot app wether or not the whole screen or > just the active window should be saved. > > Well, you two managed to convince me, thanks :-) > But what's Ryan's opinion who wanted to actually implement it? It can also optionnally be disabled by a checkbox the first time it appears, so the user knows about it and consciently dismisses it. It should also be possible to use Infopopper to say "screenshot saved to /boot/home/screen12.png", but that would appear in subsequent shots if one wants to take multiple ones, so should be selectable. Fran?ois. From revol at free.fr Fri May 2 15:08:03 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 02 May 2008 15:08:03 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25269_-_in_haiku/trunk/src=3A_k?= =?windows-1252?q?its_kits/interface_servers/app?= In-Reply-To: Message-ID: <2553941059-BeMail@laptop> > On Thu, May 1, 2008 at 4:49 PM, Ryan Leavengood > wrote: > > I may add some kind of notification that a screenshot was taken, > > but > > that is probably it for now. > > > > If I'm remembering correctly, pre-OSX MacOS used to do this by making > a camera sound when you hit the button, perhaps something along those > lines could work as a nice, reasonably unobtrusive cue? Or maybe a > notification along the lines of what's possible with infopopper? Oh yes that's an idea... installsound "Screenshot Taken" :) And I just thought about infopopper too, but it would appear on next shot if you take it right away. Fran?ois. From ingo_weinhold at gmx.de Fri May 2 15:49:06 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 15:49:06 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <7982451176-BeMail@zon> References: <7982451176-BeMail@zon> Message-ID: <20080502154906.570.3@knochen-vm.1209732708.fake> On 2008-05-02 at 13:19:06 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2008-05-02 at 00:07:41 [+0200], bonefish at BerliOS > > wrote: > > [...] > > > Log: > > > * Removed old mutex implementation and renamed cutex to mutex. > > BTW, this seems to make the problems with the OpenSSH "forwarding" > > test less > > likely. > > I could finally run the test ("make tests" plus adding the ssh user did > the trick) - thanks! :-) Oh sorry, I forgot about the user. > However, what exactly happens with this test? > I had it wait for closing connections, but they were all left > established. Also, the open sockets used up more than 27 MB - which > doesn't really look good. I don't know about that. At least one TCP connection and a few UNIX socket connections should stay open during the whole test. They are associated with the ssh connection that forwards the ports. I don't know exactly how port forwarding is implemented, but I think it just uses the one TCP connection. Until the forwarded ports are used, of course. The problem I usually encounter is that an ssh and an sshd process both start to infinitely loop in TCPEndpoint::SendData() -> WaitList::Wait() at some point. If they don't, the test will just pass. The test runs for a while and has no output (unless you enable it; cf. README.regress), so it helps to keep ProcessController's team menu open. The infinite loop situation is easily recognizable. Regarding memory usage, the UNIX socket implementation is really inefficient in that respect ATM. If the sent messages are small a lot of memory is wasted, since it just queues the buffers (which are 2 KB minimum). I don't think OpenSSH uses them in a way that would explain 27 MB, but I wouldn't completely rule that out either. I'm already in the process of extending the protocol interface so that the situation can be remedied. CU, Ingo From bga at mail.berlios.de Fri May 2 16:34:22 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Fri, 2 May 2008 16:34:22 +0200 Subject: [Haiku-commits] r25291 - in haiku/trunk: build/config_headers src/add-ons/kernel/busses/scsi/ahci Message-ID: <200805021434.m42EYMHJ028861@sheep.berlios.de> Author: bga Date: 2008-05-02 16:34:20 +0200 (Fri, 02 May 2008) New Revision: 25291 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25291&view=rev Modified: haiku/trunk/build/config_headers/tracing_config.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h Log: - Added AHCI port tracing (Only PRD table tracing for now). - Added controller attribute to the AHCIPort class for debugging purposes. AHCI is failing whenever the PRD table has an address above the 2048 Mb mark. Modified: haiku/trunk/build/config_headers/tracing_config.h =================================================================== --- haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 13:00:27 UTC (rev 25290) +++ haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 14:34:20 UTC (rev 25291) @@ -36,6 +36,7 @@ #define TEAM_TRACING 0 #define USER_MALLOC_TRACING 0 #define WAIT_FOR_OBJECTS_TRACING 0 +#define AHCI_PORT_TRACING 0 #endif // ENABLE_TRACING Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-05-02 13:00:27 UTC (rev 25290) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-05-02 14:34:20 UTC (rev 25291) @@ -15,6 +15,7 @@ #include #include #include +#include #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) //#define FLOW(a...) dprintf("ahci: " a) @@ -22,9 +23,66 @@ #define FLOW(a...) #define RWTRACE(a...) +#if AHCI_PORT_TRACING +namespace AHCIPortTracing { + +class AHCIPortTraceEntry : public AbstractTraceEntry { + protected: + AHCIPortTraceEntry(AHCIController* controller, int index) + : fController(controller) + , fIndex(index) + { + } + + void AddDump(TraceOutput& out, const char* name) + { + out.Print(name); + out.Print("controller: %p", fController); + out.Print(", index: %d", fIndex); + } + + AHCIController* fController; + int fIndex; +}; + + +class AHCIPortPrdTable : public AHCIPortTraceEntry { + public: + AHCIPortPrdTable(AHCIController* controller, int index, void* address, + size_t size) + : AHCIPortTraceEntry(controller, index) + , fAddress(address) + , fSize(size) + { + Initialized(); + } + + void AddDump(TraceOutput& out) + { + AHCIPortTraceEntry::AddDump(out, " - prd table: "); + + out.Print("address: %p", fAddress); + out.Print(", size: %lu", fSize); + } + + void* fAddress; + int fSize; +}; + + +} // namespace AHCIPortTracing + +# define T(x) new(std::nothrow) AHCIPortTracing::x + +#else +# define T(x) +#endif // AHCI_PORT_TRACING + + AHCIPort::AHCIPort(AHCIController *controller, int index) - : fIndex(index) + : fController(controller) + , fIndex(index) , fRegs(&controller->fRegs->port[index]) , fArea(-1) , fSpinlock(0) @@ -322,6 +380,7 @@ while (sgCount > 0 && dataSize > 0) { size_t size = min_c(sgTable->size, dataSize); void *address = sgTable->address; + T(AHCIPortPrdTable(fController, fIndex, address, size)); FLOW("FillPrdTable: sg-entry addr %p, size %lu\n", address, size); if ((uint32)address & 1) { TRACE("AHCIPort::FillPrdTable: data alignment error\n"); Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2008-05-02 13:00:27 UTC (rev 25290) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2008-05-02 14:34:20 UTC (rev 25291) @@ -52,6 +52,7 @@ status_t FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize); private: + AHCIController* fController; int fIndex; volatile ahci_port * fRegs; area_id fArea; From bonefish at mail.berlios.de Fri May 2 16:37:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 2 May 2008 16:37:17 +0200 Subject: [Haiku-commits] r25292 - in haiku/trunk: headers/private/net src/add-ons/kernel/network/protocols/unix src/add-ons/kernel/network/stack Message-ID: <200805021437.m42EbH7w029130@sheep.berlios.de> Author: bonefish Date: 2008-05-02 16:37:16 +0200 (Fri, 02 May 2008) New Revision: 25292 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25292&view=rev Added: haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.cpp haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.h Modified: haiku/trunk/headers/private/net/net_buffer.h haiku/trunk/headers/private/net/net_protocol.h haiku/trunk/headers/private/net/net_stack.h haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp haiku/trunk/src/add-ons/kernel/network/stack/Jamfile haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp Log: Moved the container management for ancillary data from the net_buffer module to the stack module. There's a dedicated struct ancillary_data_container, now. One can just set the container on a net_buffer. Modified: haiku/trunk/headers/private/net/net_buffer.h =================================================================== --- haiku/trunk/headers/private/net/net_buffer.h 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/headers/private/net/net_buffer.h 2008-05-02 14:37:16 UTC (rev 25292) @@ -37,11 +37,7 @@ uint8 protocol; } net_buffer; -typedef struct ancillary_data_header { - int level; - int type; - size_t len; -} ancillary_data_header; +struct ancillary_data_container; struct net_buffer_module_info { module_info info; @@ -74,16 +70,11 @@ status_t (*associate_data)(net_buffer *buffer, void *data); - status_t (*attach_ancillary_data)(net_buffer *buffer, - const ancillary_data_header *header, const void *data, - void (*destructor)(const ancillary_data_header*, void*), - void **_allocatedData); - status_t (*detach_ancillary_data)(net_buffer *buffer, void *data, - bool destroy); + void (*set_ancillary_data)(net_buffer *buffer, + ancillary_data_container *container); + ancillary_data_container* (*get_ancillary_data)(net_buffer *buffer); void * (*transfer_ancillary_data)(net_buffer *from, net_buffer *to); - void * (*next_ancillary_data)(net_buffer *buffer, - void *previousData, ancillary_data_header *_header); status_t (*direct_access)(net_buffer *buffer, uint32 offset, size_t bytes, void **_data); Modified: haiku/trunk/headers/private/net/net_protocol.h =================================================================== --- haiku/trunk/headers/private/net/net_protocol.h 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/headers/private/net/net_protocol.h 2008-05-02 14:37:16 UTC (rev 25292) @@ -16,6 +16,9 @@ #define LEVEL_DRIVER_IOCTL 0x0f000000 #define LEVEL_MASK 0x0fffffff +struct ancillary_data_container; +struct ancillary_data_header; + typedef struct net_protocol { struct net_protocol *next; struct net_protocol_module_info *module; @@ -69,8 +72,8 @@ status_t (*error_reply)(net_protocol *self, net_buffer *causedError, uint32 code, void *errorData); - status_t (*attach_ancillary_data)(net_protocol *self, net_buffer *buffer, - const cmsghdr *header); + status_t (*add_ancillary_data)(net_protocol *self, + ancillary_data_container *container, const cmsghdr *header); ssize_t (*process_ancillary_data)(net_protocol *self, const ancillary_data_header *header, const void *data, void *buffer, size_t bufferSize); Modified: haiku/trunk/headers/private/net/net_stack.h =================================================================== --- haiku/trunk/headers/private/net/net_stack.h 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/headers/private/net/net_stack.h 2008-05-02 14:37:16 UTC (rev 25292) @@ -24,6 +24,8 @@ struct net_socket; struct net_timer; +typedef struct ancillary_data_container ancillary_data_container; + struct net_fifo { benaphore lock; sem_id notify; @@ -64,6 +66,12 @@ void (*event)(struct net_device_monitor *monitor, int32 event); }; +typedef struct ancillary_data_header { + int level; + int type; + size_t len; +} ancillary_data_header; + struct net_stack_module_info { module_info info; @@ -139,6 +147,21 @@ bool (*is_restarted_syscall)(void); void (*store_syscall_restart_timeout)(bigtime_t timeout); bigtime_t (*restore_syscall_restart_timeout)(void); + + // ancillary data + ancillary_data_container* (*create_ancillary_data_container)(); + void (*delete_ancillary_data_container)( + ancillary_data_container* container); + status_t (*add_ancillary_data)(ancillary_data_container *container, + const ancillary_data_header *header, const void *data, + void (*destructor)(const ancillary_data_header*, void*), + void **_allocatedData); + status_t (*remove_ancillary_data)(ancillary_data_container *container, + void *data, bool destroy); + void* (*move_ancillary_data)(ancillary_data_container *from, + ancillary_data_container *to); + void* (*next_ancillary_data)(ancillary_data_container *container, + void *previousData, ancillary_data_header *_header); }; #endif // NET_STACK_H Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-02 14:37:16 UTC (rev 25292) @@ -268,11 +268,11 @@ status_t -unix_attach_ancillary_data(net_protocol *self, net_buffer *buffer, +unix_add_ancillary_data(net_protocol *self, ancillary_data_container *container, const cmsghdr *header) { - TRACE("[%ld] unix_attach_ancillary_data(%p, %p, %p (level: %d, type: %d, " - "len: %d))\n", find_thread(NULL), self, buffer, header, + TRACE("[%ld] unix_add_ancillary_data(%p, %p, %p (level: %d, type: %d, " + "len: %d))\n", find_thread(NULL), self, container, header, header->cmsg_level, header->cmsg_type, (int)header->cmsg_len); // we support only SCM_RIGHTS @@ -302,17 +302,17 @@ } } - // attach the ancillary data to the buffer + // attach the ancillary data to the container if (error == B_OK) { ancillary_data_header header; header.level = SOL_SOCKET; header.type = SCM_RIGHTS; header.len = count * sizeof(file_descriptor*); - TRACE("[%ld] unix_attach_ancillary_data(): attaching %d FDs to " - "buffer\n", find_thread(NULL), count); + TRACE("[%ld] unix_add_ancillary_data(): adding %d FDs to " + "container\n", find_thread(NULL), count); - error = gBufferModule->attach_ancillary_data(buffer, &header, + error = gStackModule->add_ancillary_data(container, &header, descriptors, destroy_scm_rights_descriptors, NULL); } @@ -468,7 +468,7 @@ unix_deliver_data, unix_error, unix_error_reply, - unix_attach_ancillary_data, + unix_add_ancillary_data, unix_process_ancillary_data }; Modified: haiku/trunk/src/add-ons/kernel/network/stack/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/Jamfile 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/Jamfile 2008-05-02 14:37:16 UTC (rev 25292) @@ -15,6 +15,7 @@ UsePrivateHeaders net ; KernelAddon stack : + ancillary_data.cpp datalink.cpp domains.cpp interfaces.cpp Added: haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.cpp 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.cpp 2008-05-02 14:37:16 UTC (rev 25292) @@ -0,0 +1,203 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "ancillary_data.h" + +#include +#include + +#include + +#include + + +#define MAX_ANCILLARY_DATA_SIZE 128 + + +struct ancillary_data : DoublyLinkedListLinkImpl { + void* Data() + { + return (char*)this + _ALIGN(sizeof(ancillary_data)); + } + + static ancillary_data* FromData(void* data) + { + return (ancillary_data*)((char*)data - _ALIGN(sizeof(ancillary_data))); + } + + ancillary_data_header header; + void (*destructor)(const ancillary_data_header*, void*); +}; + +typedef DoublyLinkedList ancillary_data_list; + +struct ancillary_data_container { + ancillary_data_list data_list; +}; + + +ancillary_data_container* +create_ancillary_data_container() +{ + return new(std::nothrow) ancillary_data_container; +} + + +void +delete_ancillary_data_container(ancillary_data_container* container) +{ + if (container == NULL) + return; + + while (ancillary_data* data = container->data_list.RemoveHead()) { + if (data->destructor != NULL) + data->destructor(&data->header, data->Data()); + free(data); + } +} + + +/*! + Adds ancillary data to the given container. + + \param container The container. + \param header Description of the data. + \param data If not \c NULL, the data are copied into the allocated storage. + \param destructor If not \c NULL, this function will be invoked with the + data as parameter when the container is destroyed. + \param _allocatedData Will be set to the storage allocated for the data. + \return \c B_OK when everything goes well, another error code otherwise. +*/ +status_t +add_ancillary_data(ancillary_data_container* container, + const ancillary_data_header* header, const void* data, + void (*destructor)(const ancillary_data_header*, void*), + void** _allocatedData) +{ + // check parameters + if (header == NULL) + return B_BAD_VALUE; + + if (header->len > MAX_ANCILLARY_DATA_SIZE) + return ENOBUFS; + + // allocate buffer + void *dataBuffer = malloc(_ALIGN(sizeof(ancillary_data)) + header->len); + if (dataBuffer == NULL) + return B_NO_MEMORY; + + // init and attach the structure + ancillary_data *ancillaryData = new(dataBuffer) ancillary_data; + ancillaryData->header = *header; + ancillaryData->destructor = destructor; + + container->data_list.Add(ancillaryData); + + if (data != NULL) + memcpy(ancillaryData->Data(), data, header->len); + + if (_allocatedData != NULL) + *_allocatedData = ancillaryData->Data(); + + return B_OK; +} + + +/*! + Removes ancillary data from the given container. The associated memory is + freed, i.e. the \a data pointer must no longer be used after calling this + function. Depending on \a destroy, the destructor is invoked before freeing + the data. + + \param container The container. + \param data Pointer to the data to be removed (as returned by + add_ancillary_data() or next_ancillary_data()). + \param destroy If \c true, the destructor, if one was passed to + add_ancillary_data(), is invoked for the data. + \return \c B_OK when everything goes well, another error code otherwise. +*/ +status_t +remove_ancillary_data(ancillary_data_container* container, void* data, + bool destroy) +{ + if (data == NULL) + return B_BAD_VALUE; + + ancillary_data *ancillaryData = ancillary_data::FromData(data); + + container->data_list.Remove(ancillaryData); + + if (destroy && ancillaryData->destructor != NULL) { + ancillaryData->destructor(&ancillaryData->header, + ancillaryData->Data()); + } + + free(ancillaryData); + + return B_OK; +} + + +/*! + Moves all ancillary data from container \c from to the end of the list of + ancillary data of container \c to. + + \param from The container from which to remove the ancillary data. + \param to The container to which to add the ancillary data. + \return A pointer to the first of the moved ancillary data, if any, \c NULL + otherwise. +*/ +void * +move_ancillary_data(ancillary_data_container* from, + ancillary_data_container* to) +{ + if (from == NULL || to == NULL) + return NULL; + + ancillary_data *ancillaryData = from->data_list.Head(); + to->data_list.MoveFrom(&from->data_list); + + return ancillaryData != NULL ? ancillaryData->Data() : NULL; +} + + +/*! + Returns the next ancillary data. When iterating through the data, initially + a \c NULL pointer shall be passed as \a previousData, subsequently the + previously returned data pointer. After the last item, \c NULL is returned. + + Note, that it is not safe to call remove_ancillary_data() for a data item + and then pass that pointer to this function. First get the next item, then + remove the previous one. + + \param container The container. + \param previousData The pointer to the previous data returned by this + function. Initially \c NULL shall be passed. + \param header Pointer to allocated storage into which the data description + is written. May be \c NULL. + \return A pointer to the next ancillary data in the container. \c NULL after + the last one. +*/ +void* +next_ancillary_data(ancillary_data_container* container, void* previousData, + ancillary_data_header* _header) +{ + ancillary_data *ancillaryData; + + if (previousData == NULL) { + ancillaryData = container->data_list.Head(); + } else { + ancillaryData = ancillary_data::FromData(previousData); + ancillaryData = container->data_list.GetNext(ancillaryData); + } + + if (ancillaryData == NULL) + return NULL; + + if (_header != NULL) + *_header = ancillaryData->header; + + return ancillaryData->Data(); +} Added: haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.h 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/ancillary_data.h 2008-05-02 14:37:16 UTC (rev 25292) @@ -0,0 +1,29 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef NET_ANCILLARY_DATA_H +#define NET_ANCILLARY_DATA_H + +#include + + +struct ancillary_data_container; + +ancillary_data_container* create_ancillary_data_container(); +void delete_ancillary_data_container(ancillary_data_container* container); + +status_t add_ancillary_data(ancillary_data_container* container, + const ancillary_data_header* header, const void* data, + void (*destructor)(const ancillary_data_header*, void*), + void** _allocatedData); +status_t remove_ancillary_data(ancillary_data_container* container, void* data, + bool destroy); +void* move_ancillary_data(ancillary_data_container* from, + ancillary_data_container* to); + +void* next_ancillary_data(ancillary_data_container* container, + void* previousData, ancillary_data_header* _header); + + +#endif // NET_ANCILLARY_DATA_H Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2008-05-02 14:37:16 UTC (rev 25292) @@ -25,6 +25,8 @@ #include #include +#include "ancillary_data.h" + #include "paranoia_config.h" @@ -121,30 +123,11 @@ } }; -#define MAX_ANCILLARY_DATA_SIZE 128 - -struct ancillary_data : DoublyLinkedListLinkImpl { - void* Data() - { - return (char*)this + _ALIGN(sizeof(ancillary_data)); - } - - static ancillary_data* FromData(void* data) - { - return (ancillary_data*)((char*)data - _ALIGN(sizeof(ancillary_data))); - } - - ancillary_data_header header; - void (*destructor)(const ancillary_data_header*, void*); -}; - -typedef DoublyLinkedList ancillary_data_list; - struct net_buffer_private : net_buffer { struct list buffers; data_header *allocation_header; // the current place where we // allocate header space (nodes,...) - ancillary_data_list ancillary_data; + ancillary_data_container* ancillary_data; struct { struct sockaddr_storage source; @@ -1021,7 +1004,7 @@ list_init(&buffer->buffers); list_add_item(&buffer->buffers, node); - new(&buffer->ancillary_data) ancillary_data_list; + buffer->ancillary_data = NULL; buffer->source = (sockaddr *)&buffer->storage.source; buffer->destination = (sockaddr *)&buffer->storage.destination; @@ -1063,11 +1046,7 @@ remove_data_node(node); } - while (ancillary_data* data = buffer->ancillary_data.RemoveHead()) { - if (data->destructor != NULL) - data->destructor(&data->header, data->Data()); - free(data); - } + delete_ancillary_data_container(buffer->ancillary_data); release_data_header(buffer->allocation_header); @@ -1873,89 +1852,17 @@ } -/*! - Attaches ancillary data to the given buffer. The data are completely - orthogonal to the data the buffer stores. - - \param buffer The buffer. - \param header Description of the data. - \param data If not \c NULL, the data are copied into the allocated storage. - \param destructor If not \c NULL, this function will be invoked with the - data as parameter when the buffer is destroyed. - \param _allocatedData Will be set to the storage allocated for the data. - \return \c B_OK when everything goes well, another error code otherwise. -*/ -static status_t -attach_ancillary_data(net_buffer *_buffer, const ancillary_data_header *header, - const void *data, void (*destructor)(const ancillary_data_header*, void*), - void **_allocatedData) +void +set_ancillary_data(net_buffer *buffer, ancillary_data_container *container) { - // TODO: Obviously it would be nice to allocate the memory for the - // ancillary data in the buffer. - net_buffer_private *buffer = (net_buffer_private *)_buffer; - - // check parameters - if (header == NULL) - return B_BAD_VALUE; - - if (header->len > MAX_ANCILLARY_DATA_SIZE) - return ENOBUFS; - - // allocate buffer - void *dataBuffer = malloc(_ALIGN(sizeof(ancillary_data)) + header->len); - if (dataBuffer == NULL) - return B_NO_MEMORY; - - // init and attach the structure - ancillary_data *ancillaryData = new(dataBuffer) ancillary_data; - ancillaryData->header = *header; - ancillaryData->destructor = destructor; - - buffer->ancillary_data.Add(ancillaryData); - - if (data != NULL) - memcpy(ancillaryData->Data(), data, header->len); - - if (_allocatedData != NULL) - *_allocatedData = ancillaryData->Data(); - - return B_OK; + ((net_buffer_private*)buffer)->ancillary_data = container; } -/*! - Detaches ancillary data from the given buffer. The associated memory is - free, i.e. the \a data pointer must no longer be used after calling this - function. Depending on \a destroy, the destructor is invoked before freeing - the data. - - \param buffer The buffer. - \param data Pointer to the data to be removed (as returned by - attach_ancillary_data() or next_ancillary_data()). - \param destroy If \c true, the destructor, if one was passed to - attach_ancillary_data(), is invoked for the data. - \return \c B_OK when everything goes well, another error code otherwise. -*/ -static status_t -detach_ancillary_data(net_buffer *_buffer, void *data, bool destroy) +ancillary_data_container* +get_ancillary_data(net_buffer *buffer) { - net_buffer_private *buffer = (net_buffer_private *)_buffer; - - if (data == NULL) - return B_BAD_VALUE; - - ancillary_data *ancillaryData = ancillary_data::FromData(data); - - buffer->ancillary_data.Remove(ancillaryData); - - if (destroy && ancillaryData->destructor != NULL) { - ancillaryData->destructor(&ancillaryData->header, - ancillaryData->Data()); - } - - free(ancillaryData); - - return B_OK; + return ((net_buffer_private*)buffer)->ancillary_data; } @@ -1965,7 +1872,7 @@ transfers or copies ancillary data from one buffer to another. \param from The buffer from which to remove the ancillary data. - \param to The buffer to which to add teh ancillary data. + \param to The buffer to which to add the ancillary data. \return A pointer to the first of the moved ancillary data, if any, \c NULL otherwise. */ @@ -1978,52 +1885,23 @@ if (from == NULL || to == NULL) return NULL; - ancillary_data *ancillaryData = from->ancillary_data.Head(); - to->ancillary_data.MoveFrom(&from->ancillary_data); + if (from->ancillary_data == NULL) + return NULL; - return ancillaryData != NULL ? ancillaryData->Data() : NULL; -} - - -/*! - Returns the next ancillary data. When iterating over the data, initially - a \c NULL pointer shall be passed as \a previousData, subsequently the - previously returned data pointer. After the last item, \c NULL is returned. - - Note, that it is not safe to call detach_ancillary_data() for a data item - and then pass that pointer to this function. First get the next item, then - detach the previous one. - - \param buffer The buffer. - \param previousData The pointer to the previous data returned by this - function. Initially \c NULL shall be passed. - \param header Pointer to allocated storage into which the data description - is written. May be \c NULL. - \return A pointer to the next ancillary data in the buffer. \c NULL after - the last one. -*/ -static void* -next_ancillary_data(net_buffer *_buffer, void *previousData, - ancillary_data_header *_header) -{ - net_buffer_private *buffer = (net_buffer_private *)_buffer; - - ancillary_data *ancillaryData; - - if (previousData == NULL) { - ancillaryData = buffer->ancillary_data.Head(); - } else { - ancillaryData = ancillary_data::FromData(previousData); - ancillaryData = buffer->ancillary_data.GetNext(ancillaryData); + if (to->ancillary_data == NULL) { + // no ancillary data in the target buffer + to->ancillary_data = from->ancillary_data; + from->ancillary_data = NULL; + return next_ancillary_data(to->ancillary_data, NULL, NULL); } - if (ancillaryData == NULL) - return NULL; + // both have ancillary data + void *data = move_ancillary_data(from->ancillary_data, + to->ancillary_data); + delete_ancillary_data_container(from->ancillary_data); + from->ancillary_data = NULL; - if (_header != NULL) - *_header = ancillaryData->header; - - return ancillaryData->Data(); + return data; } @@ -2228,10 +2106,9 @@ NULL, // associate_data - attach_ancillary_data, - detach_ancillary_data, + set_ancillary_data, + get_ancillary_data, transfer_ancillary_data, - next_ancillary_data, direct_access, read_data, Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-05-02 14:37:16 UTC (rev 25292) @@ -30,6 +30,7 @@ #include #include +#include "ancillary_data.h" #include "utility.h" @@ -134,8 +135,8 @@ static status_t -attach_ancillary_data(net_socket *socket, net_buffer *buffer, void *data, - size_t dataLen) +add_ancillary_data(net_socket *socket, ancillary_data_container* container, + void *data, size_t dataLen) { cmsghdr *header = (cmsghdr*)data; @@ -143,11 +144,11 @@ if (header->cmsg_len < sizeof(cmsghdr) || header->cmsg_len > dataLen) return B_BAD_VALUE; - if (socket->first_info->attach_ancillary_data == NULL) + if (socket->first_info->add_ancillary_data == NULL) return EOPNOTSUPP; - status_t status = socket->first_info->attach_ancillary_data( - socket->first_protocol, buffer, header); + status_t status = socket->first_info->add_ancillary_data( + socket->first_protocol, container, header); if (status != B_OK) return status; @@ -160,17 +161,20 @@ static status_t -process_ancillary_data(net_socket *socket, net_buffer *buffer, msghdr *_header) +process_ancillary_data(net_socket *socket, ancillary_data_container* container, + msghdr *_header) { + if (container == NULL) + return B_OK; + uint8 *dataBuffer = (uint8*)_header->msg_control; int dataBufferLen = _header->msg_controllen; ancillary_data_header header; void *data = NULL; - while ((data = gNetBufferModule.next_ancillary_data(buffer, data, &header)) - != NULL) { + while ((data = next_ancillary_data(container, data, &header)) != NULL) { if (socket->first_info->process_ancillary_data == NULL) return EOPNOTSUPP; @@ -943,7 +947,8 @@ // process ancillary data if (header != NULL) { if (buffer != NULL && header->msg_control != NULL) { - status = process_ancillary_data(socket, buffer, header); + status = process_ancillary_data(socket, + gNetBufferModule.get_ancillary_data(buffer), header); if (status != B_OK) { gNetBufferModule.free(buffer); return status; @@ -1129,8 +1134,15 @@ // attach ancillary data to the first buffer status_t status = B_OK; if (ancillaryData != NULL) { - status = attach_ancillary_data(socket, buffer, ancillaryData, - ancillaryDataLen); + ancillary_data_container *container + = create_ancillary_data_container(); + if (container != NULL) { + gNetBufferModule.set_ancillary_data(buffer, container); + status = add_ancillary_data(socket, container, ancillaryData, + ancillaryDataLen); + } else + status = B_NO_MEMORY; + ancillaryData = NULL; } Modified: haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-05-02 14:34:20 UTC (rev 25291) +++ haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-05-02 14:37:16 UTC (rev 25292) @@ -7,6 +7,7 @@ */ +#include "ancillary_data.h" #include "domains.h" #include "interfaces.h" #include "link.h" @@ -922,6 +923,13 @@ is_restarted_syscall, store_syscall_restart_timeout, restore_syscall_restart_timeout, + + create_ancillary_data_container, + delete_ancillary_data_container, + add_ancillary_data, + remove_ancillary_data, + move_ancillary_data, + next_ancillary_data }; module_info *modules[] = { From ingo_weinhold at gmx.de Fri May 2 17:39:53 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 17:39:53 +0200 Subject: [Haiku-commits] r25291 - in haiku/trunk: build/config_headers src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <200805021434.m42EYMHJ028861@sheep.berlios.de> References: <200805021434.m42EYMHJ028861@sheep.berlios.de> Message-ID: <20080502173953.684.4@knochen-vm.1209732708.fake> On 2008-05-02 at 16:34:22 [+0200], bga at BerliOS wrote: > Author: bga > Date: 2008-05-02 16:34:20 +0200 (Fri, 02 May 2008) > New Revision: 25291 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25291&view=rev > > Modified: > haiku/trunk/build/config_headers/tracing_config.h > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h > Log: > - Added AHCI port tracing (Only PRD table tracing for now). > - Added controller attribute to the AHCIPort class for debugging purposes. > > AHCI is failing whenever the PRD table has an address above the 2048 Mb > mark. > > > > Modified: haiku/trunk/build/config_headers/tracing_config.h > =================================================================== > --- haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 > 13:00:27 UTC (rev 25290) > +++ haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 > 14:34:20 UTC (rev 25291) > @@ -36,6 +36,7 @@ > #define TEAM_TRACING 0 > #define USER_MALLOC_TRACING 0 > #define WAIT_FOR_OBJECTS_TRACING 0 > +#define AHCI_PORT_TRACING 0 The list was in alphabetical order before. I would very much prefer it to stay that way. > Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp > =================================================================== > --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp > 2008-05-02 13:00:27 UTC (rev 25290) > +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp > 2008-05-02 14:34:20 UTC (rev 25291) > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) > //#define FLOW(a...) dprintf("ahci: " a) > @@ -22,9 +23,66 @@ > #define FLOW(a...) > #define RWTRACE(a...) > > +#if AHCI_PORT_TRACING > > +namespace AHCIPortTracing { > + > +class AHCIPortTraceEntry : public AbstractTraceEntry { > + protected: > + AHCIPortTraceEntry(AHCIController* controller, int index) > + : fController(controller) > + , fIndex(index) > + { > + } > + > + void AddDump(TraceOutput& out, const char* name) > + { > + out.Print(name); > + out.Print("controller: %p", fController); > + out.Print(", index: %d", fIndex); > + } There's kind of convention that the tracing output has a prefix that identifies the component it comes from. This also simplifies filtering. CU, Ingo From bga at bug-br.org.br Fri May 2 18:25:49 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Fri, 02 May 2008 13:25:49 -0300 Subject: [Haiku-commits] r25291 - in haiku/trunk: build/config_headers src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <20080502173953.684.4@knochen-vm.1209732708.fake> References: <200805021434.m42EYMHJ028861@sheep.berlios.de> <20080502173953.684.4@knochen-vm.1209732708.fake> Message-ID: <481B408D.70702@bug-br.org.br> Ingo Weinhold escreveu: >> #define WAIT_FOR_OBJECTS_TRACING 0 >> +#define AHCI_PORT_TRACING 0 > > The list was in alphabetical order before. I would very much prefer it to > stay that way. No worries, I will change that. Coincidentally, the WAIT_FOR_OBJECTS_TRACING one was the last to be added before mine so I end up not noticing the entries were sorted lexicographically instead of order of appearance. > There's kind of convention that the tracing output has a prefix that > identifies the component it comes from. This also simplifies filtering. You mean just prepending something like "ahci port" to the output? -Bruno From ingo_weinhold at gmx.de Fri May 2 18:31:01 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 02 May 2008 18:31:01 +0200 Subject: [Haiku-commits] r25291 - in haiku/trunk: build/config_headers src/add-ons/kernel/busses/scsi/ahci In-Reply-To: <481B408D.70702@bug-br.org.br> References: <200805021434.m42EYMHJ028861@sheep.berlios.de> <20080502173953.684.4@knochen-vm.1209732708.fake> <481B408D.70702@bug-br.org.br> Message-ID: <20080502183101.788.6@knochen-vm.1209732708.fake> On 2008-05-02 at 18:25:49 [+0200], Bruno Albuquerque wrote: > Ingo Weinhold escreveu: [...] > > There's kind of convention that the tracing output has a prefix that > > identifies the component it comes from. This also simplifies filtering. > > You mean just prepending something like "ahci port" to the output? Exactly. CU, Ingo From bga at mail.berlios.de Fri May 2 19:02:42 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Fri, 2 May 2008 19:02:42 +0200 Subject: [Haiku-commits] r25293 - in haiku/trunk: build/config_headers src/add-ons/kernel/busses/scsi/ahci Message-ID: <200805021702.m42H2gnw020310@sheep.berlios.de> Author: bga Date: 2008-05-02 19:02:41 +0200 (Fri, 02 May 2008) New Revision: 25293 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25293&view=rev Modified: haiku/trunk/build/config_headers/tracing_config.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp Log: - Moved AHCI_PORT_TRACING define to its correct position. - Prepend "ahci port" to all trace entries in ahci_port.cpp. Modified: haiku/trunk/build/config_headers/tracing_config.h =================================================================== --- haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 14:37:16 UTC (rev 25292) +++ haiku/trunk/build/config_headers/tracing_config.h 2008-05-02 17:02:41 UTC (rev 25293) @@ -18,6 +18,7 @@ // macros specifying the tracing level for individual components (0 is disabled) +#define AHCI_PORT_TRACING 0 #define BFS_TRACING 0 #define BLOCK_CACHE_TRANSACTION_TRACING 0 #define BMESSAGE_TRACING 0 @@ -36,7 +37,6 @@ #define TEAM_TRACING 0 #define USER_MALLOC_TRACING 0 #define WAIT_FOR_OBJECTS_TRACING 0 -#define AHCI_PORT_TRACING 0 #endif // ENABLE_TRACING Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-05-02 14:37:16 UTC (rev 25292) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2008-05-02 17:02:41 UTC (rev 25293) @@ -37,7 +37,8 @@ void AddDump(TraceOutput& out, const char* name) { - out.Print(name); + out.Print("ahci port"); + out.Print(" - %s - ", name); out.Print("controller: %p", fController); out.Print(", index: %d", fIndex); } @@ -60,9 +61,9 @@ void AddDump(TraceOutput& out) { - AHCIPortTraceEntry::AddDump(out, " - prd table: "); + AHCIPortTraceEntry::AddDump(out, "prd table"); - out.Print("address: %p", fAddress); + out.Print(", address: %p", fAddress); out.Print(", size: %lu", fSize); } From axeld at mail.berlios.de Fri May 2 19:36:28 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 2 May 2008 19:36:28 +0200 Subject: [Haiku-commits] r25294 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200805021736.m42HaSZQ001135@sheep.berlios.de> Author: axeld Date: 2008-05-02 19:36:28 +0200 (Fri, 02 May 2008) New Revision: 25294 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25294&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h Log: * The WaitList now always notifies all waiters. * In SendData(), TCP will now split the buffer into smaller parts if it can send data (ie. there is free space in the buffer queue left, but not enough to send the whole buffer, and the free space is more than the send low water mark of the socket). * Both of these changes together let TCP now pass the "forwarding" test of the OpenSSH suite. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-02 17:02:41 UTC (rev 25293) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-02 17:36:28 UTC (rev 25294) @@ -329,21 +329,20 @@ status_t -WaitList::Wait(MutexLocker& locker, bigtime_t timeout, bool wakeNext) +WaitList::Wait(MutexLocker& locker, bigtime_t timeout) { locker.Unlock(); status_t status = B_OK; - while (status == B_OK && !atomic_test_and_set(&fCondition, 0, 1)) { + while (!atomic_test_and_set(&fCondition, 0, 1)) { status = acquire_sem_etc(fSem, 1, B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT, timeout); + if (status != B_OK) + break; } locker.Lock(); - if (status == B_OK && wakeNext) - Signal(); - return status; } @@ -353,11 +352,11 @@ { atomic_or(&fCondition, 1); #ifdef __HAIKU__ - release_sem_etc(fSem, 1, B_DO_NOT_RESCHEDULE | B_RELEASE_IF_WAITING_ONLY); + release_sem_etc(fSem, 1, B_DO_NOT_RESCHEDULE | B_RELEASE_ALL); #else int32 count; if (get_sem_count(fSem, &count) == B_OK && count < 0) - release_sem_etc(fSem, 1, B_DO_NOT_RESCHEDULE); + release_sem_etc(fSem, -count, B_DO_NOT_RESCHEDULE); #endif } @@ -423,6 +422,9 @@ } mutex_destroy(&fLock); + + // TODO: we need to wait for all timers to return + //_WaitForTimers(); } @@ -730,17 +732,18 @@ return EPIPE; } - if (buffer->size > 0) { - if (buffer->size > fSendQueue.Size()) - return ENOBUFS; + uint32 flags = buffer->flags; + size_t left = buffer->size; - bigtime_t timeout = absolute_timeout(socket->send.timeout); - if (gStackModule->is_restarted_syscall()) - timeout = gStackModule->restore_syscall_restart_timeout(); - else - gStackModule->store_syscall_restart_timeout(timeout); + bigtime_t timeout = absolute_timeout(socket->send.timeout); + if (gStackModule->is_restarted_syscall()) + timeout = gStackModule->restore_syscall_restart_timeout(); + else + gStackModule->store_syscall_restart_timeout(timeout); - while (fSendQueue.Free() < buffer->size) { + while (left > 0) { + while (fSendQueue.Free() < socket->send.low_water_mark) { + // wait until enough space is available status_t status = fSendList.Wait(lock, timeout); if (status < B_OK) { TRACE(" SendData() returning %s (%d)", @@ -749,19 +752,42 @@ } } - fSendQueue.Add(buffer); + size_t size = fSendQueue.Free(); + if (size < left) { + // we need to split the original buffer + net_buffer* clone = gBufferModule->clone(buffer, false); + // TODO: add offset/size parameter to net_buffer::clone() or + // even a move_data() function, as this is a bit inefficient + if (clone == NULL) + return ENOBUFS; + + status_t status = gBufferModule->trim(clone, size); + if (status != B_OK) { + gBufferModule->free(clone); + return status; + } + + gBufferModule->remove_header(buffer, size); + left -= size; + fSendQueue.Add(clone); + } else { + left -= buffer->size; + fSendQueue.Add(buffer); + } } TRACE(" SendData(): %lu bytes used.", fSendQueue.Used()); bool force = false; - if ((buffer->flags & MSG_OOB) != 0) { + if ((flags & MSG_OOB) != 0) { fSendUrgentOffset = fSendQueue.LastSequence(); // RFC 961 specifies that the urgent offset points to the last // byte of urgent data. However, this is commonly implemented as // here, ie. it points to the first byte after the urgent data. force = true; } + if ((flags & MSG_EOF) != 0) + _Disconnect(false); if (fState == ESTABLISHED || fState == FINISH_RECEIVED) _SendQueued(force); @@ -857,7 +883,7 @@ if ((flags & MSG_DONTWAIT) != 0 || socket->receive.timeout == 0) return B_WOULD_BLOCK; - status_t status = fReceiveList.Wait(locker, timeout, false); + status_t status = fReceiveList.Wait(locker, timeout); if (status < B_OK) { // The Open Group base specification mentions that EINTR should be // returned if the recv() is interrupted before _any data_ is @@ -876,7 +902,7 @@ if (numBytes < fReceiveQueue.Available()) fReceiveList.Signal(); - bool clone = (flags & MSG_PEEK); + bool clone = (flags & MSG_PEEK) != 0; ssize_t receivedBytes = fReceiveQueue.Get(numBytes, !clone, _buffer); @@ -2159,6 +2185,17 @@ TCPEndpoint* endpoint = (TCPEndpoint*)_endpoint; T(Timer(endpoint, "time-wait")); + MutexLocker locker(endpoint->fLock); + if (!locker.IsLocked()) + return; + + if ((endpoint->fFlags & FLAG_CLOSED) == 0) { + endpoint->fFlags |= FLAG_DELETE_ON_CLOSE; + return; + } + + locker.Unlock(); + gSocketModule->delete_socket(endpoint->socket); } Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-05-02 17:02:41 UTC (rev 25293) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-05-02 17:36:28 UTC (rev 25294) @@ -32,7 +32,7 @@ status_t InitCheck() const; - status_t Wait(MutexLocker &, bigtime_t timeout, bool wakeNext = true); + status_t Wait(MutexLocker &, bigtime_t timeout); void Signal(); private: From axeld at pinc-software.de Fri May 2 20:34:01 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 20:34:01 +0200 CEST Subject: [Haiku-commits] r25287 - haiku/trunk/src/add-ons/kernel/network/stack In-Reply-To: <20080502150426.540.2@knochen-vm.1209732708.fake> Message-ID: <34077359000-BeMail@zon> Ingo Weinhold wrote: > > Actually the link level should always sit directly on top of the > > data > > link. > I haven't tried to understand yet how the protocols and > datalink_protocols > are supposed to work together. So, if the situation that the next > protocol > is NULL should never occur in link_{g,s}etsockopt() I trust you will > fix > it. :-) Maybe :-) > > I didn't really like that Hugo separated the control() hook from > > {get,set}sockopt(), but now that we have extra syscall for them, it > > may > > make more sense; I didn't review it that much back then, because I > > thought we would end up reverting that change. > Mmh, I've just used what was already there. If you think it is nicer > to let > the socket descriptor ioctl() hook translate to {g,s}etsockopt(), we > can do > that. No, it would be (and was) the other way around, actually - control() would contain setsockopt() and getsockopt() in the protocols; from the socket API, ioctl(), setsockopt(), and getsockopt() would all end up in the same function at protocol level - only the "level" argument would differ (I don't know why Hugo left the "level" in control(), as it has no meaning anymore currently). I'm not sure what I would prefer, so I don't want to spend the extra effort to revert the current solution either. Do you have any preference and can convince me? :-)) Bye, Axel. From axeld at pinc-software.de Fri May 2 20:41:00 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 20:41:00 +0200 CEST Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080502154906.570.3@knochen-vm.1209732708.fake> Message-ID: <34496480162-BeMail@zon> Ingo Weinhold wrote: > > However, what exactly happens with this test? > > I had it wait for closing connections, but they were all left > > established. Also, the open sockets used up more than 27 MB - which > > doesn't really look good. > I don't know about that. At least one TCP connection and a few UNIX > socket > connections should stay open during the whole test. They are > associated > with the ssh connection that forwards the ports. I don't know exactly > how > port forwarding is implemented, but I think it just uses the one TCP > connection. Until the forwarded ports are used, of course. It seems to use lots of connections. When I let the test run, it eventually comes to a point where it wants to end (endless loop or not); there might still be progress, the loop will just consume 100% CPU time. > The problem I usually encounter is that an ssh and an sshd process > both > start to infinitely loop in TCPEndpoint::SendData() -> > WaitList::Wait() at > some point. If they don't, the test will just pass. The test runs for > a > while and has no output (unless you enable it; cf. README.regress), > so it > helps to keep ProcessController's team menu open. The infinite loop > situation is easily recognizable. If you had waited a bit more, it would have spilled out some data :-) In any case, I haven't seen the high memory usage anymore, now. Before, it would always happen when I let the test progress after TCP ate all CPU power. > Regarding memory usage, the UNIX socket implementation is really > inefficient in that respect ATM. If the sent messages are small a lot > of > memory is wasted, since it just queues the buffers (which are 2 KB > minimum). I don't think OpenSSH uses them in a way that would explain > 27 > MB, but I wouldn't completely rule that out either. I'm already in > the > process of extending the protocol interface so that the situation can > be > remedied. I don't think it was the source of the problem, if that helps :-) Bye, Axel. From axeld at pinc-software.de Fri May 2 20:43:00 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 02 May 2008 20:43:00 +0200 CEST Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080502145558.508.1@knochen-vm.1209732708.fake> Message-ID: <34616761249-BeMail@zon> Ingo Weinhold wrote: > > BTW "automake --add-missing" did fail after I updated the tree > > (from > > before your cutex changes, IIRC); I had to manually copy > > config.{guess| > > sub}. > automake should indeed fail, but it should still replace config.guess > and > config.sub. Worked and still (r25288) works for me: I built a new image, and it now works again for me, too. I hope it was a user error of some kind, and not some flaky Haiku problem :-) Bye, Axel. From mmu_man at mail.berlios.de Sat May 3 00:13:09 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 3 May 2008 00:13:09 +0200 Subject: [Haiku-commits] r25295 - haiku/trunk/src/apps/showimage Message-ID: <200805022213.m42MD92h016785@sheep.berlios.de> Author: mmu_man Date: 2008-05-03 00:13:09 +0200 (Sat, 03 May 2008) New Revision: 25295 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25295&view=rev Modified: haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp haiku/trunk/src/apps/showimage/ShowImageStatusView.h Log: Added a path popup menu like Tracker's and Pe's to the Status bar. Modified: haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp =================================================================== --- haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp 2008-05-02 17:36:28 UTC (rev 25294) +++ haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp 2008-05-02 22:13:09 UTC (rev 25295) @@ -27,7 +27,15 @@ /*****************************************************************************/ #include "ShowImageStatusView.h" +#include "ShowImageView.h" +#include "ShowImageWindow.h" +#include +#include +#include +#include + + ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) : BView(rect, name, resizingMode, flags) @@ -42,6 +50,7 @@ SetFont(&font); } + void ShowImageStatusView::Draw(BRect updateRect) { @@ -82,9 +91,51 @@ + fh.ascent / 2.0))); } + void +ShowImageStatusView::MouseDown(BPoint where) +{ + ShowImageWindow *window = dynamic_cast(Window()); + if (!window || window->GetShowImageView() == NULL) + return; + + BPath path; + path.SetTo(window->GetShowImageView()->Image()); + + BPopUpMenu popup("no title"); + popup.SetFont(be_plain_font); + + while (path.GetParent(&path) == B_OK && path != "/") { + popup.AddItem(new BMenuItem(path.Leaf(), NULL)); + } + + BRect bounds(Bounds()); + ConvertToScreen(&bounds); + where = bounds.LeftBottom(); + + BMenuItem *item; + item = popup.Go(where, true, false, ConvertToScreen(Bounds())); + + if (item) { + path.SetTo(window->GetShowImageView()->Image()); + path.GetParent(&path); + int index = popup.IndexOf(item); + while (index--) + path.GetParent(&path); + BMessenger tracker("application/x-vnd.Be-TRAK"); + BMessage msg(B_REFS_RECEIVED); + entry_ref ref; + get_ref_for_path(path.Path(), &ref); + msg.AddRef("refs", &ref); + tracker.SendMessage(msg); + } +} + + +void ShowImageStatusView::SetText(BString &text) { fText = text; Invalidate(); } + Modified: haiku/trunk/src/apps/showimage/ShowImageStatusView.h =================================================================== --- haiku/trunk/src/apps/showimage/ShowImageStatusView.h 2008-05-02 17:36:28 UTC (rev 25294) +++ haiku/trunk/src/apps/showimage/ShowImageStatusView.h 2008-05-02 22:13:09 UTC (rev 25295) @@ -38,6 +38,8 @@ uint32 flags); virtual void Draw(BRect updateRect); + + virtual void MouseDown(BPoint where); void SetText(BString &text); From mmu_man at mail.berlios.de Sat May 3 00:23:51 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 3 May 2008 00:23:51 +0200 Subject: [Haiku-commits] r25296 - haiku/trunk/src/apps/showimage Message-ID: <200805022223.m42MNpjk017076@sheep.berlios.de> Author: mmu_man Date: 2008-05-03 00:23:50 +0200 (Sat, 03 May 2008) New Revision: 25296 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25296&view=rev Modified: haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp Log: Haiku's BMessenger::SendMessage() only takes a pointer... Modified: haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp =================================================================== --- haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp 2008-05-02 22:13:09 UTC (rev 25295) +++ haiku/trunk/src/apps/showimage/ShowImageStatusView.cpp 2008-05-02 22:23:50 UTC (rev 25296) @@ -127,7 +127,7 @@ entry_ref ref; get_ref_for_path(path.Path(), &ref); msg.AddRef("refs", &ref); - tracker.SendMessage(msg); + tracker.SendMessage(&msg); } } From nielx at mail.berlios.de Sat May 3 00:49:23 2008 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Sat, 3 May 2008 00:49:23 +0200 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem Message-ID: <200805022249.m42MnNZI017075@sheep.berlios.de> Author: nielx Date: 2008-05-03 00:49:23 +0200 (Sat, 03 May 2008) New Revision: 25297 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25297&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Update copyright entries in the about window. Work done by scottmc. Thanks! This closes #1222. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-02 22:23:50 UTC (rev 25296) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-02 22:49:23 UTC (rev 25297) @@ -516,7 +516,7 @@ "released under the GPL and LGPL licences:\n" "GNU C Library, " "GNU coretools, diffutils, findutils, " - "gawk, bison, m4, make, " + "shareutils, gawk, bison, m4, make, " "gdb, wget, ncurses, termcap, " "Bourne Again Shell.\n" "Copyright " B_UTF8_COPYRIGHT " The Free Software Foundation.", @@ -527,7 +527,8 @@ AddCopyrightEntry("The FreeBSD Project", "Contains software from the FreeBSD Project, " "released under the BSD licence:\n" - "ping, telnet, telnetd, traceroute\n" + "cal, ftpd, ping, telnet, " + "telnetd, traceroute\n" "Copyright " B_UTF8_COPYRIGHT " 1994-2008 The FreeBSD Project. " "All rights reserved.", "http://www.freebsd.org"); @@ -536,7 +537,7 @@ AddCopyrightEntry("The NetBSD Project", "Contains software developed by the NetBSD, " "Foundation, Inc. and its contributors:\n" - "ftp\n" + "ftp, tput\n" "Copyright " B_UTF8_COPYRIGHT " 1996-2008 The NetBSD Foundation, Inc. " "All rights reserved.", "http://www.netbsd.org"); @@ -646,12 +647,25 @@ // acpica copyrights AddCopyrightEntry("acpica", - "Copyright " B_UTF8_COPYRIGHT " 1999 - 2006 Intel Corp."); + "Copyright " B_UTF8_COPYRIGHT " 1999-2006 Intel Corp."); // unrar copyrights AddCopyrightEntry("unrar", - "Copyright " B_UTF8_COPYRIGHT " Alexander L. Roshal."); + "Copyright " B_UTF8_COPYRIGHT " 2002-2008 Alexander L. Roshal. " + "All rights reserved.", + "http://www.rarlab.com"); +// p7zip copyrights +// AddCopyrightEntry("p7zip", +// "Copyright " B_UTF8_COPYRIGHT " 2008 Igor Pavlov. " +// "All rights reserved."); + +// libMicros copyrights +// AddCopyrightEntry("libMicro", +// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun Microsystems, Inc. " +// "All rights reserved."); + // Open Solaris License + // libpng copyrights AddCopyrightEntry("libpng", "Copyright " B_UTF8_COPYRIGHT " 2004, 2006-2008 Glenn " @@ -659,8 +673,8 @@ // libprint copyrights AddCopyrightEntry("libprint", - "Copyright " B_UTF8_COPYRIGHT " 1999-2000 Y.Takagi. All Rights " - "Reserved."); + "Copyright " B_UTF8_COPYRIGHT " 1999-2000 Y.Takagi. All rights " + "reserved."); // cortex copyrights AddCopyrightEntry("Cortex", @@ -676,24 +690,37 @@ // libxml2, libxslt, libexslt copyrights AddCopyrightEntry("libxml2, libxslt", - "Copyright " B_UTF8_COPYRIGHT " 1998-2003 Daniel Veillard. All Rights " - "Reserved."); + "Copyright " B_UTF8_COPYRIGHT " 1998-2003 Daniel Veillard. " + "All rights reserved."); AddCopyrightEntry("libexslt", "Copyright " B_UTF8_COPYRIGHT " 2001-2002 Thomas Broyer, Charlie " - "Bozeman and Daniel Veillard. All Rights Reserved."); + "Bozeman and Daniel Veillard. All rights reserved."); // Xiph.org Foundation copyrights AddCopyrightEntry("Xiph.org Foundation", "libvorbis, libogg, libtheora, libspeex" - "Copyright " B_UTF8_COPYRIGHT " 1994-2008 Xiph.Org. All rights " - "reserved.", "http://www.xiph.org"); + "Copyright " B_UTF8_COPYRIGHT " 1994-2008 Xiph.Org. " + "All rights reserved.", + "http://www.xiph.org"); // The Tcpdump Group AddCopyrightEntry("The Tcpdump Group", "tcpdump, libpcap", "http://www.tcpdump.org"); + // Matroska + AddCopyrightEntry("libmatroska", + "Copyright " B_UTF8_COPYRIGHT " 2002-2003 Steve Lhomme. " + "All rights reserved.", + "http://www.matroska.org"); + +// OpenSound +// AddCopyrightEntry("OpenSound", +// "Copyright " B_UTF8_COPYRIGHT " 1996-2008 4Front Technologies ", +// "http://www.opensound.com"); +// BSD license + _AddCopyrightsFromAttribute(); // Build a list of installed applications and show their From leavengood at gmail.com Sat May 3 00:54:29 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Fri, 2 May 2008 18:54:29 -0400 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <200805022249.m42MnNZI017075@sheep.berlios.de> References: <200805022249.m42MnNZI017075@sheep.berlios.de> Message-ID: On Fri, May 2, 2008 at 6:49 PM, nielx at BerliOS wrote: > > +// p7zip copyrights > +// AddCopyrightEntry("p7zip", > +// "Copyright " B_UTF8_COPYRIGHT " 2008 Igor Pavlov. " > +// "All rights reserved."); > + > +// libMicros copyrights > +// AddCopyrightEntry("libMicro", > +// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun Microsystems, Inc. " > +// "All rights reserved."); > + // Open Solaris License > + Why are some things commented out? Ryan From niels.reedijk at gmail.com Sat May 3 01:05:30 2008 From: niels.reedijk at gmail.com (Niels Reedijk) Date: Sat, 3 May 2008 01:05:30 +0200 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: References: <200805022249.m42MnNZI017075@sheep.berlios.de> Message-ID: <507d86c0805021605i395ebacdw41d839f1d285ccee@mail.gmail.com> Hi Ryan, 2008/5/3 Ryan Leavengood : > On Fri, May 2, 2008 at 6:49 PM, nielx at BerliOS wrote: > > > > +// p7zip copyrights > > +// AddCopyrightEntry("p7zip", > > +// "Copyright " B_UTF8_COPYRIGHT " 2008 Igor Pavlov. " > > +// "All rights reserved."); 7zip is not yet in the repository, but someone was working on it and Scott decided to add them so that they can be commented out later. > > +// libMicros copyrights > > +// AddCopyrightEntry("libMicro", > > +// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun Microsystems, Inc. " > > +// "All rights reserved."); > > + // Open Solaris License > > + > > Why are some things commented out? Libmicro is used by one of the optional packages (which one, is hard to find). Scott asked whether he should delete them, or, keep them commented out. Ingo did not respond directly to this question, so the lines are commented out right now. You can view it as a reminder for Ingo to work on a new and improved automated copyright notice system. So this will be worked on anyway. Kind regards, N. From bonefish at mail.berlios.de Sat May 3 03:04:20 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 3 May 2008 03:04:20 +0200 Subject: [Haiku-commits] r25298 - haiku/trunk/src/system/kernel/fs Message-ID: <200805030104.m4314Kpc019420@sheep.berlios.de> Author: bonefish Date: 2008-05-03 03:04:20 +0200 (Sat, 03 May 2008) New Revision: 25298 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25298&view=rev Modified: haiku/trunk/src/system/kernel/fs/socket.cpp Log: Also check whether the data pointers of provided userland iovecs are actually pointing to userland. This saves checks in the net stack. Modified: haiku/trunk/src/system/kernel/fs/socket.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/socket.cpp 2008-05-02 22:49:23 UTC (rev 25297) +++ haiku/trunk/src/system/kernel/fs/socket.cpp 2008-05-03 01:04:20 UTC (rev 25298) @@ -161,6 +161,11 @@ return B_BAD_ADDRESS; } + for (int i = 0; i < message.msg_iovlen; i++) { + if (!IS_USER_ADDRESS(vecs[i].iov_base)) + return B_BAD_ADDRESS; + } + message.msg_iov = vecs; } else { message.msg_iov = NULL; From ingo_weinhold at gmx.de Sat May 3 03:01:47 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 03 May 2008 03:01:47 +0200 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <507d86c0805021605i395ebacdw41d839f1d285ccee@mail.gmail.com> References: <200805022249.m42MnNZI017075@sheep.berlios.de> <507d86c0805021605i395ebacdw41d839f1d285ccee@mail.gmail.com> Message-ID: <20080503030147.1361.8@knochen-vm.1209732708.fake> On 2008-05-03 at 01:05:30 [+0200], Niels Reedijk wrote: > 2008/5/3 Ryan Leavengood : > > > +// libMicros copyrights > > > +// AddCopyrightEntry("libMicro", > > > +// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun > > > Microsystems, Inc. " > > > +// "All rights reserved."); > > > + // Open Solaris License > > > + > > > > Why are some things commented out? > > Libmicro is used by one of the optional packages (which one, is hard > to find). There's a libMicro optional test package. > Scott asked whether he should delete them, or, keep them > commented out. Ingo did not respond directly to this question, so the > lines are commented out right now. You can view it as a reminder for > Ingo to work on a new and improved automated copyright notice system. > So this will be worked on anyway. It's somewhere on my list, yes. CU, Ingo From bonefish at mail.berlios.de Sat May 3 03:11:21 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 3 May 2008 03:11:21 +0200 Subject: [Haiku-commits] r25299 - in haiku/trunk: headers/private/net src/add-ons/kernel/network/stack Message-ID: <200805030111.m431BL14019655@sheep.berlios.de> Author: bonefish Date: 2008-05-03 03:11:21 +0200 (Sat, 03 May 2008) New Revision: 25299 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25299&view=rev Modified: haiku/trunk/headers/private/net/net_protocol.h haiku/trunk/src/add-ons/kernel/network/stack/Jamfile haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp Log: * Added optional {send,read}_data_no_buffer() hooks to the protocol module interface. They directly operate on iovecs and thus allow protocols that don't need it to avoid the creation of a net_buffer. * Adjusted the socket module to support the new hooks. If they are present, they will be chosen over the old hooks. Modified: haiku/trunk/headers/private/net/net_protocol.h =================================================================== --- haiku/trunk/headers/private/net/net_protocol.h 2008-05-03 01:04:20 UTC (rev 25298) +++ haiku/trunk/headers/private/net/net_protocol.h 2008-05-03 01:11:21 UTC (rev 25299) @@ -19,6 +19,8 @@ struct ancillary_data_container; struct ancillary_data_header; +struct iovec; + typedef struct net_protocol { struct net_protocol *next; struct net_protocol_module_info *module; @@ -77,6 +79,13 @@ ssize_t (*process_ancillary_data)(net_protocol *self, const ancillary_data_header *header, const void *data, void *buffer, size_t bufferSize); + + ssize_t (*send_data_no_buffer)(net_protocol *self, const iovec *vecs, + size_t vecCount, ancillary_data_container *ancillaryData, + const struct sockaddr *address, socklen_t addressLength); + ssize_t (*read_data_no_buffer)(net_protocol *self, const iovec *vecs, + size_t vecCount, ancillary_data_container **_ancillaryData, + struct sockaddr *_address, socklen_t *_addressLength); }; #endif // NET_PROTOCOL_H Modified: haiku/trunk/src/add-ons/kernel/network/stack/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/Jamfile 2008-05-03 01:04:20 UTC (rev 25298) +++ haiku/trunk/src/add-ons/kernel/network/stack/Jamfile 2008-05-03 01:11:21 UTC (rev 25299) @@ -12,7 +12,7 @@ UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; -UsePrivateHeaders net ; +UsePrivateHeaders net shared ; KernelAddon stack : ancillary_data.cpp Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-05-03 01:04:20 UTC (rev 25298) +++ haiku/trunk/src/add-ons/kernel/network/stack/net_socket.cpp 2008-05-03 01:11:21 UTC (rev 25299) @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -162,18 +163,19 @@ static status_t process_ancillary_data(net_socket *socket, ancillary_data_container* container, - msghdr *_header) + msghdr *messageHeader) { - if (container == NULL) + uint8 *dataBuffer = (uint8*)messageHeader->msg_control; + int dataBufferLen = messageHeader->msg_controllen; + + if (container == NULL || dataBuffer == NULL) { + messageHeader->msg_controllen = 0; return B_OK; + } - uint8 *dataBuffer = (uint8*)_header->msg_control; - int dataBufferLen = _header->msg_controllen; - ancillary_data_header header; void *data = NULL; - while ((data = next_ancillary_data(container, data, &header)) != NULL) { if (socket->first_info->process_ancillary_data == NULL) return EOPNOTSUPP; @@ -187,12 +189,45 @@ dataBufferLen -= bytesWritten; } - _header->msg_controllen -= dataBufferLen; + messageHeader->msg_controllen -= dataBufferLen; return B_OK; } +static ssize_t +socket_receive_no_buffer(net_socket *socket, msghdr *header, void *data, + size_t length, int flags) +{ + iovec stackVec = { data, length }; + iovec* vecs = header ? header->msg_iov : &stackVec; + int vecCount = header ? header->msg_iovlen : 1; + sockaddr* address = header ? (sockaddr*)header->msg_name : NULL; + socklen_t* addressLen = header ? &header->msg_namelen : NULL; + + ancillary_data_container* ancillaryData = NULL; + ssize_t bytesRead = socket->first_info->read_data_no_buffer( + socket->first_protocol, vecs, vecCount, &ancillaryData, address, + addressLen); + if (bytesRead < 0) + return bytesRead; + + CObjectDeleter ancillaryDataDeleter(ancillaryData, + &delete_ancillary_data_container); + + // process ancillary data + if (header != NULL) { + status_t status = process_ancillary_data(socket, ancillaryData, header); + if (status != B_OK) + return status; + + header->msg_flags = 0; + } + + return bytesRead; +} + + // #pragma mark - @@ -919,9 +954,12 @@ socket_receive(net_socket *socket, msghdr *header, void *data, size_t length, int flags) { + // If the protocol sports read_data_no_buffer() we use it. + if (socket->first_info->read_data_no_buffer != NULL) + return socket_receive_no_buffer(socket, header, data, length, flags); + size_t totalLength = length; net_buffer *buffer; - iovec tmp; int i; // the convention to this function is that have header been @@ -930,13 +968,8 @@ if (header) { // calculate the length considering all of the extra buffers - for (i = 1; i < header->msg_iovlen; i++) { - if (user_memcpy(&tmp, header->msg_iov + i, sizeof(iovec)) < B_OK) - return B_BAD_ADDRESS; - if (tmp.iov_len > 0 && tmp.iov_base == NULL) - return B_BAD_ADDRESS; - totalLength += tmp.iov_len; - } + for (i = 1; i < header->msg_iovlen; i++) + totalLength += header->msg_iov[i].iov_len; } status_t status = socket->first_info->read_data( @@ -989,14 +1022,13 @@ // we only start considering at iovec[1] // as { data, length } is iovec[0] for (i = 1; i < header->msg_iovlen && bytesCopied < bytesReceived; i++) { - if (user_memcpy(&tmp, header->msg_iov + i, sizeof(iovec)) < B_OK) + iovec& vec = header->msg_iov[i]; + size_t toRead = min_c(bytesReceived - bytesCopied, vec.iov_len); + if (gNetBufferModule.read(buffer, bytesCopied, vec.iov_base, + toRead) < B_OK) { break; + } - size_t toRead = min_c(bytesReceived - bytesCopied, tmp.iov_len); - if (gNetBufferModule.read(buffer, bytesCopied, tmp.iov_base, - toRead) < B_OK) - break; - bytesCopied += toRead; } @@ -1031,24 +1063,25 @@ if (length > SSIZE_MAX) return B_BAD_VALUE; - // the convention to this function is that have header been - // present, { data, length } would have been iovec[0] and is - // always considered like that + ancillary_data_container *ancillaryData = NULL; + CObjectDeleter ancillaryDataDeleter(NULL, + &delete_ancillary_data_container); - cmsghdr *ancillaryData = NULL; - size_t ancillaryDataLen = 0; - if (header != NULL) { address = (const sockaddr *)header->msg_name; addressLength = header->msg_namelen; - ancillaryData = (cmsghdr *)header->msg_control; - ancillaryDataLen = header->msg_controllen; - if (header->msg_iovlen <= 1) - header = NULL; - else { - bytesLeft += compute_user_iovec_length(header->msg_iov + 1, - header->msg_iovlen - 1); + // get the ancillary data + if (header->msg_control != NULL) { + ancillaryData = create_ancillary_data_container(); + if (ancillaryData == NULL) + return B_NO_MEMORY; + ancillaryDataDeleter.SetTo(ancillaryData); + + status_t status = add_ancillary_data(socket, ancillaryData, + (cmsghdr *)header->msg_control, header->msg_controllen); + if (status != B_OK) + return status; } } @@ -1082,6 +1115,33 @@ return status; } + // If the protocol has a send_data_no_buffer() hook, we use that one. + if (socket->first_info->send_data_no_buffer != NULL) { + iovec stackVec = { (void*)data, length }; + iovec* vecs = header ? header->msg_iov : &stackVec; + int vecCount = header ? header->msg_iovlen : 1; + + ssize_t written = socket->first_info->send_data_no_buffer( + socket->first_protocol, vecs, vecCount, ancillaryData, address, + addressLength); + if (written > 0) + ancillaryDataDeleter.Detach(); + return written; + } + + // By convention, if a header is given, the (data, length) equals the first + // iovec. So drop the header, if it is the only iovec. Otherwise compute + // the size of the remaining ones. + if (header != NULL) { + if (header->msg_iovlen <= 1) + header = NULL; + else { +// TODO: The iovecs have already been copied to kernel space. Simplify! + bytesLeft += compute_user_iovec_length(header->msg_iov + 1, + header->msg_iovlen - 1); + } + } + ssize_t bytesSent = 0; size_t vecOffset = 0; uint32 vecIndex = 0; @@ -1134,15 +1194,8 @@ // attach ancillary data to the first buffer status_t status = B_OK; if (ancillaryData != NULL) { - ancillary_data_container *container - = create_ancillary_data_container(); - if (container != NULL) { - gNetBufferModule.set_ancillary_data(buffer, container); - status = add_ancillary_data(socket, container, ancillaryData, - ancillaryDataLen); - } else - status = B_NO_MEMORY; - + gNetBufferModule.set_ancillary_data(buffer, ancillaryData); + ancillaryDataDeleter.Detach(); ancillaryData = NULL; } From bonefish at mail.berlios.de Sat May 3 03:14:45 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 3 May 2008 03:14:45 +0200 Subject: [Haiku-commits] r25300 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805030114.m431EjRm019886@sheep.berlios.de> Author: bonefish Date: 2008-05-03 03:14:44 +0200 (Sat, 03 May 2008) New Revision: 25300 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25300&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp Log: * Support the new {send,read}_data_no_buffer() protocol hooks to avoid unnecessary data copies and waste of memory. * Changed the storage backend to ring_buffer. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-03 01:11:21 UTC (rev 25299) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-03 01:14:44 UTC (rev 25300) @@ -414,11 +414,12 @@ } -status_t -UnixEndpoint::Send(net_buffer *buffer) +ssize_t +UnixEndpoint::Send(const iovec *vecs, size_t vecCount, + ancillary_data_container *ancillaryData) { - TRACE("[%ld] %p->UnixEndpoint::Send(%p)\n", find_thread(NULL), this, - buffer); + TRACE("[%ld] %p->UnixEndpoint::Send(%p, %ld, %p)\n", find_thread(NULL), + this, vecs, vecCount, ancillaryData); bigtime_t timeout = absolute_timeout(socket->send.timeout); if (gStackModule->is_restarted_syscall()) @@ -445,7 +446,7 @@ locker.Unlock(); peerLocker.Unlock(); - error = peerFifo->Write(buffer, timeout); + ssize_t result = peerFifo->Write(vecs, vecCount, ancillaryData, timeout); // Notify select()ing readers, if we successfully wrote anything. size_t readable = peerFifo->Readable(); @@ -471,17 +472,17 @@ if (notifyWrite) gSocketModule->notify(socket, B_SELECT_WRITE, writable); - switch (error) { + switch (result) { case UNIX_FIFO_SHUTDOWN: if (fPeerEndpoint == peerEndpoint && fState == UNIX_ENDPOINT_CONNECTED) { // Orderly write shutdown on our side. // Note: Linux and Solaris also send a SIGPIPE, but according // the send() specification that shouldn't be done. - error = EPIPE; + result = EPIPE; } else { // The FD has been closed. - error = EBADF; + result = EBADF; } break; case EPIPE: @@ -493,19 +494,21 @@ case B_TIMED_OUT: // Translate non-blocking timeouts to the correct error code. if (timeout == 0) - error = B_WOULD_BLOCK; + result = B_WOULD_BLOCK; break; } - RETURN_ERROR(error); + RETURN_ERROR(result); } -status_t -UnixEndpoint::Receive(size_t numBytes, uint32 flags, net_buffer **_buffer) +ssize_t +UnixEndpoint::Receive(const iovec *vecs, size_t vecCount, + ancillary_data_container **_ancillaryData, struct sockaddr *_address, + socklen_t *_addressLength) { - TRACE("[%ld] %p->UnixEndpoint::Receive(%ld, 0x%lx)\n", find_thread(NULL), - this, numBytes, flags); + TRACE("[%ld] %p->UnixEndpoint::Receive(%p, %ld)\n", find_thread(NULL), + this, vecs, vecCount); bigtime_t timeout = absolute_timeout(socket->receive.timeout); if (gStackModule->is_restarted_syscall()) @@ -523,6 +526,14 @@ UnixEndpoint* peerEndpoint = fPeerEndpoint; Reference peerReference(peerEndpoint); + // Copy the peer address upfront. This way, if we read something, we don't + // get into a potential race with Close(). + if (_address != NULL) { + socklen_t addrLen = min_c(*_addressLength, socket->peer.ss_len); + memcpy(_address, &socket->peer, addrLen); + *_addressLength = addrLen; + } + // lock our FIFO UnixFifo* fifo = fReceiveFifo; Reference _(fifo); @@ -531,17 +542,17 @@ // unlock endpoint locker.Unlock(); - status_t error = fifo->Read(numBytes, timeout, _buffer); + ssize_t result = fifo->Read(vecs, vecCount, _ancillaryData, timeout); // Notify select()ing writers, if we successfully read anything. size_t writable = fifo->Writable(); - bool notifyWrite = (error == B_OK && writable > 0 + bool notifyWrite = (result >= 0 && writable > 0 && !fifo->IsWriteShutdown()); // Notify select()ing readers, if we failed to read anything and there's // still something left to read. size_t readable = fifo->Readable(); - bool notifyRead = (error != B_OK && readable > 0 + bool notifyRead = (result < 0 && readable > 0 && !fifo->IsReadShutdown()); // re-lock our endpoint (unlock FIFO to respect locking order) @@ -558,12 +569,12 @@ if (peerLocked && notifyWrite) gSocketModule->notify(peerEndpoint->socket, B_SELECT_WRITE, writable); - switch (error) { + switch (result) { case UNIX_FIFO_SHUTDOWN: // Either our socket was closed or read shutdown. if (fState == UNIX_ENDPOINT_CLOSED) { // The FD has been closed. - error = EBADF; + result = EBADF; } else { // if (fReceiveFifo == fifo) { // Orderly shutdown or the peer closed the connection. @@ -571,18 +582,17 @@ // Weird case: Peer closed connection and we are already // reconnected (or listening). // } - error = B_OK; - *_buffer = NULL; + result = 0; } break; case B_TIMED_OUT: // translate non-blocking timeouts to the correct error code if (timeout == 0) - error = B_WOULD_BLOCK; + result = B_WOULD_BLOCK; break; } - RETURN_ERROR(error); + RETURN_ERROR(result); } @@ -624,7 +634,7 @@ } -void +status_t UnixEndpoint::SetReceiveBufferSize(size_t size) { TRACE("[%ld] %p->UnixEndpoint::SetReceiveBufferSize(%lu)\n", @@ -632,11 +642,11 @@ UnixEndpointLocker locker(this); - if (fState != UNIX_ENDPOINT_CONNECTED) - return; + if (fReceiveFifo == NULL) + return B_BAD_VALUE; UnixFifoLocker fifoLocker(fReceiveFifo); - fReceiveFifo->SetBufferCapacity(size); + return fReceiveFifo->SetBufferCapacity(size); } Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h 2008-05-03 01:11:21 UTC (rev 25299) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h 2008-05-03 01:14:44 UTC (rev 25300) @@ -66,13 +66,16 @@ status_t Connect(const struct sockaddr *address); status_t Accept(net_socket **_acceptedSocket); - status_t Send(net_buffer *buffer); - status_t Receive(size_t numBytes, uint32 flags, net_buffer **_buffer); + ssize_t Send(const iovec *vecs, size_t vecCount, + ancillary_data_container *ancillaryData); + ssize_t Receive(const iovec *vecs, size_t vecCount, + ancillary_data_container **_ancillaryData, struct sockaddr *_address, + socklen_t *_addressLength); ssize_t Sendable(); ssize_t Receivable(); - void SetReceiveBufferSize(size_t size); + status_t SetReceiveBufferSize(size_t size); status_t Shutdown(int direction); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-03 01:11:21 UTC (rev 25299) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-03 01:14:44 UTC (rev 25300) @@ -5,8 +5,13 @@ #include "UnixFifo.h" +#include + #include +#include +#include + #include "unix.h" @@ -15,314 +20,242 @@ #include "UnixDebug.h" -#if TRACE_BUFFER_QUEUE -# define TRACEBQ(x...) ktrace_printf(x) -# define TRACEBQ_ONLY(x) x -#else -# define TRACEBQ(x...) do {} while (false) -# define TRACEBQ_ONLY(x) -#endif +// #pragma mark - UnixRequest -UnixBufferQueue::UnixBufferQueue(size_t capacity) +UnixRequest::UnixRequest(const iovec* vecs, size_t count, + ancillary_data_container* ancillaryData) : - fSize(0), - fCapacity(capacity) -#if TRACE_BUFFER_QUEUE - , fWritten(0) - , fRead(0) -#endif + fVecs(vecs), + fVecCount(count), + fAncillaryData(ancillaryData), + fTotalSize(0), + fBytesTransferred(0), + fVecIndex(0), + fVecOffset(0) { - TRACEBQ_ONLY( - fParanoiaCheckBuffer = (uint8*)malloc(UNIX_FIFO_MAXIMAL_CAPACITY); - fParanoiaCheckBuffer2 = (uint8*)malloc(UNIX_FIFO_MAXIMAL_CAPACITY); - ) + for (size_t i = 0; i < fVecCount; i++) + fTotalSize += fVecs[i].iov_len; } -UnixBufferQueue::~UnixBufferQueue() +void +UnixRequest::AddBytesTransferred(size_t size) { - while (net_buffer* buffer = fBuffers.RemoveHead()) - gBufferModule->free(buffer); + fBytesTransferred += size; - TRACEBQ_ONLY( - free(fParanoiaCheckBuffer); - free(fParanoiaCheckBuffer2); - ) + // also adjust the current iovec index/offset + while (fVecIndex < fVecCount + && fVecs[fVecIndex].iov_len - fVecOffset <= size) { + size -= fVecs[fVecIndex].iov_len - fVecOffset; + fVecIndex++; + fVecOffset = 0; + } + + if (fVecIndex < fVecCount) + fVecOffset += size; } -status_t -UnixBufferQueue::Read(size_t size, net_buffer** _buffer) +bool +UnixRequest::GetCurrentChunk(void*& data, size_t& size) { - if (size > fSize) - size = fSize; + while (fVecIndex < fVecCount + && fVecOffset >= fVecs[fVecIndex].iov_len) { + fVecIndex++; + fVecOffset = 0; + } + if (fVecIndex >= fVecCount) + return false; - TRACEBQ("unix: UnixBufferQueue::Read(%lu): fSize: %lu, fRead: %lld, " - "fWritten: %lld", size, fSize, fRead, fWritten); + data = (uint8*)fVecs[fVecIndex].iov_base + fVecOffset; + size = fVecs[fVecIndex].iov_len - fVecOffset; + return true; +} - TRACEBQ_ONLY( - MethodDeleter _(this, &UnixBufferQueue::PostReadWrite); - ) - if (size == 0) - return B_BAD_VALUE; +void +UnixRequest::SetAncillaryData(ancillary_data_container* data) +{ + fAncillaryData = data; +} -TRACEBQ_ONLY( - if (fParanoiaCheckBuffer) { - size_t bufferSize = 0; - for (BufferList::Iterator it = fBuffers.GetIterator(); - net_buffer* buffer = it.Next();) { - size_t toWrite = min_c(buffer->size, size - bufferSize); - if (toWrite == 0) - break; - gBufferModule->read(buffer, 0, - fParanoiaCheckBuffer + bufferSize, toWrite); - bufferSize += toWrite; - } - } - *_buffer = NULL; -) - - // If the first buffer has the right size or is smaller, we can just - // dequeue it. - net_buffer* buffer = fBuffers.Head(); - if (buffer->size <= size) { - fBuffers.RemoveHead(); - fSize -= buffer->size; - TRACEBQ_ONLY(fRead += buffer->size); - *_buffer = buffer; - - if (buffer->size == size) +void +UnixRequest::AddAncillaryData(ancillary_data_container* data) { -TRACEBQ("unix: read full buffer %p (%lu)", buffer, buffer->size); -TRACEBQ_ONLY(ParanoiaReadCheck(*_buffer)); - return B_OK; + if (fAncillaryData != NULL) { + gStackModule->move_ancillary_data(data, fAncillaryData); + gStackModule->delete_ancillary_data_container(data); + } else + fAncillaryData = data; } - // buffer is too small - size_t bytesLeft = size - buffer->size; -TRACEBQ("unix: read short buffer %p (%lu/%lu)", buffer, size, buffer->size); +// #pragma mark - UnixBufferQueue - // Append from the following buffers, until we've read as much as we're - // supposed to. - while (bytesLeft > 0) { - net_buffer* nextBuffer = fBuffers.Head(); - size_t toCopy = min_c(bytesLeft, nextBuffer->size); -TRACEBQ("unix: read next buffer %p (%lu/%lu)", nextBuffer, bytesLeft, nextBuffer->size); -#if 0 - if (gBufferModule->append_cloned(buffer, nextBuffer, 0, toCopy) - != B_OK) { - // Too bad, but we've got some data, so we don't fail. -TRACEBQ_ONLY(ParanoiaReadCheck(*_buffer)); - return B_OK; - } -#endif - -// TODO: Temporary work-around for the append_cloned() call above, which -// doesn't seem to work right. Or maybe that's just in combination with the -// remove_header() below. +UnixBufferQueue::UnixBufferQueue(size_t capacity) + : + fBuffer(NULL), + fCapacity(capacity) { - void* tmpBuffer = malloc(toCopy); - if (tmpBuffer == NULL) - return B_OK; - MemoryDeleter tmpBufferDeleter(tmpBuffer); - - size_t offset = buffer->size; - if (gBufferModule->read(nextBuffer, 0, tmpBuffer, toCopy) != B_OK - || gBufferModule->append_size(buffer, toCopy, NULL) != B_OK) { - return B_OK; - } - - if (gBufferModule->write(buffer, offset, tmpBuffer, toCopy) != B_OK) { - gBufferModule->remove_trailer(buffer, toCopy); - return B_OK; - } } - // transfer the ancillary data - gBufferModule->transfer_ancillary_data(nextBuffer, buffer); - if (nextBuffer->size > toCopy) { - // remove the part we've copied -//gBufferModule->read(nextBuffer, toCopy, fParanoiaCheckBuffer, -//nextBuffer->size - toCopy); - gBufferModule->remove_header(nextBuffer, toCopy); -//TRACEBQ_ONLY(ParanoiaReadCheck(nextBuffer)); - } else { - // get rid of the buffer completely - fBuffers.RemoveHead(); - gBufferModule->free(nextBuffer); - } - - bytesLeft -= toCopy; - fSize -= toCopy; - TRACEBQ_ONLY(fRead += toCopy); - } - -TRACEBQ_ONLY(ParanoiaReadCheck(*_buffer)); - return B_OK; +UnixBufferQueue::~UnixBufferQueue() +{ + while (AncillaryDataEntry* entry = fAncillaryData.RemoveHead()) { + gStackModule->delete_ancillary_data_container(entry->data); + delete entry; } - // buffer is too big + delete_ring_buffer(fBuffer); +} - // Create a new buffer, and copy into it, as much as we need. - net_buffer* newBuffer = gBufferModule->create(256); - if (newBuffer == NULL) - return ENOBUFS; - status_t error = gBufferModule->append_cloned(newBuffer, buffer, 0, size); - if (error != B_OK) { - gBufferModule->free(newBuffer); - return error; - } +status_t +UnixBufferQueue::Init() +{ + fBuffer = create_ring_buffer(fCapacity); + if (fBuffer == NULL) + return B_NO_MEMORY; + return B_OK; +} - // transfer the ancillary data - gBufferModule->transfer_ancillary_data(buffer, newBuffer); - // remove the part we've copied -TRACEBQ("unix: read long buffer %p (%lu/%lu)", buffer, size, buffer->size); - gBufferModule->remove_header(buffer, size); +size_t +UnixBufferQueue::Readable() const +{ + return ring_buffer_readable(fBuffer); +} - fSize -= size; - TRACEBQ_ONLY(fRead += size); - *_buffer = newBuffer; -TRACEBQ_ONLY(ParanoiaReadCheck(*_buffer)); - return B_OK; +size_t +UnixBufferQueue::Writable() const +{ + return ring_buffer_writable(fBuffer); } status_t -UnixBufferQueue::Write(net_buffer* buffer, size_t maxSize) +UnixBufferQueue::Read(UnixRequest& request) { - TRACEBQ("unix: UnixBufferQueue::Write(%lu/%lu): fSize: %lu, fRead: %lld, " - "fWritten: %lld", buffer->size, maxSize, fSize, fRead, fWritten); + bool user = gStackModule->is_syscall(); - TRACEBQ_ONLY( - MethodDeleter _(this, &UnixBufferQueue::PostReadWrite); - ) + size_t readable = Readable(); + void* data; + size_t size; - maxSize = min_c(buffer->size, maxSize); - if (maxSize > Writable()) - RETURN_ERROR(ENOBUFS); + while (readable > 0 && request.GetCurrentChunk(data, size)) { + if (size > readable) + size = readable; - // If we shall write the complete buffer, things are easy. - if (maxSize == buffer->size) { - fBuffers.Add(buffer); - fSize += buffer->size; - TRACEBQ_ONLY(fWritten += buffer->size); + ssize_t bytesRead; + if (user) + bytesRead = ring_buffer_user_read(fBuffer, (uint8*)data, size); + else + bytesRead = ring_buffer_read(fBuffer, (uint8*)data, size); - return B_OK; - } + if (bytesRead < 0) + return bytesRead; + if (bytesRead == 0) + return B_ERROR; - // We shall write only a partial buffer. We need to create a new one and - // cut of the head of the old one. -// TODO: This implementation obviously sucks, but we can't use the split method, -// since it would split off the wrong buffer. The socket module requires us -// to cut off the head of the given one. + // Adjust ancillary data entry offsets, respectively attach the ones + // that belong to the read data to the request. + if (AncillaryDataEntry* entry = fAncillaryData.Head()) { + size_t offsetDelta = bytesRead; + while (entry != NULL && offsetDelta > entry->offset) { + // entry data have been read -- add ancillary data to request + fAncillaryData.RemoveHead(); + offsetDelta -= entry->offset; + request.AddAncillaryData(entry->data); + delete entry; - // create a temporary buffer - void* tmpBuffer = malloc(maxSize); - if (tmpBuffer == NULL) - return B_OK; - MemoryDeleter tmpBufferDeleter(tmpBuffer); + entry = fAncillaryData.Head(); + } - // read the data to append into the temporary buffer - status_t error = gBufferModule->read(buffer, 0, tmpBuffer, maxSize); - if (error != B_OK) - return error; + if (entry != NULL) + entry->offset -= offsetDelta; + } - // create the new buffer and append the data - net_buffer* newBuffer = gBufferModule->create(256); - if (newBuffer == NULL) - return ENOBUFS; - - error = gBufferModule->append(newBuffer, tmpBuffer, maxSize); - - // remove the header from the old buffer - if (error == B_OK) - error = gBufferModule->remove_header(buffer, maxSize); - - if (error != B_OK) { - gBufferModule->free(newBuffer); - return error; + request.AddBytesTransferred(bytesRead); + readable -= bytesRead; } - // transfer the ancillary data - gBufferModule->transfer_ancillary_data(buffer, newBuffer); - - // Everything went fine. Append the new buffer. - fBuffers.Add(newBuffer); - fSize += newBuffer->size; - TRACEBQ_ONLY(fWritten += newBuffer->size); - return B_OK; } -void -UnixBufferQueue::SetCapacity(size_t capacity) +status_t +UnixBufferQueue::Write(UnixRequest& request) { - fCapacity = capacity; -} + bool user = gStackModule->is_syscall(); + size_t writable = Writable(); + void* data; + size_t size; -#if TRACE_BUFFER_QUEUE + // If the request has ancillary data create an entry first. + AncillaryDataEntry* ancillaryEntry = NULL; + ObjectDeleter ancillaryEntryDeleter; + if (writable > 0 && request.AncillaryData() != NULL) { + ancillaryEntry = new(std::nothrow) AncillaryDataEntry; + if (ancillaryEntry == NULL) + return B_NO_MEMORY; -void -UnixBufferQueue::ParanoiaReadCheck(net_buffer* buffer) -{ - if (!buffer || !fParanoiaCheckBuffer || !fParanoiaCheckBuffer2) - return; + ancillaryEntryDeleter.SetTo(ancillaryEntry); + ancillaryEntry->data = request.AncillaryData(); + ancillaryEntry->offset = Readable(); - gBufferModule->read(buffer, 0, fParanoiaCheckBuffer2, buffer->size); - - if (memcmp(fParanoiaCheckBuffer, fParanoiaCheckBuffer2, buffer->size) - != 0) { - // find offset of first difference - size_t i = 0; - for (; i < buffer->size; i++) { - if (fParanoiaCheckBuffer[i] != fParanoiaCheckBuffer2[i]) - break; - } - - panic("unix: UnixBufferQueue::ParanoiaReadCheck(): incorrect read! " - "offset of first difference: %lu", i); + // The offsets are relative to the previous entry. + AncillaryDataList::Iterator it = fAncillaryData.GetIterator(); + while (AncillaryDataEntry* entry = it.Next()) + ancillaryEntry->offset -= entry->offset; + // TODO: This is inefficient when the list is long. Rather also + // store and maintain the absolute offset of the last queued entry. } -} + // write as much as we can + while (writable > 0 && request.GetCurrentChunk(data, size)) { + if (size > writable) + size = writable; -void -UnixBufferQueue::PostReadWrite() -{ - TRACEBQ("unix: post read/write: fSize: %lu, fRead: %lld, fWritten: %lld", - fSize, fRead, fWritten); + ssize_t bytesWritten; + if (user) + bytesWritten = ring_buffer_user_write(fBuffer, (uint8*)data, size); + else + bytesWritten = ring_buffer_write(fBuffer, (uint8*)data, size); - if (fWritten - fRead != fSize) { - panic("UnixBufferQueue::PostReadWrite(): fSize: %lu, fRead: %lld, " - "fWritten: %lld", fSize, fRead, fWritten); - } + if (bytesWritten < 0) + return bytesWritten; + if (bytesWritten == 0) + return B_ERROR; - // check buffer size sum - size_t bufferSize = 0; - for (BufferList::Iterator it = fBuffers.GetIterator(); - net_buffer* buffer = it.Next();) { - bufferSize += buffer->size; - } + if (ancillaryEntry != NULL) { + fAncillaryData.Add(ancillaryEntry); + ancillaryEntryDeleter.Detach(); + request.SetAncillaryData(NULL); + ancillaryEntry = NULL; + } - if (bufferSize != fSize) { - panic("UnixBufferQueue::PostReadWrite(): fSize: %lu, bufferSize: %lu", - fSize, bufferSize); + request.AddBytesTransferred(bytesWritten); + writable -= bytesWritten; } + + return B_OK; } -#endif // TRACE_BUFFER_QUEUE +status_t +UnixBufferQueue::SetCapacity(size_t capacity) +{ +// TODO:... +return B_ERROR; +} + // #pragma mark - @@ -351,7 +284,7 @@ status_t UnixFifo::Init() { - return B_OK; + return fBuffer.Init(); } @@ -371,24 +304,25 @@ } -status_t -UnixFifo::Read(size_t numBytes, bigtime_t timeout, net_buffer** _buffer) +ssize_t +UnixFifo::Read(const iovec* vecs, size_t vecCount, + ancillary_data_container** _ancillaryData, bigtime_t timeout) { - TRACE("[%ld] %p->UnixFifo::Read(%lu, %lld)\n", find_thread(NULL), this, - numBytes, timeout); + TRACE("[%ld] %p->UnixFifo::Read(%p, %ld, %lld)\n", find_thread(NULL), + this, vecs, vecCount, timeout); if (IsReadShutdown()) return UNIX_FIFO_SHUTDOWN; - Request request(numBytes); + UnixRequest request(vecs, vecCount, NULL); fReaders.Add(&request); - fReadRequested += request.size; + fReadRequested += request.TotalSize(); - status_t error = _Read(request, numBytes, timeout, _buffer); + status_t error = _Read(request, timeout); bool firstInQueue = fReaders.Head() == &request; fReaders.Remove(&request); - fReadRequested -= request.size; + fReadRequested -= request.TotalSize(); if (firstInQueue && !fReaders.IsEmpty() && fBuffer.Readable() > 0 && !IsReadShutdown()) { @@ -397,21 +331,30 @@ fReadCondition.NotifyAll(); } - if (error == B_OK && *_buffer != NULL && (*_buffer)->size > 0 - && !fWriters.IsEmpty() && !IsWriteShutdown()) { + if (request.BytesTransferred() > 0 && !fWriters.IsEmpty() + && !IsWriteShutdown()) { // We read something and there are writers. Notify them fWriteCondition.NotifyAll(); } + *_ancillaryData = request.AncillaryData(); + + if (request.BytesTransferred() > 0) { + if (request.BytesTransferred() > SSIZE_MAX) + RETURN_ERROR(SSIZE_MAX); + RETURN_ERROR((ssize_t)request.BytesTransferred()); + } + RETURN_ERROR(error); } -status_t -UnixFifo::Write(net_buffer* buffer, bigtime_t timeout) +ssize_t +UnixFifo::Write(const iovec* vecs, size_t vecCount, + ancillary_data_container* ancillaryData, bigtime_t timeout) { - TRACE("[%ld] %p->UnixFifo::Write(%p (%lu), %lld)\n", find_thread(NULL), - this, buffer, buffer->size, timeout); + TRACE("[%ld] %p->UnixFifo::Write(%p, %ld, %p, %lld)\n", find_thread(NULL), + this, vecs, vecCount, ancillaryData, timeout); if (IsWriteShutdown()) return UNIX_FIFO_SHUTDOWN; @@ -419,16 +362,15 @@ if (IsReadShutdown()) return EPIPE; - Request request(buffer->size); + UnixRequest request(vecs, vecCount, ancillaryData); fWriters.Add(&request); - fWriteRequested += request.size; - size_t bytesWritten = 0; + fWriteRequested += request.TotalSize(); - status_t error = _Write(request, buffer, timeout, bytesWritten); + status_t error = _Write(request, timeout); bool firstInQueue = fWriters.Head() == &request; fWriters.Remove(&request); - fWriteRequested -= request.size; + fWriteRequested -= request.TotalSize(); if (firstInQueue && !fWriters.IsEmpty() && fBuffer.Writable() > 0 && !IsWriteShutdown()) { @@ -437,12 +379,18 @@ fWriteCondition.NotifyAll(); } - if (bytesWritten > 0 && request.size > 0 && !fReaders.IsEmpty() + if (request.BytesTransferred() > 0 && !fReaders.IsEmpty() && !IsReadShutdown()) { // We've written something and there are readers. Notify them. fReadCondition.NotifyAll(); } + if (request.BytesTransferred() > 0) { + if (request.BytesTransferred() > SSIZE_MAX) + RETURN_ERROR(SSIZE_MAX); + RETURN_ERROR((ssize_t)request.BytesTransferred()); + } + RETURN_ERROR(error); } @@ -463,7 +411,7 @@ } -void +status_t UnixFifo::SetBufferCapacity(size_t capacity) { // check against allowed minimal/maximal value @@ -474,20 +422,23 @@ size_t oldCapacity = fBuffer.Capacity(); if (capacity == oldCapacity) - return; + return B_OK; // set capacity - fBuffer.SetCapacity(capacity); + status_t error = fBuffer.SetCapacity(capacity); + if (error != B_OK) + return error; // wake up waiting writers, if the capacity increased if (!fWriters.IsEmpty() && !IsWriteShutdown()) fWriteCondition.NotifyAll(); + + return B_OK; } status_t -UnixFifo::_Read(Request& request, size_t numBytes, bigtime_t timeout, - net_buffer** _buffer) +UnixFifo::_Read(UnixRequest& request, bigtime_t timeout) { // wait for the request to reach the front of the queue if (fReaders.Head() != &request && timeout == 0) @@ -509,10 +460,8 @@ return UNIX_FIFO_SHUTDOWN; if (fBuffer.Readable() == 0) { - if (IsWriteShutdown()) { - *_buffer = NULL; - RETURN_ERROR(B_OK); - } + if (IsWriteShutdown()) + RETURN_ERROR(0); if (timeout == 0) RETURN_ERROR(B_WOULD_BLOCK); @@ -536,21 +485,18 @@ if (IsReadShutdown()) return UNIX_FIFO_SHUTDOWN; - if (fBuffer.Readable() == 0 && IsWriteShutdown()) { - *_buffer = NULL; - RETURN_ERROR(B_OK); - } + if (fBuffer.Readable() == 0 && IsWriteShutdown()) + RETURN_ERROR(0); - RETURN_ERROR(fBuffer.Read(numBytes, _buffer)); + RETURN_ERROR(fBuffer.Read(request)); } status_t -UnixFifo::_Write(Request& request, net_buffer* buffer, bigtime_t timeout, - size_t& bytesWritten) +UnixFifo::_Write(UnixRequest& request, bigtime_t timeout) { if (timeout == 0) - RETURN_ERROR(_WriteNonBlocking(request, buffer, bytesWritten)); + RETURN_ERROR(_WriteNonBlocking(request)); // wait for the request to reach the front of the queue while (fWriters.Head() != &request && !IsWriteShutdown()) { @@ -571,13 +517,12 @@ if (IsReadShutdown()) return EPIPE; - if (request.size == 0) - return B_OK; + if (request.TotalSize() == 0) + return 0; status_t error = B_OK; - size_t bytesLeft = buffer->size; - while (error == B_OK && bytesLeft > 0) { + while (error == B_OK && request.BytesRemaining() > 0) { // wait for any space to become available while (error == B_OK && fBuffer.Writable() == 0 && !IsWriteShutdown() && !IsReadShutdown()) { @@ -599,14 +544,11 @@ return EPIPE; // write as much as we can - size_t toWrite = min_c(fBuffer.Writable(), bytesLeft); - error = fBuffer.Write(buffer, toWrite); + error = fBuffer.Write(request); if (error == B_OK) { // TODO: Whenever we've successfully written a part, we should reset the // timeout! - bytesWritten += toWrite; - bytesLeft -= toWrite; } } @@ -615,35 +557,16 @@ status_t -UnixFifo::_WriteNonBlocking(Request& request, net_buffer* buffer, - size_t& bytesWritten) +UnixFifo::_WriteNonBlocking(UnixRequest& request) { // We need to be first in queue and space should be available right now, // otherwise we need to fail. if (fWriters.Head() != &request || fBuffer.Writable() == 0) RETURN_ERROR(B_WOULD_BLOCK); - if (request.size == 0) - return B_OK; + if (request.TotalSize() == 0) + return 0; // Write as much as we can. - size_t toWrite = min_c(fBuffer.Writable(), buffer->size); - status_t error; - - if (buffer->size <= fBuffer.Writable()) { - // enough space available - error = fBuffer.Write(buffer, toWrite); - if (error == B_OK) - bytesWritten = toWrite; - } else { - // not enough space available -- write what we can, but return - // B_WOULD_BLOCK nevertheless - error = fBuffer.Write(buffer,toWrite); - if (error == B_OK) { - bytesWritten = toWrite; - error = B_WOULD_BLOCK; - } - } - - RETURN_ERROR(error); + RETURN_ERROR(fBuffer.Write(request)); } \ No newline at end of file Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-03 01:11:21 UTC (rev 25299) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.h 2008-05-03 01:14:44 UTC (rev 25300) @@ -18,53 +18,72 @@ #define UNIX_FIFO_SHUTDOWN_READ 1 #define UNIX_FIFO_SHUTDOWN_WRITE 2 -#define UNIX_FIFO_SHUTDOWN 1 +#define UNIX_FIFO_SHUTDOWN (B_ERRORS_END + 1) // error code returned by Read()/Write() #define UNIX_FIFO_MINIMAL_CAPACITY 1024 #define UNIX_FIFO_MAXIMAL_CAPACITY (128 * 1024) -#define TRACE_BUFFER_QUEUE 0 +struct ring_buffer; +class UnixRequest : public DoublyLinkedListLinkImpl { +public: + UnixRequest(const iovec* vecs, size_t count, + ancillary_data_container* ancillaryData); + off_t TotalSize() const { return fTotalSize; } + off_t BytesTransferred() const { return fBytesTransferred; } + off_t BytesRemaining() const { return fTotalSize - fBytesTransferred; } [... truncated: 201 lines follow ...] From ingo_weinhold at gmx.de Sat May 3 02:59:37 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 03 May 2008 02:59:37 +0200 Subject: [Haiku-commits] r25287 - haiku/trunk/src/add-ons/kernel/network/stack In-Reply-To: <34077359000-BeMail@zon> References: <34077359000-BeMail@zon> Message-ID: <20080503025937.1307.7@knochen-vm.1209732708.fake> On 2008-05-02 at 20:34:01 [+0200], Axel D?rfler wrote: [...] > I'm not sure what I would prefer, so I don't want to spend the extra > effort to revert the current solution either. Do you have any > preference and can convince me? :-)) Nope. :-) CU, Ingo From emitrax at gmail.com Sat May 3 10:30:04 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 3 May 2008 08:30:04 +0000 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <200805022249.m42MnNZI017075@sheep.berlios.de> References: <200805022249.m42MnNZI017075@sheep.berlios.de> Message-ID: 2008/5/2 nielx at BerliOS : > Author: nielx > Date: 2008-05-03 00:49:23 +0200 (Sat, 03 May 2008) > New Revision: 25297 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25297&view=rev > > Modified: > haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp > Log: > Update copyright entries in the about window. Work done by scottmc. Thanks! This closes #1222. > > > Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp > =================================================================== > --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-02 22:23:50 UTC (rev 25296) > +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-02 22:49:23 UTC (rev 25297) > @@ -516,7 +516,7 @@ > "released under the GPL and LGPL licences:\n" > "GNU C Library, " > "GNU coretools, diffutils, findutils, " > - "gawk, bison, m4, make, " > + "shareutils, gawk, bison, m4, make, " > "gdb, wget, ncurses, termcap, " > "Bourne Again Shell.\n" > "Copyright " B_UTF8_COPYRIGHT " The Free Software Foundation.", > @@ -527,7 +527,8 @@ > AddCopyrightEntry("The FreeBSD Project", > "Contains software from the FreeBSD Project, " > "released under the BSD licence:\n" > - "ping, telnet, telnetd, traceroute\n" > + "cal, ftpd, ping, telnet, " > + "telnetd, traceroute\n" > "Copyright " B_UTF8_COPYRIGHT " 1994-2008 The FreeBSD Project. " > "All rights reserved.", > "http://www.freebsd.org"); > @@ -536,7 +537,7 @@ > AddCopyrightEntry("The NetBSD Project", > "Contains software developed by the NetBSD, " > "Foundation, Inc. and its contributors:\n" > - "ftp\n" > + "ftp, tput\n" > "Copyright " B_UTF8_COPYRIGHT " 1996-2008 The NetBSD Foundation, Inc. " > "All rights reserved.", > "http://www.netbsd.org"); > @@ -646,12 +647,25 @@ > > // acpica copyrights > AddCopyrightEntry("acpica", > - "Copyright " B_UTF8_COPYRIGHT " 1999 - 2006 Intel Corp."); > + "Copyright " B_UTF8_COPYRIGHT " 1999-2006 Intel Corp."); > > // unrar copyrights > AddCopyrightEntry("unrar", > - "Copyright " B_UTF8_COPYRIGHT " Alexander L. Roshal."); > + "Copyright " B_UTF8_COPYRIGHT " 2002-2008 Alexander L. Roshal. " > + "All rights reserved.", > + "http://www.rarlab.com"); > > +// p7zip copyrights > +// AddCopyrightEntry("p7zip", > +// "Copyright " B_UTF8_COPYRIGHT " 2008 Igor Pavlov. " > +// "All rights reserved."); > + > +// libMicros copyrights > +// AddCopyrightEntry("libMicro", > +// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun Microsystems, Inc. " > +// "All rights reserved."); > + // Open Solaris License > + > // libpng copyrights > AddCopyrightEntry("libpng", > "Copyright " B_UTF8_COPYRIGHT " 2004, 2006-2008 Glenn " > @@ -659,8 +673,8 @@ > > // libprint copyrights > AddCopyrightEntry("libprint", > - "Copyright " B_UTF8_COPYRIGHT " 1999-2000 Y.Takagi. All Rights " > - "Reserved."); > + "Copyright " B_UTF8_COPYRIGHT " 1999-2000 Y.Takagi. All rights " > + "reserved."); > > // cortex copyrights > AddCopyrightEntry("Cortex", > @@ -676,24 +690,37 @@ > > // libxml2, libxslt, libexslt copyrights > AddCopyrightEntry("libxml2, libxslt", > - "Copyright " B_UTF8_COPYRIGHT " 1998-2003 Daniel Veillard. All Rights " > - "Reserved."); > + "Copyright " B_UTF8_COPYRIGHT " 1998-2003 Daniel Veillard. " > + "All rights reserved."); > > AddCopyrightEntry("libexslt", > "Copyright " B_UTF8_COPYRIGHT " 2001-2002 Thomas Broyer, Charlie " > - "Bozeman and Daniel Veillard. All Rights Reserved."); > + "Bozeman and Daniel Veillard. All rights reserved."); > > // Xiph.org Foundation copyrights > AddCopyrightEntry("Xiph.org Foundation", > "libvorbis, libogg, libtheora, libspeex" > - "Copyright " B_UTF8_COPYRIGHT " 1994-2008 Xiph.Org. All rights " > - "reserved.", "http://www.xiph.org"); > + "Copyright " B_UTF8_COPYRIGHT " 1994-2008 Xiph.Org. " > + "All rights reserved.", > + "http://www.xiph.org"); > > // The Tcpdump Group > AddCopyrightEntry("The Tcpdump Group", > "tcpdump, libpcap", > "http://www.tcpdump.org"); > > + // Matroska > + AddCopyrightEntry("libmatroska", > + "Copyright " B_UTF8_COPYRIGHT " 2002-2003 Steve Lhomme. " > + "All rights reserved.", > + "http://www.matroska.org"); > + > +// OpenSound > +// AddCopyrightEntry("OpenSound", > +// "Copyright " B_UTF8_COPYRIGHT " 1996-2008 4Front Technologies ", > +// "http://www.opensound.com"); > +// BSD license > + > _AddCopyrightsFromAttribute(); > > // Build a list of installed applications and show their > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > ctags, which is included by default in the image is missing I think. By the way, this makes me wonder why development tools are still not included by default in the image. Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From julun at mail.berlios.de Sat May 3 12:08:10 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Sat, 3 May 2008 12:08:10 +0200 Subject: [Haiku-commits] r25301 - haiku/trunk/src/preferences/print Message-ID: <200805031008.m43A8Awc001910@sheep.berlios.de> Author: julun Date: 2008-05-03 12:08:10 +0200 (Sat, 03 May 2008) New Revision: 25301 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25301&view=rev Modified: haiku/trunk/src/preferences/print/JobListView.cpp haiku/trunk/src/preferences/print/JobListView.h Log: * some code formating, no functional change Modified: haiku/trunk/src/preferences/print/JobListView.cpp =================================================================== --- haiku/trunk/src/preferences/print/JobListView.cpp 2008-05-03 01:14:44 UTC (rev 25300) +++ haiku/trunk/src/preferences/print/JobListView.cpp 2008-05-03 10:08:10 UTC (rev 25301) @@ -1,8 +1,8 @@ /*****************************************************************************/ // Printers Preference Application. // -// This application and all source files used in its construction, except -// where noted, are licensed under the MIT License, and have been written +// This application and all source files used in its construction, except +// where noted, are licensed under the MIT License, and have been written // and are: // // Copyright (c) 2001-2003 OpenBeOS Project @@ -10,93 +10,112 @@ // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included +// The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. /*****************************************************************************/ #include "JobListView.h" -#include "pr_server.h" -#include "Messages.h" #include "Globals.h" #include "Jobs.h" +#include "Messages.h" +#include "pr_server.h" #include "SpoolFolder.h" + +#include +#include #include -#include -#include -#include #include #include + +// #pragma mark -- JobListView + + JobListView::JobListView(BRect frame) : Inherited(frame, "jobs_list", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL) { } -void JobListView::AttachedToWindow() + +void +JobListView::AttachedToWindow() { Inherited::AttachedToWindow(); SetSelectionMessage(new BMessage(kMsgJobSelected)); - SetTarget(Window()); + SetTarget(Window()); } -void JobListView::SetSpoolFolder(SpoolFolder* folder) +void +JobListView::SetSpoolFolder(SpoolFolder* folder) { BPath path; - // clear list + // clear list const BListItem** items = Items(); for (int i = CountItems() - 1; i >= 0; i --) { delete items[i]; } MakeEmpty(); - if (folder == NULL) return; - - // Find directory containing printer definition nodes + + if (folder == NULL) + return; + + // Find directory containing printer definition nodes for (int32 i = 0; i < folder->CountJobs(); i ++) { Job* job = folder->JobAt(i); AddJob(job); } } -JobItem* JobListView::Find(Job* job) + +JobItem* +JobListView::Find(Job* job) { const int32 n = CountItems(); for (int32 i = 0; i < n; i ++) { JobItem* item = dynamic_cast(ItemAt(i)); - if (item && item->GetJob() == job) return item; + if (item && item->GetJob() == job) + return item; } return NULL; } -JobItem* JobListView::SelectedItem() { + +JobItem* +JobListView::SelectedItem() +{ BListItem* item = ItemAt(CurrentSelection()); return dynamic_cast(item); } -void JobListView::AddJob(Job* job) + +void +JobListView::AddJob(Job* job) { JobItem* item = new JobItem(job); AddItem(item); Invalidate(); } -void JobListView::RemoveJob(Job* job) + +void +JobListView::RemoveJob(Job* job) { JobItem* item = Find(job); if (item) { @@ -106,7 +125,9 @@ } } -void JobListView::UpdateJob(Job* job) + +void +JobListView::UpdateJob(Job* job) { JobItem* item = Find(job); if (item) { @@ -115,17 +136,21 @@ } } -void JobListView::RestartJob() + +void +JobListView::RestartJob() { JobItem* item = SelectedItem(); if (item && item->GetJob()->Status() == kFailed) { - // setting the state changes the file attribute and - // we will receive a notification from SpoolFolder + // setting the state changes the file attribute and + // we will receive a notification from SpoolFolder item->GetJob()->SetStatus(kWaiting); } } -void JobListView::CancelJob() + +void +JobListView::CancelJob() { JobItem* item = SelectedItem(); if (item && item->GetJob()->Status() != kProcessing) { @@ -135,86 +160,109 @@ } -// Implementation of JobItem +// #pragma mark -- JobItem + JobItem::JobItem(Job* job) : BListItem(0, false) , fJob(job) , fIcon(NULL) { fJob->Acquire(); - Update(); } -JobItem::~JobItem() { + +JobItem::~JobItem() +{ fJob->Release(); } -void JobItem::Update() + +void +JobItem::Update() { BNode node(&fJob->EntryRef()); - if (node.InitCheck() != B_OK) return; + if (node.InitCheck() != B_OK) + return; node.ReadAttrString(PSRV_SPOOL_ATTR_DESCRIPTION, &fName); BString mimeType; node.ReadAttrString(PSRV_SPOOL_ATTR_MIMETYPE, &mimeType); + entry_ref ref; if (fIcon == NULL && be_roster->FindApp(mimeType.String(), &ref) == B_OK) { - fIcon = new BBitmap(BRect(0,0,B_MINI_ICON-1,B_MINI_ICON-1), B_CMAP8); + fIcon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_CMAP8); BMimeType type(mimeType.String()); if (type.GetIcon(fIcon, B_MINI_ICON) != B_OK) { - delete fIcon; fIcon = NULL; + delete fIcon; + fIcon = NULL; } } + fPages = ""; int32 pages; - fPages = ""; fSize = ""; fStatus = ""; - - if (node.ReadAttr(PSRV_SPOOL_ATTR_PAGECOUNT, B_INT32_TYPE, 0, &pages, sizeof(pages)) == sizeof(pages)) { + if (node.ReadAttr(PSRV_SPOOL_ATTR_PAGECOUNT, + B_INT32_TYPE, 0, &pages, sizeof(pages)) == sizeof(pages)) { fPages << pages; - if (pages > 1) fPages << " pages."; - else fPages << " page."; + if (pages > 1) + fPages << " pages."; + else + fPages << " page."; } else { fPages = "??? pages."; } - + + fSize = ""; off_t size; if (node.GetSize(&size) == B_OK) { char buffer[80]; sprintf(buffer, "%.2f KB", size / 1024.0); fSize = buffer; } - + + fStatus = ""; switch (fJob->Status()) { - case kWaiting: fStatus = "Waiting"; + case kWaiting: + fStatus = "Waiting"; break; - case kProcessing: fStatus = "Processing"; + + case kProcessing: + fStatus = "Processing"; break; - case kFailed: fStatus = "Failed"; + + case kFailed: + fStatus = "Failed"; break; - case kCompleted: fStatus = "Completed"; + + case kCompleted: + fStatus = "Completed"; break; - default: fStatus = "Unkown status"; - } -} -void JobItem::Update(BView *owner, const BFont *font) + default: + fStatus = "Unkown status"; + } +} + + +void +JobItem::Update(BView *owner, const BFont *font) { BListItem::Update(owner, font); - + font_height height; font->GetHeight(&height); - - SetHeight( (height.ascent+height.descent+height.leading) * 2.0 +4 ); + + SetHeight((height.ascent + height.descent + height.leading) * 2.0 + 4.0); } -void JobItem::DrawItem(BView *owner, BRect, bool complete) + +void +JobItem::DrawItem(BView *owner, BRect, bool complete) { BListView* list = dynamic_cast(owner); - if (list) - { + if (list) { font_height height; BFont font; owner->GetFont(&font); @@ -222,46 +270,46 @@ float fntheight = height.ascent+height.descent+height.leading; BRect bounds = list->ItemFrame(list->IndexOf(this)); - + rgb_color color = owner->ViewColor(); - if ( IsSelected() ) + if (IsSelected()) color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT); - + rgb_color oldviewcolor = owner->ViewColor(); rgb_color oldlowcolor = owner->LowColor(); rgb_color oldcolor = owner->HighColor(); - owner->SetViewColor( color ); - owner->SetHighColor( color ); - owner->SetLowColor( color ); + owner->SetViewColor(color); + owner->SetHighColor(color); + owner->SetLowColor(color); owner->FillRect(bounds); - owner->SetLowColor( oldlowcolor ); - owner->SetHighColor( oldcolor ); + owner->SetLowColor(oldlowcolor); + owner->SetHighColor(oldcolor); BPoint iconPt(bounds.LeftTop() + BPoint(2, 2)); - BPoint leftTop(bounds.LeftTop() + BPoint(12+B_MINI_ICON, 2)); + BPoint leftTop(bounds.LeftTop() + BPoint(12 + B_MINI_ICON, 2)); BPoint namePt(leftTop + BPoint(0, fntheight)); BPoint statusPt(leftTop + BPoint(0, fntheight*2)); - + float width = owner->StringWidth(fPages.String()); - BPoint pagePt(bounds.RightTop() + BPoint(-width-32, fntheight)); + BPoint pagePt(bounds.RightTop() + BPoint(-width - 32, fntheight)); width = owner->StringWidth(fSize.String()); - BPoint sizePt(bounds.RightTop() + BPoint(-width-32, fntheight*2)); - + BPoint sizePt(bounds.RightTop() + BPoint(-width - 32, fntheight * 2)); + drawing_mode mode = owner->DrawingMode(); owner->SetDrawingMode(B_OP_OVER); - if (fIcon) owner->DrawBitmap(fIcon, iconPt); - - // left of item + if (fIcon) + owner->DrawBitmap(fIcon, iconPt); + + // left of item owner->DrawString(fName.String(), fName.Length(), namePt); owner->DrawString(fStatus.String(), fStatus.Length(), statusPt); - - // right of item + + // right of item owner->DrawString(fPages.String(), fPages.Length(), pagePt); owner->DrawString(fSize.String(), fSize.Length(), sizePt); - + owner->SetDrawingMode(mode); - owner->SetViewColor(oldviewcolor); } } Modified: haiku/trunk/src/preferences/print/JobListView.h =================================================================== --- haiku/trunk/src/preferences/print/JobListView.h 2008-05-03 01:14:44 UTC (rev 25300) +++ haiku/trunk/src/preferences/print/JobListView.h 2008-05-03 10:08:10 UTC (rev 25301) @@ -1,8 +1,8 @@ /*****************************************************************************/ // Printers Preference Application. // -// This application and all source files used in its construction, except -// where noted, are licensed under the MIT License, and have been written +// This application and all source files used in its construction, except +// where noted, are licensed under the MIT License, and have been written // and are: // // Copyright (c) 2001-2003 OpenBeOS Project @@ -10,18 +10,18 @@ // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included +// The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. /*****************************************************************************/ @@ -29,38 +29,40 @@ #ifndef JOBLISTVIEW_H #define JOBLISTVIEW_H -#include + #include +#include #include -#include "Jobs.h" +class BBitmap; +class Job; class JobItem; -class JobListView; class SpoolFolder; + class JobListView : public BListView { typedef BListView Inherited; -private: - JobItem* Find(Job* job); - public: JobListView(BRect frame); void AttachedToWindow(); void SetSpoolFolder(SpoolFolder* folder); - + void AddJob(Job* job); void RemoveJob(Job* job); void UpdateJob(Job* job); JobItem* SelectedItem(); - + void RestartJob(); void CancelJob(); + +private: + JobItem* Find(Job* job); }; -class BBitmap; + class JobItem : public BListItem { public: @@ -68,18 +70,19 @@ ~JobItem(); void Update(); - + void Update(BView *owner, const BFont *font); void DrawItem(BView *owner, BRect bounds, bool complete); - + Job* GetJob() { return fJob; } private: - - Job* fJob; - BBitmap* fIcon; - BString fName, fPages; - BString fStatus, fSize; + Job* fJob; + BBitmap* fIcon; + BString fName; + BString fPages; + BString fStatus; + BString fSize; }; From julun at mail.berlios.de Sat May 3 13:39:54 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Sat, 3 May 2008 13:39:54 +0200 Subject: [Haiku-commits] r25302 - haiku/trunk/src/preferences/print Message-ID: <200805031139.m43Bdsuu031509@sheep.berlios.de> Author: julun Date: 2008-05-03 13:39:54 +0200 (Sat, 03 May 2008) New Revision: 25302 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25302&view=rev Modified: haiku/trunk/src/preferences/print/JobListView.cpp haiku/trunk/src/preferences/print/JobListView.h Log: * added missing destructor * delete app icon on pref close * use HVIF icon in case of Haiku Modified: haiku/trunk/src/preferences/print/JobListView.cpp =================================================================== --- haiku/trunk/src/preferences/print/JobListView.cpp 2008-05-03 10:08:10 UTC (rev 25301) +++ haiku/trunk/src/preferences/print/JobListView.cpp 2008-05-03 11:39:54 UTC (rev 25302) @@ -51,6 +51,13 @@ } +JobListView::~JobListView() +{ + while (!IsEmpty()) + delete RemoveItem(0L); +} + + void JobListView::AttachedToWindow() { @@ -64,31 +71,24 @@ void JobListView::SetSpoolFolder(SpoolFolder* folder) { - BPath path; - // clear list - const BListItem** items = Items(); - for (int i = CountItems() - 1; i >= 0; i --) { - delete items[i]; - } - MakeEmpty(); + while (!IsEmpty()) + delete RemoveItem(0L); if (folder == NULL) return; // Find directory containing printer definition nodes - for (int32 i = 0; i < folder->CountJobs(); i ++) { - Job* job = folder->JobAt(i); - AddJob(job); - } + for (int32 i = 0; i < folder->CountJobs(); i++) + AddJob(folder->JobAt(i)); } JobItem* -JobListView::Find(Job* job) +JobListView::FindJob(Job* job) const { const int32 n = CountItems(); - for (int32 i = 0; i < n; i ++) { + for (int32 i = 0; i < n; i++) { JobItem* item = dynamic_cast(ItemAt(i)); if (item && item->GetJob() == job) return item; @@ -98,18 +98,16 @@ JobItem* -JobListView::SelectedItem() +JobListView::SelectedItem() const { - BListItem* item = ItemAt(CurrentSelection()); - return dynamic_cast(item); + return dynamic_cast(ItemAt(CurrentSelection())); } void JobListView::AddJob(Job* job) { - JobItem* item = new JobItem(job); - AddItem(item); + AddItem(new JobItem(job)); Invalidate(); } @@ -117,7 +115,7 @@ void JobListView::RemoveJob(Job* job) { - JobItem* item = Find(job); + JobItem* item = FindJob(job); if (item) { RemoveItem(item); delete item; @@ -129,7 +127,7 @@ void JobListView::UpdateJob(Job* job) { - JobItem* item = Find(job); + JobItem* item = FindJob(job); if (item) { item->Update(); InvalidateItem(IndexOf(item)); @@ -176,6 +174,7 @@ JobItem::~JobItem() { fJob->Release(); + delete fIcon; } @@ -193,7 +192,17 @@ entry_ref ref; if (fIcon == NULL && be_roster->FindApp(mimeType.String(), &ref) == B_OK) { - fIcon = new BBitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_CMAP8); +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + font_height fontHeight; + be_plain_font->GetHeight(&fontHeight); + float height = (fontHeight.ascent + fontHeight.descent + + fontHeight.leading) * 2.0; + BRect rect(0.0, 0.0, height, height); + fIcon = new BBitmap(rect, B_RGBA32); +#else + BRect rect(0.0, 0.0, B_MINI_ICON - 1, B_MINI_ICON - 1); + fIcon = new BBitmap(rect, B_CMAP8); +#endif BMimeType type(mimeType.String()); if (type.GetIcon(fIcon, B_MINI_ICON) != B_OK) { delete fIcon; @@ -254,7 +263,7 @@ font_height height; font->GetHeight(&height); - SetHeight((height.ascent + height.descent + height.leading) * 2.0 + 4.0); + SetHeight((height.ascent + height.descent + height.leading) * 2.0 + 8.0); } @@ -263,40 +272,52 @@ { BListView* list = dynamic_cast(owner); if (list) { - font_height height; BFont font; owner->GetFont(&font); + + font_height height; font.GetHeight(&height); - float fntheight = height.ascent+height.descent+height.leading; + float fntheight = height.ascent + height.descent + height.leading; BRect bounds = list->ItemFrame(list->IndexOf(this)); rgb_color color = owner->ViewColor(); + rgb_color oldViewColor = color; + rgb_color oldLowColor = owner->LowColor(); + rgb_color oldHighColor = owner->HighColor(); + if (IsSelected()) color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT); - rgb_color oldviewcolor = owner->ViewColor(); - rgb_color oldlowcolor = owner->LowColor(); - rgb_color oldcolor = owner->HighColor(); owner->SetViewColor(color); owner->SetHighColor(color); owner->SetLowColor(color); + owner->FillRect(bounds); - owner->SetLowColor(oldlowcolor); - owner->SetHighColor(oldcolor); - BPoint iconPt(bounds.LeftTop() + BPoint(2, 2)); - BPoint leftTop(bounds.LeftTop() + BPoint(12 + B_MINI_ICON, 2)); - BPoint namePt(leftTop + BPoint(0, fntheight)); - BPoint statusPt(leftTop + BPoint(0, fntheight*2)); + owner->SetLowColor(oldLowColor); + owner->SetHighColor(oldHighColor); - float width = owner->StringWidth(fPages.String()); - BPoint pagePt(bounds.RightTop() + BPoint(-width - 32, fntheight)); - width = owner->StringWidth(fSize.String()); - BPoint sizePt(bounds.RightTop() + BPoint(-width - 32, fntheight * 2)); + BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0)); + float iconHeight = B_MINI_ICON; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (fIcon) + iconHeight = fIcon->Bounds().Height(); +#endif + BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0)); + BPoint namePt(leftTop + BPoint(0.0, fntheight)); + BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0)); + float x = owner->StringWidth(fPages.String()) + 32.0; + BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight)); + BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0)); + drawing_mode mode = owner->DrawingMode(); - owner->SetDrawingMode(B_OP_OVER); +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + owner->SetDrawingMode(B_OP_ALPHA); +#else + owner->SetDrawingMode(B_OP_OVER); +#endif if (fIcon) owner->DrawBitmap(fIcon, iconPt); @@ -310,6 +331,6 @@ owner->DrawString(fSize.String(), fSize.Length(), sizePt); owner->SetDrawingMode(mode); - owner->SetViewColor(oldviewcolor); + owner->SetViewColor(oldViewColor); } } Modified: haiku/trunk/src/preferences/print/JobListView.h =================================================================== --- haiku/trunk/src/preferences/print/JobListView.h 2008-05-03 10:08:10 UTC (rev 25301) +++ haiku/trunk/src/preferences/print/JobListView.h 2008-05-03 11:39:54 UTC (rev 25302) @@ -46,6 +46,8 @@ typedef BListView Inherited; public: JobListView(BRect frame); + ~JobListView(); + void AttachedToWindow(); void SetSpoolFolder(SpoolFolder* folder); @@ -53,13 +55,13 @@ void RemoveJob(Job* job); void UpdateJob(Job* job); - JobItem* SelectedItem(); + JobItem* SelectedItem() const; void RestartJob(); void CancelJob(); private: - JobItem* Find(Job* job); + JobItem* FindJob(Job* job) const; }; @@ -74,7 +76,7 @@ void Update(BView *owner, const BFont *font); void DrawItem(BView *owner, BRect bounds, bool complete); - Job* GetJob() { return fJob; } + Job* GetJob() const { return fJob; } private: Job* fJob; From ingo_weinhold at gmx.de Sat May 3 15:03:05 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 03 May 2008 15:03:05 +0200 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: References: <200805022249.m42MnNZI017075@sheep.berlios.de> Message-ID: <20080503150305.419.1@knochen-vm.1209818782.fake> On 2008-05-03 at 10:30:04 [+0200], Salvatore Benedetto wrote: > > By the way, this makes me wonder why development tools are still not > included by default in the image. The default configuration is kind of a minimal configuration. It is supposed to contain only stuff that ends up in all distributions. CU, Ingo From revol at free.fr Sat May 3 16:43:18 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sat, 03 May 2008 16:43:18 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25300_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/network/protocols/unix?= In-Reply-To: <200805030114.m431EjRm019886@sheep.berlios.de> Message-ID: <2678855030-BeMail@laptop> > * Support the new {send,read}_data_no_buffer() protocol hooks to > avoid > unnecessary data copies and waste of memory. > * Changed the storage backend to ring_buffer. Isn't AF_UNI supposed to maintain packet boundaries (for SOCK_DGRAM that is) ?? Fran?ois. From emitrax at gmail.com Sat May 3 16:58:13 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 3 May 2008 14:58:13 +0000 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <20080503150305.419.1@knochen-vm.1209818782.fake> References: <200805022249.m42MnNZI017075@sheep.berlios.de> <20080503150305.419.1@knochen-vm.1209818782.fake> Message-ID: 2008/5/3 Ingo Weinhold : > > On 2008-05-03 at 10:30:04 [+0200], Salvatore Benedetto > wrote: > > > > > By the way, this makes me wonder why development tools are still not > > included by default in the image. > > The default configuration is kind of a minimal configuration. It is supposed > to contain only stuff that ends up in all distributions. IMHO, taking in consideration that R1 enduser are mainly developers, I think we should reconsider this. > CU, Ingo > Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From ingo_weinhold at gmx.de Sat May 3 18:17:16 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 03 May 2008 18:17:16 +0200 Subject: [Haiku-commits] r25300 - haiku/trunk/src/add-ons/kernel/network/protocols/unix In-Reply-To: <2678855030-BeMail@laptop> References: <2678855030-BeMail@laptop> Message-ID: <20080503181716.624.2@knochen-vm.1209818782.fake> On 2008-05-03 at 16:43:18 [+0200], Fran?ois Revol wrote: > > * Support the new {send,read}_data_no_buffer() protocol hooks to > > avoid > > unnecessary data copies and waste of memory. > > * Changed the storage backend to ring_buffer. > > Isn't AF_UNI supposed to maintain packet boundaries (for SOCK_DGRAM > that is) ?? Of course, but we do support SOCK_STREAM Unix sockets only, ATM. CU, Ingo From ingo_weinhold at gmx.de Sat May 3 18:35:39 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 03 May 2008 18:35:39 +0200 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: References: <200805022249.m42MnNZI017075@sheep.berlios.de> <20080503150305.419.1@knochen-vm.1209818782.fake> Message-ID: <20080503183539.653.3@knochen-vm.1209818782.fake> On 2008-05-03 at 16:58:13 [+0200], Salvatore Benedetto wrote: > 2008/5/3 Ingo Weinhold : > > On 2008-05-03 at 10:30:04 [+0200], Salvatore Benedetto > > > > wrote: > > > By the way, this makes me wonder why development tools are still not > > > included by default in the image. > > > > The default configuration is kind of a minimal configuration. It is > > supposed > > to contain only stuff that ends up in all distributions. > > IMHO, taking in consideration that R1 enduser are mainly developers, I > think we should reconsider > this. You seem to miss the difference between the image that is built by default and whatever distributions we're going to create. Even if we decide to do only a single distribution and include the development tools, that doesn't mean they have to be included in the default image. Adding them increases the image build time quite a bit, and that might be undesired by Haiku developers. CU, Ingo From ingo_weinhold at gmx.de Sun May 4 02:23:45 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 02:23:45 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <34496480162-BeMail@zon> References: <34496480162-BeMail@zon> Message-ID: <20080504022345.1388.5@knochen-vm.1209818782.fake> On 2008-05-02 at 20:41:00 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > > However, what exactly happens with this test? > > > I had it wait for closing connections, but they were all left > > > established. Also, the open sockets used up more than 27 MB - which > > > doesn't really look good. > > I don't know about that. At least one TCP connection and a few UNIX > > socket > > connections should stay open during the whole test. They are > > associated > > with the ssh connection that forwards the ports. I don't know exactly > > how > > port forwarding is implemented, but I think it just uses the one TCP > > connection. Until the forwarded ports are used, of course. > > It seems to use lots of connections. When I let the test run, it > eventually comes to a point where it wants to end (endless loop or > not); there might still be progress, the loop will just consume 100% > CPU time. > > > The problem I usually encounter is that an ssh and an sshd process > > both > > start to infinitely loop in TCPEndpoint::SendData() -> > > WaitList::Wait() at > > some point. If they don't, the test will just pass. The test runs for > > a > > while and has no output (unless you enable it; cf. README.regress), > > so it > > helps to keep ProcessController's team menu open. The infinite loop > > situation is easily recognizable. > > If you had waited a bit more, it would have spilled out some data :-) I had let the test run for quite a while (10 min at least) without any output. Also, the two busy threads couldn't be killed, as expected for threads busy-looping in the kernel. > In any case, I haven't seen the high memory usage anymore, now. Before, > it would always happen when I let the test progress after TCP ate all > CPU power. With r25300(+) I still have problems, though the test passes now. After a short while of running, it dumps a list of 20+ connections it is still waiting for to terminate. During that time an ssh process, an sshd process, and the "loop consumer" thread consume all CPU. After several minutes the test continues and succeeds. Before, when the test wouldn't hang, it would just pass after a much shorter time without dumping anything. I also still have the problem with ssh'ing onto a SunSSH server. After successful authentication and interactive session setup the server would unexpectedly send an EOF message. Unfortunately I have no permission to look into the server logs to see what its problem is. I suspect some Haiku networking issue, though. The net server and BONE OpenSSH 3.9p1 packages have the same problem when running under Haiku. So, unfortunately all is not well in networking land yet. :-/ CU, Ingo From bonefish at mail.berlios.de Sun May 4 02:28:28 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 02:28:28 +0200 Subject: [Haiku-commits] r25303 - haiku/trunk/headers/posix/sys Message-ID: <200805040028.m440SSYm012629@sheep.berlios.de> Author: bonefish Date: 2008-05-04 02:28:27 +0200 (Sun, 04 May 2008) New Revision: 25303 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25303&view=rev Modified: haiku/trunk/headers/posix/sys/socket.h Log: Added the Linuxish SO_PEERCRED. Modified: haiku/trunk/headers/posix/sys/socket.h =================================================================== --- haiku/trunk/headers/posix/sys/socket.h 2008-05-03 11:39:54 UTC (rev 25302) +++ haiku/trunk/headers/posix/sys/socket.h 2008-05-04 00:28:27 UTC (rev 25303) @@ -67,6 +67,7 @@ #define SO_TYPE 0x40000008 /* get socket type */ #define SO_NONBLOCK 0x40000009 #define SO_BINDTODEVICE 0x4000000a +#define SO_PEERCRED 0x4000000b /* get peer credentials, param: ucred */ /* Shutdown options */ #define SHUT_RD 0 @@ -144,7 +145,14 @@ /* SOL_SOCKET control message types */ #define SCM_RIGHTS 0x01 +/* parameter to SO_PEERCRED */ +struct ucred { + pid_t pid; /* PID of sender */ + uid_t uid; /* UID of sender */ + gid_t gid; /* GID of sender */ +}; + #if __cplusplus extern "C" { #endif From bonefish at mail.berlios.de Sun May 4 02:32:26 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 02:32:26 +0200 Subject: [Haiku-commits] r25304 - haiku/trunk/build/jam Message-ID: <200805040032.m440WQRk012934@sheep.berlios.de> Author: bonefish Date: 2008-05-04 02:32:26 +0200 (Sun, 04 May 2008) New Revision: 25304 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25304&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Don't create the symlinks for the old networking libraries in the development libraries dir. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-04 00:28:27 UTC (rev 25303) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-04 00:32:26 UTC (rev 25304) @@ -29,8 +29,7 @@ # library symlinks local lib ; - for lib in $(BEOS_SYSTEM_LIBS) - $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) libglut.so { + for lib in $(BEOS_SYSTEM_LIBS) libglut.so { AddSymlinkToHaikuImage develop lib x86 : /system/lib/$(lib:BS) ; } From bonefish at mail.berlios.de Sun May 4 02:32:58 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 02:32:58 +0200 Subject: [Haiku-commits] r25305 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805040032.m440WwjH012992@sheep.berlios.de> Author: bonefish Date: 2008-05-04 02:32:57 +0200 (Sun, 04 May 2008) New Revision: 25305 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25305&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp Log: Added support for SO_PEERCRED for Unix sockets. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-04 00:32:26 UTC (rev 25304) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp 2008-05-04 00:32:57 UTC (rev 25305) @@ -254,6 +254,10 @@ _UnsetReceiveFifo(); + fCredentials.pid = getpid(); + fCredentials.uid = geteuid(); + fCredentials.gid = getegid(); + fState = UNIX_ENDPOINT_LISTENING; RETURN_ERROR(B_OK); @@ -352,7 +356,7 @@ UnixEndpointLocker connectedLocker(connectedEndpoint); - connectedEndpoint->_Spawn(this, peerFifo); + connectedEndpoint->_Spawn(this, listeningEndpoint, peerFifo); // update our attributes _UnsetReceiveFifo(); @@ -362,6 +366,10 @@ fPeerEndpoint->AddReference(); fReceiveFifo = fifo; + fCredentials.pid = getpid(); + fCredentials.uid = geteuid(); + fCredentials.gid = getegid(); + fifoDeleter.Detach(); peerFifoDeleter.Detach(); @@ -651,6 +659,22 @@ status_t +UnixEndpoint::GetPeerCredentials(ucred* credentials) +{ + UnixEndpointLocker locker(this); + UnixEndpointLocker peerLocker; + + status_t error = _LockConnectedEndpoints(locker, peerLocker); + if (error != B_OK) + RETURN_ERROR(error); + + *credentials = fPeerEndpoint->fCredentials; + + return B_OK; +} + + +status_t UnixEndpoint::Shutdown(int direction) { TRACE("[%ld] %p->UnixEndpoint::Shutdown(%d)\n", @@ -710,7 +734,8 @@ void -UnixEndpoint::_Spawn(UnixEndpoint* connectingEndpoint, UnixFifo* fifo) +UnixEndpoint::_Spawn(UnixEndpoint* connectingEndpoint, + UnixEndpoint* listeningEndpoint, UnixFifo* fifo) { ProtocolSocket::Open(); @@ -722,6 +747,8 @@ PeerAddress().SetTo(&connectingEndpoint->socket->address); + fCredentials = listeningEndpoint->fCredentials; + fState = UNIX_ENDPOINT_CONNECTED; } Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h 2008-05-04 00:32:26 UTC (rev 25304) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h 2008-05-04 00:32:57 UTC (rev 25305) @@ -76,6 +76,7 @@ ssize_t Receivable(); status_t SetReceiveBufferSize(size_t size); + status_t GetPeerCredentials(ucred* credentials); status_t Shutdown(int direction); @@ -95,7 +96,8 @@ } private: - void _Spawn(UnixEndpoint* connectingEndpoint, UnixFifo* fifo); + void _Spawn(UnixEndpoint* connectingEndpoint, + UnixEndpoint* listeningEndpoint, UnixFifo* fifo); void _Disconnect(); status_t _LockConnectedEndpoints(UnixEndpointLocker& locker, UnixEndpointLocker& peerLocker); @@ -115,8 +117,8 @@ UnixFifo* fReceiveFifo; unix_endpoint_state fState; sem_id fAcceptSemaphore; + ucred fCredentials; bool fIsChild; }; - #endif // UNIX_ENDPOINT_H Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-04 00:32:26 UTC (rev 25304) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-04 00:32:57 UTC (rev 25305) @@ -132,6 +132,17 @@ unix_getsockopt(net_protocol *protocol, int level, int option, void *value, int *_length) { + UnixEndpoint* endpoint = (UnixEndpoint*)protocol; + + if (level == SOL_SOCKET && option == SO_PEERCRED) { + if (*_length < (int)sizeof(ucred)) + return B_BAD_VALUE; + + *_length = sizeof(ucred); + + return endpoint->GetPeerCredentials((ucred*)value); + } + return gSocketModule->get_option(protocol->socket, level, option, value, _length); } From koki at digintrans.com Sun May 4 02:32:26 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Sat, 03 May 2008 17:32:26 -0700 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <20080503183539.653.3@knochen-vm.1209818782.fake> References: <200805022249.m42MnNZI017075@sheep.berlios.de> <20080503150305.419.1@knochen-vm.1209818782.fake> <20080503183539.653.3@knochen-vm.1209818782.fake> Message-ID: <481D041A.90107@digintrans.com> Ingo Weinhold wrote: > On 2008-05-03 at 16:58:13 [+0200], Salvatore Benedetto > wrote: > >> 2008/5/3 Ingo Weinhold : >> >>> On 2008-05-03 at 10:30:04 [+0200], Salvatore Benedetto >>> >>> wrote: >>> > By the way, this makes me wonder why development tools are still not >>> > included by default in the image. >>> >>> The default configuration is kind of a minimal configuration. It is >>> supposed >>> to contain only stuff that ends up in all distributions. >>> >> IMHO, taking in consideration that R1 enduser are mainly developers, I >> think we should reconsider >> this. >> > > You seem to miss the difference between the image that is built by default > and whatever distributions we're going to create. Even if we decide to do > only a single distribution and include the development tools, that doesn't > mean they have to be included in the default image. Adding them increases > the image build time quite a bit, and that might be undesired by Haiku > developers. > Allow me to add to Ingo's comment, and please, Ingo or any other of the Haiku developers here, do correct me if I am wrong on any account. No decision has been made yet regarding what will or will not be included in the official Haiku distribution, or whether there is going to be one or more versions of Haiku targeting different user groups. What this means is that any assumption as to what Haiku will or will not be is pure speculation at this point in time. I feel compelled to mention this because I recently read comments on OSNews.com to the effect that Haiku will most likely not include all the apps that you need for daily use. This sort of statements are pure assumptions, and unfortunately could make those who are not well informed believe something that may not actually be the case in the future, also potentially propitiating the idea that third party Haiku-based distros are inevitable. The Haiku devs will have to make decisions with regards to the Haiku distro(s) at some point in time; that time has not come yet though. Until then, please at least give them the benefit of the doubt. I think they deserve, don't you? :) The channel goes back to its regular programming now. :) Cheers, Koki From marcusoverhagen at mail.berlios.de Sun May 4 03:20:22 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 4 May 2008 03:20:22 +0200 Subject: [Haiku-commits] r25306 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200805040120.m441KMHT015324@sheep.berlios.de> Author: marcusoverhagen Date: 2008-05-04 03:20:22 +0200 (Sun, 04 May 2008) New Revision: 25306 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25306&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp Log: make memory map printing independant of other mmu debug output Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2008-05-04 00:32:57 UTC (rev 25305) +++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2008-05-04 01:20:22 UTC (rev 25306) @@ -51,6 +51,13 @@ # define TRACE(x) ; #endif + +//#define TRACE_MEMORY_MAP + // Define this to print the memory map to serial debug, + // You also need to define ENABLE_SERIAL in serial.cpp + // for output to work. + + struct gdt_idt_descr { uint16 limit; uint32 *base; @@ -252,6 +259,22 @@ } + +#ifdef TRACE_MEMORY_MAP +static const char * +e820_memory_type(uint32 type) +{ + switch (type) { + case 1: return "memory"; + case 2: return "reserved"; + case 3: return "ACPI reclaim"; + case 4: return "ACPI NVS"; + default: return "unknown/reserved"; + } +} +#endif + + static uint32 get_memory_map(extended_memory **_extendedMemory) { @@ -275,11 +298,12 @@ *_extendedMemory = block; -#ifdef TRACE_MMU +#ifdef TRACE_MEMORY_MAP dprintf("extended memory info (from 0xe820):\n"); for (uint32 i = 0; i < count; i++) { - dprintf(" base 0x%Lx, len 0x%Lx, type %lu\n", - block[i].base_addr, block[i].length, block[i].type); + dprintf(" base 0x%08Lx, len 0x%08Lx, type %lu (%s)\n", + block[i].base_addr, block[i].length, + block[i].type, e820_memory_type(block[i].type)); } #endif @@ -534,7 +558,7 @@ sort_addr_range(gKernelArgs.virtual_allocated_range, gKernelArgs.num_virtual_allocated_ranges); -#ifdef TRACE_MMU +#ifdef TRACE_MEMORY_MAP { uint32 i; From ingo_weinhold at gmx.de Sun May 4 02:55:08 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 02:55:08 +0200 Subject: [Haiku-commits] r25283 - in haiku/trunk: headers/private/kernel headers/private/kernel/util src/add-ons/kernel/drivers/arch/x86/keyboard src/add-ons/kernel/drivers/tty src/add-ons/kernel/file_cache src/add-ons/kernel/network/protocols/tcp src/libs/compat/freebsd_network src/libs/compat/freebsd_network/compat/sys src/system/kernel src/system/kernel/arch/generic src/system/kernel/cache src/system/kernel/fs src/system/kernel/util src/system/kernel/vm src/system/libroot/os In-Reply-To: <20080504022345.1388.5@knochen-vm.1209818782.fake> References: <34496480162-BeMail@zon> <20080504022345.1388.5@knochen-vm.1209818782.fake> Message-ID: <20080504025508.1452.6@knochen-vm.1209818782.fake> On 2008-05-04 at 02:23:45 [+0200], Ingo Weinhold wrote: > With r25300(+) I still have problems, though the test passes now. After a > short while of running, it dumps a list of 20+ connections it is still > waiting for to terminate. During that time an ssh process, an sshd process, > and the "loop consumer" thread consume all CPU. After several minutes the > test continues and succeeds. Before, when the test wouldn't hang, it would > just pass after a much shorter time without dumping anything. I forgot that I had debug output in tcp.cpp and TCPEndpoint.cpp enabled. After disabling it and running the test again, the "loop consumer" would eat all CPU (no output in the terminal). After a while someone had consumed all memory. A few more runs of the test passed without any events. CU, Ingo From umccullough at gmail.com Sun May 4 04:47:50 2008 From: umccullough at gmail.com (Urias McCullough) Date: Sat, 3 May 2008 19:47:50 -0700 Subject: [Haiku-commits] r25297 - haiku/trunk/src/apps/aboutsystem In-Reply-To: <481D041A.90107@digintrans.com> References: <200805022249.m42MnNZI017075@sheep.berlios.de> <20080503150305.419.1@knochen-vm.1209818782.fake> <20080503183539.653.3@knochen-vm.1209818782.fake> <481D041A.90107@digintrans.com> Message-ID: <1e80d8750805031947r65617f22yaa620531c67dc197@mail.gmail.com> 2008/5/3 Jorge G. Mare (aka Koki) : > I feel compelled to mention this because I recently read comments on > OSNews.com to the effect that Haiku will most likely not include all the > apps that you need for daily use. Pretty certain I said that :) I was mostly referring to an office suite. From revol at free.fr Sun May 4 11:35:08 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 04 May 2008 11:35:08 +0200 CEST Subject: [Haiku-commits] r25300 - haiku/trunk/src/add-ons/kernel/network/protocols/unix In-Reply-To: <20080503181716.624.2@knochen-vm.1209818782.fake> Message-ID: <341086564-BeMail@laptop> > > On 2008-05-03 at 16:43:18 [+0200], Fran?ois Revol > wrote: > > > * Support the new {send,read}_data_no_buffer() protocol hooks to > > > avoid > > > unnecessary data copies and waste of memory. > > > * Changed the storage backend to ring_buffer. > > > > Isn't AF_UNI supposed to maintain packet boundaries (for SOCK_DGRAM > > that is) ?? > > Of course, but we do support SOCK_STREAM Unix sockets only, ATM. Hmm ok but how do you attach the anciliary data to a position in the byte stream ? and how do you handle reading 2 bytes at once each with anciliary data ? Fran?ois. From ingo_weinhold at gmx.de Sun May 4 14:32:45 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 14:32:45 +0200 Subject: [Haiku-commits] r25300 - haiku/trunk/src/add-ons/kernel/network/protocols/unix In-Reply-To: <341086564-BeMail@laptop> References: <341086564-BeMail@laptop> Message-ID: <20080504143245.392.1@knochen-vm.1209904186.fake> On 2008-05-04 at 11:35:08 [+0200], Fran?ois Revol wrote: > > > > On 2008-05-03 at 16:43:18 [+0200], Fran?ois Revol > > wrote: > > > > * Support the new {send,read}_data_no_buffer() protocol hooks to > > > > avoid > > > > unnecessary data copies and waste of memory. > > > > * Changed the storage backend to ring_buffer. > > > > > > Isn't AF_UNI supposed to maintain packet boundaries (for SOCK_DGRAM > > > that is) ?? > > > > Of course, but we do support SOCK_STREAM Unix sockets only, ATM. > > Hmm ok but how do you attach the anciliary data to a position in the > byte stream ? and how do you handle reading 2 bytes at once each with > anciliary data ? By using a separate queue for the ancillary data. Feel free to review the implementation in src/add-ons/kernel/network/protocols/unix/UnixFifo.* CU, Ingo From bonefish at mail.berlios.de Sun May 4 14:48:22 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 14:48:22 +0200 Subject: [Haiku-commits] r25307 - haiku/trunk/src/servers/registrar/mime Message-ID: <200805041248.m44CmMCV002241@sheep.berlios.de> Author: bonefish Date: 2008-05-04 14:48:21 +0200 (Sun, 04 May 2008) New Revision: 25307 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25307&view=rev Modified: haiku/trunk/src/servers/registrar/mime/CreateAppMetaMimeThread.cpp Log: If the supplied entry was a directory, CreateAppMetaMimeThread::DoMimeUpdate() would always fail early, making recursive operation impossible. Modified: haiku/trunk/src/servers/registrar/mime/CreateAppMetaMimeThread.cpp =================================================================== --- haiku/trunk/src/servers/registrar/mime/CreateAppMetaMimeThread.cpp 2008-05-04 01:20:22 UTC (rev 25306) +++ haiku/trunk/src/servers/registrar/mime/CreateAppMetaMimeThread.cpp 2008-05-04 12:48:21 UTC (rev 25307) @@ -49,6 +49,13 @@ if (status < B_OK) return status; + bool isDir = file.IsDirectory(); + if (_entryIsDir != NULL) + *_entryIsDir = isDir; + + if (isDir) + return B_OK; + BAppFileInfo appInfo(&file); status = appInfo.InitCheck(); if (status < B_OK) @@ -143,9 +150,6 @@ status = mime.SetIconForType(type, &largeIcon, B_LARGE_ICON); } - if (status == B_OK && _entryIsDir != NULL) - *_entryIsDir = file.IsDirectory(); - return status; } From bonefish at mail.berlios.de Sun May 4 15:01:11 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 15:01:11 +0200 Subject: [Haiku-commits] r25308 - haiku/trunk/src/kits/storage Message-ID: <200805041301.m44D1BRc002963@sheep.berlios.de> Author: bonefish Date: 2008-05-04 15:01:11 +0200 (Sun, 04 May 2008) New Revision: 25308 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25308&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: Changed the semantics of create_app_meta_mime(): Like update_mime_info() it does now accept directories and doesn't ignore the "recursive" parameter anymore. Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-05-04 12:48:21 UTC (rev 25307) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-05-04 13:01:11 UTC (rev 25308) @@ -111,11 +111,13 @@ // create_app_meta_mime /*! Creates a MIME database entry for one or more applications. - \a path should either point to an application file or should be \c NULL. - In the first case a MIME database entry for that application is created, - in the second case entries for all applications are created. - \param path The path to an application file, or \c NULL. - \param recursive Currently unused. + If \a path points to an application file, a MIME DB entry is create for the + application. If it points to a directory and \a recursive is non-null, + entries are created for all application files in the given directory + tree. If path is \c NULL all files are considered; \a recursive is + ignored in this case. + \param path The path to an application file, a directory, or \c NULL. + \param recursive Non-null to trigger recursive behavior. \param synchronous If non-null create_app_meta_mime() waits until the operation is finished, otherwise it returns immediately and the operation is done asynchronously. @@ -129,8 +131,9 @@ create_app_meta_mime(const char *path, int recursive, int synchronous, int force) { - // If path is NULL, we are recursive, otherwise no. - recursive = !path; + // Force recursion when given a NULL path + if (!path) + recursive = true; return do_mime_update(B_REG_MIME_CREATE_APP_META_MIME, path, recursive, synchronous, force); From bonefish at mail.berlios.de Sun May 4 15:10:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 15:10:42 +0200 Subject: [Haiku-commits] r25309 - in haiku/trunk: build/jam data/etc data/etc/post_install data/settings data/system/boot Message-ID: <200805041310.m44DAgW4003600@sheep.berlios.de> Author: bonefish Date: 2008-05-04 15:10:42 +0200 (Sun, 04 May 2008) New Revision: 25309 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25309&view=rev Added: haiku/trunk/data/etc/post_install/ haiku/trunk/data/etc/post_install/fresh_install haiku/trunk/data/etc/post_install/mime_update.sh Removed: haiku/trunk/data/settings/fresh_install Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/data/system/boot/Bootscript Log: Reactivated the "fresh install" code in the Bootscript, but modified it a bit: * Added directory /etc/post_install, which can contain scripts that will be executed on the first boot. * Moved the mimeset invocations to such a script. Use the "-apps" option instead of "-all". Since create_app_meta_mime() (and thus mimeset) work recursively now, running the commands does actually have an effect. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-04 13:01:11 UTC (rev 25308) +++ haiku/trunk/build/jam/HaikuImage 2008-05-04 13:10:42 UTC (rev 25309) @@ -337,9 +337,12 @@ = [ FDirName $(HAIKU_TOP) data settings network ] ; AddFilesToHaikuImage common settings network : $(networkSettingsFiles) ; -# fresh install indicator file -SEARCH on fresh_install = [ FDirName $(HAIKU_TOP) data settings ] ; -AddFilesToHaikuImage home config settings : fresh_install ; +# post install scripts and fresh install indicator file +local postInstallFiles = fresh_install mime_update.sh ; +postInstallFiles = $(postInstallFiles:G=post-install) ; +SEARCH on $(postInstallFiles) + = [ FDirName $(HAIKU_TOP) data etc post_install ] ; +AddFilesToHaikuImage beos etc post_install : $(postInstallFiles) ; # boot loader AddFilesToHaikuImage beos system : zbeos ; Copied: haiku/trunk/data/etc/post_install/fresh_install (from rev 25297, haiku/trunk/data/settings/fresh_install) Added: haiku/trunk/data/etc/post_install/mime_update.sh =================================================================== --- haiku/trunk/data/etc/post_install/mime_update.sh 2008-05-04 13:01:11 UTC (rev 25308) +++ haiku/trunk/data/etc/post_install/mime_update.sh 2008-05-04 13:10:42 UTC (rev 25309) @@ -0,0 +1,8 @@ +#!/bin/sh + +# Make sure all apps have a MIME DB entry. + +mimeset -apps -f /boot/beos/apps +mimeset -apps -f /boot/beos/preferences +mimeset -apps -f /boot/beos/system/servers +mimeset -apps -f /boot/apps Property changes on: haiku/trunk/data/etc/post_install/mime_update.sh ___________________________________________________________________ Name: svn:executable + * Deleted: haiku/trunk/data/settings/fresh_install Modified: haiku/trunk/data/system/boot/Bootscript =================================================================== --- haiku/trunk/data/system/boot/Bootscript 2008-05-04 13:01:11 UTC (rev 25308) +++ haiku/trunk/data/system/boot/Bootscript 2008-05-04 13:10:42 UTC (rev 25309) @@ -138,12 +138,21 @@ fi fi -# Check for fresh install and register all bundled app mimetypes -FRESH_INSTALL_INDICATOR_FILE=$HOME/config/settings/fresh_install -if [ -e $FRESH_INSTALL_INDICATOR_FILE ]; then -# mimeset -all -f /boot/beos/apps -# mimeset -all -f /boot/beos/preferences -# mimeset -all -f /boot/beos/system/servers -# mimeset -all -f /boot/apps - rm $FRESH_INSTALL_INDICATOR_FILE +# Check for fresh install and run post install scripts. +postInstallDir=/boot/beos/etc/post_install +freshInstallIndicator=$postInstallDir/fresh_install +if [ -e $freshInstallIndicator ]; then + # wait a moment for things to calm down a bit + sleep 3 + + # execute scripts + for f in $postInstallDir/*.sh; do + if [ -f $f ]; then + echo "Running post install script $f ..." > /dev/dprintf + $f + fi + done + + sync + rm $freshInstallIndicator fi From bonefish at mail.berlios.de Sun May 4 15:12:31 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 15:12:31 +0200 Subject: [Haiku-commits] r25310 - haiku/trunk/src/bin Message-ID: <200805041312.m44DCVRt003696@sheep.berlios.de> Author: bonefish Date: 2008-05-04 15:12:31 +0200 (Sun, 04 May 2008) New Revision: 25310 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25310&view=rev Modified: haiku/trunk/src/bin/Jamfile Log: diff_zip uses the STL and thus needs to be linked against the respective library. Not sure why it worked earlier. Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2008-05-04 13:10:42 UTC (rev 25309) +++ haiku/trunk/src/bin/Jamfile 2008-05-04 13:12:31 UTC (rev 25310) @@ -23,7 +23,6 @@ clear.c clockconfig.c # csplit.c - diff_zip.cpp driveinfo.c # echo.c eject.c @@ -120,13 +119,18 @@ xres.cpp : be $(TARGET_LIBSTDC++) : $(haiku-utils_rsrc) ; -# Haiku-specific apps which need libbe., libstdc++.so +# Haiku-specific apps which need libbe.so, libstdc++.so if $(TARGET_PLATFORM) = haiku { StdBinCommands mountvolume.cpp : be $(TARGET_LIBSTDC++) : $(haiku-utils_rsrc) ; } +# commands that need libstdc++ only +StdBinCommands + diff_zip.cpp + : $(TARGET_LIBSTDC++) : $(haiku-utils_rsrc) ; + # standard commands that need libbe.so, libtranslation.so StdBinCommands translate.cpp From bonefish at mail.berlios.de Sun May 4 15:19:57 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 15:19:57 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam Message-ID: <200805041319.m44DJvjG004057@sheep.berlios.de> Author: bonefish Date: 2008-05-04 15:19:57 +0200 (Sun, 04 May 2008) New Revision: 25311 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25311&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Added OpenSSH optional package. The daemon has to be started manually (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-04 13:12:31 UTC (rev 25310) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-04 13:19:57 UTC (rev 25311) @@ -17,6 +17,7 @@ # package dependencies OptionalPackageDependencies Development : Perl ; +OptionalPackageDependencies OpenSSH : OpenSSL ; # Development @@ -160,6 +161,23 @@ } +# OpenSSH +if [ IsOptionalHaikuImagePackageAdded OpenSSH ] { + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package OpenSSH available for gcc4" ; + } else { + local baseURL = http://haiku-files.org/files/optional-packages ; + InstallOptionalHaikuImagePackage openssh-5.0p1-gcc2-2008-05-04 + : $(baseURL)/openssh-5.0p1-gcc2-2008-05-04.zip + : + ; + + AddUserToHaikuImage sshd : 1001 : 100 : /var/empty : /bin/true + : "sshd user" ; + } +} + + # OpenSSL if [ IsOptionalHaikuImagePackageAdded OpenSSL ] { if $(HAIKU_GCC_VERSION[1]) >= 4 { From bonefish at mail.berlios.de Sun May 4 15:35:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 15:35:42 +0200 Subject: [Haiku-commits] r25312 - buildtools/trunk/patches/openssh Message-ID: <200805041335.m44DZgHv004819@sheep.berlios.de> Author: bonefish Date: 2008-05-04 15:35:41 +0200 (Sun, 04 May 2008) New Revision: 25312 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25312&view=rev Added: buildtools/trunk/patches/openssh/.OptionalPackageDescription buildtools/trunk/patches/openssh/openssh.diff buildtools/trunk/patches/openssh/ssh.sh Removed: buildtools/trunk/patches/openssh/openssh-4.7p1.diff Modified: buildtools/trunk/patches/openssh/Notes Log: Updated patch and notes. Also added the optional package description and the post install script. Added: buildtools/trunk/patches/openssh/.OptionalPackageDescription =================================================================== --- buildtools/trunk/patches/openssh/.OptionalPackageDescription 2008-05-04 13:19:57 UTC (rev 25311) +++ buildtools/trunk/patches/openssh/.OptionalPackageDescription 2008-05-04 13:35:41 UTC (rev 25312) @@ -0,0 +1,5 @@ +Package: OpenSSH +Version: 5.0p1 +Copyright: 2005-2008 Tatu Ylonen et al. +License: OpenSSH +URL: http://www.openssh.org/ Modified: buildtools/trunk/patches/openssh/Notes =================================================================== --- buildtools/trunk/patches/openssh/Notes 2008-05-04 13:19:57 UTC (rev 25311) +++ buildtools/trunk/patches/openssh/Notes 2008-05-04 13:35:41 UTC (rev 25312) @@ -1,4 +1,4 @@ -Notes for OpenSSH 4.7p1 (Haiku r24683) +Notes for OpenSSH 5.0p1 (Haiku r25311) ====================================== configure @@ -8,19 +8,24 @@ automake --add-missing autoreconf --force - ./configure --prefix=/boot/home/config --with-ssl-dir=/boot/home/config + ./configure --prefix=/boot/home/config --with-ssl-dir=/boot/home/config --sbindir=/boot/home/config/bin --libexecdir=/boot/home/config/bin --localstatedir=/var * automake will fail, but it will replace config.{sub,guess} anyway, which is all we want. -* Edit config.h: - - Undefined HAVE_CONTROL_IN_MSGHDR: Haiku doesn't really support it. - - define HAVE_U_INT64_T: Only to get rid of warnings while compiling. The - configure test only includes , which doesn't define Haiku's - u_int64_t ( does). +* Note, the /boot/home/config paths are temporary only. This has to be changed + to /boot/common. + make/install ------------ make make install + +packaging +--------- + +* Remove the generated host keys (in /boot/home/config/etc). +* Add the post install script (ssh.sh) that generates the host keys on the first + run. Deleted: buildtools/trunk/patches/openssh/openssh-4.7p1.diff Added: buildtools/trunk/patches/openssh/openssh.diff =================================================================== --- buildtools/trunk/patches/openssh/openssh.diff 2008-05-04 13:19:57 UTC (rev 25311) +++ buildtools/trunk/patches/openssh/openssh.diff 2008-05-04 13:35:41 UTC (rev 25312) @@ -0,0 +1,20 @@ +Patch against OpenSSH 5.0p1 to add Haiku support. +Date: 2008-05-04 + +diff -urN openssh-5.0p1-orig/configure.ac openssh-5.0p1/configure.ac +--- openssh-5.0p1-orig/configure.ac 2008-03-27 01:33:07.000000000 +0000 ++++ openssh-5.0p1/configure.ac 2008-05-04 00:29:35.000000000 +0000 +@@ -468,6 +468,13 @@ + *-*-dragonfly*) + SSHDLIBS="$SSHDLIBS -lcrypt" + ;; ++*-*-haiku*) ++ CPPFLAGS="$CPPFLAGS -I/boot/develop/headers/bsd" ++ LIBS="$LIBS -lbsd -lnetwork" ++ dnl u_int64_t is defined, just not through ++ AC_DEFINE(HAVE_U_INT64_T) ++ MANTYPE=man ++ ;; + *-*-hpux*) + # first we define all of the options common to all HP-UX releases + CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1" Added: buildtools/trunk/patches/openssh/ssh.sh =================================================================== --- buildtools/trunk/patches/openssh/ssh.sh 2008-05-04 13:19:57 UTC (rev 25311) +++ buildtools/trunk/patches/openssh/ssh.sh 2008-05-04 13:35:41 UTC (rev 25312) @@ -0,0 +1,17 @@ +#!/bin/sh + +# generate SSH host keys + +hostKeyDir=/boot/home/config/etc + +if [ ! -f "$hostKeyDir/ssh_host_key" ] ; then + ssh-keygen -t rsa1 -f "$hostKeyDir/ssh_host_key" -N "" +fi + +if [ ! -f "$hostKeyDir/ssh_host_dsa_key" ] ; then + ssh-keygen -t dsa -f "$hostKeyDir/ssh_host_dsa_key" -N "" +fi + +if [ ! -f "$hostKeyDir/ssh_host_rsa_key" ] ; then + ssh-keygen -t rsa -f "$hostKeyDir/ssh_host_rsa_key" -N "" +fi Property changes on: buildtools/trunk/patches/openssh/ssh.sh ___________________________________________________________________ Name: svn:executable + * From bga at bug-br.org.br Sun May 4 16:49:00 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Sun, 04 May 2008 11:49:00 -0300 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <200805041319.m44DJvjG004057@sheep.berlios.de> References: <200805041319.m44DJvjG004057@sheep.berlios.de> Message-ID: <481DCCDC.6060900@bug-br.org.br> bonefish at BerliOS escreveu: > Added OpenSSH optional package. The daemon has to be started manually > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. Hey Ingo. How does one set a password for a user under Haiku? -Bruno From ingo_weinhold at gmx.de Sun May 4 17:08:45 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 17:08:45 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <481DCCDC.6060900@bug-br.org.br> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <481DCCDC.6060900@bug-br.org.br> Message-ID: <20080504170845.620.3@knochen-vm.1209904186.fake> On 2008-05-04 at 16:49:00 [+0200], Bruno Albuquerque wrote: > bonefish at BerliOS escreveu: > > > Added OpenSSH optional package. The daemon has to be started manually > > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. > > Hey Ingo. How does one set a password for a user under Haiku? passwd CU, Ingo From ingo_weinhold at gmx.de Sun May 4 17:25:43 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 17:25:43 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080504170845.620.3@knochen-vm.1209904186.fake> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <481DCCDC.6060900@bug-br.org.br> <20080504170845.620.3@knochen-vm.1209904186.fake> Message-ID: <20080504172543.652.4@knochen-vm.1209904186.fake> On 2008-05-04 at 17:08:45 [+0200], Ingo Weinhold wrote: > > On 2008-05-04 at 16:49:00 [+0200], Bruno Albuquerque > wrote: > > bonefish at BerliOS escreveu: > > > > > Added OpenSSH optional package. The daemon has to be started manually > > > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. > > > > Hey Ingo. How does one set a password for a user under Haiku? > > passwd BTW, logging in as user other than baron doesn't work ATM. I suspect some kind of permission problem. CU, Ingo From bga at bug-br.org.br Sun May 4 17:36:12 2008 From: bga at bug-br.org.br (Bruno G. Albuquerque) Date: Sun, 4 May 2008 12:36:12 -0300 (BRT) Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080504172543.652.4@knochen-vm.1209904186.fake> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <481DCCDC.6060900@bug-br.org.br> <20080504170845.620.3@knochen-vm.1209904186.fake> <20080504172543.652.4@knochen-vm.1209904186.fake> Message-ID: <54808.189.26.192.175.1209915372.squirrel@www.bug-br.org.br> Em Dom, Maio 4, 2008 12:25 pm, Ingo Weinhold escreveu: >> > Hey Ingo. How does one set a password for a user under Haiku? >> >> passwd > > BTW, logging in as user other than baron doesn't work ATM. I suspect some > kind of permission problem. I take it you mean other then the root user, right? I am asking because dd change the default user to be "bga" and it works but, of course, the user id is the same. -Bruno From ingo_weinhold at gmx.de Sun May 4 17:55:06 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 17:55:06 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <54808.189.26.192.175.1209915372.squirrel@www.bug-br.org.br> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <481DCCDC.6060900@bug-br.org.br> <20080504170845.620.3@knochen-vm.1209904186.fake> <20080504172543.652.4@knochen-vm.1209904186.fake> <54808.189.26.192.175.1209915372.squirrel@www.bug-br.org.br> Message-ID: <20080504175506.697.5@knochen-vm.1209904186.fake> On 2008-05-04 at 17:36:12 [+0200], Bruno G. Albuquerque wrote: > Em Dom, Maio 4, 2008 12:25 pm, Ingo Weinhold escreveu: > > >> > Hey Ingo. How does one set a password for a user under Haiku? > >> > >> passwd > > > > BTW, logging in as user other than baron doesn't work ATM. I suspect some > > kind of permission problem. > > I take it you mean other then the root user, right? Yep. > I am asking because > dd change the default user to be "bga" and it works but, of course, the > user id is the same. I'd be very surprised, if dd managed to change the name of Haiku's root user. I bet you did that yourself in your UserBuildConfig. :-) CU, Ingo From bonefish at mail.berlios.de Sun May 4 18:06:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 18:06:42 +0200 Subject: [Haiku-commits] r25313 - in haiku/trunk/build: jam scripts Message-ID: <200805041606.m44G6gMN016976@sheep.berlios.de> Author: bonefish Date: 2008-05-04 18:06:41 +0200 (Sun, 04 May 2008) New Revision: 25313 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25313&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/scripts/build_haiku_image Log: Added rules AddOptionalPackageDescriptionToHaikuImage and AddLicenseToHaikuImage that can be used in optional package definitions to add a copyright entry in AboutSystem and add a license file to /etc/licenses. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-04 13:35:41 UTC (rev 25312) +++ haiku/trunk/build/jam/HaikuImage 2008-05-04 16:06:41 UTC (rev 25313) @@ -421,10 +421,30 @@ #pragma mark - Optional Packages +HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS = ; + include [ FDirName $(HAIKU_BUILD_RULES_DIR) OptionalPackages ] ; include [ FDirName $(HAIKU_BUILD_RULES_DIR) OptionalTestPackages ] ; +local optionalPackageDescriptions ; +if $(HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS) { + optionalPackageDescriptions = optional_package_descriptions ; + MakeLocate $(optionalPackageDescriptions) + : $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) ; + Depends $(optionalPackageDescriptions) + : $(HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS) ; + + actions together BuildOptionalPackageDescriptions + { + cat $(2) > $(1) + } + + BuildOptionalPackageDescriptions $(optionalPackageDescriptions) + : $(HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS) ; +} + + #pragma mark - User/Group Setup @@ -498,6 +518,10 @@ } else { AddVariableToScript $(script) : rmAttrs : rm ; } +if $(optionalPackageDescriptions) { + AddTargetVariableToScript $(script) : $(optionalPackageDescriptions) + : optionalPackageDescriptions ; +} # create the other scripts Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2008-05-04 13:35:41 UTC (rev 25312) +++ haiku/trunk/build/jam/ImageRules 2008-05-04 16:06:41 UTC (rev 25313) @@ -723,7 +723,29 @@ AddEntryToHaikuImageUserGroupFile group : $(entry) ; } +rule AddOptionalPackageDescriptionToHaikuImage file : searchPath +{ + if $(searchPath) { + SEARCH on $(file) = [ FDirName $(searchPath) ] ; + } + HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS += $(file) ; +} + +rule AddLicenseToHaikuImage file : name : searchPath +{ + if $(searchPath) { + SEARCH on $(file) = [ FDirName $(searchPath) ] ; + } + + if $(name) && $(file:BS) = $(name) { + name = ; + } + + AddFilesToHaikuImage beos etc licenses : $(file) : $(name) ; +} + + rule CreateHaikuImageMakeDirectoriesScript script { CreateContainerMakeDirectoriesScript $(HAIKU_IMAGE_CONTAINER_NAME) Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2008-05-04 13:35:41 UTC (rev 25312) +++ haiku/trunk/build/scripts/build_haiku_image 2008-05-04 16:06:41 UTC (rev 25313) @@ -12,6 +12,7 @@ # updateOnly # dontClearImage # isVMwareImage +# optionalPackageDescriptions # # addattr # bfsShell @@ -88,6 +89,9 @@ mkdir -p $tmpDir copyrightsFile=$tmpDir/copyrights $rmAttrs -f $copyrightsFile +if [ "$optionalPackageDescriptions" ]; then + cp "$optionalPackageDescriptions" $copyrightsFile +fi # create the image and mount it From bonefish at mail.berlios.de Sun May 4 18:08:31 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 4 May 2008 18:08:31 +0200 Subject: [Haiku-commits] r25314 - in haiku/trunk: build/jam src/apps/aboutsystem src/tests/system/benchmarks/libMicro Message-ID: <200805041608.m44G8VYq017101@sheep.berlios.de> Author: bonefish Date: 2008-05-04 18:08:30 +0200 (Sun, 04 May 2008) New Revision: 25314 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25314&view=rev Added: haiku/trunk/src/tests/system/benchmarks/libMicro/.OptionalPackageDescription Modified: haiku/trunk/build/jam/OptionalTestPackages haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Add libMicro copyright and license to the image when the respective optional package is installed. Modified: haiku/trunk/build/jam/OptionalTestPackages =================================================================== --- haiku/trunk/build/jam/OptionalTestPackages 2008-05-04 16:06:41 UTC (rev 25313) +++ haiku/trunk/build/jam/OptionalTestPackages 2008-05-04 16:08:30 UTC (rev 25314) @@ -32,6 +32,12 @@ write writev ; AddSymlinkToHaikuImage home benchmarks libmicro : bin-BePC : bin ; + + AddOptionalPackageDescriptionToHaikuImage + .OptionalPackageDescription + : $(HAIKU_TOP) src tests system benchmarks libMicro ; + AddLicenseToHaikuImage OPENSOLARIS.LICENSE : OpenSolaris + : $(HAIKU_TOP) src tests system benchmarks libMicro ; } Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-04 16:06:41 UTC (rev 25313) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-04 16:08:30 UTC (rev 25314) @@ -660,12 +660,6 @@ // "Copyright " B_UTF8_COPYRIGHT " 2008 Igor Pavlov. " // "All rights reserved."); -// libMicros copyrights -// AddCopyrightEntry("libMicro", -// "Copyright " B_UTF8_COPYRIGHT " 2007 Sun Microsystems, Inc. " -// "All rights reserved."); - // Open Solaris License - // libpng copyrights AddCopyrightEntry("libpng", "Copyright " B_UTF8_COPYRIGHT " 2004, 2006-2008 Glenn " Added: haiku/trunk/src/tests/system/benchmarks/libMicro/.OptionalPackageDescription =================================================================== --- haiku/trunk/src/tests/system/benchmarks/libMicro/.OptionalPackageDescription 2008-05-04 16:06:41 UTC (rev 25313) +++ haiku/trunk/src/tests/system/benchmarks/libMicro/.OptionalPackageDescription 2008-05-04 16:08:30 UTC (rev 25314) @@ -0,0 +1,3 @@ +Package: libMicro +Copyright: 2007 Sun Microsystems, Inc. All rights reserved. +License: OpenSolaris From bga at bug-br.org.br Sun May 4 18:16:29 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Sun, 04 May 2008 13:16:29 -0300 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080504175506.697.5@knochen-vm.1209904186.fake> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <481DCCDC.6060900@bug-br.org.br> <20080504170845.620.3@knochen-vm.1209904186.fake> <20080504172543.652.4@knochen-vm.1209904186.fake> <54808.189.26.192.175.1209915372.squirrel@www.bug-br.org.br> <20080504175506.697.5@knochen-vm.1209904186.fake> Message-ID: <481DE15D.6050505@bug-br.org.br> Ingo Weinhold escreveu: > I'd be very surprised, if dd managed to change the name of Haiku's root > user. I bet you did that yourself in your UserBuildConfig. :-) Don't make me come over there. :P :) -Bruno From anevilyak at gmail.com Sun May 4 19:28:55 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 4 May 2008 12:28:55 -0500 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <200805041319.m44DJvjG004057@sheep.berlios.de> References: <200805041319.m44DJvjG004057@sheep.berlios.de> Message-ID: Hi there, On Sun, May 4, 2008 at 8:19 AM, bonefish at BerliOS wrote: > Author: bonefish > Date: 2008-05-04 15:19:57 +0200 (Sun, 04 May 2008) > New Revision: 25311 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25311&view=rev > > Modified: > haiku/trunk/build/jam/OptionalPackages > Log: > Added OpenSSH optional package. The daemon has to be started manually > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. > > First of all, nice work! I have a question though: do you have to do anything special to generate the keys and such? All the utilities tell me "gethostname: no such file or directory". Regards, Rene From ingo_weinhold at gmx.de Sun May 4 19:44:50 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 04 May 2008 19:44:50 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: References: <200805041319.m44DJvjG004057@sheep.berlios.de> Message-ID: <20080504194450.788.6@knochen-vm.1209904186.fake> On 2008-05-04 at 19:28:55 [+0200], Rene Gollent wrote: > On Sun, May 4, 2008 at 8:19 AM, bonefish at BerliOS > wrote: > > Author: bonefish > > Date: 2008-05-04 15:19:57 +0200 (Sun, 04 May 2008) > > New Revision: 25311 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25311&view=rev > > > > Modified: > > haiku/trunk/build/jam/OptionalPackages > > Log: > > Added OpenSSH optional package. The daemon has to be started manually > > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. > > > > > First of all, nice work! I have a question though: do you have to do > anything special to generate the keys and such? All the utilities tell > me "gethostname: no such file or directory". You have to set a host name. E.g. by specifying HAIKU_IMAGE_HOST_NAME in your UserBuildConfig. Alternatively you can "echo" the name to /boot/common/settings/network/hostname (off the top of my head -- just in the same dir as "services" anyway). CU, Ingo From anevilyak at gmail.com Sun May 4 19:46:10 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 4 May 2008 12:46:10 -0500 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080504194450.788.6@knochen-vm.1209904186.fake> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> Message-ID: On Sun, May 4, 2008 at 12:44 PM, Ingo Weinhold wrote: > You have to set a host name. E.g. by specifying HAIKU_IMAGE_HOST_NAME in > your UserBuildConfig. Alternatively you can "echo" the name to > /boot/common/settings/network/hostname (off the top of my head -- just in > the same dir as "services" anyway). > Ahh...that's what I suspected but couldn't figure out which path it was looking for :) Thanks! Rene From anevilyak at gmail.com Sun May 4 19:51:09 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 4 May 2008 12:51:09 -0500 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> Message-ID: On Sun, May 4, 2008 at 12:46 PM, Rene Gollent wrote: > On Sun, May 4, 2008 at 12:44 PM, Ingo Weinhold wrote: > > You have to set a host name. E.g. by specifying HAIKU_IMAGE_HOST_NAME in > > your UserBuildConfig. Alternatively you can "echo" the name to > > /boot/common/settings/network/hostname (off the top of my head -- just in > > the same dir as "services" anyway). > > On a related note, is there also an optional build step for generating the host keys for sshd on first boot or must this currently be done manually every time? Regards, Rene From bga at bug-br.org.br Sun May 4 19:56:33 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Sun, 04 May 2008 14:56:33 -0300 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> Message-ID: <481DF8D1.8000103@bug-br.org.br> Rene Gollent escreveu: > On a related note, is there also an optional build step for generating > the host keys for sshd on first boot or must this currently be done > manually every time? The host keys are generated automatically in the first boot. -Bruno From anevilyak at gmail.com Sun May 4 20:00:15 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 4 May 2008 13:00:15 -0500 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <481DF8D1.8000103@bug-br.org.br> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> <481DF8D1.8000103@bug-br.org.br> Message-ID: On Sun, May 4, 2008 at 12:56 PM, Bruno Albuquerque wrote: > > On a related note, is there also an optional build step for generating > > the host keys for sshd on first boot or must this currently be done > > manually every time? > > The host keys are generated automatically in the first boot. > They weren't for me, sshd just complained about them not existing, I had to manually run ssh-keygen with the appropriate params. Or is that done if you've specified a hostname in UserBuildConfig like Ingo said? Regards, Rene From revol at free.fr Sun May 4 20:15:12 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 04 May 2008 20:15:12 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25309_-_in_haiku/trunk=3A_build?= =?windows-1252?q?/jam_data/etc_data/etc/post=5Finstall_data/settings_data?= =?windows-1252?q?/system/boot?= In-Reply-To: <200805041310.m44DAgW4003600@sheep.berlios.de> Message-ID: <570813536-BeMail@laptop> > Reactivated the "fresh install" code in the Bootscript, but modified > it > a bit: > * Added directory /etc/post_install, which can contain scripts that > will > be executed on the first boot. There used to be InstallerRebootScript and friends in /system/boot, why polute /etc more ? Fran?ois. From revol at free.fr Sun May 4 20:27:51 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 04 May 2008 20:27:51 +0200 CEST Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: Message-ID: <1329470532-BeMail@laptop> > > Added OpenSSH optional package. The daemon has to be started > > manually > > (just "sshd"), ATM. Not sure how we want to deal with daemons, > > yet. > > > > > First of all, nice work! I have a question though: do you have to do > anything special to generate the keys and such? All the utilities > tell > me "gethostname: no such file or directory". From Zeta's /system/boot/InstallerRebootScript.cd (copied to InstallerRebootScript by the Installer then moved back by itself): # assign ourselves a hostname as well as this ... ssh-keygen wants it # We get the hostname from the boot drive partition name if [ ! -e /etc/hostname ]; then /bin/ls -l / | grep -G "/boot$" | cut -d ' ' -f 14 > /etc/ hostname fi SSH_KEY_DIR="/boot/beos/etc" if [ ! -e "$SSH_KEY_DIR/ssh_host_key" -o ! -e "$SSH_KEY_DIR/ ssh_host_dsa_key" -o ! -e "$SSH_KEY_DIR/ssh_host_rsa_key" ]; then TEXT=$(translate_string "Creating OpenSSH keys...") notice --busy "$TEXT" /boot/beos/bin/ssh-keygen -t rsa1 -f "$SSH_KEY_DIR/ ssh_host_key" -N "" /boot/beos/bin/ssh-keygen -t dsa -f "$SSH_KEY_DIR/ ssh_host_dsa_key" -N "" /boot/beos/bin/ssh-keygen -t rsa -f "$SSH_KEY_DIR/ ssh_host_rsa_key" -N "" fi Fran?ois. From revol at free.fr Sun May 4 20:30:11 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 04 May 2008 20:30:11 +0200 CEST Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: Message-ID: <1469585673-BeMail@laptop> > On Sun, May 4, 2008 at 12:46 PM, Rene Gollent > wrote: > > On Sun, May 4, 2008 at 12:44 PM, Ingo Weinhold < > > ingo_weinhold at gmx.de> wrote: > > > You have to set a host name. E.g. by specifying > > > HAIKU_IMAGE_HOST_NAME in > > > your UserBuildConfig. Alternatively you can "echo" the name to > > > /boot/common/settings/network/hostname (off the top of my head > > > -- just in > > > the same dir as "services" anyway). > > > > > On a related note, is there also an optional build step for > generating > the host keys for sshd on first boot or must this currently be done > manually every time? > It could be done at build time, but if you make an install CD you'll end up installing the same keys everytime, not really the best :) That should go to InstallerRebootScript (or /etc/post_install but why add this ?) See previous post. (the hostname thing doesn't seem to work though). Fran?ois. From mmu_man at mail.berlios.de Sun May 4 22:14:21 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 4 May 2008 22:14:21 +0200 Subject: [Haiku-commits] r25315 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/sonix sensors Message-ID: <200805042014.m44KEKUK025863@sheep.berlios.de> Author: mmu_man Date: 2008-05-04 22:14:19 +0200 (Sun, 04 May 2008) New Revision: 25315 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25315&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamStreamingDeframer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp Log: - don't hardcode frame size, use the maximum available instead. Setting it at connection won't work yet. - Added hooks to handle device and sensor-specific parameters - Added gain controls for my webcam, oddly none seem to work correctly except green gain :^) Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -30,6 +30,7 @@ CamDevice::CamDevice(CamDeviceAddon &_addon, BUSBDevice* _device) : fInitStatus(B_NO_INIT), fSensor(NULL), + fLastParameterChanges(0), fCamDeviceAddon(_addon), fDevice(_device), fSupportedDeviceIndex(-1), @@ -204,6 +205,26 @@ } // ----------------------------------------------------------------------------- +void +CamDevice::AddParameters(BParameterGroup *group, int32 &index) +{ + fFirstParameterID = index; +} + +status_t +CamDevice::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size) +{ + return B_BAD_VALUE; +} + +status_t +CamDevice::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) +{ + return B_BAD_VALUE; +} + + +// ----------------------------------------------------------------------------- size_t CamDevice::MinRawFrameSize() { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-04 20:14:19 UTC (rev 25315) @@ -19,6 +19,7 @@ class BBitmap; class BBuffer; class BDataIO; +class BParameterGroup; class CamRoster; class CamDeviceAddon; class CamSensor; @@ -58,6 +59,11 @@ virtual status_t SetScale(float scale); virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue); + virtual void AddParameters(BParameterGroup *group, int32 &index); + virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); + virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size); + + // for use by deframer virtual size_t MinRawFrameSize(); virtual size_t MaxRawFrameSize(); @@ -108,8 +114,10 @@ CamDeframer* fDeframer; BDataIO* fDataInput; // where data from usb goes, likely fDeframer const BUSBEndpoint* fBulkIn; + int32 fFirstParameterID; + bigtime_t fLastParameterChanges; - private: + protected: friend class CamDeviceAddon; CamDeviceAddon& fCamDeviceAddon; BUSBDevice* fDevice; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -6,6 +6,7 @@ : fInitStatus(B_NO_INIT), fTransferEnabled(false), fVideoFrame(), + fLastParameterChanges(0), fCamDevice(_camera) { @@ -69,6 +70,25 @@ } // ----------------------------------------------------------------------------- +void +CamSensor::AddParameters(BParameterGroup *group, int32 &index) +{ + fFirstParameterID = index; +} + +status_t +CamSensor::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size) +{ + return B_BAD_VALUE; +} + +status_t +CamSensor::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) +{ + return B_BAD_VALUE; +} + +// ----------------------------------------------------------------------------- CamDevice * CamSensor::Device() { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-04 20:14:19 UTC (rev 25315) @@ -32,6 +32,10 @@ virtual status_t SetVideoFrame(BRect rect); virtual BRect VideoFrame() const { return fVideoFrame; }; virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue); + + virtual void AddParameters(BParameterGroup *group, int32 &index); + virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); + virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size); CamDevice *Device(); @@ -50,6 +54,8 @@ status_t fInitStatus; bool fTransferEnabled; BRect fVideoFrame; + int32 fFirstParameterID; + bigtime_t fLastParameterChanges; private: CamDevice *fCamDevice; }; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamStreamingDeframer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamStreamingDeframer.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamStreamingDeframer.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -34,7 +34,7 @@ int bufsize = size; bool detach = false; bool discard = false; - PRINT((CH "(%p, %d); state=%s framesz=%u queued=%u" CT, buffer, size, (fState==ST_SYNC)?"sync":"frame", (size_t)(fCurrentFrame?(fCurrentFrame->Position()):-1), (size_t)fInputBuff.Position())); + //PRINT((CH "(%p, %d); state=%s framesz=%u queued=%u" CT, buffer, size, (fState==ST_SYNC)?"sync":"frame", (size_t)(fCurrentFrame?(fCurrentFrame->Position()):-1), (size_t)fInputBuff.Position())); if (!fCurrentFrame) { BAutolock l(fLocker); if (fFrames.CountItems() < MAXFRAMEBUF) Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -18,6 +18,7 @@ #include #include "CamDevice.h" +#include "CamSensor.h" #define TOUCH(x) ((void)(x)) @@ -138,11 +139,24 @@ return; } + int32 id = P_COLOR; /* Set up the parameter web */ + + //TODO: remove and put sensible stuff there BParameterWeb *web = new BParameterWeb(); BParameterGroup *main = web->MakeGroup(Name()); BDiscreteParameter *state = main->MakeDiscreteParameter( P_COLOR, B_MEDIA_RAW_VIDEO, "Color", "Color"); + + id++; + if (fCamDevice) { + BParameterGroup *dev = web->MakeGroup("Device"); + fCamDevice->AddParameters(dev, id); + if (fCamDevice->Sensor()) { + BParameterGroup *sensor = web->MakeGroup("Sensor"); + fCamDevice->Sensor()->AddParameters(sensor, id); + } + } state->AddItem(B_HOST_TO_LENDIAN_INT32(0x00ff0000), "Red"); state->AddItem(B_HOST_TO_LENDIAN_INT32(0x0000ff00), "Green"); state->AddItem(B_HOST_TO_LENDIAN_INT32(0x000000ff), "Blue"); @@ -385,12 +399,20 @@ } //XXX:FIXME +#if 1 // if (format->u.raw_video.display.line_width == 0) format->u.raw_video.display.line_width = 352;//320; format->u.raw_video.display.line_width = 320; // if (format->u.raw_video.display.line_count == 0) format->u.raw_video.display.line_count = 288;//240; format->u.raw_video.display.line_count = 240; +#endif + + if (fCamDevice) { + format->u.raw_video.display.line_width = fCamDevice->VideoFrame().IntegerWidth() + 1; + format->u.raw_video.display.line_count = fCamDevice->VideoFrame().IntegerHeight() + 1; + } + if (format->u.raw_video.field_rate == 0) format->u.raw_video.field_rate = 29.97f; @@ -494,7 +516,7 @@ return; } -#if 0 +#if 1 /* Some dumb apps don't stop nodes before disconnecting... */ if (fRunning) HandleStop(); @@ -560,31 +582,58 @@ VideoProducer::GetParameterValue( int32 id, bigtime_t *last_change, void *value, size_t *size) { - if (id != P_COLOR) - return B_BAD_VALUE; + status_t err; - *last_change = fLastColorChange; - *size = sizeof(uint32); - *((uint32 *)value) = fColor; + if (id == P_COLOR) { + //return B_BAD_VALUE; - return B_OK; + *last_change = fLastColorChange; + *size = sizeof(uint32); + *((uint32 *)value) = fColor; + return B_OK; + } + + if (fCamDevice) { + BAutolock lock(fCamDevice->Locker()); + err = fCamDevice->GetParameterValue(id, last_change, value, size); + if (err >= B_OK) + return err; + if (fCamDevice->Sensor()) { + err = fCamDevice->Sensor()->GetParameterValue(id, last_change, value, size); + if (err >= B_OK) + return err; + } + } + + return B_BAD_VALUE; } void VideoProducer::SetParameterValue( int32 id, bigtime_t when, const void *value, size_t size) { - if ((id != P_COLOR) || !value || (size != sizeof(uint32))) - return; + status_t err = B_OK; - if (*(uint32 *)value == fColor) - return; + if (id == P_COLOR) { + if (!value || (size != sizeof(uint32))) + return; - fColor = *(uint32 *)value; - fLastColorChange = when; + if (*(uint32 *)value == fColor) + return; - BroadcastNewParameterValue( - fLastColorChange, P_COLOR, &fColor, sizeof(fColor)); + fColor = *(uint32 *)value; + fLastColorChange = when; + + } else if (fCamDevice) { + BAutolock lock(fCamDevice->Locker()); + err = fCamDevice->SetParameterValue(id, when, value, size); + if ((err < B_OK) && (fCamDevice->Sensor())) { + err = fCamDevice->Sensor()->SetParameterValue(id, when, value, size); + } + } + + if (err >= B_OK) + BroadcastNewParameterValue(when, id, (void *)value, size); } status_t Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h 2008-05-04 20:14:19 UTC (rev 25315) @@ -23,6 +23,7 @@ virtual status_t InitCheck() const { return fInitStatus; } + /* BMediaNode */ public: virtual port_id ControlPort() const; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -4,6 +4,7 @@ #include "CamBufferingDeframer.h" #include "CamStreamingDeframer.h" +#include #include #include @@ -36,6 +37,8 @@ status_t err; fFrameTagState = 0; + fRGain = fGGain = fBGain = 0; + memset(fCachedRegs, 0, SN9C102_REG_COUNT); fChipVersion = 2; if ((GetDevice()->ProductID() & ~0x3F) == 0x6080) { @@ -88,6 +91,7 @@ if (Sensor()) { PRINT((CH ": CamSensor: %s" CT, Sensor()->Name())); fInitStatus = Sensor()->Setup(); + fVideoFrame = BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1); // SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); // SetVideoFrame(BRect(0, 0, 320-1, 240-1)); } @@ -127,7 +131,7 @@ if (Sensor()) SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); - SetVideoFrame(BRect(0, 0, 320-1, 240-1)); + //SetVideoFrame(BRect(0, 0, 320-1, 240-1)); DumpRegs(); err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); @@ -364,6 +368,76 @@ return B_OK; } +void +SonixCamDevice::AddParameters(BParameterGroup *group, int32 &index) +{ + BContinuousParameter *p; + CamDevice::AddParameters(group, index); + + p = group->MakeContinuousParameter(index++, + B_MEDIA_RAW_VIDEO, "RGB gain", + B_GAIN, "", 1.0, 1.0+(float)(SN9C102_RGB_GAIN_MAX)/8, (float)1.0/8); + + p->SetChannelCount(3); + + +} + +status_t +SonixCamDevice::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size) +{ + float *gains; + switch (id - fFirstParameterID) { + case 0: + *size = 3 * sizeof(float); + gains = ((float *)value); + gains[0] = 1.0 + (float)fRGain / 8; + gains[1] = 1.0 + (float)fGGain / 8; + gains[2] = 1.0 + (float)fBGain / 8; + *last_change = fLastParameterChanges; + return B_OK; + } + return B_BAD_VALUE; +} + +status_t +SonixCamDevice::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) +{ + float *gains; + switch (id - fFirstParameterID) { + case 0: + if (!value || (size != 3 * sizeof(float))) + return B_BAD_VALUE; + gains = ((float *)value); + if ((gains[0] == 1.0 + (float)fRGain / 8) + && (gains[1] == 1.0 + (float)fGGain / 8) + && (gains[2] == 1.0 + (float)fBGain / 8)) + return B_OK; + + fRGain = (int)(8 * (gains[0] - 1.0)) & SN9C102_RGB_GAIN_MAX; + fGGain = (int)(8 * (gains[1] - 1.0)) & SN9C102_RGB_GAIN_MAX; + fBGain = (int)(8 * (gains[2] - 1.0)) & SN9C102_RGB_GAIN_MAX; + fLastParameterChanges = when; + PRINT((CH ": gain: %d,%d,%d" CT, fRGain, fGGain, fBGain)); + //WriteReg8(SN9C102_R_B_GAIN, (fBGain << 4) | fRGain); /* red, blue gain = 1+0/8 = 1 */ + /* Datasheet says: + * reg 0x10 [0:3] is rgain, [4:7] is bgain and 0x11 [0:3] is ggain + * according to sn9c102-1.15 linux driver it's wrong for reg 0x10, + * but it doesn't seem to work any better for a rev 2 chip. + * XXX + */ + WriteReg8(SN9C102_R_GAIN, fRGain); + WriteReg8(SN9C102_B_GAIN, fBGain); + if (fChipVersion >= 3) + WriteReg8(SN9C103_G_GAIN, fGGain); + else + WriteReg8(SN9C102_G_GAIN, (fGGain / 16)); + return B_OK; + } + return B_BAD_VALUE; +} + + // ----------------------------------------------------------------------------- size_t SonixCamDevice::MinRawFrameSize() Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-04 20:14:19 UTC (rev 25315) @@ -8,6 +8,9 @@ #define SN9C102_ASIC_ID 0x00 #define SN9C102_CHIP_CTRL 0x01 #define SN9C102_GPIO 0x02 +#define SN9C103_G_GAIN 0x04 /* chip version dependant! */ +#define SN9C102_R_GAIN 0x05 +#define SN9C102_B_GAIN 0x06 #define SN9C102_I2C_SETUP 0x08 #define SN9C102_I2C_SLAVE_ID 0x09 #define SN9C102_I2C_DATA0 0x0a @@ -16,7 +19,7 @@ #define SN9C102_I2C_DATA3 0x0d #define SN9C102_I2C_DATA4 0x0e #define SN9C102_CONTROL_STAT 0x0f /*I2C ??*/ -#define SN9C102_R_B_GAIN 0x10 +#define SN9C102_R_B_GAIN 0x10 /* datasheet says so but it's WRONG */ #define SN9C102_G_GAIN 0x11 /* Green channel gain control. -> Gain = (1+G_GAIN/8) Note: It is sync with VSYNC */ #define SN9C102_H_START 0x12 /* Start active pixel number after H?sync of sensor @@ -37,6 +40,8 @@ #define SN9C102_AE_ENDX 0x1e #define SN9C102_AE_ENDY 0x1f +#define SN9C102_RGB_GAIN_MAX 0x7f + // This class represents each webcam class SonixCamDevice : public CamDevice { @@ -62,6 +67,11 @@ virtual status_t SetScale(float scale); virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue); + virtual void AddParameters(BParameterGroup *group, int32 &index); + virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); + virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size); + + // for use by deframer virtual size_t MinRawFrameSize(); virtual size_t MaxRawFrameSize(); @@ -81,6 +91,10 @@ int fChipVersion; int fFrameTagState; + + uint8 fRGain; + uint8 fGGain; + uint8 fBGain; }; // the addon itself, that instanciate Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-04 16:08:30 UTC (rev 25314) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-04 20:14:19 UTC (rev 25315) @@ -1,10 +1,14 @@ /* */ +#include + #include "CamSensor.h" #include "CamDebug.h" #include "addons/sonix/SonixCamDevice.h" +#define ENABLE_GAIN 1 + class TAS5110C1BSensor : public CamSensor { public: TAS5110C1BSensor(CamDevice *_camera); @@ -18,8 +22,13 @@ virtual int MaxWidth() const { return 352; }; virtual int MaxHeight() const { return 288; }; virtual status_t SetVideoFrame(BRect rect); + virtual void AddParameters(BParameterGroup *group, int32 &firstID); + virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); + virtual status_t SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size); + private: bool fIsSonix; + float fGain; }; // ----------------------------------------------------------------------------- @@ -33,6 +42,7 @@ PRINT((CH ": unknown camera device!" CT)); fInitStatus = ENODEV; } + fGain = (float)0x40; // default } // ----------------------------------------------------------------------------- @@ -109,6 +119,53 @@ return B_OK; } +void +TAS5110C1BSensor::AddParameters(BParameterGroup *group, int32 &index) +{ + BContinuousParameter *p; + CamSensor::AddParameters(group, index); + +#ifdef ENABLE_GAIN + p = group->MakeContinuousParameter(index++, + B_MEDIA_RAW_VIDEO, "global gain", + B_GAIN, "", (float)0x00, (float)0xf6, (float)1); +#endif +} + + +status_t +TAS5110C1BSensor::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size) +{ +#ifdef ENABLE_GAIN + if (id == fFirstParameterID) { + *size = sizeof(float); + *((float *)value) = fGain; + *last_change = fLastParameterChanges; + } +#endif + return B_BAD_VALUE; +} + +status_t +TAS5110C1BSensor::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) +{ +#ifdef ENABLE_GAIN + if (id == fFirstParameterID) { + if (!value || (size != sizeof(float))) + return B_BAD_VALUE; + if (*(float *)value == fGain) + return B_OK; + fGain = *(float *)value; + fLastParameterChanges = when; + PRINT((CH ": gain: %f (%d)" CT, fGain, (unsigned)(0xf6-fGain))); + Device()->WriteIIC8(0x20, (uint8)0xf6 - (uint8)fGain); + return B_OK; + } +#endif + return B_BAD_VALUE; +} + + // ----------------------------------------------------------------------------- B_WEBCAM_DECLARE_SENSOR(TAS5110C1BSensor, tas5110c1b) From mmu_man at mail.berlios.de Sun May 4 22:35:32 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 4 May 2008 22:35:32 +0200 Subject: [Haiku-commits] r25316 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix Message-ID: <200805042035.m44KZW5x028509@sheep.berlios.de> Author: mmu_man Date: 2008-05-04 22:35:31 +0200 (Sun, 04 May 2008) New Revision: 25316 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25316&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp Log: Add IDs for Sonix cams according to linux driver. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-04 20:14:19 UTC (rev 25315) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-04 20:35:31 UTC (rev 25316) @@ -9,9 +9,49 @@ #include const usb_named_support_descriptor kSupportedDevices[] = { -{{ 0, 0, 0, 0x0c45, 0x6005 }, "Sonix", "Sonix"}, +{{ 0, 0, 0, 0x0c45, 0x6005 }, "Sonix", "Sonix"}, // mine {{ 0, 0, 0, 0x0c45, 0x6009 }, "Trust", "spacec at m 120" }, -{{ 0, 0, 0, 0x0c45, 0x600D }, "Trust", "spacec at m 120" }, +{{ 0, 0, 0, 0x0c45, 0x600d }, "Trust", "spacec at m 120" }, + +/* other devices that should be supported, + * cf. sn9c102-1.15 linux driver, sn9c102_sensor.h + * for IDs and sensors + */ +{{ 0, 0, 0, 0x0c45, 0x6001 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6024 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6025 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6028 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6029 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x602a }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x602b }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x602c }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6030 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6080 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6082 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6083 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x6088 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x608a }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x608b }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x608c }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x608e }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x608f }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60a0 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60a2 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60a3 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60a8 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60aa }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60ab }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60ac }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60ae }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60af }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60b0 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60b2 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60b3 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60b8 }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60ba }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60bb }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60bc }, "Sonix", "Sonix generic" }, +{{ 0, 0, 0, 0x0c45, 0x60be }, "Sonix", "Sonix generic" }, {{ 0, 0, 0, 0, 0}, NULL, NULL } }; @@ -50,6 +90,10 @@ case 0x60ab: fSensor = CreateSensor("tas5110c1b"); break; + case 0x6025: + fSensor = CreateSensor("tas5110c1b"); + //XXX:probe! + break; default: break; } From ingo_weinhold at gmx.de Mon May 5 00:23:30 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 05 May 2008 00:23:30 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> <481DF8D1.8000103@bug-br.org.br> Message-ID: <20080505002330.407.1@knochen-vm.1209937780.fake> On 2008-05-04 at 20:00:15 [+0200], Rene Gollent wrote: > On Sun, May 4, 2008 at 12:56 PM, Bruno Albuquerque > wrote: > > > On a related note, is there also an optional build step for generating > > > the host keys for sshd on first boot or must this currently be done > > > manually every time? > > > > The host keys are generated automatically in the first boot. > > They weren't for me, sshd just complained about them not existing, I > had to manually run ssh-keygen with the appropriate params. Or is that > done if you've specified a hostname in UserBuildConfig like Ingo said? They are generated at first boot, but apparently ssh-keygen needs a host name. You can run /etc/post_install/ssh.sh manually, if you hadn't had one set at that time. The whole situation is far from optimal yet. sshd (respectively a wrapper script) should simply generate the keys when first started, IMHO. We should also think about how we want to start daemons and the like. Bootscript is fine for the core services, but it doesn't seem flexible enough for the optional packages mechanism (or managing services later). CU, Ingo From ingo_weinhold at gmx.de Mon May 5 00:29:22 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 05 May 2008 00:29:22 +0200 Subject: [Haiku-commits] r25309 - in haiku/trunk: build/jam data/etc data/etc/post_install data/settings data/system/boot In-Reply-To: <570813536-BeMail@laptop> References: <570813536-BeMail@laptop> Message-ID: <20080505002922.456.2@knochen-vm.1209937780.fake> On 2008-05-04 at 20:15:12 [+0200], Fran?ois Revol wrote: > > Reactivated the "fresh install" code in the Bootscript, but modified > > it > > a bit: > > * Added directory /etc/post_install, which can contain scripts that > > will > > be executed on the first boot. > > There used to be InstallerRebootScript and friends in /system/boot, why > polute /etc more ? I'm fine with moving the post_install dir to /system/boot (or rather /boot/common/boot?). I don't think a single script will be flexible enough, though. CU, Ingo From kaoutsis at sch.gr Mon May 5 00:41:45 2008 From: kaoutsis at sch.gr (kaoutsis) Date: Mon, 05 May 2008 01:41:45 +0300 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080505002330.407.1@knochen-vm.1209937780.fake> References: <200805041319.m44DJvjG004057@sheep.berlios.de> <20080504194450.788.6@knochen-vm.1209904186.fake> <481DF8D1.8000103@bug-br.org.br> <20080505002330.407.1@knochen-vm.1209937780.fake> Message-ID: <481E3BA9.5070400@sch.gr> Hi Ingo, Ingo Weinhold wrote: > The whole situation is far from optimal yet. sshd (respectively a wrapper > script) should simply generate the keys when first started, IMHO. We should > also think about how we want to start daemons and the like. Bootscript is > fine for the core services, but it doesn't seem flexible enough for the > optional packages mechanism (or managing services later). > > > > You may want to have a look at http://www.initng.org/ good bye, Vasilis From bonefish at mail.berlios.de Mon May 5 02:24:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 5 May 2008 02:24:17 +0200 Subject: [Haiku-commits] r25317 - in haiku/trunk: headers/private/kernel/fs src/system/kernel/fs Message-ID: <200805050024.m450OHwi002920@sheep.berlios.de> Author: bonefish Date: 2008-05-05 02:24:14 +0200 (Mon, 05 May 2008) New Revision: 25317 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25317&view=rev Modified: haiku/trunk/headers/private/kernel/fs/fd.h haiku/trunk/src/system/kernel/fs/fd.cpp Log: Added get_open_fd() function which gets the descriptor and also increments its open count. Modified: haiku/trunk/headers/private/kernel/fs/fd.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/fd.h 2008-05-04 20:35:31 UTC (rev 25316) +++ haiku/trunk/headers/private/kernel/fs/fd.h 2008-05-05 00:24:14 UTC (rev 25317) @@ -79,6 +79,7 @@ extern int new_fd_etc(struct io_context *, struct file_descriptor *, int firstIndex); extern int new_fd(struct io_context *, struct file_descriptor *); extern struct file_descriptor *get_fd(struct io_context *, int); +extern struct file_descriptor *get_open_fd(struct io_context *, int); extern void close_fd(struct file_descriptor *descriptor); extern status_t close_fd_index(struct io_context *context, int fd); extern void put_fd(struct file_descriptor *descriptor); Modified: haiku/trunk/src/system/kernel/fs/fd.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fd.cpp 2008-05-04 20:35:31 UTC (rev 25316) +++ haiku/trunk/src/system/kernel/fs/fd.cpp 2008-05-05 00:24:14 UTC (rev 25317) @@ -303,6 +303,21 @@ } +struct file_descriptor * +get_open_fd(struct io_context *context, int fd) +{ + MutexLocker(context->io_mutex); + + file_descriptor *descriptor = get_fd_locked(context, fd); + if (descriptor == NULL) + return NULL; + + atomic_add(&descriptor->open_count, 1); + + return descriptor; +} + + /** Removes the file descriptor from the specified slot. */ From bonefish at mail.berlios.de Mon May 5 02:27:37 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 5 May 2008 02:27:37 +0200 Subject: [Haiku-commits] r25318 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805050027.m450RbjU003039@sheep.berlios.de> Author: bonefish Date: 2008-05-05 02:27:34 +0200 (Mon, 05 May 2008) New Revision: 25318 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25318&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp Log: When sending a file descriptor via SCM_RIGHTS we also need to acquire an open reference to it. Otherwise the descriptor could be closed while being on the way. This fixes the ssh login problem with non-root users. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-05 00:24:14 UTC (rev 25317) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/unix.cpp 2008-05-05 00:27:34 UTC (rev 25318) @@ -48,8 +48,10 @@ file_descriptor** descriptors = (file_descriptor**)data; for (int i = 0; i < count; i++) { - if (descriptors[i] != NULL) + if (descriptors[i] != NULL) { + close_fd(descriptors[i]); put_fd(descriptors[i]); + } } } @@ -308,7 +310,7 @@ status_t error = B_OK; for (int i = 0; i < count; i++) { - descriptors[i] = get_fd(ioContext, fds[i]); + descriptors[i] = get_open_fd(ioContext, fds[i]); if (descriptors[i] == NULL) { error = EBADF; break; @@ -332,8 +334,10 @@ // cleanup on error if (error != B_OK) { for (int i = 0; i < count; i++) { - if (descriptors[i] != NULL) + if (descriptors[i] != NULL) { + close_fd(descriptors[i]); put_fd(descriptors[i]); + } } } @@ -374,7 +378,9 @@ status_t error = B_OK; for (int i = 0; i < count; i++) { - // get an additional reference which will go to the FD table index + // Get an additional reference which will go to the FD table index. The + // reference and open reference acquired in unix_add_ancillary_data() + // will be released when the container is destroyed. inc_fd_ref_count(descriptors[i]); fds[i] = new_fd(ioContext, descriptors[i]); From mmu_man at mail.berlios.de Mon May 5 02:32:03 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 5 May 2008 02:32:03 +0200 Subject: [Haiku-commits] r25319 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/quickcam addons/sonix Message-ID: <200805050032.m450W395003313@sheep.berlios.de> Author: mmu_man Date: 2008-05-05 02:32:02 +0200 (Mon, 05 May 2008) New Revision: 25319 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25319&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h Log: - some code to support isochronous, not yet functional. - some code for quickcam, not yet functional. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 00:32:02 UTC (rev 25319) @@ -413,9 +413,49 @@ //snooze(2000); } } - if (SupportsIsochronous()) { - ;//XXX: TODO +#ifdef SUPPORT_ISO + else if (SupportsIsochronous()) { + int numPacketDescriptors = 20; + usb_iso_packet_descriptor packetDescriptors[numPacketDescriptors]; + while (fTransferEnabled) { + ssize_t len = -1; + BAutolock lock(fLocker); + if (!lock.IsLocked()) + break; + if (!fIsoIn) + break; +#ifndef DEBUG_DISCARD_INPUT + len = fIsoIn->IsochronousTransfer(fBuffer, fBufferLen, packetDescriptors, numPacketDescriptors); +#endif + + //PRINT((CH ": got %d bytes" CT, len)); +#ifdef DEBUG_WRITE_DUMP + write(fDumpFD, fBuffer, len); +#endif +#ifdef DEBUG_READ_DUMP + if ((len = read(fDumpFD, fBuffer, fBufferLen)) < fBufferLen) + lseek(fDumpFD, 0LL, SEEK_SET); +#endif + + if (len <= 0) { + PRINT((CH ": BulkIn: %s" CT, strerror(len))); + break; + } + +#ifndef DEBUG_DISCARD_DATA + if (fDataInput) { + fDataInput->Write(fBuffer, len); + // else drop + } +#endif + //snooze(2000); + } } +#endif + else { + PRINT((CH ": No supported transport." CT)); + return B_UNSUPPORTED; + } return B_OK; } @@ -434,6 +474,22 @@ } // ----------------------------------------------------------------------------- +status_t +CamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data) +{ + size_t ret; + if (!GetDevice()) + return ENODEV; + if (length > GetDevice()->MaxEndpoint0PacketSize()) + return EINVAL; + ret = GetDevice()->ControlTransfer( + USB_REQTYPE_VENDOR | USB_REQTYPE_INTERFACE_OUT | dir, + request, value, index, length, data); + return ret; +} + +// ----------------------------------------------------------------------------- CamDeviceAddon::CamDeviceAddon(WebCamMediaAddOn* webcam) : fWebCamAddOn(webcam), fSupportedDevices(NULL) Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 00:32:02 UTC (rev 25319) @@ -5,8 +5,10 @@ #include #include #ifdef __HAIKU__ +//#if 1 # include # include +# define SUPPORT_ISO #else # include # include @@ -104,6 +106,8 @@ virtual void DumpRegs(); protected: + virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data); CamSensor *CreateSensor(const char *name); status_t fInitStatus; flavor_info fFlavorInfo; @@ -114,6 +118,7 @@ CamDeframer* fDeframer; BDataIO* fDataInput; // where data from usb goes, likely fDeframer const BUSBEndpoint* fBulkIn; + const BUSBEndpoint* fIsoIn; int32 fFirstParameterID; bigtime_t fLastParameterChanges; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-05 00:32:02 UTC (rev 25319) @@ -6,7 +6,10 @@ if $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { usbKitLibraryName = libdevice.so ; } else { - usbKitLibraryName = usb ; +# usbKitLibraryName = usb ; + usbKitLibraryName = USBKit.a ; + UsePublicHeaders [ FDirName drivers ] ; + UsePublicHeaders [ FDirName device ] ; } # source directories Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp 2008-05-05 00:32:02 UTC (rev 25319) @@ -1,5 +1,10 @@ #include "QuickCamDevice.h" +#include "CamDebug.h" +#include "CamSensor.h" +// see http://www.lrr.in.tum.de/~acher/quickcam/quickcam.html + + const usb_named_support_descriptor kSupportedDevices[] = { {{ 0, 0, 0, 0x046d, 0x0840 }, "Logitech", "QuickCam Express"}, {{ 0, 0, 0, 0x046d, 0x0850 }, "Logitech", "QuickCam Express LEGO"}, @@ -22,6 +27,152 @@ } // ----------------------------------------------------------------------------- +bool +QuickCamDevice::SupportsBulk() +{ + return true; +} + +// ----------------------------------------------------------------------------- +bool +QuickCamDevice::SupportsIsochronous() +{ + return true; +} + +// ----------------------------------------------------------------------------- +status_t +QuickCamDevice::StartTransfer() +{ + status_t err; + uint8 r; + + SetScale(1); + if (Sensor()) + SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); + + //SetVideoFrame(BRect(0, 0, 320-1, 240-1)); + +DumpRegs(); +#if 0 + err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); + if (err < 0) + return err; + r |= 0x04; + err = WriteReg8(SN9C102_CHIP_CTRL, r); + if (err < 0) + return err; +#endif + return CamDevice::StartTransfer(); +} + +// ----------------------------------------------------------------------------- +status_t +QuickCamDevice::StopTransfer() +{ + status_t err; + uint8 r; + +DumpRegs(); + err = CamDevice::StopTransfer(); +#if 0 +// if (err < 0) +// return err; + err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); + if (err < 0) + return err; + r &= ~0x04; + err = WriteReg8(SN9C102_CHIP_CTRL, r); + if (err < 0) + return err; +#endif + return err; +} + +// ----------------------------------------------------------------------------- +ssize_t +QuickCamDevice::WriteReg(uint16 address, uint8 *data, size_t count) +{ + PRINT((CH "(%u, @%p, %u)" CT, address, data, count)); + return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, address, 0, count, data); +} + +// ----------------------------------------------------------------------------- +ssize_t +QuickCamDevice::ReadReg(uint16 address, uint8 *data, size_t count, bool cached) +{ + PRINT((CH "(%u, @%p, %u, %d)" CT, address, data, count, cached)); + return SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, address, 0, count, data); +} + +// ----------------------------------------------------------------------------- +status_t +QuickCamDevice::GetStatusIIC() +{ + status_t err; + uint8 status = 0; +#warning WRITEME + //dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status); + if (err < 0) + return err; + return (status&0x08)?EIO:0; +} + +// ----------------------------------------------------------------------------- +status_t +QuickCamDevice::WaitReadyIIC() +{ + status_t err; +#warning WRITEME + return EBUSY; +} + +// ----------------------------------------------------------------------------- +ssize_t +QuickCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count) +{ + status_t err; + int i; + uint8 buffer[0x23]; + if (count > 16) + return EINVAL; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICWriteAddress() : 0; + buffer[0x21] = count - 1; + buffer[0x22] = 0x01; + for (i = 0; i < count; i++) { + buffer[i] = address + i; + buffer[i+16] = data[i]; + } + return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, data); +} + +// ----------------------------------------------------------------------------- +ssize_t +QuickCamDevice::ReadIIC(uint8 address, uint8 *data) +{ +#warning WRITEME + return 1; +} + + +// ----------------------------------------------------------------------------- +status_t +QuickCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data) +{ + size_t ret; + if (!GetDevice()) + return ENODEV; + if (length > GetDevice()->MaxEndpoint0PacketSize()) + return EINVAL; + ret = GetDevice()->ControlTransfer( + USB_REQTYPE_VENDOR | dir, + request, value, index, length, data); + return ret; +} + +// ----------------------------------------------------------------------------- QuickCamDeviceAddon::QuickCamDeviceAddon(WebCamMediaAddOn* webcam) : CamDeviceAddon(webcam) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h 2008-05-05 00:32:02 UTC (rev 25319) @@ -3,14 +3,48 @@ #include "CamDevice.h" +#define STV_REG_COUNT 0x0c +// Control registers of the STV0600 ASIC +#define STV_I2C_WRITE 0x400 +#define STV_I2C_WRITE1 0x400 +#define STV_I2C_READ 0x1410 +#define STV_ISO_ENABLE 0x1440 +#define STV_SCAN_RATE 0x1443 +#define STV_ISO_SIZE 0x15c1 +#define STV_Y_CTRL 0x15c3 +#define STV_X_CTRL 0x1680 +#define STV_REG00 0x1500 +#define STV_REG01 0x1501 +#define STV_REG02 0x1502 +#define STV_REG03 0x1503 +#define STV_REG04 0x1504 +#define STV_REG23 0x0423 + + // This class represents each webcam class QuickCamDevice : public CamDevice { public: QuickCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device); ~QuickCamDevice(); - + virtual bool SupportsBulk(); + virtual bool SupportsIsochronous(); + virtual status_t StartTransfer(); + virtual status_t StopTransfer(); + + // generic register-like access + virtual ssize_t WriteReg(uint16 address, uint8 *data, size_t count=1); + virtual ssize_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false); + + // I2C-like access + virtual status_t GetStatusIIC(); + virtual status_t WaitReadyIIC(); + virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count=1); + virtual ssize_t ReadIIC(uint8 address, uint8 *data); + private: + virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data); }; // the addon itself, that instanciate Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-05 00:32:02 UTC (rev 25319) @@ -470,12 +470,20 @@ * but it doesn't seem to work any better for a rev 2 chip. * XXX */ +#if 1 WriteReg8(SN9C102_R_GAIN, fRGain); WriteReg8(SN9C102_B_GAIN, fBGain); if (fChipVersion >= 3) WriteReg8(SN9C103_G_GAIN, fGGain); else WriteReg8(SN9C102_G_GAIN, (fGGain / 16)); +#endif +#if 0 + uint8 buf[2]; + buf[0] = (fBGain << 4) | fRGain; + buf[1] = fGGain; + WriteReg(SN9C102_R_B_GAIN, buf, 2); +#endif return B_OK; } return B_BAD_VALUE; @@ -616,21 +624,23 @@ regs[24], regs[25], regs[26], regs[27], regs[28], regs[29], regs[30], regs[31]); } +#if 0 // ----------------------------------------------------------------------------- status_t SonixCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, uint16 index, uint16 length, void* data) { size_t ret; - if (length > 64) - return EINVAL; if (!GetDevice()) return ENODEV; + if (length > GetDevice()->MaxEndpoint0PacketSize()) + return EINVAL; ret = GetDevice()->ControlTransfer( USB_REQTYPE_VENDOR | USB_REQTYPE_INTERFACE_OUT | dir, request, value, index, length, data); return ret; } +#endif // ----------------------------------------------------------------------------- SonixCamDeviceAddon::SonixCamDeviceAddon(WebCamMediaAddOn* webcam) Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-05 00:27:34 UTC (rev 25318) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-05 00:32:02 UTC (rev 25319) @@ -85,8 +85,8 @@ void DumpRegs(); private: - status_t SendCommand(uint8 dir, uint8 request, uint16 value, - uint16 index, uint16 length, void* data); +// status_t SendCommand(uint8 dir, uint8 request, uint16 value, +// uint16 index, uint16 length, void* data); uint8 fCachedRegs[SN9C102_REG_COUNT]; int fChipVersion; From emitrax at gmail.com Mon May 5 11:12:11 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Mon, 5 May 2008 09:12:11 +0000 Subject: [Haiku-commits] r25319 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/quickcam addons/sonix In-Reply-To: <200805050032.m450W395003313@sheep.berlios.de> References: <200805050032.m450W395003313@sheep.berlios.de> Message-ID: 2008/5/5 mmu_man at BerliOS : > Author: mmu_man > Date: 2008-05-05 02:32:02 +0200 (Mon, 05 May 2008) > New Revision: 25319 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25319&view=rev > > Modified: > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp > haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h > Log: > - some code to support isochronous, not yet functional. > - some code for quickcam, not yet functional. I actually have some code about the quickcam that I used to test the isochronous support last year. Did I email it to you yet? Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From mmu_man at mail.berlios.de Mon May 5 17:38:04 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 5 May 2008 17:38:04 +0200 Subject: [Haiku-commits] r25320 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/quickcam addons/sonix Message-ID: <200805051538.m45Fc4E9029461@sheep.berlios.de> Author: mmu_man Date: 2008-05-05 17:38:02 +0200 (Mon, 05 May 2008) New Revision: 25320 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25320&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferedFilterInterface.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferingDeframer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamColorSpaceTransform.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDeframer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamFilterInterface.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamRoster.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamStreamingDeframer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp Log: - style cleanup (remove // -----, 2 lines between funcs) - hooks to handle probing sensor chips instead of hardcoding them. - more urls for reference drivers (the macam driver would be interesting but it's GPL and ObjC :-( )... Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/AddOn.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -11,6 +11,7 @@ #include "CamDebug.h" #include "CamDevice.h" + WebCamMediaAddOn::WebCamMediaAddOn(image_id imid) : BMediaAddOn(imid), fInitStatus(B_NO_INIT), @@ -34,6 +35,7 @@ fInitStatus = B_OK; } + WebCamMediaAddOn::~WebCamMediaAddOn() { delete fRoster; @@ -51,6 +53,7 @@ return B_OK; } + int32 WebCamMediaAddOn::CountFlavors() { @@ -67,6 +70,7 @@ return count;//(count > 0)?count:1;//1; } + /* * The pointer to the flavor received only needs to be valid between * successive calls to BMediaAddOn::GetFlavorAt(). @@ -97,6 +101,7 @@ return B_OK; } + BMediaNode * WebCamMediaAddOn::InstantiateNodeFor( const flavor_info *info, BMessage* /*_config*/, status_t* /*_out_error*/) @@ -142,6 +147,7 @@ return node; } + status_t WebCamMediaAddOn::CameraAdded(CamDevice* device) { @@ -150,6 +156,7 @@ return B_OK; } + status_t WebCamMediaAddOn::CameraRemoved(CamDevice* device) { @@ -158,6 +165,7 @@ return B_OK; } + void WebCamMediaAddOn::FillDefaultFlavorInfo(flavor_info* info) { @@ -175,6 +183,7 @@ info->out_formats = &fMediaFormat; } + BMediaAddOn * make_media_addon(image_id imid) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferedFilterInterface.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferedFilterInterface.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferedFilterInterface.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -2,28 +2,33 @@ #include "CamDevice.h" #include "CamDebug.h" + CamBufferedFilterInterface::CamBufferedFilterInterface(CamDevice *device, bool allowWrite) : CamFilterInterface(device), fAllowWrite(allowWrite) { } + CamBufferedFilterInterface::~CamBufferedFilterInterface() { } + ssize_t CamBufferedFilterInterface::Read(void *buffer, size_t size) { return fInternalBuffer.Read(buffer, size); } + ssize_t CamBufferedFilterInterface::ReadAt(off_t pos, void *buffer, size_t size) { return fInternalBuffer.ReadAt(pos, buffer, size); } + ssize_t CamBufferedFilterInterface::Write(const void *buffer, size_t size) { @@ -32,6 +37,7 @@ return fInternalBuffer.Write(buffer, size); } + ssize_t CamBufferedFilterInterface::WriteAt(off_t pos, const void *buffer, size_t size) { @@ -40,18 +46,21 @@ return fInternalBuffer.WriteAt(pos, buffer, size); } + off_t CamBufferedFilterInterface::Seek(off_t position, uint32 seek_mode) { return fInternalBuffer.Seek(position, seek_mode); } + off_t CamBufferedFilterInterface::Position() const { return fInternalBuffer.Position(); } + status_t CamBufferedFilterInterface::SetSize(off_t size) { @@ -60,6 +69,7 @@ return fInternalBuffer.SetSize(size); } + size_t CamBufferedFilterInterface::FrameSize() { @@ -67,6 +77,7 @@ return 0; } + status_t CamBufferedFilterInterface::DropFrame() { @@ -76,6 +87,7 @@ return B_OK; } + status_t CamBufferedFilterInterface::SetVideoFrame(BRect frame) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferingDeframer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferingDeframer.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamBufferingDeframer.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -15,16 +15,19 @@ #define IB fInputBuffs[fInputBuffIndex] + CamBufferingDeframer::CamBufferingDeframer(CamDevice *device) : CamDeframer(device), fInputBuffIndex(0) { } + CamBufferingDeframer::~CamBufferingDeframer() { } + ssize_t CamBufferingDeframer::Write(const void *buffer, size_t size) { @@ -100,6 +103,7 @@ return size; } + size_t CamBufferingDeframer::DiscardFromInput(size_t size) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamColorSpaceTransform.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamColorSpaceTransform.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamColorSpaceTransform.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -17,7 +17,7 @@ }; #undef B_WEBCAM_DECLARE_CSTRANSFORM -// ----------------------------------------------------------------------------- + CamColorSpaceTransform::CamColorSpaceTransform() : fInitStatus(B_NO_INIT), fVideoFrame() @@ -25,41 +25,41 @@ } -// ----------------------------------------------------------------------------- + CamColorSpaceTransform::~CamColorSpaceTransform() { } -// ----------------------------------------------------------------------------- + status_t CamColorSpaceTransform::InitCheck() { return fInitStatus; } -// ----------------------------------------------------------------------------- + const char * CamColorSpaceTransform::Name() { return ""; } -// ----------------------------------------------------------------------------- + color_space CamColorSpaceTransform::OutputSpace() { return B_RGB32; } -// ----------------------------------------------------------------------------- + status_t CamColorSpaceTransform::SetVideoFrame(BRect rect) { return ENOSYS; } -// ----------------------------------------------------------------------------- + CamColorSpaceTransform * CamColorSpaceTransform::Create(const char *name) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDeframer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDeframer.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDeframer.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -6,6 +6,7 @@ #define MAX_TAG_LEN CAMDEFRAMER_MAX_TAG_LEN #define MAXFRAMEBUF CAMDEFRAMER_MAX_QUEUED_FRAMES + CamDeframer::CamDeframer(CamDevice *device) : CamFilterInterface(device), fDevice(device), @@ -21,6 +22,7 @@ fCurrentFrame = AllocFrame(); } + CamDeframer::~CamDeframer() { delete_sem(fFrameSem); @@ -28,6 +30,7 @@ delete fCurrentFrame; } + ssize_t CamDeframer::Read(void *buffer, size_t size) { @@ -38,6 +41,7 @@ return f->Read(buffer, size); } + ssize_t CamDeframer::ReadAt(off_t pos, void *buffer, size_t size) { @@ -48,6 +52,7 @@ return f->ReadAt(pos, buffer, size); } + off_t CamDeframer::Seek(off_t position, uint32 seek_mode) { @@ -58,6 +63,7 @@ return f->Seek(position, seek_mode); } + off_t CamDeframer::Position() const { @@ -68,6 +74,7 @@ return f->Position(); } + status_t CamDeframer::SetSize(off_t size) { @@ -75,6 +82,7 @@ return EINVAL; } + ssize_t CamDeframer::Write(const void *buffer, size_t size) { @@ -83,6 +91,7 @@ return EINVAL; } + ssize_t CamDeframer::WriteAt(off_t pos, const void *buffer, size_t size) { @@ -92,12 +101,14 @@ return EINVAL; } + status_t CamDeframer::WaitFrame(bigtime_t timeout) { return acquire_sem_etc(fFrameSem, 1, B_RELATIVE_TIMEOUT, timeout); } + status_t CamDeframer::GetFrame(CamFrame **frame, bigtime_t *stamp) { @@ -111,6 +122,7 @@ return B_OK; } + status_t CamDeframer::DropFrame() { @@ -123,6 +135,7 @@ return B_OK; } + status_t CamDeframer::RegisterSOFTags(const uint8 **tags, int count, size_t len, size_t skip) { @@ -139,6 +152,7 @@ return B_OK; } + status_t CamDeframer::RegisterEOFTags(const uint8 **tags, int count, size_t len, size_t skip) { @@ -155,6 +169,7 @@ return B_OK; } + int CamDeframer::FindTags(const uint8 *buf, size_t buflen, const uint8 **tags, int tagcount, size_t taglen, size_t skiplen, int *which) { @@ -171,22 +186,24 @@ return -1; } + int CamDeframer::FindSOF(const uint8 *buf, size_t buflen, int *which) { return FindTags(buf, buflen, fSOFTags, fNumSOFTags, fLenSOFTags, fSkipSOFTags, which); } + int CamDeframer::FindEOF(const uint8 *buf, size_t buflen, int *which) { return FindTags(buf, buflen, fEOFTags, fNumEOFTags, fLenEOFTags, fSkipEOFTags, which); } + CamFrame * CamDeframer::AllocFrame() { return new CamFrame(); } - Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -26,7 +26,7 @@ }; #undef B_WEBCAM_DECLARE_SENSOR -// ----------------------------------------------------------------------------- + CamDevice::CamDevice(CamDeviceAddon &_addon, BUSBDevice* _device) : fInitStatus(B_NO_INIT), fSensor(NULL), @@ -34,6 +34,7 @@ fCamDeviceAddon(_addon), fDevice(_device), fSupportedDeviceIndex(-1), + fChipIsBigEndian(false), fTransferEnabled(false), fLocker("WebcamDeviceLock") { @@ -62,7 +63,7 @@ fBuffer = (uint8 *)malloc(fBufferLen); } -// ----------------------------------------------------------------------------- + CamDevice::~CamDevice() { close(fDumpFD); @@ -71,28 +72,28 @@ delete fDeframer; } -// ----------------------------------------------------------------------------- + status_t CamDevice::InitCheck() { return fInitStatus; } -// ----------------------------------------------------------------------------- + bool CamDevice::Matches(BUSBDevice* _device) { return (_device) == (fDevice); } -// ----------------------------------------------------------------------------- + BUSBDevice* CamDevice::GetDevice() { return fDevice; } -// ----------------------------------------------------------------------------- + void CamDevice::Unplugged() { @@ -100,14 +101,14 @@ fBulkIn = NULL; } -// ----------------------------------------------------------------------------- + bool CamDevice::IsPlugged() { return (fDevice != NULL); } -// ----------------------------------------------------------------------------- + const char * CamDevice::BrandName() { @@ -116,7 +117,7 @@ return ""; } -// ----------------------------------------------------------------------------- + const char * CamDevice::ModelName() { @@ -125,21 +126,21 @@ return ""; } -// ----------------------------------------------------------------------------- + bool CamDevice::SupportsBulk() { return false; } -// ----------------------------------------------------------------------------- + bool CamDevice::SupportsIsochronous() { return false; } -// ----------------------------------------------------------------------------- + status_t CamDevice::StartTransfer() { @@ -160,7 +161,7 @@ return B_OK; } -// ----------------------------------------------------------------------------- + status_t CamDevice::StopTransfer() { @@ -182,7 +183,7 @@ return B_OK; } -// ----------------------------------------------------------------------------- + status_t CamDevice::SetVideoFrame(BRect frame) { @@ -190,21 +191,21 @@ return B_OK; } -// ----------------------------------------------------------------------------- + status_t CamDevice::SetScale(float scale) { return B_OK; } -// ----------------------------------------------------------------------------- + status_t CamDevice::SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue) { return B_OK; } -// ----------------------------------------------------------------------------- + void CamDevice::AddParameters(BParameterGroup *group, int32 &index) { @@ -224,35 +225,35 @@ } -// ----------------------------------------------------------------------------- + size_t CamDevice::MinRawFrameSize() { return 0; } -// ----------------------------------------------------------------------------- + size_t CamDevice::MaxRawFrameSize() { return 0; } -// ----------------------------------------------------------------------------- + bool CamDevice::ValidateStartOfFrameTag(const uint8 *tag, size_t taglen) { return true; } -// ----------------------------------------------------------------------------- + bool CamDevice::ValidateEndOfFrameTag(const uint8 *tag, size_t taglen, size_t datalen) { return true; } -// ----------------------------------------------------------------------------- + status_t CamDevice::WaitFrame(bigtime_t timeout) { @@ -261,64 +262,60 @@ return EINVAL; } -// ----------------------------------------------------------------------------- + status_t CamDevice::GetFrameBitmap(BBitmap **bm, bigtime_t *stamp) { return EINVAL; } -// ----------------------------------------------------------------------------- + status_t CamDevice::FillFrameBuffer(BBuffer *buffer, bigtime_t *stamp) { return EINVAL; } -// ----------------------------------------------------------------------------- + bool CamDevice::Lock() { return fLocker.Lock(); } -// ----------------------------------------------------------------------------- -void -CamDevice::Unlock() -{ - fLocker.Unlock(); -} -// ----------------------------------------------------------------------------- ssize_t CamDevice::WriteReg(uint16 address, uint8 *data, size_t count) { return ENOSYS; } -// ----------------------------------------------------------------------------- + ssize_t CamDevice::WriteReg8(uint16 address, uint8 data) { return WriteReg(address, &data, sizeof(uint8)); } -// ----------------------------------------------------------------------------- + ssize_t CamDevice::WriteReg16(uint16 address, uint16 data) { - // XXX: ENDIAN??? + if (fChipIsBigEndian) + data = B_HOST_TO_BENDIAN_INT16(data); + else + data = B_HOST_TO_LENDIAN_INT16(data); return WriteReg(address, (uint8 *)&data, sizeof(uint16)); } -// ----------------------------------------------------------------------------- + ssize_t CamDevice::ReadReg(uint16 address, uint8 *data, size_t count, bool cached) { return ENOSYS; } -// ----------------------------------------------------------------------------- + /* status_t CamDevice::GetStatusIIC() @@ -326,35 +323,98 @@ return ENOSYS; } */ -// ----------------------------------------------------------------------------- + /*status_t CamDevice::WaitReadyIIC() { return ENOSYS; } */ -// ----------------------------------------------------------------------------- + ssize_t CamDevice::WriteIIC(uint8 address, uint8 *data, size_t count) { return ENOSYS; } -// ----------------------------------------------------------------------------- + ssize_t CamDevice::WriteIIC8(uint8 address, uint8 data) { return WriteIIC(address, &data, 1); } -// ----------------------------------------------------------------------------- ssize_t +CamDevice::WriteIIC16(uint8 address, uint16 data) +{ + if (Sensor() && Sensor()->IsBigEndian()) + data = B_HOST_TO_BENDIAN_INT16(data); + else + data = B_HOST_TO_LENDIAN_INT16(data); + return WriteIIC(address, (uint8 *)&data, 2); +} + + + + +ssize_t CamDevice::ReadIIC(uint8 address, uint8 *data) { return ENOSYS; } -// ----------------------------------------------------------------------------- + +status_t +CamDevice::ProbeSensor() +{ + const usb_webcam_support_descriptor *devs; + const usb_webcam_support_descriptor *dev = NULL; + status_t err; + int32 i; + + PRINT((CH ": probing sensors..." CT)); + if (fCamDeviceAddon.SupportedDevices() == NULL) + return B_ERROR; + devs = fCamDeviceAddon.SupportedDevices(); + for (i = 0; devs[i].vendor; i++) + { + if (GetDevice()->VendorID() != devs[i].desc.vendor) + continue; + if (GetDevice()->ProductID() != devs[i].desc.product) + continue; + dev = &devs[i]; + break; + } + if (!dev) + return ENODEV; + if (!dev->sensors) // no usable sensor + return ENOENT; + BString sensors(dev->sensors); + for (i = 0; i > -1 && i < sensors.Length(); ) { + BString name; + sensors.CopyInto(name, i, sensors.FindFirst(',', i) - i); + PRINT((CH ": probing sensor '%s'..." CT, name.String())); + + fSensor = CreateSensor(name.String()); + if (fSensor) { + err = fSensor->Probe(); + if (err >= B_OK) + return B_OK; + + PRINT((CH ": sensor '%s' Probe: %s" CT, name.String(), strerror(err))); + + delete fSensor; + fSensor = NULL; + } + + i = sensors.FindFirst(',', i+1); + if (i > - 1) + i++; + } + return ENOENT; +} + + CamSensor * CamDevice::CreateSensor(const char *name) { @@ -363,17 +423,18 @@ if (!strcmp(kSensorTable[i].name, name)) return kSensorTable[i].instfunc(this); } + PRINT((CH ": sensor '%s' not found" CT, name)); return NULL; } -// ----------------------------------------------------------------------------- + void CamDevice::SetDataInput(BDataIO *input) { fDataInput = input; } -// ----------------------------------------------------------------------------- + status_t CamDevice::DataPumpThread() { @@ -459,7 +520,7 @@ return B_OK; } -// ----------------------------------------------------------------------------- + int32 CamDevice::_DataPumpThread(void *_this) { @@ -467,13 +528,13 @@ return dev->DataPumpThread(); } -// ----------------------------------------------------------------------------- + void CamDevice::DumpRegs() { } -// ----------------------------------------------------------------------------- + status_t CamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, uint16 index, uint16 length, void* data) @@ -489,26 +550,26 @@ return ret; } -// ----------------------------------------------------------------------------- + CamDeviceAddon::CamDeviceAddon(WebCamMediaAddOn* webcam) : fWebCamAddOn(webcam), fSupportedDevices(NULL) { } -// ----------------------------------------------------------------------------- + CamDeviceAddon::~CamDeviceAddon() { } -// ----------------------------------------------------------------------------- + const char * CamDeviceAddon::BrandName() { return ""; } -// ----------------------------------------------------------------------------- + status_t CamDeviceAddon::Sniff(BUSBDevice *device) { @@ -537,16 +598,16 @@ return ENODEV; } -// ----------------------------------------------------------------------------- + CamDevice * CamDeviceAddon::Instantiate(CamRoster &roster, BUSBDevice *from) { return NULL; } -// ----------------------------------------------------------------------------- + void -CamDeviceAddon::SetSupportedDevices(const usb_named_support_descriptor *devs) +CamDeviceAddon::SetSupportedDevices(const usb_webcam_support_descriptor *devs) { fSupportedDevices = devs; } Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 15:38:02 UTC (rev 25320) @@ -33,7 +33,8 @@ usb_support_descriptor desc; const char *vendor; const char *product; -} usb_named_support_descriptor; + const char *sensors; // possible sensors this cam uses (comma separated) +} usb_webcam_support_descriptor; // This class represents each webcam class CamDevice { @@ -96,6 +97,7 @@ //virtual status_t WaitReadyIIC(); virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count); virtual ssize_t WriteIIC8(uint8 address, uint8 data); + virtual ssize_t WriteIIC16(uint8 address, uint16 data); virtual ssize_t ReadIIC(uint8 address, uint8 *data); @@ -108,6 +110,7 @@ protected: virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, uint16 index, uint16 length, void* data); + virtual status_t ProbeSensor(); CamSensor *CreateSensor(const char *name); status_t fInitStatus; flavor_info fFlavorInfo; @@ -127,6 +130,7 @@ CamDeviceAddon& fCamDeviceAddon; BUSBDevice* fDevice; int fSupportedDeviceIndex; + bool fChipIsBigEndian; bool fTransferEnabled; thread_id fPumpThread; BLocker fLocker; @@ -147,14 +151,14 @@ virtual status_t Sniff(BUSBDevice *device); virtual CamDevice* Instantiate(CamRoster &roster, BUSBDevice *from); - void SetSupportedDevices(const usb_named_support_descriptor *devs); - const usb_named_support_descriptor* SupportedDevices() const + void SetSupportedDevices(const usb_webcam_support_descriptor *devs); + const usb_webcam_support_descriptor* SupportedDevices() const { return fSupportedDevices; }; WebCamMediaAddOn* WebCamAddOn() const { return fWebCamAddOn; }; private: WebCamMediaAddOn* fWebCamAddOn; - const usb_named_support_descriptor* fSupportedDevices; // last is {{0,0,0,0,0}, NULL, NULL} + const usb_webcam_support_descriptor* fSupportedDevices; // last is {{0,0,0,0,0}, NULL, NULL, NULL } }; // internal modules Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamFilterInterface.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamFilterInterface.cpp 2008-05-05 00:32:02 UTC (rev 25319) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamFilterInterface.cpp 2008-05-05 15:38:02 UTC (rev 25320) @@ -2,6 +2,7 @@ #include "CamDevice.h" #include "CamDebug.h" + CamFilterInterface::CamFilterInterface(CamDevice *device) : BPositionIO(), fDevice(device), @@ -11,10 +12,12 @@ } + CamFilterInterface::~CamFilterInterface() { } + status_t CamFilterInterface::ChainFilter(CamFilterInterface *to) { @@ -24,6 +27,7 @@ return B_OK; } + status_t CamFilterInterface::DetachFilter(CamFilterInterface *from) { @@ -33,12 +37,14 @@ return B_OK; } + CamFilterInterface* CamFilterInterface::ChainFilter() { return fNextOfKin; } + ssize_t CamFilterInterface::Read(void *buffer, size_t size) { @@ -47,6 +53,7 @@ return EINVAL; } [... truncated: 920 lines follow ...] From mmu_man at mail.berlios.de Mon May 5 19:58:56 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 5 May 2008 19:58:56 +0200 Subject: [Haiku-commits] r25321 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons addons/quickcam addons/sonix sensors Message-ID: <200805051758.m45Hwuf7032627@sheep.berlios.de> Author: mmu_man Date: 2008-05-05 19:58:51 +0200 (Mon, 05 May 2008) New Revision: 25321 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25321&view=rev Added: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/pb0100.cpp Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/makefile haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/hdcs1000.cpp Log: Turns out my QuickCam is not a usual quickcam with an WTV600 chip but an NW80x based one... Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -360,11 +360,33 @@ ssize_t CamDevice::ReadIIC(uint8 address, uint8 *data) { + //TODO: make it mode generic return ENOSYS; } +ssize_t +CamDevice::ReadIIC8(uint8 address, uint8 *data) +{ + return ReadIIC(address, data); +} + + +ssize_t +CamDevice::ReadIIC16(uint8 address, uint16 *data) +{ + return ENOSYS; +} + + status_t +CamDevice::SetIICBitsMode(size_t bits) +{ + return ENOSYS; +} + + +status_t CamDevice::ProbeSensor() { const usb_webcam_support_descriptor *devs; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-05 17:58:51 UTC (rev 25321) @@ -99,6 +99,9 @@ virtual ssize_t WriteIIC8(uint8 address, uint8 data); virtual ssize_t WriteIIC16(uint8 address, uint16 data); virtual ssize_t ReadIIC(uint8 address, uint8 *data); + virtual ssize_t ReadIIC8(uint8 address, uint8 *data); + virtual ssize_t ReadIIC16(uint8 address, uint16 *data); + virtual status_t SetIICBitsMode(size_t bits=8); void SetDataInput(BDataIO *input); Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-05 17:58:51 UTC (rev 25321) @@ -27,7 +27,7 @@ virtual bool Use400kHz() const { return false; }; virtual bool UseRealIIC() const { return true; }; virtual uint8 IICReadAddress() const { return 0; }; - virtual uint8 IICWriteAddress() const { return 0; };; + virtual uint8 IICWriteAddress() const { return 0; }; virtual int MaxWidth() const { return -1; }; virtual int MaxHeight() const { return -1; }; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-05 17:58:51 UTC (rev 25321) @@ -16,6 +16,7 @@ local sourceDirs = addons/quickcam addons/sonix + addons cstransforms sensors ; @@ -28,7 +29,7 @@ ## addon sources local addonSources ; -addonSources = QuickCamDevice.cpp SonixCamDevice.cpp ; +addonSources = QuickCamDevice.cpp SonixCamDevice.cpp NW80xCamDevice.cpp ; ## colorspace transforms sources local csTransformsSources ; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-05 17:58:51 UTC (rev 25321) @@ -64,11 +64,13 @@ * some of the (many!) linux quickcam drivers: http://www.lrr.in.tum.de/~acher/quickcam/quickcam.html http://www.seismo.ethz.ch/linux/webcam.html +http://tuukkat.awardspace.com/quickcam/quickcam.html for PID 0xd001 * Creative's own list of linux drivers: http://connect.creativelabs.com/opensource/Lists/Webcam%20Support/AllItems.aspx * Other webcam drivers: +http://nw802.cvs.sourceforge.net NW80x based (like the QuickCam I have here) http://zc0302.sourceforge.net/zc0302.php?page=cams http://www.medias.ne.jp/~takam/bsd/NetBSD.html Added: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -0,0 +1,298 @@ +#include "NW80xCamDevice.h" +#include "CamDebug.h" +#include "CamSensor.h" + +// reference: http://nw802.cvs.sourceforge.net + +const usb_webcam_support_descriptor kSupportedDevices[] = { +{{ 0, 0, 0, 0x046d, 0xd001 }, "Logitech", "QuickCam Pro", "??" }, // Alan's +// other IDs according to nw802 linux driver: +{{ 0, 0, 0, 0x052b, 0xd001 }, "Ezonics", "EZCam Pro", "??" }, +{{ 0, 0, 0, 0x055f, 0xd001 }, "Mustek"/*"PCLine"*/, "WCam 300"/*"PCL-W300"*/, "??" }, +{{ 0, 0, 0, 0x06a5, 0xd001 }, "Generic", "NW802", "??" }, +{{ 0, 0, 0, 0x06a5, 0x0000 }, "Generic", "NW800", "??" }, +{{ 0, 0, 0, 0, 0}, NULL, NULL, NULL } +}; + + +#warning TODO! + +NW80xCamDevice::NW80xCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device) + :CamDevice(_addon, _device) +{ + status_t err; + + // linux seems to infer this sets I2C controller to 8 or 16 bit mode... + // sensors will set to the mode they want when probing + SetIICBitsMode(8); + err = ProbeSensor(); + if (err < B_OK) { + // reset I2C mode to 8 bit as linux driver does + SetIICBitsMode(8); + // not much we can do anyway + } + + fInitStatus = B_OK; +} + + +NW80xCamDevice::~NW80xCamDevice() +{ + +} + + +bool +NW80xCamDevice::SupportsBulk() +{ + return true; +} + + +bool +NW80xCamDevice::SupportsIsochronous() +{ + return true; +} + + +status_t +NW80xCamDevice::StartTransfer() +{ + status_t err; + uint8 r; + + SetScale(1); + if (Sensor()) + SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); + + //SetVideoFrame(BRect(0, 0, 320-1, 240-1)); + +DumpRegs(); +#if 0 + err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); + if (err < 0) + return err; + r |= 0x04; + err = WriteReg8(SN9C102_CHIP_CTRL, r); + if (err < 0) + return err; +#endif + return CamDevice::StartTransfer(); +} + + +status_t +NW80xCamDevice::StopTransfer() +{ + status_t err; + uint8 r; + +DumpRegs(); + err = CamDevice::StopTransfer(); +#if 0 +// if (err < 0) +// return err; + err = ReadReg(SN9C102_CHIP_CTRL, &r, 1, true); + if (err < 0) + return err; + r &= ~0x04; + err = WriteReg8(SN9C102_CHIP_CTRL, r); + if (err < 0) + return err; +#endif + return err; +} + + +ssize_t +NW80xCamDevice::WriteReg(uint16 address, uint8 *data, size_t count) +{ + PRINT((CH "(%u, @%p, %u)" CT, address, data, count)); + return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, address, 0, count, data); +} + + +ssize_t +NW80xCamDevice::ReadReg(uint16 address, uint8 *data, size_t count, bool cached) +{ + PRINT((CH "(%u, @%p, %u, %d)" CT, address, data, count, cached)); + memset(data, 0xaa, count); // linux drivers do that without explaining why !? + return SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, address, 0, count, data); +} + + +status_t +NW80xCamDevice::GetStatusIIC() +{ + status_t err; + uint8 status = 0; +#warning WRITEME + //dprintf(ID "i2c_status: error 0x%08lx, status = %02x\n", err, status); + if (err < 0) + return err; + return (status&0x08)?EIO:0; +} + + +status_t +NW80xCamDevice::WaitReadyIIC() +{ + status_t err; +#warning WRITEME + return EBUSY; +} + + +ssize_t +NW80xCamDevice::WriteIIC(uint8 address, uint8 *data, size_t count) +{ + status_t err; + int i; + uint8 buffer[0x23]; + if (count > 16) + return EINVAL; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICWriteAddress() : 0; + buffer[0x21] = count - 1; + buffer[0x22] = 0x01; + for (i = 0; i < count; i++) { + buffer[i] = address + i; + buffer[i+16] = data[i]; + } + return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); +} + + +ssize_t +NW80xCamDevice::ReadIIC(uint8 address, uint8 *data) +{ + return ReadIIC(address, data); +} + + +ssize_t +NW80xCamDevice::ReadIIC8(uint8 address, uint8 *data) +{ + status_t err; + int i; + uint8 buffer[0x23]; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; + buffer[0x21] = 1 - 1; + buffer[0x22] = 0x03; + buffer[0] = address; + err = SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + buffer[0] = 0xaa; + err = SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, STV_I2C_READ, 0, 0x1, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + *data = buffer[0]; + PRINT((CH ": 0x%02x" CT, *data)); + return 1; +} + + +ssize_t +NW80xCamDevice::ReadIIC16(uint8 address, uint16 *data) +{ + status_t err; + int i; + uint8 buffer[0x23]; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; + buffer[0x21] = 1 - 1; + buffer[0x22] = 0x03; + buffer[0] = address; + err = SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); + if (err < B_OK) + return err; + + buffer[0] = 0xaa; + buffer[1] = 0xaa; + err = SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, STV_I2C_READ, 0, 0x2, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + if (fChipIsBigEndian) + *data = B_HOST_TO_BENDIAN_INT16(*(uint16 *)(&buffer[0])); + else + *data = B_HOST_TO_LENDIAN_INT16(*(uint16 *)(&buffer[0])); + PRINT((CH ": 0x%04x" CT, *data)); + return 2; +} + + +status_t +NW80xCamDevice::SetIICBitsMode(size_t bits) +{ + switch (bits) { + case 8: + WriteReg8(STV_REG23, 0); + break; + case 16: + WriteReg8(STV_REG23, 1); + break; + default: + return EINVAL; + } + return B_OK; +} + + +status_t +NW80xCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data) +{ + size_t ret; + if (!GetDevice()) + return ENODEV; + if (length > GetDevice()->MaxEndpoint0PacketSize()) + return EINVAL; + ret = GetDevice()->ControlTransfer( + USB_REQTYPE_VENDOR | dir, + request, value, index, length, data); + return ret; +} + + +NW80xCamDeviceAddon::NW80xCamDeviceAddon(WebCamMediaAddOn* webcam) + : CamDeviceAddon(webcam) +{ + SetSupportedDevices(kSupportedDevices); +} + + +NW80xCamDeviceAddon::~NW80xCamDeviceAddon() +{ +} + + +const char * +NW80xCamDeviceAddon::BrandName() +{ + return "NW80x-based"; +} + + +NW80xCamDevice * +NW80xCamDeviceAddon::Instantiate(CamRoster &roster, BUSBDevice *from) +{ + return new NW80xCamDevice(*this, from); +} + + +extern "C" status_t +B_WEBCAM_MKINTFUNC(nw80xcam) +(WebCamMediaAddOn* webcam, CamDeviceAddon **addon) +{ + *addon = new NW80xCamDeviceAddon(webcam); + return B_OK; +} Added: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.h 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.h 2008-05-05 17:58:51 UTC (rev 25321) @@ -0,0 +1,66 @@ +#ifndef _NW80X_CAM_DEVICE_H +#define _NW80X_CAM_DEVICE_H + +#include "CamDevice.h" + +#define STV_REG_COUNT 0x0c +// Control registers of the STV0600 ASIC +#define STV_I2C_WRITE 0x400 +#define STV_I2C_WRITE1 0x400 +#define STV_I2C_READ 0x1410 +#define STV_ISO_ENABLE 0x1440 +#define STV_SCAN_RATE 0x1443 +#define STV_ISO_SIZE 0x15c1 +#define STV_Y_CTRL 0x15c3 +#define STV_X_CTRL 0x1680 +#define STV_REG00 0x1500 +#define STV_REG01 0x1501 +#define STV_REG02 0x1502 +#define STV_REG03 0x1503 +#define STV_REG04 0x1504 +#define STV_REG23 0x0423 + + +// This class represents each webcam +class NW80xCamDevice : public CamDevice +{ + public: + NW80xCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device); + ~NW80xCamDevice(); + virtual bool SupportsBulk(); + virtual bool SupportsIsochronous(); + virtual status_t StartTransfer(); + virtual status_t StopTransfer(); + + // generic register-like access + virtual ssize_t WriteReg(uint16 address, uint8 *data, size_t count=1); + virtual ssize_t ReadReg(uint16 address, uint8 *data, size_t count=1, bool cached=false); + + // I2C-like access + virtual status_t GetStatusIIC(); + virtual status_t WaitReadyIIC(); + virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count=1); + virtual ssize_t ReadIIC(uint8 address, uint8 *data); + virtual ssize_t ReadIIC8(uint8 address, uint8 *data); + virtual ssize_t ReadIIC16(uint8 address, uint16 *data); + virtual status_t SetIICBitsMode(size_t bits=8); + + private: + virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, + uint16 index, uint16 length, void* data); +}; + +// the addon itself, that instanciate + +class NW80xCamDeviceAddon : public CamDeviceAddon +{ + public: + NW80xCamDeviceAddon(WebCamMediaAddOn* webcam); + virtual ~NW80xCamDeviceAddon(); + + virtual const char *BrandName(); + virtual NW80xCamDevice *Instantiate(CamRoster &roster, BUSBDevice *from); + +}; + +#endif /* _NW80X_CAM_CAM_DEVICE_H */ Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -6,7 +6,6 @@ const usb_webcam_support_descriptor kSupportedDevices[] = { {{ 0, 0, 0, 0x046d, 0x0840 }, "Logitech", "QuickCam Express", NULL }, {{ 0, 0, 0, 0x046d, 0x0850 }, "Logitech", "QuickCam Express LEGO", NULL }, -{{ 0, 0, 0, 0x046d, 0xd001 }, "Logitech", "QuickCam Express", NULL }, // Alan's {{ 0, 0, 0, 0, 0}, NULL, NULL, NULL } }; @@ -15,6 +14,18 @@ QuickCamDevice::QuickCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device) :CamDevice(_addon, _device) { + status_t err; + + // linux seems to infer this sets I2C controller to 8 or 16 bit mode... + // sensors will set to the mode they want when probing + SetIICBitsMode(8); + err = ProbeSensor(); + if (err < B_OK) { + // reset I2C mode to 8 bit as linux driver does + SetIICBitsMode(8); + // not much we can do anyway + } + fInitStatus = B_OK; } @@ -100,6 +111,7 @@ QuickCamDevice::ReadReg(uint16 address, uint8 *data, size_t count, bool cached) { PRINT((CH "(%u, @%p, %u, %d)" CT, address, data, count, cached)); + memset(data, 0xaa, count); // linux drivers do that without explaining why !? return SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, address, 0, count, data); } @@ -142,20 +154,94 @@ buffer[i] = address + i; buffer[i+16] = data[i]; } - return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, data); + return SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); } ssize_t QuickCamDevice::ReadIIC(uint8 address, uint8 *data) { -#warning WRITEME + return ReadIIC(address, data); +} + + +ssize_t +QuickCamDevice::ReadIIC8(uint8 address, uint8 *data) +{ + status_t err; + int i; + uint8 buffer[0x23]; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; + buffer[0x21] = 1 - 1; + buffer[0x22] = 0x03; + buffer[0] = address; + err = SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + buffer[0] = 0xaa; + err = SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, STV_I2C_READ, 0, 0x1, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + *data = buffer[0]; + PRINT((CH ": 0x%02x" CT, *data)); return 1; } +ssize_t +QuickCamDevice::ReadIIC16(uint8 address, uint16 *data) +{ + status_t err; + int i; + uint8 buffer[0x23]; + memset(buffer, 0, sizeof(buffer)); + buffer[0x20] = Sensor() ? Sensor()->IICReadAddress() : 0; + buffer[0x21] = 1 - 1; + buffer[0x22] = 0x03; + buffer[0] = address; + err = SendCommand(USB_REQTYPE_DEVICE_OUT, 0x04, STV_I2C_WRITE, 0, 0x23, buffer); + if (err < B_OK) + return err; + buffer[0] = 0xaa; + buffer[1] = 0xaa; + err = SendCommand(USB_REQTYPE_DEVICE_IN, 0x04, STV_I2C_READ, 0, 0x2, buffer); + PRINT((CH ": SendCommand: %s" CT, strerror(err))); + if (err < B_OK) + return err; + + if (fChipIsBigEndian) + *data = B_HOST_TO_BENDIAN_INT16(*(uint16 *)(&buffer[0])); + else + *data = B_HOST_TO_LENDIAN_INT16(*(uint16 *)(&buffer[0])); + PRINT((CH ": 0x%04x" CT, *data)); + return 2; +} + + status_t +QuickCamDevice::SetIICBitsMode(size_t bits) +{ + switch (bits) { + case 8: + WriteReg8(STV_REG23, 0); + break; + case 16: + WriteReg8(STV_REG23, 1); + break; + default: + return EINVAL; + } + return B_OK; +} + + +status_t QuickCamDevice::SendCommand(uint8 dir, uint8 request, uint16 value, uint16 index, uint16 length, void* data) { Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/quickcam/QuickCamDevice.h 2008-05-05 17:58:51 UTC (rev 25321) @@ -41,6 +41,9 @@ virtual status_t WaitReadyIIC(); virtual ssize_t WriteIIC(uint8 address, uint8 *data, size_t count=1); virtual ssize_t ReadIIC(uint8 address, uint8 *data); + virtual ssize_t ReadIIC8(uint8 address, uint8 *data); + virtual ssize_t ReadIIC16(uint8 address, uint16 *data); + virtual status_t SetIICBitsMode(size_t bits=8); private: virtual status_t SendCommand(uint8 dir, uint8 request, uint16 value, Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -9,7 +9,7 @@ #include const usb_webcam_support_descriptor kSupportedDevices[] = { -{{ 0, 0, 0, 0x0c45, 0x6005 }, "Sonix", "Sonix", "foo,bar,tas5110c1b" }, // mine +{{ 0, 0, 0, 0x0c45, 0x6005 }, "Sonix", "Sonix", "tas5110c1b" }, // mine {{ 0, 0, 0, 0x0c45, 0x6009 }, "Trust", "spacec at m 120", NULL }, {{ 0, 0, 0, 0x0c45, 0x600d }, "Trust", "spacec at m 120", NULL }, Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/makefile =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/makefile 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/makefile 2008-05-05 17:58:51 UTC (rev 25321) @@ -34,6 +34,7 @@ # in folder names do not work well with this makefile. SRCS := $(wildcard *.cpp) \ $(wildcard addons/*/*.cpp) \ +$(wildcard addons/*.cpp) \ $(wildcard sensors/*.cpp) \ $(wildcard cstransforms/*.cpp) @@ -193,8 +194,8 @@ CamDevice.cpp: CamInternalSensors.h CamColorSpaceTransform.cpp: CamInternalColorSpaceTransforms.h -CamInternalAddons.h: $(wildcard addons/*/*CamDevice.cpp) - grep -h B_WEBCAM_MKINTFUNC $(CURDIR)/addons/*/*CamDevice.cpp > $@ +CamInternalAddons.h: $(wildcard addons/*/*CamDevice.cpp) $(wildcard addons/*CamDevice.cpp) + grep -h B_WEBCAM_MKINTFUNC $(CURDIR)/addons/*/*CamDevice.cpp $(CURDIR)/addons/*CamDevice.cpp > $@ CamInternalSensors.h: $(wildcard sensors/*.cpp) grep -h B_WEBCAM_DECLARE_SENSOR $(CURDIR)/sensors/*.cpp > $@ Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/hdcs1000.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/hdcs1000.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/hdcs1000.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -2,25 +2,53 @@ */ #include "CamSensor.h" +#include "CamDebug.h" +#define HDCS_ADDR_QC 0xaa + +#define HDCS_IDENT 0x00 + class HDCS1000Sensor : public CamSensor { public: HDCS1000Sensor(CamDevice *_camera); ~HDCS1000Sensor(); + + virtual status_t Probe(); + + virtual uint8 IICReadAddress() const { return HDCS_ADDR_QC; }; + virtual uint8 IICWriteAddress() const { return HDCS_ADDR_QC; }; }; -// ----------------------------------------------------------------------------- + HDCS1000Sensor::HDCS1000Sensor(CamDevice *_camera) : CamSensor(_camera) { - } -// ----------------------------------------------------------------------------- + HDCS1000Sensor::~HDCS1000Sensor() { } -// ----------------------------------------------------------------------------- + +status_t +HDCS1000Sensor::Probe() +{ + status_t err; + uint8 data; + PRINT((CH "()" CT)); + Device()->SetIICBitsMode(8); + // QuickCam only ? + err = Device()->ReadIIC8(HDCS_IDENT+1, &data); + if (err < B_OK) + return ENODEV; + if (data == 8) { + PRINT((CH ": found %s sensor!" CT, Name())); + return B_OK; + } + return ENODEV; +} + + B_WEBCAM_DECLARE_SENSOR(HDCS1000Sensor, hdcs1000) Added: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/pb0100.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/pb0100.cpp 2008-05-05 15:38:02 UTC (rev 25320) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/pb0100.cpp 2008-05-05 17:58:51 UTC (rev 25321) @@ -0,0 +1,56 @@ +/* +*/ + +#include "CamSensor.h" +#include "CamDebug.h" + +#define PB_ADDR_QC 0xba + +#define PB_IDENT 0x00 + + +class PB0100Sensor : public CamSensor { +public: + PB0100Sensor(CamDevice *_camera); + ~PB0100Sensor(); + virtual status_t Probe(); + + virtual uint8 IICReadAddress() const { return PB_ADDR_QC; }; + virtual uint8 IICWriteAddress() const { return PB_ADDR_QC; }; +}; + + +PB0100Sensor::PB0100Sensor(CamDevice *_camera) +: CamSensor(_camera) +{ + Device()->SetIICBitsMode(16); + +} + + +PB0100Sensor::~PB0100Sensor() +{ +} + + +status_t +PB0100Sensor::Probe() +{ + status_t err; + uint16 data; + PRINT((CH "()" CT)); + Device()->SetIICBitsMode(16); + // QuickCam only ? + err = Device()->ReadIIC16(PB_IDENT, &data); + if (err < B_OK) + return ENODEV; + if (data == 0x64) { + PRINT((CH ": found %s sensor!" CT, Name())); + return B_OK; + } + return ENODEV; +} + + +B_WEBCAM_DECLARE_SENSOR(PB0100Sensor, pb0100) + From mmu_man at mail.berlios.de Mon May 5 22:50:28 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Mon, 5 May 2008 22:50:28 +0200 Subject: [Haiku-commits] r25322 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons Message-ID: <200805052050.m45KoSxP013766@sheep.berlios.de> Author: mmu_man Date: 2008-05-05 22:50:27 +0200 (Mon, 05 May 2008) New Revision: 25322 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25322&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp Log: More links Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-05 17:58:51 UTC (rev 25321) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-05 20:50:27 UTC (rev 25322) @@ -64,19 +64,36 @@ * some of the (many!) linux quickcam drivers: http://www.lrr.in.tum.de/~acher/quickcam/quickcam.html http://www.seismo.ethz.ch/linux/webcam.html + +* NW80x based: +http://nw802.cvs.sourceforge.net NW80x based (like the QuickCam I have here) http://tuukkat.awardspace.com/quickcam/quickcam.html for PID 0xd001 +http://blognux.free.fr/sources/EasyCam2/04032006_11:11/drivers/nw802/ +datasheets: +http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php * Creative's own list of linux drivers: http://connect.creativelabs.com/opensource/Lists/Webcam%20Support/AllItems.aspx * Other webcam drivers: -http://nw802.cvs.sourceforge.net NW80x based (like the QuickCam I have here) http://zc0302.sourceforge.net/zc0302.php?page=cams +http://www.smcc.demon.nl/webcam/ (philips) http://www.medias.ne.jp/~takam/bsd/NetBSD.html +http://blognux.free.fr/sources/EasyCam2/04032006_19:49/ +http://www.wifi.com.ar/english/doc/webcam/ov511cameras.html * CMOS Sensor datasheets (rather, marketing buzz): http://www.tascorp.com.tw/product_file/TAS5110C1B_Brief_V0.3.pdf http://www.tascorp.com.tw/product_file/TAS5130D1B_Brief_V0.3.pdf +Divio NW80x: +http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php +http://www.digchip.com/datasheets/parts/datasheet/132/NW802.php +http://web.archive.org/web/*/divio.com/* +All from eTOMS (ET31X110 would be == NW800 but isn't there): +http://www.etomscorp.com/english/webdesign/product_search.asp +http://web.archive.org/web/*re_pd_sr_1nr_50/http://etomscorp.com/* +Agilent HDCS: +http://www.ortodoxism.ro/datasheets2/2/05jj45dcrga6zr0zjg7hrde83cpy.pdf * Linux USB stack: http://www.iglu.org.il/lxr/source/include/linux/usb.h Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp 2008-05-05 17:58:51 UTC (rev 25321) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/NW80xCamDevice.cpp 2008-05-05 20:50:27 UTC (rev 25322) @@ -2,21 +2,46 @@ #include "CamDebug.h" #include "CamSensor.h" -// reference: http://nw802.cvs.sourceforge.net +// reference drivers: +// http://nw802.cvs.sourceforge.net +// http://nw802.cvs.sourceforge.net/nw802/nw802-2.4/ +// http://www.medias.ne.jp/~takam/bsd/NetBSD.html#nw802 +// https://dev.openwrt.org/attachment/ticket/2319/nw802-patch.txt +// win binary driver template, readme has interesting info: +// http://www.bulgar-bg.com/Downloads/drivers/PCAMDriver/ +// http://www.bulgar-bg.com/Downloads/drivers/PCAMDriver/Readme.txt const usb_webcam_support_descriptor kSupportedDevices[] = { {{ 0, 0, 0, 0x046d, 0xd001 }, "Logitech", "QuickCam Pro", "??" }, // Alan's // other IDs according to nw802 linux driver: {{ 0, 0, 0, 0x052b, 0xd001 }, "Ezonics", "EZCam Pro", "??" }, {{ 0, 0, 0, 0x055f, 0xd001 }, "Mustek"/*"PCLine"*/, "WCam 300"/*"PCL-W300"*/, "??" }, -{{ 0, 0, 0, 0x06a5, 0xd001 }, "Generic", "NW802", "??" }, -{{ 0, 0, 0, 0x06a5, 0x0000 }, "Generic", "NW800", "??" }, +{{ 0, 0, 0, 0x06a5, 0xd001 }, "Divio", "NW802", "??" }, +{{ 0, 0, 0, 0x06a5, 0x0000 }, "Divio", "NW800", "??" }, {{ 0, 0, 0, 0, 0}, NULL, NULL, NULL } }; #warning TODO! +// datasheets: (scarce) +// http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php +// http://www.digchip.com/datasheets/parts/datasheet/132/NW802.php +// http://web.archive.org/web/*/divio.com/* +// http://web.archive.org/web/20020217173519/divio.com/NW802.html +// +// supported sensors: +// Sensor Model # Data Width Voltage Timing +// Conexant CN0352 10 bits 3.3 V Master +// Elecvision EVS110K 8 bits 3.3 V Slave +// HP (Agilent) HDC1000 10 bits 3.3 V Master +// Hyundai HB7121B 8 bits 3.3 V Master +// Pixart PAS006AC 9 bits 3.3 V Master +// TASC TAS5110A 9 bits 3.8 V Slave +// +// http://www.wifi.com.ar/english/doc/webcam/ov511cameras.html says: +// 06a5 (Divio) d800 Etoms ET31X110 (A.K.A Divio NW800) + NW80xCamDevice::NW80xCamDevice(CamDeviceAddon &_addon, BUSBDevice* _device) :CamDevice(_addon, _device) { From axeld at pinc-software.de Mon May 5 23:24:44 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 05 May 2008 23:24:44 +0200 CEST Subject: [Haiku-commits] r25309 - in haiku/trunk: build/jam data/etc data/etc/post_install data/settings data/system/boot In-Reply-To: <20080505002922.456.2@knochen-vm.1209937780.fake> Message-ID: <50897880252-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-04 at 20:15:12 [+0200], Fran?ois Revol > wrote: > > There used to be InstallerRebootScript and friends in /system/boot, > > why > > polute /etc more ? > I'm fine with moving the post_install dir to /system/boot (or rather > /boot/common/boot?). I don't think a single script will be flexible > enough, > though. Why not put that directory in there, then? :-) I like to have it in /boot/common/boot/ - we should really propagate its usage. Bye, Axel. From mmu_man at mail.berlios.de Tue May 6 02:25:34 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 6 May 2008 02:25:34 +0200 Subject: [Haiku-commits] r25323 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/sonix sensors Message-ID: <200805060025.m460PYpu022819@sheep.berlios.de> Author: mmu_man Date: 2008-05-06 02:25:26 +0200 (Tue, 06 May 2008) New Revision: 25323 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25323&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp Log: - Finaly got sensor gain to work for mine... - added brightness and contrast parameters for sn9cxxx according to a linux driver, but doesn't seem to work for mine. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-05 20:50:27 UTC (rev 25322) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-06 00:25:26 UTC (rev 25323) @@ -81,10 +81,13 @@ http://www.medias.ne.jp/~takam/bsd/NetBSD.html http://blognux.free.fr/sources/EasyCam2/04032006_19:49/ http://www.wifi.com.ar/english/doc/webcam/ov511cameras.html +http://mxhaard.free.fr/spca5xx.html * CMOS Sensor datasheets (rather, marketing buzz): +http://mxhaard.free.fr/spca50x/Doc/ many http://www.tascorp.com.tw/product_file/TAS5110C1B_Brief_V0.3.pdf http://www.tascorp.com.tw/product_file/TAS5130D1B_Brief_V0.3.pdf +http://www.mnementh.co.uk/sonix/hv7131e1.pdf Divio NW80x: http://www.digchip.com/datasheets/parts/datasheet/132/NW800.php http://www.digchip.com/datasheets/parts/datasheet/132/NW802.php Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-05 20:50:27 UTC (rev 25322) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-06 00:25:26 UTC (rev 25323) @@ -78,6 +78,8 @@ fFrameTagState = 0; fRGain = fGGain = fBGain = 0; + // unknown + fBrightness = 0.5; memset(fCachedRegs, 0, SN9C102_REG_COUNT); fChipVersion = 2; @@ -271,13 +273,16 @@ count++; // includes address if (count > 5) return EINVAL; - buffer[0] = (count << 4) | Sensor()->Use400kHz()?0x01:0 - | Sensor()->UseRealIIC()?0x80:0; + buffer[0] = ((count) << 4) | (Sensor()->Use400kHz()?0x01:0) + | (Sensor()->UseRealIIC()?0x80:0); buffer[1] = Sensor()->IICWriteAddress(); buffer[2] = address; memset(&buffer[3], 0, 5); - memcpy(&buffer[3], data, count); - buffer[7] = 0x14; /* absolutely no idea why V4L2 driver use that value */ + memcpy(&buffer[3], data, count-1); + buffer[7] = 0x10; /*0x14;*/ /* absolutely no idea why V4L2 driver use that value */ + for (int i = 0; i < 8; i++) { + PRINT(("[%d] = %02x\n", i, buffer[i])); + } err = WriteReg(SN9C102_I2C_SETUP, buffer, 8); //dprintf(ID "sonix_i2c_write_multi: set_regs error 0x%08lx\n", err); //PRINT((CH ": WriteReg: %s" CT, strerror(err))); @@ -403,16 +408,31 @@ void SonixCamDevice::AddParameters(BParameterGroup *group, int32 &index) { + BParameterGroup *g; BContinuousParameter *p; CamDevice::AddParameters(group, index); - p = group->MakeContinuousParameter(index++, + // R,G,B gains + g = group->MakeGroup("RGB gain"); + p = g->MakeContinuousParameter(index++, B_MEDIA_RAW_VIDEO, "RGB gain", B_GAIN, "", 1.0, 1.0+(float)(SN9C102_RGB_GAIN_MAX)/8, (float)1.0/8); p->SetChannelCount(3); +#if 0 + // Contrast - NON FUNCTIONAL + g = group->MakeGroup("Contrast"); + p = g->MakeContinuousParameter(index++, + B_MEDIA_RAW_VIDEO, "Contrast", + B_GAIN, "", 0.0, 1.0, 1.0/256); + // Brightness - NON FUNCTIONAL + g = group->MakeGroup("Brightness"); + p = g->MakeContinuousParameter(index++, + B_MEDIA_RAW_VIDEO, "Brightness", + B_GAIN, "", 0.0, 1.0, 1.0/256); +#endif } status_t @@ -428,6 +448,20 @@ gains[2] = 1.0 + (float)fBGain / 8; *last_change = fLastParameterChanges; return B_OK; +#if 0 + case 1: + *size = sizeof(float); + gains = ((float *)value); + gains[0] = fContrast; + *last_change = fLastParameterChanges; + return B_OK; + case 2: + *size = sizeof(float); + gains = ((float *)value); + gains[0] = fBrightness; + *last_change = fLastParameterChanges; + return B_OK; +#endif } return B_BAD_VALUE; } @@ -473,6 +507,24 @@ WriteReg(SN9C102_R_B_GAIN, buf, 2); #endif return B_OK; +#if 0 + case 1: + if (!value || (size != sizeof(float))) + return B_BAD_VALUE; + gains = ((float *)value); + fContrast = gains[0]; + WriteReg8(SN9C10x_CONTRAST, ((uint8)(fContrast * 256))); + return B_OK; + case 2: + if (!value || (size != sizeof(float))) + return B_BAD_VALUE; + gains = ((float *)value); + fBrightness = gains[0]; + // it actually ends up writing to SN9C102_V_SIZE... + WriteReg8(SN9C10x_BRIGHTNESS, ((uint8)(fBrightness * 256))); + + return B_OK; +#endif } return B_BAD_VALUE; } Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-05 20:50:27 UTC (rev 25322) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.h 2008-05-06 00:25:26 UTC (rev 25323) @@ -40,6 +40,13 @@ #define SN9C102_AE_ENDX 0x1e #define SN9C102_AE_ENDY 0x1f +// extra regs ? maybe 103 or later only ? used by gspcav1 +#define SN9C10x_CONTRAST 0x84 +#define SN9C10x_BRIGHTNESS 0x96 +#undef SN9C102_REG_COUNT +#define SN9C102_REG_COUNT 0x100 + + #define SN9C102_RGB_GAIN_MAX 0x7f // This class represents each webcam @@ -95,6 +102,8 @@ uint8 fRGain; uint8 fGGain; uint8 fBGain; + float fContrast; + float fBrightness; }; // the addon itself, that instanciate Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-05 20:50:27 UTC (rev 25322) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-06 00:25:26 UTC (rev 25323) @@ -18,7 +18,7 @@ virtual bool Use400kHz() const { return false; }; virtual bool UseRealIIC() const { return false; }; virtual uint8 IICReadAddress() const { return 0x00; }; - virtual uint8 IICWriteAddress() const { return 0xff; }; + virtual uint8 IICWriteAddress() const { return 0x11; /*0xff;*/ }; virtual int MaxWidth() const { return 352; }; virtual int MaxHeight() const { return 288; }; virtual status_t SetVideoFrame(BRect rect); @@ -71,10 +71,11 @@ Device()->WriteReg8(SN9C102_PIX_CLK, 0xfb); /* pixclk = 2 * masterclk, sensor is slave mode */ } - //sonix_i2c_write_multi(dev, dev->sensor->i2c_wid, 2, 0xc0, 0x80, 0, 0, 0); /* AEC = 0x203 ??? */ - Device()->WriteIIC8(0xc0, 0x80); /* AEC = 0x203 ??? */ if (fIsSonix) { + //sonix_i2c_write_multi(dev, dev->sensor->i2c_wid, 2, 0xc0, 0x80, 0, 0, 0); /* AEC = 0x203 ??? */ + Device()->WriteIIC8(0xc0, 0x80); /* AEC = 0x203 ??? */ + // set crop Device()->WriteReg8(SN9C102_H_SIZE, 69); Device()->WriteReg8(SN9C102_V_SIZE, 9); @@ -126,6 +127,7 @@ CamSensor::AddParameters(group, index); #ifdef ENABLE_GAIN + // NON-FUNCTIONAL p = group->MakeContinuousParameter(index++, B_MEDIA_RAW_VIDEO, "global gain", B_GAIN, "", (float)0x00, (float)0xf6, (float)1); @@ -157,8 +159,19 @@ return B_OK; fGain = *(float *)value; fLastParameterChanges = when; - PRINT((CH ": gain: %f (%d)" CT, fGain, (unsigned)(0xf6-fGain))); - Device()->WriteIIC8(0x20, (uint8)0xf6 - (uint8)fGain); + PRINT((CH ": gain: %f" CT, fGain)); + + if (fIsSonix) { + // some drivers do: + //Device()->WriteIIC8(0x20, (uint8)0xf6 - (uint8)fGain); + // but it doesn't seem to work + + // works, not sure why yet, XXX check datasheet for AEG/AEC + uint8 buf[2] = { 0x20, 0x70 }; + buf[1] = (uint8)0xff - (uint8)fGain; + Device()->WriteIIC(0x02, buf, 2); + } + return B_OK; } #endif From bonefish at mail.berlios.de Tue May 6 05:30:27 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 May 2008 05:30:27 +0200 Subject: [Haiku-commits] r25324 - haiku/trunk/headers/private/kernel/util Message-ID: <200805060330.m463URtn000139@sheep.berlios.de> Author: bonefish Date: 2008-05-06 05:30:25 +0200 (Tue, 06 May 2008) New Revision: 25324 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25324&view=rev Modified: haiku/trunk/headers/private/kernel/util/atomic.h Log: Added atomic_pointer_get(). Modified: haiku/trunk/headers/private/kernel/util/atomic.h =================================================================== --- haiku/trunk/headers/private/kernel/util/atomic.h 2008-05-06 00:25:26 UTC (rev 25323) +++ haiku/trunk/headers/private/kernel/util/atomic.h 2008-05-06 03:30:25 UTC (rev 25324) @@ -37,6 +37,17 @@ #endif } + +template PointerType* +atomic_pointer_get(PointerType** _pointer) +{ +#if LONG_MAX == INT_MAX + return (PointerType*)atomic_get((vint32*)_pointer); +#else + return (PointerType*)atomic_get64((vint64*)_pointer); +#endif +} + #endif // __cplusplus #endif /* _KERNEL_UTIL_ATOMIC_H */ From bonefish at mail.berlios.de Tue May 6 05:30:48 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 May 2008 05:30:48 +0200 Subject: [Haiku-commits] r25325 - haiku/trunk/headers/private/kernel Message-ID: <200805060330.m463Umkg000180@sheep.berlios.de> Author: bonefish Date: 2008-05-06 05:30:48 +0200 (Tue, 06 May 2008) New Revision: 25325 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25325&view=rev Modified: haiku/trunk/headers/private/kernel/tracing.h Log: Missing copyright header. Modified: haiku/trunk/headers/private/kernel/tracing.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing.h 2008-05-06 03:30:25 UTC (rev 25324) +++ haiku/trunk/headers/private/kernel/tracing.h 2008-05-06 03:30:48 UTC (rev 25325) @@ -1,3 +1,8 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ #ifndef KERNEL_TRACING_H #define KERNEL_TRACING_H From bonefish at mail.berlios.de Tue May 6 05:39:37 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 6 May 2008 05:39:37 +0200 Subject: [Haiku-commits] r25326 - in haiku/trunk: headers/posix headers/private/kernel src/system/kernel src/system/libroot/posix Message-ID: <200805060339.m463dbJg000585@sheep.berlios.de> Author: bonefish Date: 2008-05-06 05:39:36 +0200 (Tue, 06 May 2008) New Revision: 25326 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25326&view=rev Added: haiku/trunk/headers/posix/semaphore.h haiku/trunk/headers/private/kernel/realtime_sem.h haiku/trunk/src/system/kernel/realtime_sem.cpp haiku/trunk/src/system/libroot/posix/semaphore.cpp Modified: haiku/trunk/headers/private/kernel/sem.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/main.c haiku/trunk/src/system/kernel/sem.cpp haiku/trunk/src/system/kernel/syscalls.cpp haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/libroot/posix/Jamfile Log: Added support for POSIX semaphores (the ones from the XSI extension Realtime option group). The implementation should be complete, but is totally untested yet. Added: haiku/trunk/headers/posix/semaphore.h =================================================================== --- haiku/trunk/headers/posix/semaphore.h 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/headers/posix/semaphore.h 2008-05-06 03:39:36 UTC (rev 25326) @@ -0,0 +1,36 @@ +/* + * Copyright 2008, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _SEMAPHORE_H_ +#define _SEMAPHORE_H_ + +#include +#include + + +typedef struct { + int id; +} sem_t; + +#define SEM_FAILED ((sem_t*)(long)-1) + +__BEGIN_DECLS + +sem_t* sem_open(const char* name, int openFlags,...); +int sem_close(sem_t* semaphore); +int sem_unlink(const char* name); + +int sem_init(sem_t* semaphore, int shared, unsigned value); +int sem_destroy(sem_t* semaphore); + +int sem_post(sem_t* semaphore); +int sem_timedwait(sem_t* semaphore, const struct timespec* timeout); +int sem_trywait(sem_t* semaphore); +int sem_wait(sem_t* semaphore); +int sem_getvalue(sem_t* semaphore, int* value); + +__END_DECLS + + +#endif /* _SEMAPHORE_H_ */ Added: haiku/trunk/headers/private/kernel/realtime_sem.h =================================================================== --- haiku/trunk/headers/private/kernel/realtime_sem.h 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/headers/private/kernel/realtime_sem.h 2008-05-06 03:39:36 UTC (rev 25326) @@ -0,0 +1,38 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef KERNEL_REALTIME_SEM_H +#define KERNEL_REALTIME_SEM_H + +#include +#include +#include + +#include + + +struct realtime_sem_context; + + +__BEGIN_DECLS + +void realtime_sem_init(); +void delete_realtime_sem_context(struct realtime_sem_context* context); +struct realtime_sem_context* clone_realtime_sem_context( + struct realtime_sem_context* context); + +status_t _user_realtime_sem_open(const char* name, int openFlags, + mode_t mode, uint32 semCount, sem_t* userSem, + sem_t** _usedUserSem); +status_t _user_realtime_sem_close(sem_id semID, sem_t** _deleteUserSem); +status_t _user_realtime_sem_unlink(const char* name); + +status_t _user_realtime_sem_get_value(sem_id semID, int* value); +status_t _user_realtime_sem_post(sem_id semID); +status_t _user_realtime_sem_wait(sem_id semID, bigtime_t timeout); + +__END_DECLS + + +#endif // KERNEL_REALTIME_SEM_H Modified: haiku/trunk/headers/private/kernel/sem.h =================================================================== --- haiku/trunk/headers/private/kernel/sem.h 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/headers/private/kernel/sem.h 2008-05-06 03:39:36 UTC (rev 25326) @@ -20,7 +20,7 @@ extern "C" { #endif -extern status_t sem_init(struct kernel_args *args); +extern status_t haiku_sem_init(struct kernel_args *args); extern int sem_delete_owned_sems(team_id owner); extern int32 sem_used_sems(void); extern int32 sem_max_sems(void); Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-05-06 03:39:36 UTC (rev 25326) @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -75,6 +76,18 @@ struct sem_info *info, size_t size); extern status_t _kern_set_sem_owner(sem_id id, team_id proc); +/* POSIX realtime sem syscalls */ +extern status_t _kern_realtime_sem_open(const char* name, int openFlags, + mode_t mode, uint32 semCount, sem_t* userSem, + sem_t** _usedUserSem); +extern status_t _kern_realtime_sem_close(sem_id semID, + sem_t** _deleteUserSem); +extern status_t _kern_realtime_sem_unlink(const char* name); + +extern status_t _kern_realtime_sem_get_value(sem_id semID, int* value); +extern status_t _kern_realtime_sem_post(sem_id semID); +extern status_t _kern_realtime_sem_wait(sem_id semID, bigtime_t timeout); + /* team & thread syscalls */ extern thread_id _kern_load_image(int32 argCount, const char **args, Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-05-06 03:39:36 UTC (rev 25326) @@ -68,8 +68,8 @@ THREAD_BLOCK_TYPE_USER_BASE = 10000 }; -struct image; - // defined in image.c +struct image; // defined in image.c +struct realtime_sem_context; // defined in realtime_sem.cpp struct select_info; struct death_entry { @@ -181,6 +181,7 @@ int state; // current team state, see above int32 flags; void *io_context; + struct realtime_sem_context *realtime_sem_context; sem_id death_sem; // semaphore to wait on for dying threads struct list dead_threads; int dead_threads_count; Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-06 03:39:36 UTC (rev 25326) @@ -33,6 +33,7 @@ Notifications.cpp port.cpp real_time_clock.c + realtime_sem.cpp scheduler.cpp sem.cpp shutdown.c Modified: haiku/trunk/src/system/kernel/main.c =================================================================== --- haiku/trunk/src/system/kernel/main.c 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/main.c 2008-05-06 03:39:36 UTC (rev 25326) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -137,7 +138,7 @@ rtc_init(&sKernelArgs); TRACE("init semaphores\n"); - sem_init(&sKernelArgs); + haiku_sem_init(&sKernelArgs); condition_variable_init(); // now we can create and use semaphores @@ -158,6 +159,7 @@ TRACE("init kernel daemons\n"); kernel_daemon_init(); arch_platform_init_post_thread(&sKernelArgs); + realtime_sem_init(); TRACE("init VM threads\n"); vm_init_post_thread(&sKernelArgs); Added: haiku/trunk/src/system/kernel/realtime_sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/realtime_sem.cpp 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/realtime_sem.cpp 2008-05-06 03:39:36 UTC (rev 25326) @@ -0,0 +1,758 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class SemInfo { +public: + SemInfo() + : + fName(NULL), + fRefCount(1), + fID(-1) + { + } + + ~SemInfo() + { + free(fName); + if (fID >= 0) + delete_sem(fID); + } + + const char* Name() const { return fName; } + sem_id ID() const { return fID; } + + status_t Init(const char* name, mode_t mode, int32 semCount) + { + fName = strdup(name); + if (fName == NULL) + return B_NO_MEMORY; + + fID = create_sem(semCount, name); + if (fID < 0) + return fID; + + fUID = geteuid(); + fGID = getegid(); + fPermissions = mode; + + return B_OK; + } + + void AcquireReference() + { + atomic_add(&fRefCount, 1); + } + + void ReleaseReference() + { + if (atomic_add(&fRefCount, -1) == 1) + delete this; + } + + bool HasPermissions() const + { + if ((fPermissions & S_IWOTH) != 0) + return true; + + uid_t uid = geteuid(); + if (uid == 0 || (uid == fUID && (fPermissions & S_IWUSR) != 0)) + return true; + + gid_t gid = getegid(); + if (gid == fGID && (fPermissions & S_IWGRP) != 0) + return true; + + return false; + } + + HashTableLink* HashTableLink() + { + return &fHashLink; + } + +private: + char* fName; + vint32 fRefCount; + sem_id fID; + uid_t fUID; + gid_t fGID; + mode_t fPermissions; + + ::HashTableLink fHashLink; +}; + + +struct NamedSemHashDefinition { + typedef const char* KeyType; + typedef SemInfo ValueType; + + size_t HashKey(const KeyType& key) const + { + return hash_hash_string(key); + } + + size_t Hash(SemInfo* semaphore) const + { + return HashKey(semaphore->Name()); + } + + bool Compare(const KeyType& key, SemInfo* semaphore) const + { + return strcmp(key, semaphore->Name()) == 0; + } + + HashTableLink* GetLink(SemInfo* semaphore) const + { + return semaphore->HashTableLink(); + } +}; + + +class GlobalRealtimeSemTable { +public: + GlobalRealtimeSemTable() + { + mutex_init(&fLock, "global realtime sem table"); + } + + ~GlobalRealtimeSemTable() + { + mutex_destroy(&fLock); + } + + status_t Init() + { + return fSemaphores.InitCheck(); + } + + status_t OpenSem(const char* name, int openFlags, mode_t mode, + uint32 semCount, SemInfo*& _sem, bool& _created) + { + MutexLocker _(fLock); + + SemInfo* sem = fSemaphores.Lookup(name); + if (sem != NULL) { + if ((openFlags & O_EXCL) != 0) + return EEXIST; + + if (!sem->HasPermissions()) + return EACCES; + + sem->AcquireReference(); + _sem = sem; + _created = false; + return B_OK; + } + + if ((openFlags & O_CREAT) == 0) + return ENOENT; + + // does not exist yet -- create + sem = new(std::nothrow) SemInfo; + if (sem == NULL) + return B_NO_MEMORY; + + status_t error = sem->Init(name, mode, semCount); + if (error != B_OK) { + delete sem; + return error; + } + + error = fSemaphores.Insert(sem); + if (error != B_OK) { + delete sem; + return error; + } + + // add one reference for the table + sem->AcquireReference(); + + _sem = sem; + _created = true; + return B_OK; + } + + status_t UnlinkSem(const char* name) + { + MutexLocker _(fLock); + + SemInfo* sem = fSemaphores.Lookup(name); + if (sem == NULL) + return ENOENT; + + if (!sem->HasPermissions()) + return EACCES; + + fSemaphores.Remove(sem); + sem->ReleaseReference(); + // release the table reference + + return B_OK; + } + +private: + typedef OpenHashTable SemTable; + + mutex fLock; + SemTable fSemaphores; +}; + + +static GlobalRealtimeSemTable sSemTable; + + +class TeamSemInfo { +public: + TeamSemInfo(SemInfo* semaphore, sem_t* userSem) + : + fSemaphore(semaphore), + fUserSemaphore(userSem), + fOpenCount(1) + { + } + + ~TeamSemInfo() + { + if (fSemaphore != NULL) + fSemaphore->ReleaseReference(); + } + + SemInfo* Semaphore() const { return fSemaphore; } + sem_t* UserSemaphore() const { return fUserSemaphore; } + + void Open() + { + fOpenCount++; + } + + bool Close() + { + return --fOpenCount == 0; + } + + TeamSemInfo* Clone() const + { + TeamSemInfo* sem = new(std::nothrow) TeamSemInfo(fSemaphore, + fUserSemaphore); + if (sem == NULL) + return NULL; + + sem->fOpenCount = fOpenCount; + fSemaphore->AcquireReference(); + + return sem; + } + + HashTableLink* HashTableLink() + { + return &fHashLink; + } + +private: + SemInfo* fSemaphore; + sem_t* fUserSemaphore; + int32 fOpenCount; + + ::HashTableLink fHashLink; +}; + + +struct TeamSemHashDefinition { + typedef sem_id KeyType; + typedef TeamSemInfo ValueType; + + size_t HashKey(const KeyType& key) const + { + return (size_t)key; + } + + size_t Hash(TeamSemInfo* semaphore) const + { + return HashKey(semaphore->Semaphore()->ID()); + } + + bool Compare(const KeyType& key, TeamSemInfo* semaphore) const + { + return key == semaphore->Semaphore()->ID(); + } + + HashTableLink* GetLink(TeamSemInfo* semaphore) const + { + return semaphore->HashTableLink(); + } +}; + + +struct realtime_sem_context { + realtime_sem_context() + { + mutex_init(&fLock, "realtime sem context"); + } + + ~realtime_sem_context() + { + mutex_lock(&fLock); + + // delete all semaphores. + SemTable::Iterator it = fSemaphores.GetIterator(); + while (TeamSemInfo* sem = it.Next()) { + // Note, this uses internal knowledge about how the iterator works. + // Ugly, but there's no good alternative. + fSemaphores.RemoveUnchecked(sem); + delete sem; + } + + mutex_destroy(&fLock); + } + + status_t Init() + { + return fSemaphores.InitCheck(); + } + + realtime_sem_context* Clone() + { + // create new context + realtime_sem_context* context = new(std::nothrow) realtime_sem_context; + if (context == NULL) + return NULL; + ObjectDeleter contextDeleter(context); + + MutexLocker _(fLock); + + // clone all semaphores + SemTable::Iterator it = fSemaphores.GetIterator(); + while (TeamSemInfo* sem = it.Next()) { + TeamSemInfo* clonedSem = sem->Clone(); + if (clonedSem == NULL) + return NULL; + + if (context->fSemaphores.Insert(clonedSem) != B_OK) { + delete clonedSem; + return NULL; + } + } + + contextDeleter.Detach(); + return context; + } + + status_t CreateAnonymousSem(uint32 semCount, int& _id) + { + SemInfo* sem = new(std::nothrow) SemInfo; + if (sem == NULL) + return B_NO_MEMORY; + ObjectDeleter semDeleter(sem); + + status_t error = sem->Init(NULL, 0, semCount); + if (error != B_OK) { + delete sem; + return error; + } + + TeamSemInfo* teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); + if (teamSem == NULL) + return B_NO_MEMORY; + semDeleter.Detach(); + + MutexLocker _(fLock); + + error = fSemaphores.Insert(teamSem); + if (error != B_OK) { + delete teamSem; + return error; + } + + _id = teamSem->Semaphore()->ID(); + + return B_OK; + } + + status_t OpenSem(const char* name, int openFlags, mode_t mode, + uint32 semCount, sem_t* userSem, sem_t*& _usedUserSem, int& _id, + bool& _created) + { + SemInfo* sem; + status_t error = sSemTable.OpenSem(name, openFlags, mode, semCount, + sem, _created); + if (error != B_OK) + return error; + + MutexLocker _(fLock); + + TeamSemInfo* teamSem = fSemaphores.Lookup(sem->ID()); + if (teamSem != NULL) { + // already open -- just increment the open count + teamSem->Open(); + sem->ReleaseReference(); + _usedUserSem = teamSem->UserSemaphore(); + _id = teamSem->Semaphore()->ID(); + return B_OK; + } + + // not open yet -- create a new team sem + teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); + if (teamSem == NULL) { + sem->ReleaseReference(); + return B_NO_MEMORY; + } + + error = fSemaphores.Insert(teamSem); + if (error != B_OK) { + delete teamSem; + return error; + } + + _usedUserSem = teamSem->UserSemaphore(); + _id = teamSem->Semaphore()->ID(); + + return B_OK; + } + + status_t CloseSem(sem_id id, sem_t*& deleteUserSem) + { + deleteUserSem = NULL; + + MutexLocker _(fLock); + + TeamSemInfo* sem = fSemaphores.Lookup(id); + if (sem == NULL) + return B_BAD_VALUE; + + if (sem->Close()) { + // last reference closed + fSemaphores.Remove(sem); + deleteUserSem = sem->UserSemaphore(); + delete sem; + } + + return B_OK; + } + + status_t AcquireSem(sem_id id, bigtime_t timeout) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + status_t error; + if (timeout == 0) { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, + 0); + } else if (timeout == B_INFINITE_TIMEOUT) { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT, 0); + } else { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT, + timeout); + } + + return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; + } + + status_t ReleaseSem(sem_id id) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + status_t error = release_sem(id); + return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; + } + + status_t GetSemCount(sem_id id, int& _count) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + int32 count; + status_t error = get_sem_count(id, &count); + if (error != B_OK) + return error; + + _count = count; + return B_OK; + } + +private: + typedef OpenHashTable SemTable; + + mutex fLock; + SemTable fSemaphores; +}; + + +// #pragma mark - implementation private + + +static realtime_sem_context* +get_current_team_context() +{ + struct team* team = thread_get_current_thread()->team; + + // get context + realtime_sem_context* context = atomic_pointer_get( + &team->realtime_sem_context); + if (context != NULL) + return context; + + // no context yet -- create a new one + context = new(std::nothrow) realtime_sem_context; + if (context == NULL || context->Init() != B_OK) { + delete context; + return NULL; + } + + // set the allocated context + realtime_sem_context* oldContext = atomic_pointer_test_and_set( + &team->realtime_sem_context, context, (realtime_sem_context*)NULL); + if (oldContext == NULL) + return context; + + // someone else was quicker + delete context; + return oldContext; +} + + +static status_t +copy_sem_name_to_kernel(const char* userName, KPath& buffer, char*& name) +{ + if (userName == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userName)) + return B_BAD_ADDRESS; + + if (buffer.InitCheck() != B_OK) + return B_NO_MEMORY; + + // copy userland path to kernel + name = buffer.LockBuffer(); + ssize_t actualLength = user_strlcpy(name, userName, buffer.BufferSize()); + + if (actualLength < 0) + return B_BAD_ADDRESS; + if ((size_t)actualLength >= buffer.BufferSize()) + return ENAMETOOLONG; + + return B_OK; +} + + +// #pragma mark - kernel internal + + +void +realtime_sem_init() +{ + new(&sSemTable) GlobalRealtimeSemTable; + if (sSemTable.Init() != B_OK) + panic("realtime_sem_init() failed to init global table"); +} + + +void +delete_realtime_sem_context(realtime_sem_context* context) +{ + delete context; +} + + +realtime_sem_context* +clone_realtime_sem_context(realtime_sem_context* context) +{ + if (context == NULL) + return NULL; + + return context->Clone(); +} + + +// #pragma mark - syscalls + + +status_t +_user_realtime_sem_open(const char* userName, int openFlags, mode_t mode, + uint32 semCount, sem_t* userSem, sem_t** _usedUserSem) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_NO_MEMORY; + + // userSem must always be given + if (userSem == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userSem)) + return B_BAD_ADDRESS; + + // anonymous semaphores are less work -- deal with them first + if (userName == NULL) { + int id; + status_t error = context->CreateAnonymousSem(semCount, id); + if (error != B_OK) + return error; + + if (user_memcpy(&userSem->id, &id, sizeof(int)) != B_OK) { + sem_t* dummy; + context->CloseSem(id, dummy); + return B_BAD_ADDRESS; + } + + return B_OK; + } + + // check user pointers + if (_usedUserSem == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(_usedUserSem) || !IS_USER_ADDRESS(userName)) + return B_BAD_ADDRESS; + + // copy name to kernel + KPath nameBuffer(B_PATH_NAME_LENGTH); + char* name; + status_t error = copy_sem_name_to_kernel(userName, nameBuffer, name); + if (error != B_OK) + return error; + + // open the semaphore + sem_t* usedUserSem; + bool created; + int id; + error = context->OpenSem(name, openFlags, mode, semCount, userSem, + usedUserSem, id, created); + if (error != B_OK) + return error; + + // copy results back to userland + if (user_memcpy(&userSem->id, &id, sizeof(int)) != B_OK + || user_memcpy(_usedUserSem, &usedUserSem, sizeof(sem_t*)) != B_OK) { + if (created) + sSemTable.UnlinkSem(name); + sem_t* dummy; + context->CloseSem(id, dummy); + return B_BAD_ADDRESS; + } + + return B_OK; +} + + +status_t +_user_realtime_sem_close(sem_id semID, sem_t** _deleteUserSem) +{ + if (_deleteUserSem != NULL && !IS_USER_ADDRESS(_deleteUserSem)) + return B_BAD_ADDRESS; + + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + // close sem + sem_t* deleteUserSem; + status_t error = context->CloseSem(semID, deleteUserSem); + if (error != B_OK) + return error; + + // copy back result to userland + if (_deleteUserSem != NULL + && user_memcpy(_deleteUserSem, &deleteUserSem, sizeof(sem_t*)) + != B_OK) { + return B_BAD_ADDRESS; + } + + return B_OK; +} + + +status_t +_user_realtime_sem_unlink(const char* userName) +{ + // copy name to kernel + KPath nameBuffer(B_PATH_NAME_LENGTH); + char* name; + status_t error = copy_sem_name_to_kernel(userName, nameBuffer, name); + if (error != B_OK) + return error; + + return sSemTable.UnlinkSem(name); +} + + +status_t +_user_realtime_sem_get_value(sem_id semID, int* _value) +{ + if (_value == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(_value)) + return B_BAD_ADDRESS; + + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + // get sem count + int count; + status_t error = context->GetSemCount(semID, count); + if (error != B_OK) + return error; + + // copy back result to userland + if (user_memcpy(_value, &count, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + return B_OK; +} + + +status_t +_user_realtime_sem_post(sem_id semID) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + return context->ReleaseSem(semID); +} + + +status_t +_user_realtime_sem_wait(sem_id semID, bigtime_t timeout) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + return syscall_restart_handle_post(context->AcquireSem(semID, timeout)); +} Modified: haiku/trunk/src/system/kernel/sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/sem.cpp 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/sem.cpp 2008-05-06 03:39:36 UTC (rev 25326) @@ -301,7 +301,7 @@ status_t -sem_init(kernel_args *args) +haiku_sem_init(kernel_args *args) { area_id area; int32 i; Modified: haiku/trunk/src/system/kernel/syscalls.cpp =================================================================== --- haiku/trunk/src/system/kernel/syscalls.cpp 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/syscalls.cpp 2008-05-06 03:39:36 UTC (rev 25326) @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-06 03:30:48 UTC (rev 25325) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-06 03:39:36 UTC (rev 25326) @@ -26,6 +26,7 @@ #include #include #include +#include #include [... truncated: 210 lines follow ...] From axeld at pinc-software.de Tue May 6 10:26:42 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 06 May 2008 10:26:42 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25326_-_in_haiku/trunk=3A_headers/posi?= =?utf-8?q?x_headers/private/kernel_src/system/kernel_src/system/libroot/p?= =?utf-8?q?osix?= In-Reply-To: <200805060339.m463dbJg000585@sheep.berlios.de> Message-ID: <1256875083-BeMail@zon> bonefish at BerliOS wrote: > - sem_init(&sKernelArgs); > + haiku_sem_init(&sKernelArgs); Nice one! But is there any actual need to rename this one? At least I would rather stay consistent there with the other sem_* functions. Maybe we want to move the XSI realtime semaphores into a posix/ subdirectory or something like that when we have more of those files? The kernel directory is already quite crowded, and I would like to separate core Haiku services from POSIX only ones. Bye, Axel. From axeld at pinc-software.de Tue May 6 14:00:29 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 06 May 2008 14:00:29 +0200 CEST Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <200805041319.m44DJvjG004057@sheep.berlios.de> Message-ID: <14083707318-BeMail@zon> bonefish at BerliOS wrote: > Log: > Added OpenSSH optional package. The daemon has to be started manually > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. Me neither, but if you can run it as an inetd service as well, you could add a few lines in "services" to make it work automatically. Bye, Axel. From ingo_weinhold at gmx.de Tue May 6 21:21:20 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 06 May 2008 21:21:20 +0200 Subject: [Haiku-commits] r25326 - in haiku/trunk: headers/posix headers/private/kernel src/system/kernel src/system/libroot/posix In-Reply-To: <1256875083-BeMail@zon> References: <1256875083-BeMail@zon> Message-ID: <20080506212120.495.1@knochen-vm.1210100255.fake> On 2008-05-06 at 10:26:42 [+0200], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > - sem_init(&sKernelArgs); > > + haiku_sem_init(&sKernelArgs); > > Nice one! But is there any actual need to rename this one? Yep, it clashed with the sem_init() declared in , which is included in for the sem_t type (which is a typedef, not a struct ATM). I could have avoided that by using void* and casting from and to sem_t*, but I found renaming the private sem_init() the better option. We might want to consider pulling type and macro definitions out of public headers into separate headers to eliminate unnecessary dependencies. That would have helped in this case, too. > At least I > would rather stay consistent there with the other sem_* functions. > Maybe we want to move the XSI realtime semaphores into a posix/ > subdirectory or something like that when we have more of those files? > The kernel directory is already quite crowded, and I would like to > separate core Haiku services from POSIX only ones. Good idea. Will do that. CU, Ingo From ingo_weinhold at gmx.de Tue May 6 21:25:43 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 06 May 2008 21:25:43 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <14083707318-BeMail@zon> References: <14083707318-BeMail@zon> Message-ID: <20080506212543.538.2@knochen-vm.1210100255.fake> On 2008-05-06 at 14:00:29 [+0200], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > Log: > > Added OpenSSH optional package. The daemon has to be started manually > > (just "sshd"), ATM. Not sure how we want to deal with daemons, yet. > > Me neither, but if you can run it as an inetd service as well, you > could add a few lines in "services" to make it work automatically. sshd can be run as an inetd service, but at least the man page recommends to run it as daemon, since it has to generate server keys on startup, which may take some time. BTW, to run it as an inetd service one would have to pass a parameter ("-i"), which our net server doesn't support ATM. CU, Ingo From korli at mail.berlios.de Tue May 6 23:07:21 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 6 May 2008 23:07:21 +0200 Subject: [Haiku-commits] r25327 - haiku/trunk/src/servers/input Message-ID: <200805062107.m46L7LUu005756@sheep.berlios.de> Author: korli Date: 2008-05-06 23:07:21 +0200 (Tue, 06 May 2008) New Revision: 25327 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25327&view=rev Modified: haiku/trunk/src/servers/input/InputServer.cpp haiku/trunk/src/servers/input/Jamfile Log: B_SAFEMODE_DISABLE_USER_ADD_ONS is also a safe mode we now honor Modified: haiku/trunk/src/servers/input/InputServer.cpp =================================================================== --- haiku/trunk/src/servers/input/InputServer.cpp 2008-05-06 03:39:36 UTC (rev 25326) +++ haiku/trunk/src/servers/input/InputServer.cpp 2008-05-06 21:07:21 UTC (rev 25327) @@ -10,6 +10,8 @@ #include "kb_mouse_driver.h" #include "MethodReplicant.h" +#include + #include #include @@ -25,7 +27,6 @@ #include #include #include -#include #include @@ -163,6 +164,19 @@ fSafeMode = true; } +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#else + if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#endif + { + if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") + || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") + || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) + fSafeMode = true; + } + + gDeviceManager.LoadState(); #ifndef HAIKU_TARGET_PLATFORM_HAIKU Modified: haiku/trunk/src/servers/input/Jamfile =================================================================== --- haiku/trunk/src/servers/input/Jamfile 2008-05-06 03:39:36 UTC (rev 25326) +++ haiku/trunk/src/servers/input/Jamfile 2008-05-06 21:07:21 UTC (rev 25327) @@ -30,7 +30,7 @@ AddResources input_server : input_server.rdef ; -UsePrivateHeaders app input interface shared storage ; +UsePrivateHeaders app input interface kernel shared storage ; SubDirC++Flags -DADD_ON_STABLE_SECONDS=1 ; # for AddOnMonitorHandler.cpp From stippi at mail.berlios.de Tue May 6 23:11:53 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 6 May 2008 23:11:53 +0200 Subject: [Haiku-commits] r25328 - haiku/trunk/src/preferences/network Message-ID: <200805062111.m46LBrAO006529@sheep.berlios.de> Author: stippi Date: 2008-05-06 23:11:53 +0200 (Tue, 06 May 2008) New Revision: 25328 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25328&view=rev Added: haiku/trunk/src/preferences/network/Network.rdef Modified: haiku/trunk/src/preferences/network/Jamfile Log: Add proper RDef file so the Network prefelt is known to the system as an application. NOTE: Using FileTypes within Haiku to set this properties does not result in other applications to be able to use BRoster::Launch() with the given signature. The error message will change from "Application not found" to "No application found to handle this file type" (or the like). Modified: haiku/trunk/src/preferences/network/Jamfile =================================================================== --- haiku/trunk/src/preferences/network/Jamfile 2008-05-06 21:07:21 UTC (rev 25327) +++ haiku/trunk/src/preferences/network/Jamfile 2008-05-06 21:11:53 UTC (rev 25328) @@ -8,5 +8,6 @@ EthernetSettingsView.cpp settings.cpp : be root $(HAIKU_NETWORK_LIBS) + : Network.rdef ; Copied: haiku/trunk/src/preferences/network/Network.rdef (from rev 25177, haiku/trunk/src/preferences/network_old/Network.rdef) =================================================================== --- haiku/trunk/src/preferences/network_old/Network.rdef 2008-04-26 12:16:53 UTC (rev 25177) +++ haiku/trunk/src/preferences/network/Network.rdef 2008-05-06 21:11:53 UTC (rev 25328) @@ -0,0 +1,16 @@ + +resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Haiku-Network"; + +resource app_flags B_SINGLE_LAUNCH; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + variety = B_APPV_DEVELOPMENT, + internal = 0, + + short_info = "Network", + long_info = "Network ?2007-2008 Haiku" +}; From stippi at mail.berlios.de Tue May 6 23:13:00 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 6 May 2008 23:13:00 +0200 Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus Message-ID: <200805062113.m46LD0CS006778@sheep.berlios.de> Author: stippi Date: 2008-05-06 23:13:00 +0200 (Tue, 06 May 2008) New Revision: 25329 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25329&view=rev Modified: haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp haiku/trunk/src/apps/networkstatus/NetworkStatusView.h Log: Applied patch by Dario Casalinuovo with some changes by myself: The NetworkStatus applet is now able to launch the Network preferences via its contex menu. Modified: haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp =================================================================== --- haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp 2008-05-06 21:11:53 UTC (rev 25328) +++ haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp 2008-05-06 21:13:00 UTC (rev 25329) @@ -5,6 +5,7 @@ * Authors: * Axel D?rfler, axeld at pinc-software.de * Hugo Santos, hugosantos at gmail.com + * Dario Casalinuovo */ @@ -62,6 +63,8 @@ const uint32 kMinIconWidth = 16; const uint32 kMinIconHeight = 16; +const uint32 kOpenNetworkPref = 'onwp'; + const bigtime_t kUpdateInterval = 1000000; // every second @@ -232,6 +235,10 @@ _ShowConfiguration(message); break; + case kOpenNetworkPref: + _OpenNetworksPreferences(); + break; + case B_ABOUT_REQUESTED: _AboutRequested(); break; @@ -354,6 +361,9 @@ menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About NetworkStatus" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); + menu->AddItem(new BMenuItem("Open Networks Preferences" B_UTF8_ELLIPSIS, + new BMessage(kOpenNetworkPref))); + if (fInDeskbar) menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); @@ -466,6 +476,23 @@ } +void +NetworkStatusView::_OpenNetworksPreferences() +{ + status_t ret = be_roster->Launch("application/x-vnd.Haiku-Network"); + if (ret < B_OK) { + BString errorMessage("Launching the Network preflet failed.\n\n" + "Error: "); + errorMessage << strerror(ret); + BAlert* alert = new BAlert("launch error", errorMessage.String(), + "Ok"); + // asynchronous alert in order to not block replicant host + // application + alert->Go(NULL); + } +} + + // #pragma mark - Modified: haiku/trunk/src/apps/networkstatus/NetworkStatusView.h =================================================================== --- haiku/trunk/src/apps/networkstatus/NetworkStatusView.h 2008-05-06 21:11:53 UTC (rev 25328) +++ haiku/trunk/src/apps/networkstatus/NetworkStatusView.h 2008-05-06 21:13:00 UTC (rev 25329) @@ -4,6 +4,7 @@ * * Authors: * Axel D?rfler, axeld at pinc-software.de + * Dario Casalinuovo */ #ifndef NETWORK_STATUS_VIEW_H #define NETWORK_STATUS_VIEW_H @@ -53,6 +54,7 @@ const char* name); int32 _DetermineInterfaceStatus(const char* name); void _Update(bool force = false); + void _OpenNetworksPreferences(); BMessageRunner* fMessageRunner; BObjectList fInterfaces; From axeld at pinc-software.de Tue May 6 23:15:04 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 06 May 2008 23:15:04 +0200 CEST Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080506212543.538.2@knochen-vm.1210100255.fake> Message-ID: <47358340076-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-06 at 14:00:29 [+0200], Axel D?rfler > > wrote: > > bonefish at BerliOS wrote: > > > Log: > > > Added OpenSSH optional package. The daemon has to be started > > > manually > > > (just "sshd"), ATM. Not sure how we want to deal with daemons, > > > yet. > > Me neither, but if you can run it as an inetd service as well, you > > could add a few lines in "services" to make it work automatically. > sshd can be run as an inetd service, but at least the man page > recommends > to run it as daemon, since it has to generate server keys on startup, > which > may take some time. BTW, to run it as an inetd service one would have > to > pass a parameter ("-i"), which our net server doesn't support ATM. What lazy bastard has written that piece of junk? :-) Anyway, that would indeed sound like a very good reason not to run sshd as an inetd like service (the delay, not the parameter :-)). Bye, Axel. From korli at mail.berlios.de Tue May 6 23:18:31 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 6 May 2008 23:18:31 +0200 Subject: [Haiku-commits] r25330 - haiku/trunk/src/servers/input Message-ID: <200805062118.m46LIVei008154@sheep.berlios.de> Author: korli Date: 2008-05-06 23:18:31 +0200 (Tue, 06 May 2008) New Revision: 25330 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25330&view=rev Modified: haiku/trunk/src/servers/input/AddOnManager.cpp haiku/trunk/src/servers/input/AddOnManager.h Log: when no input method is found but the replicant was loaded, we now unload it Modified: haiku/trunk/src/servers/input/AddOnManager.cpp =================================================================== --- haiku/trunk/src/servers/input/AddOnManager.cpp 2008-05-06 21:13:00 UTC (rev 25329) +++ haiku/trunk/src/servers/input/AddOnManager.cpp 2008-05-06 21:18:31 UTC (rev 25330) @@ -477,6 +477,13 @@ void +AddOnManager::UnloadReplicant() +{ + BDeskbar().RemoveItem(REPLICANT_CTL_NAME); +} + + +void AddOnManager::LoadReplicant() { CALLED(); @@ -756,6 +763,12 @@ AddOnManager::HandleMethodReplicant(BMessage* message, BMessage* reply) { CALLED(); + + if (InputServer::gInputMethodList.CountItems() == 0) { + UnloadReplicant(); + return B_OK; + } + LoadReplicant(); BAutolock lock(InputServer::gInputMethodListLocker); Modified: haiku/trunk/src/servers/input/AddOnManager.h =================================================================== --- haiku/trunk/src/servers/input/AddOnManager.h 2008-05-06 21:13:00 UTC (rev 25329) +++ haiku/trunk/src/servers/input/AddOnManager.h 2008-05-06 21:18:31 UTC (rev 25330) @@ -51,6 +51,7 @@ status_t HandleNodeMonitor(BMessage*); void LoadReplicant(); + void UnloadReplicant(); int32 GetReplicantAt(BMessenger target, int32 index) const; status_t GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const; status_t GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const; From korli at mail.berlios.de Tue May 6 23:23:24 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 6 May 2008 23:23:24 +0200 Subject: [Haiku-commits] r25331 - haiku/trunk/src/bin Message-ID: <200805062123.m46LNOxt010141@sheep.berlios.de> Author: korli Date: 2008-05-06 23:23:24 +0200 (Tue, 06 May 2008) New Revision: 25331 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25331&view=rev Modified: haiku/trunk/src/bin/waitfor.c Log: fix mmu_man's name Modified: haiku/trunk/src/bin/waitfor.c =================================================================== --- haiku/trunk/src/bin/waitfor.c 2008-05-06 21:18:31 UTC (rev 25330) +++ haiku/trunk/src/bin/waitfor.c 2008-05-06 21:23:24 UTC (rev 25331) @@ -1,5 +1,5 @@ /* waitfor.c - waits for a given threadname - * (c) 2002, Fran?ois Revol (mmu_man) for OpenBeOS + * (c) 2002, Fran??ois Revol (mmu_man) for OpenBeOS * released under the MIT licence. * * ChangeLog: From axeld at pinc-software.de Tue May 6 23:25:07 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 06 May 2008 23:25:07 +0200 CEST Subject: [Haiku-commits] r25326 - in haiku/trunk: headers/posix headers/private/kernel src/system/kernel src/system/libroot/posix In-Reply-To: <20080506212120.495.1@knochen-vm.1210100255.fake> Message-ID: <47961959482-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-06 at 10:26:42 [+0200], Axel D?rfler > > wrote: > > bonefish at BerliOS wrote: > > > - sem_init(&sKernelArgs); > > > + haiku_sem_init(&sKernelArgs); > > > > Nice one! But is there any actual need to rename this one? > Yep, it clashed with the sem_init() declared in , which > is > included in for the sem_t type (which is a typedef, > not a > struct ATM). I could have avoided that by using void* and casting > from and > to sem_t*, but I found renaming the private sem_init() the better > option. Hm... C++ linkage would have helped, too ;-) > We might want to consider pulling type and macro definitions out of > public > headers into separate headers to eliminate unnecessary dependencies. > That > would have helped in this case, too. I don't know - this sounds like a lot of duplicated work with potential errors. > > At least I > > would rather stay consistent there with the other sem_* functions. > > Maybe we want to move the XSI realtime semaphores into a posix/ > > subdirectory or something like that when we have more of those > > files? > > The kernel directory is already quite crowded, and I would like to > > separate core Haiku services from POSIX only ones. > Good idea. Will do that. Thanks! Bye, Axel. From axeld at pinc-software.de Tue May 6 23:28:59 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 06 May 2008 23:28:59 +0200 CEST Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus In-Reply-To: <200805062113.m46LD0CS006778@sheep.berlios.de> Message-ID: <48193766389-BeMail@zon> stippi at BerliOS wrote: > const uint32 kMinIconWidth = 16; > const uint32 kMinIconHeight = 16; > > +const uint32 kOpenNetworkPref = 'onwp'; > + Can this please a) grouped with the other message constants, and b) get the "Msg" prefix, too? I wouldn't even mind writing out Preferences ;-) Bye, Axel. From anevilyak at gmail.com Tue May 6 23:30:57 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Tue, 6 May 2008 16:30:57 -0500 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <47358340076-BeMail@zon> References: <20080506212543.538.2@knochen-vm.1210100255.fake> <47358340076-BeMail@zon> Message-ID: On Tue, May 6, 2008 at 4:15 PM, Axel D?rfler wrote: > > What lazy bastard has written that piece of junk? :-) > Anyway, that would indeed sound like a very good reason not to run sshd > as an inetd like service (the delay, not the parameter :-)). > > Bye, > Axel. > That delay only happens on first run doesn't it? It doesn't have to regenerate keys on every single startup does it? Regards, Rene From korli at mail.berlios.de Tue May 6 23:39:32 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 6 May 2008 23:39:32 +0200 Subject: [Haiku-commits] r25332 - haiku/trunk/src/kits/translation Message-ID: <200805062139.m46LdWjJ019095@sheep.berlios.de> Author: korli Date: 2008-05-06 23:39:31 +0200 (Tue, 06 May 2008) New Revision: 25332 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25332&view=rev Modified: haiku/trunk/src/kits/translation/Jamfile haiku/trunk/src/kits/translation/TranslatorRoster.cpp Log: B_SAFEMODE_DISABLE_USER_ADD_ONS is also a safe mode we now honor in translation kit Modified: haiku/trunk/src/kits/translation/Jamfile =================================================================== --- haiku/trunk/src/kits/translation/Jamfile 2008-05-06 21:23:24 UTC (rev 25331) +++ haiku/trunk/src/kits/translation/Jamfile 2008-05-06 21:39:31 UTC (rev 25332) @@ -7,7 +7,7 @@ UsePublicHeaders translation ; } -UsePrivateHeaders translation textencoding ; +UsePrivateHeaders kernel translation textencoding ; SharedLibrary libtranslation.so : BitmapStream.cpp Modified: haiku/trunk/src/kits/translation/TranslatorRoster.cpp =================================================================== --- haiku/trunk/src/kits/translation/TranslatorRoster.cpp 2008-05-06 21:23:24 UTC (rev 25331) +++ haiku/trunk/src/kits/translation/TranslatorRoster.cpp 2008-05-06 21:39:31 UTC (rev 25332) @@ -17,12 +17,13 @@ #include "FuncTranslator.h" #include "TranslatorRosterPrivate.h" +#include +#include + #include #include #include #include -#include -#include #include #include #include @@ -152,6 +153,18 @@ || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) fSafeMode = true; } + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#else + if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#endif + { + if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") + || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") + || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) + fSafeMode = true; + } // we're sneaking us into the BApplication if (be_app != NULL && be_app->Lock()) { From leavengood at gmail.com Tue May 6 23:41:06 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 6 May 2008 17:41:06 -0400 Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus In-Reply-To: <48193766389-BeMail@zon> References: <200805062113.m46LD0CS006778@sheep.berlios.de> <48193766389-BeMail@zon> Message-ID: On Tue, May 6, 2008 at 5:28 PM, Axel D?rfler wrote: > stippi at BerliOS wrote: > > const uint32 kMinIconWidth = 16; > > const uint32 kMinIconHeight = 16; > > > > +const uint32 kOpenNetworkPref = 'onwp'; > > + > > Can this please a) grouped with the other message constants, and b) get > the "Msg" prefix, too? I wouldn't even mind writing out Preferences ;-) This might be something nice to be specific about in our Coding Guidelines. I have noticed the above sometimes (kDoSomething) and sometimes MSG_DO_SOMETHING inside enums and I guess MsgWhatever sometimes too. Is MsgWhatever the preferred approach? Should be specify a preference of enums over const uint32 or vice versa? Ryan From anevilyak at gmail.com Tue May 6 23:43:10 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Tue, 6 May 2008 16:43:10 -0500 Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus In-Reply-To: References: <200805062113.m46LD0CS006778@sheep.berlios.de> <48193766389-BeMail@zon> Message-ID: On Tue, May 6, 2008 at 4:41 PM, Ryan Leavengood wrote: > > This might be something nice to be specific about in our Coding > Guidelines. I have noticed the above sometimes (kDoSomething) and > sometimes MSG_DO_SOMETHING inside enums and I guess MsgWhatever > sometimes too. Is MsgWhatever the preferred approach? Should be > specify a preference of enums over const uint32 or vice versa? > If I understand Axel right he means kMsgOpenNetworkPrefs, no? Regards, Rene From leavengood at gmail.com Tue May 6 23:50:08 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 6 May 2008 17:50:08 -0400 Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus In-Reply-To: References: <200805062113.m46LD0CS006778@sheep.berlios.de> <48193766389-BeMail@zon> Message-ID: On Tue, May 6, 2008 at 5:43 PM, Rene Gollent wrote: > > If I understand Axel right he means kMsgOpenNetworkPrefs, no? Ah, OK. My question about const uint32 versus enum still stands. Ryan From korli at mail.berlios.de Tue May 6 23:58:07 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 6 May 2008 23:58:07 +0200 Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl Message-ID: <200805062158.m46Lw7xo025702@sheep.berlios.de> Author: korli Date: 2008-05-06 23:58:07 +0200 (Tue, 06 May 2008) New Revision: 25333 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25333&view=rev Modified: haiku/trunk/src/kits/opengl/GLRendererRoster.cpp haiku/trunk/src/kits/opengl/GLRendererRoster.h haiku/trunk/src/kits/opengl/Jamfile Log: we honor safe modes for GL addons too. maybe this should end somewhere in libbe and a userland safemode.h Modified: haiku/trunk/src/kits/opengl/GLRendererRoster.cpp =================================================================== --- haiku/trunk/src/kits/opengl/GLRendererRoster.cpp 2008-05-06 21:39:31 UTC (rev 25332) +++ haiku/trunk/src/kits/opengl/GLRendererRoster.cpp 2008-05-06 21:58:07 UTC (rev 25333) @@ -5,9 +5,11 @@ * Authors: */ +#include +#include + #include #include -#include #include #include #include "GLDispatcher.h" @@ -17,13 +19,49 @@ #include +#ifdef HAIKU_TARGET_PLATFORM_HAIKU +extern "C" status_t _kern_get_safemode_option(const char *parameter, + char *buffer, size_t *_bufferSize); +#else +extern "C" status_t _kget_safemode_option_(const char *parameter, + char *buffer, size_t *_bufferSize); +#endif + GLRendererRoster::GLRendererRoster(BGLView *view, ulong options) : fNextID(0), fView(view), - fOptions(options) + fOptions(options), + fSafeMode(false) { - AddDefaultPaths(); + char parameter[32]; + size_t parameterLength = sizeof(parameter); + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK) +#else + if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter, ¶meterLength) == B_OK) +#endif + { + if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") + || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") + || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) + fSafeMode = true; + } + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#else + if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, ¶meterLength) == B_OK) +#endif + { + if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on") + || !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes") + || !strcasecmp(parameter, "enable") || !strcmp(parameter, "1")) + fSafeMode = true; + } + + AddDefaultPaths(); } @@ -55,7 +93,7 @@ B_BEOS_ADDONS_DIRECTORY, }; - for (uint32 i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) { + for (uint32 i = fSafeMode ? 2 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) { BPath path; status_t status = find_directory(paths[i], &path, true); if (status == B_OK && path.Append("opengl") == B_OK) Modified: haiku/trunk/src/kits/opengl/GLRendererRoster.h =================================================================== --- haiku/trunk/src/kits/opengl/GLRendererRoster.h 2008-05-06 21:39:31 UTC (rev 25332) +++ haiku/trunk/src/kits/opengl/GLRendererRoster.h 2008-05-06 21:58:07 UTC (rev 25333) @@ -35,6 +35,7 @@ int32 fNextID; BGLView *fView; ulong fOptions; + bool fSafeMode; }; #endif /* _GLRENDERER_ROSTER_H */ Modified: haiku/trunk/src/kits/opengl/Jamfile =================================================================== --- haiku/trunk/src/kits/opengl/Jamfile 2008-05-06 21:39:31 UTC (rev 25332) +++ haiku/trunk/src/kits/opengl/Jamfile 2008-05-06 21:58:07 UTC (rev 25333) @@ -2,7 +2,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -UsePrivateHeaders opengl ; +UsePrivateHeaders kernel opengl ; if $(TARGET_PLATFORM) != haiku { UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ; From korli at mail.berlios.de Wed May 7 00:04:25 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 7 May 2008 00:04:25 +0200 Subject: [Haiku-commits] r25334 - in haiku/trunk: headers/private/kernel src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86 Message-ID: <200805062204.m46M4PVV026566@sheep.berlios.de> Author: korli Date: 2008-05-07 00:04:25 +0200 (Wed, 07 May 2008) New Revision: 25334 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25334&view=rev Modified: haiku/trunk/headers/private/kernel/safemode.h haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp haiku/trunk/src/system/kernel/arch/x86/apm.cpp Log: added B_SAFEMODE_DISABLE_APM Modified: haiku/trunk/headers/private/kernel/safemode.h =================================================================== --- haiku/trunk/headers/private/kernel/safemode.h 2008-05-06 21:58:07 UTC (rev 25333) +++ haiku/trunk/headers/private/kernel/safemode.h 2008-05-06 22:04:25 UTC (rev 25334) @@ -15,6 +15,7 @@ #define B_SAFEMODE_DISABLE_USER_ADD_ONS "disableuseraddons" #define B_SAFEMODE_DISABLE_IDE_DMA "disableidedma" #define B_SAFEMODE_DISABLE_ACPI "disable_acpi" +#define B_SAFEMODE_DISABLE_APM "disable_apm" #define B_SAFEMODE_DISABLE_SMP "disable_smp" #define B_SAFEMODE_DISABLE_HYPER_THREADING "disable_hyperthreading" #define B_SAFEMODE_FAIL_SAFE_VIDEO_MODE "fail_safe_video_mode" Modified: haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp 2008-05-06 21:58:07 UTC (rev 25333) +++ haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp 2008-05-06 22:04:25 UTC (rev 25334) @@ -35,7 +35,7 @@ menu->AddItem(item = new(nothrow) MenuItem("Disable APM")); item->SetType(MENU_ITEM_MARKABLE); - item->SetData("disable_apm"); + item->SetData(B_SAFEMODE_DISABLE_APM); item->SetHelpText("This overrides the APM setting in the kernel settings file"); menu->AddItem(item = new(nothrow) MenuItem("Disable ACPI")); Modified: haiku/trunk/src/system/kernel/arch/x86/apm.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/apm.cpp 2008-05-06 21:58:07 UTC (rev 25333) +++ haiku/trunk/src/system/kernel/arch/x86/apm.cpp 2008-05-06 22:04:25 UTC (rev 25334) @@ -291,7 +291,7 @@ handle = load_driver_settings(B_SAFEMODE_DRIVER_SETTINGS); if (handle != NULL) { - apm = !get_driver_boolean_parameter(handle, "disable_apm", !apm, !apm); + apm = !get_driver_boolean_parameter(handle, B_SAFEMODE_DISABLE_APM, !apm, !apm); unload_driver_settings(handle); } From stefano.ceccherini at gmail.com Wed May 7 00:07:37 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Wed, 7 May 2008 00:07:37 +0200 Subject: [Haiku-commits] r25334 - in haiku/trunk: headers/private/kernel src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86 In-Reply-To: <200805062204.m46M4PVV026566@sheep.berlios.de> References: <200805062204.m46M4PVV026566@sheep.berlios.de> Message-ID: <894b9700805061507p77a7ccbfw93a86d7b4a70bd9c@mail.gmail.com> 2008/5/7 korli at BerliOS : > Author: korli > Date: 2008-05-07 00:04:25 +0200 (Wed, 07 May 2008) > New Revision: 25334 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25334&view=rev > > Modified: > haiku/trunk/headers/private/kernel/safemode.h > haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp > haiku/trunk/src/system/kernel/arch/x86/apm.cpp > Log: > added B_SAFEMODE_DISABLE_APM > Since there is an option to disable this, maybe we should enable it by default in the kernel settings. From ingo_weinhold at gmx.de Wed May 7 00:19:12 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 07 May 2008 00:19:12 +0200 Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: <200805062158.m46Lw7xo025702@sheep.berlios.de> References: <200805062158.m46Lw7xo025702@sheep.berlios.de> Message-ID: <20080507001912.1403.8@knochen-vm.1210100255.fake> On 2008-05-06 at 23:58:07 [+0200], korli at BerliOS wrote: > Author: korli > Date: 2008-05-06 23:58:07 +0200 (Tue, 06 May 2008) > New Revision: 25333 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25333&view=rev > > Modified: > haiku/trunk/src/kits/opengl/GLRendererRoster.cpp > haiku/trunk/src/kits/opengl/GLRendererRoster.h > haiku/trunk/src/kits/opengl/Jamfile > Log: > we honor safe modes for GL addons too. maybe this should end somewhere in > libbe and a userland safemode.h I'd even consider it nicer not to check the safe-mode option everywhere. IMHO a small set of helper functions (respectively a helper class) for add-on loading should be provided. And it would simply use the ADDON_PATH environment variable, which would already reflect disabling of user add-ons, and would thus also respect the user's changes to the variable (why else would it be a variable in the first place?). CU, Ingo From ingo_weinhold at gmx.de Wed May 7 00:41:47 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 07 May 2008 00:41:47 +0200 Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: References: <20080506212543.538.2@knochen-vm.1210100255.fake> <47358340076-BeMail@zon> Message-ID: <20080507004147.1451.9@knochen-vm.1210100255.fake> On 2008-05-06 at 23:30:57 [+0200], Rene Gollent wrote: > On Tue, May 6, 2008 at 4:15 PM, Axel D?rfler wrote: > > > > What lazy bastard has written that piece of junk? :-) > > Anyway, that would indeed sound like a very good reason not to run sshd > > as an inetd like service (the delay, not the parameter :-)). > > That delay only happens on first run doesn't it? It doesn't have to > regenerate keys on every single startup does it? I'm not an ssh/ssl expert either, but AFAIK the "server keys" are a second key pair different from the "host keys". Both are used when initiating the connection. The server keys are volatile and regenerated periodically (default is every hour). When not running as a daemon they would need to be generated with every connection, though. Starting the daemon doesn't seem to cause any noticible CPU activity on my machine though. Maybe the "tens of seconds" for generating the server keys the man page speaks of don't really apply to modern hardware anymore. CU, Ingo From bonefish at mail.berlios.de Wed May 7 00:47:39 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 00:47:39 +0200 Subject: [Haiku-commits] r25335 - in haiku/trunk: build/jam data data/common data/common/boot data/common/boot/post_install data/common/settings data/etc data/system/boot Message-ID: <200805062247.m46MldJo025859@sheep.berlios.de> Author: bonefish Date: 2008-05-07 00:47:38 +0200 (Wed, 07 May 2008) New Revision: 25335 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25335&view=rev Added: haiku/trunk/data/common/ haiku/trunk/data/common/boot/ haiku/trunk/data/common/boot/post_install/ haiku/trunk/data/common/boot/post_install/mime_update.sh haiku/trunk/data/common/settings/ haiku/trunk/data/common/settings/fresh_install Removed: haiku/trunk/data/etc/post_install/ Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/OptionalPackages haiku/trunk/data/system/boot/Bootscript Log: Moved /etc/post_install to /boot/common/boot and the fresh_install marker file to /boot/common/settings. Repackaged OpenSSH accordingly. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-06 22:04:25 UTC (rev 25334) +++ haiku/trunk/build/jam/HaikuImage 2008-05-06 22:47:38 UTC (rev 25335) @@ -338,11 +338,14 @@ AddFilesToHaikuImage common settings network : $(networkSettingsFiles) ; # post install scripts and fresh install indicator file -local postInstallFiles = fresh_install mime_update.sh ; +local postInstallFiles = mime_update.sh ; postInstallFiles = $(postInstallFiles:G=post-install) ; SEARCH on $(postInstallFiles) - = [ FDirName $(HAIKU_TOP) data etc post_install ] ; -AddFilesToHaikuImage beos etc post_install : $(postInstallFiles) ; + = [ FDirName $(HAIKU_TOP) data common boot post_install ] ; +SEARCH on fresh_install + = [ FDirName $(HAIKU_TOP) data common settings ] ; +AddFilesToHaikuImage common boot post_install : $(postInstallFiles) ; +AddFilesToHaikuImage common settings : fresh_install ; # boot loader AddFilesToHaikuImage beos system : zbeos ; Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-06 22:04:25 UTC (rev 25334) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-06 22:47:38 UTC (rev 25335) @@ -167,8 +167,8 @@ Echo "No optional package OpenSSH available for gcc4" ; } else { local baseURL = http://haiku-files.org/files/optional-packages ; - InstallOptionalHaikuImagePackage openssh-5.0p1-gcc2-2008-05-04 - : $(baseURL)/openssh-5.0p1-gcc2-2008-05-04.zip + InstallOptionalHaikuImagePackage openssh-5.0p1-gcc2-2008-05-04-1 + : $(baseURL)/openssh-5.0p1-gcc2-2008-05-04-1.zip : ; Copied: haiku/trunk/data/common/boot/post_install/mime_update.sh (from rev 25309, haiku/trunk/data/etc/post_install/mime_update.sh) Copied: haiku/trunk/data/common/settings/fresh_install (from rev 25309, haiku/trunk/data/etc/post_install/fresh_install) Modified: haiku/trunk/data/system/boot/Bootscript =================================================================== --- haiku/trunk/data/system/boot/Bootscript 2008-05-06 22:04:25 UTC (rev 25334) +++ haiku/trunk/data/system/boot/Bootscript 2008-05-06 22:47:38 UTC (rev 25335) @@ -139,8 +139,8 @@ fi # Check for fresh install and run post install scripts. -postInstallDir=/boot/beos/etc/post_install -freshInstallIndicator=$postInstallDir/fresh_install +postInstallDir=/boot/common/boot/post_install +freshInstallIndicator=/boot/common/settings/fresh_install if [ -e $freshInstallIndicator ]; then # wait a moment for things to calm down a bit sleep 3 From bonefish at mail.berlios.de Wed May 7 01:16:05 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 01:16:05 +0200 Subject: [Haiku-commits] r25336 - in haiku/trunk: headers/private/kernel headers/private/kernel/posix src/system/kernel src/system/kernel/lib src/system/kernel/posix src/system/libroot/posix Message-ID: <200805062316.m46NG54u000733@sheep.berlios.de> Author: bonefish Date: 2008-05-07 01:16:04 +0200 (Wed, 07 May 2008) New Revision: 25336 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25336&view=rev Added: haiku/trunk/headers/private/kernel/posix/ haiku/trunk/headers/private/kernel/posix/realtime_sem.h haiku/trunk/src/system/kernel/posix/ haiku/trunk/src/system/kernel/posix/Jamfile haiku/trunk/src/system/kernel/posix/realtime_sem.cpp Removed: haiku/trunk/headers/private/kernel/realtime_sem.h haiku/trunk/src/system/kernel/realtime_sem.cpp Modified: haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/lib/Jamfile haiku/trunk/src/system/kernel/main.c haiku/trunk/src/system/kernel/syscalls.cpp haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/libroot/posix/semaphore.cpp Log: * Moved realtime_sem.{cpp,h} into new posix subdirectory. * Renamed the old kernel_posix[_arch...].o to kernel_lib_posix... Copied: haiku/trunk/headers/private/kernel/posix/realtime_sem.h (from rev 25335, haiku/trunk/headers/private/kernel/realtime_sem.h) Deleted: haiku/trunk/headers/private/kernel/realtime_sem.h Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-06 23:16:04 UTC (rev 25336) @@ -33,7 +33,6 @@ Notifications.cpp port.cpp real_time_clock.c - realtime_sem.cpp scheduler.cpp sem.cpp shutdown.c @@ -64,16 +63,17 @@ ; KernelLd kernel_$(TARGET_ARCH) : + kernel_cache.o kernel_core.o - kernel_fs.o - kernel_vm.o - kernel_cache.o + kernel_debug.o kernel_device_manager.o kernel_disk_device_manager.o - kernel_util.o + kernel_fs.o kernel_messaging.o - kernel_debug.o + kernel_posix.o kernel_slab.o + kernel_util.o + kernel_vm.o lib$(TARGET_ARCH).a kernel_platform_$(TARGET_BOOT_PLATFORM).o @@ -83,8 +83,8 @@ # kernel parts borrowed from libroot and others kernel_os_main.o kernel_os_arch_$(TARGET_ARCH).o - kernel_posix.o - kernel_posix_arch_$(TARGET_ARCH).o + kernel_lib_posix.o + kernel_lib_posix_arch_$(TARGET_ARCH).o kernel_misc.o $(HAIKU_STATIC_LIBSUPC++) @@ -96,16 +96,17 @@ ; KernelLd kernel.so : + kernel_cache.o kernel_core.o - kernel_fs.o - kernel_vm.o - kernel_cache.o + kernel_debug.o kernel_device_manager.o kernel_disk_device_manager.o - kernel_util.o + kernel_fs.o kernel_messaging.o - kernel_debug.o + kernel_posix.o kernel_slab.o + kernel_util.o + kernel_vm.o lib$(TARGET_ARCH).a kernel_platform_$(TARGET_BOOT_PLATFORM).o @@ -115,8 +116,8 @@ # kernel libroot parts kernel_os_main.o kernel_os_arch_$(TARGET_ARCH).o - kernel_posix.o - kernel_posix_arch_$(TARGET_ARCH).o + kernel_lib_posix.o + kernel_lib_posix_arch_$(TARGET_ARCH).o $(HAIKU_STATIC_LIBSUPC++) @@ -153,6 +154,7 @@ SubInclude HAIKU_TOP src system kernel fs ; SubInclude HAIKU_TOP src system kernel lib ; SubInclude HAIKU_TOP src system kernel messaging ; +SubInclude HAIKU_TOP src system kernel posix ; SubInclude HAIKU_TOP src system kernel slab ; SubInclude HAIKU_TOP src system kernel util ; SubInclude HAIKU_TOP src system kernel vm ; Modified: haiku/trunk/src/system/kernel/lib/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/lib/Jamfile 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/lib/Jamfile 2008-05-06 23:16:04 UTC (rev 25336) @@ -31,7 +31,7 @@ SEARCH_SOURCE += [ FDirName $(posixSources) time ] ; SEARCH_SOURCE += [ FDirName $(posixSources) unistd ] ; -KernelMergeObject kernel_posix.o : +KernelMergeObject kernel_lib_posix.o : # main kernel_errno.c dirent.c @@ -129,7 +129,7 @@ SEARCH_SOURCE += [ FDirName $(posixSources) arch $(TARGET_ARCH) ] ; SEARCH_SOURCE += [ FDirName $(posixSources) string arch $(TARGET_ARCH) ] ; -KernelMergeObject kernel_posix_arch_$(TARGET_ARCH).o : +KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o : setjmp.S siglongjmp.S sigsetjmp.S Modified: haiku/trunk/src/system/kernel/main.c =================================================================== --- haiku/trunk/src/system/kernel/main.c 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/main.c 2008-05-06 23:16:04 UTC (rev 25336) @@ -32,8 +32,8 @@ #include #include #include +#include #include -#include #include #include #include Added: haiku/trunk/src/system/kernel/posix/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/posix/Jamfile 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/posix/Jamfile 2008-05-06 23:16:04 UTC (rev 25336) @@ -0,0 +1,9 @@ +SubDir HAIKU_TOP src system kernel posix ; + +UsePrivateHeaders shared ; + +KernelMergeObject kernel_posix.o : + realtime_sem.cpp + + : $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused +; Copied: haiku/trunk/src/system/kernel/posix/realtime_sem.cpp (from rev 25335, haiku/trunk/src/system/kernel/realtime_sem.cpp) =================================================================== --- haiku/trunk/src/system/kernel/realtime_sem.cpp 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/posix/realtime_sem.cpp 2008-05-06 23:16:04 UTC (rev 25336) @@ -0,0 +1,758 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class SemInfo { +public: + SemInfo() + : + fName(NULL), + fRefCount(1), + fID(-1) + { + } + + ~SemInfo() + { + free(fName); + if (fID >= 0) + delete_sem(fID); + } + + const char* Name() const { return fName; } + sem_id ID() const { return fID; } + + status_t Init(const char* name, mode_t mode, int32 semCount) + { + fName = strdup(name); + if (fName == NULL) + return B_NO_MEMORY; + + fID = create_sem(semCount, name); + if (fID < 0) + return fID; + + fUID = geteuid(); + fGID = getegid(); + fPermissions = mode; + + return B_OK; + } + + void AcquireReference() + { + atomic_add(&fRefCount, 1); + } + + void ReleaseReference() + { + if (atomic_add(&fRefCount, -1) == 1) + delete this; + } + + bool HasPermissions() const + { + if ((fPermissions & S_IWOTH) != 0) + return true; + + uid_t uid = geteuid(); + if (uid == 0 || (uid == fUID && (fPermissions & S_IWUSR) != 0)) + return true; + + gid_t gid = getegid(); + if (gid == fGID && (fPermissions & S_IWGRP) != 0) + return true; + + return false; + } + + HashTableLink* HashTableLink() + { + return &fHashLink; + } + +private: + char* fName; + vint32 fRefCount; + sem_id fID; + uid_t fUID; + gid_t fGID; + mode_t fPermissions; + + ::HashTableLink fHashLink; +}; + + +struct NamedSemHashDefinition { + typedef const char* KeyType; + typedef SemInfo ValueType; + + size_t HashKey(const KeyType& key) const + { + return hash_hash_string(key); + } + + size_t Hash(SemInfo* semaphore) const + { + return HashKey(semaphore->Name()); + } + + bool Compare(const KeyType& key, SemInfo* semaphore) const + { + return strcmp(key, semaphore->Name()) == 0; + } + + HashTableLink* GetLink(SemInfo* semaphore) const + { + return semaphore->HashTableLink(); + } +}; + + +class GlobalRealtimeSemTable { +public: + GlobalRealtimeSemTable() + { + mutex_init(&fLock, "global realtime sem table"); + } + + ~GlobalRealtimeSemTable() + { + mutex_destroy(&fLock); + } + + status_t Init() + { + return fSemaphores.InitCheck(); + } + + status_t OpenSem(const char* name, int openFlags, mode_t mode, + uint32 semCount, SemInfo*& _sem, bool& _created) + { + MutexLocker _(fLock); + + SemInfo* sem = fSemaphores.Lookup(name); + if (sem != NULL) { + if ((openFlags & O_EXCL) != 0) + return EEXIST; + + if (!sem->HasPermissions()) + return EACCES; + + sem->AcquireReference(); + _sem = sem; + _created = false; + return B_OK; + } + + if ((openFlags & O_CREAT) == 0) + return ENOENT; + + // does not exist yet -- create + sem = new(std::nothrow) SemInfo; + if (sem == NULL) + return B_NO_MEMORY; + + status_t error = sem->Init(name, mode, semCount); + if (error != B_OK) { + delete sem; + return error; + } + + error = fSemaphores.Insert(sem); + if (error != B_OK) { + delete sem; + return error; + } + + // add one reference for the table + sem->AcquireReference(); + + _sem = sem; + _created = true; + return B_OK; + } + + status_t UnlinkSem(const char* name) + { + MutexLocker _(fLock); + + SemInfo* sem = fSemaphores.Lookup(name); + if (sem == NULL) + return ENOENT; + + if (!sem->HasPermissions()) + return EACCES; + + fSemaphores.Remove(sem); + sem->ReleaseReference(); + // release the table reference + + return B_OK; + } + +private: + typedef OpenHashTable SemTable; + + mutex fLock; + SemTable fSemaphores; +}; + + +static GlobalRealtimeSemTable sSemTable; + + +class TeamSemInfo { +public: + TeamSemInfo(SemInfo* semaphore, sem_t* userSem) + : + fSemaphore(semaphore), + fUserSemaphore(userSem), + fOpenCount(1) + { + } + + ~TeamSemInfo() + { + if (fSemaphore != NULL) + fSemaphore->ReleaseReference(); + } + + SemInfo* Semaphore() const { return fSemaphore; } + sem_t* UserSemaphore() const { return fUserSemaphore; } + + void Open() + { + fOpenCount++; + } + + bool Close() + { + return --fOpenCount == 0; + } + + TeamSemInfo* Clone() const + { + TeamSemInfo* sem = new(std::nothrow) TeamSemInfo(fSemaphore, + fUserSemaphore); + if (sem == NULL) + return NULL; + + sem->fOpenCount = fOpenCount; + fSemaphore->AcquireReference(); + + return sem; + } + + HashTableLink* HashTableLink() + { + return &fHashLink; + } + +private: + SemInfo* fSemaphore; + sem_t* fUserSemaphore; + int32 fOpenCount; + + ::HashTableLink fHashLink; +}; + + +struct TeamSemHashDefinition { + typedef sem_id KeyType; + typedef TeamSemInfo ValueType; + + size_t HashKey(const KeyType& key) const + { + return (size_t)key; + } + + size_t Hash(TeamSemInfo* semaphore) const + { + return HashKey(semaphore->Semaphore()->ID()); + } + + bool Compare(const KeyType& key, TeamSemInfo* semaphore) const + { + return key == semaphore->Semaphore()->ID(); + } + + HashTableLink* GetLink(TeamSemInfo* semaphore) const + { + return semaphore->HashTableLink(); + } +}; + + +struct realtime_sem_context { + realtime_sem_context() + { + mutex_init(&fLock, "realtime sem context"); + } + + ~realtime_sem_context() + { + mutex_lock(&fLock); + + // delete all semaphores. + SemTable::Iterator it = fSemaphores.GetIterator(); + while (TeamSemInfo* sem = it.Next()) { + // Note, this uses internal knowledge about how the iterator works. + // Ugly, but there's no good alternative. + fSemaphores.RemoveUnchecked(sem); + delete sem; + } + + mutex_destroy(&fLock); + } + + status_t Init() + { + return fSemaphores.InitCheck(); + } + + realtime_sem_context* Clone() + { + // create new context + realtime_sem_context* context = new(std::nothrow) realtime_sem_context; + if (context == NULL) + return NULL; + ObjectDeleter contextDeleter(context); + + MutexLocker _(fLock); + + // clone all semaphores + SemTable::Iterator it = fSemaphores.GetIterator(); + while (TeamSemInfo* sem = it.Next()) { + TeamSemInfo* clonedSem = sem->Clone(); + if (clonedSem == NULL) + return NULL; + + if (context->fSemaphores.Insert(clonedSem) != B_OK) { + delete clonedSem; + return NULL; + } + } + + contextDeleter.Detach(); + return context; + } + + status_t CreateAnonymousSem(uint32 semCount, int& _id) + { + SemInfo* sem = new(std::nothrow) SemInfo; + if (sem == NULL) + return B_NO_MEMORY; + ObjectDeleter semDeleter(sem); + + status_t error = sem->Init(NULL, 0, semCount); + if (error != B_OK) { + delete sem; + return error; + } + + TeamSemInfo* teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); + if (teamSem == NULL) + return B_NO_MEMORY; + semDeleter.Detach(); + + MutexLocker _(fLock); + + error = fSemaphores.Insert(teamSem); + if (error != B_OK) { + delete teamSem; + return error; + } + + _id = teamSem->Semaphore()->ID(); + + return B_OK; + } + + status_t OpenSem(const char* name, int openFlags, mode_t mode, + uint32 semCount, sem_t* userSem, sem_t*& _usedUserSem, int& _id, + bool& _created) + { + SemInfo* sem; + status_t error = sSemTable.OpenSem(name, openFlags, mode, semCount, + sem, _created); + if (error != B_OK) + return error; + + MutexLocker _(fLock); + + TeamSemInfo* teamSem = fSemaphores.Lookup(sem->ID()); + if (teamSem != NULL) { + // already open -- just increment the open count + teamSem->Open(); + sem->ReleaseReference(); + _usedUserSem = teamSem->UserSemaphore(); + _id = teamSem->Semaphore()->ID(); + return B_OK; + } + + // not open yet -- create a new team sem + teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); + if (teamSem == NULL) { + sem->ReleaseReference(); + return B_NO_MEMORY; + } + + error = fSemaphores.Insert(teamSem); + if (error != B_OK) { + delete teamSem; + return error; + } + + _usedUserSem = teamSem->UserSemaphore(); + _id = teamSem->Semaphore()->ID(); + + return B_OK; + } + + status_t CloseSem(sem_id id, sem_t*& deleteUserSem) + { + deleteUserSem = NULL; + + MutexLocker _(fLock); + + TeamSemInfo* sem = fSemaphores.Lookup(id); + if (sem == NULL) + return B_BAD_VALUE; + + if (sem->Close()) { + // last reference closed + fSemaphores.Remove(sem); + deleteUserSem = sem->UserSemaphore(); + delete sem; + } + + return B_OK; + } + + status_t AcquireSem(sem_id id, bigtime_t timeout) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + status_t error; + if (timeout == 0) { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT, + 0); + } else if (timeout == B_INFINITE_TIMEOUT) { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT, 0); + } else { + error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT, + timeout); + } + + return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; + } + + status_t ReleaseSem(sem_id id) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + status_t error = release_sem(id); + return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; + } + + status_t GetSemCount(sem_id id, int& _count) + { + MutexLocker locker(fLock); + + if (fSemaphores.Lookup(id) == NULL) + return B_BAD_VALUE; + + locker.Unlock(); + + int32 count; + status_t error = get_sem_count(id, &count); + if (error != B_OK) + return error; + + _count = count; + return B_OK; + } + +private: + typedef OpenHashTable SemTable; + + mutex fLock; + SemTable fSemaphores; +}; + + +// #pragma mark - implementation private + + +static realtime_sem_context* +get_current_team_context() +{ + struct team* team = thread_get_current_thread()->team; + + // get context + realtime_sem_context* context = atomic_pointer_get( + &team->realtime_sem_context); + if (context != NULL) + return context; + + // no context yet -- create a new one + context = new(std::nothrow) realtime_sem_context; + if (context == NULL || context->Init() != B_OK) { + delete context; + return NULL; + } + + // set the allocated context + realtime_sem_context* oldContext = atomic_pointer_test_and_set( + &team->realtime_sem_context, context, (realtime_sem_context*)NULL); + if (oldContext == NULL) + return context; + + // someone else was quicker + delete context; + return oldContext; +} + + +static status_t +copy_sem_name_to_kernel(const char* userName, KPath& buffer, char*& name) +{ + if (userName == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userName)) + return B_BAD_ADDRESS; + + if (buffer.InitCheck() != B_OK) + return B_NO_MEMORY; + + // copy userland path to kernel + name = buffer.LockBuffer(); + ssize_t actualLength = user_strlcpy(name, userName, buffer.BufferSize()); + + if (actualLength < 0) + return B_BAD_ADDRESS; + if ((size_t)actualLength >= buffer.BufferSize()) + return ENAMETOOLONG; + + return B_OK; +} + + +// #pragma mark - kernel internal + + +void +realtime_sem_init() +{ + new(&sSemTable) GlobalRealtimeSemTable; + if (sSemTable.Init() != B_OK) + panic("realtime_sem_init() failed to init global table"); +} + + +void +delete_realtime_sem_context(realtime_sem_context* context) +{ + delete context; +} + + +realtime_sem_context* +clone_realtime_sem_context(realtime_sem_context* context) +{ + if (context == NULL) + return NULL; + + return context->Clone(); +} + + +// #pragma mark - syscalls + + +status_t +_user_realtime_sem_open(const char* userName, int openFlags, mode_t mode, + uint32 semCount, sem_t* userSem, sem_t** _usedUserSem) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_NO_MEMORY; + + // userSem must always be given + if (userSem == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userSem)) + return B_BAD_ADDRESS; + + // anonymous semaphores are less work -- deal with them first + if (userName == NULL) { + int id; + status_t error = context->CreateAnonymousSem(semCount, id); + if (error != B_OK) + return error; + + if (user_memcpy(&userSem->id, &id, sizeof(int)) != B_OK) { + sem_t* dummy; + context->CloseSem(id, dummy); + return B_BAD_ADDRESS; + } + + return B_OK; + } + + // check user pointers + if (_usedUserSem == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(_usedUserSem) || !IS_USER_ADDRESS(userName)) + return B_BAD_ADDRESS; + + // copy name to kernel + KPath nameBuffer(B_PATH_NAME_LENGTH); + char* name; + status_t error = copy_sem_name_to_kernel(userName, nameBuffer, name); + if (error != B_OK) + return error; + + // open the semaphore + sem_t* usedUserSem; + bool created; + int id; + error = context->OpenSem(name, openFlags, mode, semCount, userSem, + usedUserSem, id, created); + if (error != B_OK) + return error; + + // copy results back to userland + if (user_memcpy(&userSem->id, &id, sizeof(int)) != B_OK + || user_memcpy(_usedUserSem, &usedUserSem, sizeof(sem_t*)) != B_OK) { + if (created) + sSemTable.UnlinkSem(name); + sem_t* dummy; + context->CloseSem(id, dummy); + return B_BAD_ADDRESS; + } + + return B_OK; +} + + +status_t +_user_realtime_sem_close(sem_id semID, sem_t** _deleteUserSem) +{ + if (_deleteUserSem != NULL && !IS_USER_ADDRESS(_deleteUserSem)) + return B_BAD_ADDRESS; + + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + // close sem + sem_t* deleteUserSem; + status_t error = context->CloseSem(semID, deleteUserSem); + if (error != B_OK) + return error; + + // copy back result to userland + if (_deleteUserSem != NULL + && user_memcpy(_deleteUserSem, &deleteUserSem, sizeof(sem_t*)) + != B_OK) { + return B_BAD_ADDRESS; + } + + return B_OK; +} + + +status_t +_user_realtime_sem_unlink(const char* userName) +{ + // copy name to kernel + KPath nameBuffer(B_PATH_NAME_LENGTH); + char* name; + status_t error = copy_sem_name_to_kernel(userName, nameBuffer, name); + if (error != B_OK) + return error; + + return sSemTable.UnlinkSem(name); +} + + +status_t +_user_realtime_sem_get_value(sem_id semID, int* _value) +{ + if (_value == NULL) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(_value)) + return B_BAD_ADDRESS; + + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + // get sem count + int count; + status_t error = context->GetSemCount(semID, count); + if (error != B_OK) + return error; + + // copy back result to userland + if (user_memcpy(_value, &count, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + return B_OK; +} + + +status_t +_user_realtime_sem_post(sem_id semID) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + return context->ReleaseSem(semID); +} + + +status_t +_user_realtime_sem_wait(sem_id semID, bigtime_t timeout) +{ + realtime_sem_context* context = get_current_team_context(); + if (context == NULL) + return B_BAD_VALUE; + + return syscall_restart_handle_post(context->AcquireSem(semID, timeout)); +} Deleted: haiku/trunk/src/system/kernel/realtime_sem.cpp Modified: haiku/trunk/src/system/kernel/syscalls.cpp =================================================================== --- haiku/trunk/src/system/kernel/syscalls.cpp 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/syscalls.cpp 2008-05-06 23:16:04 UTC (rev 25336) @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-06 23:16:04 UTC (rev 25336) @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include Modified: haiku/trunk/src/system/libroot/posix/semaphore.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-06 22:47:38 UTC (rev 25335) +++ haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-06 23:16:04 UTC (rev 25336) @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include From revol at free.fr Wed May 7 09:50:37 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 07 May 2008 09:50:37 +0200 CEST Subject: [Haiku-commits] r25311 - haiku/trunk/build/jam In-Reply-To: <20080507004147.1451.9@knochen-vm.1210100255.fake> Message-ID: <1377381779-BeMail@laptop> > > > What lazy bastard has written that piece of junk? :-) > > > Anyway, that would indeed sound like a very good reason not to > > > run sshd > > > as an inetd like service (the delay, not the parameter :-)). > > > > That delay only happens on first run doesn't it? It doesn't have to > > regenerate keys on every single startup does it? > > I'm not an ssh/ssl expert either, but AFAIK the "server keys" are a > second > key pair different from the "host keys". Both are used when > initiating the > connection. The server keys are volatile and regenerated periodically > (default is every hour). When not running as a daemon they would need > to be > generated with every connection, though. > > Starting the daemon doesn't seem to cause any noticible CPU activity > on my > machine though. Maybe the "tens of seconds" for generating the server > keys > the man page speaks of don't really apply to modern hardware anymore. Indeed on 600MHz it's barely noticeable: $ time echo | sshd -i [910] openlog(sshd, LOG_PID, 32) [910] syslog(32, error: setsockopt SO_KEEPALIVE: Invalid argument) [910] closelog() SSH-1.99-OpenSSH_3.9p1 Protocol mismatch. [910] openlog(sshd, LOG_PID, 32) [910] syslog(32, Bad protocol version identification '' from UNKNOWN) [910] closelog() real 0m0.555s user 0m0.134s sys 0m0.203s Fran?ois. From stippi at mail.berlios.de Wed May 7 10:18:23 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 May 2008 10:18:23 +0200 Subject: [Haiku-commits] r25337 - haiku/trunk/src/apps/networkstatus Message-ID: <200805070818.m478IN9q027357@sheep.berlios.de> Author: stippi Date: 2008-05-07 10:18:21 +0200 (Wed, 07 May 2008) New Revision: 25337 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25337&view=rev Modified: haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp Log: Fixed name and placement for kMsgOpenNetworkPreferences definition. Modified: haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp =================================================================== --- haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp 2008-05-06 23:16:04 UTC (rev 25336) +++ haiku/trunk/src/apps/networkstatus/NetworkStatusView.cpp 2008-05-07 08:18:21 UTC (rev 25337) @@ -59,12 +59,11 @@ const uint32 kMsgUpdate = 'updt'; const uint32 kMsgShowConfiguration = 'shcf'; +const uint32 kMsgOpenNetworkPreferences = 'onwp'; const uint32 kMinIconWidth = 16; const uint32 kMinIconHeight = 16; -const uint32 kOpenNetworkPref = 'onwp'; - const bigtime_t kUpdateInterval = 1000000; // every second @@ -235,7 +234,7 @@ _ShowConfiguration(message); break; - case kOpenNetworkPref: + case kMsgOpenNetworkPreferences: _OpenNetworksPreferences(); break; @@ -362,7 +361,7 @@ menu->AddItem(new BMenuItem("About NetworkStatus" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem("Open Networks Preferences" B_UTF8_ELLIPSIS, - new BMessage(kOpenNetworkPref))); + new BMessage(kMsgOpenNetworkPreferences))); if (fInDeskbar) menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); From jackburton at mail.berlios.de Wed May 7 11:07:37 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 7 May 2008 11:07:37 +0200 Subject: [Haiku-commits] r25338 - haiku/trunk/src/system/kernel/fs Message-ID: <200805070907.m4797bTs031481@sheep.berlios.de> Author: jackburton Date: 2008-05-07 11:07:37 +0200 (Wed, 07 May 2008) New Revision: 25338 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25338&view=rev Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp Log: The second parameter of KPath::SetTo() is a bool, not a size_t. Reported by Marc Flerackers. Thanks! Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-07 08:18:21 UTC (rev 25337) +++ haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-07 09:07:37 UTC (rev 25338) @@ -25,7 +25,7 @@ fPathLength(0), fLocked(false) { - SetTo(NULL, bufferSize); + SetTo(NULL, false, bufferSize); } From mmu_man at mail.berlios.de Wed May 7 11:07:48 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 7 May 2008 11:07:48 +0200 Subject: [Haiku-commits] r25339 - haiku/trunk/src/add-ons/kernel/drivers/tty Message-ID: <200805070907.m4797mqx031531@sheep.berlios.de> Author: mmu_man Date: 2008-05-07 11:07:48 +0200 (Wed, 07 May 2008) New Revision: 25339 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25339&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp Log: Fix a warning, print the pointer to the mutex instead of implying a cast of the address of the pointer to an int. Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-07 09:07:37 UTC (rev 25338) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-07 09:07:48 UTC (rev 25339) @@ -1866,7 +1866,7 @@ kprintf(" open_count: %ld\n", tty.open_count); kprintf(" select_pool: %p\n", tty.select_pool); kprintf(" pending_eof: %lu\n", tty.pending_eof); - kprintf(" lock: %ld\n", &tty.lock); + kprintf(" lock: %p\n", tty.lock); kprintf(" input_buffer:\n"); kprintf(" first: %ld\n", tty.input_buffer.first); From axeld at pinc-software.de Wed May 7 11:27:21 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 11:27:21 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25334_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/boot/platform/bios=5Fia32__src/system/ker?= =?utf-8?q?nel/arch/x86?= In-Reply-To: <894b9700805061507p77a7ccbfw93a86d7b4a70bd9c@mail.gmail.com> Message-ID: <879378118-BeMail@zon> "Stefano Ceccherini" wrote: > 2008/5/7 korli at BerliOS : > > Author: korli > > Date: 2008-05-07 00:04:25 +0200 (Wed, 07 May 2008) > > New Revision: 25334 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25334&view=rev > > > > Modified: > > haiku/trunk/headers/private/kernel/safemode.h > > haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp > > haiku/trunk/src/system/kernel/arch/x86/apm.cpp > > Log: > > added B_SAFEMODE_DISABLE_APM > Since there is an option to disable this, maybe we should enable it > by > default in the kernel settings. That's what it used to be, but I think it was Marcus who disabled it some time ago. AFAIK there are some pending problems with it (I only had them when using the PowerStatus app), so it might be better to have them disabled for now - you will then know what made your system unreliable, at least :-) Once Jan's vm86 stuff is in, I wanted to try mapping the lower BIOS area at the correct position to see if that helps with APM, too. Also, we should really better look into getting ACPI to work properly ASAP. It's on my list, at least. Bye, Axel. From axeld at pinc-software.de Wed May 7 11:28:57 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 11:28:57 +0200 CEST Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: <20080507001912.1403.8@knochen-vm.1210100255.fake> Message-ID: <975703451-BeMail@zon> Ingo Weinhold wrote: > > Log: > > we honor safe modes for GL addons too. maybe this should end > > somewhere in > > libbe and a userland safemode.h > I'd even consider it nicer not to check the safe-mode option > everywhere. IMHO > a small set of helper functions (respectively a helper class) for add > -on > loading should be provided. And it would simply use the ADDON_PATH > environment variable, which would already reflect disabling of user > add-ons, > and would thus also respect the user's changes to the variable (why > else > would it be a variable in the first place?). That sounds like the best option to me, too. We might want to extend the "safemode" app to check for different options, then, and do that in the SetupEnvironment script. Bye, Axel. From axeld at pinc-software.de Wed May 7 11:31:21 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 11:31:21 +0200 CEST Subject: [Haiku-commits] r25337 - haiku/trunk/src/apps/networkstatus In-Reply-To: <200805070818.m478IN9q027357@sheep.berlios.de> Message-ID: <1119711045-BeMail@zon> stippi at BerliOS wrote: > Log: > Fixed name and placement for kMsgOpenNetworkPreferences definition. Thanks! Bye, Axel. From axeld at pinc-software.de Wed May 7 11:37:46 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 11:37:46 +0200 CEST Subject: [Haiku-commits] r25329 - haiku/trunk/src/apps/networkstatus In-Reply-To: Message-ID: <1504257428-BeMail@zon> "Ryan Leavengood" wrote: > On Tue, May 6, 2008 at 5:43 PM, Rene Gollent > wrote: > > If I understand Axel right he means kMsgOpenNetworkPrefs, no? > Ah, OK. My question about const uint32 versus enum still stands. I guess that can be done according to your own preference. I usually take "const uint32" as the target type is actually a uint32, and you often don't have all types in a single place (like public vs. private constants). Other than that, I guess enum would be kind of nicer :-) Bye, Axel. From korli at users.berlios.de Wed May 7 11:39:25 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 7 May 2008 11:39:25 +0200 Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: <975703451-BeMail@zon> References: <20080507001912.1403.8@knochen-vm.1210100255.fake> <975703451-BeMail@zon> Message-ID: 2008/5/7 Axel D?rfler : > That sounds like the best option to me, too. > We might want to extend the "safemode" app to check for different > options, then, and do that in the SetupEnvironment script. > I don't understand well how an environment variable can help with find_directory(). Please explain. Bye, J?r?me From axeld at pinc-software.de Wed May 7 12:03:49 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 12:03:49 +0200 CEST Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: Message-ID: <3067361179-BeMail@zon> "J?r?me Duval" wrote: > 2008/5/7 Axel D?rfler : > > That sounds like the best option to me, too. > > We might want to extend the "safemode" app to check for different > > options, then, and do that in the SetupEnvironment script. > I don't understand well how an environment variable can help with > find_directory(). Please explain. It wouldn't help with find_directory() at all. The add-on helper class Ingo mentioned could use the add-on path variable to locate add-ons. Of course, the helper class could also additionally use the private syscall, but the path variable should still be set to the correct value when that safemode option is enabled. Bye, Axel. From dlmcpaul at mail.berlios.de Wed May 7 12:08:32 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Wed, 7 May 2008 12:08:32 +0200 Subject: [Haiku-commits] r25340 - in haiku/trunk/src/add-ons/media/plugins/mp4_reader: . libMP4 Message-ID: <200805071008.m47A8WlC004871@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-07 12:08:31 +0200 (Wed, 07 May 2008) New Revision: 25340 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25340&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.h haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.h haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.h haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Structs.h haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4TrakAtom.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp Log: bring haiku mp4_reader up to date with BeOS mp4_extractor Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.cpp 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.cpp 2008-05-07 10:08:31 UTC (rev 25340) @@ -41,6 +41,17 @@ parentAtom = NULL; } +char *AtomBase::getAtomTypeAsFourcc() +{ + fourcc[0] = (char)((atomType >> 24) & 0xff); + fourcc[1] = (char)((atomType >> 16) & 0xff); + fourcc[2] = (char)((atomType >> 8) & 0xff); + fourcc[3] = (char)((atomType >> 0) & 0xff); + fourcc[4] = '\0'; + + return fourcc; +} + char *AtomBase::getAtomName() { char *_result; @@ -209,6 +220,36 @@ // Assert((bytes_read == maxread,"Read Error"); } +uint64 AtomBase::GetBits(uint64 buffer, uint8 startBit, uint8 totalBits) +{ + // startBit should range from 0-63, totalBits should range from 1-64 + if ((startBit < 64) && (totalBits > 0) && (totalBits <= 64) && (startBit + totalBits <= 64)) { + // Ok pull from the buffer the bits wanted. + buffer = buffer << startBit; + buffer = buffer >> (64 - (totalBits + startBit) + startBit); + + printf("buffer = %Ld\n",buffer); + + return buffer; + } + + return 0L; +} + +uint32 AtomBase::GetBits(uint32 buffer, uint8 startBit, uint8 totalBits) +{ + // startBit should range from 0-31, totalBits should range from 1-32 + if ((startBit < 32) && (totalBits > 0) && (totalBits <= 32) && (startBit + totalBits <= 32)) { + // Ok pull from the buffer the bits wanted. + buffer = buffer << startBit; + buffer = buffer >> (32 - (startBit + totalBits) + startBit); + + return buffer; + } + + return 0; +} + FullAtom::FullAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomBase(pStream, pstreamOffset, patomType, patomSize) { } Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.h 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.h 2008-05-07 10:08:31 UTC (rev 25340) @@ -101,17 +101,18 @@ uint64 getAtomSize() {return atomSize;}; uint32 getAtomType() {return atomType;}; - off_t getAtomOffset() {return atomOffset;}; - off_t getStreamOffset() {return streamOffset;}; + char *getAtomTypeAsFourcc(); + off_t getAtomOffset() { return atomOffset; }; + off_t getStreamOffset() { return streamOffset; }; - uint64 getDataSize() {return atomSize - 8;}; + uint64 getDataSize() { return atomSize - 8;}; uint64 getBytesRemaining(); - bool IsType(uint32 patomType) {return patomType == atomType;}; + bool IsType(uint32 patomType) { return patomType == atomType; }; - void setAtomOffset(off_t patomOffset) {atomOffset = patomOffset;}; - void setStreamOffset(off_t pstreamOffset) {streamOffset = pstreamOffset;}; + void setAtomOffset(off_t patomOffset) { atomOffset = patomOffset; }; + void setStreamOffset(off_t pstreamOffset) { streamOffset = pstreamOffset; }; char *getAtomName(); @@ -142,6 +143,9 @@ void Read(uint8 *value); void Read(char *value, uint32 maxread); void Read(uint8 *value, uint32 maxread); + + uint64 GetBits(uint64 buffer, uint8 startBit, uint8 totalBits); + uint32 GetBits(uint32 buffer, uint8 startBit, uint8 totalBits); }; class FullAtom : public AtomBase { Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.cpp 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.cpp 2008-05-07 10:08:31 UTC (rev 25340) @@ -62,11 +62,15 @@ { AtomBase* aAtomBase; + // check all mdat atoms to make sure pPosition is within one of them + for (uint32 index=0;indexgetAtomSize() > 8)) { - MDATAtom *aMdatAtom = dynamic_cast(aAtomBase); - return pPosition >= aMdatAtom->getEOF(); + MDATAtom *aMDATAtom = dynamic_cast(aAtomBase); + if (pPosition >= aMDATAtom->getAtomOffset() && pPosition <= aMDATAtom->getEOF()) { + return false; + } } } @@ -187,8 +191,7 @@ bigtime_t MP4FileReader::getMovieDuration() { - return (bigtime_t(getMVHDAtom()->getDuration()) * 1000000L) - / getMovieTimeScale(); + return bigtime_t((getMVHDAtom()->getDuration() * 1000000.0) / getMovieTimeScale()); } @@ -261,29 +264,18 @@ uint32 -MP4FileReader::getVideoFrameCount(uint32 streamIndex) +MP4FileReader::getFrameCount(uint32 streamIndex) { AtomBase *aAtomBase = GetChildAtom(uint32('trak'), streamIndex); - if (aAtomBase && dynamic_cast(aAtomBase)->IsVideo()) + if (aAtomBase) { return dynamic_cast(aAtomBase)->FrameCount(); + } return 1; } - uint32 -MP4FileReader::getAudioFrameCount(uint32 streamIndex) -{ - AtomBase *aAtomBase = GetChildAtom(uint32('trak'), streamIndex); - - if (aAtomBase && dynamic_cast(aAtomBase)->IsAudio()) - return dynamic_cast(aAtomBase)->FrameCount(); - - return 1; -} - -uint32 MP4FileReader::getAudioChunkCount(uint32 streamIndex) { AtomBase *aAtomBase = GetChildAtom(uint32('trak'), streamIndex); @@ -368,8 +360,12 @@ TRAKAtom *aTrakAtom = dynamic_cast(aAtomBase); if (pFrameNo < aTrakAtom->FrameCount()) { - // Get Sample for Frame - uint32 SampleNo = aTrakAtom->getSampleForFrame(pFrameNo); + // Get time for Frame + bigtime_t Time = aTrakAtom->getTimeForFrame(pFrameNo); + + // Get Sample for Time + uint32 SampleNo = aTrakAtom->getSampleForTime(Time); + // Get Chunk For Sample and the offset for the frame within that chunk uint32 OffsetInChunk; uint32 ChunkNo = aTrakAtom->getChunkForSample(SampleNo, &OffsetInChunk); @@ -391,6 +387,8 @@ } } +// printf("frame %ld, time %Ld, sample %ld, Chunk %ld, OffsetInChunk %ld, Offset %Ld\n",pFrameNo, Time, SampleNo, ChunkNo, OffsetInChunk, OffsetNo); + return OffsetNo; } } @@ -458,7 +456,7 @@ } else { theMainHeader.width = VideoFormat(videoStream)->width; theMainHeader.height = VideoFormat(videoStream)->height; - theMainHeader.total_frames = getVideoFrameCount(videoStream); + theMainHeader.total_frames = getFrameCount(videoStream); theMainHeader.suggested_buffer_size = theMainHeader.width * theMainHeader.height * VideoFormat(videoStream)->bit_count / 8; theMainHeader.micro_sec_per_frame = uint32(1000000.0 / VideoFormat(videoStream)->FrameRate); } @@ -483,18 +481,33 @@ if (aAtomBase) { STSDAtom *aSTSDAtom = dynamic_cast(aAtomBase); - // Fill In a wave_format_ex structure + // Fill in the AudioMetaData structure AudioDescription aAudioDescription = aSTSDAtom->getAsAudio(); theAudio.compression = aAudioDescription.codecid; + theAudio.codecSubType = aAudioDescription.codecSubType; theAudio.NoOfChannels = aAudioDescription.theAudioSampleEntry.ChannelCount; - theAudio.SampleSize = aAudioDescription.theAudioSampleEntry.SampleSize; + + // Fix for broken mp4's with 0 SampleSize, default to 16 bits + if (aAudioDescription.theAudioSampleEntry.SampleSize == 0) { + theAudio.SampleSize = 16; + } else { + theAudio.SampleSize = aAudioDescription.theAudioSampleEntry.SampleSize; + } + theAudio.SampleRate = aAudioDescription.theAudioSampleEntry.SampleRate / 65536; // Convert from fixed point decimal to float - theAudio.PacketSize = uint32((theAudio.SampleSize * theAudio.NoOfChannels * 1024) / 8); + theAudio.FrameSize = aAudioDescription.FrameSize; + if (aAudioDescription.BufferSize == 0) { + theAudio.BufferSize = uint32((theAudio.SampleSize * theAudio.NoOfChannels * theAudio.FrameSize) / 8); + } else { + theAudio.BufferSize = aAudioDescription.BufferSize; + } + + theAudio.BitRate = aAudioDescription.BitRate; - theAudio.theVOL = aAudioDescription.theVOL; - theAudio.VOLSize = aAudioDescription.VOLSize; + theAudio.theDecoderConfig = aAudioDescription.theDecoderConfig; + theAudio.DecoderConfigSize = aAudioDescription.DecoderConfigSize; return &theAudio; } @@ -519,25 +532,26 @@ VideoDescription aVideoDescription = aSTSDAtom->getAsVideo(); theVideo.compression = aVideoDescription.codecid; + theVideo.codecSubType = aVideoDescription.codecSubType; theVideo.width = aVideoDescription.theVideoSampleEntry.Width; theVideo.height = aVideoDescription.theVideoSampleEntry.Height; theVideo.planes = aVideoDescription.theVideoSampleEntry.Depth; - theVideo.size = aVideoDescription.theVideoSampleEntry.Width * aVideoDescription.theVideoSampleEntry.Height * aVideoDescription.theVideoSampleEntry.Depth / 8; + theVideo.BufferSize = aVideoDescription.theVideoSampleEntry.Width * aVideoDescription.theVideoSampleEntry.Height * aVideoDescription.theVideoSampleEntry.Depth / 8; theVideo.bit_count = aVideoDescription.theVideoSampleEntry.Depth; theVideo.image_size = aVideoDescription.theVideoSampleEntry.Height * aVideoDescription.theVideoSampleEntry.Width; theVideo.HorizontalResolution = aVideoDescription.theVideoSampleEntry.HorizontalResolution; theVideo.VerticalResolution = aVideoDescription.theVideoSampleEntry.VerticalResolution; theVideo.FrameCount = aVideoDescription.theVideoSampleEntry.FrameCount; - theVideo.theVOL = aVideoDescription.theVOL; - theVideo.VOLSize = aVideoDescription.VOLSize; + theVideo.theDecoderConfig = aVideoDescription.theDecoderConfig; + theVideo.DecoderConfigSize = aVideoDescription.DecoderConfigSize; aAtomBase = aTrakAtom->GetChildAtom(uint32('stts'),0); if (aAtomBase) { STTSAtom *aSTTSAtom = dynamic_cast(aAtomBase); - theVideo.FrameRate = ((aSTTSAtom->getSUMCounts() * 1000000.0L) / aTrakAtom->Duration(1)); + theVideo.FrameRate = ((aSTTSAtom->getSUMCounts() * 1000000.0) / aTrakAtom->Duration(1)); return &theVideo; } @@ -552,25 +566,25 @@ const mp4_stream_header* MP4FileReader::StreamFormat(uint32 streamIndex) { - // Fill In a Stream Header - theStreamHeader.length = 0; - if (IsActive(streamIndex) == false) { return NULL; } + // Fill In a Stream Header + theStreamHeader.length = 0; + if (IsVideo(streamIndex)) { - theStreamHeader.rate = uint32(1000000L*VideoFormat(streamIndex)->FrameRate); + theStreamHeader.rate = uint32(1000000.0*VideoFormat(streamIndex)->FrameRate); theStreamHeader.scale = 1000000L; - theStreamHeader.length = getVideoFrameCount(streamIndex); + theStreamHeader.length = getFrameCount(streamIndex); } if (IsAudio(streamIndex)) { theStreamHeader.rate = uint32(AudioFormat(streamIndex)->SampleRate); theStreamHeader.scale = 1; - theStreamHeader.length = getAudioFrameCount(streamIndex); + theStreamHeader.length = getFrameCount(streamIndex); theStreamHeader.sample_size = AudioFormat(streamIndex)->SampleSize; - theStreamHeader.suggested_buffer_size = theStreamHeader.rate * theStreamHeader.sample_size; + theStreamHeader.suggested_buffer_size = AudioFormat(streamIndex)->BufferSize; } return &theStreamHeader; @@ -601,8 +615,7 @@ if (aAtomBase) { TRAKAtom *aTrakAtom = dynamic_cast(aAtomBase); - uint32 SampleNo = aTrakAtom->getSampleForFrame(pFrameNo); - return aTrakAtom->IsSyncSample(SampleNo); + return aTrakAtom->IsSyncSample(pFrameNo); } return false; @@ -620,6 +633,8 @@ *keyframe = IsKeyFrame(streamIndex, pFrameNo); } +// printf("start %Ld, size %ld, eof %s, eod %s\n",*start,*size, IsEndOfFile(*start + *size) ? "true" : "false", IsEndOfData(*start + *size) ? "true" : "false"); + // TODO need a better method for detecting End of Data Note ChunkSize of 0 seems to be it. return *start > 0 && *size > 0 && !IsEndOfFile(*start + *size) && !IsEndOfData(*start + *size); @@ -647,11 +662,18 @@ if (aAtom) { if (dynamic_cast(aAtom)) { aAtom->ProcessMetaData(); - printf("ftyp atom found checking brands\n"); + printf("ftyp atom found checking brands..."); // MP4 files start with a ftyp atom that does not contain a qt brand - return !(dynamic_cast(aAtom)->HasBrand(uint32('qt '))); + if (!dynamic_cast(aAtom)->HasBrand(uint32('qt '))) { + printf("no quicktime brand found must be mp4\n"); + return true; + } else { + printf("quicktime brand found\n"); + } } } + + printf("NO ftyp atom found, cannot be mp4\n"); return false; } Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.h 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4FileReader.h 2008-05-07 10:08:31 UTC (rev 25340) @@ -89,10 +89,7 @@ bigtime_t getMaxDuration(); // The no of frames in the video track indexed by streamIndex - // 1 frame = 1 chunk - uint32 getVideoFrameCount(uint32 streamIndex); - // The no of frames in the audio track indexed by streamIndex - uint32 getAudioFrameCount(uint32 streamIndex); + uint32 getFrameCount(uint32 streamIndex); // The no of chunks in the audio track indexed by streamIndex uint32 getAudioChunkCount(uint32 streamIndex); // Is stream (track) a video track Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp 2008-05-07 10:08:31 UTC (rev 25340) @@ -189,6 +189,14 @@ return new ESDSAtom(pStream, aStreamOffset, aAtomType, aRealAtomSize); } + if (aAtomType == uint32('alac')) { + return new ALACAtom(pStream, aStreamOffset, aAtomType, aRealAtomSize); + } + + if (aAtomType == uint32('wave')) { + return new WAVEAtom(pStream, aStreamOffset, aAtomType, aRealAtomSize); + } + return new AtomBase(pStream, aStreamOffset, aAtomType, aRealAtomSize); } @@ -477,6 +485,8 @@ ReadArrayHeader(&theHeader); +// printf("STTS:: Entries %ld\n",theHeader.NoEntries); + for (uint32 i=0;iDuration * theTimeToSampleArray[i]->Count); SUMCounts += theTimeToSampleArray[i]->Count; + +// printf("(%ld,%ld)",aTimeToSample->Count,aTimeToSample->Duration); + } +// printf("\n"); } char *STTSAtom::OnGetAtomName() @@ -494,24 +508,30 @@ return "Time to Sample Atom"; } -uint32 STTSAtom::getSampleForTime(uint32 pTime) +uint32 STTSAtom::getSampleForTime(bigtime_t pTime) { + // Sample for time is this calc, how does STTS help us? + return uint32((pTime * FrameRate + 50) / 1000000.0); + + // TODO this is too slow. PreCalc when loading this? - uint64 Duration = 0; - +/* bigtime_t TotalDuration = 0; + uint64 TotalCount = 0; + for (uint32 i=0;iDuration * theTimeToSampleArray[i]->Count); - if (Duration > pTime) { - return i; + TotalDuration += (theTimeToSampleArray[i]->Duration * theTimeToSampleArray[i]->Count); + TotalCount += theTimeToSampleArray[i]->Count; + if ((TotalDuration * 44100) > pTime) { + return uint32((pTime * FrameRate + 50) / 1000000.0); } } - return 0; + return 0; */ } uint32 STTSAtom::getSampleForFrame(uint32 pFrame) { -// Hmm Sample is Frame really, this Atom is more usefull for time->sample calcs + // Convert frame to time and call getSampleForTime() return pFrame; } @@ -573,6 +593,8 @@ ReadArrayHeader(&theHeader); uint32 TotalPrevSamples = 0; + +// printf("STSC:: Entries %ld\n",theHeader.NoEntries); for (uint32 i=0;iTotalPrevSamples = 0; } +// printf("(%ld,%ld)",aSampleToChunk->SamplesPerChunk, aSampleToChunk->TotalPrevSamples); + theSampleToChunkArray[i] = aSampleToChunk; } +// printf("\n"); } char *STSCAtom::OnGetAtomName() @@ -665,7 +690,7 @@ FullAtom::OnProcessMetaData(); ReadArrayHeader(&theHeader); - + for (uint32 i=0;i theSyncSampleArray[i]->SyncSampleNo) { + if (pSampleNo < theSyncSampleArray[i]->SyncSampleNo) { return false; } } @@ -908,28 +933,42 @@ return 0LL; } -ESDSAtom::ESDSAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : FullAtom(pStream, pstreamOffset, patomType, patomSize) +DecoderConfigAtom::DecoderConfigAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomBase(pStream, pstreamOffset, patomType, patomSize) { - theVOL = NULL; + theDecoderConfig = NULL; + DecoderConfigSize = 0; } -ESDSAtom::~ESDSAtom() +DecoderConfigAtom::~DecoderConfigAtom() { - if (theVOL) { - free(theVOL); + if (theDecoderConfig) { + free(theDecoderConfig); } } -bool ESDSAtom::SkipTag(uint8 Tag, uint32 *offset) { +void DecoderConfigAtom::OnProcessMetaData() +{ + DecoderConfigSize = getBytesRemaining(); + + theDecoderConfig = (uint8 *)(malloc(DecoderConfigSize)); + Read(theDecoderConfig,DecoderConfigSize); +} + +uint8 *DecoderConfigAtom::getDecoderConfig() +{ + return theDecoderConfig; +} + +bool DecoderConfigAtom::SkipTag(uint8 *ESDS, uint8 Tag, uint32 *offset) { uint8 byte; - byte = theVOL[(*offset)++]; + byte = ESDS[(*offset)++]; if (byte == Tag) { uint8 numBytes = 0; unsigned int length = 0; do { - byte = theVOL[(*offset)++]; + byte = ESDS[(*offset)++]; numBytes++; length = (length << 7) | (byte & 0x7F); } while ((byte & 0x80) && numBytes < 4); @@ -937,123 +976,243 @@ } else { // go back Tag not found (*offset)--; - printf("No Tag %d\n",Tag); return false; } return true; } +char *DecoderConfigAtom::OnGetAtomName() +{ + return "Decoder Config Atom - Unknown type"; +} + +void DecoderConfigAtom::OverrideAudioDescription(AudioDescription *pAudioDescription) +{ + if (pAudioDescription) { + pAudioDescription->DecoderConfigSize = DecoderConfigSize; + pAudioDescription->theDecoderConfig = (uint8 *)(malloc(DecoderConfigSize)); + memcpy(pAudioDescription->theDecoderConfig, theDecoderConfig, DecoderConfigSize); + OnOverrideAudioDescription(pAudioDescription); + } +} + +void DecoderConfigAtom::OverrideVideoDescription(VideoDescription *pVideoDescription) +{ + if (pVideoDescription) { + pVideoDescription->DecoderConfigSize = DecoderConfigSize; + pVideoDescription->theDecoderConfig = (uint8 *)(malloc(DecoderConfigSize)); + memcpy(pVideoDescription->theDecoderConfig, theDecoderConfig, DecoderConfigSize); + OnOverrideVideoDescription(pVideoDescription); + } +} + +ESDSAtom::ESDSAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : DecoderConfigAtom(pStream, pstreamOffset, patomType, patomSize) +{ +} + +ESDSAtom::~ESDSAtom() +{ +} + void ESDSAtom::OnProcessMetaData() { - FullAtom::OnProcessMetaData(); + // Read 4 bytes because this is really a FullAtom + uint32 version; + Read(&version); + DecoderConfigAtom::OnProcessMetaData(); +} - VOLSize = getBytesRemaining(); +char *ESDSAtom::OnGetAtomName() +{ + return "Extended Sample Description Atom"; +} + +char *obj_type_names[]= +{ + "Unknown", + "Main-AAC", + "LC-AAC", + "SSR-AAC", + "LTP-AAC", + "HE-AAC", + "HE-AAC(disabled)" +}; + +int aac_sampling_rate[16] = +{ + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, + 16000, 12000, 11025, 8000, 7350, 0, 0, 0 +}; + +void ESDSAtom::OnOverrideAudioDescription(AudioDescription *pAudioDescription) +{ + // decode for aac and check for HE-AAC which uses a framesize of 2048 + // also check for MP3 which has an ESDS uint32 offset = 0; + + if (SkipTag(pAudioDescription->theDecoderConfig, 0x03, &offset)) { + offset += 3; + } else { + offset += 2; + } + + if (SkipTag(pAudioDescription->theDecoderConfig, 0x04, &offset)) { + ESDSType = pAudioDescription->theDecoderConfig[offset]; + StreamType = pAudioDescription->theDecoderConfig[offset+1]/4; + NeededBufferSize = uint32(pAudioDescription->theDecoderConfig[offset+2]) * 256 * 256 + + pAudioDescription->theDecoderConfig[offset+3] * 256 + pAudioDescription->theDecoderConfig[offset+4]; + MaxBitRate = uint32(pAudioDescription->theDecoderConfig[offset+5]) * 256 * 256 * 256 + + pAudioDescription->theDecoderConfig[offset+6] * 256 * 256 + + pAudioDescription->theDecoderConfig[offset+7] * 256 + + pAudioDescription->theDecoderConfig[offset+8]; + AvgBitRate = uint32(pAudioDescription->theDecoderConfig[offset+9]) * 256 * 256 * 256 + + pAudioDescription->theDecoderConfig[offset+10] * 256 * 256 + + pAudioDescription->theDecoderConfig[offset+11] * 256 + + pAudioDescription->theDecoderConfig[offset+12]; + printf("obj type id is %d \n", ESDSType); + printf("stream type is %d\n", StreamType); + printf("Buffer Size is %ld\n", NeededBufferSize); + printf("max Bitrate is %ld\n", MaxBitRate); + printf("avg Bitrate is %ld\n", AvgBitRate); + + pAudioDescription->BitRate = AvgBitRate; + + offset+=13; + } + + SkipTag(pAudioDescription->theDecoderConfig, 0x05, &offset); + uint32 buffer; + uint32 temp; + + switch (ESDSType) { + case 64: // AAC + // Attempt to read AAC Header + buffer = pAudioDescription->theDecoderConfig[offset]; + buffer = buffer * 256 + pAudioDescription->theDecoderConfig[offset+1] ; + buffer = buffer * 256 + pAudioDescription->theDecoderConfig[offset+2] ; + buffer = buffer * 256 + pAudioDescription->theDecoderConfig[offset+3] ; - theVOL = (uint8 *)(malloc(VOLSize)); - Read(theVOL,VOLSize); + // Bits 0-5 are decoder type + temp = GetBits(buffer,0,5); + theAACHeader.objTypeIndex = temp; + // Bits 6-9 are frequency index + temp = GetBits(buffer,6,3); + theAACHeader.sampleRateIndex = temp; + // Bits 10-12 are channels + temp = GetBits(buffer,10,3); + theAACHeader.totalChannels = temp; - // Display the VOL - if (VOLSize > 0) { - if (SkipTag(0x03,&offset)) { - offset += 3; + if (theAACHeader.objTypeIndex < 3) { + pAudioDescription->codecSubType = 'mp4a'; + pAudioDescription->FrameSize = 1024; } else { - offset += 2; + pAudioDescription->codecSubType = 'haac'; + pAudioDescription->FrameSize = 2048; } - - if (SkipTag(0x04,&offset)) { - printf("type id is %d", theVOL[offset]); - switch (theVOL[offset]) { - case 1: printf("system v1"); break; - case 2: printf("system v2"); break; - case 32: printf("MPEG-4 video"); break; - case 33: printf("MPEG-4 AVC SPS"); break; - case 34: printf("MPEG-4 AVC PPS"); break; - case 64: printf("MPEG-4 audio"); break; + + // SampleRate is in 16.16 format + pAudioDescription->theAudioSampleEntry.SampleRate = aac_sampling_rate[theAACHeader.sampleRateIndex] * 65536 ; + pAudioDescription->theAudioSampleEntry.ChannelCount = theAACHeader.totalChannels; + break; + + case 107: // MP3 + pAudioDescription->codecSubType = 'mp3'; + + // Only set this for mp3, we calc it normally + if (NeededBufferSize > pAudioDescription->BufferSize) { + pAudioDescription->BufferSize = NeededBufferSize; } - - offset+=2; - - uint32 a,b,c; - uint32 buff; - - a = theVOL[offset]; - b = theVOL[offset+1]; - c = theVOL[offset+2]; - buff = (a << 16) | (b << 8) | c; - - printf(" buf size %ld ",buff); - printf(" max bit rate %ld",uint32(theVOL[offset+4])); - printf(" avg bit rate %ld\n",uint32(theVOL[offset+8])); - } - } else { - printf("VOL size is 0\n"); + break; } - } -size_t ESDSAtom::getVOLSize(bool forAudio) +void ESDSAtom::OnOverrideVideoDescription(VideoDescription *pVideoDescription) { - uint32 offset = 0; - if (forAudio) { - if (SkipTag(0x03,&offset)) { - offset += 3; - } else { - offset += 2; - } - if (SkipTag(0x04,&offset)) { - offset += 13; - } + // Nothing to override +} - SkipTag(0x05,&offset); - } - - return ( VOLSize - offset); +ALACAtom::ALACAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : DecoderConfigAtom(pStream, pstreamOffset, patomType, patomSize) +{ } -uint8 *ESDSAtom::getVOL(bool forAudio) +ALACAtom::~ALACAtom() { - uint32 offset = 0; - if (forAudio) { - if (SkipTag(0x03,&offset)) { - offset += 3; - } else { - offset += 2; - } - if (SkipTag(0x04,&offset)) { - offset += 13; - } +} - SkipTag(0x05,&offset); - } - - return &theVOL[offset]; +void ALACAtom::OnProcessMetaData() +{ + DecoderConfigAtom::OnProcessMetaData(); } -char *ESDSAtom::OnGetAtomName() +char *ALACAtom::OnGetAtomName() { - return "Extended Sample Description Atom"; + return "ALAC Decoder Config Atom"; } +void ALACAtom::OnOverrideAudioDescription(AudioDescription *pAudioDescription) +{ + pAudioDescription->codecSubType = 'alac'; + pAudioDescription->FrameSize = 4096; +} + +void ALACAtom::OnOverrideVideoDescription(VideoDescription *pVideoDescription) +{ + // Nothing to override +} + +WAVEAtom::WAVEAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : DecoderConfigAtom(pStream, pstreamOffset, patomType, patomSize) +{ +} + +WAVEAtom::~WAVEAtom() +{ +} + +void WAVEAtom::OnProcessMetaData() +{ + +} + +char *WAVEAtom::OnGetAtomName() +{ + return "WAVE Decoder Config Atom"; +} + +void WAVEAtom::OnOverrideAudioDescription(AudioDescription *pAudioDescription) +{ + pAudioDescription->codecSubType = 'alac'; + pAudioDescription->FrameSize = 4096; +} + +void WAVEAtom::OnOverrideVideoDescription(VideoDescription *pVideoDescription) +{ + // Nothing to override +} + STSDAtom::STSDAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : FullAtom(pStream, pstreamOffset, patomType, patomSize) { theHeader.NoEntries = 0; - theAudioDescription.theVOL = NULL; - theVideoDescription.theVOL = NULL; + theAudioDescription.codecid = 0; + theAudioDescription.codecSubType = 0; + theAudioDescription.FrameSize = 0; + theAudioDescription.BufferSize = 0; + theAudioDescription.BitRate = 0; + theAudioDescription.theDecoderConfig = NULL; + theVideoDescription.theDecoderConfig = NULL; } STSDAtom::~STSDAtom() { - if (theAudioDescription.theVOL) { - free(theAudioDescription.theVOL); - theAudioDescription.theVOL = NULL; + if (theAudioDescription.theDecoderConfig) { + free(theAudioDescription.theDecoderConfig); + theAudioDescription.theDecoderConfig = NULL; } - if (theVideoDescription.theVOL) { - free(theVideoDescription.theVOL); - theVideoDescription.theVOL = NULL; + if (theVideoDescription.theDecoderConfig) { + free(theVideoDescription.theDecoderConfig); + theVideoDescription.theDecoderConfig = NULL; } } @@ -1062,12 +1221,14 @@ return dynamic_cast(getParent())->getMediaHandlerType(); } -void STSDAtom::ReadESDS(uint8 **VOL, size_t *VOLSize, bool forAudio) +void STSDAtom::ReadDecoderConfig(uint8 **pDecoderConfig, size_t *pDecoderConfigSize, AudioDescription *pAudioDescription, VideoDescription *pVideoDescription) { - // Check for a esds and if it exists read it into the VOL buffer - // MPEG-4 video/audio use the esds to store the VOL (STUPID COMMITTEE IDEA) + // Check for a Decoder Config and if it exists copy it back to the caller + // MPEG-4 video/audio use the various decoder config structures to pass additional + // decoder information to the decoder. The extractor sometimes needs to decode the data + // to work out how to properly construct the decoder - // First make sure we have a esds + // First make sure we have a something if (getBytesRemaining() > 0) { // Well something is there so read it as an atom AtomBase *aAtomBase = getAtom(theStream); @@ -1075,11 +1236,11 @@ aAtomBase->ProcessMetaData(); printf("%s [%Ld]\n",aAtomBase->getAtomName(),aAtomBase->getAtomSize()); - if (dynamic_cast(aAtomBase)) { - // ESDS atom good - *VOLSize = dynamic_cast(aAtomBase)->getVOLSize(forAudio); - *VOL = (uint8 *)(malloc(*VOLSize)); - memcpy(*VOL,dynamic_cast(aAtomBase)->getVOL(forAudio),*VOLSize); + if (dynamic_cast(aAtomBase)) { + // DecoderConfig atom good + DecoderConfigAtom *aDecoderConfigAtom = dynamic_cast(aAtomBase); + aDecoderConfigAtom->OverrideAudioDescription(pAudioDescription); + aDecoderConfigAtom->OverrideVideoDescription(pVideoDescription); delete aAtomBase; } else { @@ -1099,7 +1260,7 @@ Read(&theAudioDescription.theAudioSampleEntry.reserved); Read(&theAudioDescription.theAudioSampleEntry.SampleRate); - ReadESDS(&theAudioDescription.theVOL,&theAudioDescription.VOLSize,true); + ReadDecoderConfig(&theAudioDescription.theDecoderConfig, &theAudioDescription.DecoderConfigSize, &theAudioDescription, NULL); } void STSDAtom::ReadVideoDescription() @@ -1129,7 +1290,7 @@ Read(&theVideoDescription.theVideoSampleEntry.Depth); Read(&theVideoDescription.theVideoSampleEntry.pre_defined3); - ReadESDS(&theVideoDescription.theVOL,&theVideoDescription.VOLSize, false); + ReadDecoderConfig(&theVideoDescription.theDecoderConfig, &theVideoDescription.DecoderConfigSize, NULL, &theVideoDescription); } void STSDAtom::OnProcessMetaData() @@ -1331,13 +1492,13 @@ char *MDATAtom::OnGetAtomName() { - printf("Offset %lld, Size %lld ",getStreamOffset(),getAtomSize()); + printf("Offset %lld, Size %lld ",getAtomOffset(),getAtomSize() - 8); return "Media Data Atom"; } off_t MDATAtom::getEOF() { - return getStreamOffset() + getAtomSize(); + return getAtomOffset() + getAtomSize() - 8; } MINFAtom::MINFAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize) : AtomContainer(pStream, pstreamOffset, patomType, patomSize) @@ -1549,7 +1710,7 @@ bigtime_t MDHDAtom::getDuration() { - return bigtime_t((uint64(theHeader.Duration) * 1000000L) / theHeader.TimeScale); + return bigtime_t((theHeader.Duration * 1000000.0) / theHeader.TimeScale); } uint32 MDHDAtom::getTimeScale() Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.h 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.h 2008-05-07 10:08:31 UTC (rev 25340) @@ -171,15 +171,18 @@ void OnProcessMetaData(); char *OnGetAtomName(); - uint64 getSUMCounts() {return SUMCounts;}; - uint64 getSUMDurations() {return SUMDurations;}; - uint32 getSampleForTime(uint32 pTime); + uint64 getSUMCounts() { return SUMCounts; }; + uint64 getSUMDurations() { return SUMDurations; }; + uint32 getSampleForTime(bigtime_t pTime); uint32 getSampleForFrame(uint32 pFrame); + void setFrameRate(float pFrameRate) { FrameRate = pFrameRate; }; + private: array_header theHeader; TimeToSampleArray theTimeToSampleArray; - uint64 SUMDurations; + bigtime_t SUMDurations; uint64 SUMCounts; + float FrameRate; }; // Atom class for reading the composition time to sample atom @@ -300,22 +303,72 @@ off_t getEOF(); }; -class ESDSAtom : public FullAtom { +// Subclass for handling special decoder config atoms like ESDS, ALAC, AVCC, AMR +// ESDS is actually a FullAtom but others are not :-( +class DecoderConfigAtom : public AtomBase { public: + DecoderConfigAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize); + virtual ~DecoderConfigAtom(); + virtual void OnProcessMetaData(); + virtual char *OnGetAtomName(); + + // The decoder config is what the decoder uses for it's setup + // The values SHOULD mirror the Container values but often don't + // So we have to parse the config and use the values as container overrides + void OverrideAudioDescription(AudioDescription *pAudioDescription); + virtual void OnOverrideAudioDescription(AudioDescription *pAudioDescription) {} ; + void OverrideVideoDescription(VideoDescription *pVideoDescription); + virtual void OnOverrideVideoDescription(VideoDescription *pVideoDescription) {} ; + bool SkipTag(uint8 *ESDS, uint8 Tag, uint32 *offset); + + uint8 *getDecoderConfig(); + size_t getDecoderConfigSize() { return DecoderConfigSize; } ; +private: + uint8 *theDecoderConfig; + size_t DecoderConfigSize; +}; + +// Atom class for reading the ESDS decoder config atom +class ESDSAtom : public DecoderConfigAtom { +public: ESDSAtom(BPositionIO *pStream, off_t pstreamOffset, uint32 patomType, uint64 patomSize); virtual ~ESDSAtom(); void OnProcessMetaData(); char *OnGetAtomName(); - - uint8 *getVOL(bool forAudio); - size_t getVOLSize(bool forAudio); + void OnOverrideAudioDescription(AudioDescription *pAudioDescription); + void OnOverrideVideoDescription(VideoDescription *pVideoDescription); private: [... truncated: 599 lines follow ...] From stippi at mail.berlios.de Wed May 7 12:43:13 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 May 2008 12:43:13 +0200 Subject: [Haiku-commits] r25341 - in haiku/trunk: data/artwork/icons src/apps/bsnow Message-ID: <200805071043.m47AhDJM027087@sheep.berlios.de> Author: stippi Date: 2008-05-07 12:43:11 +0200 (Wed, 07 May 2008) New Revision: 25341 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25341&view=rev Added: haiku/trunk/data/artwork/icons/App_BSnow Modified: haiku/trunk/src/apps/bsnow/BSnow.rdef Log: Added HVIF icon for BSnow, courtesy of "Meanwhile". I was planning to do a "snowman" icon for BSnow (big snowballs, coals for eyes, carrot...) but have not found the time yet. Meanwhile and I agree that his icon is much better than the previous one in any case. :-) (Hope you don't take offense, Francois!) Added: haiku/trunk/data/artwork/icons/App_BSnow =================================================================== (Binary files differ) Property changes on: haiku/trunk/data/artwork/icons/App_BSnow ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: haiku/trunk/src/apps/bsnow/BSnow.rdef =================================================================== --- haiku/trunk/src/apps/bsnow/BSnow.rdef 2008-05-07 10:08:31 UTC (rev 25340) +++ haiku/trunk/src/apps/bsnow/BSnow.rdef 2008-05-07 10:43:11 UTC (rev 25341) @@ -1,39 +1,46 @@ -/* -** BSnow.rdef -** -** Automatically generated by BResourceParser on -** Friday, December 21, 2007 at 00:15:36. -** -*/ -resource(1, "BEOS:APP_FLAGS") (#'APPF') $"00000000"; +resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.mmu_man.BSnow"; -resource(1, "BEOS:APP_VERSION") #'APPV' array { - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000000000000000000000000000000000000000000000000000" - $"0000000000000000" +resource app_flags B_SINGLE_LAUNCH; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + variety = B_APPV_DEVELOPMENT, + internal = 0, + + short_info = "BSnow", + long_info = "BSnow ?2007-2008 Haiku" }; -resource(101, "BEOS:L:STD_ICON") #'ICON' array { +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + +resource vector_icon { + $"6E6369660E0500020006023C43C6B9E5E23A85A83CEE414268F44A445962FFFF" + $"FFFFC1CCFF0200040200ECF5FAFFECF5FA020006023B2B47BB18653D0FA53D22" + $"5148297046CA1920FDFDFDFFC1CCFF020004028FFFFFFFFFC1CCFF020006023C" + $"71E33A0C78BA15E43C7D2149055549455700FFFFFFFFC1CCFF05FF020006023A" + $"1DA6393F04BBB5BC3C6B074AEA3648091102C1CCFCBDFFFFFF03DBE2FD020006" + $"023C0AE63B3927BC611E3D03FF4C25624A1A9600C1CCFFB4FFFFFF03C1CCFA03" + $"C1CCFF02000602BD498B3E1159BF219BBE7D2F4C1B8F4A331349C1CCFFFFFFFF" + $"FF040174100A08325E395E41564E5E555E6052584E3E510A06302C303E40454C" + $"3C4C2A3C250A04302C303E404540320A04302C40324C2A3C250A04403240454C" + $"3C4C2A0A0338423C4D3C440A0622422254325C3E513E402E3A0A042242225432" + $"5C32490A04224232493E402E3A0A043249325C3E513E400A063E423E544E5C5A" + $"505A3F4A390A06C785BF40C354C2764E495A3F4A39C391BD6F0A043E42C354C2" + $"76C785BF40C391BD6F0A054151C08BC8834E5C4E49C35DC27A0A053E423E54C0" + $"8BC8834151C35DC27A0A044E494E5C5A505A3E120A0D0100000A0001061815FF" + $"01178400040A00010618001501178600040A010107000A080109000A0B010520" + $"20210A050108000A00010A1001178400040A02010D000A0A010E000A0902040F" + $"000A06010B000A0C010C000A0001011815FF01178400040A0001011800150117" + $"8600040A030102000A040103000A07010400" +}; + +#else + +resource large_icon { $"FFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFF3FFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFF" $"FFFFFF3F3F3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFFFFFF" @@ -68,7 +75,7 @@ $"3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" }; -resource(101, "BEOS:M:STD_ICON") #'MICN' array { +resource mini_icon { $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" $"FFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFF" $"FFFFFFFF3FFFFFFFFFFFFFFF3FFFFFFF" @@ -87,5 +94,5 @@ $"3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" }; -resource(1, "BEOS:APP_SIG") (#'MIMS') "application/x-vnd.mmu_man.BSnow"; +#endif From revol at free.fr Wed May 7 12:43:52 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 07 May 2008 12:43:52 +0200 CEST Subject: [Haiku-commits] r25334 - in haiku/trunk: headers/private/kernel src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86 In-Reply-To: <879378118-BeMail@zon> Message-ID: <457876305-BeMail@laptop> > "Stefano Ceccherini" wrote: > > 2008/5/7 korli at BerliOS : > > > Author: korli > > > Date: 2008-05-07 00:04:25 +0200 (Wed, 07 May 2008) > > > New Revision: 25334 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25334&view=rev > > > > > > Modified: > > > haiku/trunk/headers/private/kernel/safemode.h > > > haiku/trunk/src/system/boot/platform/bios_ia32/menu.cpp > > > haiku/trunk/src/system/kernel/arch/x86/apm.cpp > > > Log: > > > added B_SAFEMODE_DISABLE_APM > > Since there is an option to disable this, maybe we should enable it > > by > > default in the kernel settings. > > That's what it used to be, but I think it was Marcus who disabled it > some time ago. AFAIK there are some pending problems with it (I only > had them when using the PowerStatus app), so it might be better to > have > them disabled for now - you will then know what made your system > unreliable, at least :-) In general APM isn't very reliable by itself, it doesn't work on SMP, and also if you want to at least manage to suspend once correctly you must force vesa mode so the BIOS understands what state the graphics card is. But for things like auto power off and battery status at least it can be useful. > Once Jan's vm86 stuff is in, I wanted to try mapping the lower BIOS > area at the correct position to see if that helps with APM, too. It might help indeed. > Also, we should really better look into getting ACPI to work properly > ASAP. It's on my list, at least. That also means fixing all drivers to support suspend, pending the new driver architecture maybe ? Fran?ois. From stefano.ceccherini at gmail.com Wed May 7 12:50:07 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Wed, 7 May 2008 12:50:07 +0200 Subject: [Haiku-commits] r25334 - in haiku/trunk: headers/private/kernel src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86 In-Reply-To: <457876305-BeMail@laptop> References: <879378118-BeMail@zon> <457876305-BeMail@laptop> Message-ID: <894b9700805070350x149eb263hcb571ee34b65e286@mail.gmail.com> 2008/5/7 Fran?ois Revol : > But for things like auto power off and battery status at least it can > be useful. That's the only reason I enable it in my haiku install, actually. From revol at free.fr Wed May 7 13:01:21 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 07 May 2008 13:01:21 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25341_-_in_haiku/trunk=3A_data/?= =?windows-1252?q?artwork/icons_src/apps/bsnow?= In-Reply-To: <200805071043.m47AhDJM027087@sheep.berlios.de> Message-ID: <1506172680-BeMail@laptop> > Added HVIF icon for BSnow, courtesy of "Meanwhile". I was planning to > do > a "snowman" icon for BSnow (big snowballs, coals for eyes, carrot...) > but have > not found the time yet. Meanwhile and I agree that his icon is much > better than > the previous one in any case. :-) (Hope you don't take offense, > Francois!) > Looks more like ice cubes to me (could give ideas for new app), but it's definitely better :) Sometimes one makes an icon just because one has to :D Fran?ois. From korli at users.berlios.de Wed May 7 13:20:22 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 7 May 2008 13:20:22 +0200 Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: <3067361179-BeMail@zon> References: <3067361179-BeMail@zon> Message-ID: 2008/5/7 Axel D?rfler : > It wouldn't help with find_directory() at all. The add-on helper class > Ingo mentioned could use the add-on path variable to locate add-ons. > Of course, the helper class could also additionally use the private > syscall, but the path variable should still be set to the correct value > when that safemode option is enabled. > Hmm, let's say I want to find the paths for fonts: what would the path variable look like ? Bye, J?r?me From axeld at mail.berlios.de Wed May 7 13:35:21 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 13:35:21 +0200 Subject: [Haiku-commits] r25342 - haiku/trunk/src/preferences Message-ID: <200805071135.m47BZLVF003654@sheep.berlios.de> Author: axeld Date: 2008-05-07 13:35:21 +0200 (Wed, 07 May 2008) New Revision: 25342 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25342&view=rev Modified: haiku/trunk/src/preferences/Jamfile Log: Dial-Up-Network preferences app does not compile - since it's probably going to be removed in the future, I removed it from the build for now. Modified: haiku/trunk/src/preferences/Jamfile =================================================================== --- haiku/trunk/src/preferences/Jamfile 2008-05-07 10:43:11 UTC (rev 25341) +++ haiku/trunk/src/preferences/Jamfile 2008-05-07 11:35:21 UTC (rev 25342) @@ -4,7 +4,7 @@ SubInclude HAIKU_TOP src preferences backgrounds ; SubInclude HAIKU_TOP src preferences datatranslations ; SubInclude HAIKU_TOP src preferences devices ; -SubInclude HAIKU_TOP src preferences dun ; +#SubInclude HAIKU_TOP src preferences dun ; SubInclude HAIKU_TOP src preferences filetypes ; SubInclude HAIKU_TOP src preferences fonts ; SubInclude HAIKU_TOP src preferences joysticks ; From bonefish at mail.berlios.de Wed May 7 14:03:26 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 14:03:26 +0200 Subject: [Haiku-commits] r25343 - haiku/trunk/src/system/libroot/posix Message-ID: <200805071203.m47C3QnP005623@sheep.berlios.de> Author: bonefish Date: 2008-05-07 14:03:25 +0200 (Wed, 07 May 2008) New Revision: 25343 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25343&view=rev Modified: haiku/trunk/src/system/libroot/posix/semaphore.cpp Log: Clear O_EXCL, if O_CREAT is not given. Modified: haiku/trunk/src/system/libroot/posix/semaphore.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-07 11:35:21 UTC (rev 25342) +++ haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-07 12:03:25 UTC (rev 25343) @@ -36,6 +36,9 @@ mode = va_arg(args, mode_t); semCount = va_arg(args, unsigned); va_end(args); + } else { + // clear O_EXCL, if O_CREAT is not given + openFlags &= ~O_EXCL; } // Allocate a sem_t structure -- we don't know, whether this is the first From axeld at mail.berlios.de Wed May 7 14:07:22 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 14:07:22 +0200 Subject: [Haiku-commits] r25344 - haiku/trunk/src/apps/poorman Message-ID: <200805071207.m47C7Mw4005980@sheep.berlios.de> Author: axeld Date: 2008-05-07 14:07:22 +0200 (Wed, 07 May 2008) New Revision: 25344 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25344&view=rev Modified: haiku/trunk/src/apps/poorman/constants.cpp Log: Build fix. Modified: haiku/trunk/src/apps/poorman/constants.cpp =================================================================== --- haiku/trunk/src/apps/poorman/constants.cpp 2008-05-07 12:03:25 UTC (rev 25343) +++ haiku/trunk/src/apps/poorman/constants.cpp 2008-05-07 12:07:22 UTC (rev 25344) @@ -1,5 +1,7 @@ #include "constants.h" +#include + // ------------------------------------------------------ // PoorMan Window extern const char* STR_APP_SIG From bonefish at mail.berlios.de Wed May 7 14:10:38 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 14:10:38 +0200 Subject: [Haiku-commits] r25345 - haiku/trunk/src/system/kernel/posix Message-ID: <200805071210.m47CAcH1006247@sheep.berlios.de> Author: bonefish Date: 2008-05-07 14:10:38 +0200 (Wed, 07 May 2008) New Revision: 25345 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25345&view=rev Modified: haiku/trunk/src/system/kernel/posix/realtime_sem.cpp Log: * Don't try to strdup() the name given for an unnamed semaphore. * When initializing an unnamed semaphore failed, it would be deleted twice. * The user structure pointer wasn't correctly passed when initializing named semaphores. * When opening a named semaphore failed after it has already been published, it is now unlinked again. * The timeout passed to sem_timedwait() is relative to the Epoch. We need to offset to system time. * Added TODO regarding a per team semaphore limit. Modified: haiku/trunk/src/system/kernel/posix/realtime_sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/realtime_sem.cpp 2008-05-07 12:07:22 UTC (rev 25344) +++ haiku/trunk/src/system/kernel/posix/realtime_sem.cpp 2008-05-07 12:10:38 UTC (rev 25345) @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -46,9 +47,11 @@ status_t Init(const char* name, mode_t mode, int32 semCount) { - fName = strdup(name); - if (fName == NULL) - return B_NO_MEMORY; + if (name != NULL) { + fName = strdup(name); + if (fName == NULL) + return B_NO_MEMORY; + } fID = create_sem(semCount, name); if (fID < 0) @@ -171,6 +174,7 @@ return ENOENT; // does not exist yet -- create +// TODO: Enforce per team semaphore limit! sem = new(std::nothrow) SemInfo; if (sem == NULL) return B_NO_MEMORY; @@ -362,16 +366,15 @@ status_t CreateAnonymousSem(uint32 semCount, int& _id) { +// TODO: Enforce per team semaphore limit! SemInfo* sem = new(std::nothrow) SemInfo; if (sem == NULL) return B_NO_MEMORY; ObjectDeleter semDeleter(sem); status_t error = sem->Init(NULL, 0, semCount); - if (error != B_OK) { - delete sem; + if (error != B_OK) return error; - } TeamSemInfo* teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); if (teamSem == NULL) @@ -414,15 +417,19 @@ } // not open yet -- create a new team sem - teamSem = new(std::nothrow) TeamSemInfo(sem, NULL); + teamSem = new(std::nothrow) TeamSemInfo(sem, userSem); if (teamSem == NULL) { sem->ReleaseReference(); + if (_created) + sSemTable.UnlinkSem(name); return B_NO_MEMORY; } error = fSemaphores.Insert(teamSem); if (error != B_OK) { delete teamSem; + if (_created) + sSemTable.UnlinkSem(name); return error; } @@ -469,7 +476,8 @@ error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT, 0); } else { error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT, - timeout); + timeout - rtc_boot_time()); + // The given absolute timeout is relative to the Epoch. } return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; From axeld at mail.berlios.de Wed May 7 14:14:50 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 14:14:50 +0200 Subject: [Haiku-commits] r25346 - haiku/trunk/src/add-ons/accelerants Message-ID: <200805071214.m47CEond006994@sheep.berlios.de> Author: axeld Date: 2008-05-07 14:14:49 +0200 (Wed, 07 May 2008) New Revision: 25346 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25346&view=rev Modified: haiku/trunk/src/add-ons/accelerants/Jamfile Log: Rudolf's accelerant skeleton is not really meant to be built. Modified: haiku/trunk/src/add-ons/accelerants/Jamfile =================================================================== --- haiku/trunk/src/add-ons/accelerants/Jamfile 2008-05-07 12:10:38 UTC (rev 25345) +++ haiku/trunk/src/add-ons/accelerants/Jamfile 2008-05-07 12:14:49 UTC (rev 25346) @@ -9,7 +9,6 @@ SubInclude HAIKU_TOP src add-ons accelerants radeon ; SubInclude HAIKU_TOP src add-ons accelerants s3savage ; SubInclude HAIKU_TOP src add-ons accelerants tdfx ; -SubInclude HAIKU_TOP src add-ons accelerants skeleton ; SubInclude HAIKU_TOP src add-ons accelerants vesa ; SubInclude HAIKU_TOP src add-ons accelerants via ; SubInclude HAIKU_TOP src add-ons accelerants vmware ; From bonefish at mail.berlios.de Wed May 7 14:15:39 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 14:15:39 +0200 Subject: [Haiku-commits] r25347 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200805071215.m47CFdAf007217@sheep.berlios.de> Author: bonefish Date: 2008-05-07 14:15:39 +0200 (Wed, 07 May 2008) New Revision: 25347 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25347&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: Tests for POSIX Realtime semaphores. Unfortunately they reveal that the semantics of fork()ing with unnamed semaphores on other platforms is different from what I thought it was. Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-05-07 12:14:49 UTC (rev 25346) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-05-07 12:15:39 UTC (rev 25347) @@ -10,8 +10,8 @@ : flock_test.cpp ; -SimpleTest signal_test - : signal_test.cpp +SimpleTest realtime_sem_test1 + : realtime_sem_test1.cpp ; SimpleTest setpgid_test : setpgid_test.cpp ; @@ -20,6 +20,10 @@ : setjmp_test.c ; +SimpleTest signal_test + : signal_test.cpp +; + SimpleTest sigsetjmp_test : sigsetjmp_test.c ; Added: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-07 12:14:49 UTC (rev 25346) +++ haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-07 12:15:39 UTC (rev 25347) @@ -0,0 +1,1043 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifdef __HAIKU__ +# include +#else + +typedef int64_t bigtime_t; + +static bigtime_t +system_time() +{ + timeval tv; + gettimeofday(&tv, NULL); + return (bigtime_t)tv.tv_sec * 1000000 + tv.tv_usec; +} + + +#endif // !__HAIKU__ + + +static timespec* +absolute_timeout(timespec& timeout, bigtime_t relativeTimeout) +{ + timeval tv; + gettimeofday(&tv, NULL); + timeout.tv_sec = tv.tv_sec + relativeTimeout / 1000000; + timeout.tv_nsec = (tv.tv_usec + relativeTimeout % 1000000) * 1000; + if (timeout.tv_nsec > 1000000000) { + timeout.tv_sec++; + timeout.tv_nsec -= 1000000000; + } + + return &timeout; +} + + +template +static void +_assert_equals(const char* test, const Type& expected, const Type& actual, + int lineNumber) +{ + if (actual == expected) + return; + + fprintf(stderr, "%s FAILED in line %d\n", test, lineNumber); + exit(1); +} + + +template +static void +_assert_equals_not(const char* test, const Type& unexpected, const Type& actual, + int lineNumber) +{ + if (actual != unexpected) + return; + + fprintf(stderr, "%s FAILED in line %d\n", test, lineNumber); + exit(1); +} + + +static void +_assert_time_equals(const char* test, bigtime_t expected, + bigtime_t actual, int lineNumber) +{ + // allow 2% deviation + bigtime_t diff = actual > expected ? actual - expected : expected - actual; + if (diff <= expected / 50) + return; + + fprintf(stderr, "%s FAILED in line %d: expected time: %lld, actual: %lld\n", + test, lineNumber, (long long)expected, (long long)actual); + exit(1); +} + + +static void +_assert_posix_bool_success(const char* test, bool success, int lineNumber) +{ + if (success) + return; + + fprintf(stderr, "%s FAILED in line %d: %s\n", test, lineNumber, + strerror(errno)); + exit(1); +} + + +static void +_assert_posix_bool_error(const char* test, int expectedError, bool success, + int lineNumber) +{ + if (success) { + fprintf(stderr, "%s FAILED in line %d: call succeeded unexpectedly\n", + test, lineNumber); + exit(1); + } + + if (errno != expectedError) { + fprintf(stderr, "%s FAILED in line %d: call set unexpected error " + "code \"%s\" (0x%x), expected: \"%s\" (0x%x)\n", test, lineNumber, + strerror(errno), errno, strerror(expectedError), expectedError); + exit(1); + } +} + + +static void +test_ok(const char* test) +{ + if (test != NULL) + printf("%s OK\n", test); +} + + +static void +_wait_for_child(const char* test, pid_t child, int lineNumber) +{ + int status; + pid_t result = wait(&status); + _assert_posix_bool_success(test, result >= 0, lineNumber); + _assert_equals(test, child, result, lineNumber); +} + + +#define TEST(test) test_ok(currentTest); currentTest = (test); + +#define assert_equals(expected, actual) \ + _assert_equals(currentTest, (expected), (actual), __LINE__) + +#define assert_equals_not(expected, actual) \ + _assert_equals_not(currentTest, (expected), (actual), __LINE__) + +#define assert_time_equals(expected, actual) \ + _assert_time_equals(currentTest, (expected), (actual), __LINE__) + +#define assert_posix_bool_success(success) \ + _assert_posix_bool_success(currentTest, (success), __LINE__) + +#define assert_posix_success(result) \ + _assert_posix_bool_success(currentTest, (result) == 0, __LINE__) + +#define assert_posix_bool_error(expectedError, success) \ + _assert_posix_bool_error(currentTest, (expectedError), (success), __LINE__) + +#define assert_posix_error(expectedError, result) \ + _assert_posix_bool_error(currentTest, (expectedError), (result) == 0, \ + __LINE__) + +#define wait_for_child(child) \ + _wait_for_child(currentTest, (child), __LINE__) + + +static const char* const kSemName1 = "/test_sem1"; + + +static void +test_open_close_unlink() +{ + const char* currentTest = NULL; + + // open non-existing with O_CREAT + TEST("sem_open(O_CREAT) non-existing"); + sem_t* sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 1); + assert_posix_bool_success(sem != SEM_FAILED); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // open existing with O_CREAT + TEST("sem_open(O_CREAT) existing"); + sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 1); + assert_posix_bool_success(sem != SEM_FAILED); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // open existing without O_CREAT + TEST("sem_open() existing"); + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + // re-open existing without O_CREAT + TEST("sem_open() existing"); + sem_t* sem2 = sem_open(kSemName1, 0); + assert_posix_bool_success(sem2 != SEM_FAILED); + assert_equals(sem, sem2); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // open existing with O_CREAT | O_EXCL + TEST("sem_open(O_CREAT | O_EXCL) existing"); + sem = sem_open(kSemName1, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 1); + assert_posix_bool_error(EEXIST, sem != SEM_FAILED); + + // open existing without O_CREAT + TEST("sem_open() existing"); + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + // unlink + TEST("unlink() existing"); + assert_posix_success(sem_unlink(kSemName1)); + + // open non-existing with O_CREAT | O_EXCL + TEST("sem_open(O_CREAT | O_EXCL) non-existing"); + sem2 = sem_open(kSemName1, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, 2); + assert_posix_bool_success(sem2 != SEM_FAILED); + assert_equals_not(sem, sem2); + + // unlink + TEST("unlink() existing"); + assert_posix_success(sem_unlink(kSemName1)); + + // unlink + TEST("unlink() non-existing"); + assert_posix_error(ENOENT, sem_unlink(kSemName1)); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem2)); + + TEST("done"); +} + + +static void +test_init_destroy() +{ + const char* currentTest = NULL; + + // init + TEST("sem_init()"); + sem_t sem; + assert_posix_success(sem_init(&sem, 0, 1)); + + // destroy + TEST("sem_destroy()"); + assert_posix_success(sem_destroy(&sem)); + + // init + TEST("sem_init()"); + assert_posix_success(sem_init(&sem, 0, 1)); + + // init + TEST("sem_init()"); + sem_t sem2; + assert_posix_success(sem_init(&sem2, 0, 2)); + + // destroy + TEST("sem_destroy()"); + assert_posix_success(sem_destroy(&sem)); + + // destroy + TEST("sem_destroy()"); + assert_posix_success(sem_destroy(&sem2)); + + TEST("done"); +} + + +static void +test_open_close_fork() +{ + const char* currentTest = NULL; + + // open non-existing with O_CREAT + TEST("sem_open(O_CREAT) non-existing"); + sem_t* sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 1); + assert_posix_bool_success(sem != SEM_FAILED); + + TEST("close_sem() forked"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + assert_posix_success(sem_close(sem)); + exit(0); + } else { + // parent + assert_posix_success(sem_close(sem)); + wait_for_child(child); + } + + TEST("sem_open() existing forked"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sem = sem_open(kSemName1, O_CREAT); + assert_posix_bool_success(sem != SEM_FAILED); + exit(0); + } else { + // parent + sem = sem_open(kSemName1, O_CREAT); + wait_for_child(child); + assert_posix_success(sem_close(sem)); + } + + TEST("done"); +} + + +static void +test_init_destroy_fork() +{ + const char* currentTest = NULL; + + // init + TEST("sem_init()"); + sem_t sem; + assert_posix_success(sem_init(&sem, 0, 1)); + + // destroy + TEST("sem_destroy() forked"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + assert_posix_success(sem_destroy(&sem)); + exit(0); + } else { + // parent + assert_posix_success(sem_destroy(&sem)); + wait_for_child(child); + } + + TEST("done"); +} + + +static void +test_post_wait_named() +{ + const char* currentTest = NULL; + + // make sure the sem doesn't exist yet + sem_unlink(kSemName1); + + // open non-existing with O_CREAT + TEST("sem_open(O_CREAT) non-existing"); + sem_t* sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 1); + assert_posix_bool_success(sem != SEM_FAILED); + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // wait + TEST("sem_wait() non-blocking"); + assert_posix_success(sem_wait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // wait + TEST("sem_wait() non-blocking"); + assert_posix_success(sem_wait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + // re-open existing + TEST("sem_open() existing"); + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // trywait + TEST("sem_trywait() success"); + assert_posix_success(sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // trywait + TEST("sem_trywait() success"); + assert_posix_success(sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // trywait failure + TEST("sem_trywait() failure"); + assert_posix_error(EAGAIN, sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // timedwait + TEST("sem_timedwait() success"); + timespec timeout; + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + TEST("sem_timedwait() success"); + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("sem_timedwait() timeout"); + bigtime_t startTime = system_time(); + assert_posix_error(ETIMEDOUT, sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + TEST("done"); +} + + +static void +test_post_wait_unnamed() +{ + const char* currentTest = NULL; + + // init + TEST("sem_init()"); + sem_t _sem; + assert_posix_success(sem_init(&_sem, 0, 1)); + sem_t* sem = &_sem; + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // wait + TEST("sem_wait() non-blocking"); + assert_posix_success(sem_wait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // wait + TEST("sem_wait() non-blocking"); + assert_posix_success(sem_wait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // trywait + TEST("sem_trywait() success"); + assert_posix_success(sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // trywait + TEST("sem_trywait() success"); + assert_posix_success(sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // trywait failure + TEST("sem_trywait() failure"); + assert_posix_error(EAGAIN, sem_trywait(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // post + TEST("sem_post() no waiting"); + assert_posix_success(sem_post(sem)); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(2, value); + + // timedwait + TEST("sem_timedwait() success"); + timespec timeout; + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + TEST("sem_timedwait() success"); + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("sem_timedwait() timeout"); + bigtime_t startTime = system_time(); + assert_posix_error(ETIMEDOUT, sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // destroy + TEST("sem_destroy()"); + assert_posix_success(sem_destroy(sem)); + + TEST("done"); +} + + +static void +test_post_wait_named_fork() +{ + const char* currentTest = NULL; + + // make sure the sem doesn't exist yet + sem_unlink(kSemName1); + + // open non-existing with O_CREAT + TEST("sem_open(O_CREAT) non-existing"); + sem_t* sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock child after wait"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + bigtime_t startTime = system_time(); + assert_posix_success(sem_wait(sem)); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sleep(1); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock parent after wait"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sleep(1); + assert_posix_success(sem_post(sem)); + + exit(0); + } else { + // parent + bigtime_t startTime = system_time(); + assert_posix_success(sem_wait(sem)); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock child after wait before timeout"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + timespec timeout; + bigtime_t startTime = system_time(); + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 2000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sleep(1); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock child after wait after timeout"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + timespec timeout; + bigtime_t startTime = system_time(); + assert_posix_error(ETIMEDOUT, sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sleep(2); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + TEST("done"); +} + + +static void +test_post_wait_named_fork2() +{ + const char* currentTest = NULL; + + // make sure the sem doesn't exist yet + sem_unlink(kSemName1); + + // open non-existing with O_CREAT + TEST("sem_open(O_CREAT) non-existing"); + sem_t* sem = sem_open(kSemName1, O_CREAT, S_IRUSR | S_IWUSR, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + sem = NULL; + + TEST("unblock child after wait"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + bigtime_t startTime = system_time(); + assert_posix_success(sem_wait(sem)); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + sleep(1); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + sem = NULL; + + TEST("unblock child after wait before timeout"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + timespec timeout; + bigtime_t startTime = system_time(); + assert_posix_success(sem_timedwait(sem, + absolute_timeout(timeout, 2000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + sleep(1); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + sem = NULL; + + TEST("unblock child after wait after timeout"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + timespec timeout; + bigtime_t startTime = system_time(); + assert_posix_error(ETIMEDOUT, sem_timedwait(sem, + absolute_timeout(timeout, 1000000))); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sem = sem_open(kSemName1, 0); + assert_posix_bool_success(sem != SEM_FAILED); + + sleep(2); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // close + TEST("sem_close()"); + assert_posix_success(sem_close(sem)); + + TEST("done"); +} + + +#ifdef __HAIKU__ + +static void +test_post_wait_unnamed_fork() +{ + const char* currentTest = NULL; + + // init + TEST("sem_init()"); + sem_t _sem; + assert_posix_success(sem_init(&_sem, 1, 0)); + sem_t* sem = &_sem; + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock child after wait"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + bigtime_t startTime = system_time(); + assert_posix_success(sem_wait(sem)); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + exit(0); + } else { + // parent + sleep(1); + assert_posix_success(sem_post(sem)); + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock parent after wait"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sleep(1); + assert_posix_success(sem_post(sem)); + + exit(0); + } else { + // parent + bigtime_t startTime = system_time(); + assert_posix_success(sem_wait(sem)); + bigtime_t diffTime = system_time() - startTime; + assert_time_equals(1000000, diffTime); + + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + TEST("unblock child after wait before timeout"); + child = fork(); + assert_posix_bool_success(child >= 0); [... truncated: 76 lines follow ...] From mmu_man at mail.berlios.de Wed May 7 16:03:19 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 7 May 2008 16:03:19 +0200 Subject: [Haiku-commits] r25348 - haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam Message-ID: <200805071403.m47E3J1c020436@sheep.berlios.de> Author: mmu_man Date: 2008-05-07 16:03:18 +0200 (Wed, 07 May 2008) New Revision: 25348 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25348&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile Log: missed a file, oddly it was still building (but with undefined symbols... when I say they are bad :P) Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-07 12:15:39 UTC (rev 25347) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Jamfile 2008-05-07 14:03:18 UTC (rev 25348) @@ -37,7 +37,7 @@ ## sensors sources local sensorsSources ; -sensorsSources = hdcs1000.cpp hv7131e1.cpp tas5110c1b.cpp ; +sensorsSources = hdcs1000.cpp hv7131e1.cpp pb0100.cpp tas5110c1b.cpp ; ## how to build header files from sources to include the list of built-in addons. # but it doesn't seem to work for some reason... From stippi at mail.berlios.de Wed May 7 17:38:09 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 May 2008 17:38:09 +0200 Subject: [Haiku-commits] r25349 - haiku/trunk/src/kits/interface Message-ID: <200805071538.m47Fc9Bf029210@sheep.berlios.de> Author: stippi Date: 2008-05-07 17:38:09 +0200 (Wed, 07 May 2008) New Revision: 25349 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25349&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: Fixed bad text antialiasing against the colored background used for input methods. Fixes #2209. Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2008-05-07 14:03:18 UTC (rev 25348) +++ haiku/trunk/src/kits/interface/TextView.cpp 2008-05-07 15:38:09 UTC (rev 25349) @@ -3576,7 +3576,16 @@ } while ((tabChars + numTabs) < numBytes); } - if (inputRegion.CountRects() > 0) { + drawing_mode textRenderingMode = B_OP_COPY; + + if (inputRegion.CountRects() > 0 + && ((offset <= fInline->Offset() + && fInline->Offset() < offset + tabChars) + || (fInline->Offset() <= offset + && offset < fInline->Offset() + fInline->Length()))) { + + textRenderingMode = B_OP_OVER; + BRegion textRegion; GetTextRegion(offset, offset + length, &textRegion); @@ -3608,6 +3617,7 @@ const char *stringToDraw = fText->GetString(offset, &returnedBytes); + view->SetDrawingMode(textRenderingMode); view->DrawString(stringToDraw, returnedBytes); if (foundTab) { float penPos = PenLocation().x - fTextRect.left; From bonefish at mail.berlios.de Wed May 7 17:42:10 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 7 May 2008 17:42:10 +0200 Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200805071542.m47FgAjY029588@sheep.berlios.de> Author: bonefish Date: 2008-05-07 17:42:10 +0200 (Wed, 07 May 2008) New Revision: 25350 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25350&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp Log: * Added more tests for unnamed semaphores. Looks like I have to think of an alternative implementation. * Improved output a bit. Modified: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-07 15:38:09 UTC (rev 25349) +++ haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-07 15:42:10 UTC (rev 25350) @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -124,6 +125,13 @@ static void +test_set(const char* testSet) +{ + printf("\nTEST SET: %s\n", testSet); +} + + +static void test_ok(const char* test) { if (test != NULL) @@ -138,11 +146,25 @@ pid_t result = wait(&status); _assert_posix_bool_success(test, result >= 0, lineNumber); _assert_equals(test, child, result, lineNumber); + _assert_equals(test, 0, status, lineNumber); } -#define TEST(test) test_ok(currentTest); currentTest = (test); +#if 0 +static void +dump_sem(const char* name, sem_t* sem) +{ + printf("%s, %p: ", name, sem); + for (size_t i = 0; i < sizeof(sem_t); i++) + printf("%02x", ((char*)sem)[i]); + printf("\n"); +} +#endif + +#define TEST_SET(testSet) test_set(testSet) +#define TEST(test) test_ok(currentTest); currentTest = (test) + #define assert_equals(expected, actual) \ _assert_equals(currentTest, (expected), (actual), __LINE__) @@ -175,6 +197,8 @@ static void test_open_close_unlink() { + TEST_SET("sem_{open,close,unlink}()"); + const char* currentTest = NULL; // open non-existing with O_CREAT @@ -257,6 +281,8 @@ static void test_init_destroy() { + TEST_SET("sem_{init,destroy}()"); + const char* currentTest = NULL; // init @@ -292,6 +318,8 @@ static void test_open_close_fork() { + TEST_SET("sem_{open,close}() with fork()"); + const char* currentTest = NULL; // open non-existing with O_CREAT @@ -336,6 +364,8 @@ static void test_init_destroy_fork() { + TEST_SET("sem_{init,destroy}() with fork()"); + const char* currentTest = NULL; // init @@ -365,6 +395,8 @@ static void test_post_wait_named() { + TEST_SET("sem_{post,wait,trywait,timedwait}() named semaphore"); + const char* currentTest = NULL; // make sure the sem doesn't exist yet @@ -513,6 +545,8 @@ static void test_post_wait_unnamed() { + TEST_SET("sem_{post,wait,trywait,timedwait}() unnamed semaphore"); + const char* currentTest = NULL; // init @@ -646,6 +680,8 @@ static void test_post_wait_named_fork() { + TEST_SET("sem_{post,wait,trywait,timedwait}() named semaphore with fork()"); + const char* currentTest = NULL; // make sure the sem doesn't exist yet @@ -769,6 +805,9 @@ static void test_post_wait_named_fork2() { + TEST_SET("sem_{post,wait,trywait,timedwait}() named semaphore open after " + "fork"); + const char* currentTest = NULL; // make sure the sem doesn't exist yet @@ -898,24 +937,107 @@ } -#ifdef __HAIKU__ - static void test_post_wait_unnamed_fork() { + TEST_SET("sem_{post,wait,trywait,timedwait}() unnamed semaphore with " + "fork()"); + const char* currentTest = NULL; // init TEST("sem_init()"); sem_t _sem; - assert_posix_success(sem_init(&_sem, 1, 0)); + assert_posix_success(sem_init(&_sem, 1, 1)); sem_t* sem = &_sem; TEST("sem_getvalue()"); int value; assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + TEST("sem_wait() on fork()ed unnamed sem in parent and child"); + pid_t child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + sleep(1); + assert_posix_success(sem_wait(sem)); + + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + exit(0); + } else { + // parent + assert_posix_success(sem_wait(sem)); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); assert_equals(0, value); + TEST("sem_post() on fork()ed unnamed sem in parent and child"); + child = fork(); + assert_posix_bool_success(child >= 0); + + if (child == 0) { + // child + assert_posix_success(sem_post(sem)); + + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + exit(0); + } else { + // parent + assert_posix_success(sem_post(sem)); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + wait_for_child(child); + } + + TEST("sem_getvalue()"); + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(1, value); + + // destroy + TEST("sem_destroy()"); + assert_posix_success(sem_destroy(sem)); + + TEST("done"); +} + + +static void +test_post_wait_unnamed_fork_shared() +{ + TEST_SET("sem_{post,wait,trywait,timedwait}() unnamed semaphore with " + "fork() in shared memory"); + + const char* currentTest = NULL; + + // create shared memory area + void* address = mmap(NULL, 4096, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANON, -1, 0); + assert_posix_bool_success(address != MAP_FAILED); + + // init + TEST("sem_init()"); + sem_t* sem = (sem_t*)address; + assert_posix_success(sem_init(sem, 1, 0)); + + TEST("sem_getvalue()"); + int value; + assert_posix_success(sem_getvalue(sem, &value)); + assert_equals(0, value); + TEST("unblock child after wait"); pid_t child = fork(); assert_posix_bool_success(child >= 0); @@ -1017,12 +1139,13 @@ TEST("sem_destroy()"); assert_posix_success(sem_destroy(sem)); + // unmap memory + assert_posix_success(munmap(address, 4096)); + TEST("done"); } -#endif // __HAIKU__ - int main() { @@ -1034,10 +1157,8 @@ test_post_wait_unnamed(); test_post_wait_named_fork(); test_post_wait_named_fork2(); -#ifdef __HAIKU__ test_post_wait_unnamed_fork(); -// TODO: Check whether Linux and Solaris actually create an -// independent clone of an unnamed semaphore on fork(). Check what happens when -// putting the semaphore in anonymously mmap()ed memory. -#endif + test_post_wait_unnamed_fork_shared(); + + printf("\nall tests OK\n"); } From axeld at mail.berlios.de Wed May 7 18:23:00 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 18:23:00 +0200 Subject: [Haiku-commits] r25351 - haiku/trunk/src/add-ons/kernel/file_cache Message-ID: <200805071623.m47GN07C000540@sheep.berlios.de> Author: axeld Date: 2008-05-07 18:23:00 +0200 (Wed, 07 May 2008) New Revision: 25351 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25351&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp Log: Some minor fix I had laying around on some machine. Modified: haiku/trunk/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp 2008-05-07 15:42:10 UTC (rev 25350) +++ haiku/trunk/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp 2008-05-07 16:23:00 UTC (rev 25351) @@ -553,9 +553,14 @@ RuleMatcher::RuleMatcher(team_id team, const char *name) + : + fRules(NULL) { recursive_lock_lock(&sLock); + if (name == NULL) + return; + fRules = (team_rules *)hash_lookup(sTeamHash, &team); if (fRules != NULL) return; From axeld at mail.berlios.de Wed May 7 18:30:12 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 18:30:12 +0200 Subject: [Haiku-commits] r25352 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda Message-ID: <200805071630.m47GUC5d001196@sheep.berlios.de> Author: axeld Date: 2008-05-07 18:30:11 +0200 (Wed, 07 May 2008) New Revision: 25352 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25352&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h Log: * Rewrote controller reset - it now performs a full reset, and does no longer assume the driver to be in reset when started. * Major cleanup of the register access: now hda_controller and hda_stream both have member functions for this, the OREGx() and REGx() macros are gone. * Made the register names and definitions more descriptive - the short names of the specs are still mentioned in the comments. Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-05-07 16:23:00 UTC (rev 25351) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-05-07 16:30:11 UTC (rev 25352) @@ -51,17 +51,85 @@ }; struct hda_codec; +struct hda_stream; +/*! This structure describes a single HDA compliant + controller. It contains a list of available streams + for use by the codecs contained, and the messaging queue + (verb/response) buffers for communication. +*/ +struct hda_controller { + struct pci_info pci_info; + vint32 opened; + const char* devfs_path; + + area_id regs_area; + vuint8* regs; + uint32 irq; + + uint16 codec_status; + uint32 num_input_streams; + uint32 num_output_streams; + uint32 num_bidir_streams; + + uint32 corb_length; + uint32 rirb_length; + uint32 rirb_read_pos; + uint32 corb_write_pos; + area_id corb_rirb_pos_area; + corb_t* corb; + rirb_t* rirb; + uint32* stream_positions; + + hda_codec* codecs[HDA_MAX_CODECS + 1]; + hda_codec* active_codec; + uint32 num_codecs; + + hda_stream* streams[HDA_MAX_STREAMS]; + + uint8 Read8(uint32 reg) + { + return *(regs + reg); + } + + uint16 Read16(uint32 reg) + { + return *(vuint16*)(regs + reg); + } + + uint32 Read32(uint32 reg) + { + return *(vuint32*)(regs + reg); + } + + void Write8(uint32 reg, uint8 value) + { + *(regs + reg) = value; + } + + void Write16(uint32 reg, uint16 value) + { + *(vuint16*)(regs + reg) = value; + } + + void Write32(uint32 reg, uint32 value) + { + *(vuint32*)(regs + reg) = value; + } +}; + /*! This structure describes a single stream of audio data, which is can have multiple channels (for stereo or better). */ struct hda_stream { uint32 id; /* HDA controller stream # */ - uint32 off; /* HDA I/O/B descriptor offset */ - bool running; /* Is this stream active? */ + uint32 offset; /* HDA I/O/B descriptor offset */ + bool running; spinlock lock; /* Write lock */ uint32 type; + hda_controller* controller; + uint32 pin_widget; /* PIN Widget ID */ uint32 io_widgets[MAX_IO_WIDGETS]; /* Input/Output Converter Widget ID */ uint32 num_io_widgets; @@ -87,6 +155,36 @@ area_id buffer_area; area_id buffer_descriptors_area; uint32 physical_buffer_descriptors; /* BDL physical address */ + + uint8 Read8(uint32 reg) + { + return controller->Read8(HDAC_STREAM_BASE + offset + reg); + } + + uint16 Read16(uint32 reg) + { + return controller->Read16(HDAC_STREAM_BASE + offset + reg); + } + + uint8 Read32(uint32 reg) + { + return controller->Read32(HDAC_STREAM_BASE + offset + reg); + } + + void Write8(uint32 reg, uint8 value) + { + *(controller->regs + HDAC_STREAM_BASE + offset + reg) = value; + } + + void Write16(uint32 reg, uint8 value) + { + *(vuint16*)(controller->regs + HDAC_STREAM_BASE + offset + reg) = value; + } + + void Write32(uint32 reg, uint8 value) + { + *(vuint32*)(controller->regs + HDAC_STREAM_BASE + offset + reg) = value; + } }; struct hda_widget { @@ -174,41 +272,7 @@ struct hda_controller* controller; }; -/*! This structure describes a single HDA compliant - controller. It contains a list of available streams - for use by the codecs contained, and the messaging queue - (verb/response) buffers for communication. -*/ -struct hda_controller { - struct pci_info pci_info; - vint32 opened; - const char* devfs_path; - area_id regs_area; - vuint8* regs; - uint32 irq; - - uint16 codec_status; - uint32 num_input_streams; - uint32 num_output_streams; - uint32 num_bidir_streams; - - uint32 corb_length; - uint32 rirb_length; - uint32 rirb_read_pos; - uint32 corb_write_pos; - area_id corb_rirb_pos_area; - corb_t* corb; - rirb_t* rirb; - uint32* stream_positions; - - hda_codec* codecs[HDA_MAX_CODECS + 1]; - hda_codec* active_codec; - uint32 num_codecs; - - hda_stream* streams[HDA_MAX_STREAMS]; -}; - /* driver.c */ extern device_hooks gDriverHooks; extern pci_module_info* gPci; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp 2008-05-07 16:23:00 UTC (rev 25351) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp 2008-05-07 16:30:11 UTC (rev 25352) @@ -14,10 +14,18 @@ #define MAKE_RATE(base, multiply, divide) \ - ((base == 44100 ? FMT_44_1_BASE_RATE : 0) \ - | ((multiply - 1) << FMT_MULTIPLY_RATE_SHIFT) \ - | ((divide - 1) << FMT_DIVIDE_RATE_SHIFT)) + ((base == 44100 ? FORMAT_44_1_BASE_RATE : 0) \ + | ((multiply - 1) << FORMAT_MULTIPLY_RATE_SHIFT) \ + | ((divide - 1) << FORMAT_DIVIDE_RATE_SHIFT)) +#define HDAC_INPUT_STREAM_OFFSET(controller, index) \ + ((index) * HDAC_STREAM_SIZE) +#define HDAC_OUTPUT_STREAM_OFFSET(controller, index) \ + (((controller)->num_input_streams + (index)) * HDAC_STREAM_SIZE) +#define HDAC_BIDIR_STREAM_OFFSET(controller, index) \ + (((controller)->num_input_streams + (controller)->num_output_streams \ + + (index)) * HDAC_STREAM_SIZE) + static const struct { uint32 multi_rate; uint32 hw_rate; @@ -67,13 +75,13 @@ if (!stream->running) return; - status = OREG8(controller, stream->off, STS); + status = stream->Read8(HDAC_STREAM_STATUS); if (status == 0) return; - OREG8(controller, stream->off, STS) = status; + stream->Write8(HDAC_STREAM_STATUS, status); - if ((status & STS_BCIS) != 0) { + if ((status & STATUS_BUFFER_COMPLETED) != 0) { // Buffer Completed Interrupt acquire_spinlock(&stream->lock); @@ -86,38 +94,38 @@ release_sem_etc(stream->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); } else - dprintf("HDA: stream status %x\n", status); + dprintf("hda: stream status %x\n", status); } static int32 hda_interrupt_handler(hda_controller* controller) { - int32 rc = B_HANDLED_INTERRUPT; + int32 handled = B_HANDLED_INTERRUPT; /* Check if this interrupt is ours */ - uint32 intsts = REG32(controller, INTSTS); - if ((intsts & INTSTS_GIS) == 0) + uint32 intrStatus = controller->Read32(HDAC_INTR_STATUS); + if ((intrStatus & INTR_STATUS_GLOBAL) == 0) return B_UNHANDLED_INTERRUPT; /* Controller or stream related? */ - if (intsts & INTSTS_CIS) { - uint32 stateStatus = REG16(controller, STATESTS); - uint8 rirbStatus = REG8(controller, RIRBSTS); - uint8 corbStatus = REG8(controller, CORBSTS); + if (intrStatus & INTR_STATUS_CONTROLLER) { + uint32 stateStatus = controller->Read16(HDAC_STATE_STATUS); + uint8 rirbStatus = controller->Read8(HDAC_RIRB_STATUS); + uint8 corbStatus = controller->Read8(HDAC_CORB_STATUS); if (stateStatus) { /* Detected Codec state change */ - REG16(controller, STATESTS) = stateStatus; + controller->Write16(HDAC_STATE_STATUS, stateStatus); controller->codec_status = stateStatus; } /* Check for incoming responses */ if (rirbStatus) { - REG8(controller, RIRBSTS) = rirbStatus; + controller->Write8(HDAC_RIRB_STATUS, rirbStatus); - if (rirbStatus & RIRBSTS_RINTFL) { - uint16 writePos = (REG16(controller, RIRBWP) + 1) + if ((rirbStatus & RIRB_STATUS_RESPONSE) != 0) { + uint16 writePos = (controller->Read16(HDAC_RIRB_WRITE_POS) + 1) % controller->rirb_length; for (; controller->rirb_read_pos != writePos; @@ -146,26 +154,26 @@ /* Store response in codec */ codec->responses[codec->response_count++] = response; release_sem_etc(codec->response_sem, 1, B_DO_NOT_RESCHEDULE); - rc = B_INVOKE_SCHEDULER; + handled = B_INVOKE_SCHEDULER; } } - if (rirbStatus & RIRBSTS_OIS) + if ((rirbStatus & RIRB_STATUS_OVERRUN) != 0) dprintf("hda: RIRB Overflow\n"); } /* Check for sending errors */ if (corbStatus) { - REG8(controller, CORBSTS) = corbStatus; + controller->Write8(HDAC_CORB_STATUS, corbStatus); - if (corbStatus & CORBSTS_MEI) + if ((corbStatus & CORB_STATUS_MEMORY_ERROR) != 0) dprintf("hda: CORB Memory Error!\n"); } } - if (intsts & ~(INTSTS_CIS | INTSTS_GIS)) { + if ((intrStatus & INTR_STATUS_STREAM_MASK) != 0) { for (uint32 index = 0; index < HDA_MAX_STREAMS; index++) { - if ((intsts & (1 << index)) != 0) { + if ((intrStatus & (1 << index)) != 0) { if (controller->streams[index]) { stream_handle_interrupt(controller, controller->streams[index]); @@ -179,25 +187,80 @@ /* NOTE: See HDA001 => CIS/GIS cannot be cleared! */ - return rc; + return handled; } static status_t -hda_hw_start(hda_controller* controller) +reset_controller(hda_controller* controller) { - int timeout = 10; + // stop streams - // TODO: reset controller first? (we currently reset on uninit only) + for (uint32 i = 0; i < controller->num_input_streams; i++) { + controller->Write8(HDAC_STREAM_CONTROL0 + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + controller->Write8(HDAC_STREAM_STATUS + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + } + for (uint32 i = 0; i < controller->num_output_streams; i++) { + controller->Write8(HDAC_STREAM_CONTROL0 + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + controller->Write8(HDAC_STREAM_STATUS + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + } + for (uint32 i = 0; i < controller->num_bidir_streams; i++) { + controller->Write8(HDAC_STREAM_CONTROL0 + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + controller->Write8(HDAC_STREAM_STATUS + HDAC_STREAM_BASE + + HDAC_INPUT_STREAM_OFFSET(controller, i), 0); + } - /* Put controller out of reset mode */ - REG32(controller, GCTL) |= GCTL_CRST; + // stop DMA + controller->Write8(HDAC_CORB_CONTROL, 0); + controller->Write8(HDAC_RIRB_CONTROL, 0); - do { + // reset DMA position buffer + controller->Write32(HDAC_DMA_POSITION_BASE_LOWER, 0); + controller->Write32(HDAC_DMA_POSITION_BASE_UPPER, 0); + + // Set reset bit - it must be asserted for at least 100us + + uint32 control = controller->Read32(HDAC_GLOBAL_CONTROL); + controller->Write32(HDAC_GLOBAL_CONTROL, control & ~GLOBAL_CONTROL_RESET); + + for (int timeout = 0; timeout < 10; timeout++) { snooze(100); - } while (--timeout && !(REG32(controller, GCTL) & GCTL_CRST)); - return timeout ? B_OK : B_TIMED_OUT; + control = controller->Read32(HDAC_GLOBAL_CONTROL); + if ((control & GLOBAL_CONTROL_RESET) == 0) + break; + } + if ((control & GLOBAL_CONTROL_RESET) != 0) { + dprintf("hda: unable to reset controller\n"); + return B_BUSY; + } + + // Unset reset bit + + control = controller->Read32(HDAC_GLOBAL_CONTROL); + controller->Write32(HDAC_GLOBAL_CONTROL, control | GLOBAL_CONTROL_RESET); + + for (int timeout = 0; timeout < 10; timeout++) { + snooze(100); + + control = controller->Read32(HDAC_GLOBAL_CONTROL); + if ((control & GLOBAL_CONTROL_RESET) != 0) + break; + } + if ((control & GLOBAL_CONTROL_RESET) == 0) { + dprintf("hda: unable to exit reset\n"); + return B_BUSY; + } + + // Wait for codecs to finish their own reset (apparently needs more + // time than documented in the specs) + snooze(1000); + return B_OK; } @@ -217,29 +280,29 @@ physical_entry pe; /* Determine and set size of CORB */ - corbSize = REG8(controller, CORBSIZE); - if (corbSize & CORBSIZE_CAP_256E) { + corbSize = controller->Read8(HDAC_CORB_SIZE); + if ((corbSize & CORB_SIZE_CAP_256_ENTRIES) != 0) { controller->corb_length = 256; - REG8(controller, CORBSIZE) = CORBSIZE_SZ_256E; - } else if (corbSize & CORBSIZE_CAP_16E) { + controller->Write8(HDAC_CORB_SIZE, CORB_SIZE_256_ENTRIES); + } else if (corbSize & CORB_SIZE_CAP_16_ENTRIES) { controller->corb_length = 16; - REG8(controller, CORBSIZE) = CORBSIZE_SZ_16E; - } else if (corbSize & CORBSIZE_CAP_2E) { + controller->Write8(HDAC_CORB_SIZE, CORB_SIZE_16_ENTRIES); + } else if (corbSize & CORB_SIZE_CAP_2_ENTRIES) { controller->corb_length = 2; - REG8(controller, CORBSIZE) = CORBSIZE_SZ_2E; + controller->Write8(HDAC_CORB_SIZE, CORB_SIZE_2_ENTRIES); } /* Determine and set size of RIRB */ - rirbSize = REG8(controller, RIRBSIZE); - if (rirbSize & RIRBSIZE_CAP_256E) { + rirbSize = controller->Read8(HDAC_RIRB_SIZE); + if (rirbSize & RIRB_SIZE_CAP_256_ENTRIES) { controller->rirb_length = 256; - REG8(controller, RIRBSIZE) = RIRBSIZE_SZ_256E; - } else if (rirbSize & RIRBSIZE_CAP_16E) { + controller->Write8(HDAC_RIRB_SIZE, RIRB_SIZE_256_ENTRIES); + } else if (rirbSize & RIRB_SIZE_CAP_16_ENTRIES) { controller->rirb_length = 16; - REG8(controller, RIRBSIZE) = RIRBSIZE_SZ_16E; - } else if (rirbSize & RIRBSIZE_CAP_2E) { + controller->Write8(HDAC_RIRB_SIZE, RIRB_SIZE_16_ENTRIES); + } else if (rirbSize & RIRB_SIZE_CAP_2_ENTRIES) { controller->rirb_length = 2; - REG8(controller, RIRBSIZE) = RIRBSIZE_SZ_2E; + controller->Write8(HDAC_RIRB_SIZE, RIRB_SIZE_2_ENTRIES); } /* Determine rirb offset in memory and total size of corb+alignment+rirb */ @@ -267,39 +330,43 @@ } /* Program CORB/RIRB for these locations */ - REG32(controller, CORBLBASE) = (uint32)pe.address; - REG32(controller, CORBUBASE) = 0; - REG32(controller, RIRBLBASE) = (uint32)pe.address + rirbOffset; - REG32(controller, RIRBUBASE) = 0; + controller->Write32(HDAC_CORB_BASE_LOWER, (uint32)pe.address); + controller->Write32(HDAC_CORB_BASE_UPPER, 0); + controller->Write32(HDAC_RIRB_BASE_LOWER, (uint32)pe.address + rirbOffset); + controller->Write32(HDAC_RIRB_BASE_UPPER, 0); /* Program DMA position update */ - REG32(controller, DMA_POSITION_BASE_LOWER) = (uint32)pe.address + posOffset; - REG32(controller, DMA_POSITION_BASE_UPPER) = 0; + controller->Write32(HDAC_DMA_POSITION_BASE_LOWER, + (uint32)pe.address + posOffset); + controller->Write32(HDAC_DMA_POSITION_BASE_UPPER, 0); controller->stream_positions = (uint32*) ((uint8*)controller->corb + posOffset); /* Reset CORB read pointer */ /* NOTE: See HDA011 for corrected procedure! */ - REG16(controller, CORBRP) = CORBRP_RST; + controller->Write16(HDAC_CORB_READ_POS, CORB_READ_POS_RESET); do { spin(10); - } while ( !(REG16(controller, CORBRP) & CORBRP_RST) ); - REG16(controller, CORBRP) = 0; + } while ((controller->Read16(HDAC_CORB_READ_POS) + & CORB_READ_POS_RESET) == 0); + controller->Write16(HDAC_CORB_READ_POS, 0); /* Reset RIRB write pointer */ - REG16(controller, RIRBWP) = RIRBWP_RST; + controller->Write16(HDAC_RIRB_WRITE_POS, RIRB_WRITE_POS_RESET); /* Generate interrupt for every response */ - REG16(controller, RINTCNT) = 1; + controller->Write16(HDAC_RESPONSE_INTR_COUNT, 1); /* Setup cached read/write indices */ controller->rirb_read_pos = 1; controller->corb_write_pos = 0; /* Gentlemen, start your engines... */ - REG8(controller, CORBCTL) = CORBCTL_RUN | CORBCTL_MEIE; - REG8(controller, RIRBCTL) = RIRBCTL_DMAEN | RIRBCTL_OIC | RIRBCTL_RINTCTL; + controller->Write8(HDAC_CORB_CONTROL, + CORB_CONTROL_RUN | CORB_CONTROL_MEMORY_ERROR_INTR); + controller->Write8(HDAC_RIRB_CONTROL, RIRB_CONTROL_DMA_ENABLE + | RIRB_CONTROL_OVERRUN_INTR | RIRB_CONTROL_RESPONSE_INTR); return B_OK; } @@ -337,17 +404,18 @@ stream->buffer_area = B_ERROR; stream->buffer_descriptors_area = B_ERROR; stream->type = type; + stream->controller = controller; switch (type) { case STREAM_PLAYBACK: stream->id = 1; - stream->off = controller->num_input_streams * HDAC_SDSIZE; + stream->offset = HDAC_OUTPUT_STREAM_OFFSET(controller, 0); controller->streams[controller->num_input_streams] = stream; break; case STREAM_RECORD: stream->id = 2; - stream->off = 0; + stream->offset = HDAC_INPUT_STREAM_OFFSET(controller, 0); controller->streams[0] = stream; break; @@ -374,22 +442,18 @@ status_t hda_stream_start(hda_controller* controller, hda_stream* stream) { - stream->buffer_ready_sem = create_sem(0, - stream->type == STREAM_PLAYBACK ? "hda_playback_sem" : "hda_record_sem"); + stream->buffer_ready_sem = create_sem(0, stream->type == STREAM_PLAYBACK + ? "hda_playback_sem" : "hda_record_sem"); if (stream->buffer_ready_sem < B_OK) return stream->buffer_ready_sem; - REG32(controller, INTCTL) |= 1 << (stream->off / HDAC_SDSIZE); - OREG8(controller, stream->off, CTL0) |= CTL0_IOCE | CTL0_FEIE | CTL0_DEIE - | CTL0_RUN; + controller->Write32(HDAC_INTR_CONTROL, controller->Read32(HDAC_INTR_CONTROL) + | (1 << (stream->offset / HDAC_STREAM_SIZE))); + stream->Write8(HDAC_STREAM_CONTROL0, stream->Read8(HDAC_STREAM_CONTROL0) + | CONTROL0_BUFFER_COMPLETED_INTR | CONTROL0_FIFO_ERROR_INTR + | CONTROL0_DESCRIPTOR_ERROR_INTR | CONTROL0_RUN); -#if 0 - while (!(OREG8(controller, stream->off, CTL0) & CTL0_RUN)) - snooze(1); -#endif - stream->running = true; - return B_OK; } @@ -400,15 +464,12 @@ status_t hda_stream_stop(hda_controller* controller, hda_stream* stream) { - OREG8(controller, stream->off, CTL0) &= ~(CTL0_IOCE | CTL0_FEIE | CTL0_DEIE - | CTL0_RUN); - REG32(controller, INTCTL) &= ~(1 << (stream->off / HDAC_SDSIZE)); + stream->Write8(HDAC_STREAM_CONTROL0, stream->Read8(HDAC_STREAM_CONTROL0) + & ~(CONTROL0_BUFFER_COMPLETED_INTR | CONTROL0_FIFO_ERROR_INTR + | CONTROL0_DESCRIPTOR_ERROR_INTR | CONTROL0_RUN)); + controller->Write32(HDAC_INTR_CONTROL, controller->Read32(HDAC_INTR_CONTROL) + & ~(1 << (stream->offset / HDAC_STREAM_SIZE))); -#if 0 - while ((OREG8(controller, stream->off, CTL0) & CTL0_RUN) != 0) - snooze(1); -#endif - stream->running = false; delete_sem(stream->buffer_ready_sem); stream->buffer_ready_sem = -1; @@ -513,14 +574,14 @@ /* Configure stream registers */ format = stream->num_channels - 1; switch (stream->sample_format) { - case B_FMT_8BIT_S: format |= FMT_8BIT; stream->bps = 8; break; - case B_FMT_16BIT: format |= FMT_16BIT; stream->bps = 16; break; - case B_FMT_20BIT: format |= FMT_20BIT; stream->bps = 20; break; - case B_FMT_24BIT: format |= FMT_24BIT; stream->bps = 24; break; - case B_FMT_32BIT: format |= FMT_32BIT; stream->bps = 32; break; + case B_FMT_8BIT_S: format |= FORMAT_8BIT; stream->bps = 8; break; + case B_FMT_16BIT: format |= FORMAT_16BIT; stream->bps = 16; break; + case B_FMT_20BIT: format |= FORMAT_20BIT; stream->bps = 20; break; + case B_FMT_24BIT: format |= FORMAT_24BIT; stream->bps = 24; break; + case B_FMT_32BIT: format |= FORMAT_32BIT; stream->bps = 32; break; default: - dprintf("%s: Invalid sample format: 0x%lx\n", __func__, + dprintf("hda: Invalid sample format: 0x%lx\n", stream->sample_format); break; } @@ -536,27 +597,27 @@ dprintf("IRA: %s: setup stream %ld: SR=%ld, SF=%ld\n", __func__, stream->id, stream->rate, stream->bps); - OREG16(audioGroup->codec->controller, stream->off, FMT) = format; - OREG32(audioGroup->codec->controller, stream->off, BDPL) - = stream->physical_buffer_descriptors; - OREG32(audioGroup->codec->controller, stream->off, BDPU) = 0; - OREG16(audioGroup->codec->controller, stream->off, LVI) - = stream->num_buffers - 1; + stream->Write16(HDAC_STREAM_FORMAT, format); + stream->Write32(HDAC_STREAM_BUFFERS_BASE_LOWER, + stream->physical_buffer_descriptors); + stream->Write32(HDAC_STREAM_BUFFERS_BASE_UPPER, 0); + stream->Write16(HDAC_STREAM_LAST_VALID, stream->num_buffers - 1); /* total cyclic buffer size in _bytes_ */ - OREG32(audioGroup->codec->controller, stream->off, CBL) - = stream->sample_size * stream->num_channels * stream->num_buffers - * stream->buffer_length; - OREG8(audioGroup->codec->controller, stream->off, CTL2) = stream->id << 4; + stream->Write32(HDAC_STREAM_BUFFER_SIZE, stream->sample_size + * stream->num_channels * stream->num_buffers * stream->buffer_length); + stream->Write8(HDAC_STREAM_CONTROL2, stream->id << 4); - REG32(audioGroup->codec->controller, DMA_POSITION_BASE_LOWER) - |= DMA_POSITION_ENABLED; + stream->controller->Write32(HDAC_DMA_POSITION_BASE_LOWER, + stream->controller->Read32(HDAC_DMA_POSITION_BASE_LOWER) + | DMA_POSITION_ENABLED); + hda_codec* codec = audioGroup->codec; for (uint32 i = 0; i < stream->num_io_widgets; i++) { - verb[0] = MAKE_VERB(audioGroup->codec->addr, stream->io_widgets[i], + verb[0] = MAKE_VERB(codec->addr, stream->io_widgets[i], VID_SET_CONVERTER_FORMAT, format); - verb[1] = MAKE_VERB(audioGroup->codec->addr, stream->io_widgets[i], + verb[1] = MAKE_VERB(codec->addr, stream->io_widgets[i], VID_SET_CONVERTER_STREAM_CHANNEL, stream->id << 4); - hda_send_verbs(audioGroup->codec, verb, response, 2); + hda_send_verbs(codec, verb, response, 2); } snooze(1000); @@ -572,12 +633,11 @@ { hda_controller *controller = codec->controller; uint32 sent = 0; - status_t rc; codec->response_count = 0; while (sent < count) { - uint32 readPos = REG16(controller, CORBRP); + uint32 readPos = controller->Read16(HDAC_CORB_READ_POS); uint32 queued = 0; while (sent < count) { @@ -594,11 +654,11 @@ queued++; } - REG16(controller, CORBWP) = controller->corb_write_pos; - rc = acquire_sem_etc(codec->response_sem, queued, B_RELATIVE_TIMEOUT, - 1000ULL * 50); - if (rc < B_OK) - return rc; + controller->Write16(HDAC_CORB_WRITE_POS, controller->corb_write_pos); + status_t status = acquire_sem_etc(codec->response_sem, queued, + B_RELATIVE_TIMEOUT, 50000ULL); + if (status < B_OK) + return status; } if (responses != NULL) @@ -612,9 +672,8 @@ status_t hda_hw_init(hda_controller* controller) { - status_t rc; - uint16 gcap; - uint32 index; + uint16 capabilities; + status_t status; /* Map MMIO registers */ controller->regs_area = map_physical_memory("hda_hw_regs", @@ -622,58 +681,58 @@ controller->pci_info.u.h0.base_register_sizes[0], B_ANY_KERNEL_ADDRESS, 0, (void**)&controller->regs); if (controller->regs_area < B_OK) { - rc = controller->regs_area; + status = controller->regs_area; goto error; } /* Absolute minimum hw is online; we can now install interrupt handler */ controller->irq = controller->pci_info.u.h0.interrupt_line; - rc = install_io_interrupt_handler(controller->irq, + status = install_io_interrupt_handler(controller->irq, (interrupt_handler)hda_interrupt_handler, controller, 0); - if (rc != B_OK) + if (status != B_OK) goto no_irq; + capabilities = controller->Read16(HDAC_GLOBAL_CAP); + controller->num_input_streams = GLOBAL_CAP_INPUT_STREAMS(capabilities); + controller->num_output_streams = GLOBAL_CAP_OUTPUT_STREAMS(capabilities); + controller->num_bidir_streams = GLOBAL_CAP_BIDIR_STREAMS(capabilities); + /* show some hw features */ - gcap = REG16(controller, GCAP); - dprintf("HDA: HDA v%d.%d, O:%d/I:%d/B:%d, #SDO:%d, 64bit:%s\n", - REG8(controller, VMAJ), REG8(controller, VMIN), - GCAP_OSS(gcap), GCAP_ISS(gcap), GCAP_BSS(gcap), - GCAP_NSDO(gcap) ? GCAP_NSDO(gcap) *2 : 1, - gcap & GCAP_64OK ? "yes" : "no" ); + dprintf("hda: HDA v%d.%d, O:%ld/I:%ld/B:%ld, #SDO:%d, 64bit:%s\n", + controller->Read8(HDAC_VERSION_MAJOR), + controller->Read8(HDAC_VERSION_MINOR), + controller->num_output_streams, controller->num_input_streams, + controller->num_bidir_streams, + GLOBAL_CAP_NUM_SDO(capabilities), + GLOBAL_CAP_64BIT(capabilities) ? "yes" : "no"); - controller->num_input_streams = GCAP_OSS(gcap); - controller->num_output_streams = GCAP_ISS(gcap); - controller->num_bidir_streams = GCAP_BSS(gcap); - /* Get controller into valid state */ - rc = hda_hw_start(controller); - if (rc != B_OK) + status = reset_controller(controller); + if (status != B_OK) goto reset_failed; /* Setup CORB/RIRB/DMA POS */ - rc = init_corb_rirb_pos(controller); - if (rc != B_OK) + status = init_corb_rirb_pos(controller); + if (status != B_OK) goto corb_rirb_failed; - REG16(controller, WAKEEN) = 0x7fff; + controller->Write16(HDAC_WAKE_ENABLE, 0x7fff); /* Enable controller interrupts */ - REG32(controller, INTCTL) = INTCTL_GIE | INTCTL_CIE; + controller->Write32(HDAC_INTR_CONTROL, INTR_CONTROL_GLOBAL_ENABLE + | INTR_CONTROL_CONTROLLER_ENABLE); - /* Wait for codecs to warm up */ - snooze(1000); - if (!controller->codec_status) { - rc = ENODEV; + status = ENODEV; goto corb_rirb_failed; } - for (index = 0; index < HDA_MAX_CODECS; index++) { + // Create codecs + for (uint32 index = 0; index < HDA_MAX_CODECS; index++) { if ((controller->codec_status & (1 << index)) != 0) hda_codec_new(controller, index); } - - for (index = 0; index < HDA_MAX_CODECS; index++) { + for (uint32 index = 0; index < HDA_MAX_CODECS; index++) { if (controller->codecs[index] && controller->codecs[index]->num_audio_groups > 0) { controller->active_codec = controller->codecs[index]; @@ -684,10 +743,10 @@ if (controller->active_codec != NULL) return B_OK; - rc = ENODEV; + status = ENODEV; corb_rirb_failed: - REG32(controller, INTCTL) = 0; + controller->Write32(HDAC_INTR_CONTROL, 0); reset_failed: remove_io_interrupt_handler(controller->irq, @@ -699,9 +758,9 @@ controller->regs = NULL; error: - dprintf("ERROR: %s(%ld)\n", strerror(rc), rc); + dprintf("hda: ERROR: %s(%ld)\n", strerror(status), status); - return rc; + return status; } @@ -731,17 +790,11 @@ /* Stop all audio streams */ hda_hw_stop(controller); - /* Stop CORB/RIRB */ - REG8(controller, CORBCTL) = 0; - REG8(controller, RIRBCTL) = 0; + reset_controller(controller); - REG32(controller, CORBLBASE) = 0; - REG32(controller, RIRBLBASE) = 0; - REG32(controller, DMA_POSITION_BASE_LOWER) = 0; + /* Disable interrupts, and remove interrupt handler */ + controller->Write32(HDAC_INTR_CONTROL, 0); - /* Disable interrupts, reset controller, and remove interrupt handler */ - REG32(controller, INTCTL) = 0; - REG32(controller, GCTL) &= ~GCTL_CRST; remove_io_interrupt_handler(controller->irq, (interrupt_handler)hda_interrupt_handler, controller); Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h 2008-05-07 16:23:00 UTC (rev 25351) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h 2008-05-07 16:30:11 UTC (rev 25352) @@ -4,135 +4,132 @@ * * Authors: * Ithamar Adema, ithamar AT unet DOT nl + * Axel D?rfler, axeld at pinc-software.de */ #ifndef HDAC_REGS_H #define HDAC_REGS_H + #include -/* Accessors for HDA controller registers */ -#define REG32(controller, reg) (*(vuint32*)((controller)->regs + HDAC_##reg)) -#define REG16(controller, reg) (*(vuint16*)((controller)->regs + HDAC_##reg)) -#define REG8(controller, reg) (*((controller)->regs + HDAC_##reg)) -#define OREG32(controller, stream, reg) \ - (*(vuint32*)((controller)->regs + HDAC_SDBASE + (stream) + HDAC_SD_##reg)) -#define OREG16(controller, stream, reg) \ - (*(vuint16*)((controller)->regs + HDAC_SDBASE + (stream) + HDAC_SD_##reg)) -#define OREG8(controller, stream, reg) \ - (*((controller)->regs + HDAC_SDBASE + (stream) + HDAC_SD_##reg)) +/* Controller register definitions */ +#define HDAC_GLOBAL_CAP 0x00 // 16bits, GCAP +#define GLOBAL_CAP_OUTPUT_STREAMS(cap) (((cap) >> 12) & 15) +#define GLOBAL_CAP_INPUT_STREAMS(cap) (((cap) >> 8) & 15) +#define GLOBAL_CAP_BIDIR_STREAMS(cap) (((cap) >> 3) & 15) +#define GLOBAL_CAP_NUM_SDO(cap) ((((cap) >> 1) & 3) ? (cap & 6) : 1) +#define GLOBAL_CAP_64BIT(cap) (((cap) & 1) != 0) -/* Register definitions */ -#define HDAC_GCAP 0x00 /* 16bits */ -#define GCAP_OSS(gcap) (((gcap) >> 12) & 15) -#define GCAP_ISS(gcap) (((gcap) >> 8) & 15) -#define GCAP_BSS(gcap) (((gcap) >> 3) & 15) -#define GCAP_NSDO(gcap) (((gcap) >> 1) & 3) -#define GCAP_64OK ((gcap) & 1) +#define HDAC_VERSION_MINOR 0x02 // 8bits, VMIN +#define HDAC_VERSION_MAJOR 0x03 // 8bits, VMAJ -#define HDAC_VMIN 0x02 /* 8bits */ -#define HDAC_VMAJ 0x03 /* 8bits */ +#define HDAC_GLOBAL_CONTROL 0x08 // 32bits, GCTL +#define GLOBAL_CONTROL_UNSOLICITED (1 << 8) + // accept unsolicited responses +#define GLOBAL_CONTROL_FLUSH (1 << 1) +#define GLOBAL_CONTROL_RESET (1 << 0) -#define HDAC_GCTL 0x08 /* 32bits */ -#define GCTL_UNSOL (1 << 8) /* Accept Unsolicited responses */ -#define GCTL_FCNTRL (1 << 1) /* Flush Control */ -#define GCTL_CRST (1 << 0) /* Controller Reset */ +#define HDAC_WAKE_ENABLE 0x0c // 16bits, WAKEEN +#define HDAC_STATE_STATUS 0x0e // 16bits, STATESTS -#define HDAC_WAKEEN 0x0c /* 16bits */ -#define HDAC_STATESTS 0x0e /* 16bits */ +#define HDAC_INTR_CONTROL 0x20 // 32bits, INTCTL +#define INTR_CONTROL_GLOBAL_ENABLE (1 << 31) +#define INTR_CONTROL_CONTROLLER_ENABLE (1 << 30) -#define HDAC_INTCTL 0x20 /* 32bits */ -#define INTCTL_GIE (1 << 31) /* Global Interrupt Enable */ -#define INTCTL_CIE (1 << 30) /* Controller Interrupt Enable */ +#define HDAC_INTR_STATUS 0x24 // 32bits, INTSTS +#define INTR_STATUS_GLOBAL (1 << 31) +#define INTR_STATUS_CONTROLLER (1 << 30) +#define INTR_STATUS_STREAM_MASK 0x3fffffff -#define HDAC_INTSTS 0x24 /* 32bits */ -#define INTSTS_GIS (1 << 31) /* Global Interrupt Status */ -#define INTSTS_CIS (1 << 30) /* Controller Interrupt Status */ +#define HDAC_CORB_BASE_LOWER 0x40 // 32bits, CORBLBASE +#define HDAC_CORB_BASE_UPPER 0x44 // 32bits, CORBUBASE +#define HDAC_CORB_WRITE_POS 0x48 // 16bits, CORBWP -#define HDAC_CORBLBASE 0x40 /* 32bits */ -#define HDAC_CORBUBASE 0x44 /* 32bits */ -#define HDAC_CORBWP 0x48 /* 16bits */ +#define HDAC_CORB_READ_POS 0x4a // 16bits, CORBRP +#define CORB_READ_POS_RESET (1 << 15) -#define HDAC_CORBRP 0x4a /* 16bits */ -#define CORBRP_RST (1 << 15) +#define HDAC_CORB_CONTROL 0x4c // 8bits, CORBCTL +#define CORB_CONTROL_RUN (1 << 1) +#define CORB_CONTROL_MEMORY_ERROR_INTR (1 << 0) -#define HDAC_CORBCTL 0x4c /* 8bits */ -#define CORBCTL_RUN (1 << 1) -#define CORBCTL_MEIE (1 << 0) +#define HDAC_CORB_STATUS 0x4d // 8bits, CORBSTS +#define CORB_STATUS_MEMORY_ERROR (1 << 0) -#define HDAC_CORBSTS 0x4d /* 8bits */ -#define CORBSTS_MEI (1 << 0) +#define HDAC_CORB_SIZE 0x4e // 8bits, CORBSIZE +#define CORB_SIZE_CAP_2_ENTRIES (1 << 4) +#define CORB_SIZE_CAP_16_ENTRIES (1 << 5) +#define CORB_SIZE_CAP_256_ENTRIES (1 << 6) +#define CORB_SIZE_2_ENTRIES 0x00 // 8 byte +#define CORB_SIZE_16_ENTRIES 0x01 // 64 byte +#define CORB_SIZE_256_ENTRIES 0x02 // 1024 byte -#define HDAC_CORBSIZE 0x4e /* 8bits */ -#define CORBSIZE_CAP_2E (1 << 4) -#define CORBSIZE_CAP_16E (1 << 5) -#define CORBSIZE_CAP_256E (1 << 6) -#define CORBSIZE_SZ_2E 0 -#define CORBSIZE_SZ_16E (1 << 0) -#define CORBSIZE_SZ_256E (1 << 1) +#define HDAC_RIRB_BASE_LOWER 0x50 // 32bits, RIRBLBASE +#define HDAC_RIRB_BASE_UPPER 0x54 // 32bits, RIRBUBASE -#define HDAC_RIRBLBASE 0x50 /* 32bits */ -#define HDAC_RIRBUBASE 0x54 /* 32bits */ +#define HDAC_RIRB_WRITE_POS 0x58 // 16bits, RIRBWP +#define RIRB_WRITE_POS_RESET (1 << 15) -#define HDAC_RIRBWP 0x58 /* 16bits */ -#define RIRBWP_RST (1 << 15) +#define HDAC_RESPONSE_INTR_COUNT 0x5a // 16bits, RINTCNT -#define HDAC_RINTCNT 0x5a /* 16bits */ +#define HDAC_RIRB_CONTROL 0x5c // 8bits, RIRBCTL +#define RIRB_CONTROL_OVERRUN_INTR (1 << 2) +#define RIRB_CONTROL_DMA_ENABLE (1 << 1) +#define RIRB_CONTROL_RESPONSE_INTR (1 << 0) -#define HDAC_RIRBCTL 0x5c /* 8bits */ -#define RIRBCTL_OIC (1 << 2) -#define RIRBCTL_DMAEN (1 << 1) -#define RIRBCTL_RINTCTL (1 << 0) +#define HDAC_RIRB_STATUS 0x5d // 8bits, RIRBSTS +#define RIRB_STATUS_OVERRUN (1 << 2) +#define RIRB_STATUS_RESPONSE (1 << 0) -#define HDAC_RIRBSTS 0x5d -#define RIRBSTS_OIS (1 << 2) -#define RIRBSTS_RINTFL (1 << 0) +#define HDAC_RIRB_SIZE 0x5e // 8bits, RIRBSIZE +#define RIRB_SIZE_CAP_2_ENTRIES (1 << 4) +#define RIRB_SIZE_CAP_16_ENTRIES (1 << 5) +#define RIRB_SIZE_CAP_256_ENTRIES (1 << 6) +#define RIRB_SIZE_2_ENTRIES 0x00 +#define RIRB_SIZE_16_ENTRIES 0x01 +#define RIRB_SIZE_256_ENTRIES 0x02 -#define HDAC_RIRBSIZE 0x5e /* 8bits */ -#define RIRBSIZE_CAP_2E (1 << 4) -#define RIRBSIZE_CAP_16E (1 << 5) -#define RIRBSIZE_CAP_256E (1 << 6) -#define RIRBSIZE_SZ_2E 0 -#define RIRBSIZE_SZ_16E (1 << 0) -#define RIRBSIZE_SZ_256E (1 << 1) - -#define HDAC_DMA_POSITION_BASE_LOWER 0x70 /* 32bits */ -#define HDAC_DMA_POSITION_BASE_UPPER 0x74 /* 32bits */ +#define HDAC_DMA_POSITION_BASE_LOWER 0x70 // 32bits, DPLBASE +#define HDAC_DMA_POSITION_BASE_UPPER 0x74 // 32bits, DPUBASE #define DMA_POSITION_ENABLED 1 -#define HDAC_SDBASE 0x80 -#define HDAC_SDSIZE 0x20 +/* Stream Descriptor Registers */ +#define HDAC_STREAM_BASE 0x80 +#define HDAC_STREAM_SIZE 0x20 -#define HDAC_SD_CTL0 0x00 /* 8bits */ -#define CTL0_SRST (1 << 0) -#define CTL0_RUN (1 << 1) -#define CTL0_IOCE (1 << 2) -#define CTL0_FEIE (1 << 3) -#define CTL0_DEIE (1 << 4) -#define HDAC_SD_CTL1 0x01 /* 8bits */ -#define HDAC_SD_CTL2 0x02 /* 8bits */ -#define CTL2_DIR (1 << 3) -#define CTL2_TP (1 << 2) -#define HDAC_SD_STS 0x03 /* 8bits */ -#define STS_BCIS (1 << 2) -#define STS_FIFOE (1 << 3) -#define STS_DESE (1 << 4) -#define STS_FIFORDY (1 << 5) -#define HDAC_SD_LPIB 0x04 /* 32bits */ -#define HDAC_SD_CBL 0x08 /* 32bits */ -#define HDAC_SD_LVI 0x0C /* 16bits */ -#define HDAC_SD_FIFOS 0x10 /* 16bits */ -#define HDAC_SD_FMT 0x12 /* 16bits */ -#define FMT_8BIT (0 << 4) -#define FMT_16BIT (1 << 4) -#define FMT_20BIT (2 << 4) -#define FMT_24BIT (3 << 4) -#define FMT_32BIT (4 << 4) -#define FMT_44_1_BASE_RATE (1 << 14) [... truncated: 52 lines follow ...] From axeld at pinc-software.de Wed May 7 18:47:36 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 18:47:36 +0200 CEST Subject: [Haiku-commits] r25333 - haiku/trunk/src/kits/opengl In-Reply-To: Message-ID: <27294246634-BeMail@zon> "J?r?me Duval" wrote: > 2008/5/7 Axel D?rfler : > > It wouldn't help with find_directory() at all. The add-on helper > > class > > Ingo mentioned could use the add-on path variable to locate add- > > ons. > > Of course, the helper class could also additionally use the > > private > > syscall, but the path variable should still be set to the correct > > value > > when that safemode option is enabled. > Hmm, let's say I want to find the paths for fonts: what would the > path > variable look like ? Hm? The variable $ADDON_PATH is surely not used in this case. There is no path variable for fonts, anyway, it's available only through find_directory(). Bye, Axel. From anevilyak at gmail.com Wed May 7 19:42:15 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Wed, 7 May 2008 12:42:15 -0500 Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <200805071542.m47FgAjY029588@sheep.berlios.de> References: <200805071542.m47FgAjY029588@sheep.berlios.de> Message-ID: Hi, On Wed, May 7, 2008 at 10:42 AM, bonefish at BerliOS wrote: > Author: bonefish > Date: 2008-05-07 17:42:10 +0200 (Wed, 07 May 2008) > New Revision: 25350 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25350&view=rev > > Modified: > haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp > Log: > * Added more tests for unnamed semaphores. Looks like I have to think of > an alternative implementation. > * Improved output a bit. I'm curious, what distinguishes XSI semaphores from our native ones in terms of behavior / semantics? I can't seem to find a good link explaining them. Regards, Rene From mmu_man at mail.berlios.de Wed May 7 20:36:35 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 7 May 2008 20:36:35 +0200 Subject: [Haiku-commits] r25353 - haiku/trunk/src/apps/codycam Message-ID: <200805071836.m47IaZbS028417@sheep.berlios.de> Author: mmu_man Date: 2008-05-07 20:36:34 +0200 (Wed, 07 May 2008) New Revision: 25353 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25353&view=rev Modified: haiku/trunk/src/apps/codycam/CodyCam.cpp haiku/trunk/src/apps/codycam/VideoConsumer.cpp Log: - remove hardcoded color - do not force bitmap size for ftp, in case the webcam doesn't give 320x240 it would mess up with memcpy. Maybe we'll want to give the option to either resize to QVGA or keep the native size someday. Modified: haiku/trunk/src/apps/codycam/CodyCam.cpp =================================================================== --- haiku/trunk/src/apps/codycam/CodyCam.cpp 2008-05-07 16:30:11 UTC (rev 25352) +++ haiku/trunk/src/apps/codycam/CodyCam.cpp 2008-05-07 18:36:34 UTC (rev 25353) @@ -39,8 +39,6 @@ const int32 kButtonHeight = 15; const int32 kSliderViewRectHeight = 40; -const rgb_color kViewGray = {216, 216, 216, 255}; - static void ErrorAlert(const char* message, status_t err); static status_t AddTranslationItems(BMenu* intoMenu, uint32 fromType); @@ -477,7 +475,7 @@ aRect.OffsetTo(B_ORIGIN); aRect.top += menuBar->Frame().Height() + 1; fView = new BView(aRect, "Background View", B_FOLLOW_ALL, B_WILL_DRAW); - fView->SetViewColor(kViewGray); + fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(fView); /* add some controls */ Modified: haiku/trunk/src/apps/codycam/VideoConsumer.cpp =================================================================== --- haiku/trunk/src/apps/codycam/VideoConsumer.cpp 2008-05-07 16:30:11 UTC (rev 25352) +++ haiku/trunk/src/apps/codycam/VideoConsumer.cpp 2008-05-07 18:36:34 UTC (rev 25353) @@ -322,6 +322,8 @@ else ERROR("VideoConsumer::CreateBuffers ERROR IN GET BUFFER LIST\n"); + fFtpBitmap = new BBitmap(BRect(0, 0, xSize - 1, ySize - 1), B_RGB32, false, false); + FUNCTION("VideoConsumer::CreateBuffers - EXIT\n"); return status; } @@ -368,7 +370,6 @@ return B_ERROR; } - fFtpBitmap = new BBitmap(BRect(0, 0, 320 - 1, 240 - 1), B_RGB32, false, false); fConnectionActive = true; FUNCTION("VideoConsumer::Connected - EXIT\n"); From stippi at mail.berlios.de Wed May 7 21:22:06 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 May 2008 21:22:06 +0200 Subject: [Haiku-commits] r25354 - haiku/trunk/src/servers/registrar Message-ID: <200805071922.m47JM6c0014045@sheep.berlios.de> Author: stippi Date: 2008-05-07 21:22:05 +0200 (Wed, 07 May 2008) New Revision: 25354 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25354&view=rev Modified: haiku/trunk/src/servers/registrar/MIMEManager.cpp Log: Better naming of a variable. Modified: haiku/trunk/src/servers/registrar/MIMEManager.cpp =================================================================== --- haiku/trunk/src/servers/registrar/MIMEManager.cpp 2008-05-07 18:36:34 UTC (rev 25353) +++ haiku/trunk/src/servers/registrar/MIMEManager.cpp 2008-05-07 19:22:05 UTC (rev 25354) @@ -205,7 +205,7 @@ status_t threadStatus = B_NO_INIT; bool messageIsDetached = false; - bool stillOwnThread = true; + bool stillOwnsThread = true; // Gather our arguments err = message->FindRef("entry", &root); @@ -253,7 +253,7 @@ if (!err) { err = fThreadManager.LaunchThread(thread); if (!err) { - stillOwnThread = false; + stillOwnsThread = false; } } @@ -272,7 +272,7 @@ if (messageIsDetached && threadStatus != B_OK) delete message; // Delete the thread if necessary - if (stillOwnThread) + if (stillOwnsThread) delete thread; break; } From stippi at mail.berlios.de Wed May 7 21:23:12 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 7 May 2008 21:23:12 +0200 Subject: [Haiku-commits] r25355 - haiku/trunk/src/servers/registrar Message-ID: <200805071923.m47JNC2n014125@sheep.berlios.de> Author: stippi Date: 2008-05-07 21:23:11 +0200 (Wed, 07 May 2008) New Revision: 25355 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25355&view=rev Modified: haiku/trunk/src/servers/registrar/ShutdownProcess.cpp Log: Print a message about restarting or shutting down the computer. Since this may take a short moment on real hardware, it is better than the "Asking blah to quit..." which is otherwise still left. Modified: haiku/trunk/src/servers/registrar/ShutdownProcess.cpp =================================================================== --- haiku/trunk/src/servers/registrar/ShutdownProcess.cpp 2008-05-07 19:22:05 UTC (rev 25354) +++ haiku/trunk/src/servers/registrar/ShutdownProcess.cpp 2008-05-07 19:23:11 UTC (rev 25355) @@ -1306,6 +1306,10 @@ // we're through: do the shutdown _SetPhase(DONE_PHASE); + if (fReboot) + _SetShutdownWindowText("Restarting" B_UTF8_ELLIPSIS); + else + _SetShutdownWindowText("Shutting down" B_UTF8_ELLIPSIS); _ShutDown(); _SetShutdownWindowWaitForShutdown(); From ingo_weinhold at gmx.de Wed May 7 22:44:59 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 07 May 2008 22:44:59 +0200 Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: References: <200805071542.m47FgAjY029588@sheep.berlios.de> Message-ID: <20080507224459.1368.3@knochen-vm.1210160172.fake> On 2008-05-07 at 19:42:15 [+0200], Rene Gollent wrote: > > I'm curious, what distinguishes XSI semaphores from our native ones in > terms of behavior / semantics? I can't seem to find a good link > explaining them. To add a bit of confusion: There are actually two semaphore standards which are part of the XSI extension. XSI semaphores are the older one which the somewhat weird interface. The semaphores from the Realtime option group, which I'm trying to implement, are behaviorally quite similar to BeOS semaphores (sem_post() corresponds to release_sem(), sem_{wait,trywait,timedwait}() to acquire_sem[_etc]()). Livetime and sharing between processes differ, though. Named POSIX sems live until deleted explicitly, while BeOS sems die with the owning team. The tricky part turns out to be the unnamed semaphores. They can be created anywhere in memory. If that memory is shared between processes, all processes that can access the memory can also use the semaphore. For the specifications of the individual functions have a look at the Open Group Base Specifications. CU, Ingo From mauricek at mail.berlios.de Wed May 7 23:09:56 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Wed, 7 May 2008 23:09:56 +0200 Subject: [Haiku-commits] r25356 - in haiku/trunk: headers/private/media src/kits/media Message-ID: <200805072109.m47L9uq9022736@sheep.berlios.de> Author: mauricek Date: 2008-05-07 23:09:56 +0200 (Wed, 07 May 2008) New Revision: 25356 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25356&view=rev Modified: haiku/trunk/headers/private/media/MediaExtractor.h haiku/trunk/src/kits/media/MediaExtractor.cpp haiku/trunk/src/kits/media/MediaFile.cpp Log: - Implemented MediaExtractor::Copyright, which just calls the instantiated reader - Implemented BMediaFile::Copyright, which just calls Copyright() of the extractor. So this is just a simple pass through. - Style cleanup (mostly whitespaces) Problem is that our readers currently return the copyright of the source code, not the copyright of the MediaFile itself, like the BeBook documents. Thus, we might need to change all readers to return appropiate data or behave differently for Haiku readers. Modified: haiku/trunk/headers/private/media/MediaExtractor.h =================================================================== --- haiku/trunk/headers/private/media/MediaExtractor.h 2008-05-07 19:23:11 UTC (rev 25355) +++ haiku/trunk/headers/private/media/MediaExtractor.h 2008-05-07 21:09:56 UTC (rev 25356) @@ -27,11 +27,13 @@ ~MediaExtractor(); status_t InitCheck(); - + void GetFileFormatInfo(media_file_format *mfi) const; int32 StreamCount(); - + + const char* Copyright(); + const media_format * EncodedFormat(int32 stream); int64 CountFrames(int32 stream) const; bigtime_t Duration(int32 stream) const; @@ -40,12 +42,13 @@ int64 *frame, bigtime_t *time); status_t FindKeyFrame(int32 stream, uint32 seekTo, int64 *frame, bigtime_t *time) const; - + status_t GetNextChunk(int32 stream, const void **chunkBuffer, size_t *chunkSize, media_header *mediaHeader); - status_t CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci); + status_t CreateDecoder(int32 stream, Decoder **decoder, + media_codec_info *mci); private: static int32 extractor_thread(void *arg); @@ -53,14 +56,14 @@ private: status_t fErr; - + sem_id fExtractorWaitSem; thread_id fExtractorThread; volatile bool fTerminateExtractor; - + BDataIO *fSource; Reader *fReader; - + stream_info * fStreamInfo; int32 fStreamCount; Modified: haiku/trunk/src/kits/media/MediaExtractor.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaExtractor.cpp 2008-05-07 19:23:11 UTC (rev 25355) +++ haiku/trunk/src/kits/media/MediaExtractor.cpp 2008-05-07 21:09:56 UTC (rev 25356) @@ -1,5 +1,6 @@ -/* +/* ** Copyright 2004-2007, Marcus Overhagen. All rights reserved. +** Copyright 2008, Maurice Kalinowski. All rights reserved. ** Distributed under the terms of the MIT License. */ #include "MediaExtractor.h" @@ -71,7 +72,7 @@ "stream %ld failed\n", i); } } - + #if DISABLE_CHUNK_CACHE == 0 // start extractor thread fExtractorWaitSem = create_sem(1, "media extractor thread sem"); @@ -85,7 +86,7 @@ MediaExtractor::~MediaExtractor() { CALLED(); - + // terminate extractor thread fTerminateExtractor = true; release_sem(fExtractorWaitSem); @@ -132,6 +133,13 @@ } +const char* +MediaExtractor::Copyright() +{ + return fReader->Copyright(); +} + + const media_format * MediaExtractor::EncodedFormat(int32 stream) { @@ -148,7 +156,7 @@ media_format format; const void *infoBuffer; size_t infoSize; - + fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration, &format, &infoBuffer, &infoSize); @@ -165,7 +173,7 @@ media_format format; const void *infoBuffer; size_t infoSize; - + fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration, &format, &infoBuffer, &infoSize); @@ -180,16 +188,16 @@ CALLED(); if (fStreamInfo[stream].status != B_OK) return fStreamInfo[stream].status; - + status_t result; result = fReader->Seek(fStreamInfo[stream].cookie, seekTo, frame, time); if (result != B_OK) return result; - + // clear buffered chunks fStreamInfo[stream].chunkCache->MakeEmpty(); release_sem(fExtractorWaitSem); - + return B_OK; } @@ -201,7 +209,7 @@ CALLED(); if (fStreamInfo[stream].status != B_OK) return fStreamInfo[stream].status; - + return fReader->FindKeyFrame(fStreamInfo[stream].cookie, seekTo, frame, time); } @@ -219,7 +227,7 @@ static BLocker locker; BAutolock lock(locker); return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer, - chunkSize, mediaHeader); + chunkSize, mediaHeader); #endif status_t err; @@ -240,7 +248,7 @@ fExtractor = extractor; fStream = stream; } - + virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize, media_header *mediaHeader) { @@ -264,7 +272,7 @@ "stream %ld\n", stream); return res; } - + res = _plugin_manager.CreateDecoder(&decoder, fStreamInfo[stream].encodedFormat); if (res != B_OK) { @@ -283,7 +291,7 @@ } decoder->SetChunkProvider(chunkProvider); - + res = decoder->Setup(&fStreamInfo[stream].encodedFormat, fStreamInfo[stream].infoBuffer, fStreamInfo[stream].infoBufferSize); if (res != B_OK) { @@ -321,7 +329,7 @@ acquire_sem(fExtractorWaitSem); if (fTerminateExtractor) return; - + bool refill_done; do { refill_done = false; Modified: haiku/trunk/src/kits/media/MediaFile.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaFile.cpp 2008-05-07 19:23:11 UTC (rev 25355) +++ haiku/trunk/src/kits/media/MediaFile.cpp 2008-05-07 21:09:56 UTC (rev 25356) @@ -12,7 +12,7 @@ * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @@ -82,7 +82,7 @@ InitWriter(new BFile(ref, O_WRONLY), mfi, flags); } - + BMediaFile::BMediaFile(BDataIO *destination, const media_file_format * mfi, int32 flags) @@ -121,7 +121,7 @@ BMediaFile::~BMediaFile() { CALLED(); - + ReleaseAllTracks(); delete[] fTrackList; delete fExtractor; @@ -130,7 +130,7 @@ } -status_t +status_t BMediaFile::InitCheck() const { CALLED(); @@ -139,7 +139,7 @@ // Get info about the underlying file format. -status_t +status_t BMediaFile::GetFileFormatInfo(media_file_format *mfi) const { CALLED(); @@ -153,8 +153,7 @@ const char * BMediaFile::Copyright(void) const { - UNIMPLEMENTED(); - return ""; + return fExtractor->Copyright(); } @@ -205,7 +204,7 @@ } -status_t +status_t BMediaFile::ReleaseAllTracks(void) { CALLED(); @@ -224,7 +223,7 @@ // Create and add a track to the media file BMediaTrack * -BMediaFile::CreateTrack(media_format *mf, +BMediaFile::CreateTrack(media_format *mf, const media_codec_info *mci, uint32 flags) { @@ -244,7 +243,7 @@ // For BeOS R5 compatibility extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( BMediaFile *self, media_format *mf, const media_codec_info *mci); -BMediaTrack * +BMediaTrack * CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( BMediaFile *self, media_format *mf, @@ -257,7 +256,7 @@ // For BeOS R5 compatibility extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_format( BMediaFile *self, media_format *mf); -BMediaTrack * +BMediaTrack * CreateTrack__10BMediaFileP12media_format( BMediaFile *self, media_format *mf) @@ -345,7 +344,7 @@ } -/* virtual */ status_t +/* virtual */ status_t BMediaFile::Perform(int32 selector, void * data) { UNIMPLEMENTED(); @@ -366,7 +365,7 @@ *************************************************************/ -void +void BMediaFile::Init() { CALLED(); @@ -386,18 +385,18 @@ } -void +void BMediaFile::InitReader(BDataIO *source, int32 flags) { CALLED(); - + fSource = source; - + fExtractor = new MediaExtractor(source, flags); fErr = fExtractor->InitCheck(); if (fErr) return; - + fExtractor->GetFileFormatInfo(&fMFI); fTrackNum = fExtractor->StreamCount(); fTrackList = new BMediaTrack *[fTrackNum]; From mmu_man at mail.berlios.de Wed May 7 23:13:10 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 7 May 2008 23:13:10 +0200 Subject: [Haiku-commits] r25357 - haiku/trunk/src/apps/codycam Message-ID: <200805072113.m47LDALL022921@sheep.berlios.de> Author: mmu_man Date: 2008-05-07 23:13:09 +0200 (Wed, 07 May 2008) New Revision: 25357 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25357&view=rev Modified: haiku/trunk/src/apps/codycam/VideoConsumer.cpp Log: Use the view's Bounds() as target rect when drawing, so if the source is not QVGA it's stretched instead of just clipped. Modified: haiku/trunk/src/apps/codycam/VideoConsumer.cpp =================================================================== --- haiku/trunk/src/apps/codycam/VideoConsumer.cpp 2008-05-07 21:09:56 UTC (rev 25356) +++ haiku/trunk/src/apps/codycam/VideoConsumer.cpp 2008-05-07 21:13:09 UTC (rev 25357) @@ -572,7 +572,7 @@ *p = (*p >> 3) & 0x1f1f1f1f; } - fView->DrawBitmap(fBitmap[index]); + fView->DrawBitmap(fBitmap[index], fView->Bounds()); fWindow->Unlock(); } } From axeld at pinc-software.de Wed May 7 23:13:42 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 23:13:42 +0200 CEST Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <20080507224459.1368.3@knochen-vm.1210160172.fake> Message-ID: <43260518980-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-07 at 19:42:15 [+0200], Rene Gollent > wrote: > > I'm curious, what distinguishes XSI semaphores from our native ones > > in > > terms of behavior / semantics? I can't seem to find a good link > > explaining them. > To add a bit of confusion: There are actually two semaphore standards > which > are part of the XSI extension. XSI semaphores are the older one which > the > somewhat weird interface. The semaphores from the Realtime option > group, > which I'm trying to implement, are behaviorally quite similar to BeOS > semaphores (sem_post() corresponds to release_sem(), > sem_{wait,trywait,timedwait}() to acquire_sem[_etc]()). Livetime and > sharing > between processes differ, though. Named POSIX sems live until deleted > explicitly, while BeOS sems die with the owning team. The tricky part > turns > out to be the unnamed semaphores. They can be created anywhere in > memory. If > that memory is shared between processes, all processes that can > access the > memory can also use the semaphore. So what is your plan? It would be possible to move these semaphores to a special team (like the kernel), and maintain them there. The only question that remains would be how to let them die gracefully - and when :-) Is it possible to map areas and unnamed semaphores together at all? Bye, Axel. From axeld at pinc-software.de Wed May 7 23:17:36 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 07 May 2008 23:17:36 +0200 CEST Subject: [Haiku-commits] r25334 - in haiku/trunk: headers/private/kernel src/system/boot/platform/bios_ia32 src/system/kernel/arch/x86 In-Reply-To: <457876305-BeMail@laptop> Message-ID: <43494395850-BeMail@zon> "Fran?ois Revol" wrote: [APM] > But for things like auto power off and battery status at least it can > be useful. I wouldn't want to use APM for anything else but that. > > Once Jan's vm86 stuff is in, I wanted to try mapping the lower BIOS > > area at the correct position to see if that helps with APM, too. > It might help indeed. Let's hope so. I heard there are lots of other bugs in Haiku, though ;- ) > > Also, we should really better look into getting ACPI to work > > properly > > ASAP. It's on my list, at least. > That also means fixing all drivers to support suspend, pending the > new > driver architecture maybe ? Not really :-) I plan to have a look at power management, but that doesn't have a high priority yet. Bye, Axel. From axeld at mail.berlios.de Wed May 7 23:21:44 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 7 May 2008 23:21:44 +0200 Subject: [Haiku-commits] r25358 - in haiku/trunk: headers/private/kernel/arch/m68k headers/private/kernel/arch/ppc headers/private/kernel/arch/x86 src/system/kernel/vm Message-ID: <200805072121.m47LLiDP023487@sheep.berlios.de> Author: axeld Date: 2008-05-07 23:21:43 +0200 (Wed, 07 May 2008) New Revision: 25358 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25358&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel.h haiku/trunk/headers/private/kernel/arch/ppc/arch_kernel.h haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h haiku/trunk/src/system/kernel/vm/vm.cpp Log: First part of the vm86 work by Jan Kl?\195?\182tzke: * Allow userland teams to create areas below 1 MB when requested specifically. * Note, this is a temporary solution - see the comments in the code. Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel.h 2008-05-07 21:13:09 UTC (rev 25357) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel.h 2008-05-07 21:21:43 UTC (rev 25358) @@ -20,9 +20,10 @@ ** region wont be placed there. The 64kb region assures a user space thread cannot pass ** a buffer into the kernel as part of a syscall that would cross into kernel space. */ -#define USER_BASE 0x100000 -#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) -#define USER_TOP (USER_BASE + USER_SIZE) +#define USER_BASE 0x100000 +#define USER_BASE_ANY USER_BASE +#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) +#define USER_TOP (USER_BASE + USER_SIZE) #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE (USER_BASE + (USER_SIZE - USER_STACK_REGION)) Modified: haiku/trunk/headers/private/kernel/arch/ppc/arch_kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/ppc/arch_kernel.h 2008-05-07 21:13:09 UTC (rev 25357) +++ haiku/trunk/headers/private/kernel/arch/ppc/arch_kernel.h 2008-05-07 21:21:43 UTC (rev 25358) @@ -20,9 +20,10 @@ ** region wont be placed there. The 64kb region assures a user space thread cannot pass ** a buffer into the kernel as part of a syscall that would cross into kernel space. */ -#define USER_BASE 0x100000 -#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) -#define USER_TOP (USER_BASE + USER_SIZE) +#define USER_BASE 0x100000 +#define USER_BASE_ANY USER_BASE +#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) +#define USER_TOP (USER_BASE + USER_SIZE) #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE (USER_BASE + (USER_SIZE - USER_STACK_REGION)) Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h 2008-05-07 21:13:09 UTC (rev 25357) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h 2008-05-07 21:21:43 UTC (rev 25358) @@ -1,7 +1,10 @@ /* -** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ + * Copyright 2004-2008, Haiku Inc. All rights reserved. + * Distributes under the terms of the MIT license. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ #ifndef _KERNEL_ARCH_x86_KERNEL_H #define _KERNEL_ARCH_x86_KERNEL_H @@ -14,19 +17,22 @@ #define KERNEL_SIZE 0x80000000 #define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1)) -/* -** User space layout is a little special: -** The user space does not completely cover the space not covered by the kernel. -** This is accomplished by starting user space at 1Mb and running to 64kb short of kernel space. -** The lower 1Mb reserved spot makes it easy to find null pointer references and guarantees a -** region wont be placed there. The 64kb region assures a user space thread cannot pass -** a buffer into the kernel as part of a syscall that would cross into kernel space. -*/ -#define USER_BASE 0x100000 -#define USER_SIZE (0x80000000 - (0x10000 + 0x100000)) -#define USER_TOP (USER_BASE + USER_SIZE) +/* User space layout is a little special: + * The user space does not completely cover the space not covered by the + * kernel. There is a gap of 64kb between the user and kernel space. The 64kb + * region assures a user space thread cannot pass a buffer into the kernel as + * part of a syscall that would cross into kernel space. + * Furthermore no areas are placed in the lower 1Mb unless the application + * explicitly requests it to find null pointer references. + * TODO: introduce the 1Mb lower barrier again - it's only used for vm86 mode, + * and this should be moved into the kernel (and address space) completely. + */ +#define USER_BASE 0x00 +#define USER_BASE_ANY 0x100000 +#define USER_SIZE (KERNEL_BASE - 0x10000) +#define USER_TOP (USER_BASE + USER_SIZE) #define USER_STACK_REGION 0x70000000 #define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION) -#endif /* _KERNEL_ARCH_x86_KERNEL_H */ +#endif /* _KERNEL_ARCH_x86_KERNEL_H */ Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-07 21:13:09 UTC (rev 25357) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-07 21:21:43 UTC (rev 25358) @@ -1139,12 +1139,11 @@ } -/** This inserts the area you pass into the specified address space. - * It will also set the "_address" argument to its base address when - * the call succeeds. - * You need to hold the vm_address_space semaphore. - */ - +/*! This inserts the area you pass into the specified address space. + It will also set the "_address" argument to its base address when + the call succeeds. + You need to hold the vm_address_space semaphore. +*/ static status_t insert_area(vm_address_space *addressSpace, void **_address, uint32 addressSpec, addr_t size, vm_area *area) @@ -1167,6 +1166,10 @@ case B_ANY_KERNEL_ADDRESS: case B_ANY_KERNEL_BLOCK_ADDRESS: searchBase = addressSpace->base; + // TODO: remove this again when vm86 mode is moved into the kernel + // completely (currently needs a userland address space!) + if (searchBase == USER_BASE) + searchBase = USER_BASE_ANY; searchEnd = addressSpace->base + (addressSpace->size - 1); break; @@ -1175,7 +1178,7 @@ } status = find_and_insert_area_slot(addressSpace, searchBase, size, - searchEnd, addressSpec, area); + searchEnd, addressSpec, area); if (status == B_OK) { // ToDo: do we have to do anything about B_ANY_KERNEL_ADDRESS // vs. B_ANY_KERNEL_BLOCK_ADDRESS here? From mmu_man at mail.berlios.de Wed May 7 23:39:49 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 7 May 2008 23:39:49 +0200 Subject: [Haiku-commits] r25359 - in haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam: . addons/sonix sensors Message-ID: <200805072139.m47LdnRn025139@sheep.berlios.de> Author: mmu_man Date: 2008-05-07 23:39:48 +0200 (Wed, 07 May 2008) New Revision: 25359 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25359&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp Log: - point to logitech opensource website - cleanup - handle frame size suggestions (Codycam gets QVGA now, and eXposer doesn't complain), though the picture is not centered nor scaled yet. - added a stat text parameter to show actual frame rate. Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.cpp 2008-05-07 21:39:48 UTC (rev 25359) @@ -185,6 +185,19 @@ status_t +CamDevice::AcceptVideoFrame(uint32 &width, uint32 &height) +{ + status_t err = ENOSYS; + if (Sensor()) + err = Sensor()->AcceptVideoFrame(width, height); + if (err < B_OK) + return err; + fVideoFrame = BRect(0, 0, width - 1, height - 1); + return B_OK; +} + + +status_t CamDevice::SetVideoFrame(BRect frame) { fVideoFrame = frame; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamDevice.h 2008-05-07 21:39:48 UTC (rev 25359) @@ -57,6 +57,7 @@ virtual status_t StopTransfer(); virtual bool TransferEnabled() const { return fTransferEnabled; }; + virtual status_t AcceptVideoFrame(uint32 &width, uint32 &height); virtual status_t SetVideoFrame(BRect rect); virtual BRect VideoFrame() const { return fVideoFrame; }; virtual status_t SetScale(float scale); Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.cpp 2008-05-07 21:39:48 UTC (rev 25359) @@ -66,6 +66,22 @@ status_t +CamSensor::AcceptVideoFrame(uint32 &width, uint32 &height) +{ + // minimum sanity + if (width < 1) + width = MaxWidth(); + if (height < 1) + height = MaxHeight(); + if (width > MaxWidth()) + width = MaxWidth(); + if (height > MaxHeight()) + height = MaxHeight(); + return B_OK; +} + + +status_t CamSensor::SetVideoFrame(BRect rect) { return ENOSYS; Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/CamSensor.h 2008-05-07 21:39:48 UTC (rev 25359) @@ -28,10 +28,11 @@ virtual bool UseRealIIC() const { return true; }; virtual uint8 IICReadAddress() const { return 0; }; virtual uint8 IICWriteAddress() const { return 0; }; + virtual int MaxWidth() const { return -1; }; virtual int MaxHeight() const { return -1; }; - - + + virtual status_t AcceptVideoFrame(uint32 &width, uint32 &height); virtual status_t SetVideoFrame(BRect rect); virtual BRect VideoFrame() const { return fVideoFrame; }; virtual status_t SetVideoParams(float brightness, float contrast, float hue, float red, float green, float blue); Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.cpp 2008-05-07 21:39:48 UTC (rev 25359) @@ -20,6 +20,14 @@ #include "CamDevice.h" #include "CamSensor.h" +// don't separate parameters from addon, device and sensor +#define SINGLE_PARAMETER_GROUP 1 + +// CodyCam and eXposer prefer 320x240 +//#define FORCE_320_240 1 +//#define FORCE_160_120 1 +//#define FORCE_MAX_FRAME 1 + #define TOUCH(x) ((void)(x)) #define PRINTF(a,b) \ @@ -32,7 +40,9 @@ #include "Producer.h" -#define FIELD_RATE 30.f +//#define FIELD_RATE 30.f +//#define FIELD_RATE 29.97f +#define FIELD_RATE 5.f int32 VideoProducer::fInstances = 0; @@ -139,27 +149,40 @@ return; } - int32 id = P_COLOR; /* Set up the parameter web */ //TODO: remove and put sensible stuff there BParameterWeb *web = new BParameterWeb(); BParameterGroup *main = web->MakeGroup(Name()); - BDiscreteParameter *state = main->MakeDiscreteParameter( + BParameterGroup *g; + + /* + g = main->MakeGroup("Color"); + BDiscreteParameter *state = g->MakeDiscreteParameter( P_COLOR, B_MEDIA_RAW_VIDEO, "Color", "Color"); + state->AddItem(B_HOST_TO_LENDIAN_INT32(0x00ff0000), "Red"); + state->AddItem(B_HOST_TO_LENDIAN_INT32(0x0000ff00), "Green"); + state->AddItem(B_HOST_TO_LENDIAN_INT32(0x000000ff), "Blue"); + */ - id++; + BParameter *p; + g = main->MakeGroup("Info"); + p = g->MakeTextParameter( + P_INFO, B_MEDIA_RAW_VIDEO, "", "Info", 256); + + int32 id = P_LAST; if (fCamDevice) { - BParameterGroup *dev = web->MakeGroup("Device"); - fCamDevice->AddParameters(dev, id); +#ifndef SINGLE_PARAMETER_GROUP + main = web->MakeGroup("Device"); +#endif + fCamDevice->AddParameters(main, id); if (fCamDevice->Sensor()) { - BParameterGroup *sensor = web->MakeGroup("Sensor"); - fCamDevice->Sensor()->AddParameters(sensor, id); +#ifndef SINGLE_PARAMETER_GROUP + main = web->MakeGroup("Sensor"); +#endif + fCamDevice->Sensor()->AddParameters(main, id); } } - state->AddItem(B_HOST_TO_LENDIAN_INT32(0x00ff0000), "Red"); - state->AddItem(B_HOST_TO_LENDIAN_INT32(0x0000ff00), "Green"); - state->AddItem(B_HOST_TO_LENDIAN_INT32(0x000000ff), "Blue"); fColor = B_HOST_TO_LENDIAN_INT32(0x00ff0000); fLastColorChange = system_time(); @@ -179,7 +202,7 @@ fOutput.format.u.raw_video = media_raw_video_format::wildcard; fOutput.format.u.raw_video.interlace = 1; fOutput.format.u.raw_video.display.format = B_RGB32; - fOutput.format.u.raw_video.field_rate = 29.97f; // XXX: mmu + fOutput.format.u.raw_video.field_rate = FIELD_RATE; // XXX: mmu /* Start the BMediaEventLooper control loop running */ Run(); @@ -285,8 +308,16 @@ TOUCH(quality); + PRINTF(1, ("FormatSuggestionRequested() %ldx%ld\n", \ + format->u.raw_video.display.line_width, \ + format->u.raw_video.display.line_count)); + *format = fOutput.format; - format->u.raw_video.field_rate = 29.97f; + if (fCamDevice && fCamDevice->Sensor()) { + format->u.raw_video.display.line_width = fCamDevice->Sensor()->MaxWidth(); + format->u.raw_video.display.line_count = fCamDevice->Sensor()->MaxHeight(); + } + format->u.raw_video.field_rate = FIELD_RATE; return B_OK; } @@ -301,9 +332,30 @@ if (output != fOutput.source) return B_MEDIA_BAD_SOURCE; + PRINTF(1, ("FormatProposal() %ldx%ld\n", \ + format->u.raw_video.display.line_width, \ + format->u.raw_video.display.line_count)); + err = format_is_compatible(*format, fOutput.format) ? B_OK : B_MEDIA_BAD_FORMAT; + + uint32 width = format->u.raw_video.display.line_width; + uint32 height = format->u.raw_video.display.line_count; + *format = fOutput.format; + + if (err == B_OK && fCamDevice) { + err = fCamDevice->AcceptVideoFrame(width, height); + if (err >= B_OK) { + format->u.raw_video.display.line_width = width; + format->u.raw_video.display.line_count = height; + } + } + + PRINTF(1, ("FormatProposal: %ldx%ld\n", \ + format->u.raw_video.display.line_width, \ + format->u.raw_video.display.line_count)); + return err; } @@ -374,7 +426,7 @@ const media_destination &destination, media_format *format, media_source *out_source, char *out_name) { -// status_t err; + status_t err; PRINTF(1, ("PrepareToConnect() %ldx%ld\n", \ format->u.raw_video.display.line_width, \ @@ -399,7 +451,7 @@ } //XXX:FIXME -#if 1 +#if 0 // if (format->u.raw_video.display.line_width == 0) format->u.raw_video.display.line_width = 352;//320; format->u.raw_video.display.line_width = 320; @@ -408,13 +460,34 @@ format->u.raw_video.display.line_count = 240; #endif +#ifdef FORCE_320_240 + { + format->u.raw_video.display.line_width = 320; + format->u.raw_video.display.line_count = 240; + } +#endif +#ifdef FORCE_160_120 + { + format->u.raw_video.display.line_width = 160; + format->u.raw_video.display.line_count = 120; + } +#endif +#ifdef FORCE_MAX_FRAME + { + format->u.raw_video.display.line_width = 0; + format->u.raw_video.display.line_count = 0; + } +#endif if (fCamDevice) { - format->u.raw_video.display.line_width = fCamDevice->VideoFrame().IntegerWidth() + 1; - format->u.raw_video.display.line_count = fCamDevice->VideoFrame().IntegerHeight() + 1; + err = fCamDevice->AcceptVideoFrame( + format->u.raw_video.display.line_width, + format->u.raw_video.display.line_count); + if (err < B_OK) + return err; } if (format->u.raw_video.field_rate == 0) - format->u.raw_video.field_rate = 29.97f; + format->u.raw_video.field_rate = FIELD_RATE; *out_source = fOutput.source; strcpy(out_name, fOutput.name); @@ -584,13 +657,21 @@ { status_t err; - if (id == P_COLOR) { - //return B_BAD_VALUE; + switch (id) { + case P_COLOR: + //return B_BAD_VALUE; - *last_change = fLastColorChange; - *size = sizeof(uint32); - *((uint32 *)value) = fColor; - return B_OK; + *last_change = fLastColorChange; + *size = sizeof(uint32); + *((uint32 *)value) = fColor; + return B_OK; + case P_INFO: + if (*size < fInfoString.Length() + 1) + return EINVAL; + *last_change = fLastColorChange; + *size = fInfoString.Length() + 1; + memcpy(value, fInfoString.String(), *size); + return B_OK; } if (fCamDevice) { @@ -614,22 +695,29 @@ { status_t err = B_OK; - if (id == P_COLOR) { - if (!value || (size != sizeof(uint32))) - return; + switch (id) { + case P_COLOR: + if (!value || (size != sizeof(uint32))) + return; - if (*(uint32 *)value == fColor) + if (*(uint32 *)value == fColor) + return; + + fColor = *(uint32 *)value; + fLastColorChange = when; + break; + case P_INFO: + // forbidden return; + default: + if (fCamDevice == NULL) + return; - fColor = *(uint32 *)value; - fLastColorChange = when; - - } else if (fCamDevice) { - BAutolock lock(fCamDevice->Locker()); - err = fCamDevice->SetParameterValue(id, when, value, size); - if ((err < B_OK) && (fCamDevice->Sensor())) { - err = fCamDevice->Sensor()->SetParameterValue(id, when, value, size); - } + BAutolock lock(fCamDevice->Locker()); + err = fCamDevice->SetParameterValue(id, when, value, size); + if ((err < B_OK) && (fCamDevice->Sensor())) { + err = fCamDevice->Sensor()->SetParameterValue(id, when, value, size); + } } if (err >= B_OK) @@ -724,6 +812,24 @@ release_sem(fFrameSync); } +void +VideoProducer::_UpdateStats() +{ + float fps = (fStats[0].frames - fStats[1].frames) * 1000000LL + / (double)(fStats[0].stamp - fStats[1].stamp); + float rfps = (fStats[0].actual - fStats[1].actual) * 1000000LL + / (double)(fStats[0].stamp - fStats[1].stamp); + fInfoString = "FPS: "; + fInfoString << fps << " virt, " + << rfps << " real, missed: " << fStats[0].missed; + memcpy(&fStats[1], &fStats[0], sizeof(fStats[0])); + fLastColorChange = system_time(); + BroadcastNewParameterValue(fLastColorChange, P_INFO, + (void *)fInfoString.String(), fInfoString.Length()+1); +} + + + /* The following functions form the thread that generates frames. You should * replace this with the code that interfaces to your hardware. */ int32 @@ -752,6 +858,7 @@ ((fFrame - fFrameBase) * (1000000 / fConnectedFormat.field_rate)) - fProcessingLatency; +PRINT(("PS: %Ld\n", fProcessingLatency)); /* Drop frame if it's at least a frame late */ if (wait_until < system_time()) @@ -822,11 +929,13 @@ //NO! must be called without lock! //BAutolock lock(fCamDevice->Locker()); + bigtime_t now = system_time(); bigtime_t stamp; //#ifdef UseFillFrameBuffer err = fCamDevice->FillFrameBuffer(buffer, &stamp); if (err < B_OK) { ;//XXX handle error + fStats[0].missed++; } //#endif #ifdef UseGetFrameBitmap @@ -834,13 +943,24 @@ err = fCamDevice->GetFrameBitmap(&bm, &stamp); if (err >= B_OK) { ;//XXX handle error + fStats[0].missed++; } #endif + fStats[0].frames = fFrame; + fStats[0].actual++;; + fStats[0].stamp = system_time(); + //PRINTF(1, ("FrameGenerator: stamp %Ld vs %Ld\n", stamp, h->start_time)); //XXX: that's what we should be doing, but CodyCam drops all frames as they are late. (maybe add latency ??) //h->start_time = TimeSource()->PerformanceTimeFor(stamp); h->start_time = TimeSource()->PerformanceTimeFor(system_time()); + + // update processing latency + // XXX: should I ?? + fProcessingLatency = system_time() - now; + fProcessingLatency /= 10; + PRINTF(1, ("FrameGenerator: SendBuffer...\n")); /* Send the buffer on down to the consumer */ if (SendBuffer(buffer, fOutput.destination) < B_OK) { @@ -849,6 +969,8 @@ * buffer group. */ buffer->Recycle(); } + + _UpdateStats(); } PRINTF(1, ("FrameGenerator: thread existed.\n")); Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/Producer.h 2008-05-07 21:39:48 UTC (rev 25359) @@ -8,8 +8,11 @@ #include #include #include +#include class CamDevice; +class BParameter; +class BTextParameter; class VideoProducer : public virtual BMediaEventLooper, @@ -106,6 +109,8 @@ void HandleTimeWarp(bigtime_t performance_time); void HandleSeek(bigtime_t performance_time); + void _UpdateStats(); + static int32 fInstances; status_t fInitStatus; @@ -134,9 +139,21 @@ bool fConnected; bool fEnabled; - enum { P_COLOR }; + enum { + P_COLOR, + P_INFO, + P_LAST // first available for addons + }; uint32 fColor; - bigtime_t fLastColorChange; + BString fInfoString; + bigtime_t fLastColorChange; // TODO: rename + + struct { + uint32 frames; + uint32 actual; + uint32 missed; + bigtime_t stamp; + } fStats[2]; }; #endif Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/README.txt 2008-05-07 21:39:48 UTC (rev 25359) @@ -54,6 +54,9 @@ References and other drivers of interest: +* Logitech opensource effort: +http://www.quickcamteam.net/ + * Sonix linux drivers (several of them): http://sourceforge.net/projects/sonix/ -- http://sonix.sourceforge.net/ http://freshmeat.net/projects/sonic-snap/?branch_id=55324&release_id=183982 Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/addons/sonix/SonixCamDevice.cpp 2008-05-07 21:39:48 UTC (rev 25359) @@ -163,7 +163,7 @@ SetScale(1); if (Sensor()) - SetVideoFrame(BRect(0, 0, Sensor()->MaxWidth()-1, Sensor()->MaxHeight()-1)); + SetVideoFrame(fVideoFrame); //SetVideoFrame(BRect(0, 0, 320-1, 240-1)); Modified: haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-07 21:21:43 UTC (rev 25358) +++ haiku/trunk/src/add-ons/media/media-add-ons/usb_webcam/sensors/tas5110c1b.cpp 2008-05-07 21:39:48 UTC (rev 25359) @@ -19,8 +19,11 @@ virtual bool UseRealIIC() const { return false; }; virtual uint8 IICReadAddress() const { return 0x00; }; virtual uint8 IICWriteAddress() const { return 0x11; /*0xff;*/ }; + virtual int MaxWidth() const { return 352; }; virtual int MaxHeight() const { return 288; }; + + virtual status_t AcceptVideoFrame(uint32 &width, uint32 &height); virtual status_t SetVideoFrame(BRect rect); virtual void AddParameters(BParameterGroup *group, int32 &firstID); virtual status_t GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size); @@ -31,7 +34,7 @@ float fGain; }; -// ----------------------------------------------------------------------------- + TAS5110C1BSensor::TAS5110C1BSensor(CamDevice *_camera) : CamSensor(_camera) { @@ -45,12 +48,12 @@ fGain = (float)0x40; // default } -// ----------------------------------------------------------------------------- + TAS5110C1BSensor::~TAS5110C1BSensor() { } -// ----------------------------------------------------------------------------- + status_t TAS5110C1BSensor::Setup() { @@ -93,15 +96,31 @@ return B_OK; } -// ----------------------------------------------------------------------------- + const char * TAS5110C1BSensor::Name() { return "TASC tas5110c1b"; } -// ----------------------------------------------------------------------------- + status_t +TAS5110C1BSensor::AcceptVideoFrame(uint32 &width, uint32 &height) +{ + // default sanity checks + status_t err = CamSensor::AcceptVideoFrame(width, height); + if (err < B_OK) + return err; + // must be modulo 16 + width /= 16; + width *= 16; + height /= 16; + height *= 16; + return B_OK; +} + + +status_t TAS5110C1BSensor::SetVideoFrame(BRect rect) { if (fIsSonix) { @@ -120,6 +139,7 @@ return B_OK; } + void TAS5110C1BSensor::AddParameters(BParameterGroup *group, int32 &index) { @@ -128,7 +148,8 @@ #ifdef ENABLE_GAIN // NON-FUNCTIONAL - p = group->MakeContinuousParameter(index++, + BParameterGroup *g = group->MakeGroup("global gain"); + p = g->MakeContinuousParameter(index++, B_MEDIA_RAW_VIDEO, "global gain", B_GAIN, "", (float)0x00, (float)0xf6, (float)1); #endif @@ -148,6 +169,7 @@ return B_BAD_VALUE; } + status_t TAS5110C1BSensor::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size) { @@ -179,6 +201,6 @@ } -// ----------------------------------------------------------------------------- + B_WEBCAM_DECLARE_SENSOR(TAS5110C1BSensor, tas5110c1b) From ingo_weinhold at gmx.de Thu May 8 00:20:38 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 08 May 2008 00:20:38 +0200 Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <43260518980-BeMail@zon> References: <43260518980-BeMail@zon> Message-ID: <20080508002038.1604.6@knochen-vm.1210160172.fake> On 2008-05-07 at 23:13:42 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2008-05-07 at 19:42:15 [+0200], Rene Gollent > > wrote: > > > I'm curious, what distinguishes XSI semaphores from our native ones > > > in > > > terms of behavior / semantics? I can't seem to find a good link > > > explaining them. > > To add a bit of confusion: There are actually two semaphore standards > > which > > are part of the XSI extension. XSI semaphores are the older one which > > the > > somewhat weird interface. The semaphores from the Realtime option > > group, > > which I'm trying to implement, are behaviorally quite similar to BeOS > > semaphores (sem_post() corresponds to release_sem(), > > sem_{wait,trywait,timedwait}() to acquire_sem[_etc]()). Livetime and > > sharing > > between processes differ, though. Named POSIX sems live until deleted > > explicitly, while BeOS sems die with the owning team. The tricky part > > turns > > out to be the unnamed semaphores. They can be created anywhere in > > memory. If > > that memory is shared between processes, all processes that can > > access the > > memory can also use the semaphore. > > So what is your plan? It would be possible to move these semaphores to > a special team (like the kernel), and maintain them there. Currently I just use BeOS semaphores owned by the kernel. There's no real problem with using unnamed semaphores in shared memory (well, the kernel implementation isn't quite correct yet), since the sem_t structure stores the ID of the BeOS semaphore -- so all teams will automatically use the correct semaphore. A problem is, that unnamed semaphores not living in shared memory would be automatically shared by parent and child after a fork(), too. At least Linux and Solaris behave differently; there the sem_t structure actually is the semaphore (no kernel resources seem to be involved) and a fork() thus results in two independent semaphores. I've just look through the Free/NetBSD implementation, which is similar to my current one, though they don't even really support shared unnamed semaphores. So maybe I shouldn't bother that much. The specification doesn't say what is supposed to happen on fork(). It only says that referring to copies of the semaphore structure for use with the sem_*() functions has undefined results. It's unclear whether that includes copies through fork(). I don't think it does, though. > The only > question that remains would be how to let them die gracefully - and > when :-) > Is it possible to map areas and unnamed semaphores together at all? You mean like automatically destroying the semaphore when the last area is deleted? I considered allowing to add objects to areas that would be automatically destroyed when the area is destroyed (and cloned when it is cloned), but I'm not sure whether this is a good path to follow. CU, Ingo From korli at mail.berlios.de Thu May 8 00:43:47 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 00:43:47 +0200 Subject: [Haiku-commits] r25360 - haiku/trunk/src/apps/installer Message-ID: <200805072243.m47MhlWV020602@sheep.berlios.de> Author: korli Date: 2008-05-08 00:43:45 +0200 (Thu, 08 May 2008) New Revision: 25360 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25360&view=rev Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp Log: this break was forgotten Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-05-07 21:39:48 UTC (rev 25359) +++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-05-07 22:43:45 UTC (rev 25360) @@ -230,6 +230,7 @@ SetStatusMessage(status); } else SetStatusMessage(fLastStatus.String()); + break; } case INSTALL_FINISHED: DisableInterface(false); From revol at free.fr Thu May 8 02:22:18 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 02:22:18 +0200 CEST Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <20080508002038.1604.6@knochen-vm.1210160172.fake> Message-ID: <830003653-BeMail@laptop> > > > To add a bit of confusion: There are actually two semaphore > > > standards > > > which > > > are part of the XSI extension. XSI semaphores are the older one > > > which > > > the > > > somewhat weird interface. The semaphores from the Realtime option SysV IPC... let them die. > > > out to be the unnamed semaphores. They can be created anywhere in > > > memory. If > > > that memory is shared between processes, all processes that can > > > access the > > > memory can also use the semaphore. Was about to tell use phys address as key, but that won't work if it's swapped out/in. > I've just look through the Free/NetBSD implementation, which is > similar to > my current one, though they don't even really support shared unnamed > semaphores. So maybe I shouldn't bother that much. The specification > doesn't say what is supposed to happen on fork(). It only says that If it doesn't say, then it's implementation-defined. In that case if they ever change the specs you can complain they went bad in the first place and it's their fault. Fran?ois. From ingo_weinhold at gmx.de Thu May 8 03:21:37 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 08 May 2008 03:21:37 +0200 Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <830003653-BeMail@laptop> References: <830003653-BeMail@laptop> Message-ID: <20080508032137.1744.7@knochen-vm.1210160172.fake> On 2008-05-08 at 02:22:18 [+0200], Fran?ois Revol wrote: > > > > > out to be the unnamed semaphores. They can be created anywhere in > > > > memory. If > > > > that memory is shared between processes, all processes that can > > > > access the > > > > memory can also use the semaphore. > > Was about to tell use phys address as key, but that won't work if it's > swapped out/in. Yep, that's a problem though, since it can be arbitrary user memory. > > I've just look through the Free/NetBSD implementation, which is > > similar to > > my current one, though they don't even really support shared unnamed > > semaphores. So maybe I shouldn't bother that much. The specification > > doesn't say what is supposed to happen on fork(). It only says that > > If it doesn't say, then it's implementation-defined. > In that case if they ever change the specs you can complain they went > bad in the first place and it's their fault. I'm less worried about the specs writers than about the people who interpret the specs and write software that we might want to port to Haiku. If something that is implementation-defined works in some way on other platforms, it's probably not too bad an idea to implement the same behavior. The *BSDs are farther off concerning unnamed semaphores than we are ATM, so I guess we're fine. CU, Ingo From bonefish at mail.berlios.de Thu May 8 03:27:32 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 03:27:32 +0200 Subject: [Haiku-commits] r25361 - in haiku/trunk: headers/posix headers/private/kernel/posix src/system/libroot/posix/unistd Message-ID: <200805080127.m481RWE1001411@sheep.berlios.de> Author: bonefish Date: 2008-05-08 03:27:31 +0200 (Thu, 08 May 2008) New Revision: 25361 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25361&view=rev Modified: haiku/trunk/headers/posix/unistd.h haiku/trunk/headers/private/kernel/posix/realtime_sem.h haiku/trunk/src/system/libroot/posix/unistd/conf.c Log: * Fixed some misunderstanding regarding the _POSIX_* macros. They are not supposed to be passed to pathconf() or sysconf(). * Added POSIX semaphore related macros. Modified: haiku/trunk/headers/posix/unistd.h =================================================================== --- haiku/trunk/headers/posix/unistd.h 2008-05-07 22:43:45 UTC (rev 25360) +++ haiku/trunk/headers/posix/unistd.h 2008-05-08 01:27:31 UTC (rev 25361) @@ -28,8 +28,15 @@ #define F_TEST 3 /* test a section for locks by other processes */ /* POSIX version support */ -#define _POSIX_VERSION (199009L) +#define _POSIX_VERSION (199009L) /* TODO: Update! */ +#define _POSIX_CHOWN_RESTRICTED 1 +#define _POSIX_JOB_CONTROL 1 +#define _POSIX_NO_TRUNC 0 +#define _POSIX_SAVED_IDS 1 +#define _POSIX_VDISABLE ((char)-2) /* TODO: Check this! */ +#define _POSIX_SEMAPHORES (200112L) + /* pathconf() constants */ #define _PC_CHOWN_RESTRICTED 1 #define _PC_MAX_CANON 2 @@ -40,11 +47,6 @@ #define _PC_PIPE_BUF 7 #define _PC_VDISABLE 8 #define _PC_LINK_MAX 25 -#define _POSIX_CHOWN_RESTRICTED 9 -#define _POSIX_JOB_CONTROL 10 -#define _POSIX_NO_TRUNC 11 -#define _POSIX_SAVED_IDS 12 -#define _POSIX_VDISABLE ((cc_t) - 2) /* sysconf() constants */ #define _SC_ARG_MAX 15 @@ -61,6 +63,9 @@ #define _SC_GETPW_R_SIZE_MAX 26 #define _SC_PAGE_SIZE 27 #define _SC_PAGESIZE _SC_PAGE_SIZE +#define _SC_SEM_NSEMS_MAX 28 +#define _SC_SEM_VALUE_MAX 29 +#define _SC_SEMAPHORES 30 /* lseek() constants */ #ifndef SEEK_SET Modified: haiku/trunk/headers/private/kernel/posix/realtime_sem.h =================================================================== --- haiku/trunk/headers/private/kernel/posix/realtime_sem.h 2008-05-07 22:43:45 UTC (rev 25360) +++ haiku/trunk/headers/private/kernel/posix/realtime_sem.h 2008-05-08 01:27:31 UTC (rev 25361) @@ -15,6 +15,11 @@ struct realtime_sem_context; +#define MAX_POSIX_SEMS_PER_TEAM 128 +#define MAX_POSIX_SEMS 1024 +#define MAX_POSIX_SEM_VALUE INT_MAX + + __BEGIN_DECLS void realtime_sem_init(); @@ -22,7 +27,7 @@ struct realtime_sem_context* clone_realtime_sem_context( struct realtime_sem_context* context); -status_t _user_realtime_sem_open(const char* name, int openFlags, +status_t _user_realtime_sem_open(const char* name, int openFlagsOrShared, mode_t mode, uint32 semCount, sem_t* userSem, sem_t** _usedUserSem); status_t _user_realtime_sem_close(sem_id semID, sem_t** _deleteUserSem); Modified: haiku/trunk/src/system/libroot/posix/unistd/conf.c =================================================================== --- haiku/trunk/src/system/libroot/posix/unistd/conf.c 2008-05-07 22:43:45 UTC (rev 25360) +++ haiku/trunk/src/system/libroot/posix/unistd/conf.c 2008-05-08 01:27:31 UTC (rev 25361) @@ -15,6 +15,7 @@ #include #include +#include #include @@ -61,6 +62,12 @@ return MAX_PASSWD_BUFFER_SIZE; case _SC_PAGE_SIZE: return B_PAGE_SIZE; + case _SC_SEM_NSEMS_MAX: + return MAX_POSIX_SEMS; + case _SC_SEM_VALUE_MAX: + return MAX_POSIX_SEM_VALUE; + case _SC_SEMAPHORES: + return _POSIX_SEMAPHORES; } return -1; @@ -71,10 +78,8 @@ fpathconf(int fd, int name) { switch (name) { - // ToDo: out of what stupidity have those been defined differently? case _PC_CHOWN_RESTRICTED: - case _POSIX_CHOWN_RESTRICTED: - return 1; + return _POSIX_CHOWN_RESTRICTED; case _PC_MAX_CANON: return MAX_CANON; @@ -86,8 +91,7 @@ return NAME_MAX; case _PC_NO_TRUNC: - case _POSIX_NO_TRUNC: - return 0; + return _POSIX_NO_TRUNC; case _PC_PATH_MAX: return PATH_MAX; @@ -98,10 +102,8 @@ case _PC_LINK_MAX: return LINK_MAX; - // _PC_VDISABLE - // _POSIX_VDISABLE - // _POSIX_JOB_CONTROL - // _POSIX_SAVED_IDS + case _PC_VDISABLE: + return _POSIX_VDISABLE; } return -1; From bonefish at mail.berlios.de Thu May 8 03:39:51 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 03:39:51 +0200 Subject: [Haiku-commits] r25362 - in haiku/trunk: headers/posix headers/private/kernel src/system/kernel/posix src/system/libroot/posix Message-ID: <200805080139.m481doU2001835@sheep.berlios.de> Author: bonefish Date: 2008-05-08 03:39:49 +0200 (Thu, 08 May 2008) New Revision: 25362 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25362&view=rev Modified: haiku/trunk/headers/posix/semaphore.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/src/system/kernel/posix/realtime_sem.cpp haiku/trunk/src/system/libroot/posix/semaphore.cpp Log: * Added some padding to the sem_t structure. * Changed the semantics of unnamed semaphores. Before parent and child of a fork() would always share an earlier created semaphore. Now we do that only, if the "shared" parameter of sem_init() was true. That's still not quite the behavior Linux and Solaris have, but should be perfectly fine with how reasonable code would use the API. * There's a global table for shared unnamed semaphores now. ATM a semaphore is leaked when no one explicitly destroys it (just as with named sems). * Enforce per-team and global semaphore number limits. Modified: haiku/trunk/headers/posix/semaphore.h =================================================================== --- haiku/trunk/headers/posix/semaphore.h 2008-05-08 01:27:31 UTC (rev 25361) +++ haiku/trunk/headers/posix/semaphore.h 2008-05-08 01:39:49 UTC (rev 25362) @@ -5,12 +5,14 @@ #ifndef _SEMAPHORE_H_ #define _SEMAPHORE_H_ +#include #include #include typedef struct { - int id; + int32_t id; + int32_t _padding[3]; } sem_t; #define SEM_FAILED ((sem_t*)(long)-1) Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-05-08 01:27:31 UTC (rev 25361) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-05-08 01:39:49 UTC (rev 25362) @@ -77,9 +77,9 @@ extern status_t _kern_set_sem_owner(sem_id id, team_id proc); /* POSIX realtime sem syscalls */ -extern status_t _kern_realtime_sem_open(const char* name, int openFlags, - mode_t mode, uint32 semCount, sem_t* userSem, - sem_t** _usedUserSem); +extern status_t _kern_realtime_sem_open(const char* name, + int openFlagsOrShared, mode_t mode, uint32 semCount, + sem_t* userSem, sem_t** _usedUserSem); extern status_t _kern_realtime_sem_close(sem_id semID, sem_t** _deleteUserSem); extern status_t _kern_realtime_sem_unlink(const char* name); Modified: haiku/trunk/src/system/kernel/posix/realtime_sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/realtime_sem.cpp 2008-05-08 01:27:31 UTC (rev 25361) +++ haiku/trunk/src/system/kernel/posix/realtime_sem.cpp 2008-05-08 01:39:49 UTC (rev 25362) @@ -29,33 +29,61 @@ public: SemInfo() : + fSemaphoreID(-1) + { + } + + virtual ~SemInfo() + { + if (fSemaphoreID >= 0) + delete_sem(fSemaphoreID); + } + + sem_id SemaphoreID() const { return fSemaphoreID; } + + status_t Init(int32 semCount, const char* name) + { + fSemaphoreID = create_sem(semCount, name); + if (fSemaphoreID < 0) + return fSemaphoreID; + + return B_OK; + } + + virtual sem_id ID() const = 0; + virtual SemInfo* Clone() = 0; + virtual void Delete() = 0; + +private: + sem_id fSemaphoreID; +}; + + +class NamedSem : public SemInfo { +public: + NamedSem() + : fName(NULL), - fRefCount(1), - fID(-1) + fRefCount(1) { } - ~SemInfo() + virtual ~NamedSem() { free(fName); - if (fID >= 0) - delete_sem(fID); } const char* Name() const { return fName; } - sem_id ID() const { return fID; } status_t Init(const char* name, mode_t mode, int32 semCount) { - if (name != NULL) { - fName = strdup(name); - if (fName == NULL) - return B_NO_MEMORY; - } + status_t error = SemInfo::Init(semCount, name); + if (error != B_OK) + return error; - fID = create_sem(semCount, name); - if (fID < 0) - return fID; + fName = strdup(name); + if (fName == NULL) + return B_NO_MEMORY; fUID = geteuid(); fGID = getegid(); @@ -91,72 +119,216 @@ return false; } - HashTableLink* HashTableLink() + virtual sem_id ID() const { + return SemaphoreID(); + } + + virtual SemInfo* Clone() + { + AcquireReference(); + return this; + } + + virtual void Delete() + { + ReleaseReference(); + } + + HashTableLink* HashTableLink() + { return &fHashLink; } private: char* fName; vint32 fRefCount; - sem_id fID; uid_t fUID; gid_t fGID; mode_t fPermissions; - ::HashTableLink fHashLink; + ::HashTableLink fHashLink; }; +class UnnamedSem : public SemInfo { +public: + UnnamedSem() + : + fID(0) + { + } + + virtual ~UnnamedSem() + { + } + + status_t Init(int32 semCount, const char* name) + { + return SemInfo::Init(semCount, name); + } + + void SetID(sem_id id) + { + fID = id; + } + + virtual sem_id ID() const + { + return fID; + } + + virtual SemInfo* Clone() + { + sem_info info; + if (get_sem_info(SemaphoreID(), &info) != B_OK) + return NULL; + + UnnamedSem* clone = new(std::nothrow) UnnamedSem; + if (clone == NULL) + return NULL; + + if (clone->Init(info.count, info.name) != B_OK) { + delete clone; + return NULL; + } + + clone->SetID(fID); + + return clone; + } + + virtual void Delete() + { + delete this; + } + +private: + sem_id fID; +}; + + +class UnnamedSharedSem : public SemInfo { +public: + UnnamedSharedSem() + { + } + + virtual ~UnnamedSharedSem() + { + } + + status_t Init(int32 semCount, const char* name) + { + return SemInfo::Init(semCount, name); + } + + virtual sem_id ID() const + { + return SemaphoreID(); + } + + virtual SemInfo* Clone() + { + // Can't be cloned. + return NULL; + } + + virtual void Delete() + { + delete this; + } + + HashTableLink* HashTableLink() + { + return &fHashLink; + } + +private: + ::HashTableLink fHashLink; +}; + + struct NamedSemHashDefinition { typedef const char* KeyType; - typedef SemInfo ValueType; + typedef NamedSem ValueType; size_t HashKey(const KeyType& key) const { return hash_hash_string(key); } - size_t Hash(SemInfo* semaphore) const + size_t Hash(NamedSem* semaphore) const { return HashKey(semaphore->Name()); } - bool Compare(const KeyType& key, SemInfo* semaphore) const + bool Compare(const KeyType& key, NamedSem* semaphore) const { return strcmp(key, semaphore->Name()) == 0; } - HashTableLink* GetLink(SemInfo* semaphore) const + HashTableLink* GetLink(NamedSem* semaphore) const { return semaphore->HashTableLink(); } }; -class GlobalRealtimeSemTable { +struct UnnamedSemHashDefinition { + typedef sem_id KeyType; + typedef UnnamedSharedSem ValueType; + + size_t HashKey(const KeyType& key) const + { + return (size_t)key; + } + + size_t Hash(UnnamedSharedSem* semaphore) const + { + return HashKey(semaphore->SemaphoreID()); + } + + bool Compare(const KeyType& key, UnnamedSharedSem* semaphore) const + { + return key == semaphore->SemaphoreID(); + } + + HashTableLink* GetLink(UnnamedSharedSem* semaphore) const + { + return semaphore->HashTableLink(); + } +}; + + +class GlobalSemTable { public: - GlobalRealtimeSemTable() + GlobalSemTable() + : + fSemaphoreCount(0) { - mutex_init(&fLock, "global realtime sem table"); + mutex_init(&fLock, "global named sem table"); } - ~GlobalRealtimeSemTable() + ~GlobalSemTable() { mutex_destroy(&fLock); } status_t Init() { - return fSemaphores.InitCheck(); + status_t error = fNamedSemaphores.InitCheck(); + if (error != B_OK) + return error; + return fUnnamedSemaphores.InitCheck(); } - status_t OpenSem(const char* name, int openFlags, mode_t mode, - uint32 semCount, SemInfo*& _sem, bool& _created) + status_t OpenNamedSem(const char* name, int openFlags, mode_t mode, + uint32 semCount, NamedSem*& _sem, bool& _created) { MutexLocker _(fLock); - SemInfo* sem = fSemaphores.Lookup(name); + NamedSem* sem = fNamedSemaphores.Lookup(name); if (sem != NULL) { if ((openFlags & O_EXCL) != 0) return EEXIST; @@ -174,8 +346,10 @@ return ENOENT; // does not exist yet -- create -// TODO: Enforce per team semaphore limit! - sem = new(std::nothrow) SemInfo; + if (fSemaphoreCount >= MAX_POSIX_SEMS) + return ENOSPC; + + sem = new(std::nothrow) NamedSem; if (sem == NULL) return B_NO_MEMORY; @@ -185,7 +359,7 @@ return error; } - error = fSemaphores.Insert(sem); + error = fNamedSemaphores.Insert(sem); if (error != B_OK) { delete sem; return error; @@ -194,38 +368,92 @@ // add one reference for the table sem->AcquireReference(); + fSemaphoreCount++; + _sem = sem; _created = true; return B_OK; } - status_t UnlinkSem(const char* name) + status_t UnlinkNamedSem(const char* name) { MutexLocker _(fLock); - SemInfo* sem = fSemaphores.Lookup(name); + NamedSem* sem = fNamedSemaphores.Lookup(name); if (sem == NULL) return ENOENT; if (!sem->HasPermissions()) return EACCES; - fSemaphores.Remove(sem); + fNamedSemaphores.Remove(sem); sem->ReleaseReference(); // release the table reference + fSemaphoreCount--; return B_OK; } + status_t CreateUnnamedSem(uint32 semCount, int32_t& _id) + { + MutexLocker _(fLock); + + if (fSemaphoreCount >= MAX_POSIX_SEMS) + return ENOSPC; + + UnnamedSharedSem* sem = new(std::nothrow) UnnamedSharedSem; + if (sem == NULL) + return B_NO_MEMORY; + + status_t error = sem->Init(semCount, "unnamed shared sem"); + if (error == B_OK) + error = fUnnamedSemaphores.Insert(sem); + if (error != B_OK) { + delete sem; + return error; + } + + fSemaphoreCount++; + + _id = sem->SemaphoreID(); + return B_OK; + } + + status_t DeleteUnnamedSem(sem_id id) + { + MutexLocker _(fLock); + + UnnamedSharedSem* sem = fUnnamedSemaphores.Lookup(id); + if (sem == NULL) + return B_BAD_VALUE; + + fUnnamedSemaphores.Remove(sem); + delete sem; + + fSemaphoreCount--; + + return B_OK; + } + + bool IsUnnamedValidSem(sem_id id) + { + MutexLocker _(fLock); + + return fUnnamedSemaphores.Lookup(id) != NULL; + } + private: - typedef OpenHashTable SemTable; + typedef OpenHashTable NamedSemTable; + typedef OpenHashTable UnnamedSemTable; - mutex fLock; - SemTable fSemaphores; + mutex fLock; + NamedSemTable fNamedSemaphores; + UnnamedSemTable fUnnamedSemaphores; + int32 fSemaphoreCount; }; -static GlobalRealtimeSemTable sSemTable; +static GlobalSemTable sSemTable; class TeamSemInfo { @@ -241,10 +469,11 @@ ~TeamSemInfo() { if (fSemaphore != NULL) - fSemaphore->ReleaseReference(); + fSemaphore->Delete(); } - SemInfo* Semaphore() const { return fSemaphore; } + sem_id ID() const { return fSemaphore->ID(); } + sem_id SemaphoreID() const { return fSemaphore->SemaphoreID(); } sem_t* UserSemaphore() const { return fUserSemaphore; } void Open() @@ -259,15 +488,19 @@ TeamSemInfo* Clone() const { - TeamSemInfo* sem = new(std::nothrow) TeamSemInfo(fSemaphore, - fUserSemaphore); + SemInfo* sem = fSemaphore->Clone(); if (sem == NULL) return NULL; - sem->fOpenCount = fOpenCount; - fSemaphore->AcquireReference(); + TeamSemInfo* clone = new(std::nothrow) TeamSemInfo(sem, fUserSemaphore); + if (clone == NULL) { + sem->Delete(); + return NULL; + } - return sem; + clone->fOpenCount = fOpenCount; + + return clone; } HashTableLink* HashTableLink() @@ -295,12 +528,12 @@ size_t Hash(TeamSemInfo* semaphore) const { - return HashKey(semaphore->Semaphore()->ID()); + return HashKey(semaphore->ID()); } bool Compare(const KeyType& key, TeamSemInfo* semaphore) const { - return key == semaphore->Semaphore()->ID(); + return key == semaphore->ID(); } HashTableLink* GetLink(TeamSemInfo* semaphore) const @@ -312,6 +545,8 @@ struct realtime_sem_context { realtime_sem_context() + : + fSemaphoreCount(0) { mutex_init(&fLock, "realtime sem context"); } @@ -334,6 +569,7 @@ status_t Init() { + fNextPrivateSemID = -1; return fSemaphores.InitCheck(); } @@ -347,6 +583,8 @@ MutexLocker _(fLock); + context->fNextPrivateSemID = fNextPrivateSemID; + // clone all semaphores SemTable::Iterator it = fSemaphores.GetIterator(); while (TeamSemInfo* sem = it.Next()) { @@ -358,21 +596,24 @@ delete clonedSem; return NULL; } + context->fSemaphoreCount++; } contextDeleter.Detach(); return context; } - status_t CreateAnonymousSem(uint32 semCount, int& _id) + status_t CreateUnnamedSem(uint32 semCount, bool shared, int32_t& _id) { -// TODO: Enforce per team semaphore limit! - SemInfo* sem = new(std::nothrow) SemInfo; + if (shared) + return sSemTable.CreateUnnamedSem(semCount, _id); + + UnnamedSem* sem = new(std::nothrow) UnnamedSem; if (sem == NULL) return B_NO_MEMORY; - ObjectDeleter semDeleter(sem); + ObjectDeleter semDeleter(sem); - status_t error = sem->Init(NULL, 0, semCount); + status_t error = sem->Init(semCount, "unnamed sem"); if (error != B_OK) return error; @@ -383,23 +624,31 @@ MutexLocker _(fLock); + if (fSemaphoreCount >= MAX_POSIX_SEMS_PER_TEAM) { + delete teamSem; + return ENOSPC; + } + + sem->SetID(_NextPrivateSemID()); + error = fSemaphores.Insert(teamSem); if (error != B_OK) { delete teamSem; return error; } - _id = teamSem->Semaphore()->ID(); + fSemaphoreCount++; + _id = teamSem->ID(); return B_OK; } status_t OpenSem(const char* name, int openFlags, mode_t mode, - uint32 semCount, sem_t* userSem, sem_t*& _usedUserSem, int& _id, + uint32 semCount, sem_t* userSem, sem_t*& _usedUserSem, int32_t& _id, bool& _created) { - SemInfo* sem; - status_t error = sSemTable.OpenSem(name, openFlags, mode, semCount, + NamedSem* sem; + status_t error = sSemTable.OpenNamedSem(name, openFlags, mode, semCount, sem, _created); if (error != B_OK) return error; @@ -412,16 +661,25 @@ teamSem->Open(); sem->ReleaseReference(); _usedUserSem = teamSem->UserSemaphore(); - _id = teamSem->Semaphore()->ID(); + _id = teamSem->ID(); return B_OK; } // not open yet -- create a new team sem + + // first check the semaphore limit, though + if (fSemaphoreCount >= MAX_POSIX_SEMS_PER_TEAM) { + sem->ReleaseReference(); + if (_created) + sSemTable.UnlinkNamedSem(name); + return ENOSPC; + } + teamSem = new(std::nothrow) TeamSemInfo(sem, userSem); if (teamSem == NULL) { sem->ReleaseReference(); if (_created) - sSemTable.UnlinkSem(name); + sSemTable.UnlinkNamedSem(name); return B_NO_MEMORY; } @@ -429,12 +687,14 @@ if (error != B_OK) { delete teamSem; if (_created) - sSemTable.UnlinkSem(name); + sSemTable.UnlinkNamedSem(name); return error; } + fSemaphoreCount++; + _usedUserSem = teamSem->UserSemaphore(); - _id = teamSem->Semaphore()->ID(); + _id = teamSem->ID(); return B_OK; } @@ -447,11 +707,12 @@ TeamSemInfo* sem = fSemaphores.Lookup(id); if (sem == NULL) - return B_BAD_VALUE; + return sSemTable.DeleteUnnamedSem(id); if (sem->Close()) { // last reference closed fSemaphores.Remove(sem); + fSemaphoreCount--; deleteUserSem = sem->UserSemaphore(); delete sem; } @@ -463,8 +724,12 @@ { MutexLocker locker(fLock); - if (fSemaphores.Lookup(id) == NULL) - return B_BAD_VALUE; + TeamSemInfo* sem = fSemaphores.Lookup(id); + if (sem == NULL) { + if (!sSemTable.IsUnnamedValidSem(id)) + return B_BAD_VALUE; + } else + id = sem->SemaphoreID(); locker.Unlock(); @@ -487,8 +752,12 @@ { MutexLocker locker(fLock); - if (fSemaphores.Lookup(id) == NULL) - return B_BAD_VALUE; + TeamSemInfo* sem = fSemaphores.Lookup(id); + if (sem == NULL) { + if (!sSemTable.IsUnnamedValidSem(id)) + return B_BAD_VALUE; + } else + id = sem->SemaphoreID(); locker.Unlock(); @@ -500,8 +769,12 @@ { MutexLocker locker(fLock); - if (fSemaphores.Lookup(id) == NULL) - return B_BAD_VALUE; + TeamSemInfo* sem = fSemaphores.Lookup(id); + if (sem == NULL) { + if (!sSemTable.IsUnnamedValidSem(id)) + return B_BAD_VALUE; + } else + id = sem->SemaphoreID(); locker.Unlock(); @@ -515,10 +788,25 @@ } private: + sem_id _NextPrivateSemID() + { + while (true) { + if (fNextPrivateSemID >= 0) + fNextPrivateSemID = -1; + + sem_id id = fNextPrivateSemID--; + if (fSemaphores.Lookup(id) == NULL) + return id; + } + } + +private: typedef OpenHashTable SemTable; mutex fLock; SemTable fSemaphores; + int32 fSemaphoreCount; + sem_id fNextPrivateSemID; }; @@ -585,9 +873,9 @@ void realtime_sem_init() { - new(&sSemTable) GlobalRealtimeSemTable; + new(&sSemTable) GlobalSemTable; if (sSemTable.Init() != B_OK) - panic("realtime_sem_init() failed to init global table"); + panic("realtime_sem_init() failed to init global sem table"); } @@ -612,23 +900,27 @@ status_t -_user_realtime_sem_open(const char* userName, int openFlags, mode_t mode, - uint32 semCount, sem_t* userSem, sem_t** _usedUserSem) +_user_realtime_sem_open(const char* userName, int openFlagsOrShared, + mode_t mode, uint32 semCount, sem_t* userSem, sem_t** _usedUserSem) { realtime_sem_context* context = get_current_team_context(); if (context == NULL) return B_NO_MEMORY; + if (semCount > MAX_POSIX_SEM_VALUE) + return B_BAD_VALUE; + // userSem must always be given if (userSem == NULL) return B_BAD_VALUE; if (!IS_USER_ADDRESS(userSem)) return B_BAD_ADDRESS; - // anonymous semaphores are less work -- deal with them first + // unnamed semaphores are less work -- deal with them first if (userName == NULL) { - int id; - status_t error = context->CreateAnonymousSem(semCount, id); + int32_t id; + status_t error = context->CreateUnnamedSem(semCount, openFlagsOrShared, + id); if (error != B_OK) return error; @@ -657,8 +949,8 @@ // open the semaphore sem_t* usedUserSem; bool created; - int id; - error = context->OpenSem(name, openFlags, mode, semCount, userSem, + int32_t id; + error = context->OpenSem(name, openFlagsOrShared, mode, semCount, userSem, usedUserSem, id, created); if (error != B_OK) return error; @@ -667,7 +959,7 @@ if (user_memcpy(&userSem->id, &id, sizeof(int)) != B_OK || user_memcpy(_usedUserSem, &usedUserSem, sizeof(sem_t*)) != B_OK) { if (created) - sSemTable.UnlinkSem(name); + sSemTable.UnlinkNamedSem(name); sem_t* dummy; context->CloseSem(id, dummy); return B_BAD_ADDRESS; @@ -714,7 +1006,7 @@ if (error != B_OK) return error; - return sSemTable.UnlinkSem(name); + return sSemTable.UnlinkNamedSem(name); } Modified: haiku/trunk/src/system/libroot/posix/semaphore.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-08 01:27:31 UTC (rev 25361) +++ haiku/trunk/src/system/libroot/posix/semaphore.cpp 2008-05-08 01:39:49 UTC (rev 25362) @@ -89,8 +89,8 @@ int sem_init(sem_t* semaphore, int shared, unsigned value) { - RETURN_AND_SET_ERRNO(_kern_realtime_sem_open(NULL, 0, 0, value, semaphore, - NULL)); + RETURN_AND_SET_ERRNO(_kern_realtime_sem_open(NULL, shared, 0, value, + semaphore, NULL)); } From bonefish at mail.berlios.de Thu May 8 03:44:47 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 03:44:47 +0200 Subject: [Haiku-commits] r25363 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200805080144.m481ilRE002101@sheep.berlios.de> Author: bonefish Date: 2008-05-08 03:44:46 +0200 (Thu, 08 May 2008) New Revision: 25363 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25363&view=rev Modified: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp Log: * Be more lenient when checking the timeout. In my tests Haiku was up to 5ms off. Not really good... * The test on non-shared unnamed semaphores doesn't request a shared semaphore anymore. It passes under Haiku, now. Modified: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-08 01:39:49 UTC (rev 25362) +++ haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-05-08 01:44:46 UTC (rev 25363) @@ -82,9 +82,9 @@ _assert_time_equals(const char* test, bigtime_t expected, bigtime_t actual, int lineNumber) { - // allow 2% deviation + // allow 5% deviation bigtime_t diff = actual > expected ? actual - expected : expected - actual; - if (diff <= expected / 50) + if (diff <= expected / 20) return; fprintf(stderr, "%s FAILED in line %d: expected time: %lld, actual: %lld\n", @@ -948,7 +948,7 @@ // init TEST("sem_init()"); sem_t _sem; - assert_posix_success(sem_init(&_sem, 1, 1)); + assert_posix_success(sem_init(&_sem, 0, 1)); sem_t* sem = &_sem; TEST("sem_getvalue()"); From axeld at mail.berlios.de Thu May 8 12:27:56 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 12:27:56 +0200 Subject: [Haiku-commits] r25364 - haiku/trunk/src/apps/mail Message-ID: <200805081027.m48ARu62004084@sheep.berlios.de> Author: axeld Date: 2008-05-08 12:27:55 +0200 (Thu, 08 May 2008) New Revision: 25364 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25364&view=rev Modified: haiku/trunk/src/apps/mail/Content.cpp haiku/trunk/src/apps/mail/Content.h haiku/trunk/src/apps/mail/MailWindow.cpp Log: * Added a quote_context structure that FillInQuoteTextRuns() can now optionally use to keep track of the current context. This should not only make it faster, but may also fix the occasionally seen bug of the previous solution. * Added a simple diff mode coloring as well - only enabled when quote coloring is enabled. * Minor cleanup. Modified: haiku/trunk/src/apps/mail/Content.cpp =================================================================== --- haiku/trunk/src/apps/mail/Content.cpp 2008-05-08 01:44:46 UTC (rev 25363) +++ haiku/trunk/src/apps/mail/Content.cpp 2008-05-08 10:27:55 UTC (rev 25364) @@ -89,14 +89,19 @@ const rgb_color kHyperLinkColor = {0, 0, 255, 255}; const rgb_color kHeaderColor = {72, 72, 72, 255}; -const rgb_color kQuoteColors[] = -{ - {0, 0, 0x80, 0}, // 3rd, 6th, ... quote level color - {0, 0x80, 0, 0}, // 1st, 4th, ... quote level color - {0x80, 0, 0, 0} // 2nd, ... +const rgb_color kQuoteColors[] = { + {0, 0, 0x80, 0}, // 3rd, 6th, ... quote level color (blue) + {0, 0x80, 0, 0}, // 1st, 4th, ... quote level color (green) + {0x80, 0, 0, 0} // 2nd, ... (red) }; const int32 kNumQuoteColors = 3; +const rgb_color kDiffColors[] = { + {0xb0, 0, 0, 0}, // '-', red + {0, 0x90, 0, 0}, // '+', green + {0x6a, 0x6a, 0x6a, 0} // '@@', dark grey +}; + void Unicode2UTF8(int32 c, char **out); @@ -422,6 +427,23 @@ } +int32 +diff_mode(char c) +{ + if (c == '+') + return 2; + if (c == '-') + return 1; + if (c == '@') + return 3; + if (c == ' ') + return 0; + + // everything else ends the diff mode + return -1; +} + + bool is_quote_char(char c) { @@ -429,33 +451,42 @@ } -/** Fills the specified text_run_array with the correct values for the - * specified text. - * If "view" is NULL, it will assume that "line" lies on a line break, - * if not, it will correctly retrieve the number of quotes the current - * line already has. - */ - +/*! Fills the specified text_run_array with the correct values for the + specified text. + If "view" is NULL, it will assume that "line" lies on a line break, + if not, it will correctly retrieve the number of quotes the current + line already has. +*/ void -FillInQuoteTextRuns(BTextView *view, const char *line, int32 length, const BFont &font, - text_run_array *style, int32 maxStyles) +FillInQuoteTextRuns(BTextView* view, quote_context* context, const char* line, + int32 length, const BFont& font, text_run_array* style, int32 maxStyles) { - text_run *runs = style->runs; + text_run* runs = style->runs; int32 index = style->count; bool begin; int32 pos = 0; + int32 diffMode = 0; + bool inDiff = false; + bool wasDiff = false; int32 level = 0; // get index to the beginning of the current line - if (view != NULL) { + if (context != NULL) { + level = context->level; + diffMode = context->diff_mode; + begin = context->begin; + inDiff = context->in_diff; + wasDiff = context->was_diff; + } else if (view != NULL) { int32 start, end; view->GetSelection(&end, &end); - begin = view->TextLength() == 0 || view->ByteAt(view->TextLength() - 1) == '\n'; + begin = view->TextLength() == 0 + || view->ByteAt(view->TextLength() - 1) == '\n'; - // the following line works only reliable when text wrapping is set to off; - // so the complicated version actually used here is necessary: + // the following line works only reliable when text wrapping is set to + // off; so the complicated version actually used here is necessary: // start = view->OffsetAt(view->CurrentLine()); const char *text = view->Text(); @@ -472,19 +503,28 @@ // get number of nested qoutes for current line if (!begin && start < end) { - begin = true; // if there was no text in this line, there may come more nested quotes + begin = true; + // if there was no text in this line, there may come + // more nested quotes - for (int32 i = start; i < end; i++) { - if (is_quote_char(text[i])) - level++; - else if (text[i] != ' ' && text[i] != '\t') { - begin = false; - break; + diffMode = diff_mode(text[start]); + if (diffMode == 0) { + for (int32 i = start; i < end; i++) { + if (is_quote_char(text[i])) + level++; + else if (text[i] != ' ' && text[i] != '\t') { + begin = false; + break; + } } - } - if (begin) // skip leading spaces (tabs & newlines aren't allowed here) + } else + inDiff = true; + + if (begin) { + // skip leading spaces (tabs & newlines aren't allowed here) while (line[pos] == ' ') pos++; + } } } else begin = true; @@ -494,7 +534,10 @@ for (int32 pos = 0; pos < length;) { int32 next; if (begin && is_quote_char(line[pos])) { + begin = false; + while (pos < length && line[pos] != '\n') { + // insert style for each quote level level++; bool search = true; @@ -502,46 +545,84 @@ if (search && is_quote_char(line[next]) || line[next] == '\n') break; - else if (line[next] != ' ' && line[next] != '\t') + else if (search && line[next] != ' ' && line[next] != '\t') search = false; } runs[index].offset = pos; runs[index].font = font; - runs[index].color = level > 0 ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor; + runs[index].color = level > 0 + ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor; pos = next; if (++index >= maxStyles) break; } } else { + if (begin) { + if (!inDiff) { + inDiff = !strncmp(&line[pos], "--- ", 4); + wasDiff = false; + } + if (inDiff) { + diffMode = diff_mode(line[pos]); + if (diffMode < 0) { + inDiff = false; + wasDiff = true; + } + } + } + runs[index].offset = pos; runs[index].font = font; - runs[index].color = level > 0 ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor; - index++; + if (wasDiff) + runs[index].color = kDiffColors[diff_mode('@') - 1]; + else if (diffMode <= 0) { + runs[index].color = level > 0 + ? kQuoteColors[level % kNumQuoteColors] : kNormalTextColor; + } else + runs[index].color = kDiffColors[diffMode - 1]; + begin = false; + for (next = pos; next < length; next++) { - if (line[next] == '\n') + if (line[next] == '\n') { + begin = true; + wasDiff = false; break; + } } + pos = next; + index++; } - if (index >= maxStyles) - break; + if (pos < length) + begin = line[pos] == '\n'; - level = 0; - - if (pos < length && line[pos] == '\n') { + if (begin) { pos++; - begin = true; + level = 0; + wasDiff = false; - // skip leading spaces (tabs & newlines aren't allowed here) - while (pos < length && line[pos] == ' ') + // skip one leading space (tabs & newlines aren't allowed here) + if (!inDiff && pos < length && line[pos] == ' ') pos++; } + + if (index >= maxStyles) + break; } style->count = index; + + if (context) { + // update context for next run + context->level = level; + context->diff_mode = diffMode; + context->begin = begin; + context->in_diff = inDiff; + context->was_diff = wasDiff; + } } @@ -2171,12 +2252,12 @@ } -//-------------------------------------------------------------------- // #pragma mark - -TTextView::Reader::Reader(bool header, bool raw, bool quote, bool incoming, bool stripHeader, - bool mime, TTextView *view, BEmailMessage *mail, BList *list, sem_id sem) +TTextView::Reader::Reader(bool header, bool raw, bool quote, bool incoming, + bool stripHeader, bool mime, TTextView *view, BEmailMessage *mail, + BList *list, sem_id sem) : fHeader(header), fRaw(raw), @@ -2193,7 +2274,8 @@ bool -TTextView::Reader::ParseMail(BMailContainer *container, BTextMailComponent *ignore) +TTextView::Reader::ParseMail(BMailContainer *container, + BTextMailComponent *ignore) { int32 count = 0; for (int32 i = 0; i < container->CountComponents(); i++) { @@ -2337,7 +2419,8 @@ bool -TTextView::Reader::Insert(const char *line, int32 count, bool isHyperLink, bool isHeader) +TTextView::Reader::Insert(const char *line, int32 count, bool isHyperLink, + bool isHeader) { if (!count) return true; @@ -2345,17 +2428,20 @@ BFont font(fView->Font()); TextRunArray style(count / 8 + 8); - if (fView->fColoredQuotes && !isHeader && !isHyperLink) - FillInQuoteTextRuns(fView, line, count, font, &style.Array(), style.MaxEntries()); - else { + if (fView->fColoredQuotes && !isHeader && !isHyperLink) { + FillInQuoteTextRuns(fView, &fQuoteContext, line, count, font, + &style.Array(), style.MaxEntries()); + } else { text_run_array &array = style.Array(); array.count = 1; array.runs[0].offset = 0; if (isHeader) { array.runs[0].color = isHyperLink ? kHyperLinkColor : kHeaderColor; font.SetSize(font.Size() * 0.9); - } else - array.runs[0].color = isHyperLink ? kHyperLinkColor : kNormalTextColor; + } else { + array.runs[0].color = isHyperLink + ? kHyperLinkColor : kNormalTextColor; + } array.runs[0].font = font; } @@ -3061,7 +3147,8 @@ const BFont *font = Font(); TextRunArray style(targetLength / 8 + 8); - FillInQuoteTextRuns(NULL, target, targetLength, font, &style.Array(), style.MaxEntries()); + FillInQuoteTextRuns(NULL, NULL, target, targetLength, font, + &style.Array(), style.MaxEntries()); Insert(target, targetLength, &style.Array()); } else Insert(target, targetLength); @@ -3138,7 +3225,8 @@ const BFont *font = Font(); TextRunArray style(length / 8 + 8); - FillInQuoteTextRuns(NULL, target, length, font, &style.Array(), style.MaxEntries()); + FillInQuoteTextRuns(NULL, NULL, target, length, font, + &style.Array(), style.MaxEntries()); Insert(target, length, &style.Array()); } else Insert(target, length); Modified: haiku/trunk/src/apps/mail/Content.h =================================================================== --- haiku/trunk/src/apps/mail/Content.h 2008-05-08 01:44:46 UTC (rev 25363) +++ haiku/trunk/src/apps/mail/Content.h 2008-05-08 10:27:55 UTC (rev 25364) @@ -31,13 +31,6 @@ names are registered trademarks or trademarks of their respective holders. All rights reserved. */ - -//-------------------------------------------------------------------- -// -// Content.h -// -//-------------------------------------------------------------------- - #ifndef _CONTENT_H #define _CONTENT_H @@ -72,8 +65,7 @@ struct text_run_array; -typedef struct -{ +typedef struct { bool header; bool raw; bool quote; @@ -86,8 +78,7 @@ sem_id *stop_sem; } reader_info; -enum ENCLOSURE_TYPE -{ +enum ENCLOSURE_TYPE { TYPE_ENCLOSURE = 100, TYPE_BE_ENCLOSURE, TYPE_URL, @@ -113,8 +104,7 @@ //==================================================================== -class TContentView : public BView -{ +class TContentView : public BView { public: TContentView(BRect, bool incoming, BEmailMessage *mail, BFont*, bool showHeader, bool coloredQuotes); @@ -138,8 +128,25 @@ S_SHOW_ERRORS = 2 }; -class TTextView : public BTextView -{ +struct quote_context { + quote_context() + : + level(0), + diff_mode(0), + begin(true), + in_diff(false), + was_diff(false) + { + } + + int32 level; + int32 diff_mode; + bool begin; + bool in_diff; + bool was_diff; +}; + +class TTextView : public BTextView { public: TTextView(BRect, BRect, bool incoming, BEmailMessage *mail, TContentView *, BFont *, bool showHeader, bool coloredQuotes); @@ -220,8 +227,7 @@ bool fRaw; bool fCursor; - struct spell_mark - { + struct spell_mark { spell_mark *next; int32 start; int32 end; @@ -230,18 +236,21 @@ spell_mark *fFirstSpellMark; - class Reader - { + class Reader { public: - Reader(bool header,bool raw,bool quote,bool incoming,bool stripHeaders,bool mime, - TTextView *view,BEmailMessage *mail,BList *list,sem_id sem); + Reader(bool header, bool raw, bool quote, bool incoming, + bool stripHeaders, bool mime, TTextView* view, + BEmailMessage* mail, BList* list, sem_id sem); - static status_t Run(void *); + static status_t Run(void* _dummy); private: - bool ParseMail(BMailContainer *container,BTextMailComponent *ignore); - bool Process(const char *data, int32 len, bool isHeader = false); - bool Insert(const char *line, int32 count, bool isHyperLink, bool isHeader = false); + bool ParseMail(BMailContainer* container, + BTextMailComponent* ignore); + bool Process(const char* data, int32 length, + bool isHeader = false); + bool Insert(const char* line, int32 count, bool isHyperLink, + bool isHeader = false); bool Lock(); status_t Unlock(); @@ -249,11 +258,12 @@ bool fHeader; bool fRaw; bool fQuote; + quote_context fQuoteContext; bool fIncoming; bool fStripHeader; bool fMime; - TTextView *fView; - BEmailMessage *fMail; + TTextView* fView; + BEmailMessage* fMail; BList *fEnclosures; sem_id fStopSem; }; @@ -288,7 +298,8 @@ size_t fNumEntries; }; -extern void FillInQuoteTextRuns(BTextView *view, const char *line, int32 length, - const BFont &font, text_run_array *style, int32 maxStyles = 5); +extern void FillInQuoteTextRuns(BTextView* view, quote_context* context, + const char* line, int32 length, const BFont& font, text_run_array* style, + int32 maxStyles = 5); #endif /* #ifndef _CONTENT_H */ Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2008-05-08 01:44:46 UTC (rev 25363) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2008-05-08 10:27:55 UTC (rev 25364) @@ -2169,8 +2169,9 @@ TextRunArray style(length / 8 + 8); - FillInQuoteTextRuns(fContentView->fTextView, fContentView->fTextView->Text(), - length, font, &style.Array(), style.MaxEntries()); + FillInQuoteTextRuns(fContentView->fTextView, NULL, + fContentView->fTextView->Text(), length, font, &style.Array(), + style.MaxEntries()); fContentView->fTextView->SetRunArray(0, length, &style.Array()); } From jackburton at mail.berlios.de Thu May 8 12:28:53 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 8 May 2008 12:28:53 +0200 Subject: [Haiku-commits] r25365 - haiku/trunk/src/apps/terminal Message-ID: <200805081028.m48ASrJr004280@sheep.berlios.de> Author: jackburton Date: 2008-05-08 12:28:52 +0200 (Thu, 08 May 2008) New Revision: 25365 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25365&view=rev Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp Log: When opening a new tab, select it automatically, as described in ticket #2176. Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-05-08 10:27:55 UTC (rev 25364) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2008-05-08 10:28:52 UTC (rev 25365) @@ -536,11 +536,10 @@ if (!job.CanContinue()){ // It is likely that the only way that the job was cancelled is - // because the user hit 'Cancel' in the page setup window, in which - // case, the user does *not* need to be told that it was cancelled. - // He/she will simply expect that it was done. - // (new BAlert("Cancel", "Print job cancelled", "OK"))->Go(); - return; + // because the user hit 'Cancel' in the page setup window, in which + // case, the user does *not* need to be told that it was cancelled. + // He/she will simply expect that it was done. + return; } } } @@ -610,6 +609,8 @@ ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, viewHeight + fMenubar->Bounds().Height()); } + // TODO: No fTabView->Select(tab); ? + fTabView->Select(fTabView->CountTabs() - 1); } catch (...) { // most probably out of memory. That's bad. // TODO: Should cleanup, I guess From axeld at pinc-software.de Thu May 8 12:29:04 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 12:29:04 +0200 CEST Subject: [Haiku-commits] r25350 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <20080508002038.1604.6@knochen-vm.1210160172.fake> Message-ID: <11131232758-BeMail@zon> Ingo Weinhold wrote: > > The only > > question that remains would be how to let them die gracefully - and > > when :-) > > Is it possible to map areas and unnamed semaphores together at all? > You mean like automatically destroying the semaphore when the last > area is > deleted? I considered allowing to add objects to areas that would be > automatically destroyed when the area is destroyed (and cloned when > it is > cloned), but I'm not sure whether this is a good path to follow. Me neither. Maybe one can attach it to a process group - then it would be at least safe to remove them at a certain point. Bye, Axel. From korli at mail.berlios.de Thu May 8 13:12:02 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 13:12:02 +0200 Subject: [Haiku-commits] r25366 - haiku/trunk/src/preferences/sounds Message-ID: <200805081112.m48BC2nr022926@sheep.berlios.de> Author: korli Date: 2008-05-08 13:12:01 +0200 (Thu, 08 May 2008) New Revision: 25366 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25366&view=rev Modified: haiku/trunk/src/preferences/sounds/HWindow.cpp Log: Patch from Kaoutsis: use find_directory() instead of a fixed path added some checks, keep the style clean Modified: haiku/trunk/src/preferences/sounds/HWindow.cpp =================================================================== --- haiku/trunk/src/preferences/sounds/HWindow.cpp 2008-05-08 10:28:52 UTC (rev 25365) +++ haiku/trunk/src/preferences/sounds/HWindow.cpp 2008-05-08 11:12:01 UTC (rev 25366) @@ -1,46 +1,43 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2003, OpenBeOS -// -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// -// File: HWindow.cpp -// Author: J?r?me Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu -// Description: Sounds Preferences -// Created : November 24, 2003 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +/* + * Copyright 2003-2008, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * J?r?me Duval + * Oliver Ruiz Dorantes + * Atsushi Takamatsu + */ + #include "HWindow.h" #include "HEventList.h" #include "HEventItem.h" -#include -#include + +#include + +#include +#include +#include +#include +#include #include +#include +#include #include #include -#include -#include #include -#include -#include -#include -#include +#include #include #include -#include +#include #include -#include -#include +#include +#include #include -/*********************************************************** - * Constructor - ***********************************************************/ -HWindow::HWindow(BRect rect, const char* name) - :_inherited(rect, name, B_TITLED_WINDOW, 0), + +HWindow::HWindow(BRect rect, const char *name) + : _inherited(rect, name, B_TITLED_WINDOW, 0), fFilePanel(NULL), fPlayer(NULL) { @@ -57,18 +54,14 @@ fEventList->Select(0); } -/*********************************************************** - * Destructor - ***********************************************************/ + HWindow::~HWindow() { delete fFilePanel; delete fPlayer; } -/*********************************************************** - * Initialize GUIs. - ***********************************************************/ + void HWindow::InitGUI() { @@ -83,26 +76,22 @@ stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); listView->AddChild(stringView); - + stringRect.OffsetBy(120, 0); stringView = new BStringView(stringRect, "sound", "Sound"); stringView->SetFont(be_bold_font); stringView->ResizeToPreferred(); listView->AddChild(stringView); - + rect.left += 13; rect.right -= B_V_SCROLL_BAR_WIDTH + 13; rect.top += 28; rect.bottom -= 7; fEventList = new HEventList(rect); fEventList->SetType(BMediaFiles::B_SOUNDS); - - BScrollView *scrollView = new BScrollView("" - ,fEventList - ,B_FOLLOW_ALL - ,0 - ,false - ,true); + + BScrollView *scrollView = new BScrollView("", fEventList, B_FOLLOW_ALL, 0, + false, true); listView->AddChild(scrollView); rect = Bounds(); @@ -125,34 +114,25 @@ menu->AddItem(new BMenuItem("", new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS, new BMessage(M_OTHER_MESSAGE))); - BMenuField *menuField = new BMenuField(rect - ,"filemenu" - ,"Sound File:" - ,menu - ,B_FOLLOW_TOP | B_FOLLOW_LEFT); + BMenuField *menuField = new BMenuField(rect, "filemenu", "Sound File:", menu, + B_FOLLOW_TOP | B_FOLLOW_LEFT); menuField->SetDivider(menuField->StringWidth("Sound File:") + 10); box->AddChild(menuField); rect.OffsetBy(-2, menuField->Bounds().Height() + 15); - BButton *button = new BButton(rect - ,"stop" - ,"Stop" - ,new BMessage(M_STOP_MESSAGE) - ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); + BButton *button = new BButton(rect, "stop", "Stop", new BMessage(M_STOP_MESSAGE), + B_FOLLOW_RIGHT | B_FOLLOW_TOP); button->ResizeToPreferred(); button->SetEnabled(false); button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15, rect.top); box->AddChild(button); - + rect = button->Frame(); view->ResizeTo(view->Bounds().Width(), 24 + rect.bottom + 12); box->ResizeTo(box->Bounds().Width(), rect.bottom + 12); button->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP); - button = new BButton(rect - ,"play" - ,"Play" - ,new BMessage(M_PLAY_MESSAGE) - ,B_FOLLOW_RIGHT | B_FOLLOW_TOP); + button = new BButton(rect, "play", "Play", new BMessage(M_PLAY_MESSAGE), + B_FOLLOW_RIGHT | B_FOLLOW_TOP); button->ResizeToPreferred(); button->SetEnabled(false); button->MoveTo(rect.left - button->Bounds().Width() - 15, rect.top); @@ -169,18 +149,15 @@ } -/*********************************************************** - * MessageReceived - ***********************************************************/ void HWindow::MessageReceived(BMessage *message) { - switch(message->what) { - case M_OTHER_MESSAGE: + switch (message->what) { + case M_OTHER_MESSAGE: { BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenu *menu = menufield->Menu(); - + int32 sel = fEventList->CurrentSelection(); if (sel >= 0) { HEventItem *item = cast_as(fEventList->ItemAt(sel), HEventItem); @@ -189,7 +166,7 @@ BMenuItem *item = menu->FindItem(""); if (item) item->SetMarked(true); - } else{ + } else { BMenuItem *item = menu->FindItem(path.Leaf()); if (item) item->SetMarked(true); @@ -198,18 +175,20 @@ fFilePanel->Show(); break; } - case B_SIMPLE_DATA: - case B_REFS_RECEIVED: + + case B_SIMPLE_DATA: + case B_REFS_RECEIVED: { entry_ref ref; int32 sel = fEventList->CurrentSelection(); if (message->FindRef("refs", &ref) == B_OK && sel >= 0) { BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenu *menu = menufield->Menu(); + // check audio file BNode node(&ref); BNodeInfo ninfo(&node); - char type[B_MIME_TYPE_LENGTH+1]; + char type[B_MIME_TYPE_LENGTH + 1]; ninfo.GetType(type); BMimeType mtype(type); BMimeType superType; @@ -217,9 +196,10 @@ if (superType.Type() == NULL || strcmp(superType.Type(), "audio") != 0) { beep(); (new BAlert("", "This is not a audio file.", "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); + B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); break; } + // add file item BMessage *msg = new BMessage(M_ITEM_MESSAGE); BPath path(&ref); @@ -235,15 +215,14 @@ } break; } - case M_PLAY_MESSAGE: + + case M_PLAY_MESSAGE: { int32 sel = fEventList->CurrentSelection(); - if (sel >= 0) - { + if (sel >= 0) { HEventItem *item = cast_as(fEventList->ItemAt(sel), HEventItem); - const char* path = item->Path(); - if (path) - { + const char *path = item->Path(); + if (path) { entry_ref ref; ::get_ref_for_path(path, &ref); delete fPlayer; @@ -253,24 +232,25 @@ } break; } - case M_STOP_MESSAGE: + + case M_STOP_MESSAGE: { if (!fPlayer) break; - if (fPlayer->IsPlaying()) - { + if (fPlayer->IsPlaying()) { fPlayer->StopPlaying(); delete fPlayer; fPlayer = NULL; } break; } - case M_EVENT_CHANGED: + + case M_EVENT_CHANGED: { - const char* path; + const char *path; BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenu *menu = menufield->Menu(); - + if (message->FindString("path", &path) == B_OK) { BPath path(path); if (path.InitCheck() != B_OK) { @@ -285,110 +265,113 @@ } break; } - case M_ITEM_MESSAGE: + + case M_ITEM_MESSAGE: { entry_ref ref; - if (message->FindRef("refs", &ref) == B_OK) { + if (message->FindRef("refs", &ref) == B_OK) fEventList->SetPath(BPath(&ref).Path()); - } break; } - case M_NONE_MESSAGE: + + case M_NONE_MESSAGE: { fEventList->SetPath(NULL); break; } - default: - _inherited::MessageReceived(message); + + default: + _inherited::MessageReceived(message); } } -/*********************************************************** - * Init menu - ***********************************************************/ + void HWindow::SetupMenuField() { BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BMenu *menu = menufield->Menu(); int32 count = fEventList->CountItems(); - for(int32 i = 0; i < count; i++) { + for (int32 i = 0; i < count; i++) { HEventItem *item = cast_as(fEventList->ItemAt(i), HEventItem); if (!item) continue; - + BPath path(item->Path()); if (path.InitCheck() != B_OK) continue; if (menu->FindItem(path.Leaf())) continue; - + BMessage *msg = new BMessage(M_ITEM_MESSAGE); entry_ref ref; ::get_ref_for_path(path.Path(), &ref); msg->AddRef("refs", &ref); menu->AddItem(new BMenuItem(path.Leaf(), msg), 0); } - - BPath path("/boot/beos/etc/sounds"); - status_t err = B_OK; - BDirectory dir( path.Path() ); + + BPath path; + BDirectory dir; BEntry entry; BPath item_path; - while (err == B_OK){ - err = dir.GetNextEntry((BEntry *)&entry, true); - if (entry.InitCheck() != B_NO_ERROR) { + + status_t err = find_directory(B_BEOS_SOUNDS_DIRECTORY, &path); + if (err == B_OK) + err = dir.SetTo(path.Path()); + while (err == B_OK) { + err = dir.GetNextEntry((BEntry*)&entry, true); + if (entry.InitCheck() != B_NO_ERROR) break; - } + entry.GetPath(&item_path); - + if (menu->FindItem(item_path.Leaf())) continue; - + BMessage *msg = new BMessage(M_ITEM_MESSAGE); entry_ref ref; ::get_ref_for_path(item_path.Path(), &ref); msg->AddRef("refs", &ref); menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0); } - - path.SetTo("/boot/home/config/sounds"); - dir.SetTo(path.Path()); - err = B_OK; + + err = find_directory(B_USER_SOUNDS_DIRECTORY, &path); + if (err == B_OK) + err = dir.SetTo(path.Path()); while (err == B_OK) { - err = dir.GetNextEntry((BEntry *)&entry, true); - if (entry.InitCheck() != B_NO_ERROR) { + err = dir.GetNextEntry((BEntry*)&entry, true); + if (entry.InitCheck() != B_NO_ERROR) break; - } + entry.GetPath(&item_path); - + if (menu->FindItem(item_path.Leaf())) continue; - + BMessage *msg = new BMessage(M_ITEM_MESSAGE); entry_ref ref; - + ::get_ref_for_path(item_path.Path(), &ref); msg->AddRef("refs", &ref); menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0); } - - path.SetTo("/boot/home/media"); - dir.SetTo(path.Path()); - err = B_OK; + + err = find_directory(B_COMMON_SOUNDS_DIRECTORY, &path); + if (err == B_OK) + err = dir.SetTo(path.Path()); while (err == B_OK) { - err = dir.GetNextEntry((BEntry *)&entry, true); - if (entry.InitCheck() != B_NO_ERROR) { + err = dir.GetNextEntry((BEntry*)&entry, true); + if (entry.InitCheck() != B_NO_ERROR) break; - } + entry.GetPath(&item_path); - + if (menu->FindItem(item_path.Leaf())) continue; - + BMessage *msg = new BMessage(M_ITEM_MESSAGE); entry_ref ref; - + ::get_ref_for_path(item_path.Path(), &ref); msg->AddRef("refs", &ref); menu->AddItem(new BMenuItem(item_path.Leaf(), msg), 0); @@ -397,9 +380,6 @@ } -/*********************************************************** - * Pulse - ***********************************************************/ void HWindow::Pulse() { @@ -407,15 +387,15 @@ BMenuField *menufield = cast_as(FindView("filemenu"), BMenuField); BButton *button = cast_as(FindView("play"), BButton); BButton *stop = cast_as(FindView("stop"), BButton); - + if (!menufield) return; - if (sel >=0) { + if (sel >= 0) { menufield->SetEnabled(true); HEventItem *item = cast_as(fEventList->ItemAt(sel), HEventItem); - const char* path = item->Path(); + const char *path = item->Path(); if (path && strcmp(path, "")) button->SetEnabled(true); else @@ -424,6 +404,7 @@ menufield->SetEnabled(false); button->SetEnabled(false); } + if (fPlayer) { if (fPlayer->IsPlaying()) stop->SetEnabled(true); @@ -434,9 +415,6 @@ } -/*********************************************************** - * DispatchMessage - ***********************************************************/ void HWindow::DispatchMessage(BMessage *message, BHandler *handler) { @@ -445,9 +423,7 @@ BWindow::DispatchMessage(message, handler); } -/*********************************************************** - * QuitRequested - ***********************************************************/ + bool HWindow::QuitRequested() { From korli at mail.berlios.de Thu May 8 13:17:09 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 13:17:09 +0200 Subject: [Haiku-commits] r25367 - haiku/trunk/build/jam Message-ID: <200805081117.m48BH9mW028198@sheep.berlios.de> Author: korli Date: 2008-05-08 13:17:09 +0200 (Thu, 08 May 2008) New Revision: 25367 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25367&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added a sounds directory in beos/etc Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-08 11:12:01 UTC (rev 25366) +++ haiku/trunk/build/jam/HaikuImage 2008-05-08 11:17:09 UTC (rev 25367) @@ -269,6 +269,8 @@ SEARCH on $(logoArtwork) = [ FDirName $(HAIKU_TOP) data artwork ] ; AddFilesToHaikuImage beos etc artwork : $(logoArtwork) ; +AddDirectoryToHaikuImage beos etc sounds ; + # Mail spell check dictionaries local spellFiles = words geekspeak ; spellFiles = $(spellFiles:G=spell) ; From korli at mail.berlios.de Thu May 8 13:28:45 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 13:28:45 +0200 Subject: [Haiku-commits] r25368 - haiku/trunk/src/servers/app Message-ID: <200805081128.m48BSjd3004432@sheep.berlios.de> Author: korli Date: 2008-05-08 13:28:42 +0200 (Thu, 08 May 2008) New Revision: 25368 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25368&view=rev Modified: haiku/trunk/src/servers/app/FontManager.cpp Log: Patch from Kaoutsis: use find_directory() instead of hard coded paths Modified: haiku/trunk/src/servers/app/FontManager.cpp =================================================================== --- haiku/trunk/src/servers/app/FontManager.cpp 2008-05-08 11:17:09 UTC (rev 25367) +++ haiku/trunk/src/servers/app/FontManager.cpp 2008-05-08 11:28:42 UTC (rev 25368) @@ -317,13 +317,23 @@ // default known mappings // TODO: load them for real, and use these as a fallback - _AddDefaultMapping("Bitstream Vera Sans", "Roman", - "/boot/beos/etc/fonts/ttfonts/Vera.ttf"); - _AddDefaultMapping("Bitstream Vera Sans", "Bold", - "/boot/beos/etc/fonts/ttfonts/VeraBd.ttf"); - _AddDefaultMapping("Bitstream Vera Sans Mono", "Roman", - "/boot/beos/etc/fonts/ttfonts/VeraMono.ttf"); + BPath ttfontsPath; + if (find_directory(B_BEOS_FONTS_DIRECTORY, &ttfontsPath) == B_OK) { + ttfontsPath.Append("ttfonts"); + BPath veraFontPath = ttfontsPath; + veraFontPath.Append("Vera.ttf"); + _AddDefaultMapping("Bitstream Vera Sans", "Roman", veraFontPath.Path()); + + veraFontPath.SetTo(ttfontsPath.Path()); + veraFontPath.Append("VeraBd.ttf"); + _AddDefaultMapping("Bitstream Vera Sans", "Bold", veraFontPath.Path()); + + veraFontPath.SetTo(ttfontsPath.Path()); + veraFontPath.Append("VeraMono.ttf"); + _AddDefaultMapping("Bitstream Vera Sans Mono", "Roman", veraFontPath.Path()); + } + return false; } From stefano.ceccherini at gmail.com Thu May 8 13:33:27 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 8 May 2008 13:33:27 +0200 Subject: [Haiku-commits] r25368 - haiku/trunk/src/servers/app In-Reply-To: <200805081128.m48BSjd3004432@sheep.berlios.de> References: <200805081128.m48BSjd3004432@sheep.berlios.de> Message-ID: <894b9700805080433v13e379a7xa4a9bde0b05d37d9@mail.gmail.com> 2008/5/8 korli at BerliOS : > Author: korli > Date: 2008-05-08 13:28:42 +0200 (Thu, 08 May 2008) > New Revision: 25368 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25368&view=rev > > Modified: > haiku/trunk/src/servers/app/FontManager.cpp > Log: > Patch from Kaoutsis: use find_directory() instead of hard coded paths > > + BPath ttfontsPath; > + if (find_directory(B_BEOS_FONTS_DIRECTORY, &ttfontsPath) == B_OK) { > + ttfontsPath.Append("ttfonts"); > > + BPath veraFontPath = ttfontsPath; > + veraFontPath.Append("Vera.ttf"); > + _AddDefaultMapping("Bitstream Vera Sans", "Roman", veraFontPath.Path()); > + > + veraFontPath.SetTo(ttfontsPath.Path()); > + veraFontPath.Append("VeraBd.ttf"); > + _AddDefaultMapping("Bitstream Vera Sans", "Bold", veraFontPath.Path()); > + > + veraFontPath.SetTo(ttfontsPath.Path()); > + veraFontPath.Append("VeraMono.ttf"); > + _AddDefaultMapping("Bitstream Vera Sans Mono", "Roman", veraFontPath.Path()); > + } > + > return false; BTW Default font isn't vera anymore, but Deja Vu. I obviously forgot to change it here too. We should also remove Vera from the image/repository, since DejaVu is Vera plus some extra glyphs. From revol at free.fr Thu May 8 13:43:00 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 13:43:00 +0200 CEST Subject: [Haiku-commits] r25367 - haiku/trunk/build/jam In-Reply-To: <200805081117.m48BH9mW028198@sheep.berlios.de> Message-ID: <2232444179-BeMail@laptop> > added a sounds directory in beos/etc Oh great I had that pending here :) Maybe it's time have a contest for an official startup and beep sound ? personally I was thinking about a few notes of some recognizable japanese instrument to fit the "Haiku" name (alike Ubuntu's startup sound which sounds a bit african without being too strongly assigned), but that could be something totally different. Fran?ois. From korli at mail.berlios.de Thu May 8 13:43:01 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 13:43:01 +0200 Subject: [Haiku-commits] r25369 - haiku/trunk/src/servers/app Message-ID: <200805081143.m48Bh1Mb031448@sheep.berlios.de> Author: korli Date: 2008-05-08 13:43:00 +0200 (Thu, 08 May 2008) New Revision: 25369 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25369&view=rev Modified: haiku/trunk/src/servers/app/FontManager.cpp Log: added a TODO about user fonts in safe mode Modified: haiku/trunk/src/servers/app/FontManager.cpp =================================================================== --- haiku/trunk/src/servers/app/FontManager.cpp 2008-05-08 11:28:42 UTC (rev 25368) +++ haiku/trunk/src/servers/app/FontManager.cpp 2008-05-08 11:43:00 UTC (rev 25369) @@ -1064,6 +1064,7 @@ #if !TEST_MODE // TODO: actually, find_directory() cannot know which user ID we want here + // TODO: avoids user fonts in safe mode BPath path; if (find_directory(B_USER_FONTS_DIRECTORY, &path, true) != B_OK) return; From jackburton at mail.berlios.de Thu May 8 14:07:42 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 8 May 2008 14:07:42 +0200 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal Message-ID: <200805081207.m48C7gg1002377@sheep.berlios.de> Author: jackburton Date: 2008-05-08 14:07:41 +0200 (Thu, 08 May 2008) New Revision: 25370 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25370&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Added a BDragger so that Terminal is replicanteable. Salvatore, hope you like it :) Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-08 11:43:00 UTC (rev 25369) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-08 12:07:41 UTC (rev 25370) @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -183,6 +184,14 @@ { _InitObject(argc, argv); SetTermSize(fTermRows, fTermColumns, true); + + BRect rect(0, 0, 16, 16); + rect.OffsetTo(Bounds().right - rect.Width(), + Bounds().bottom - rect.Height()); + + SetFlags(Flags() | B_DRAW_ON_CHILDREN | B_FOLLOW_ALL); + AddChild(new BDragger(rect, this, + B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW)); } @@ -326,6 +335,9 @@ if (status == B_OK) status = data->AddInt32("rows", (int32)fTermRows); + if (data->ReplaceString("class", "TermView") != B_OK) + data->AddString("class", "TermView"); + return status; } From revol at free.fr Thu May 8 14:21:02 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 14:21:02 +0200 CEST Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <200805081207.m48C7gg1002377@sheep.berlios.de> Message-ID: <4514294567-BeMail@laptop> > Added a BDragger so that Terminal is replicanteable. Salvatore, hope > you > like it :) \o/ Just need to support a "InitialCommand" field from the BMessage and then you can add a "tail -f /var/log/syslog" on your desktop ;) Fran?ois. From stefano.ceccherini at gmail.com Thu May 8 14:27:16 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 8 May 2008 14:27:16 +0200 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <4514294567-BeMail@laptop> References: <200805081207.m48C7gg1002377@sheep.berlios.de> <4514294567-BeMail@laptop> Message-ID: <894b9700805080527v45c313k543760a2b0365c15@mail.gmail.com> 2008/5/8 Fran?ois Revol : > > \o/ > > Just need to support a "InitialCommand" field from the BMessage and > then you can add a "tail -f /var/log/syslog" on your desktop ;) It's already there. You need to add 2 fields: an int32 "argc" and a char ** "argv". BTW I just noticed the dragger follow the view when scrolled, so it's not nice... needs to change it. From stefano.ceccherini at gmail.com Thu May 8 14:29:43 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 8 May 2008 14:29:43 +0200 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700805080527v45c313k543760a2b0365c15@mail.gmail.com> References: <200805081207.m48C7gg1002377@sheep.berlios.de> <4514294567-BeMail@laptop> <894b9700805080527v45c313k543760a2b0365c15@mail.gmail.com> Message-ID: <894b9700805080529v60b4edc5nd4e5ff2228ac7f8@mail.gmail.com> 2008/5/8 Stefano Ceccherini : > 2008/5/8 Fran?ois Revol : >> >> \o/ >> >> Just need to support a "InitialCommand" field from the BMessage and >> then you can add a "tail -f /var/log/syslog" on your desktop ;) > > It's already there. You need to add 2 fields: an int32 "argc" and a > char ** "argv". Sorry, I meant: an int32 "argc" and a number of const char * "argv". I didn't think of a better solution... maybe having just a string with a commandline separated by spaces ? From mmu_man at mail.berlios.de Thu May 8 14:35:42 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 8 May 2008 14:35:42 +0200 Subject: [Haiku-commits] r25371 - haiku/trunk/src/apps/sudoku Message-ID: <200805081235.m48CZgl8006622@sheep.berlios.de> Author: mmu_man Date: 2008-05-08 14:35:41 +0200 (Thu, 08 May 2008) New Revision: 25371 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25371&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp Log: BPicture is obviously not text data, should be image/ supertype! Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-05-08 12:07:41 UTC (rev 25370) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-05-08 12:35:41 UTC (rev 25371) @@ -475,7 +475,7 @@ // flattened BPicture, anyone handles that ? if (SaveTo(mio, kExportAsPicture) >= B_OK) { - clip->AddData("text/x-vnd.Be-picture", B_MIME_TYPE, mio.Buffer(), mio.BufferLength()); + clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE, mio.Buffer(), mio.BufferLength()); } mio.SetSize(0LL); From emitrax at gmail.com Thu May 8 14:40:55 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Thu, 8 May 2008 12:40:55 +0000 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <200805081207.m48C7gg1002377@sheep.berlios.de> References: <200805081207.m48C7gg1002377@sheep.berlios.de> Message-ID: 2008/5/8 jackburton at BerliOS : > Author: jackburton > Date: 2008-05-08 14:07:41 +0200 (Thu, 08 May 2008) > New Revision: 25370 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25370&view=rev > > Modified: > haiku/trunk/src/apps/terminal/TermView.cpp > Log: > Added a BDragger so that Terminal is replicanteable. Salvatore, hope you > like it :) > Finally! :) Thanks. Let's see how it look on the desktop. BTW: It'd be nice to have a test application, that simply accepts replicant. For example, I could put the editor on top, and the terminal below. :) Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From revol at free.fr Thu May 8 14:44:01 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 14:44:01 +0200 CEST Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700805080527v45c313k543760a2b0365c15@mail.gmail.com> Message-ID: <5893237534-BeMail@laptop> > 2008/5/8 Fran?ois Revol : > > > > \o/ > > > > Just need to support a "InitialCommand" field from the BMessage and > > then you can add a "tail -f /var/log/syslog" on your desktop ;) > > It's already there. You need to add 2 fields: an int32 "argc" and a > char ** "argv". Great, I have to try it ! > BTW I just noticed the dragger follow the view when scrolled, so it's > not nice... needs to change it. Eh. Fran?ois. From revol at free.fr Thu May 8 14:45:00 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 14:45:00 +0200 CEST Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700805080529v60b4edc5nd4e5ff2228ac7f8@mail.gmail.com> Message-ID: <5952577117-BeMail@laptop> > 2008/5/8 Stefano Ceccherini : > > 2008/5/8 Fran?ois Revol : > >> > >> \o/ > >> > >> Just need to support a "InitialCommand" field from the BMessage > > > and > >> then you can add a "tail -f /var/log/syslog" on your desktop ;) > > > > It's already there. You need to add 2 fields: an int32 "argc" and > > a > > char ** "argv". > > Sorry, I meant: an int32 "argc" and a number of const char * "argv". > I didn't think of a better solution... maybe having just a string > with > a commandline separated by spaces ? Actually you might want to follow the same fields as B_ARGV_RECEIVED, that will simplify the code. Fran?ois. From revol at free.fr Thu May 8 14:46:17 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 14:46:17 +0200 CEST Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: Message-ID: <6029458740-BeMail@laptop> > BTW: It'd be nice to have a test application, that simply accepts > replicant. For example, > I could put the editor on top, and the terminal below. :) Don't we have a Container demo around ? at least it was part of Be's Sample code. I could also commit my ShelfTest code... Fran?ois. From mmu_man at mail.berlios.de Thu May 8 14:56:56 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 8 May 2008 14:56:56 +0200 Subject: [Haiku-commits] r25372 - haiku/trunk/src/kits/support Message-ID: <200805081256.m48CuufL010662@sheep.berlios.de> Author: mmu_man Date: 2008-05-08 14:56:55 +0200 (Thu, 08 May 2008) New Revision: 25372 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25372&view=rev Modified: haiku/trunk/src/kits/support/String.cpp Log: Make the BString& version of SetTo() behave like BeOS, that length < 0 is means "until the end". This makes CopyInto() acting alike too. Note the char * version crashes in BeOS, instead we act like the other version for consistency. There are many other calls that crash in BeOS when called with invalid args, should we attempt to sanitize them or call debugger() instead ? Modified: haiku/trunk/src/kits/support/String.cpp =================================================================== --- haiku/trunk/src/kits/support/String.cpp 2008-05-08 12:35:41 UTC (rev 25371) +++ haiku/trunk/src/kits/support/String.cpp 2008-05-08 12:56:55 UTC (rev 25372) @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -259,6 +260,8 @@ BString& BString::SetTo(const char* string, int32 maxLength) { + if (maxLength < 0) + maxLength = INT32_MAX; maxLength = strlen_clamp(safestr(string), maxLength); if (_DetachWith("", maxLength) == B_OK) memcpy(fPrivateData, string, maxLength); @@ -309,6 +312,8 @@ BString& BString::SetTo(const BString& string, int32 maxLength) { + if (maxLength < 0) + maxLength = INT32_MAX; if (fPrivateData != string.fPrivateData // make sure we reassing in case length is different || (fPrivateData == string.fPrivateData && Length() > maxLength)) { From korli at mail.berlios.de Thu May 8 15:10:09 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 8 May 2008 15:10:09 +0200 Subject: [Haiku-commits] r25373 - haiku/trunk/src/kits/interface Message-ID: <200805081310.m48DA9Vs012254@sheep.berlios.de> Author: korli Date: 2008-05-08 15:10:09 +0200 (Thu, 08 May 2008) New Revision: 25373 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25373&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: use find_directory() instead of /boot/home/ Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-05-08 12:56:55 UTC (rev 25372) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-05-08 13:10:09 UTC (rev 25373) @@ -19,10 +19,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -3248,15 +3250,23 @@ int32 rawKey; if (event->FindInt32("key", &rawKey) == B_OK && rawKey == B_PRINT_KEY) { // Get filename - char filename[128]; + BPath homePath; + + if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK) { + fprintf(stderr, "failed to find user home directory\n"); + return true; + } + + BPath path; BEntry entry; - int32 index = 1; do { - // TODO: Use find_directory(B_USER_DIRECTORY, ...) - sprintf(filename, "/boot/home/screen%ld.png", index++); - entry.SetTo(filename); - } while(entry.Exists()); + char filename[32]; + sprintf(filename, "screen%ld.png", index++); + path = homePath; + path.Append(filename); + entry.SetTo(path.Path()); + } while (entry.Exists()); // Get the screen bitmap BScreen screen(this); @@ -3264,7 +3274,7 @@ screen.GetBitmap(&screenDump, false); // Dump to PNG - SaveToPNG(filename, screen.Frame(), screenDump->ColorSpace(), + SaveToPNG(path.Path(), screen.Frame(), screenDump->ColorSpace(), screenDump->Bits(), screenDump->BitsLength(), screenDump->BytesPerRow()); From emitrax at gmail.com Thu May 8 15:10:18 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Thu, 8 May 2008 13:10:18 +0000 Subject: [Haiku-commits] r25372 - haiku/trunk/src/kits/support In-Reply-To: <200805081256.m48CuufL010662@sheep.berlios.de> References: <200805081256.m48CuufL010662@sheep.berlios.de> Message-ID: 2008/5/8 mmu_man at BerliOS : > Author: mmu_man > Date: 2008-05-08 14:56:55 +0200 (Thu, 08 May 2008) > New Revision: 25372 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25372&view=rev > > Modified: > haiku/trunk/src/kits/support/String.cpp > Log: > Make the BString& version of SetTo() behave like BeOS, that length < 0 is means "until the end". This makes CopyInto() acting alike too. Note the char * version crashes in BeOS, instead we act like the other version for consistency. > There are many other calls that crash in BeOS when called with invalid args, should we attempt to sanitize them or call debugger() instead ? > BTW: Marco made me notice, that there is not GetLine method, or std::cin operator>> method. This might come handy when writing command line applications I think. Any particular reason why it is missing? Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From oliver.ruiz.dorantes at gmail.com Thu May 8 15:24:31 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Thu, 8 May 2008 15:24:31 +0200 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <6029458740-BeMail@laptop> References: <6029458740-BeMail@laptop> Message-ID: http://www.bebits.com/app/3910 2008/5/8, Fran?ois Revol : > > > BTW: It'd be nice to have a test application, that simply accepts > > replicant. For example, > > I could put the editor on top, and the terminal below. :) > > > Don't we have a Container demo around ? at least it was part of Be's > Sample code. > > I could also commit my ShelfTest code... > > > Fran?ois. > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bonefish at mail.berlios.de Thu May 8 15:42:33 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 15:42:33 +0200 Subject: [Haiku-commits] r25374 - in haiku/trunk: data/system/boot headers/posix/sys src/system/libroot/posix/sys Message-ID: <200805081342.m48DgXXb015813@sheep.berlios.de> Author: bonefish Date: 2008-05-08 15:42:33 +0200 (Thu, 08 May 2008) New Revision: 25374 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25374&view=rev Modified: haiku/trunk/data/system/boot/Bootscript haiku/trunk/headers/posix/sys/mman.h haiku/trunk/src/system/libroot/posix/sys/mman.cpp Log: Implement shm_open() and shm_unlink(). The shared memory objects are simply created as files in /boot/var/shared_memory/. The Bootscript clears the directory. Modified: haiku/trunk/data/system/boot/Bootscript =================================================================== --- haiku/trunk/data/system/boot/Bootscript 2008-05-08 13:10:09 UTC (rev 25373) +++ haiku/trunk/data/system/boot/Bootscript 2008-05-08 13:42:33 UTC (rev 25374) @@ -57,6 +57,12 @@ SCRIPTS=beos/system/boot SERVERS=beos/system/servers +# clean the shared memory dir +shmDir=/boot/var/shared_memory +rm -rf $shmDir +mkdir $shmDir +chmod 777 $shmDir + # Set up the environment export SAFEMODE=`/bin/safemode` Modified: haiku/trunk/headers/posix/sys/mman.h =================================================================== --- haiku/trunk/headers/posix/sys/mman.h 2008-05-08 13:10:09 UTC (rev 25373) +++ haiku/trunk/headers/posix/sys/mman.h 2008-05-08 13:42:33 UTC (rev 25374) @@ -5,6 +5,7 @@ #ifndef _SYS_MMAN_H #define _SYS_MMAN_H +#include #include @@ -24,19 +25,17 @@ // mmap() error return code #define MAP_FAILED ((void*)-1) -#ifdef __cplusplus -extern "C" { -#endif +__BEGIN_DECLS -extern void* mmap(void* address, size_t length, int protection, int flags, - int fd, off_t offset); -extern int munmap(void* address, size_t length); +void* mmap(void* address, size_t length, int protection, int flags, + int fd, off_t offset); +int munmap(void* address, size_t length); +int shm_open(const char* name, int openMode, mode_t permissions); +int shm_unlink(const char* name); -#ifdef __cplusplus -} -#endif +__END_DECLS #endif // _SYS_MMAN_H Modified: haiku/trunk/src/system/libroot/posix/sys/mman.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2008-05-08 13:10:09 UTC (rev 25373) +++ haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2008-05-08 13:42:33 UTC (rev 25374) @@ -6,6 +6,8 @@ #include #include +#include +#include #include @@ -14,6 +16,73 @@ #include +static const char* kSharedMemoryDir = "/boot/var/shared_memory/"; + + +static bool +append_string(char*& path, size_t& bytesLeft, const char* toAppend, size_t size) +{ + if (bytesLeft <= size) + return false; + + memcpy(path, toAppend, size); + path += size; + path[0] = '\0'; + bytesLeft -= size; + + return true; +} + + +static bool +append_string(char*& path, size_t& bytesLeft, const char* toAppend) +{ + return append_string(path, bytesLeft, toAppend, strlen(toAppend)); +} + + +static status_t +shm_name_to_path(const char* name, char* path, size_t pathSize) +{ + if (name == NULL) + return B_BAD_VALUE; + + // skip leading slashes + while (*name == '/') + name++; + + if (*name == '\0') + return B_BAD_VALUE; + + // create the path; replace occurrences of '/' by "%s" and '%' by "%%" + if (!append_string(path, pathSize, kSharedMemoryDir)) + return ENAMETOOLONG; + + while (const char* found = strpbrk(name, "%/")) { + // append section that doesn't need escaping + if (found != name) { + if (!append_string(path, pathSize, name, found - name)) + return ENAMETOOLONG; + } + + // append escaped char + const char* append = (*found == '%' ? "%%" : "%s"); + if (!append_string(path, pathSize, append, 2)) + return ENAMETOOLONG; + name = found + 1; + } + + // append remaining string + if (!append_string(path, pathSize, name)) + return ENAMETOOLONG; + + return B_OK; +} + + +// #pragma mark - + + void* mmap(void* address, size_t length, int protection, int flags, int fd, off_t offset) @@ -71,3 +140,27 @@ { RETURN_AND_SET_ERRNO(_kern_unmap_memory(address, length)); } + + +int +shm_open(const char* name, int openMode, mode_t permissions) +{ + char path[PATH_MAX]; + status_t error = shm_name_to_path(name, path, sizeof(path)); + if (error != B_OK) + RETURN_AND_SET_ERRNO(error); + + return open(path, openMode, permissions); +} + + +int +shm_unlink(const char* name) +{ + char path[PATH_MAX]; + status_t error = shm_name_to_path(name, path, sizeof(path)); + if (error != B_OK) + RETURN_AND_SET_ERRNO(error); + + return unlink(path); +} From leavengood at gmail.com Thu May 8 15:52:20 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 8 May 2008 09:52:20 -0400 Subject: [Haiku-commits] r25367 - haiku/trunk/build/jam In-Reply-To: <2232444179-BeMail@laptop> References: <200805081117.m48BH9mW028198@sheep.berlios.de> <2232444179-BeMail@laptop> Message-ID: On Thu, May 8, 2008 at 7:43 AM, Fran?ois Revol wrote: > > personally I was thinking about a few notes of some recognizable > japanese instrument to fit the "Haiku" name (alike Ubuntu's startup > sound which sounds a bit african without being too strongly assigned), > but that could be something totally different. I had the same thoughts. I was thinking of the Shakuhachi flute: http://en.wikipedia.org/wiki/Shakuhachi This can be synthesized pretty well or one could even be made from PVC pipe ;) I was thinking of making one for fun and maybe if I can play it well enough I could record something :) I think there are some classic Japanese arrangements for it which could be used as the basis for our start-up sound. Ryan From stefano.ceccherini at gmail.com Thu May 8 16:01:25 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Thu, 8 May 2008 16:01:25 +0200 Subject: [Haiku-commits] r25370 - haiku/trunk/src/apps/terminal In-Reply-To: <5952577117-BeMail@laptop> References: <894b9700805080529v60b4edc5nd4e5ff2228ac7f8@mail.gmail.com> <5952577117-BeMail@laptop> Message-ID: <894b9700805080701t77dfa931m5a49f1f3037d9521@mail.gmail.com> 2008/5/8 Fran?ois Revol : > Actually you might want to follow the same fields as B_ARGV_RECEIVED, > that will simplify the code. I'll do that. From axeld at mail.berlios.de Thu May 8 17:08:14 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 17:08:14 +0200 Subject: [Haiku-commits] r25375 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200805081508.m48F8E1V022427@sheep.berlios.de> Author: axeld Date: 2008-05-08 17:08:14 +0200 (Thu, 08 May 2008) New Revision: 25375 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25375&view=rev Added: haiku/trunk/src/system/kernel/kernel_daemon.cpp Removed: haiku/trunk/src/system/kernel/kernel_daemon.c Modified: haiku/trunk/headers/private/kernel/kernel_daemon.h haiku/trunk/src/system/kernel/Jamfile Log: * kernel_daemon is now a C++ file, and uses DoublyLinkedList instead of the C list mechanism which also makes the code nicer. Modified: haiku/trunk/headers/private/kernel/kernel_daemon.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel_daemon.h 2008-05-08 13:42:33 UTC (rev 25374) +++ haiku/trunk/headers/private/kernel/kernel_daemon.h 2008-05-08 15:08:14 UTC (rev 25375) @@ -1,12 +1,17 @@ +/* + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _KERNEL_DAEMON_H #define _KERNEL_DAEMON_H -/* -** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + #include -extern status_t kernel_daemon_init(void); +#ifdef __cplusplus +extern "C" +#endif +status_t kernel_daemon_init(void); + #endif /* _KRENEL_DAEMON_H */ Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-05-08 13:42:33 UTC (rev 25374) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-08 15:08:14 UTC (rev 25375) @@ -25,7 +25,7 @@ heap.cpp image.c int.c - kernel_daemon.c + kernel_daemon.cpp linkhack.c lock.cpp main.c Deleted: haiku/trunk/src/system/kernel/kernel_daemon.c Copied: haiku/trunk/src/system/kernel/kernel_daemon.cpp (from rev 25339, haiku/trunk/src/system/kernel/kernel_daemon.c) =================================================================== --- haiku/trunk/src/system/kernel/kernel_daemon.c 2008-05-07 09:07:48 UTC (rev 25339) +++ haiku/trunk/src/system/kernel/kernel_daemon.cpp 2008-05-08 15:08:14 UTC (rev 25375) @@ -0,0 +1,143 @@ +/* + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include +#include +#include + +#include + +#include +#include +#include + + +// The use of snooze() in the kernel_daemon() function is very inaccurate, of +// course - the time the daemons need to execute add up in each iteration. +// But since the kernel daemon is documented to be very inaccurate, this +// actually might be okay (and that's why it's implemented this way now :-). +// BeOS R5 seems to do it in the same way, anyway. + +struct daemon : DoublyLinkedListLinkImpl { + daemon_hook function; + void* arg; + int32 frequency; + int32 offset; +}; + + +typedef DoublyLinkedList DaemonList; + +static mutex sDaemonMutex; +static DaemonList sDaemons; + + +static status_t +kernel_daemon(void* data) +{ + int32 iteration = 0; + + while (true) { + mutex_lock(&sDaemonMutex); + + DaemonList::Iterator iterator = sDaemons.GetIterator(); + + // iterate through the list and execute each daemon if needed + while (iterator.HasNext()) { + struct daemon* daemon = iterator.Next(); + + if (((iteration + daemon->offset) % daemon->frequency) == 0) + daemon->function(daemon->arg, iteration); + } + mutex_unlock(&sDaemonMutex); + + iteration++; + snooze(100000); // 0.1 seconds + } + + return B_OK; +} + + +// #pragma mark - + + +extern "C" status_t +unregister_kernel_daemon(daemon_hook function, void* arg) +{ + MutexLocker _(sDaemonMutex); + + DaemonList::Iterator iterator = sDaemons.GetIterator(); + + // search for the daemon and remove it from the list + while (iterator.HasNext()) { + struct daemon* daemon = iterator.Next(); + + if (daemon->function == function && daemon->arg == arg) { + // found it! + iterator.Remove(); + free(daemon); + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + +extern "C" status_t +register_kernel_daemon(daemon_hook function, void* arg, int frequency) +{ + if (function == NULL || frequency < 1) + return B_BAD_VALUE; + + struct daemon* daemon = new(std::nothrow) struct daemon(); + if (daemon == NULL) + return B_NO_MEMORY; + + daemon->function = function; + daemon->arg = arg; + daemon->frequency = frequency; + + MutexLocker _(sDaemonMutex); + + if (frequency > 1) { + // we try to balance the work-load for each daemon run + // (beware, it's a very simple algorithm, yet effective) + + DaemonList::Iterator iterator = sDaemons.GetIterator(); + int32 num = 0; + + while (iterator.HasNext()) { + if (iterator.Next()->frequency == frequency) + num++; + } + + daemon->offset = num % frequency; + } else + daemon->offset = 0; + + sDaemons.Add(daemon); + return B_OK; +} + + +extern "C" status_t +kernel_daemon_init(void) +{ + thread_id thread; + + mutex_init(&sDaemonMutex, "kernel daemon"); + new(&sDaemons) DaemonList; + + thread = spawn_kernel_thread(&kernel_daemon, "kernel daemon", + B_LOW_PRIORITY, NULL); + send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); + + return B_OK; +} From axeld at mail.berlios.de Thu May 8 17:08:31 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 17:08:31 +0200 Subject: [Haiku-commits] r25376 - haiku/trunk/src/system/kernel/fs Message-ID: <200805081508.m48F8V4v022465@sheep.berlios.de> Author: axeld Date: 2008-05-08 17:08:30 +0200 (Thu, 08 May 2008) New Revision: 25376 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25376&view=rev Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp Log: Reordered includes. Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-08 15:08:14 UTC (rev 25375) +++ haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-08 15:08:30 UTC (rev 25376) @@ -5,14 +5,15 @@ /** A simple class wrapping a path. Has a fixed-sized buffer. */ -#include -#include -#include +#include #include #include +#include +#include + // debugging #define TRACE(x) ; //#define TRACE(x) dprintf x From axeld at mail.berlios.de Thu May 8 17:09:57 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 17:09:57 +0200 Subject: [Haiku-commits] r25377 - haiku/trunk/src/tests/add-ons/kernel Message-ID: <200805081509.m48F9vSV022549@sheep.berlios.de> Author: axeld Date: 2008-05-08 17:09:57 +0200 (Thu, 08 May 2008) New Revision: 25377 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25377&view=rev Modified: haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp Log: Fixed the libkernelland_emu.so build that Ingo broke so deliberately. Modified: haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp 2008-05-08 15:08:30 UTC (rev 25376) +++ haiku/trunk/src/tests/add-ons/kernel/kernelland_emu.cpp 2008-05-08 15:09:57 UTC (rev 25377) @@ -26,7 +26,7 @@ #include #ifdef TRACE -#undef TRACE +# undef TRACE #endif #define TRACE(x) //#define TRACE(x) printf x @@ -1081,22 +1081,35 @@ // #pragma mark - -status_t +void mutex_init(mutex *m, const char *name) { if (m == NULL) - return EINVAL; + return; if (name == NULL) name = "mutex_sem"; - m->holder = -1; + // We need to store the semaphore in "waiters", as it is no sem anymore + // Also, kernel mutex creation cannot fail anymore, but we could... + m->waiters = (struct mutex_waiter *)create_sem(1, name); + if ((sem_id)m->waiters < B_OK) + debugger("semaphore creation failed"); +} - m->sem = create_sem(1, name); - if (m->sem >= B_OK) - return B_OK; - return m->sem; +void +mutex_init_etc(mutex *m, const char *name, uint32 flags) +{ + if (m == NULL) + return; + + if (name == NULL) + name = "mutex_sem"; + + m->waiters = (struct mutex_waiter *)create_sem(1, name); + if ((sem_id)m->waiters < B_OK) + debugger("semaphore creation failed"); } @@ -1106,44 +1119,31 @@ if (mutex == NULL) return; - if (mutex->sem >= 0) { - delete_sem(mutex->sem); - mutex->sem = -1; + if ((sem_id)mutex->waiters >= 0) { + delete_sem((sem_id)mutex->waiters); + mutex->waiters = (struct mutex_waiter *)-1; } - mutex->holder = -1; } status_t -mutex_lock(mutex *mutex) +_mutex_trylock(mutex *mutex) { - thread_id me = find_thread(NULL); + return acquire_sem_etc((sem_id)mutex->waiters, 1, B_RELATIVE_TIMEOUT, 0); +} - // ToDo: if acquire_sem() fails, we shouldn't panic - but we should definitely - // change the mutex API to actually return the status code - status_t status = acquire_sem(mutex->sem); - if (status < B_OK) - return status; - if (me == mutex->holder) - panic("mutex_lock failure: mutex %p (sem = 0x%lx) acquired twice by thread 0x%lx\n", mutex, mutex->sem, me); - - mutex->holder = me; - return B_OK; +status_t +_mutex_lock(mutex *mutex, bool threadsLocked) +{ + return acquire_sem((sem_id)mutex->waiters); } void -mutex_unlock(mutex *mutex) +_mutex_unlock(mutex *mutex) { - thread_id me = find_thread(NULL); - - if (me != mutex->holder) - panic("mutex_unlock failure: thread 0x%lx is trying to release mutex %p (current holder 0x%lx)\n", - me, mutex, mutex->holder); - - mutex->holder = -1; - release_sem(mutex->sem); + release_sem((sem_id)mutex->waiters); } From axeld at mail.berlios.de Thu May 8 17:52:28 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 17:52:28 +0200 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs Message-ID: <200805081552.m48FqSE1027683@sheep.berlios.de> Author: axeld Date: 2008-05-08 17:52:27 +0200 (Thu, 08 May 2008) New Revision: 25378 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25378&view=rev Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp haiku/trunk/src/system/kernel/fs/fifo.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Replaced benaphores with mutexes. Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-08 15:09:57 UTC (rev 25377) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-08 15:52:27 UTC (rev 25378) @@ -99,7 +99,7 @@ struct block_cache : DoublyLinkedListLinkImpl { hash_table *hash; - benaphore lock; + mutex lock; int fd; off_t max_blocks; size_t block_size; @@ -657,9 +657,7 @@ if (transaction_hash == NULL) return; - if (benaphore_init(&lock, "block cache") < B_OK) - return; - + mutex_init(&lock, "block cache"); register_low_memory_handler(&block_cache::LowMemoryHandler, this, 0); } @@ -671,7 +669,7 @@ unregister_low_memory_handler(&block_cache::LowMemoryHandler, this); - benaphore_destroy(&lock); + mutex_destroy(&lock); condition_variable.Unpublish(); @@ -689,9 +687,6 @@ status_t block_cache::InitCheck() { - if (lock.sem < B_OK) - return lock.sem; - if (buffer_cache == NULL || hash == NULL || transaction_hash == NULL) return B_NO_MEMORY; @@ -834,7 +829,7 @@ block_cache::LowMemoryHandler(void *data, int32 level) { block_cache *cache = (block_cache *)data; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); if (!locker.IsLocked()) { // If our block_cache were deleted, it could be that we had @@ -1457,7 +1452,7 @@ block_cache *cache; if (last != NULL) { - benaphore_unlock(&last->lock); + mutex_unlock(&last->lock); cache = sCaches.GetNext((block_cache *)&sMarkCache); sCaches.Remove((block_cache *)&sMarkCache); @@ -1471,14 +1466,14 @@ if (cache == NULL) break; - status_t status = benaphore_lock(&cache->lock); + status_t status = mutex_lock(&cache->lock); if (status != B_OK) { // can only happen if the cache is being deleted right now continue; } if (cache->deleting) { - benaphore_unlock(&cache->lock); + mutex_unlock(&cache->lock); continue; } @@ -1667,7 +1662,7 @@ cache_start_transaction(void *_cache) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); if (cache->last_transaction && cache->last_transaction->open) { panic("last transaction (%ld) still open!\n", @@ -1694,7 +1689,7 @@ cache_sync_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); status_t status = B_ENTRY_NOT_FOUND; TRACE(("cache_sync_transaction(id %ld)\n", id)); @@ -1762,7 +1757,7 @@ transaction_notification_hook hook, void *data) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("cache_end_transaction(id = %ld)\n", id)); @@ -1819,7 +1814,7 @@ cache_abort_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("cache_abort_transaction(id = %ld)\n", id)); @@ -1870,7 +1865,7 @@ transaction_notification_hook hook, void *data) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("cache_detach_sub_transaction(id = %ld)\n", id)); @@ -1958,7 +1953,7 @@ cache_abort_sub_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("cache_abort_sub_transaction(id = %ld)\n", id)); @@ -2009,7 +2004,7 @@ cache_start_sub_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("cache_start_sub_transaction(id = %ld)\n", id)); @@ -2060,7 +2055,7 @@ { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL) @@ -2076,7 +2071,7 @@ { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL) @@ -2109,7 +2104,7 @@ cached_block *block = (cached_block *)*_cookie; block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL || !transaction->open) @@ -2145,7 +2140,7 @@ cache_blocks_in_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL) @@ -2159,7 +2154,7 @@ cache_blocks_in_main_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL) @@ -2173,7 +2168,7 @@ cache_blocks_in_sub_transaction(void *_cache, int32 id) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cache_transaction *transaction = lookup_transaction(cache, id); if (transaction == NULL) @@ -2194,7 +2189,7 @@ if (allowWrites) block_cache_sync(cache); - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); // free all blocks @@ -2243,7 +2238,7 @@ // we will sync all dirty blocks to disk that have a completed // transaction or no transaction only - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); hash_iterator iterator; hash_open(cache->hash, &iterator); @@ -2281,7 +2276,7 @@ return B_BAD_VALUE; } - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); for (; numBlocks > 0; numBlocks--, blockNumber++) { cached_block *block = (cached_block *)hash_lookup(cache->hash, @@ -2312,7 +2307,7 @@ block_cache_make_writable(void *_cache, off_t blockNumber, int32 transaction) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); if (cache->read_only) panic("tried to make block writable on a read-only cache!"); @@ -2334,7 +2329,7 @@ off_t length, int32 transaction) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("block_cache_get_writable_etc(block = %Ld, transaction = %ld)\n", blockNumber, transaction)); @@ -2358,7 +2353,7 @@ block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); TRACE(("block_cache_get_empty(block = %Ld, transaction = %ld)\n", blockNumber, transaction)); @@ -2374,7 +2369,7 @@ block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); bool allocated; cached_block *block = get_cached_block(cache, blockNumber, &allocated); @@ -2410,7 +2405,7 @@ int32 transaction) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); cached_block *block = (cached_block *)hash_lookup(cache->hash, &blockNumber); @@ -2433,7 +2428,7 @@ block_cache_put(void *_cache, off_t blockNumber) { block_cache *cache = (block_cache *)_cache; - BenaphoreLocker locker(&cache->lock); + MutexLocker locker(&cache->lock); put_cached_block(cache, blockNumber); } Modified: haiku/trunk/src/system/kernel/fs/fifo.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fifo.cpp 2008-05-08 15:09:57 UTC (rev 25377) +++ haiku/trunk/src/system/kernel/fs/fifo.cpp 2008-05-08 15:52:27 UTC (rev 25378) @@ -133,7 +133,7 @@ void SetModificationTime(time_t modificationTime) { fModificationTime = modificationTime; } - benaphore *RequestLock() { return &fRequestLock; } + mutex *RequestLock() { return &fRequestLock; } status_t WriteDataToBuffer(const void *data, size_t *_length, bool nonBlocking); @@ -168,7 +168,7 @@ ReadRequestList fReadRequests; WriteRequestList fWriteRequests; - benaphore fRequestLock; + mutex fRequestLock; ConditionVariable fWriteCondition; @@ -306,7 +306,7 @@ fWriteSelectSyncPool(NULL) { fWriteCondition.Publish(this, "pipe"); - benaphore_init(&fRequestLock, "pipe request"); + mutex_init(&fRequestLock, "pipe request"); fCreationTime = fModificationTime = time(NULL); } @@ -315,22 +315,18 @@ Inode::~Inode() { fWriteCondition.Unpublish(); - benaphore_destroy(&fRequestLock); + mutex_destroy(&fRequestLock); } status_t Inode::InitCheck() { - if (fRequestLock.sem < B_OK) - return B_ERROR; - return B_OK; } -/*! - Writes the specified data bytes to the inode's ring buffer. The +/*! Writes the specified data bytes to the inode's ring buffer. The request lock must be held when calling this method. Notifies readers if necessary, so that blocking readers will get started. Returns B_OK for success, B_BAD_ADDRESS if copying from the buffer failed, @@ -367,9 +363,9 @@ WriteRequest request(minToWrite); fWriteRequests.Add(&request); - benaphore_unlock(&fRequestLock); + mutex_unlock(&fRequestLock); status_t status = entry.Wait(); - benaphore_lock(&fRequestLock); + mutex_lock(&fRequestLock); fWriteRequests.Remove(&request); @@ -475,9 +471,9 @@ THREAD_BLOCK_TYPE_OTHER, "fifo read request"); // wait - benaphore_unlock(&fRequestLock); + mutex_unlock(&fRequestLock); status_t status = thread_block(); - benaphore_lock(&fRequestLock); + mutex_lock(&fRequestLock); return status; } @@ -567,7 +563,7 @@ void Inode::Open(int openMode) { - BenaphoreLocker locker(RequestLock()); + MutexLocker locker(RequestLock()); if ((openMode & O_ACCMODE) == O_WRONLY) fWriterCount++; @@ -592,7 +588,7 @@ { TRACE(("Inode::Close(openMode = %d)\n", openMode)); - BenaphoreLocker locker(RequestLock()); + MutexLocker locker(RequestLock()); if ((openMode & O_ACCMODE) == O_WRONLY && --fWriterCount == 0) NotifyEndClosed(true); @@ -761,7 +757,7 @@ if ((cookie->open_mode & O_RWMASK) != O_RDONLY) return B_NOT_ALLOWED; - BenaphoreLocker locker(inode->RequestLock()); + MutexLocker locker(inode->RequestLock()); if (inode->IsActive() && inode->WriterCount() == 0) { // as long there is no writer, and the pipe is empty, @@ -805,7 +801,7 @@ if ((cookie->open_mode & O_RWMASK) != O_WRONLY) return B_NOT_ALLOWED; - BenaphoreLocker locker(inode->RequestLock()); + MutexLocker locker(inode->RequestLock()); size_t length = *_length; if (length == 0) @@ -837,7 +833,7 @@ return error; - BenaphoreLocker locker(fifo->RequestLock()); + MutexLocker locker(fifo->RequestLock()); st->st_size = fifo->BytesAvailable(); @@ -909,7 +905,7 @@ if (!inode) return B_ERROR; - BenaphoreLocker locker(inode->RequestLock()); + MutexLocker locker(inode->RequestLock()); return inode->Select(event, sync, cookie->open_mode); } @@ -925,7 +921,7 @@ if (!inode) return B_ERROR; - BenaphoreLocker locker(inode->RequestLock()); + MutexLocker locker(inode->RequestLock()); return inode->Deselect(event, sync, cookie->open_mode); } Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-05-08 15:09:57 UTC (rev 25377) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-05-08 15:52:27 UTC (rev 25378) @@ -207,7 +207,7 @@ The only operation allowed while holding this lock besides getting or setting the field is inc_vnode_ref_count() on io_context::root. */ -static benaphore sIOContextRootLock; +static mutex sIOContextRootLock; #define VNODE_HASH_TABLE_SIZE 1024 static hash_table *sVnodeTable; @@ -1468,7 +1468,7 @@ struct vnode* fallBack, bool lockRootLock) { if (lockRootLock) - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); struct vnode* obsoleteVnode = NULL; @@ -1487,7 +1487,7 @@ } if (lockRootLock) - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); if (obsoleteVnode != NULL) put_vnode(obsoleteVnode); @@ -1601,13 +1601,13 @@ // Get current working directory from io context struct io_context* context = get_current_io_context(kernel); - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); struct vnode* root = context->root; if (root != NULL) inc_vnode_ref_count(root); - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); if (root != NULL) return root; @@ -1971,10 +1971,10 @@ while (*++path == '/') ; - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); vnode = ioContext->root; inc_vnode_ref_count(vnode); - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); absoluteSymlink = true; } @@ -4156,11 +4156,11 @@ mutex_lock(&parentContext->io_mutex); - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); context->root = parentContext->root; if (context->root) inc_vnode_ref_count(context->root); - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); context->cwd = parentContext->cwd; if (context->cwd) @@ -4413,10 +4413,8 @@ mutex_init(&sMountMutex, "vfs_mount_lock"); mutex_init(&sVnodeCoveredByMutex, "vfs_vnode_covered_by_lock"); mutex_init(&sVnodeMutex, "vfs_vnode_lock"); + mutex_init(&sIOContextRootLock, "io_context::root lock"); - if (benaphore_init(&sIOContextRootLock, "io_context::root lock") < 0) - panic("vfs_init: error allocating io_context::root lock\n"); - if (block_cache_init() != B_OK) return B_ERROR; @@ -6470,9 +6468,9 @@ if (!sRoot) { sRoot = mount->root_vnode; - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); get_current_io_context(true)->root = sRoot; - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); inc_vnode_ref_count(sRoot); } @@ -8705,10 +8703,10 @@ // set the new root struct io_context* context = get_current_io_context(false); - benaphore_lock(&sIOContextRootLock); + mutex_lock(&sIOContextRootLock); struct vnode* oldRoot = context->root; context->root = vnode; - benaphore_unlock(&sIOContextRootLock); + mutex_unlock(&sIOContextRootLock); put_vnode(oldRoot); From axeld at mail.berlios.de Thu May 8 17:57:59 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 17:57:59 +0200 Subject: [Haiku-commits] r25379 - haiku/trunk/src/system/kernel/vm Message-ID: <200805081557.m48Fvxr8028200@sheep.berlios.de> Author: axeld Date: 2008-05-08 17:57:59 +0200 (Thu, 08 May 2008) New Revision: 25379 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25379&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Replaced the sAvailableMemoryLock benaphore with a mutex. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-08 15:52:27 UTC (rev 25378) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-08 15:57:59 UTC (rev 25379) @@ -197,7 +197,7 @@ static mutex sAreaCacheLock; static off_t sAvailableMemory; -static benaphore sAvailableMemoryLock; +static mutex sAvailableMemoryLock; // function declarations static void delete_area(vm_address_space *addressSpace, vm_area *area); @@ -3583,7 +3583,6 @@ // initialize some globals sNextAreaID = 1; sAreaHashLock = -1; - sAvailableMemoryLock.sem = -1; vm_page_init_num_pages(args); sAvailableMemory = vm_page_num_pages() * B_PAGE_SIZE; @@ -3690,7 +3689,7 @@ // since we're still single threaded and only the kernel address space exists, // it isn't that hard to find all of the ones we need to create - benaphore_init(&sAvailableMemoryLock, "available memory lock"); + mutex_init(&sAvailableMemoryLock, "available memory lock"); arch_vm_translation_map_init_post_sem(args); vm_address_space_init_post_sem(); @@ -4484,11 +4483,11 @@ void vm_unreserve_memory(size_t amount) { - benaphore_lock(&sAvailableMemoryLock); + mutex_lock(&sAvailableMemoryLock); sAvailableMemory += amount; - benaphore_unlock(&sAvailableMemoryLock); + mutex_unlock(&sAvailableMemoryLock); } @@ -4496,7 +4495,7 @@ vm_try_reserve_memory(size_t amount) { status_t status; - benaphore_lock(&sAvailableMemoryLock); + mutex_lock(&sAvailableMemoryLock); //dprintf("try to reserve %lu bytes, %Lu left\n", amount, sAvailableMemory); @@ -4506,7 +4505,7 @@ } else status = B_NO_MEMORY; - benaphore_unlock(&sAvailableMemoryLock); + mutex_unlock(&sAvailableMemoryLock); return status; } From axeld at mail.berlios.de Thu May 8 18:06:51 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 18:06:51 +0200 Subject: [Haiku-commits] r25380 - haiku/trunk/src/system/kernel/slab Message-ID: <200805081606.m48G6pGm029112@sheep.berlios.de> Author: axeld Date: 2008-05-08 18:06:51 +0200 (Thu, 08 May 2008) New Revision: 25380 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25380&view=rev Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp Log: Now uses mutexes instead of benaphores, that also simplified object instantiation at early boot a bit. Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-05-08 15:57:59 UTC (rev 25379) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-05-08 16:06:51 UTC (rev 25380) @@ -63,7 +63,7 @@ struct object_cache : DoublyLinkedListLinkImpl { char name[32]; - benaphore lock; + mutex lock; size_t object_size; size_t cache_color_cycle; SlabList empty, partial, full; @@ -164,7 +164,7 @@ static ObjectCacheList sObjectCaches; -static benaphore sObjectCacheListLock; +static mutex sObjectCacheListLock; static uint8 *sInitialBegin, *sInitialLimit, *sInitialPointer; static kernel_args *sKernelArgs; @@ -420,19 +420,6 @@ static status_t -benaphore_boot_init(benaphore *lock, const char *name, uint32 flags) -{ - if (flags & CACHE_DURING_BOOT) { - lock->sem = -1; - lock->count = 1; - return B_OK; - } - - return benaphore_init(lock, name); -} - - -static status_t area_allocate_pages(object_cache *cache, void **pages, uint32 flags) { TRACE_CACHE(cache, "allocate pages (%lu, 0x0%lx)", cache->slab_size, flags); @@ -521,7 +508,7 @@ if (cache->reclaimer) cache->reclaimer(cache->cookie, level); - BenaphoreLocker _(cache->lock); + MutexLocker _(cache->lock); size_t minimumAllowed; switch (level) { @@ -571,9 +558,7 @@ { strlcpy(cache->name, name, sizeof(cache->name)); - status_t status = benaphore_boot_init(&cache->lock, name, flags); - if (status < B_OK) - return status; + mutex_init(&cache->lock, cache->name); if (objectSize < sizeof(object_link)) objectSize = sizeof(object_link); @@ -606,7 +591,7 @@ status_t status = object_depot_init(&cache->depot, flags, object_cache_return_object_wrapper); if (status < B_OK) { - benaphore_destroy(&cache->lock); + mutex_destroy(&cache->lock); return status; } } @@ -626,7 +611,7 @@ register_low_memory_handler(object_cache_low_memory, cache, 5); - BenaphoreLocker _(sObjectCacheListLock); + MutexLocker _(sObjectCacheListLock); sObjectCaches.Add(cache); return B_OK; @@ -636,10 +621,6 @@ static status_t object_cache_init_locks(object_cache *cache) { - status_t status = benaphore_init(&cache->lock, cache->name); - if (status < B_OK) - return status; - if (cache->flags & CACHE_NO_DEPOT) return B_OK; @@ -780,11 +761,11 @@ T(Delete(cache)); { - BenaphoreLocker _(sObjectCacheListLock); + MutexLocker _(sObjectCacheListLock); sObjectCaches.Remove(cache); } - benaphore_lock(&cache->lock); + mutex_lock(&cache->lock); if (!(cache->flags & CACHE_NO_DEPOT)) object_depot_destroy(&cache->depot); @@ -800,7 +781,7 @@ while (!cache->empty.IsEmpty()) cache->ReturnSlab(cache->empty.RemoveHead()); - benaphore_destroy(&cache->lock); + mutex_destroy(&cache->lock); delete_cache(cache); } @@ -816,7 +797,7 @@ } } - BenaphoreLocker _(cache->lock); + MutexLocker _(cache->lock); slab *source; if (cache->partial.IsEmpty()) { @@ -908,7 +889,7 @@ return; } - BenaphoreLocker _(cache->lock); + MutexLocker _(cache->lock); object_cache_return_to_slab(cache, cache->ObjectSlab(object), object); } @@ -942,7 +923,7 @@ T(Reserve(cache, objectCount, flags)); - BenaphoreLocker _(cache->lock); + MutexLocker _(cache->lock); return object_cache_reserve_internal(cache, objectCount, flags); } @@ -1477,8 +1458,7 @@ object_cache *cache = (object_cache *)strtoul(argv[1], NULL, 16); kprintf("name: %s\n", cache->name); - kprintf("lock: { count: %ld, sem: %ld }\n", cache->lock.count, - cache->lock.sem); + kprintf("lock: %p\n", &cache->lock); kprintf("object_size: %lu\n", cache->object_size); kprintf("cache_color_cycle: %lu\n", cache->cache_color_cycle); kprintf("used_count: %lu\n", cache->used_count); @@ -1518,9 +1498,7 @@ void slab_init_post_sem() { - status_t status = benaphore_init(&sObjectCacheListLock, "object cache list"); - if (status < B_OK) - panic("slab_init: failed to create object cache list lock"); + mutex_init(&sObjectCacheListLock, "object cache list"); ObjectCacheList::Iterator it = sObjectCaches.GetIterator(); From superstippi at gmx.de Thu May 8 18:19:38 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 08 May 2008 18:19:38 +0200 Subject: [Haiku-commits] r25380 - haiku/trunk/src/system/kernel/slab In-Reply-To: <200805081606.m48G6pGm029112@sheep.berlios.de> References: <200805081606.m48G6pGm029112@sheep.berlios.de> Message-ID: <20080508181938.6720.6@stippis2.1210243288.fake> axeld at BerliOS wrote: > @@ -636,10 +621,6 @@ > static status_t > object_cache_init_locks(object_cache *cache) > { > - status_t status = benaphore_init(&cache->lock, cache->name); > - if (status < B_OK) > - return status; > - Here it disappeared completely, was this intended? Best regards, -Stephan From revol at free.fr Thu May 8 18:23:46 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 08 May 2008 18:23:46 +0200 CEST Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <200805081552.m48FqSE1027683@sheep.berlios.de> Message-ID: <1044001002-BeMail@laptop> > Author: axeld > Date: 2008-05-08 17:52:27 +0200 (Thu, 08 May 2008) > New Revision: 25378 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25378&view=rev > > Modified: > haiku/trunk/src/system/kernel/cache/block_cache.cpp > haiku/trunk/src/system/kernel/fs/fifo.cpp > haiku/trunk/src/system/kernel/fs/vfs.cpp > Log: > Replaced benaphores with mutexes. > How about butex ? Just don't scratch a match :D Fran?ois. From axeld at mail.berlios.de Thu May 8 18:44:01 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 18:44:01 +0200 Subject: [Haiku-commits] r25381 - haiku/trunk/headers/private/kernel/util Message-ID: <200805081644.m48Gi1P8020589@sheep.berlios.de> Author: axeld Date: 2008-05-08 18:43:59 +0200 (Thu, 08 May 2008) New Revision: 25381 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25381&view=rev Modified: haiku/trunk/headers/private/kernel/util/Stack.h Log: Added a StackDeleter class that also empties the stack and deletes the items. Modified: haiku/trunk/headers/private/kernel/util/Stack.h =================================================================== --- haiku/trunk/headers/private/kernel/util/Stack.h 2008-05-08 16:06:51 UTC (rev 25380) +++ haiku/trunk/headers/private/kernel/util/Stack.h 2008-05-08 16:43:59 UTC (rev 25381) @@ -1,12 +1,13 @@ -/* Stack - a template stack class (plus some handy methods) - * - * Copyright 2001-2005, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2001-2008, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef KERNEL_UTIL_STACK_H #define KERNEL_UTIL_STACK_H +#include + #include @@ -75,4 +76,33 @@ int32 fMax; }; +template class StackDeleter { +public: + StackDeleter(Stack* stack) + : fStack(stack) + { + } + + ~StackDeleter() + { + if (fStack == NULL) + return; + + T item; + while (fStack->Pop(&item)) { + delete item; + } + + delete fStack; + } + + void Detach() + { + fStack = NULL; + } + +private: + Stack* fStack; +}; + #endif /* KERNEL_UTIL_STACK_H */ From axeld at mail.berlios.de Thu May 8 18:45:29 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 18:45:29 +0200 Subject: [Haiku-commits] r25382 - in haiku/trunk: headers/private/kernel/fs src/system/kernel/fs Message-ID: <200805081645.m48GjTeR022616@sheep.berlios.de> Author: axeld Date: 2008-05-08 18:45:29 +0200 (Thu, 08 May 2008) New Revision: 25382 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25382&view=rev Modified: haiku/trunk/headers/private/kernel/fs/KPath.h haiku/trunk/src/system/kernel/fs/KPath.cpp Log: * Added Adopt() method that steals the other path's buffer. * Fixed operator=(): the second argument of SetTo() is a boolean (normalize), not the length of the buffer. Modified: haiku/trunk/headers/private/kernel/fs/KPath.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/KPath.h 2008-05-08 16:43:59 UTC (rev 25381) +++ haiku/trunk/headers/private/kernel/fs/KPath.h 2008-05-08 16:45:29 UTC (rev 25382) @@ -22,6 +22,7 @@ status_t SetTo(const char *path, bool normalize = false, size_t bufferSize = B_PATH_NAME_LENGTH); + void Adopt(KPath& other); status_t InitCheck() const; Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-08 16:43:59 UTC (rev 25381) +++ haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-08 16:45:29 UTC (rev 25382) @@ -86,6 +86,18 @@ } +void +KPath::Adopt(KPath& other) +{ + free(fBuffer); + + fBuffer = other.fBuffer; + fBufferSize = other.fBufferSize; + + other.fBuffer = NULL; +} + + status_t KPath::InitCheck() const { @@ -257,7 +269,7 @@ KPath& KPath::operator=(const KPath& other) { - SetTo(other.fBuffer, other.fBufferSize); + SetTo(other.fBuffer, false, other.fBufferSize); return *this; } From axeld at mail.berlios.de Thu May 8 18:48:17 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 8 May 2008 18:48:17 +0200 Subject: [Haiku-commits] r25383 - haiku/trunk/src/tests/system/kernel/device_manager/playground Message-ID: <200805081648.m48GmHK9025422@sheep.berlios.de> Author: axeld Date: 2008-05-08 18:48:14 +0200 (Thu, 08 May 2008) New Revision: 25383 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25383&view=rev Added: haiku/trunk/src/tests/system/kernel/device_manager/playground/KPath.cpp Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp Log: * Rewrote how the dynamic drivers are registered, and made it a bit more flexible; now, a driver type can result in any number of paths to probe. * Also, the "bus" modules (busses/bus_managers) are now always probed - that's only a temporary solution and should be restricted to certain driver types later. * Added a userland buildable version of KPath. Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile 2008-05-08 16:45:29 UTC (rev 25382) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile 2008-05-08 16:48:14 UTC (rev 25383) @@ -8,10 +8,10 @@ SimpleTest device_manager : device_manager.cpp + KPath.cpp bus.cpp driver.cpp : be libkernelland_emu.so ; - Added: haiku/trunk/src/tests/system/kernel/device_manager/playground/KPath.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/KPath.cpp 2008-05-08 16:45:29 UTC (rev 25382) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/KPath.cpp 2008-05-08 16:48:14 UTC (rev 25383) @@ -0,0 +1,330 @@ +/* + * Copyright 2004-2006, Ingo Weinhold, bonefish at users.sf.net. + * Distributed under the terms of the MIT License. + */ + +/** A simple class wrapping a path. Has a fixed-sized buffer. */ + +#include + +#include +#include + +#include + + +// debugging +#define TRACE(x) ; +//#define TRACE(x) dprintf x + + +KPath::KPath(size_t bufferSize) + : + fBuffer(NULL), + fBufferSize(0), + fPathLength(0), + fLocked(false) +{ + SetTo(NULL, false, bufferSize); +} + + +KPath::KPath(const char* path, bool normalize, size_t bufferSize) + : + fBuffer(NULL), + fBufferSize(0), + fPathLength(0), + fLocked(false) +{ + SetTo(path, normalize, bufferSize); +} + + +KPath::KPath(const KPath& other) + : + fBuffer(NULL), + fBufferSize(0), + fPathLength(0), + fLocked(false) +{ + *this = other; +} + + +KPath::~KPath() +{ + free(fBuffer); +} + + +status_t +KPath::SetTo(const char* path, bool normalize, size_t bufferSize) +{ + if (bufferSize == 0) + bufferSize = B_PATH_NAME_LENGTH; + + // free the previous buffer, if the buffer size differs + if (fBuffer && fBufferSize != bufferSize) { + free(fBuffer); + fBuffer = NULL; + fBufferSize = 0; + } + fPathLength = 0; + fLocked = false; + + // allocate buffer + if (!fBuffer) + fBuffer = (char*)malloc(bufferSize); + if (!fBuffer) + return B_NO_MEMORY; + if (fBuffer) { + fBufferSize = bufferSize; + fBuffer[0] = '\0'; + } + return SetPath(path, normalize); +} + + +void +KPath::Adopt(KPath& other) +{ + free(fBuffer); + + fBuffer = other.fBuffer; + fBufferSize = other.fBufferSize; + + other.fBuffer = NULL; +} + + +status_t +KPath::InitCheck() const +{ + return fBuffer ? B_OK : B_NO_MEMORY; +} + + +status_t +KPath::SetPath(const char *path, bool normalize) +{ + if (!fBuffer) + return B_NO_INIT; + + if (path) { + if (normalize) { + // normalize path + BPath normalizedPath; + status_t error = normalizedPath.SetTo(path, NULL, true); + if (error != B_OK) { + SetPath(NULL); + return error; + } + + strlcpy(fBuffer, normalizedPath.Path(), fBufferSize); + fPathLength = strlen(fBuffer); + } else { + // don't normalize path + size_t length = strlen(path); + if (length >= fBufferSize) + return B_BUFFER_OVERFLOW; + + memcpy(fBuffer, path, length + 1); + fPathLength = length; + _ChopTrailingSlashes(); + } + } else { + fBuffer[0] = '\0'; + fPathLength = 0; + } + return B_OK; +} + + +const char* +KPath::Path() const +{ + return fBuffer; +} + + +char * +KPath::LockBuffer() +{ + if (!fBuffer || fLocked) + return NULL; + + fLocked = true; + return fBuffer; +} + + +void +KPath::UnlockBuffer() +{ + if (!fLocked) { + TRACE(("KPath::UnlockBuffer(): ERROR: Buffer not locked!\n")); + return; + } + fLocked = false; + fPathLength = strnlen(fBuffer, fBufferSize); + if (fPathLength == fBufferSize) { + TRACE(("KPath::UnlockBuffer(): WARNING: Unterminated buffer!\n")); + fPathLength--; + fBuffer[fPathLength] = '\0'; + } + _ChopTrailingSlashes(); +} + + +const char * +KPath::Leaf() const +{ + if (!fBuffer) + return NULL; + + // only "/" has trailing slashes -- then we have to return the complete + // buffer, as we have to do in case there are no slashes at all + if (fPathLength != 1 || fBuffer[0] != '/') { + for (int32 i = fPathLength - 1; i >= 0; i--) { + if (fBuffer[i] == '/') + return fBuffer + i + 1; + } + } + return fBuffer; +} + + +status_t +KPath::ReplaceLeaf(const char *newLeaf) +{ + const char *leaf = Leaf(); + if (!leaf) + return B_NO_INIT; + + int32 leafIndex = leaf - fBuffer; + // chop off the current leaf (don't replace "/", though) + if (leafIndex != 0 || fBuffer[leafIndex - 1]) { + fBuffer[leafIndex] = '\0'; + fPathLength = leafIndex; + _ChopTrailingSlashes(); + } + + // if a leaf was given, append it + if (newLeaf) + return Append(newLeaf); + return B_OK; +} + + +bool +KPath::RemoveLeaf() +{ + // get the leaf -- bail out, if not initialized or only the "/" is left + const char *leaf = Leaf(); + if (!leaf || leaf == fBuffer) + return false; + + // chop off the leaf + int32 leafIndex = leaf - fBuffer; + fBuffer[leafIndex] = '\0'; + fPathLength = leafIndex; + _ChopTrailingSlashes(); + + return true; +} + + +status_t +KPath::Append(const char *component, bool isComponent) +{ + // check initialization and parameter + if (!fBuffer) + return B_NO_INIT; + if (!component) + return B_BAD_VALUE; + if (fPathLength == 0) + return SetPath(component); + + // get component length + size_t componentLength = strlen(component); + if (componentLength < 1) + return B_OK; + + // if our current path is empty, we just copy the supplied one + // compute the result path len + bool insertSlash = isComponent && fBuffer[fPathLength - 1] != '/' + && component[0] != '/'; + size_t resultPathLength = fPathLength + componentLength + (insertSlash ? 1 : 0); + if (resultPathLength >= fBufferSize) + return B_BUFFER_OVERFLOW; + + // compose the result path + if (insertSlash) + fBuffer[fPathLength++] = '/'; + memcpy(fBuffer + fPathLength, component, componentLength + 1); + fPathLength = resultPathLength; + return B_OK; +} + + +KPath& +KPath::operator=(const KPath& other) +{ + SetTo(other.fBuffer, other.fBufferSize); + return *this; +} + + +KPath& +KPath::operator=(const char* path) +{ + SetTo(path); + return *this; +} + + +bool +KPath::operator==(const KPath& other) const +{ + if (!fBuffer) + return !other.fBuffer; + + return (other.fBuffer + && fPathLength == other.fPathLength + && strcmp(fBuffer, other.fBuffer) == 0); +} + + +bool +KPath::operator==(const char* path) const +{ + if (!fBuffer) + return (!path); + + return path && !strcmp(fBuffer, path); +} + + +bool +KPath::operator!=(const KPath& other) const +{ + return !(*this == other); +} + + +bool +KPath::operator!=(const char* path) const +{ + return !(*this == path); +} + + +void +KPath::_ChopTrailingSlashes() +{ + if (fBuffer) { + while (fPathLength > 1 && fBuffer[fPathLength - 1] == '/') + fBuffer[--fPathLength] = '\0'; + } +} + Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-08 16:45:29 UTC (rev 25382) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-08 16:48:14 UTC (rev 25383) @@ -6,20 +6,22 @@ #include "device_manager.h" -#include -#include - -#include -#include -#include - #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include + + #define TRACE(a) dprintf a #define DEVICE_MANAGER_ROOT_NAME "system/devices_root/driver_v1" @@ -107,6 +109,13 @@ private: status_t _RegisterFixed(uint32& registered); + status_t _GetNextDriverPath(void*& cookie, KPath& _path); + status_t _GetNextDriver(void* list, + driver_module_info*& driver); + status_t _FindBestDriver(const char* path, + driver_module_info*& bestDriver, + float& bestSupport); + status_t _RegisterPath(const char* path); status_t _RegisterDynamic(); bool _IsBus() const; @@ -123,12 +132,14 @@ AttributeList fAttributes; }; - device_manager_info *gDeviceManager; static device_node *sRootNode; +// #pragma mark - device_attr + + device_attr_private::device_attr_private() { name = NULL; @@ -355,7 +366,7 @@ } -// #pragma mark - +// #pragma mark - device_node /*! Allocate device node info structure; @@ -551,77 +562,182 @@ status_t -device_node::_RegisterDynamic() +device_node::_GetNextDriverPath(void*& cookie, KPath& _path) { - uint32 findFlags; - if (dm_get_attr_uint32(this, B_DRIVER_FIND_CHILD_FLAGS, &findFlags, false) - != B_OK) - findFlags = 0; + Stack* stack = NULL; - driver_module_info* bestDriver = NULL; - float best = 0.0; + if (cookie == NULL) { + // find all paths and add them + stack = new(std::nothrow) Stack(); + if (stack == NULL) + return B_NO_MEMORY; - char path[64]; - if (!_IsBus()) { - strlcpy(path, "drivers", sizeof(path)); + StackDeleter stackDeleter(stack); - const char *type; - if (dm_get_attr_string(this, B_DRIVER_DEVICE_TYPE, &type, false) - == B_OK) { - strlcat(path, "/", sizeof(path)); - strlcat(path, type, sizeof(path)); + if (!_IsBus()) { + // add driver paths + KPath* path = new(std::nothrow) KPath; + if (path == NULL) + return B_NO_MEMORY; + + status_t status = path->SetTo("drivers"); + if (status != B_OK) { + delete path; + return status; + } + + // TODO: this might be more than one path! + const char *type; + if (dm_get_attr_string(this, B_DRIVER_DEVICE_TYPE, &type, false) + == B_OK) + path->Append(type); + + stack->Push(path); } - } else { - // TODO: we might want to allow bus* specifiers as well, ie. - // busses/usb - strlcpy(path, "bus", sizeof(path)); + + // add bus paths + KPath* path = new(std::nothrow) KPath; + if (path == NULL) + return B_NO_MEMORY; + + status_t status = path->SetTo("bus"); + if (status != B_OK) { + delete path; + return status; + } + + stack->Push(path); + stackDeleter.Detach(); + + cookie = (void*)stack; + } else + stack = static_cast*>(cookie); + + KPath* path; + if (stack->Pop(&path)) { + _path.Adopt(*path); + delete path; + return B_OK; } - void* list = open_module_list_etc(path, "driver_v1"); + delete stack; + return B_ENTRY_NOT_FOUND; +} + + +status_t +device_node::_GetNextDriver(void* list, driver_module_info*& driver) +{ while (true) { char name[B_FILE_NAME_LENGTH]; size_t nameLength = sizeof(name); - if (read_next_module_name(list, name, &nameLength) != B_OK) - break; + status_t status = read_next_module_name(list, name, &nameLength); + if (status != B_OK) + return status; if (!strcmp(fModuleName, name)) continue; - driver_module_info* driver; if (get_module(name, (module_info**)&driver) != B_OK) continue; - if (driver->supports_device != NULL - && driver->register_device != NULL) { - float support = driver->supports_device(this); + if (driver->supports_device == NULL + || driver->register_device == NULL) { + put_module(name); + continue; + } - if ((findFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { - if (support > best) { - if (bestDriver != NULL) - put_module(bestDriver->info.name); + return B_OK; + } +} - bestDriver = driver; - best = support; - continue; - // keep reference to best module around - } - } else if (support > 0.0) { -printf(" register module \"%s\", support %f\n", name, support); - driver->register_device(this); - } + +status_t +device_node::_FindBestDriver(const char* path, driver_module_info*& bestDriver, + float& bestSupport) +{ + if (bestDriver == NULL) + bestSupport = 0.0f; + + void* list = open_module_list_etc(path, "driver_v1"); + driver_module_info* driver; + while (_GetNextDriver(list, driver) == B_OK) { + float support = driver->supports_device(this); + if (support > bestSupport) { + if (bestDriver != NULL) + put_module(bestDriver->info.name); + + bestDriver = driver; + bestSupport = support; + continue; + // keep reference to best module around } - put_module(name); + put_module(driver->info.name); } close_module_list(list); - if (bestDriver != NULL) { -printf(" register best module \"%s\", support %f\n", bestDriver->info.name, best); - bestDriver->register_device(this); - put_module(bestDriver->info.name); + return bestDriver != NULL ? B_OK : B_ENTRY_NOT_FOUND; +} + + +status_t +device_node::_RegisterPath(const char* path) +{ + void* list = open_module_list_etc(path, "driver_v1"); + driver_module_info* driver; + uint32 count = 0; + + while (_GetNextDriver(list, driver) == B_OK) { + float support = driver->supports_device(this); + if (support > 0.0) { +printf(" register module \"%s\", support %f\n", driver->info.name, support); + if (driver->register_device(this) == B_OK) + count++; + } + + put_module(driver->info.name); } - + close_module_list(list); + + return count > 0 ? B_OK : B_ENTRY_NOT_FOUND; +} + + +status_t +device_node::_RegisterDynamic() +{ + uint32 findFlags; + if (dm_get_attr_uint32(this, B_DRIVER_FIND_CHILD_FLAGS, &findFlags, false) + != B_OK) + findFlags = 0; + + KPath path; + + if ((findFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { + // find the one driver + driver_module_info* bestDriver = NULL; + float bestSupport = 0.0; + void* cookie = NULL; + + while (_GetNextDriverPath(cookie, path) == B_OK) { + _FindBestDriver(path.Path(), bestDriver, bestSupport); + } + + if (bestDriver != NULL) { +printf(" register best module \"%s\", support %f\n", bestDriver->info.name, bestSupport); + bestDriver->register_device(this); + put_module(bestDriver->info.name); + } + } else { + // register all drivers that match + void* cookie = NULL; + while (_GetNextDriverPath(cookie, path) == B_OK) { + _RegisterPath(path.Path()); + } + } + return B_OK; } From axeld at pinc-software.de Thu May 8 18:51:07 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 18:51:07 +0200 CEST Subject: [Haiku-commits] r25380 - haiku/trunk/src/system/kernel/slab In-Reply-To: <20080508181938.6720.6@stippis2.1210243288.fake> Message-ID: <34054789869-BeMail@zon> Stephan Assmus wrote: > axeld at BerliOS wrote: > > @@ -636,10 +621,6 @@ > > static status_t > > object_cache_init_locks(object_cache *cache) > > { > > - status_t status = benaphore_init(&cache->lock, cache->name); > > - if (status < B_OK) > > - return status; > Here it disappeared completely, was this intended? Thanks for looking over it! But actually yes, that was intended :-) It's only called from slab_init_post_sem(), and mutexes can and will now be created earlier (they no longer depend on the semaphore mechanism). Bye, Axel. From axeld at pinc-software.de Thu May 8 18:52:13 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 18:52:13 +0200 CEST Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <1044001002-BeMail@laptop> Message-ID: <34120412941-BeMail@zon> "Fran?ois Revol" wrote: > How about butex ? > Just don't scratch a match :D Our mutexes work like benaphores, too; it's only a name, anyway. And even if they go away in the kernel, benaphores are still useful and will stay in userland :-) Bye, Axel. From anevilyak at gmail.com Thu May 8 18:59:41 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 8 May 2008 11:59:41 -0500 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <34120412941-BeMail@zon> References: <1044001002-BeMail@laptop> <34120412941-BeMail@zon> Message-ID: On Thu, May 8, 2008 at 11:52 AM, Axel D?rfler wrote: > Our mutexes work like benaphores, too; it's only a name, anyway. And > even if they go away in the kernel, benaphores are still useful and > will stay in userland :-) > Do they? I thought mutexes aren't count-based like semaphore/benaphores are. Regards, Rene From bga at bug-br.org.br Thu May 8 19:24:30 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 08 May 2008 14:24:30 -0300 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: References: <1044001002-BeMail@laptop> <34120412941-BeMail@zon> Message-ID: <4823374E.8010801@bug-br.org.br> Rene Gollent wrote: >> Our mutexes work like benaphores, too; it's only a name, anyway. And >> even if they go away in the kernel, benaphores are still useful and >> will stay in userland :-) > > Do they? I thought mutexes aren't count-based like semaphore/benaphores are. That's actually a very good point. The formal definition of mutexes x semaphores is that mutexes have no count while semaphores do have them. Did we started changing semantics or am I missing something? :) -Bruno From axeld at pinc-software.de Thu May 8 19:31:19 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 19:31:19 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25378_-_in_haiku/trunk/src/system/kern?= =?utf-8?q?el=3A_cache_fs?= In-Reply-To: Message-ID: <36466079151-BeMail@zon> "Rene Gollent" wrote: > On Thu, May 8, 2008 at 11:52 AM, Axel D?rfler > wrote: > > Our mutexes work like benaphores, too; it's only a name, anyway. > > And > > even if they go away in the kernel, benaphores are still useful > > and > > will stay in userland :-) > Do they? I thought mutexes aren't count-based like semaphore/ > benaphores are. Well, have a look at the implementation :-) Benaphores are just like mutexes - just because one can implement almost everything using semaphores, it doesn't mean it's the same thing. Bye, Axel. From anevilyak at gmail.com Thu May 8 19:34:21 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 8 May 2008 12:34:21 -0500 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <36466079151-BeMail@zon> References: <36466079151-BeMail@zon> Message-ID: On Thu, May 8, 2008 at 12:31 PM, Axel D?rfler wrote: > Well, have a look at the implementation :-) > Benaphores are just like mutexes - just because one can implement > almost everything using semaphores, it doesn't mean it's the same > thing. > I thought benaphores just used an atomic counter to avoid having to make a trip to the kernel unless blocking would occur? Or have they changed since? Regards, Rene From superstippi at gmx.de Thu May 8 20:03:45 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 08 May 2008 20:03:45 +0200 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <200805081552.m48FqSE1027683@sheep.berlios.de> References: <200805081552.m48FqSE1027683@sheep.berlios.de> Message-ID: <20080508200345.7890.8@stippis2.1210243288.fake> axeld at BerliOS wrote: > Author: axeld > Date: 2008-05-08 17:52:27 +0200 (Thu, 08 May 2008) New Revision: 25378 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25378&view=rev > > Modified: > haiku/trunk/src/system/kernel/cache/block_cache.cpp > haiku/trunk/src/system/kernel/fs/fifo.cpp > haiku/trunk/src/system/kernel/fs/vfs.cpp > Log: > Replaced benaphores with mutexes. BTW, I kept doing the same test before and after more of these changes. I have a local copy of source code here with some changes. I timed svn diff, always from a fresh boot: Before semaphore changes: real 1m5.171s user 0m2.517s sys 0m0.989s After initial semaphore changes: real 1m9.361s user 0m2.388s sys 0m0.959s After more mutex changes (25378): real 0m57.888s user 0m2.330s sys 0m0.913s So it seems to pay off. :-) Best regards, -Stephan From anevilyak at gmail.com Thu May 8 20:10:31 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 8 May 2008 13:10:31 -0500 Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <36466079151-BeMail@zon> References: <36466079151-BeMail@zon> Message-ID: On Thu, May 8, 2008 at 12:31 PM, Axel D?rfler wrote: > Well, have a look at the implementation :-) > Benaphores are just like mutexes - just because one can implement > almost everything using semaphores, it doesn't mean it's the same > thing. > Never mind, I understand now. Regards, Rene From ingo_weinhold at gmx.de Thu May 8 21:41:00 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 08 May 2008 21:41:00 +0200 Subject: [Haiku-commits] r25381 - haiku/trunk/headers/private/kernel/util In-Reply-To: <200805081644.m48Gi1P8020589@sheep.berlios.de> References: <200805081644.m48Gi1P8020589@sheep.berlios.de> Message-ID: <20080508214100.452.1@knochen-vm.1210274936.fake> On 2008-05-08 at 18:44:01 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2008-05-08 18:43:59 +0200 (Thu, 08 May 2008) > New Revision: 25381 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25381&view=rev > > Modified: > haiku/trunk/headers/private/kernel/util/Stack.h > Log: > Added a StackDeleter class that also empties the stack and deletes the > items. How about using an AutoDeleter specialization in such a case? Would be less code and you get the additional methods (Detach(), SetTo(), Unset()) for free. CU, Ingo From bonefish at mail.berlios.de Thu May 8 22:50:18 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 22:50:18 +0200 Subject: [Haiku-commits] r25384 - in haiku/trunk/src: apps/sudoku preferences/print servers/media_addon Message-ID: <200805082050.m48KoITm011922@sheep.berlios.de> Author: bonefish Date: 2008-05-08 22:50:17 +0200 (Thu, 08 May 2008) New Revision: 25384 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25384&view=rev Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/preferences/print/AddPrinterDialog.cpp haiku/trunk/src/servers/media_addon/main.cpp Log: Cast B_OK to (uint32) to solve an overloading ambiguity (I don't agree with the compiler, though :-)), I'm about to introduce. Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-05-08 16:48:14 UTC (rev 25383) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2008-05-08 20:50:17 UTC (rev 25384) @@ -411,7 +411,7 @@ delete view; bitmap->Unlock(); } - BMessage msg(B_OK); + BMessage msg((uint32)B_OK); status = bitmap->Archive(&msg); if (status >= B_OK) { status = msg.Flatten(&stream); Modified: haiku/trunk/src/preferences/print/AddPrinterDialog.cpp =================================================================== --- haiku/trunk/src/preferences/print/AddPrinterDialog.cpp 2008-05-08 16:48:14 UTC (rev 25383) +++ haiku/trunk/src/preferences/print/AddPrinterDialog.cpp 2008-05-08 20:50:17 UTC (rev 25384) @@ -233,7 +233,8 @@ transportMenuField->SetDivider(divider); // add a "OK" button, and make it default - fOk = new BButton(r, NULL, "Add", new BMessage(B_OK), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); + fOk = new BButton(r, NULL, "Add", new BMessage((uint32)B_OK), + B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fOk->ResizeToPreferred(); fOk->GetPreferredSize(&w, &h); // put the ok bottom at bottom right corner Modified: haiku/trunk/src/servers/media_addon/main.cpp =================================================================== --- haiku/trunk/src/servers/media_addon/main.cpp 2008-05-08 16:48:14 UTC (rev 25383) +++ haiku/trunk/src/servers/media_addon/main.cpp 2008-05-08 20:50:17 UTC (rev 25384) @@ -689,7 +689,8 @@ } PlayMediaFile(type, name); - msg->SendReply(B_OK); // XXX don't know which reply is expected + msg->SendReply((uint32)B_OK); + // XXX don't know which reply is expected return; } From bonefish at mail.berlios.de Thu May 8 22:54:15 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 8 May 2008 22:54:15 +0200 Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support Message-ID: <200805082054.m48KsFLJ012454@sheep.berlios.de> Author: bonefish Date: 2008-05-08 22:54:14 +0200 (Thu, 08 May 2008) New Revision: 25385 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25385&view=rev Modified: haiku/trunk/headers/os/support/Errors.h Log: Changed all error codes from enum values to macros. This allows for compile time checks. Incidently those are not totally uncommon in portable code. Modified: haiku/trunk/headers/os/support/Errors.h =================================================================== --- haiku/trunk/headers/os/support/Errors.h 2008-05-08 20:50:17 UTC (rev 25384) +++ haiku/trunk/headers/os/support/Errors.h 2008-05-08 20:54:14 UTC (rev 25385) @@ -11,112 +11,107 @@ /* Error baselines */ #define B_GENERAL_ERROR_BASE LONG_MIN -#define B_OS_ERROR_BASE B_GENERAL_ERROR_BASE + 0x1000 -#define B_APP_ERROR_BASE B_GENERAL_ERROR_BASE + 0x2000 -#define B_INTERFACE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x3000 -#define B_MEDIA_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4000 /* - 0x41ff */ -#define B_TRANSLATION_ERROR_BASE B_GENERAL_ERROR_BASE + 0x4800 /* - 0x48ff */ -#define B_MIDI_ERROR_BASE B_GENERAL_ERROR_BASE + 0x5000 -#define B_STORAGE_ERROR_BASE B_GENERAL_ERROR_BASE + 0x6000 -#define B_POSIX_ERROR_BASE B_GENERAL_ERROR_BASE + 0x7000 -#define B_MAIL_ERROR_BASE B_GENERAL_ERROR_BASE + 0x8000 -#define B_PRINT_ERROR_BASE B_GENERAL_ERROR_BASE + 0x9000 -#define B_DEVICE_ERROR_BASE B_GENERAL_ERROR_BASE + 0xa000 +#define B_OS_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x1000) +#define B_APP_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x2000) +#define B_INTERFACE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x3000) +#define B_MEDIA_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x4000) + /* - 0x41ff */ +#define B_TRANSLATION_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x4800) + /* - 0x48ff */ +#define B_MIDI_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x5000) +#define B_STORAGE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x6000) +#define B_POSIX_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x7000) +#define B_MAIL_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x8000) +#define B_PRINT_ERROR_BASE (B_GENERAL_ERROR_BASE + 0x9000) +#define B_DEVICE_ERROR_BASE (B_GENERAL_ERROR_BASE + 0xa000) /* Developer-defined errors start at (B_ERRORS_END+1) */ -#define B_ERRORS_END (B_GENERAL_ERROR_BASE + 0xffff) +#define B_ERRORS_END (B_GENERAL_ERROR_BASE + 0xffff) /* General Errors */ -enum { - B_NO_MEMORY = B_GENERAL_ERROR_BASE, - B_IO_ERROR, - B_PERMISSION_DENIED, - B_BAD_INDEX, - B_BAD_TYPE, - B_BAD_VALUE, - B_MISMATCHED_VALUES, - B_NAME_NOT_FOUND, - B_NAME_IN_USE, - B_TIMED_OUT, - B_INTERRUPTED, - B_WOULD_BLOCK, - B_CANCELED, - B_NO_INIT, - B_BUSY, - B_NOT_ALLOWED, - B_BAD_DATA, - B_DONT_DO_THAT, +#define B_NO_MEMORY (B_GENERAL_ERROR_BASE + 0) +#define B_IO_ERROR (B_GENERAL_ERROR_BASE + 1) +#define B_PERMISSION_DENIED (B_GENERAL_ERROR_BASE + 2) +#define B_BAD_INDEX (B_GENERAL_ERROR_BASE + 3) +#define B_BAD_TYPE (B_GENERAL_ERROR_BASE + 4) +#define B_BAD_VALUE (B_GENERAL_ERROR_BASE + 5) +#define B_MISMATCHED_VALUES (B_GENERAL_ERROR_BASE + 6) +#define B_NAME_NOT_FOUND (B_GENERAL_ERROR_BASE + 7) +#define B_NAME_IN_USE (B_GENERAL_ERROR_BASE + 8) +#define B_TIMED_OUT (B_GENERAL_ERROR_BASE + 9) +#define B_INTERRUPTED (B_GENERAL_ERROR_BASE + 10) +#define B_WOULD_BLOCK (B_GENERAL_ERROR_BASE + 11) +#define B_CANCELED (B_GENERAL_ERROR_BASE + 12) +#define B_NO_INIT (B_GENERAL_ERROR_BASE + 13) +#define B_BUSY (B_GENERAL_ERROR_BASE + 14) +#define B_NOT_ALLOWED (B_GENERAL_ERROR_BASE + 15) +#define B_BAD_DATA (B_GENERAL_ERROR_BASE + 16) +#define B_DONT_DO_THAT (B_GENERAL_ERROR_BASE + 17) - B_ERROR = -1, - B_OK = 0, - B_NO_ERROR = 0 -}; +#define B_ERROR (-1) +#define B_OK ((int)0) +#define B_NO_ERROR ((int)0) /* Kernel Kit Errors */ -enum { - B_BAD_SEM_ID = B_OS_ERROR_BASE, - B_NO_MORE_SEMS, +#define B_BAD_SEM_ID (B_OS_ERROR_BASE + 0) +#define B_NO_MORE_SEMS (B_OS_ERROR_BASE + 1) - B_BAD_THREAD_ID = B_OS_ERROR_BASE + 0x100, - B_NO_MORE_THREADS, - B_BAD_THREAD_STATE, - B_BAD_TEAM_ID, - B_NO_MORE_TEAMS, +#define B_BAD_THREAD_ID (B_OS_ERROR_BASE + 0x100) +#define B_NO_MORE_THREADS (B_OS_ERROR_BASE + 0x101) +#define B_BAD_THREAD_STATE (B_OS_ERROR_BASE + 0x102) +#define B_BAD_TEAM_ID (B_OS_ERROR_BASE + 0x103) +#define B_NO_MORE_TEAMS (B_OS_ERROR_BASE + 0x104) - B_BAD_PORT_ID = B_OS_ERROR_BASE + 0x200, - B_NO_MORE_PORTS, +#define B_BAD_PORT_ID (B_OS_ERROR_BASE + 0x200) +#define B_NO_MORE_PORTS (B_OS_ERROR_BASE + 0x201) - B_BAD_IMAGE_ID = B_OS_ERROR_BASE + 0x300, - B_BAD_ADDRESS, - B_NOT_AN_EXECUTABLE, - B_MISSING_LIBRARY, - B_MISSING_SYMBOL, +#define B_BAD_IMAGE_ID (B_OS_ERROR_BASE + 0x300) +#define B_BAD_ADDRESS (B_OS_ERROR_BASE + 0x301) +#define B_NOT_AN_EXECUTABLE (B_OS_ERROR_BASE + 0x302) +#define B_MISSING_LIBRARY (B_OS_ERROR_BASE + 0x303) +#define B_MISSING_SYMBOL (B_OS_ERROR_BASE + 0x304) - B_DEBUGGER_ALREADY_INSTALLED = B_OS_ERROR_BASE + 0x400 -}; +#define B_DEBUGGER_ALREADY_INSTALLED (B_OS_ERROR_BASE + 0x400) /* Application Kit Errors */ -enum { - B_BAD_REPLY = B_APP_ERROR_BASE, - B_DUPLICATE_REPLY, - B_MESSAGE_TO_SELF, - B_BAD_HANDLER, - B_ALREADY_RUNNING, - B_LAUNCH_FAILED, - B_AMBIGUOUS_APP_LAUNCH, - B_UNKNOWN_MIME_TYPE, - B_BAD_SCRIPT_SYNTAX, - B_LAUNCH_FAILED_NO_RESOLVE_LINK, - B_LAUNCH_FAILED_EXECUTABLE, - B_LAUNCH_FAILED_APP_NOT_FOUND, - B_LAUNCH_FAILED_APP_IN_TRASH, - B_LAUNCH_FAILED_NO_PREFERRED_APP, - B_LAUNCH_FAILED_FILES_APP_NOT_FOUND, - B_BAD_MIME_SNIFFER_RULE, - B_NOT_A_MESSAGE, - B_SHUTDOWN_CANCELLED, - B_SHUTTING_DOWN -}; +#define B_BAD_REPLY (B_APP_ERROR_BASE + 0) +#define B_DUPLICATE_REPLY (B_APP_ERROR_BASE + 1) +#define B_MESSAGE_TO_SELF (B_APP_ERROR_BASE + 2) +#define B_BAD_HANDLER (B_APP_ERROR_BASE + 3) +#define B_ALREADY_RUNNING (B_APP_ERROR_BASE + 4) +#define B_LAUNCH_FAILED (B_APP_ERROR_BASE + 5) +#define B_AMBIGUOUS_APP_LAUNCH (B_APP_ERROR_BASE + 6) +#define B_UNKNOWN_MIME_TYPE (B_APP_ERROR_BASE + 7) +#define B_BAD_SCRIPT_SYNTAX (B_APP_ERROR_BASE + 8) +#define B_LAUNCH_FAILED_NO_RESOLVE_LINK (B_APP_ERROR_BASE + 9) +#define B_LAUNCH_FAILED_EXECUTABLE (B_APP_ERROR_BASE + 10) +#define B_LAUNCH_FAILED_APP_NOT_FOUND (B_APP_ERROR_BASE + 11) +#define B_LAUNCH_FAILED_APP_IN_TRASH (B_APP_ERROR_BASE + 12) +#define B_LAUNCH_FAILED_NO_PREFERRED_APP (B_APP_ERROR_BASE + 13) +#define B_LAUNCH_FAILED_FILES_APP_NOT_FOUND (B_APP_ERROR_BASE + 14) +#define B_BAD_MIME_SNIFFER_RULE (B_APP_ERROR_BASE + 15) +#define B_NOT_A_MESSAGE (B_APP_ERROR_BASE + 16) +#define B_SHUTDOWN_CANCELLED (B_APP_ERROR_BASE + 17) +#define B_SHUTTING_DOWN (B_APP_ERROR_BASE + 18) /* Storage Kit/File System Errors */ -enum { - B_FILE_ERROR = B_STORAGE_ERROR_BASE, - B_FILE_NOT_FOUND, /* deprecated: use B_ENTRY_NOT_FOUND instead */ - B_FILE_EXISTS, - B_ENTRY_NOT_FOUND, - B_NAME_TOO_LONG, - B_NOT_A_DIRECTORY, - B_DIRECTORY_NOT_EMPTY, - B_DEVICE_FULL, - B_READ_ONLY_DEVICE, - B_IS_A_DIRECTORY, - B_NO_MORE_FDS, - B_CROSS_DEVICE_LINK, - B_LINK_LIMIT, - B_BUSTED_PIPE, - B_UNSUPPORTED, - B_PARTITION_TOO_SMALL -}; +#define B_FILE_ERROR (B_STORAGE_ERROR_BASE + 0) +#define B_FILE_NOT_FOUND (B_STORAGE_ERROR_BASE + 1) + /* deprecated: use B_ENTRY_NOT_FOUND instead */ +#define B_FILE_EXISTS (B_STORAGE_ERROR_BASE + 2) +#define B_ENTRY_NOT_FOUND (B_STORAGE_ERROR_BASE + 3) +#define B_NAME_TOO_LONG (B_STORAGE_ERROR_BASE + 4) +#define B_NOT_A_DIRECTORY (B_STORAGE_ERROR_BASE + 5) +#define B_DIRECTORY_NOT_EMPTY (B_STORAGE_ERROR_BASE + 6) +#define B_DEVICE_FULL (B_STORAGE_ERROR_BASE + 7) +#define B_READ_ONLY_DEVICE (B_STORAGE_ERROR_BASE + 8) +#define B_IS_A_DIRECTORY (B_STORAGE_ERROR_BASE + 9) +#define B_NO_MORE_FDS (B_STORAGE_ERROR_BASE + 10) +#define B_CROSS_DEVICE_LINK (B_STORAGE_ERROR_BASE + 11) +#define B_LINK_LIMIT (B_STORAGE_ERROR_BASE + 12) +#define B_BUSTED_PIPE (B_STORAGE_ERROR_BASE + 13) +#define B_UNSUPPORTED (B_STORAGE_ERROR_BASE + 14) +#define B_PARTITION_TOO_SMALL (B_STORAGE_ERROR_BASE + 15) /* POSIX Errors */ #define E2BIG (B_POSIX_ERROR_BASE + 1) @@ -215,68 +210,60 @@ #define B_NOT_SUPPORTED EOPNOTSUPP /* Media Kit Errors */ -enum { - B_STREAM_NOT_FOUND = B_MEDIA_ERROR_BASE, - B_SERVER_NOT_FOUND, - B_RESOURCE_NOT_FOUND, - B_RESOURCE_UNAVAILABLE, - B_BAD_SUBSCRIBER, - B_SUBSCRIBER_NOT_ENTERED, - B_BUFFER_NOT_AVAILABLE, - B_LAST_BUFFER_ERROR -}; +#define B_STREAM_NOT_FOUND (B_MEDIA_ERROR_BASE + 0) +#define B_SERVER_NOT_FOUND (B_MEDIA_ERROR_BASE + 1) +#define B_RESOURCE_NOT_FOUND (B_MEDIA_ERROR_BASE + 2) +#define B_RESOURCE_UNAVAILABLE (B_MEDIA_ERROR_BASE + 3) +#define B_BAD_SUBSCRIBER (B_MEDIA_ERROR_BASE + 4) +#define B_SUBSCRIBER_NOT_ENTERED (B_MEDIA_ERROR_BASE + 5) +#define B_BUFFER_NOT_AVAILABLE (B_MEDIA_ERROR_BASE + 6) +#define B_LAST_BUFFER_ERROR (B_MEDIA_ERROR_BASE + 7) /* Mail Kit Errors */ -enum { - B_MAIL_NO_DAEMON = B_MAIL_ERROR_BASE, - B_MAIL_UNKNOWN_USER, - B_MAIL_WRONG_PASSWORD, - B_MAIL_UNKNOWN_HOST, - B_MAIL_ACCESS_ERROR, - B_MAIL_UNKNOWN_FIELD, - B_MAIL_NO_RECIPIENT, - B_MAIL_INVALID_MAIL -}; +#define B_MAIL_NO_DAEMON (B_MAIL_ERROR_BASE + 0) +#define B_MAIL_UNKNOWN_USER (B_MAIL_ERROR_BASE + 1) +#define B_MAIL_WRONG_PASSWORD (B_MAIL_ERROR_BASE + 2) +#define B_MAIL_UNKNOWN_HOST (B_MAIL_ERROR_BASE + 3) +#define B_MAIL_ACCESS_ERROR (B_MAIL_ERROR_BASE + 4) +#define B_MAIL_UNKNOWN_FIELD (B_MAIL_ERROR_BASE + 5) +#define B_MAIL_NO_RECIPIENT (B_MAIL_ERROR_BASE + 6) +#define B_MAIL_INVALID_MAIL (B_MAIL_ERROR_BASE + 7) /* Printing Errors */ -enum { - B_NO_PRINT_SERVER = B_PRINT_ERROR_BASE -}; +#define B_NO_PRINT_SERVER (B_PRINT_ERROR_BASE + 0) /* Device Kit Errors */ -enum { - B_DEV_INVALID_IOCTL = B_DEVICE_ERROR_BASE, - B_DEV_NO_MEMORY, - B_DEV_BAD_DRIVE_NUM, - B_DEV_NO_MEDIA, - B_DEV_UNREADABLE, - B_DEV_FORMAT_ERROR, - B_DEV_TIMEOUT, - B_DEV_RECALIBRATE_ERROR, - B_DEV_SEEK_ERROR, - B_DEV_ID_ERROR, - B_DEV_READ_ERROR, - B_DEV_WRITE_ERROR, - B_DEV_NOT_READY, - B_DEV_MEDIA_CHANGED, - B_DEV_MEDIA_CHANGE_REQUESTED, - B_DEV_RESOURCE_CONFLICT, - B_DEV_CONFIGURATION_ERROR, - B_DEV_DISABLED_BY_USER, - B_DEV_DOOR_OPEN, +#define B_DEV_INVALID_IOCTL (B_DEVICE_ERROR_BASE + 0) +#define B_DEV_NO_MEMORY (B_DEVICE_ERROR_BASE + 1) +#define B_DEV_BAD_DRIVE_NUM (B_DEVICE_ERROR_BASE + 2) +#define B_DEV_NO_MEDIA (B_DEVICE_ERROR_BASE + 3) +#define B_DEV_UNREADABLE (B_DEVICE_ERROR_BASE + 4) +#define B_DEV_FORMAT_ERROR (B_DEVICE_ERROR_BASE + 5) +#define B_DEV_TIMEOUT (B_DEVICE_ERROR_BASE + 6) +#define B_DEV_RECALIBRATE_ERROR (B_DEVICE_ERROR_BASE + 7) +#define B_DEV_SEEK_ERROR (B_DEVICE_ERROR_BASE + 8) +#define B_DEV_ID_ERROR (B_DEVICE_ERROR_BASE + 9) +#define B_DEV_READ_ERROR (B_DEVICE_ERROR_BASE + 10) +#define B_DEV_WRITE_ERROR (B_DEVICE_ERROR_BASE + 11) +#define B_DEV_NOT_READY (B_DEVICE_ERROR_BASE + 12) +#define B_DEV_MEDIA_CHANGED (B_DEVICE_ERROR_BASE + 13) +#define B_DEV_MEDIA_CHANGE_REQUESTED (B_DEVICE_ERROR_BASE + 14) +#define B_DEV_RESOURCE_CONFLICT (B_DEVICE_ERROR_BASE + 15) +#define B_DEV_CONFIGURATION_ERROR (B_DEVICE_ERROR_BASE + 16) +#define B_DEV_DISABLED_BY_USER (B_DEVICE_ERROR_BASE + 17) +#define B_DEV_DOOR_OPEN (B_DEVICE_ERROR_BASE + 18) - B_DEV_INVALID_PIPE, - B_DEV_CRC_ERROR, - B_DEV_STALLED, - B_DEV_BAD_PID, - B_DEV_UNEXPECTED_PID, - B_DEV_DATA_OVERRUN, - B_DEV_DATA_UNDERRUN, - B_DEV_FIFO_OVERRUN, - B_DEV_FIFO_UNDERRUN, - B_DEV_PENDING, - B_DEV_MULTIPLE_ERRORS, - B_DEV_TOO_LATE -}; +#define B_DEV_INVALID_PIPE (B_DEVICE_ERROR_BASE + 19) +#define B_DEV_CRC_ERROR (B_DEVICE_ERROR_BASE + 20) +#define B_DEV_STALLED (B_DEVICE_ERROR_BASE + 21) +#define B_DEV_BAD_PID (B_DEVICE_ERROR_BASE + 22) +#define B_DEV_UNEXPECTED_PID (B_DEVICE_ERROR_BASE + 23) +#define B_DEV_DATA_OVERRUN (B_DEVICE_ERROR_BASE + 24) +#define B_DEV_DATA_UNDERRUN (B_DEVICE_ERROR_BASE + 25) +#define B_DEV_FIFO_OVERRUN (B_DEVICE_ERROR_BASE + 26) +#define B_DEV_FIFO_UNDERRUN (B_DEVICE_ERROR_BASE + 27) +#define B_DEV_PENDING (B_DEVICE_ERROR_BASE + 28) +#define B_DEV_MULTIPLE_ERRORS (B_DEVICE_ERROR_BASE + 29) +#define B_DEV_TOO_LATE (B_DEVICE_ERROR_BASE + 30) #endif /* _ERRORS_H */ From axeld at pinc-software.de Thu May 8 23:25:39 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 23:25:39 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25384_-_in_haiku/trunk/src=3A_apps/sud?= =?utf-8?q?oku_preferences/print_servers/media=5Faddon?= In-Reply-To: <200805082050.m48KoITm011922@sheep.berlios.de> Message-ID: <50526704869-BeMail@zon> bonefish at BerliOS wrote: > Log: > Cast B_OK to (uint32) to solve an overloading ambiguity (I don't > agree > with the compiler, though :-)), I'm about to introduce. Those "what" codes don't seem to make much sense, anyway. Maybe we should fix them. Bye, Axel. From axeld at pinc-software.de Thu May 8 23:29:53 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 08 May 2008 23:29:53 +0200 CEST Subject: [Haiku-commits] r25378 - in haiku/trunk/src/system/kernel: cache fs In-Reply-To: <20080508200345.7890.8@stippis2.1210243288.fake> Message-ID: <50780168511-BeMail@zon> Stephan Assmus wrote: > So it seems to pay off. :-) For the real mutexes this definitely should, but for benaphores, it should be the same in the end - both use the same mechanism. But since we currently compile with KDEBUG on, and many other debugging things, everything is much slower than it would be on a production system. Bye, Axel. From mmu_man at mail.berlios.de Fri May 9 00:30:43 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 00:30:43 +0200 Subject: [Haiku-commits] r25386 - haiku/trunk/src/apps/terminal Message-ID: <200805082230.m48MUhNd023459@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 00:30:39 +0200 (Fri, 09 May 2008) New Revision: 25386 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25386&view=rev Modified: haiku/trunk/src/apps/terminal/Shell.cpp Log: Sorry but I still need to test Terminal in BeOS to debug it... allstuff is #if(n)defed on __HAIKU__ for clarity. To be removed. Modified: haiku/trunk/src/apps/terminal/Shell.cpp =================================================================== --- haiku/trunk/src/apps/terminal/Shell.cpp 2008-05-08 20:54:14 UTC (rev 25385) +++ haiku/trunk/src/apps/terminal/Shell.cpp 2008-05-08 22:30:39 UTC (rev 25386) @@ -283,21 +283,57 @@ signal(SIGTTOU, SIG_IGN); +#ifdef __HAIKU__ // get a pseudo-tty int master = posix_openpt(O_RDWR | O_NOCTTY); const char *ttyName; +#else /* __HAIKU__ */ + /* + * Get a pseudo-tty. We do this by cycling through files in the + * directory. The operating system will not allow us to open a master + * which is already in use, so we simply go until the open succeeds. + */ + char ttyName[B_PATH_NAME_LENGTH]; + int master = -1; + DIR *dir = opendir("/dev/pt/"); + if (dir != NULL) { + struct dirent *dirEntry; + while ((dirEntry = readdir(dir)) != NULL) { + // skip '.' and '..' + if (dirEntry->d_name[0] == '.') + continue; + char ptyName[B_PATH_NAME_LENGTH]; + snprintf(ptyName, sizeof(ptyName), "/dev/pt/%s", dirEntry->d_name); + + master = open(ptyName, O_RDWR); + if (master >= 0) { + // Set the tty that corresponds to the pty we found + snprintf(ttyName, sizeof(ttyName), "/dev/tt/%s", dirEntry->d_name); + break; + } else { + // B_BUSY is a normal case + if (errno != B_BUSY) + fprintf(stderr, "could not open %s: %s\n", ptyName, strerror(errno)); + } + } + closedir(dir); + } +#endif /* __HAIKU__ */ + if (master < 0) { fprintf(stderr, "Didn't find any available pseudo ttys."); return errno; } +#ifdef __HAIKU__ if (grantpt(master) != 0 || unlockpt(master) != 0 || (ttyName = ptsname(master)) == NULL) { close(master); fprintf(stderr, "Failed to init pseudo tty."); return errno; } +#endif /* __HAIKU__ */ /* * Get the modes of the current terminal. We will duplicates these From mmu_man at mail.berlios.de Fri May 9 01:07:54 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 01:07:54 +0200 Subject: [Haiku-commits] r25387 - haiku/trunk/src/apps/terminal Message-ID: <200805082307.m48N7sO3010835@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 01:07:52 +0200 (Fri, 09 May 2008) New Revision: 25387 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25387&view=rev Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp haiku/trunk/src/apps/terminal/MenuUtil.cpp haiku/trunk/src/apps/terminal/TermConst.h Log: - MakeMenu() now adds a separator for empty strings. - add pref names for ANSI colors, for later... Modified: haiku/trunk/src/apps/terminal/AppearPrefView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-05-08 22:30:39 UTC (rev 25386) +++ haiku/trunk/src/apps/terminal/AppearPrefView.cpp 2008-05-08 23:07:52 UTC (rev 25387) @@ -33,6 +33,21 @@ PREF_CURSOR_BACK_COLOR, PREF_SELECT_FORE_COLOR, PREF_SELECT_BACK_COLOR, +#if 0 + "", + PREF_IM_FORE_COLOR, + PREF_IM_BACK_COLOR, + PREF_IM_SELECT_COLOR, + "", + PREF_ANSI_BLACK_COLOR, + PREF_ANSI_RED_COLOR, + PREF_ANSI_GREEN_COLOR, + PREF_ANSI_YELLOW_COLOR, + PREF_ANSI_BLUE_COLOR, + PREF_ANSI_MAGENTA_COLOR, + PREF_ANSI_CYAN_COLOR, + PREF_ANSI_WHITE_COLOR, +#endif NULL }; Modified: haiku/trunk/src/apps/terminal/MenuUtil.cpp =================================================================== --- haiku/trunk/src/apps/terminal/MenuUtil.cpp 2008-05-08 22:30:39 UTC (rev 25386) +++ haiku/trunk/src/apps/terminal/MenuUtil.cpp 2008-05-08 23:07:52 UTC (rev 25387) @@ -28,7 +28,10 @@ int32 i = 0; while (*items) { - menu->AddItem(new BMenuItem(*items, new BMessage(msg))); + if (!strcmp(*items, "")) + menu->AddSeparatorItem(); + else + menu->AddItem(new BMenuItem(*items, new BMessage(msg))); if (!strcmp(*items, defaultItemName)) menu->ItemAt(i)->SetMarked(true); Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2008-05-08 22:30:39 UTC (rev 25386) +++ haiku/trunk/src/apps/terminal/TermConst.h 2008-05-08 23:07:52 UTC (rev 25387) @@ -99,6 +99,15 @@ const char* const PREF_IM_BACK_COLOR = "IM Background Color"; const char* const PREF_IM_SELECT_COLOR = "IM Selection Color"; +const char* const PREF_ANSI_BLACK_COLOR = "ANSI Black Color"; +const char* const PREF_ANSI_RED_COLOR = "ANSI Red Color"; +const char* const PREF_ANSI_GREEN_COLOR = "ANSI Green Color"; +const char* const PREF_ANSI_YELLOW_COLOR = "ANSI Yellow Color"; +const char* const PREF_ANSI_BLUE_COLOR = "ANSI Blue Color"; +const char* const PREF_ANSI_MAGENTA_COLOR = "ANSI Magenta Color"; +const char* const PREF_ANSI_CYAN_COLOR = "ANSI Cyan Color"; +const char* const PREF_ANSI_WHITE_COLOR = "ANSI White Color"; + const char* const PREF_HISTORY_SIZE = "History Size"; const char* const PREF_CURSOR_BLINKING = "Cursor Blinking rate"; From mmu_man at mail.berlios.de Fri May 9 03:15:33 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 03:15:33 +0200 Subject: [Haiku-commits] r25388 - haiku/trunk/src/apps/terminal Message-ID: <200805090115.m491FXR5028284@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 03:15:25 +0200 (Fri, 09 May 2008) New Revision: 25388 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25388&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: Handle any dropped message. This makes dropping from Pe working for ex, as well as the BeOS BColorControl. Color drop is currently disabled, for now it just pastes it as text if provided (#rrggbb form from BColorControl). Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-08 23:07:52 UTC (rev 25387) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-09 01:15:25 UTC (rev 25388) @@ -1638,6 +1638,37 @@ entry_ref ref; char *ctrl_l = " "; + // first check for any dropped message + if (msg->WasDropped()) { + char *text; + int32 numBytes; + //rgb_color *color; + + int32 i = 0; + + if (msg->FindRef("refs", i++, &ref) == B_OK) { + _DoFileDrop(ref); + + while (msg->FindRef("refs", i++, &ref) == B_OK) { + _WritePTY((const uchar*)" ", 1); + _DoFileDrop(ref); + } + return; +#if 0 + } else if (msg->FindData("RGBColor", B_RGB_COLOR_TYPE, + (const void **)&color, &numBytes) == B_OK + && numBytes == sizeof(color)) { + // TODO: handle color drop + // maybe only on replicants ? + return; +#endif + } else if (msg->FindData("text/plain", B_MIME_TYPE, + (const void **)&text, &numBytes) == B_OK) { + _WritePTY((uchar *)text, numBytes); + return; + } + } + switch (msg->what){ case B_ABOUT_REQUESTED: // (replicant) about box requested @@ -1645,7 +1676,9 @@ break; case B_SIMPLE_DATA: + case B_REFS_RECEIVED: { + // handle refs if they weren't dropped int32 i = 0; if (msg->FindRef("refs", i++, &ref) == B_OK) { _DoFileDrop(ref); @@ -1659,23 +1692,6 @@ break; } - case B_MIME_DATA: - { - char *text; - int32 numBytes; - status_t sts; - - if (msg->WasDropped()) { - sts = msg->FindData("text/plain", - B_MIME_TYPE, (const void **)&text, &numBytes); - if (sts != B_OK) - break; - - _WritePTY((uchar *)text, numBytes); - } - break; - } - case B_COPY: Copy(be_clipboard); break; From bonefish at mail.berlios.de Fri May 9 03:32:38 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 9 May 2008 03:32:38 +0200 Subject: [Haiku-commits] r25389 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/libroot/os Message-ID: <200805090132.m491WcV4029372@sheep.berlios.de> Author: bonefish Date: 2008-05-09 03:32:36 +0200 (Fri, 09 May 2008) New Revision: 25389 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25389&view=rev Modified: haiku/trunk/headers/private/kernel/kernel.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/thread.h haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/libroot/os/thread.c Log: * Changed _kern_spawn_thread() and create_thread(): Instead of individual arguments they get a single thread_creation_attributes structure now. * Added stack_address and stack_size to thread_creation_attributes, which allow to specify the stack size or the stack to be used for the new user thread. Modified: haiku/trunk/headers/private/kernel/kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel.h 2008-05-09 01:15:25 UTC (rev 25388) +++ haiku/trunk/headers/private/kernel/kernel.h 2008-05-09 01:32:36 UTC (rev 25389) @@ -37,6 +37,8 @@ /** Size of the stack given to teams in user space */ #define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024) // 16 MB #define USER_STACK_SIZE (256 * 1024) // 256 kB +#define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB +#define MAX_USER_STACK_SIZE (16 * 1024 * 1024) // 16 MB #define USER_STACK_GUARD_PAGES 4 // 16 kB /** Size of the environmental variables space for a process */ Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-05-09 01:15:25 UTC (rev 25388) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-05-09 01:32:36 UTC (rev 25389) @@ -33,6 +33,7 @@ struct disk_device_job_progress_info; struct partitionable_space_data; +struct thread_creation_attributes; struct user_disk_device_data; struct user_disk_device_job_info; struct user_disk_system_info; @@ -107,8 +108,8 @@ extern pid_t _kern_setsid(void); extern status_t _kern_change_root(const char *path); -extern thread_id _kern_spawn_thread(int32 (*func)(thread_func, void *), - const char *name, int32 priority, void *data1, void *data2); +extern thread_id _kern_spawn_thread( + struct thread_creation_attributes* attributes); extern thread_id _kern_find_thread(const char *name); extern status_t _kern_suspend_thread(thread_id thread); extern status_t _kern_resume_thread(thread_id thread); Modified: haiku/trunk/headers/private/kernel/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/thread.h 2008-05-09 01:15:25 UTC (rev 25388) +++ haiku/trunk/headers/private/kernel/thread.h 2008-05-09 01:32:36 UTC (rev 25389) @@ -20,8 +20,23 @@ struct kernel_args; struct select_info; +struct thread_creation_attributes; +struct thread_creation_attributes { + int32 (*entry)(thread_func, void *); + const char* name; + int32 priority; + void* args1; + void* args2; + void* stack_address; + size_t stack_size; + // when calling kernel only + team_id team; + thread_id thread; +}; + + #ifdef __cplusplus extern "C" { #endif @@ -89,7 +104,7 @@ status_t _user_suspend_thread(thread_id thread); status_t _user_resume_thread(thread_id thread); status_t _user_rename_thread(thread_id thread, const char *name); -thread_id _user_spawn_thread(thread_entry_func entry, const char *name, int32 priority, void *arg1, void *arg2); +thread_id _user_spawn_thread(struct thread_creation_attributes* attributes); status_t _user_wait_for_thread(thread_id id, status_t *_returnCode); status_t _user_snooze_etc(bigtime_t timeout, int timebase, uint32 flags); status_t _user_kill_thread(thread_id thread); Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-05-09 01:15:25 UTC (rev 25388) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-05-09 01:32:36 UTC (rev 25389) @@ -364,8 +364,7 @@ \code < 0 \endcode a fresh one is allocated. */ static thread_id -create_thread(const char *name, team_id teamID, thread_entry_func entry, - void *args1, void *args2, int32 priority, bool kernel, thread_id threadID) +create_thread(thread_creation_attributes& attributes, bool kernel) { struct thread *thread, *currentThread; struct team *team; @@ -375,14 +374,16 @@ bool abort = false; bool debugNewThread = false; - TRACE(("create_thread(%s, id = %ld, %s)\n", name, threadID, - kernel ? "kernel" : "user")); + TRACE(("create_thread(%s, id = %ld, %s)\n", attributes.name, + attributes.thread, kernel ? "kernel" : "user")); - thread = create_thread_struct(NULL, name, threadID, NULL); + thread = create_thread_struct(NULL, attributes.name, attributes.thread, + NULL); if (thread == NULL) return B_NO_MEMORY; - thread->priority = priority == -1 ? B_NORMAL_PRIORITY : priority; + thread->priority = attributes.priority == -1 + ? B_NORMAL_PRIORITY : attributes.priority; thread->next_priority = thread->priority; // ToDo: this could be dangerous in case someone calls resume_thread() on us thread->state = B_THREAD_SUSPENDED; @@ -391,7 +392,8 @@ // init debug structure clear_thread_debug_info(&thread->debug_info, false); - snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%ld_kstack", name, thread->id); + snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%ld_kstack", attributes.name, + thread->id); thread->kernel_stack_area = create_area(stack_name, (void **)&thread->kernel_stack_base, B_ANY_KERNEL_ADDRESS, KERNEL_STACK_SIZE, B_FULL_LOCK, @@ -416,7 +418,7 @@ // If the new thread belongs to the same team as the current thread, // it may inherit some of the thread debug flags. currentThread = thread_get_current_thread(); - if (currentThread && currentThread->team->id == teamID) { + if (currentThread && currentThread->team->id == attributes.team) { // inherit all user flags... int32 debugFlags = currentThread->debug_info.flags & B_THREAD_DEBUG_USER_FLAG_MASK; @@ -440,7 +442,7 @@ GRAB_TEAM_LOCK(); // look at the team, make sure it's not being deleted - team = team_get_team_struct_locked(teamID); + team = team_get_team_struct_locked(attributes.team); if (team != NULL && team->state != TEAM_STATE_DEATH) { // Debug the new thread, if the parent thread required that (see above), // or the respective global team debug flag is set. But only, if a @@ -470,9 +472,9 @@ return B_BAD_TEAM_ID; } - thread->args1 = args1; - thread->args2 = args2; - thread->entry = entry; + thread->args1 = attributes.args1; + thread->args2 = attributes.args2; + thread->entry = attributes.entry; status = thread->id; if (kernel) { @@ -485,22 +487,33 @@ } else { // create user stack - // the stack will be between USER_STACK_REGION and the main thread stack area - // (the user stack of the main thread is created in team_create_team()) - thread->user_stack_base = USER_STACK_REGION; - thread->user_stack_size = USER_STACK_SIZE; + // the stack will be between USER_STACK_REGION and the main thread stack + // area (the user stack of the main thread is created in + // team_create_team()) + if (attributes.stack_address == NULL) { + thread->user_stack_base = USER_STACK_REGION; + if (attributes.stack_size <= 0) + thread->user_stack_size = USER_STACK_SIZE; + else + thread->user_stack_size = PAGE_ALIGN(attributes.stack_size); - snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%ld_stack", name, thread->id); - thread->user_stack_area = create_area_etc(team, stack_name, - (void **)&thread->user_stack_base, B_BASE_ADDRESS, - thread->user_stack_size + TLS_SIZE, B_NO_LOCK, - B_READ_AREA | B_WRITE_AREA | B_STACK_AREA); - if (thread->user_stack_area < B_OK - || arch_thread_init_tls(thread) < B_OK) { - // great, we have a fully running thread without a (usable) stack - dprintf("create_thread: unable to create proper user stack!\n"); - status = thread->user_stack_area; - kill_thread(thread->id); + snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%ld_stack", + attributes.name, thread->id); + thread->user_stack_area = create_area_etc(team, stack_name, + (void **)&thread->user_stack_base, B_BASE_ADDRESS, + thread->user_stack_size + TLS_SIZE, B_NO_LOCK, + B_READ_AREA | B_WRITE_AREA | B_STACK_AREA); + if (thread->user_stack_area < B_OK + || arch_thread_init_tls(thread) < B_OK) { + // great, we have a fully running thread without a (usable) + // stack + dprintf("create_thread: unable to create proper user stack!\n"); + status = thread->user_stack_area; + kill_thread(thread->id); + } + } else { + thread->user_stack_base = (addr_t)attributes.stack_address; + thread->user_stack_size = attributes.stack_size; } user_debug_update_new_thread_flags(thread->id); @@ -1829,8 +1842,18 @@ spawn_kernel_thread_etc(thread_func function, const char *name, int32 priority, void *arg, team_id team, thread_id threadID) { - return create_thread(name, team, (thread_entry_func)function, arg, NULL, - priority, true, threadID); + thread_creation_attributes attributes; + attributes.entry = (thread_entry_func)function; + attributes.name = name; + attributes.priority = priority; + attributes.args1 = arg; + attributes.args2 = NULL; + attributes.stack_address = NULL; + attributes.stack_size = 0; + attributes.team = team; + attributes.thread = threadID; + + return create_thread(attributes, true); } @@ -2593,8 +2616,18 @@ spawn_kernel_thread(thread_func function, const char *name, int32 priority, void *arg) { - return create_thread(name, team_get_kernel_team()->id, - (thread_entry_func)function, arg, NULL, priority, true, -1); + thread_creation_attributes attributes; + attributes.entry = (thread_entry_func)function; + attributes.name = name; + attributes.priority = priority; + attributes.args1 = arg; + attributes.args2 = NULL; + attributes.stack_address = NULL; + attributes.stack_size = 0; + attributes.team = team_get_kernel_team()->id; + attributes.thread = -1; + + return create_thread(attributes, true); } @@ -2677,23 +2710,40 @@ thread_id -_user_spawn_thread(int32 (*entry)(thread_func, void *), const char *userName, - int32 priority, void *data1, void *data2) +_user_spawn_thread(thread_creation_attributes* userAttributes) { + thread_creation_attributes attributes; + if (userAttributes == NULL || !IS_USER_ADDRESS(userAttributes) + || user_memcpy(&attributes, userAttributes, + sizeof(attributes)) != B_OK) { + return B_BAD_ADDRESS; + } + + if (attributes.stack_size != 0 + && (attributes.stack_size < MIN_USER_STACK_SIZE + || attributes.stack_size > MAX_USER_STACK_SIZE)) { + return B_BAD_VALUE; + } + char name[B_OS_NAME_LENGTH]; thread_id threadID; - if (!IS_USER_ADDRESS(entry) || entry == NULL - || (userName != NULL && (!IS_USER_ADDRESS(userName) - || user_strlcpy(name, userName, B_OS_NAME_LENGTH) < B_OK))) + if (!IS_USER_ADDRESS(attributes.entry) || attributes.entry == NULL + || attributes.stack_address != NULL + && !IS_USER_ADDRESS(attributes.stack_address) + || (attributes.name != NULL && (!IS_USER_ADDRESS(attributes.name) + || user_strlcpy(name, attributes.name, B_OS_NAME_LENGTH) < 0))) return B_BAD_ADDRESS; - threadID = create_thread(userName != NULL ? name : "user thread", - thread_get_current_thread()->team->id, entry, - data1, data2, priority, false, -1); + attributes.name = attributes.name != NULL ? name : "user thread"; + attributes.team = thread_get_current_thread()->team->id; + attributes.thread = -1; - user_debug_thread_created(threadID); + threadID = create_thread(attributes, false); + if (threadID >= 0) + user_debug_thread_created(threadID); + return threadID; } Modified: haiku/trunk/src/system/libroot/os/thread.c =================================================================== --- haiku/trunk/src/system/libroot/os/thread.c 2008-05-09 01:15:25 UTC (rev 25388) +++ haiku/trunk/src/system/libroot/os/thread.c 2008-05-09 01:32:36 UTC (rev 25389) @@ -9,6 +9,8 @@ #include #include +#include + #include "libroot_private.h" #include "tls.h" #include "syscalls.h" @@ -42,10 +44,20 @@ thread_id spawn_thread(thread_func entry, const char *name, int32 priority, void *data) { + struct thread_creation_attributes attributes; + _single_threaded = false; // used for I/O locking - BeOS compatibility issue - return _kern_spawn_thread(thread_entry, name, priority, entry, data); + attributes.entry = &thread_entry; + attributes.name = name; + attributes.priority = priority; + attributes.args1 = entry; + attributes.args2 = data; + attributes.stack_address = NULL; + attributes.stack_size = 0; + + return _kern_spawn_thread(&attributes); } From bonefish at mail.berlios.de Fri May 9 03:36:50 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 9 May 2008 03:36:50 +0200 Subject: [Haiku-commits] r25390 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread Message-ID: <200805090136.m491aoGr029554@sheep.berlios.de> Author: bonefish Date: 2008-05-09 03:36:49 +0200 (Fri, 09 May 2008) New Revision: 25390 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25390&view=rev Modified: haiku/trunk/headers/posix/pthread.h haiku/trunk/src/system/libroot/posix/pthread/Jamfile haiku/trunk/src/system/libroot/posix/pthread/pthread.c haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h Log: Implemented pthread_attr_{g,s}etstacksize(). Also added commented-out prototypes for the missing pthread_attr_*() functions. Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2008-05-09 01:32:36 UTC (rev 25389) +++ haiku/trunk/headers/posix/pthread.h 2008-05-09 01:36:49 UTC (rev 25390) @@ -170,7 +170,48 @@ extern int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); extern int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); +extern int pthread_attr_getstacksize(const pthread_attr_t *attr, + size_t *stacksize); +extern int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); +#if 0 /* Unimplemented attribute functions: */ + +// mandatory! +extern int pthread_attr_getschedparam(const pthread_attr_t *attr, + struct sched_param *param); +extern int pthread_attr_setschedparam(pthread_attr_t *attr, + const struct sched_param *param); + +// [TPS] +extern int pthread_attr_getinheritsched(const pthread_attr_t *attr, + int *inheritsched); +extern int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); + +extern int pthread_attr_getschedpolicy(const pthread_attr_t *attr, + int *policy); +extern int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); +extern int pthread_attr_getscope(const pthread_attr_t *attr, + int *contentionscope); +extern int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); + +// [XSI] +extern int pthread_attr_getguardsize(const pthread_attr_t *attr, + size_t *guardsize); +extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize); + +// [TSA] +extern int pthread_attr_getstackaddr(const pthread_attr_t *attr, + void **stackaddr); +extern int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr); + +// [TSA TSS] +extern int pthread_attr_getstack(const pthread_attr_t *attr, + void **stackaddr, size_t *stacksize); +extern int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); + +#endif /* 0 */ + + /* thread functions */ extern int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg); Modified: haiku/trunk/src/system/libroot/posix/pthread/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-09 01:32:36 UTC (rev 25389) +++ haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-09 01:36:49 UTC (rev 25390) @@ -1,5 +1,6 @@ SubDir HAIKU_TOP src system libroot posix pthread ; +UsePrivateKernelHeaders ; UsePrivateHeaders libroot ; MergeObject posix_pthread.o : Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2008-05-09 01:32:36 UTC (rev 25389) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2008-05-09 01:36:49 UTC (rev 25390) @@ -11,10 +11,15 @@ #include +#include +#include +#include + static const pthread_attr pthread_attr_default = { PTHREAD_CREATE_JOINABLE, - B_NORMAL_PRIORITY + B_NORMAL_PRIORITY, + USER_STACK_SIZE }; @@ -60,7 +65,7 @@ static int32 -pthread_thread_entry(void *_thread) +pthread_thread_entry(thread_func _unused, void *_thread) { struct pthread_thread *thread = (struct pthread_thread *)_thread; @@ -84,6 +89,7 @@ const pthread_attr *attr = NULL; struct pthread_thread *thread; thread_id threadID; + struct thread_creation_attributes attributes; if (_thread == NULL) return B_BAD_VALUE; @@ -109,8 +115,15 @@ sPthreadSlot = tls_allocate(); } - threadID = spawn_thread(pthread_thread_entry, "pthread func", - attr->sched_priority, thread); + attributes.entry = pthread_thread_entry; + attributes.name = "pthread func"; + attributes.priority = attr->sched_priority; + attributes.args1 = thread; + attributes.args2 = NULL; + attributes.stack_address = NULL; + attributes.stack_size = attr->stack_size; + + threadID = _kern_spawn_thread(&attributes); if (threadID < B_OK) { // stupid error code (EAGAIN) but demanded by POSIX return B_WOULD_BLOCK; Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c 2008-05-09 01:32:36 UTC (rev 25389) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c 2008-05-09 01:36:49 UTC (rev 25390) @@ -1,15 +1,17 @@ /* -** Copyright 2006, J?r?me Duval. All rights reserved. -** Distributed under the terms of the MIT License. -*/ + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Copyright 2006, J?r?me Duval. All rights reserved. + * Distributed under the terms of the MIT License. + */ - #include #include "pthread_private.h" #include +#include + int pthread_attr_init(pthread_attr_t *_attr) { @@ -24,6 +26,7 @@ attr->detach_state = PTHREAD_CREATE_JOINABLE; attr->sched_priority = B_NORMAL_PRIORITY; + attr->stack_size = USER_STACK_SIZE; *_attr = attr; return B_OK; @@ -75,3 +78,33 @@ return B_OK; } + +int +pthread_attr_getstacksize(const pthread_attr_t *_attr, size_t *stacksize) +{ + pthread_attr *attr; + + if (_attr == NULL || (attr = *_attr) == NULL || stacksize == NULL) + return B_BAD_VALUE; + + *stacksize = attr->stack_size; + + return 0; +} + + +int +pthread_attr_setstacksize(pthread_attr_t *_attr, size_t stacksize) +{ + pthread_attr *attr; + + if (_attr == NULL || (attr = *_attr) == NULL) + return B_BAD_VALUE; + + if (stacksize < MIN_USER_STACK_SIZE || stacksize > MAX_USER_STACK_SIZE) + return B_BAD_VALUE; + + attr->stack_size = stacksize; + + return 0; +} Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-05-09 01:32:36 UTC (rev 25389) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-05-09 01:36:49 UTC (rev 25390) @@ -44,6 +44,7 @@ typedef struct _pthread_attr { int32 detach_state; int32 sched_priority; + size_t stack_size; } pthread_attr; typedef void (*pthread_key_destructor)(void *data); From mmu_man at mail.berlios.de Fri May 9 04:22:39 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 04:22:39 +0200 Subject: [Haiku-commits] r25391 - haiku/trunk/src/apps/terminal Message-ID: <200805090222.m492Mccn032502@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 04:22:37 +0200 (Fri, 09 May 2008) New Revision: 25391 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25391&view=rev Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/VTKeyTbl.c haiku/trunk/src/apps/terminal/VTkeymap.h Log: - get rid of control chars in source files (ESC and CTRL-L) - fix Home and End keys - simplify code - add different strings for Ctrl-arrows, allows to map them to previous/next-word (PuTTY and others have actually several codes depending on mods & ALT, mode & CTRL and even mods & CTRL|ALT, might be even better...). Modified: haiku/trunk/src/apps/terminal/CodeConv.cpp =================================================================== --- haiku/trunk/src/apps/terminal/CodeConv.cpp 2008-05-09 01:36:49 UTC (rev 25390) +++ haiku/trunk/src/apps/terminal/CodeConv.cpp 2008-05-09 02:22:37 UTC (rev 25391) @@ -72,7 +72,7 @@ // system api for code conversion... check if this (which looks a lot like a workaround) // applies to haiku, and if not, get rid of this class and just use the system api directly. if (coding == B_EUC_CONVERSION && state != 0) { - const char *end_of_jis = "(B"; + const char *end_of_jis = "\033(B"; strncpy((char *)dst + dstlen, end_of_jis, 3); dstlen += 3; } Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-09 01:36:49 UTC (rev 25390) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-09 02:22:37 UTC (rev 25391) @@ -1483,26 +1483,28 @@ // Terminal filters RET, ENTER, F1...F12, and ARROW key code. // TODO: Cleanup if (numBytes == 1) { + const char *toWrite = NULL; switch (*bytes) { case B_RETURN: - if (rawChar == B_RETURN) { - char c = 0x0d; - fShell->Write(&c, 1); - return; - } + if (rawChar == B_RETURN) + toWrite = "\r"; break; case B_LEFT_ARROW: if (rawChar == B_LEFT_ARROW) { - fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE) - 1); - return; + if (mod & B_CONTROL_KEY) + toWrite = CTRL_LEFT_ARROW_KEY_CODE; + else + toWrite = LEFT_ARROW_KEY_CODE; } break; case B_RIGHT_ARROW: if (rawChar == B_RIGHT_ARROW) { - fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE) - 1); - return; + if (mod & B_CONTROL_KEY) + toWrite = CTRL_RIGHT_ARROW_KEY_CODE; + else + toWrite = RIGHT_ARROW_KEY_CODE; } break; @@ -1515,8 +1517,10 @@ return; } if (rawChar == B_UP_ARROW) { - fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE) - 1); - return; + if (mod & B_CONTROL_KEY) + toWrite = CTRL_UP_ARROW_KEY_CODE; + else + toWrite = UP_ARROW_KEY_CODE; } break; @@ -1528,30 +1532,26 @@ } if (rawChar == B_DOWN_ARROW) { - fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE) - 1); - return; + if (mod & B_CONTROL_KEY) + toWrite = CTRL_DOWN_ARROW_KEY_CODE; + else + toWrite = DOWN_ARROW_KEY_CODE; } break; case B_INSERT: - if (rawChar == B_INSERT) { - fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE) - 1); - return; - } + if (rawChar == B_INSERT) + toWrite = INSERT_KEY_CODE; break; case B_HOME: - if (rawChar == B_HOME) { - fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE) - 1); - return; - } + if (rawChar == B_HOME) + toWrite = HOME_KEY_CODE; break; case B_END: - if (rawChar == B_END) { - fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE) - 1); - return; - } + if (rawChar == B_END) + toWrite = END_KEY_CODE; break; case B_PAGE_UP: @@ -1562,10 +1562,8 @@ } return; } - if (rawChar == B_PAGE_UP) { - fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE) - 1); - return; - } + if (rawChar == B_PAGE_UP) + toWrite = PAGE_UP_KEY_CODE; break; case B_PAGE_DOWN: @@ -1575,10 +1573,8 @@ return; } - if (rawChar == B_PAGE_DOWN) { - fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE) - 1); - return; - } + if (rawChar == B_PAGE_DOWN) + toWrite = PAGE_DOWN_KEY_CODE; break; case B_FUNCTION_KEY: @@ -1593,6 +1589,10 @@ default: break; } + if (toWrite) { + fShell->Write(toWrite, strlen(toWrite)); + return; + } } else { // input multibyte character if (fEncoding != M_UTF8) { @@ -1636,7 +1636,7 @@ TermView::MessageReceived(BMessage *msg) { entry_ref ref; - char *ctrl_l = " "; + char *ctrl_l = "\x0c"; // first check for any dropped message if (msg->WasDropped()) { Modified: haiku/trunk/src/apps/terminal/VTKeyTbl.c =================================================================== --- haiku/trunk/src/apps/terminal/VTKeyTbl.c 2008-05-09 01:36:49 UTC (rev 25390) +++ haiku/trunk/src/apps/terminal/VTKeyTbl.c 2008-05-09 02:22:37 UTC (rev 25391) @@ -48,16 +48,16 @@ char *function_key_char_table [] = { -"[11~", -"[12~", -"[13~", -"[14~", -"[15~", -"[16~", -"[17~", -"[18~", -"[19~", -"[20~", -"[21~", -"[22~", +"\033[11~", +"\033[12~", +"\033[13~", +"\033[14~", +"\033[15~", +"\033[16~", +"\033[17~", +"\033[18~", +"\033[19~", +"\033[20~", +"\033[21~", +"\033[22~", }; Modified: haiku/trunk/src/apps/terminal/VTkeymap.h =================================================================== --- haiku/trunk/src/apps/terminal/VTkeymap.h 2008-05-09 01:36:49 UTC (rev 25390) +++ haiku/trunk/src/apps/terminal/VTkeymap.h 2008-05-09 02:22:37 UTC (rev 25391) @@ -65,17 +65,24 @@ -#define LEFT_ARROW_KEY_CODE "" -#define RIGHT_ARROW_KEY_CODE "" -#define UP_ARROW_KEY_CODE "" -#define DOWN_ARROW_KEY_CODE "" +#define LEFT_ARROW_KEY_CODE "\033[D" +#define RIGHT_ARROW_KEY_CODE "\033[C" +#define UP_ARROW_KEY_CODE "\033[A" +#define DOWN_ARROW_KEY_CODE "\033[B" -#define HOME_KEY_CODE "[@" -#define INSERT_KEY_CODE "[2~" -#define END_KEY_CODE "[[" -#define PAGE_UP_KEY_CODE "[5~" -#define PAGE_DOWN_KEY_CODE "[6~" +#define CTRL_LEFT_ARROW_KEY_CODE "\033[5D" +#define CTRL_RIGHT_ARROW_KEY_CODE "\033[5C" +#define CTRL_UP_ARROW_KEY_CODE "\033[5A" +#define CTRL_DOWN_ARROW_KEY_CODE "\033[5B" +//#define HOME_KEY_CODE "\033[@" +#define HOME_KEY_CODE "\033[1~" +#define INSERT_KEY_CODE "\033[2~" +//#define END_KEY_CODE "\033[[" +#define END_KEY_CODE "\033[4~" +#define PAGE_UP_KEY_CODE "\033[5~" +#define PAGE_DOWN_KEY_CODE "\033[6~" + //#define IS_DOWN_KEY(x) (info.key_states[(x) / 8] & key_state_table[(x) % 8]) #define IS_DOWN_KEY(x) \ (info.key_states[(x) >> 3] & (1 << (7 - ((x) % 8)))) From mmu_man at mail.berlios.de Fri May 9 05:44:39 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 05:44:39 +0200 Subject: [Haiku-commits] r25392 - haiku/trunk/src/apps/terminal Message-ID: <200805090344.m493idFm003827@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 05:44:37 +0200 (Fri, 09 May 2008) New Revision: 25392 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25392&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/VTPrsTbl.c haiku/trunk/src/apps/terminal/VTparse.h Log: - SetPosX/Y were wrong, but not yet used. - implemented HPA/VPA (CV/CH) sequences (set absolute v and h position). It's optional but because the beterm termcap advertises it we must implement it. Also note beterm increments args unlike others. This fixes all obvious display issues with the rhapsody IRC client (a small ncurses client I ported). - maybe we should switch the CASE_* to an enum ? Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2008-05-09 02:22:37 UTC (rev 25391) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2008-05-09 03:44:37 UTC (rev 25392) @@ -883,6 +883,26 @@ parsestate = groundtable; break; + case CASE_VPA: // ESC [...d move cursor absolute vertical + /* VPA (CV) */ + if ((row = param[0]) < 1) + row = 1; + + // note beterm wants it 1-based unlike usual terminals + fView->SetCurY(row - 1); + parsestate = groundtable; + break; + + case CASE_HPA: // ESC [...G move cursor absolute horizontal + /* HPA (CH) */ + if ((col = param[0]) < 1) + col = 1; + + // note beterm wants it 1-based unlike usual terminals + fView->SetCurX(col - 1); + parsestate = groundtable; + break; + default: break; } Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-09 02:22:37 UTC (rev 25391) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-09 03:44:37 UTC (rev 25392) @@ -838,7 +838,7 @@ void TermView::SetCurX(int x) { - if (x >= 0 && x < fTermRows) { + if (x >= 0 && x < fTermColumns) { UpdateLine(); fCurPos.x = x; } @@ -849,7 +849,7 @@ void TermView::SetCurY(int y) { - if (y >= 0 && y < fTermColumns) { + if (y >= 0 && y < fTermRows) { UpdateLine(); fCurPos.y = y; } Modified: haiku/trunk/src/apps/terminal/VTPrsTbl.c =================================================================== --- haiku/trunk/src/apps/terminal/VTPrsTbl.c 2008-05-09 02:22:37 UTC (rev 25391) +++ haiku/trunk/src/apps/terminal/VTPrsTbl.c 2008-05-09 03:44:37 UTC (rev 25392) @@ -1096,7 +1096,7 @@ CASE_CUB, CASE_GROUND_STATE, CASE_GROUND_STATE, -CASE_GROUND_STATE, +CASE_HPA, /* H I J K */ CASE_CUP, CASE_GROUND_STATE, @@ -1133,8 +1133,8 @@ CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ +CASE_VPA, CASE_GROUND_STATE, -CASE_GROUND_STATE, CASE_CUP, CASE_GROUND_STATE, /* h i j k */ Modified: haiku/trunk/src/apps/terminal/VTparse.h =================================================================== --- haiku/trunk/src/apps/terminal/VTparse.h 2008-05-09 02:22:37 UTC (rev 25391) +++ haiku/trunk/src/apps/terminal/VTparse.h 2008-05-09 03:44:37 UTC (rev 25392) @@ -116,3 +116,6 @@ #define CASE_SJIS_KANA 84 #define CASE_PRINT_GR 85 #define CASE_PRINT_CS96 86 +// additions, maybe reorder/reuse older ones ? +#define CASE_VPA 87 +#define CASE_HPA 88 From axeld at pinc-software.de Fri May 9 09:57:53 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 09:57:53 +0200 CEST Subject: [Haiku-commits] r25392 - haiku/trunk/src/apps/terminal In-Reply-To: <200805090344.m493idFm003827@sheep.berlios.de> Message-ID: <2064435925-BeMail@zon> mmu_man at BerliOS wrote: > Log: > - SetPosX/Y were wrong, but not yet used. > - implemented HPA/VPA (CV/CH) sequences (set absolute v and h > position). It's > optional but because the beterm termcap advertises it we must > implement it. Also > note beterm increments args unlike others. This fixes all obvious > display issues > with the rhapsody IRC client (a small ncurses client I ported). What about switching to advertize ourselves as "xterm", and add the additional functionality? Does vim now work correctly? Ah, well, you probably didn't test that ;- )) Bye, Axel. From axeld at pinc-software.de Fri May 9 10:01:22 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 10:01:22 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25389_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/kernel_src/system/libroot/os?= In-Reply-To: <200805090132.m491WcV4029372@sheep.berlios.de> Message-ID: <2273060289-BeMail@zon> bonefish at BerliOS wrote: > Log: > * Changed _kern_spawn_thread() and create_thread(): Instead of > individual > arguments they get a single thread_creation_attributes structure > now. > * Added stack_address and stack_size to thread_creation_attributes, > which allow to specify the stack size or the stack to be used for > the > new user thread. Great, this is also something I wanted to do for quite some time :-) Now we can change the app_server to create threads with less stack, so that it can run many more windows at once :-) Bye, Axel. From anevilyak at gmail.com Fri May 9 14:25:35 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 07:25:35 -0500 Subject: [Haiku-commits] r25389 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/libroot/os In-Reply-To: <2273060289-BeMail@zon> References: <200805090132.m491WcV4029372@sheep.berlios.de> <2273060289-BeMail@zon> Message-ID: On Fri, May 9, 2008 at 3:01 AM, Axel D?rfler wrote: > Great, this is also something I wanted to do for quite some time :-) > Now we can change the app_server to create threads with less stack, so > that it can run many more windows at once :-) Just curious, given that we now have wait_for_objects(), wouldn't it theoretically be feasible to modify the app_server so it's not necessary to spawn a thread per window any more? Also, what is our per-team stack size anyways? Regards, Rene From axeld at mail.berlios.de Fri May 9 14:42:35 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 9 May 2008 14:42:35 +0200 Subject: [Haiku-commits] r25393 - in haiku/trunk: headers/os/drivers src/add-ons/kernel/drivers/audio/hda Message-ID: <200805091242.m49CgZTn023978@sheep.berlios.de> Author: axeld Date: 2008-05-09 14:42:33 +0200 (Fri, 09 May 2008) New Revision: 25393 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25393&view=rev Modified: haiku/trunk/headers/os/drivers/PCI.h haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h Log: * Added PCI_hd_audio sub-type in the PCI_multimedia base class. * Fixed some minor typos. Modified: haiku/trunk/headers/os/drivers/PCI.h =================================================================== --- haiku/trunk/headers/os/drivers/PCI.h 2008-05-09 03:44:37 UTC (rev 25392) +++ haiku/trunk/headers/os/drivers/PCI.h 2008-05-09 12:42:33 UTC (rev 25393) @@ -326,7 +326,7 @@ #define PCI_vga 0x00 /* VGA controller */ #define PCI_xga 0x01 /* XGA controller */ -#define PCI_3d 0x02 /* ?d controller */ +#define PCI_3d 0x02 /* 3d controller */ #define PCI_display_other 0x80 /* other display controller */ @@ -334,10 +334,11 @@ values for the class_sub field for class_base = 0x04 (multimedia device) --- */ -#define PCI_video 0x00 /* video */ -#define PCI_audio 0x01 /* audio */ -#define PCI_telephony 0x02 /* computer telephony device */ -#define PCI_multimedia_other 0x80 /* other multimedia device */ +#define PCI_video 0x00 /* video */ +#define PCI_audio 0x01 /* audio */ +#define PCI_telephony 0x02 /* computer telephony device */ +#define PCI_hd_audio 0x03 /* HD audio */ +#define PCI_multimedia_other 0x80 /* other multimedia device */ /* --- @@ -403,7 +404,7 @@ system peripherals) --- */ -#define PCI_pic 0x00 /* periperal interrupt controller */ +#define PCI_pic 0x00 /* peripheral interrupt controller */ #define PCI_dma 0x01 /* dma controller */ #define PCI_timer 0x02 /* timers */ #define PCI_rtc 0x03 /* real time clock */ Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-05-09 03:44:37 UTC (rev 25392) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/driver.h 2008-05-09 12:42:33 UTC (rev 25393) @@ -30,7 +30,9 @@ #define MAX_CARDS 4 /* values for the class_sub field for class_base = 0x04 (multimedia device) */ -#define PCI_hd_audio 3 +#ifndef __HAIKU__ +# define PCI_hd_audio 3 +#endif #define HDA_MAX_AUDIO_GROUPS 15 #define HDA_MAX_CODECS 15 From axeld at mail.berlios.de Fri May 9 14:56:29 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 9 May 2008 14:56:29 +0200 Subject: [Haiku-commits] r25394 - haiku/trunk/src/tests/system/kernel/device_manager/playground Message-ID: <200805091256.m49CuTsl025028@sheep.berlios.de> Author: axeld Date: 2008-05-09 14:56:29 +0200 (Fri, 09 May 2008) New Revision: 25394 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25394&view=rev Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp Log: * Changed how the driver paths are found: now, the bus can add type/sub-type/ interface information (in the PCI notion) to a node, and the possible paths of a device driver are generated from that information by the device manager. * Removed the "is bus" attribute - the device manager now decides wether or not a device always loads its children (as opposed to on demand loading only), even if the B_FIND_CHILD_ON_DEMAND flag is specified. * device_node::Register() now correctly maintains the fRegistered member field. * Replaced the driver_module() and driver_data() methods with a get_driver() method that retrieves all information at once. * Cleaned attribute names. * Some other cleanup, adding const where it makes sense. Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-09 12:42:33 UTC (rev 25393) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-09 12:56:29 UTC (rev 25394) @@ -7,6 +7,7 @@ #include "bus.h" #include +#include #define BUS_MODULE_NAME "bus_managers/sample_bus/driver_v1" @@ -19,7 +20,7 @@ supports_device(device_node *parent) { const char* bus; - if (gDeviceManager->get_attr_string(parent, B_DRIVER_BUS, &bus, false) + if (gDeviceManager->get_attr_string(parent, B_DEVICE_BUS, &bus, false) != B_OK) return -1; @@ -34,9 +35,8 @@ register_device(device_node *parent) { device_attr attrs[] = { - {B_DRIVER_PRETTY_NAME, B_STRING_TYPE, {string: "My Bus"}}, - {B_DRIVER_BUS, B_STRING_TYPE, {string: BUS_NAME}}, - {B_DRIVER_IS_BUS, B_UINT8_TYPE, {ui8: true}}, + {B_DEVICE_PRETTY_NAME, B_STRING_TYPE, {string: "My Bus"}}, + {B_DEVICE_BUS, B_STRING_TYPE, {string: BUS_NAME}}, {NULL} }; @@ -65,23 +65,32 @@ const struct device_info { uint16 vendor; uint16 device; - const char *type; + uint16 type; + uint16 sub_type; + uint16 interface; } kDevices[] = { - {0x1000, 0x0001, B_DISK_DRIVER_TYPE}, - {0x1001, 0x0001, B_NETWORK_DRIVER_TYPE}, - {0x1002, 0x0001, B_AUDIO_DRIVER_TYPE}, - {0x1002, 0x0002, B_BUS_DRIVER_TYPE}, + {0x1000, 0x0001, PCI_mass_storage, PCI_sata, PCI_sata_ahci}, + {0x1001, 0x0001, PCI_network, PCI_ethernet, 0}, + {0x1002, 0x0001, PCI_multimedia, PCI_audio, 0}, + {0x1002, 0x0002, PCI_serial_bus, PCI_usb, PCI_usb_ehci}, }; const size_t kNumDevices = sizeof(kDevices) / sizeof(kDevices[0]); for (uint32 i = 0; i < kNumDevices; i++) { device_attr attrs[] = { // info about the device - {"bus/vendor", B_UINT16_TYPE, {ui16: kDevices[i].vendor}}, - {"bus/device", B_UINT16_TYPE, {ui16: kDevices[i].device}}, + {B_DEVICE_VENDOR_ID, B_UINT16_TYPE, {ui16: kDevices[i].vendor}}, + {B_DEVICE_ID, B_UINT16_TYPE, {ui16: kDevices[i].device}}, - {B_DRIVER_BUS, B_STRING_TYPE, {string: BUS_NAME}}, - {B_DRIVER_DEVICE_TYPE, B_STRING_TYPE, {string: kDevices[i].type}}, + {B_DEVICE_BUS, B_STRING_TYPE, {string: BUS_NAME}}, + {B_DEVICE_TYPE, B_UINT16_TYPE, {ui16: kDevices[i].type}}, + {B_DEVICE_SUB_TYPE, B_UINT16_TYPE, + {ui16: kDevices[i].sub_type}}, + {B_DEVICE_INTERFACE, B_UINT16_TYPE, + {ui16: kDevices[i].interface}}, + + {B_DEVICE_FIND_CHILD_FLAGS, B_UINT32_TYPE, + {ui32: B_FIND_CHILD_ON_DEMAND}}, {NULL} }; @@ -90,7 +99,8 @@ } device_attr attrs[] = { - {B_DRIVER_FIXED_CHILD, B_STRING_TYPE, {string: "non_existing/driver_v1"}}, + {B_DEVICE_FIXED_CHILD, B_STRING_TYPE, + {string: "non_existing/driver_v1"}}, {NULL} }; @@ -122,9 +132,9 @@ static status_t get_bus_info(void* cookie, bus_info* info) { - gDeviceManager->get_attr_uint16((device_node*)cookie, "bus/vendor", + gDeviceManager->get_attr_uint16((device_node*)cookie, B_DEVICE_VENDOR_ID, &info->vendor_id, false); - gDeviceManager->get_attr_uint16((device_node*)cookie, "bus/device", + gDeviceManager->get_attr_uint16((device_node*)cookie, B_DEVICE_ID, &info->device_id, false); return B_OK; } Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-09 12:42:33 UTC (rev 25393) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-09 12:56:29 UTC (rev 25394) @@ -13,8 +13,9 @@ #include #include +#include #include -#include +#include #include #include @@ -36,11 +37,13 @@ extern bool gDebugOutputEnabled; // from libkernelland_emu.so -status_t dm_get_attr_uint8(const device_node* node, const char* name, uint8* _value, - bool recursive); -status_t dm_get_attr_uint32(device_node* node, const char* name, uint32* _value, - bool recursive); -status_t dm_get_attr_string(device_node* node, const char* name, +status_t dm_get_attr_uint8(const device_node* node, const char* name, + uint8* _value, bool recursive); +status_t dm_get_attr_uint16(const device_node* node, const char* name, + uint16* _value, bool recursive); +status_t dm_get_attr_uint32(const device_node* node, const char* name, + uint32* _value, bool recursive); +status_t dm_get_attr_string(const device_node* node, const char* name, const char** _value, bool recursive); @@ -109,6 +112,9 @@ private: status_t _RegisterFixed(uint32& registered); + bool _AlwaysRegisterDynamic(); + status_t _AddPath(Stack& stack, const char* path, + const char* subPath = NULL); status_t _GetNextDriverPath(void*& cookie, KPath& _path); status_t _GetNextDriver(void* list, driver_module_info*& driver); @@ -117,7 +123,6 @@ float& bestSupport); status_t _RegisterPath(const char* path); status_t _RegisterDynamic(); - bool _IsBus() const; device_node* fParent; NodeList fChildren; @@ -496,33 +501,22 @@ if (status != B_OK) return status; - if (!fChildren.IsEmpty()) + if (!fChildren.IsEmpty()) { + fRegistered = true; return B_OK; + } } // Register all possible child device nodes - uint32 findFlags = 0; - dm_get_attr_uint32(this, B_DRIVER_FIND_CHILD_FLAGS, &findFlags, false); + status = _RegisterDynamic(); + if (status == B_OK) + fRegistered = true; - if ((findFlags & B_FIND_CHILD_ON_DEMAND) != 0) - return B_OK; - - return _RegisterDynamic(); + return status; } -bool -device_node::_IsBus() const -{ - uint8 isBus; - if (dm_get_attr_uint8(this, B_DRIVER_IS_BUS, &isBus, false) != B_OK) - return false; - - return isBus; -} - - /*! Registers any children that are identified via the B_DRIVER_FIXED_CHILD attribute. If any of these children cannot be registered, this call will fail (we @@ -536,7 +530,7 @@ while (iterator.HasNext()) { device_attr_private* attr = iterator.Next(); - if (strcmp(attr->name, B_DRIVER_FIXED_CHILD)) + if (strcmp(attr->name, B_DEVICE_FIXED_CHILD)) continue; driver_module_info* driver; @@ -562,6 +556,27 @@ status_t +device_node::_AddPath(Stack& stack, const char* basePath, + const char* subPath) +{ + KPath* path = new(std::nothrow) KPath; + if (path == NULL) + return B_NO_MEMORY; + + status_t status = path->SetTo(basePath); + if (status == B_OK && subPath != NULL && subPath[0]) + status = path->Append(subPath); + if (status == B_OK) + status = stack.Push(path); + + if (status != B_OK) + delete path; + + return status; +} + + +status_t device_node::_GetNextDriverPath(void*& cookie, KPath& _path) { Stack* stack = NULL; @@ -573,40 +588,73 @@ return B_NO_MEMORY; StackDeleter stackDeleter(stack); + uint16 type = 0; + uint16 subType = 0; + uint16 interface = 0; + dm_get_attr_uint16(this, B_DEVICE_TYPE, &type, false); + dm_get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false); + dm_get_attr_uint16(this, B_DEVICE_INTERFACE, &interface, false); - if (!_IsBus()) { - // add driver paths - KPath* path = new(std::nothrow) KPath; - if (path == NULL) - return B_NO_MEMORY; - - status_t status = path->SetTo("drivers"); - if (status != B_OK) { - delete path; - return status; - } - - // TODO: this might be more than one path! - const char *type; - if (dm_get_attr_string(this, B_DRIVER_DEVICE_TYPE, &type, false) - == B_OK) - path->Append(type); - - stack->Push(path); + // TODO: maybe make this extendible via settings file? + switch (type) { + case PCI_mass_storage: + switch (subType) { + case PCI_scsi: + _AddPath(*stack, "busses", "scsi"); + break; + case PCI_ide: + _AddPath(*stack, "busses", "ide"); + break; + case PCI_sata: + _AddPath(*stack, "busses", "sata"); + break; + default: + _AddPath(*stack, "busses", "disk"); + break; + } + break; + case PCI_serial_bus: + switch (subType) { + case PCI_firewire: + _AddPath(*stack, "busses", "firewire"); + break; + case PCI_usb: + _AddPath(*stack, "busses", "usb"); + break; + default: + _AddPath(*stack, "busses"); + break; + } + break; + case PCI_network: + _AddPath(*stack, "drivers", "net"); + break; + case PCI_display: + _AddPath(*stack, "drivers", "graphics"); + break; + case PCI_multimedia: + switch (subType) { + case PCI_audio: + case PCI_hd_audio: + _AddPath(*stack, "drivers", "audio"); + break; + case PCI_video: + _AddPath(*stack, "drivers", "video"); + break; + default: + _AddPath(*stack, "drivers"); + break; + } + break; + default: + if (sRootNode == this) { + _AddPath(*stack, "busses/pci"); + _AddPath(*stack, "bus_managers"); + } else + _AddPath(*stack, "drivers"); + break; } - // add bus paths - KPath* path = new(std::nothrow) KPath; - if (path == NULL) - return B_NO_MEMORY; - - status_t status = path->SetTo("bus"); - if (status != B_OK) { - delete path; - return status; - } - - stack->Push(path); stackDeleter.Detach(); cookie = (void*)stack; @@ -705,14 +753,31 @@ } +bool +device_node::_AlwaysRegisterDynamic() +{ + uint16 type = 0; + uint16 subType = 0; + dm_get_attr_uint16(this, B_DEVICE_TYPE, &type, false); + dm_get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false); + + return type == PCI_serial_bus || type == PCI_bridge; + // TODO: we may want to be a bit more specific in the future +} + + status_t device_node::_RegisterDynamic() { - uint32 findFlags; - if (dm_get_attr_uint32(this, B_DRIVER_FIND_CHILD_FLAGS, &findFlags, false) - != B_OK) - findFlags = 0; + uint32 findFlags = 0; + dm_get_attr_uint32(this, B_DEVICE_FIND_CHILD_FLAGS, &findFlags, false); + // If this is our initial registration, we honour the B_FIND_CHILD_ON_DEMAND + // requirements + if (!fRegistered && (findFlags & B_FIND_CHILD_ON_DEMAND) != 0 + && !_AlwaysRegisterDynamic()) + return B_OK; + KPath path; if ((findFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { @@ -825,20 +890,16 @@ } -static driver_module_info* -driver_module(device_node* node) +static void +get_driver(device_node* node, driver_module_info** _module, void** _data) { - return node->DriverModule(); + if (_module != NULL) + *_module = node->DriverModule(); + if (_data != NULL) + *_data = node->DriverData(); } -static void* -driver_data(device_node* node) -{ - return node->DriverData(); -} - - static device_node* device_root(void) { @@ -885,7 +946,7 @@ status_t -dm_get_attr_uint16(device_node* node, const char* name, uint16* _value, +dm_get_attr_uint16(const device_node* node, const char* name, uint16* _value, bool recursive) { if (node == NULL || name == NULL || _value == NULL) @@ -902,7 +963,7 @@ status_t -dm_get_attr_uint32(device_node* node, const char* name, uint32* _value, +dm_get_attr_uint32(const device_node* node, const char* name, uint32* _value, bool recursive) { if (node == NULL || name == NULL || _value == NULL) @@ -919,7 +980,7 @@ status_t -dm_get_attr_uint64(device_node* node, const char* name, +dm_get_attr_uint64(const device_node* node, const char* name, uint64* _value, bool recursive) { if (node == NULL || name == NULL || _value == NULL) @@ -936,8 +997,8 @@ status_t -dm_get_attr_string(device_node* node, const char* name, const char** _value, - bool recursive) +dm_get_attr_string(const device_node* node, const char* name, + const char** _value, bool recursive) { if (node == NULL || name == NULL || _value == NULL) return B_BAD_VALUE; @@ -953,7 +1014,7 @@ status_t -dm_get_attr_raw(device_node* node, const char* name, const void** _data, +dm_get_attr_raw(const device_node* node, const char* name, const void** _data, size_t* _length, bool recursive) { if (node == NULL || name == NULL || (_data == NULL && _length == NULL)) @@ -1005,8 +1066,7 @@ rescan_device, register_device, unregister_device, - driver_module, - driver_data, + get_driver, device_root, get_next_child_device, get_parent, @@ -1030,10 +1090,9 @@ dm_init_root_node(void) { device_attr attrs[] = { - {B_DRIVER_PRETTY_NAME, B_STRING_TYPE, {string: "Devices Root"}}, - {B_DRIVER_IS_BUS, B_UINT8_TYPE, {ui8: true}}, - {B_DRIVER_BUS, B_STRING_TYPE, {string: "root"}}, - {B_DRIVER_FIND_CHILD_FLAGS, B_UINT32_TYPE, + {B_DEVICE_PRETTY_NAME, B_STRING_TYPE, {string: "Devices Root"}}, + {B_DEVICE_BUS, B_STRING_TYPE, {string: "root"}}, + {B_DEVICE_FIND_CHILD_FLAGS, B_UINT32_TYPE, {ui32: B_FIND_MULTIPLE_CHILDREN}}, {NULL} }; Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-09 12:42:33 UTC (rev 25393) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-09 12:56:29 UTC (rev 25394) @@ -69,8 +69,8 @@ device_node **_node); status_t (*unregister_device)(device_node *node); - driver_module_info *(*driver_module)(device_node *node); - void *(*driver_data)(device_node *node); + void (*get_driver)(device_node *node, driver_module_info **_module, + void **_cookie); device_node *(*root_device)(); status_t (*get_next_child_device)(device_node *parent, device_node *node, @@ -86,17 +86,17 @@ status_t (*free_id)(const char *generator, uint32 id); #endif - status_t (*get_attr_uint8)(device_node *node, const char *name, + status_t (*get_attr_uint8)(const device_node *node, const char *name, uint8 *value, bool recursive); - status_t (*get_attr_uint16)(device_node *node, const char *name, + status_t (*get_attr_uint16)(const device_node *node, const char *name, uint16 *value, bool recursive); - status_t (*get_attr_uint32)(device_node *node, const char *name, + status_t (*get_attr_uint32)(const device_node *node, const char *name, uint32 *value, bool recursive); - status_t (*get_attr_uint64)(device_node *node, const char *name, + status_t (*get_attr_uint64)(const device_node *node, const char *name, uint64 *value, bool recursive); - status_t (*get_attr_string)(device_node *node, const char *name, + status_t (*get_attr_string)(const device_node *node, const char *name, const char **_value, bool recursive); - status_t (*get_attr_raw)(device_node *node, const char *name, + status_t (*get_attr_raw)(const device_node *node, const char *name, const void **_data, size_t *_size, bool recursive); status_t (*get_next_attr)(device_node *node, device_attr **_attr); @@ -122,33 +122,30 @@ }; -// standard device node attributes +/* standard device node attributes */ -#define B_DRIVER_PRETTY_NAME "driver/pretty name" // string -#define B_DRIVER_MAPPING "driver/mapping" // string -#define B_DRIVER_IS_BUS "driver/is_bus" // uint8 -#define B_DRIVER_BUS "driver/bus" // string -#define B_DRIVER_FIXED_CHILD "fixed child" // string -#define B_DRIVER_FIND_CHILD_FLAGS "find child flags" // uint32 -#define B_DRIVER_UNIQUE_DEVICE_ID "unique id" // string -#define B_DRIVER_DEVICE_TYPE "device type" // string +#define B_DEVICE_PRETTY_NAME "device/pretty name" /* string */ +#define B_DEVICE_MAPPING "device/mapping" /* string */ +#define B_DEVICE_BUS "device/bus" /* string */ +#define B_DEVICE_FIXED_CHILD "device/fixed child" /* string */ +#define B_DEVICE_FIND_CHILD_FLAGS "device/find child flags" /* uint32 */ +#define B_DEVICE_VENDOR_ID "device/vendor" /* uint16 */ +#define B_DEVICE_ID "device/id" /* uint16 */ +#define B_DEVICE_TYPE "device/type" + /* uint16, PCI base class */ +#define B_DEVICE_SUB_TYPE "device/subtype" + /* uint16, PCI sub type */ +#define B_DEVICE_INTERFACE "device/interface" + /* uint16, PCI class API */ + +#define B_DEVICE_UNIQUE_ID "device/unique id" /* string */ + // find child flags #define B_FIND_CHILD_ON_DEMAND 0x01 #define B_FIND_MULTIPLE_CHILDREN 0x02 -// driver types -#define B_AUDIO_DRIVER_TYPE "audio" -#define B_BUS_DRIVER_TYPE "bus" -#define B_DISK_DRIVER_TYPE "disk" -#define B_GRAPHICS_DRIVER_TYPE "graphics" -#define B_INPUT_DRIVER_TYPE "input" -#define B_MISC_DRIVER_TYPE "misc" -#define B_NETWORK_DRIVER_TYPE "net" -#define B_VIDEO_DRIVER_TYPE "video" -#define B_INTERRUPT_CONTROLLER_DRIVER_TYPE "interrupt controller" - // interface of device typedef struct io_request io_request; Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-09 12:42:33 UTC (rev 25393) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-09 12:56:29 UTC (rev 25394) @@ -28,13 +28,13 @@ return -1; #endif - bus_for_driver_module_info* module - = (bus_for_driver_module_info*)gDeviceManager->driver_module(parent); + bus_for_driver_module_info* module; + void* data; + gDeviceManager->get_driver(parent, (driver_module_info**)&module, &data); + if (strcmp(module->info.info.name, BUS_FOR_DRIVER_NAME)) return -1; - void* data = gDeviceManager->driver_data(parent); - bus_info info; if (module->get_bus_info(data, &info) == B_OK && info.vendor_id == 0x1001 From axeld at mail.berlios.de Fri May 9 15:08:59 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 9 May 2008 15:08:59 +0200 Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util Message-ID: <200805091308.m49D8xYw026218@sheep.berlios.de> Author: axeld Date: 2008-05-09 15:08:59 +0200 (Fri, 09 May 2008) New Revision: 25395 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25395&view=rev Modified: haiku/trunk/headers/private/kernel/util/Stack.h Log: Followed Ingo's suggestion, and made StackDeleter an AutoDeleter specialization. Modified: haiku/trunk/headers/private/kernel/util/Stack.h =================================================================== --- haiku/trunk/headers/private/kernel/util/Stack.h 2008-05-09 12:56:29 UTC (rev 25394) +++ haiku/trunk/headers/private/kernel/util/Stack.h 2008-05-09 13:08:59 UTC (rev 25395) @@ -10,7 +10,9 @@ #include +#include + template class Stack { public: Stack() @@ -76,33 +78,34 @@ int32 fMax; }; -template class StackDeleter { + +template class StackDelete { public: - StackDeleter(Stack* stack) - : fStack(stack) + inline void operator()(Stack* stack) { - } + if (stack == NULL) + return; - ~StackDeleter() - { - if (fStack == NULL) - return; - T item; - while (fStack->Pop(&item)) { + while (stack->Pop(&item)) { delete item; } + + delete stack; + } +}; - delete fStack; +template class StackDeleter + : public BPrivate::AutoDeleter, StackDelete > { +public: + StackDeleter() + { } - void Detach() + StackDeleter(Stack* stack) + : BPrivate::AutoDeleter, StackDelete >(stack) { - fStack = NULL; } - -private: - Stack* fStack; }; #endif /* KERNEL_UTIL_STACK_H */ From axeld at pinc-software.de Fri May 9 15:08:52 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 15:08:52 +0200 CEST Subject: [Haiku-commits] r25381 - haiku/trunk/headers/private/kernel/util In-Reply-To: <20080508214100.452.1@knochen-vm.1210274936.fake> Message-ID: <20723704488-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-08 at 18:44:01 [+0200], axeld at BerliOS < > axeld at mail.berlios.de> > wrote: > > Log: > > Added a StackDeleter class that also empties the stack and deletes > > the > > items. > How about using an AutoDeleter specialization in such a case? Would > be less > code and you get the additional methods (Detach(), SetTo(), Unset()) > for > free. I don't know about less code, but I did so in r25395 :-) Bye, Axel. From anevilyak at gmail.com Fri May 9 15:12:06 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 08:12:06 -0500 Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util In-Reply-To: <200805091308.m49D8xYw026218@sheep.berlios.de> References: <200805091308.m49D8xYw026218@sheep.berlios.de> Message-ID: On Fri, May 9, 2008 at 8:08 AM, axeld at BerliOS wrote: > -template class StackDeleter { > + > +template class StackDelete { > public: > - StackDeleter(Stack* stack) Shouldn't that be class StackDeleter? Regards, Rene From axeld at pinc-software.de Fri May 9 15:17:01 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 15:17:01 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25389_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/kernel_src/system/libroot/os?= In-Reply-To: Message-ID: <21212140984-BeMail@zon> "Rene Gollent" wrote: > On Fri, May 9, 2008 at 3:01 AM, Axel D?rfler > wrote: > > Great, this is also something I wanted to do for quite some time :- > > ) > > Now we can change the app_server to create threads with less stack, > > so > > that it can run many more windows at once :-) > Just curious, given that we now have wait_for_objects(), wouldn't it > theoretically be feasible to modify the app_server so it's not > necessary to spawn a thread per window any more? Also, what is our > per-team stack size anyways? 16 MB for the first thread (to make things like GCC work), and 192 KB for all other threads. However, it looks like it's actually 256 KB on Haiku, dunno why. Since we now have wait_for_objects(), it would indeed be okay to change that mapping, but it would still be beneficial to have more than CPU- count threads in there, so I don't think we'll do that for now - as that would make considerably wait_for_objects() less useful, though. Besides, having 200 threads waiting idle does not really hurt anyone (if they don't eat up the app_server's address space). If threading gets really cheap one day (who knows), we might want to spawn a new thread for each incoming message. Bye, Axel. From anevilyak at gmail.com Fri May 9 15:29:00 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 08:29:00 -0500 Subject: [Haiku-commits] r25389 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/libroot/os In-Reply-To: <21212140984-BeMail@zon> References: <21212140984-BeMail@zon> Message-ID: On Fri, May 9, 2008 at 8:17 AM, Axel D?rfler wrote: > 16 MB for the first thread (to make things like GCC work), and 192 KB > for all other threads. However, it looks like it's actually 256 KB on > Haiku, dunno why. > > Since we now have wait_for_objects(), it would indeed be okay to change > that mapping, but it would still be beneficial to have more than CPU- > count threads in there, so I don't think we'll do that for now - as > that would make considerably wait_for_objects() less useful, though. > Besides, having 200 threads waiting idle does not really hurt anyone > (if they don't eat up the app_server's address space). I wasn't really thinking a thread per CPU...more of an M:N model I guess, i.e. have a pool of worker threads to which useful work can be dispatched, since at any given time it's usually only a subset of windows/apps that are actually doing anything. Regards, Rene From axeld at pinc-software.de Fri May 9 15:29:47 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 15:29:47 +0200 CEST Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util In-Reply-To: Message-ID: <21978182719-BeMail@zon> "Rene Gollent" wrote: > On Fri, May 9, 2008 at 8:08 AM, axeld at BerliOS < > axeld at mail.berlios.de> wrote: > > -template class StackDeleter { > > + > > +template class StackDelete { > > public: > > - StackDeleter(Stack* stack) > Shouldn't that be class StackDeleter? StackDelete provides the method that is called upon destruction of the StackDeleter object. Bye, Axel. From anevilyak at gmail.com Fri May 9 15:33:14 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 08:33:14 -0500 Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util In-Reply-To: <21978182719-BeMail@zon> References: <21978182719-BeMail@zon> Message-ID: On Fri, May 9, 2008 at 8:29 AM, Axel D?rfler wrote: > "Rene Gollent" wrote: >> On Fri, May 9, 2008 at 8:08 AM, axeld at BerliOS < >> axeld at mail.berlios.de> wrote: >> > -template class StackDeleter { >> > + >> > +template class StackDelete { >> > public: >> > - StackDeleter(Stack* stack) >> Shouldn't that be class StackDeleter? > > StackDelete provides the method that is called upon destruction of the > StackDeleter object. > No I mean, your commit changed the name of the class from StackDeleter to StackDelete while still using the old constructor name and such, unless I read the diff wrong. Regards, Rene From superstippi at gmx.de Fri May 9 15:38:06 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 09 May 2008 15:38:06 +0200 Subject: [Haiku-commits] r25389 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/libroot/os In-Reply-To: References: <200805090132.m491WcV4029372@sheep.berlios.de> <2273060289-BeMail@zon> Message-ID: <20080509153806.769.1@stippis2.1210339488.fake> Rene Gollent wrote: > On Fri, May 9, 2008 at 3:01 AM, Axel D?rfler > wrote: > > Great, this is also something I wanted to do for quite some time :-) > > Now we can change the app_server to create threads with less stack, so > > that it can run many more windows at once :-) > > Just curious, given that we now have wait_for_objects(), wouldn't it > theoretically be feasible to modify the app_server so it's not necessary > to spawn a thread per window any more? The way our setup works, we have a lot of threads (from a percentage POV) that contribute to screen redraw. And there is this automatic equal distribution of time. I am wondring if this is not the secret to BeOS responsiveness, and Haiku inherits this even though the actual drawing is in some situations a lot slower than the BeOS implementation. So personally I would keep it like it is for now, but feel free of course to experiment with alternative implementations. :-) I can recommend starting with a simple prototype, the one I started out with is still in SVN under src/tests/servers/app/newerClipping. Though it could use a cleanup (I think I accidentally commited some experiments I was doing a while back). Best regards, -Stephan From axeld at pinc-software.de Fri May 9 16:07:26 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 16:07:26 +0200 CEST Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util In-Reply-To: Message-ID: <24237384897-BeMail@zon> "Rene Gollent" wrote: > On Fri, May 9, 2008 at 8:29 AM, Axel D?rfler > wrote: > > StackDelete provides the method that is called upon destruction of > > the > > StackDeleter object. > No I mean, your commit changed the name of the class from > StackDeleter > to StackDelete while still using the old constructor name and such, > unless I read the diff wrong. You did :-) Bye, Axel. From anevilyak at gmail.com Fri May 9 16:21:16 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 09:21:16 -0500 Subject: [Haiku-commits] r25395 - haiku/trunk/headers/private/kernel/util In-Reply-To: <24237384897-BeMail@zon> References: <24237384897-BeMail@zon> Message-ID: On Fri, May 9, 2008 at 9:07 AM, Axel D?rfler wrote: > > You did :-) > ....I really shouldn't try to read diffs on 3h sleep :) Sorry for the confusion, Rene From revol at free.fr Fri May 9 17:03:24 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 09 May 2008 17:03:24 +0200 CEST Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support In-Reply-To: <200805082054.m48KsFLJ012454@sheep.berlios.de> Message-ID: <676925156-BeMail@laptop> > Author: bonefish > Date: 2008-05-08 22:54:14 +0200 (Thu, 08 May 2008) > New Revision: 25385 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25385&view=rev > > Modified: > haiku/trunk/headers/os/support/Errors.h > Log: > Changed all error codes from enum values to macros. This allows for > compile time checks. Incidently those are not totally uncommon in > portable code. Are you sure this won't break existing code ? enums are ints but I'm not sure how #defines are handles in some places, wouldn't that allow some bad implicit casts without any warning ? What do you mean by compile-time check ? #ifdef in portable code are only used on POSIX errors which were already #defined... Fran?ois. From bonefish at mail.berlios.de Fri May 9 17:05:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 9 May 2008 17:05:17 +0200 Subject: [Haiku-commits] r25396 - haiku/trunk/src/system/libroot/posix/pthread Message-ID: <200805091505.m49F5H7s007427@sheep.berlios.de> Author: bonefish Date: 2008-05-09 17:05:17 +0200 (Fri, 09 May 2008) New Revision: 25396 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25396&view=rev Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread.c Log: I broke pthreads in r25390. The thread pointer was passed in the wrong argument. Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2008-05-09 13:08:59 UTC (rev 25395) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread.c 2008-05-09 15:05:17 UTC (rev 25396) @@ -118,8 +118,8 @@ attributes.entry = pthread_thread_entry; attributes.name = "pthread func"; attributes.priority = attr->sched_priority; - attributes.args1 = thread; - attributes.args2 = NULL; + attributes.args1 = NULL; + attributes.args2 = thread; attributes.stack_address = NULL; attributes.stack_size = attr->stack_size; From revol at free.fr Fri May 9 17:49:54 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 09 May 2008 17:49:54 +0200 CEST Subject: [Haiku-commits] r25392 - haiku/trunk/src/apps/terminal In-Reply-To: <2064435925-BeMail@zon> Message-ID: <3466821314-BeMail@laptop> > mmu_man at BerliOS wrote: > > Log: > > - SetPosX/Y were wrong, but not yet used. > > - implemented HPA/VPA (CV/CH) sequences (set absolute v and h > > position). It's > > optional but because the beterm termcap advertises it we must > > implement it. Also > > note beterm increments args unlike others. This fixes all obvious > > display issues > > with the rhapsody IRC client (a small ncurses client I ported). > > What about switching to advertize ourselves as "xterm", and add the > additional functionality? We shouldn't be that far away... the only obvious missing thing is the alt graphics charset (there seems to be some code from MuTerm already), which Be's Terminal never supported. This is why every curses app look ugly in BeOS, because they either use +---+ or think it's enabled and send lqqqp... or even undisplayables. In theory UTF-8 has all those already, but they are in a range expressed with more than 1 byte. And of course termcap descriptions handles remapping them but only to 1 byte + a start and end sequence. So we can't have it send UTF-8 for that (maybe recent libs have that fixed ?). Still, some features depart from xterm and others, as I said like VPA and HPA, where we say we take the arg +1. Should be easy to #ifdef BETERM_SUPPORT though, or even have a setting. Ideally we would extend the termcap description, or provide a haiku one, which mean we can even add some funky features to ease integration into the GUI, but that would only end up in our own termcap, not that of all the existing OSes, including R5. > Does vim now work correctly? Ah, well, you probably didn't test that > ;- > )) Didn't it ? What was wrong with it ? Didn't test it recently, no. I would have tested xemacs -nw but I can't yet. Oh dear I'll zip you up the 100MB stuff needed to dump it and let you debug BFS :P Fran?ois. From stippi at mail.berlios.de Fri May 9 17:56:44 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 9 May 2008 17:56:44 +0200 Subject: [Haiku-commits] r25397 - in haiku/trunk/src: add-ons/kernel/file_systems/bfs system/boot/loader/file_systems/bfs Message-ID: <200805091556.m49Fui17012420@sheep.berlios.de> Author: stippi Date: 2008-05-09 17:56:37 +0200 (Fri, 09 May 2008) New Revision: 25397 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25397&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile haiku/trunk/src/system/boot/loader/file_systems/bfs/Jamfile Log: Fix the build. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile 2008-05-09 15:05:17 UTC (rev 25396) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Jamfile 2008-05-09 15:56:37 UTC (rev 25397) @@ -26,6 +26,7 @@ UsePrivateHeaders [ FDirName kernel ] ; # For kernel_cpp.cpp UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; +UsePrivateHeaders [ FDirName shared ] ; UsePrivateHeaders [ FDirName storage ] ; KernelAddon bfs : Modified: haiku/trunk/src/system/boot/loader/file_systems/bfs/Jamfile =================================================================== --- haiku/trunk/src/system/boot/loader/file_systems/bfs/Jamfile 2008-05-09 15:05:17 UTC (rev 25396) +++ haiku/trunk/src/system/boot/loader/file_systems/bfs/Jamfile 2008-05-09 15:56:37 UTC (rev 25397) @@ -2,7 +2,7 @@ UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; UsePrivateHeaders [ FDirName kernel disk_device_manager ] ; -UsePrivateHeaders kernel storage ; +UsePrivateHeaders kernel shared storage ; SubDirHdrs $(HAIKU_TOP) src add-ons kernel file_systems bfs ; From axeld at pinc-software.de Fri May 9 18:09:39 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 18:09:39 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25397_-_in_haiku/trunk/src=3A_add-ons/?= =?utf-8?q?kernel/file=5Fsystems/bfs__system/boot/loader/file=5Fsystems/bf?= =?utf-8?q?s?= In-Reply-To: <200805091556.m49Fui17012420@sheep.berlios.de> Message-ID: <31570846503-BeMail@zon> stippi at BerliOS wrote: > Log: > Fix the build. Thanks, I didn't notice that! Bye, Axel. From ingo_weinhold at gmx.de Fri May 9 18:22:56 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 09 May 2008 18:22:56 +0200 Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support In-Reply-To: <676925156-BeMail@laptop> References: <676925156-BeMail@laptop> Message-ID: <20080509182256.404.1@knochen-vm.1210348621.fake> On 2008-05-09 at 17:03:24 [+0200], Fran?ois Revol wrote: > > Author: bonefish > > Date: 2008-05-08 22:54:14 +0200 (Thu, 08 May 2008) > > New Revision: 25385 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25385&view=rev > > > > Modified: > > haiku/trunk/headers/os/support/Errors.h > > Log: > > Changed all error codes from enum values to macros. This allows for > > compile time checks. Incidently those are not totally uncommon in > > portable code. > > Are you sure this won't break existing code ? > enums are ints but I'm not sure how #defines are handles in some > places, wouldn't that allow some bad implicit casts without any warning > ? The macros are defined to numbers, so they are int by default, too. The only exception is B_OK, since 0 is handled specially by the compiler. I tried to explicitly cast it to int, but at least gcc 2.95.3 (haven't checked with gcc 4) just ignores it. Other than potential new overloading ambiguities for B_OK I can't imagine any problems. > What do you mean by compile-time check ? > #ifdef in portable code are only used on POSIX errors which were > already #defined... Yeah, but since they are defined to enum members, those error codes can't be compared at compile-time. E.g. the check #if EAGAIN != EWOULDBLOCK ... (as used in APR) does work only, if they are defined to numerical values. Apropos error codes. Alas it seems the GNU tools are right assuming that error codes are positive. I hadn't found an evidence that this is required by POSIX before, but it actually is (cf. the errno.h specification). I suppose we should address that problem at some point in the future. CU, Ingo From anevilyak at gmail.com Fri May 9 18:32:28 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 9 May 2008 11:32:28 -0500 Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support In-Reply-To: <20080509182256.404.1@knochen-vm.1210348621.fake> References: <676925156-BeMail@laptop> <20080509182256.404.1@knochen-vm.1210348621.fake> Message-ID: On Fri, May 9, 2008 at 11:22 AM, Ingo Weinhold wrote: > Apropos error codes. Alas it seems the GNU tools are right assuming that > error codes are positive. I hadn't found an evidence that this is required > by POSIX before, but it actually is (cf. the errno.h specification). I > suppose we should address that problem at some point in the future. That seems to be a more recent change: Issue 6 The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification: Values for errno are now required to be distinct positive values rather than non-zero values. This change is for alignment with the ISO/IEC 9899:1999 standard. I'm not sure exactly when that update was made though. Regards, Rene From axeld at pinc-software.de Fri May 9 19:43:08 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 09 May 2008 19:43:08 +0200 CEST Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support In-Reply-To: Message-ID: <37179560993-BeMail@zon> "Rene Gollent" wrote: > On Fri, May 9, 2008 at 11:22 AM, Ingo Weinhold > wrote: > > Apropos error codes. Alas it seems the GNU tools are right assuming > > that > > error codes are positive. I hadn't found an evidence that this is > > required > > by POSIX before, but it actually is (cf. the errno.h > > specification). I > > suppose we should address that problem at some point in the future. > That seems to be a more recent change: > > Issue 6 > > The following new requirements on POSIX implementations derive > from alignment with the Single UNIX Specification: > > Values for errno are now required to be distinct positive values > rather than non-zero values. This change is for alignment with the > ISO/IEC 9899:1999 standard. > > I'm not sure exactly when that update was made though. I can't see what we can do about it either - it would just break everything if we changed that. I find it rather intolerant to make such a change at a time when there were operating systems around that required them to be negative. I also don't really see any advantage in forcing them to be positive. Bye, Axel. From bonefish at mail.berlios.de Fri May 9 20:22:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 9 May 2008 20:22:01 +0200 Subject: [Haiku-commits] r25398 - haiku/trunk/src/system/libroot/posix/arch/x86 Message-ID: <200805091822.m49IM1w8023979@sheep.berlios.de> Author: bonefish Date: 2008-05-09 20:22:01 +0200 (Fri, 09 May 2008) New Revision: 25398 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25398&view=rev Modified: haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S Log: setjmp() must return 1 when a 0 value has been passed to longjmp(). Modified: haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S =================================================================== --- haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S 2008-05-09 15:56:37 UTC (rev 25397) +++ haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S 2008-05-09 18:22:01 UTC (rev 25398) @@ -19,6 +19,12 @@ mov 4(%esp), %ecx mov 8(%esp), %eax + /* If value is 0, setjmp() must return 1. */ + test %eax, %eax + mov $1, %eax + jnz 1f +1: + // restore registers mov JMP_REGS_EBX(%ecx), %ebx mov JMP_REGS_ESI(%ecx), %esi From bonefish at mail.berlios.de Fri May 9 20:23:27 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 9 May 2008 20:23:27 +0200 Subject: [Haiku-commits] r25399 - haiku/trunk/src/system/kernel/vm Message-ID: <200805091823.m49INRAo024036@sheep.berlios.de> Author: bonefish Date: 2008-05-09 20:23:23 +0200 (Fri, 09 May 2008) New Revision: 25399 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25399&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Also align the given size to pages when unmapping memory. Fixes munmap() for non-aligned sizes. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-09 18:22:01 UTC (rev 25398) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-09 18:23:23 UTC (rev 25399) @@ -1198,6 +1198,7 @@ { // TODO: Support deleting partial areas! + size = PAGE_ALIGN(size); addr_t lastAddress = address + (size - 1); // check whether any areas are only partially covered From mmu_man at mail.berlios.de Fri May 9 20:49:47 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 9 May 2008 20:49:47 +0200 Subject: [Haiku-commits] r25400 - haiku/trunk/src/add-ons/kernel/drivers/tty Message-ID: <200805091849.m49InlJh029509@sheep.berlios.de> Author: mmu_man Date: 2008-05-09 20:49:47 +0200 (Fri, 09 May 2008) New Revision: 25400 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25400&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp Log: - mark BeOS-specific ioctls we support for legacy apps, - add 'wsiz' which is a private alias for TIOCSWINSZ, - add some we might want to implement (or not) as reminder, - add hw signal ioctls with a note for later (call driver service func), - implement 'ichr' undocumented ioctl that waits on N chars on input, this fixes behaviour of rhapsody IRC client and many other curses apps. Oddly it seems even our own curses still uses it, that should likely be fixed as we support select(). But we must keep this one in to support apps that have their own curses lib. Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-09 18:23:23 UTC (rev 25399) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-09 18:49:47 UTC (rev 25400) @@ -1319,6 +1319,7 @@ TRACE(("tty_ioctl: tty %p, op %lu, buffer %p, length %lu\n", tty, op, buffer, length)); MutexLocker locker(tty->lock); + // values marked BeOS are non-standard codes we support for legacy apps switch (op) { /* blocking/non-blocking mode */ @@ -1352,8 +1353,9 @@ case TIOCGPGRP: TRACE(("tty: get pgrp_id\n")); return user_memcpy(buffer, &tty->settings->pgrp_id, sizeof(pid_t)); + case TIOCSPGRP: - case 'pgid': + case 'pgid': // BeOS { TRACE(("tty: set pgrp_id\n")); pid_t groupID; @@ -1376,6 +1378,7 @@ sizeof(struct winsize)); case TIOCSWINSZ: + case 'wsiz': // BeOS { uint16 oldColumns = tty->settings->window_size.ws_col; uint16 oldRows = tty->settings->window_size.ws_row; @@ -1420,6 +1423,60 @@ return B_OK; } + + case 'ichr': // BeOS (int *) (pre- select() support) + { + int wanted; + int toRead; + + // help identify apps using it + //dprintf("tty: warning: legacy BeOS opcode 'ichr'\n"); + + if (user_memcpy(&wanted, buffer, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + // release the mutex and grab a read lock + locker.Unlock(); + ReaderLocker readLocker(cookie); + + do { + status_t status = readLocker.AcquireReader(wanted == 0); + if (status != B_OK) + return status; + + toRead = readLocker.AvailableBytes(); + } while (toRead < wanted); + + if (user_memcpy(buffer, &toRead, sizeof(int)) != B_OK) + return B_BAD_ADDRESS; + + return B_OK; + } + + case TCWAITEVENT: // BeOS (uint *) + // wait for event (timeout if !NULL) + case TCVTIME: // BeOS (bigtime_t *) set highrez VTIME + dprintf("tty: unsupported legacy opcode %lu\n", op); + // TODO; + break; + + case TCXONC: // Unix, but even Linux doesn't handle it + dprintf("tty: unsupported TCXONC\n"); + break; + + case TCQUERYCONNECTED: // BeOS + case 'ochr': // BeOS (int *) same as ichr for write + dprintf("tty: unsupported legacy opcode %lu\n", op); + // BeOS didn't implement them anyway + break; + + case TCSETDTR: + case TCSETRTS: + case TCGETBITS: + // TODO: should call the driver service func here, + // for non-virtual tty. + // return tty->driver->service(); + break; } TRACE(("tty: unsupported opcode %lu\n", op)); From jackburton at mail.berlios.de Fri May 9 21:56:25 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 9 May 2008 21:56:25 +0200 Subject: [Haiku-commits] r25401 - haiku/trunk/src/apps/terminal Message-ID: <200805091956.m49JuPMZ002612@sheep.berlios.de> Author: jackburton Date: 2008-05-09 21:56:25 +0200 (Fri, 09 May 2008) New Revision: 25401 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25401&view=rev Modified: haiku/trunk/src/apps/terminal/TermParse.cpp haiku/trunk/src/apps/terminal/VTPrsTbl.c Log: added the g prefix to some global variable Modified: haiku/trunk/src/apps/terminal/TermParse.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermParse.cpp 2008-05-09 18:49:47 UTC (rev 25400) +++ haiku/trunk/src/apps/terminal/TermParse.cpp 2008-05-09 19:56:25 UTC (rev 25401) @@ -27,19 +27,19 @@ ////////////////////////////////////////////////////////////////////////////// -extern int utf8_groundtable[]; /* UTF8 Ground table */ -extern int cs96_groundtable[]; /* CS96 Ground table */ -extern int iso8859_groundtable[]; /* ISO8859 & EUC Ground table */ -extern int sjis_groundtable[]; /* Shift-JIS Ground table */ +extern int gUTF8GroundTable[]; /* UTF8 Ground table */ +extern int gCS96GroundTable[]; /* CS96 Ground table */ +extern int gISO8859GroundTable[]; /* ISO8859 & EUC Ground table */ +extern int gSJISGroundTable[]; /* Shift-JIS Ground table */ -extern int esctable[]; /* ESC */ -extern int csitable[]; /* ESC [ */ -extern int dectable[]; /* ESC [ ? */ -extern int scrtable[]; /* ESC # */ -extern int igntable[]; /* ignore table */ -extern int iestable[]; /* ignore ESC table */ -extern int eigtable[]; /* ESC ignore table */ -extern int mbcstable[]; /* ESC $ */ +extern int gEscTable[]; /* ESC */ +extern int gCsiTable[]; /* ESC [ */ +extern int gDecTable[]; /* ESC [ ? */ +extern int gScrTable[]; /* ESC # */ +extern int gIgnoreTable[]; /* ignore table */ +extern int gIesTable[]; /* ignore ESC table */ +extern int gEscIgnoreTable[]; /* ESC ignore table */ +extern int gMbcsTable[]; /* ESC $ */ @@ -302,7 +302,7 @@ int row, col; /* default coding system is UTF8 */ - int *groundtable = utf8_groundtable; + int *groundtable = gUTF8GroundTable; int *parsestate = groundtable; while (!fQuitting) { @@ -325,19 +325,19 @@ case B_ISO8_CONVERSION: case B_ISO9_CONVERSION: case B_ISO10_CONVERSION: - groundtable = iso8859_groundtable; + groundtable = gISO8859GroundTable; break; case B_SJIS_CONVERSION: - groundtable = sjis_groundtable; + groundtable = gSJISGroundTable; break; case B_EUC_CONVERSION: case B_EUC_KR_CONVERSION: case B_JIS_CONVERSION: - groundtable = iso8859_groundtable; + groundtable = gISO8859GroundTable; break; case M_UTF8: default: - groundtable = utf8_groundtable; + groundtable = gUTF8GroundTable; break; } parsestate = groundtable; @@ -452,12 +452,12 @@ case CASE_MBCS: /* ESC $ */ - parsestate = mbcstable; + parsestate = gMbcsTable; break; case CASE_GSETS: /* ESC $ ? */ - parsestate = cs96_groundtable; + parsestate = gCS96GroundTable; cs96 = 1; break; @@ -490,17 +490,17 @@ case CASE_ESC: /* escape */ - parsestate = esctable; + parsestate = gEscTable; break; case CASE_IGNORE_STATE: /* Ies: ignore anything else */ - parsestate = igntable; + parsestate = gIgnoreTable; break; case CASE_IGNORE_ESC: /* Ign: escape */ - parsestate = iestable; + parsestate = gIesTable; break; case CASE_IGNORE: @@ -515,12 +515,12 @@ case CASE_SCR_STATE: // ESC # /* enter scr state */ - parsestate = scrtable; + parsestate = gScrTable; break; case CASE_ESC_IGNORE: /* unknown escape sequence */ - parsestate = eigtable; + parsestate = gEscIgnoreTable; break; case CASE_ESC_DIGIT: // ESC [ number @@ -538,7 +538,7 @@ case CASE_DEC_STATE: /* enter dec mode */ - parsestate = dectable; + parsestate = gDecTable; break; case CASE_ICH: // ESC [@ insert charactor @@ -810,7 +810,7 @@ /* enter csi state */ nparam = 1; param[0] = DEFAULT; - parsestate = csitable; + parsestate = gCsiTable; break; case CASE_OSC: Modified: haiku/trunk/src/apps/terminal/VTPrsTbl.c =================================================================== --- haiku/trunk/src/apps/terminal/VTPrsTbl.c 2008-05-09 18:49:47 UTC (rev 25400) +++ haiku/trunk/src/apps/terminal/VTPrsTbl.c 2008-05-09 19:56:25 UTC (rev 25401) @@ -33,7 +33,7 @@ #define USE_MBCS #define USE_ISO2022 -int utf8_groundtable[] = /* UTF8 coding ground table */ +int gUTF8GroundTable[] = /* UTF8 coding ground table */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -357,7 +357,7 @@ CASE_UTF8_3BYTE, }; -int cs96_groundtable[] = /* charset 96 table */ +int gCS96GroundTable[] = /* charset 96 table */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -681,7 +681,7 @@ CASE_IGNORE, }; -int iso8859_groundtable[] = +int gISO8859GroundTable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -1005,7 +1005,7 @@ CASE_PRINT_GR, }; -int csitable[] = /* ESC [ */ +int gCsiTable[] = /* ESC [ */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -1329,7 +1329,7 @@ CASE_GROUND_STATE, }; -int dectable[] = /* ESC [ ? */ +int gDecTable[] = /* ESC [ ? */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -1670,7 +1670,7 @@ CASE_GROUND_STATE, }; -int eigtable[] = /* CASE_ESC_IGNORE */ +int gEscIgnoreTable[] = /* CASE_ESC_IGNORE */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -1995,7 +1995,7 @@ CASE_GROUND_STATE, }; -int esctable[] = /* ESC */ +int gEscTable[] = /* ESC */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -2337,7 +2337,7 @@ CASE_GROUND_STATE, }; -int iestable[] = /* CASE_IGNORE_ESC */ +int gIesTable[] = /* CASE_IGNORE_ESC */ { /* NUL SOH STX ETX */ CASE_IGNORE_STATE, @@ -2661,7 +2661,7 @@ CASE_GROUND_STATE, }; -int igntable[] = /* CASE_IGNORE_STATE */ +int gIgnoreTable[] = /* CASE_IGNORE_STATE */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -2985,7 +2985,7 @@ CASE_GROUND_STATE, }; -int scrtable[] = /* ESC # */ +int gScrTable[] = /* ESC # */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -3309,7 +3309,7 @@ CASE_GROUND_STATE, }; -int scstable[] = /* ESC ( etc. */ +int gScsTable[] = /* ESC ( etc. */ { /* NUL SOH STX ETX */ CASE_IGNORE, @@ -3737,7 +3737,7 @@ }; #ifdef USE_MBCS -int mbcstable[] = { +int gMbcsTable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, @@ -4060,7 +4060,7 @@ CASE_GROUND_STATE, }; -int smbcstable[] = { +int gSmbcsTable[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, @@ -4385,7 +4385,7 @@ #endif -int sjis_groundtable[] = /* Shift-JIS ground table. */ +int gSJISGroundTable[] = /* Shift-JIS ground table. */ { /* NUL SOH STX ETX */ CASE_IGNORE, From korli at mail.berlios.de Fri May 9 22:26:56 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 9 May 2008 22:26:56 +0200 Subject: [Haiku-commits] r25402 - haiku/trunk/src/data/etc/timezones Message-ID: <200805092026.m49KQuGn006333@sheep.berlios.de> Author: korli Date: 2008-05-09 22:26:56 +0200 (Fri, 09 May 2008) New Revision: 25402 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25402&view=rev Modified: haiku/trunk/src/data/etc/timezones/africa haiku/trunk/src/data/etc/timezones/asia haiku/trunk/src/data/etc/timezones/backward haiku/trunk/src/data/etc/timezones/europe haiku/trunk/src/data/etc/timezones/iso3166.tab haiku/trunk/src/data/etc/timezones/leapseconds haiku/trunk/src/data/etc/timezones/northamerica haiku/trunk/src/data/etc/timezones/southamerica haiku/trunk/src/data/etc/timezones/zone.tab Log: update to tzdata2008b Modified: haiku/trunk/src/data/etc/timezones/africa =================================================================== --- haiku/trunk/src/data/etc/timezones/africa 2008-05-09 19:56:25 UTC (rev 25401) +++ haiku/trunk/src/data/etc/timezones/africa 2008-05-09 20:26:56 UTC (rev 25402) @@ -1,4 +1,4 @@ -# @(#)africa 8.9 +# @(#)africa 8.10 #
 
 # This data is by no means authoritative; if you think you know better,
@@ -224,9 +224,19 @@
 # From Jesper Norgaard Welen (2007-08-15): [The following agree:]
 # http://www.nentjes.info/Bill/bill5.htm 
 # http://www.timeanddate.com/worldclock/city.html?n=53
+# From Steffen Thorsen (2007-09-04): The official information...:
+# http://www.sis.gov.eg/En/EgyptOnline/Miscellaneous/000002/0207000000000000001580.htm
+Rule	Egypt	2007	only	-	Sep	Thu>=1	23:00s	0	-
+# From Abdelrahman Hassan (2007-09-06):
+# Due to the Hijri (lunar Islamic calendar) year being 11 days shorter
+# than the year of the Gregorian calendar, Ramadan shifts earlier each
+# year. This year it will be observed September 13 (September is quite
+# hot in Egypt), and the idea is to make fasting easier for workers by
+# shifting business hours one hour out of daytime heat. Consequently,
+# unless discontinued, next DST may end Thursday 28 August 2008.
 # From Paul Eggert (2007-08-17):
-# For lack of better info, assume the new rule is first Thursday.
-Rule	Egypt	2007	max	-	Sep	Thu>=1	23:00s	0	-
+# For lack of better info, assume the new rule is last Thursday in August.
+Rule	Egypt	2008	max	-	Aug	lastThu	23:00s	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Cairo	2:05:00 -	LMT	1900 Oct

Modified: haiku/trunk/src/data/etc/timezones/asia
===================================================================
--- haiku/trunk/src/data/etc/timezones/asia	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/asia	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)asia	8.11
+# @(#)asia	8.18
 # 
 
 # This data is by no means authoritative; if you think you know better,
@@ -446,13 +446,13 @@
 
 # India
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Calcutta	5:53:28 -	LMT	1880	# Kolkata
+Zone	Asia/Kolkata	5:53:28 -	LMT	1880	# Kolkata
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
 			6:30	-	BURT	1942 May 15 # Burma Time
 			5:30	-	IST	1942 Sep
 			5:30	1:00	IST	1945 Oct 15
 			5:30	-	IST
-# The following are like Asia/Calcutta:
+# The following are like Asia/Kolkata:
 #	Andaman Is
 #	Lakshadweep (Laccadive, Minicoy and Amindivi Is)
 #	Nicobar Is
@@ -568,14 +568,24 @@
 # Reingold's/Dershowitz' calculator gives correctly the Gregorian date
 # 2058-03-21 for 1 Farvardin 1437 (astronomical).
 #
-# From Paul Eggert (2006-03-22):
-# The above comments about post-2006 transitions may become relevant again,
-# if Iran ever resuscitates DST, so we'll leave the comments in.
-#
 # From Steffen Thorsen (2006-03-22):
 # Several of my users have reported that Iran will not observe DST anymore:
 # http://www.irna.ir/en/news/view/line-17/0603193812164948.htm
 #
+# From Reuters (2007-09-16), with a heads-up from Jesper Norgaard Welen:
+# ... the Guardian Council ... approved a law on Sunday to re-introduce
+# daylight saving time ...
+# http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916
+#
+# From Roozbeh Pournader (2007-11-05):
+# This is quoted from Official Gazette of the Islamic Republic of
+# Iran, Volume 63, Number 18242, dated Tuesday 1386/6/24
+# [2007-10-16]. I am doing the best translation I can:...
+# The official time of the country will be moved forward for one hour
+# on the 24 hours of the first day of the month of Farvardin and will
+# be changed back to its previous state on the 24 hours of the
+# thirtieth day of Shahrivar.
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Iran	1978	1980	-	Mar	21	0:00	1:00	D
 Rule	Iran	1978	only	-	Oct	21	0:00	0	S
@@ -596,6 +606,36 @@
 Rule	Iran	2004	only	-	Sep	21	0:00	0	S
 Rule	Iran	2005	only	-	Mar	22	0:00	1:00	D
 Rule	Iran	2005	only	-	Sep	22	0:00	0	S
+Rule	Iran	2008	only	-	Mar	21	0:00	1:00	D
+Rule	Iran	2008	only	-	Sep	21	0:00	0	S
+Rule	Iran	2009	2011	-	Mar	22	0:00	1:00	D
+Rule	Iran	2009	2011	-	Sep	22	0:00	0	S
+Rule	Iran	2012	only	-	Mar	21	0:00	1:00	D
+Rule	Iran	2012	only	-	Sep	21	0:00	0	S
+Rule	Iran	2013	2015	-	Mar	22	0:00	1:00	D
+Rule	Iran	2013	2015	-	Sep	22	0:00	0	S
+Rule	Iran	2016	only	-	Mar	21	0:00	1:00	D
+Rule	Iran	2016	only	-	Sep	21	0:00	0	S
+Rule	Iran	2017	2019	-	Mar	22	0:00	1:00	D
+Rule	Iran	2017	2019	-	Sep	22	0:00	0	S
+Rule	Iran	2020	only	-	Mar	21	0:00	1:00	D
+Rule	Iran	2020	only	-	Sep	21	0:00	0	S
+Rule	Iran	2021	2023	-	Mar	22	0:00	1:00	D
+Rule	Iran	2021	2023	-	Sep	22	0:00	0	S
+Rule	Iran	2024	only	-	Mar	21	0:00	1:00	D
+Rule	Iran	2024	only	-	Sep	21	0:00	0	S
+Rule	Iran	2025	2027	-	Mar	22	0:00	1:00	D
+Rule	Iran	2025	2027	-	Sep	22	0:00	0	S
+Rule	Iran	2028	2029	-	Mar	21	0:00	1:00	D
+Rule	Iran	2028	2029	-	Sep	21	0:00	0	S
+Rule	Iran	2030	2031	-	Mar	22	0:00	1:00	D
+Rule	Iran	2030	2031	-	Sep	22	0:00	0	S
+Rule	Iran	2032	2033	-	Mar	21	0:00	1:00	D
+Rule	Iran	2032	2033	-	Sep	21	0:00	0	S
+Rule	Iran	2034	2035	-	Mar	22	0:00	1:00	D
+Rule	Iran	2034	2035	-	Sep	22	0:00	0	S
+Rule	Iran	2036	2037	-	Mar	21	0:00	1:00	D
+Rule	Iran	2036	2037	-	Sep	21	0:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tehran	3:25:44	-	LMT	1916
 			3:25:44	-	TMT	1946	# Tehran Mean Time
@@ -620,6 +660,21 @@
 #
 # So we'll ignore the Economist's claim.
 
+# From Steffen Thorsen (2008-03-10):
+# The cabinet in Iraq abolished DST last week, according to the following
+# news sources (in Arabic):
+# 
+# http://www.aljeeran.net/wesima_articles/news-20080305-98602.html
+# 
+# 
+# http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10
+# 
+#
+# We have published a short article in English about the change:
+# 
+# http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html
+# 
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Iraq	1982	only	-	May	1	0:00	1:00	D
 Rule	Iraq	1982	1984	-	Oct	1	0:00	0	S
@@ -630,8 +685,8 @@
 # IATA SSIM (1991/1996) says Apr 1 12:01am UTC; guess the `:01' is a typo.
 # Shanks & Pottenger say Iraq did not observe DST 1992/1997; ignore this.
 #
-Rule	Iraq	1991	max	-	Apr	 1	3:00s	1:00	D
-Rule	Iraq	1991	max	-	Oct	 1	3:00s	0	S
+Rule	Iraq	1991	2007	-	Apr	 1	3:00s	1:00	D
+Rule	Iraq	1991	2007	-	Oct	 1	3:00s	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Baghdad	2:57:40	-	LMT	1890
 			2:57:36	-	BMT	1918	    # Baghdad Mean Time?
@@ -1518,6 +1573,17 @@
 # I guess it is likely that next year's date will be moved as well,
 # because of the Ramadan.
 
+# From Jesper Norgaard Welen (2007-09-18):
+# According to Steffen Thorsen's web site the Gaza Strip and the rest of the
+# Palestinian territories left DST early on 13.th. of September at 2:00.
+
+# From Paul Eggert (2007-09-20):
+# My understanding is that Gaza and the West Bank disagree even over when
+# the weekend is (Thursday+Friday versus Friday+Saturday), so I'd be a bit
+# surprised if they agreed about DST.  But for now, assume they agree.
+# For lack of better information, predict that future changes will be
+# the 2nd Thursday of September at 02:00.
+
 # The rules for Egypt are stolen from the `africa' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
@@ -1533,7 +1599,7 @@
 Rule Palestine	2005	only	-	Oct	 4	2:00	0	-
 Rule Palestine	2006	max	-	Apr	 1	0:00	1:00	S
 Rule Palestine	2006	only	-	Sep	22	0:00	0	-
-Rule Palestine	2007	max	-	Oct	Fri>=15	0:00	0	-
+Rule Palestine	2007	max	-	Sep	Thu>=8	2:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
@@ -1636,7 +1702,7 @@
 # kept their clocks set five and a half hours ahead of Greenwich Mean
 # Time (GMT), in line with neighbor India.
 # From Paul Eggert (2006-04-18):
-# People who live in regions under Tamil control can use TZ='Asia/Calcutta',
+# People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],
 # as that zone has agreed with the Tamil areas since our cutoff date of 1970.
 
 # From K Sethu (2006-04-25):
@@ -1726,10 +1792,62 @@
 # From Paul Eggert (2007-03-29):
 # Today the AP reported "Syria will switch to summertime at midnight Thursday."
 # http://www.iht.com/articles/ap/2007/03/29/africa/ME-GEN-Syria-Time-Change.php
-# For lack of better info, assume the rule changed to "last Friday in March"
-# this year.
-Rule	Syria	2007	max	-	Mar	lastFri	0:00	1:00	S
-Rule	Syria	2007	max	-	Oct	 1	0:00	0	-
+Rule	Syria	2007	only	-	Mar	lastFri	0:00	1:00	S
+# From Jesper Norgard (2007-10-27):
+# The sister center ICARDA of my work CIMMYT is confirming that Syria DST will
+# not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or
+# rather Midnight between Thursday and Friday. This does make more sence than
+# having it between Wednesday and Thursday (two workdays in Syria) since the
+# weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now
+# it is implemented at midnight of the last workday before weekend...
+# 
+# From Steffen Thorsen (2007-10-27):
+# Jesper Norgaard Welen wrote:
+# 
+# > "Winter local time in Syria will be observed at midnight of Thursday 1
+# > November 2007, and the clock will be put back 1 hour."
+# 
+# I found confirmation on this in this gov.sy-article (Arabic):
+# http://wehda.alwehda.gov.sy/_print_veiw.asp?FileName=12521710520070926111247
+# 
+# which using Google's translate tools says:
+# Council of Ministers also approved the commencement of work on 
+# identifying the winter time as of Friday, 2/11/2007 where the 60th 
+# minute delay at midnight Thursday 1/11/2007.
+Rule	Syria	2007	only	-	Nov	 Fri>=1	0:00	0	-
+
+# From Stephen Colebourne (2008-03-17):
+# For everyone's info, I saw an IATA time zone change for [Syria] for
+# this month (March 2008) in the last day or so...This is the data IATA
+# are now using:
+# Country     Time Standard   --- DST Start ---   --- DST End ---  DST
+# Name        Zone Variation   Time    Date        Time    Date
+# Variation
+# Syrian Arab
+# Republic    SY    +0200      2200  03APR08       2100  30SEP08   +0300
+#                              2200  02APR09       2100  30SEP09   +0300
+#                              2200  01APR10       2100  30SEP10   +0300
+
+# From Arthur David Olson (2008-03-17):
+# Here's a link to English-language coverage by the Syrian Arab News
+# Agency (SANA)...
+# 
+# http://www.sana.sy/eng/21/2008/03/11/165173.htm
+# ...which reads (in part) "The Cabinet approved the suggestion of the
+# Ministry of Electricity to begin daylight savings time on Friday April
+# 4th, advancing clocks one hour ahead on midnight of Thursday April 3rd."
+# Since Syria is two hours east of UTC, the 2200 and 2100 transition times
+# shown above match up with midnight in Syria.
+
+# From Arthur David Olson (2008-03-18):
+# My buest guess at a Syrian rule is "the Friday nearest April 1";
+# coding that involves either using a "Mar Fri>=29" construct that old time zone
+# compilers can't handle  or having multiple Rules (a la Israel).
+# For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end.
+
+Rule	Syria	2008	max	-	Apr	Fri>=1	0:00	1:00	S
+Rule	Syria	2008	max	-	Oct	1	0:00	0	-
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Damascus	2:25:12 -	LMT	1920	# Dimashq
 			2:00	Syria	EE%sT
@@ -1783,13 +1901,13 @@
 
 # Vietnam
 
-# From Paul Eggert (1993-11-18):
-# Saigon's official name is Thanh-Pho Ho Chi Minh, but it's too long.
-# We'll stick with the traditional name for now.
+# From Arthur David Olson (2008-03-18):
+# The English-language name of Vietnam's most populous city is "Ho Chi Min City";
+# we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
 
 # From Shanks & Pottenger:
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	Asia/Saigon	7:06:40 -	LMT	1906 Jun  9
+Zone	Asia/Ho_Chi_Minh	7:06:40 -	LMT	1906 Jun  9
 			7:06:20	-	SMT	1911 Mar 11 0:01 # Saigon MT?
 			7:00	-	ICT	1912 May
 			8:00	-	ICT	1931 May

Modified: haiku/trunk/src/data/etc/timezones/backward
===================================================================
--- haiku/trunk/src/data/etc/timezones/backward	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/backward	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)backward	8.3
+# @(#)backward	8.6
 
 # This file provides links between current names for time zones
 # and their old names.  Many names changed in late 1993.
@@ -24,12 +24,15 @@
 Link	Asia/Ashgabat		Asia/Ashkhabad
 Link	Asia/Chongqing		Asia/Chungking
 Link	Asia/Dhaka		Asia/Dacca
+Link	Asia/Kolkata		Asia/Calcutta
 Link	Asia/Macau		Asia/Macao
 Link	Asia/Jerusalem		Asia/Tel_Aviv
+Link	Asia/Ho_Chi_Minh	Asia/Saigon
 Link	Asia/Thimphu		Asia/Thimbu
 Link	Asia/Makassar		Asia/Ujung_Pandang
 Link	Asia/Ulaanbaatar	Asia/Ulan_Bator
 Link	Atlantic/Faroe		Atlantic/Faeroe
+Link	Europe/Oslo		Atlantic/Jan_Mayen
 Link	Australia/Sydney	Australia/ACT
 Link	Australia/Sydney	Australia/Canberra
 Link	Australia/Lord_Howe	Australia/LHI

Modified: haiku/trunk/src/data/etc/timezones/europe
===================================================================
--- haiku/trunk/src/data/etc/timezones/europe	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/europe	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)europe	8.11
+# @(#)europe	8.12
 # 
 
 # This data is by no means authoritative; if you think you know better,
@@ -1714,7 +1714,6 @@
 # come up with more definitive info about the timekeeping during the
 # war years it's probably best just do do the following for now:
 Link	Europe/Oslo	Arctic/Longyearbyen
-Link	Europe/Oslo	Atlantic/Jan_Mayen
 
 # Poland
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S

Modified: haiku/trunk/src/data/etc/timezones/iso3166.tab
===================================================================
--- haiku/trunk/src/data/etc/timezones/iso3166.tab	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/iso3166.tab	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,12 +1,12 @@
 # ISO 3166 alpha-2 country codes
 #
-# @(#)iso3166.tab	8.4
+# @(#)iso3166.tab	8.5
 #
 # From Paul Eggert (2006-09-27):
 #
 # This file contains a table with the following columns:
 # 1.  ISO 3166-1 alpha-2 country code, current as of
-#     ISO 3166-1 Newsletter No. V-12 (2006-09-26).  See:
+#     ISO 3166-1 Newsletter VI-1 (2007-09-21).  See:
 #     
 #     ISO 3166 Maintenance agency (ISO 3166/MA)
 #     .
@@ -47,6 +47,7 @@
 BH	Bahrain
 BI	Burundi
 BJ	Benin
+BL	St Barthelemy
 BM	Bermuda
 BN	Brunei
 BO	Bolivia
@@ -159,6 +160,7 @@
 MC	Monaco
 MD	Moldova
 ME	Montenegro
+MF	St Martin (French part)
 MG	Madagascar
 MH	Marshall Islands
 MK	Macedonia

Modified: haiku/trunk/src/data/etc/timezones/leapseconds
===================================================================
--- haiku/trunk/src/data/etc/timezones/leapseconds	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/leapseconds	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)leapseconds	8.4
+# @(#)leapseconds	8.5
 
 # Allowance for leapseconds added to each timezone file.
 
@@ -46,26 +46,27 @@
 Leap	2005	Dec	31	23:59:60	+	S
 
 # INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
+#
 # SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE
 #
 # SERVICE DE LA ROTATION TERRESTRE
-# OBSERVATOIRE DE PARIS
+# OBSERVATOIRE DE PARIS				
 # 61, Av. de l'Observatoire 75014 PARIS (France)
 # Tel.      : 33 (0) 1 40 51 22 26
 # FAX       : 33 (0) 1 40 51 22 91
 # Internet  : services.iers at obspm.fr
 #
-# Paris, 28 June 2007
+# Paris, 18 January 2008
 #
-# Bulletin C 34
+# Bulletin C 35
 #
-# To authorities responsible
+# To authorities responsible		
 # for the measurement and
-# distribution of time
+# distribution of time	
 #
 # INFORMATION ON UTC - TAI
 #
-# NO positive leap second will be introduced at the end of December 2007.
+# NO positive leap second will be introduced at the end of June 2008.
 # The difference between Coordinated Universal Time UTC and the
 # International Atomic Time TAI is :		
 #
@@ -77,6 +78,6 @@
 # will be no time step at the next possible date.
 #
 # Daniel GAMBIS
-# Director			
-# Earth Orientation Center of IERS
+# Head			
+# Earth Orientation Center of the IERS
 # Observatoire de Paris, France

Modified: haiku/trunk/src/data/etc/timezones/northamerica
===================================================================
--- haiku/trunk/src/data/etc/timezones/northamerica	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/northamerica	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)northamerica	8.18
+# @(#)northamerica	8.23
 # 
 
 # also includes Central America and the Caribbean
@@ -2187,7 +2187,70 @@
 # says Cuban clocks will advance at midnight on March 10.
 # For lack of better information, assume Cuba will use US rules,
 # except that it switches at midnight standard time as usual.
+#
+# From Steffen Thorsen (2007-10-25):
+# Carlos Alberto Fonseca Arauz informed me that Cuba will end DST one week 
+# earlier - on the last Sunday of October, just like in 2006.
+# 
+# He supplied these references:
+# 
+# http://www.prensalatina.com.mx/article.asp?ID=%7B4CC32C1B-A9F7-42FB-8A07-8631AFC923AF%7D&language=ES
+# http://actualidad.terra.es/sociedad/articulo/cuba_llama_ahorrar_energia_cambio_1957044.htm
+# 
+# From Alex Kryvenishev (2007-10-25):
+# Here is also article from Granma (Cuba):
+# 
+# [Regira] el Horario Normal desde el [proximo] domingo 28 de octubre
+# http://www.granma.cubaweb.cu/2007/10/24/nacional/artic07.html
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_cuba03.html
 
+# From Arthur David Olson (2008-03-09):
+# I'm in Maryland which is now observing United States Eastern Daylight
+# Time. At 9:44 local time I used RealPlayer to listen to
+# 
+# http://media.enet.cu/radioreloj
+# , a Cuban information station, and heard
+# the time announced as "ocho cuarenta y cuatro" ("eight forty-four"),
+# indicating that Cuba is still on standard time.
+
+# From Steffen Thorsen (2008-03-12):
+# It seems that Cuba will start DST on Sunday, 2007-03-16...
+# It was announced yesterday, according to this source (in Spanish):
+# 
+# http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm
+# 
+#
+# Some more background information is posted here:
+# 
+# http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html
+# 
+#
+# The article also says that Cuba has been observing DST since 1963,
+# while Shanks (and tzdata) has 1965 as the first date (except in the
+# 1940's). Many other web pages in Cuba also claim that it has been
+# observed since 1963, but with the exception of 1970 - an exception
+# which is not present in tzdata/Shanks. So there is a chance we need to
+# change some historic records as well.
+#
+# One example:
+# 
+# http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm
+# 
+
+# From Jesper Norgaard Welen (2008-03-13):
+# The Cuban time change has just been confirmed on the most authoritative
+# web site, the Granma.  Please check out
+# 
+# http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html
+# 
+#
+# Basically as expected after Steffen Thorsens information, the change
+# will take place midnight between Saturday and Sunday.
+
+# From Arthur David Olson (2008-03-12):
+# Assume Sun>=15 (third Sunday) going forward.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Cuba	1928	only	-	Jun	10	0:00	1:00	D
 Rule	Cuba	1928	only	-	Oct	10	0:00	0	S
@@ -2218,9 +2281,9 @@
 Rule	Cuba	1998	1999	-	Mar	lastSun	0:00s	1:00	D
 Rule	Cuba	1998	2003	-	Oct	lastSun	0:00s	0	S
 Rule	Cuba	2000	2006	-	Apr	Sun>=1	0:00s	1:00	D
-Rule	Cuba	2006	only	-	Oct	lastSun	0:00s	0	S
-Rule	Cuba	2007	max	-	Mar	Sun>=8	0:00s	1:00	D
-Rule	Cuba	2007	max	-	Nov	Sun>=1	0:00s	0	S
+Rule	Cuba	2006	max	-	Oct	lastSun	0:00s	0	S
+Rule	Cuba	2007	only	-	Mar	Sun>=8	0:00s	1:00	D
+Rule	Cuba	2008	max	-	Mar	Sun>=15	0:00s	1:00	D
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Havana	-5:29:28 -	LMT	1890
@@ -2287,6 +2350,10 @@
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Guadeloupe	-4:06:08 -	LMT	1911 Jun 8	# Pointe a Pitre
 			-4:00	-	AST
+# St Barthelemy
+Link America/Guadeloupe	America/St_Barthelemy
+# St Martin (French part)
+Link America/Guadeloupe	America/Marigot
 
 # Guatemala
 #

Modified: haiku/trunk/src/data/etc/timezones/southamerica
===================================================================
--- haiku/trunk/src/data/etc/timezones/southamerica	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/southamerica	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)southamerica	8.11
+# @(#)southamerica	8.19
 # 
 
 # This data is by no means authoritative; if you think you know better,
@@ -105,7 +105,11 @@
 # which did not result in the switch of a time zone, as they stayed 9 hours
 # from the International Date Line.
 Rule	Arg	1999	only	-	Oct	Sun>=1	0:00	1:00	S
-Rule	Arg	2000	only	-	Mar	Sun>=1	0:00	0	-
+# From Paul Eggert (2007-12-28):
+# DST was set to expire on March 5, not March 3, but since it was converted
+# to standard time on March 3 it's more convenient for us to pretend that
+# it ended on March 3.
+Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 #
 # From Peter Gradelski via Steffen Thorsen (2000-03-01):
 # We just checked with our Sao Paulo office and they say the government of
@@ -140,6 +144,30 @@
 # This kind of things had always been done this way in Argentina.
 # We are still -03:00 all year round in all of the country.
 #
+# From Steffen Thorsen (2007-12-21):
+# A user (Leonardo Chaim) reported that Argentina will adopt DST....
+# all of the country (all Zone-entries) are affected.  News reports like
+# http://www.lanacion.com.ar/opinion/nota.asp?nota_id=973037 indicate
+# that Argentina will use DST next year as well, from October to
+# March, although exact rules are not given.
+#
+# From Jesper Norgaard Welen (2007-12-26)
+# The last hurdle of Argentina DST is over, the proposal was approved in
+# the lower chamber too (Deputados) with a vote 192 for and 2 against.
+# By the way thanks to Mariano Absatz and Daniel Mario Vega for the link to
+# the original scanned proposal, where the dates and the zero hours are
+# clear and unambiguous...This is the article about final approval:
+# 
+# http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996
+# 
+#
+# From Paul Eggert (2007-12-22):
+# For dates after mid-2008, the following rules are my guesses and
+# are quite possibly wrong, but are more likely than no DST at all.
+Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
+Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
+Rule	Arg	2008	max	-	Oct	Sun>=1	0:00	1:00	S
+ 
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
 # its timezone this winter... starting tomorrow night....
@@ -200,6 +228,76 @@
 # http://www.sanjuan.gov.ar/prensa/archivo/000426.html
 # http://www.sanjuan.gov.ar/prensa/archivo/000441.html
 
+# From Alex Krivenyshev (2008-01-17):
+# Here are articles that Argentina Province San Luis is planning to end DST
+# as earlier as upcoming Monday January 21, 2008 or February 2008:
+#
+# Provincia argentina retrasa reloj y marca diferencia con resto del pais
+# (Argentine Province delayed clock and mark difference with the rest of the
+# country)
+# 
+# http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel
+# 
+#
+# Es inminente que en San Luis atrasen una hora los relojes
+# (It is imminent in San Luis clocks one hour delay)
+# 
+# http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414
+# 
+#
+# 
+# http://www.worldtimezone.net/dst_news/dst_news_argentina02.html
+# 
+
+# From Jesper Norgaard Welen (2008-01-18):
+# The page of the San Luis provincial government
+# 
+# http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812
+# 
+# confirms what Alex Krivenyshev has earlier sent to the tz
+# emailing list about that San Luis plans to return to standard
+# time much earlier than the rest of the country. It also
+# confirms that upon request the provinces San Juan and Mendoza 
+# refused to follow San Luis in this change. 
+# 
+# The change is supposed to take place Monday the 21.st at 0:00
+# hours. As far as I understand it if this goes ahead, we need
+# a new timezone for San Luis (although there are also documented
+# independent changes in the southamerica file of San Luis in
+# 1990 and 1991 which has not been confirmed).
+
+# From Jesper Norgaard Welen (2008-01-25):
+# Unfortunately the below page has become defunct, about the San Luis
+# time change. Perhaps because it now is part of a group of pages "Most
+# important pages of 2008."
+#
+# You can use
+# 
+# http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834
+# 
+# instead it seems. Or use "Buscador" from the main page of the San Luis
+# government, and fill in "huso" and click OK, and you will get 3 pages
+# from which the first one is identical to the above.
+
+# From Mariano Absatz (2008-01-28):
+# I can confirm that the Province of San Luis (and so far only that
+# province) decided to go back to UTC-3 effective midnight Jan 20th 2008
+# (that is, Monday 21st at 0:00 is the time the clocks were delayed back
+# 1 hour), and they intend to keep UTC-3 as their timezone all year round
+# (that is, unless they change their mind any minute now).
+#
+# So we'll have to add yet another city to 'southamerica' (I think San
+# Luis city is the mos populated city in the Province, so it'd be
+# America/Argentina/San_Luis... of course I can't remember if San Luis's
+# history of particular changes goes along with Mendoza or San Juan :-(
+# (I only remember not being able to collect hard facts about San Luis
+# back in 2004, when these provinces changed to UTC-4 for a few days, I
+# mailed them personally and never got an answer).
+
+# From Arthur David Olson (2008-03-15):
+# Until there's better information, asssume San Luis was like San Juan
+# rather than Mendoza (since San Juan has a simpler DST history).
+
 # Unless otherwise specified, data are from Shanks & Pottenger through 1992,
 # from the IATA otherwise.  As noted below, Shanks & Pottenger say that
 # America/Cordoba split into 6 subregions during 1991/1992, but we
@@ -214,7 +312,7 @@
 			-4:00	Arg	AR%sT	1969 Oct  5
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN), Chaco (CC),
 # Formosa (FM), Salta (SA), Santiago del Estero (SE), Cordoba (CB),
@@ -237,7 +335,7 @@
 			-4:00	-	WART	1991 Oct 20
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Tucuman (TM)
 Zone America/Argentina/Tucuman -4:20:52 - LMT	1894 Oct 31
@@ -250,7 +348,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 13
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # La Rioja (LR)
 Zone America/Argentina/La_Rioja -4:27:24 - LMT	1894 Oct 31
@@ -263,7 +361,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # San Juan (SJ)
 Zone America/Argentina/San_Juan -4:34:04 - LMT	1894 Oct 31
@@ -276,7 +374,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Jujuy (JY)
 Zone America/Argentina/Jujuy -4:21:12 -	LMT	1894 Oct 31
@@ -290,7 +388,7 @@
 			-3:00	1:00	ARST	1992
 			-3:00	Arg	AR%sT	1999 Oct  3
 			-4:00	Arg	AR%sT	2000 Mar  3
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Catamarca (CT), Chubut (CH)
 Zone America/Argentina/Catamarca -4:23:08 - LMT	1894 Oct 31
@@ -303,7 +401,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Mendoza (MZ)
 Zone America/Argentina/Mendoza -4:35:16 - LMT	1894 Oct 31
@@ -320,6 +418,20 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 23
 			-4:00	-	WART	2004 Sep 26
+			-3:00	Arg	AR%sT
+#
+# San Luis (SL)
+Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
+			-4:16:48 -	CMT	1920 May
+			-4:00	-	ART	1930 Dec
+			-4:00	Arg	AR%sT	1969 Oct  5
+			-3:00	Arg	AR%sT	1991 Mar  1
+			-4:00	-	WART	1991 May  7
+			-3:00	Arg	AR%sT	1999 Oct  3
+			-4:00	Arg	AR%sT	2000 Mar  3
+			-3:00	-	ART	2004 May 31
+			-4:00	-	WART	2004 Jul 25
+			-3:00	Arg	AR%sT	2008 Jan 21
 			-3:00	-	ART
 #
 # Santa Cruz (SC)
@@ -331,7 +443,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 Jun  1
 			-4:00	-	WART	2004 Jun 20
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 #
 # Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF)
 Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
@@ -342,7 +454,7 @@
 			-4:00	Arg	AR%sT	2000 Mar  3
 			-3:00	-	ART	2004 May 30
 			-4:00	-	WART	2004 Jun 20
-			-3:00	-	ART
+			-3:00	Arg	AR%sT
 
 # Aruba
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -424,6 +536,10 @@
 # modern Brazilian eletronic voting machines which, apparently, can't deal
 # with a time change between the first and the second rounds of the elections.
 
+# From Steffen Thorsen (2007-09-20):
+# Brazil will start DST on 2007-10-14 00:00 and end on 2008-02-17 00:00:
+# http://www.mme.gov.br/site/news/detail.do;jsessionid=BBA06811AFCAAC28F0285210913513DA?newsId=13975
+
 # From Paul Eggert (2002-10-10):
 # The official decrees referenced below are mostly taken from
 # 
@@ -557,13 +673,18 @@
 # Decree 5,539 (2005-09-19),
 # adopted by the same states as before.
 Rule	Brazil	2005	only	-	Oct	16	 0:00	1:00	S
-# Decree 5,920
-# (2006-10-03), adopted by the same states as before.
-Rule	Brazil	2006	max	-	Nov	Sun>=1	 0:00	1:00	S
-Rule	Brazil	2007	max	-	Feb	lastSun	 0:00	0	-
+# Decree 5,920 (2006-10-03),
+# adopted by the same states as before.
+Rule	Brazil	2006	only	-	Nov	 5	 0:00	1:00	S
+Rule	Brazil	2007	only	-	Feb	25	 0:00	0	-
+# (Decree number not yet known)
+# http://www.brasil.gov.br/noticias/ultimas_noticias/horario_verao070920/
+# (2007-09-20) after a heads-up from Steffen Thorsen:
+Rule	Brazil	2007	max	-	Oct	Sun>=8	 0:00	1:00	S
+Rule	Brazil	2008	max	-	Feb	Sun>=15	 0:00	0	-
 # The latest ruleset listed above says that the following states observe DST:
 # DF, ES, GO, MG, MS, MT, PR, RJ, RS, SC, SP.
-# For dates after mid-2007, the above rules with TO="max" are guesses
+# For dates after mid-2008, the above rules with TO="max" are guesses
 # and are quite possibly wrong, but are more likely than no DST at all.
 
 
@@ -722,6 +843,26 @@
 # America/Santiago.  The pre-1980 Pacific/Easter data are dubious,
 # but we have no other source.
 
+# From German Poo-Caaman~o (2008-03-03):
+# Due to drought, Chile extends Daylight Time in three weeks.  This
+# is one-time change (Saturday 3/29 at 24:00 for America/Santiago
+# and Saturday 3/29 at 22:00 for Pacific/Easter)
+# The Supreme Decree is located at 
+# 
+# http://www.shoa.cl/servicios/supremo316.pdf
+# 
+# and the instructions for 2008 are located in:
+# 
+# http://www.horaoficial.cl/cambio.htm
+# .
+
+# From Jos? Miguel Garrido (2008-03-05):
+# ...
+# You could see the announces of the change on 
+# 
+# http://www.shoa.cl/noticias/2008/04hora/hora.htm
+# .
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1932	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -752,7 +893,11 @@
 Rule	Chile	1998	only	-	Sep	27	4:00u	1:00	S
 Rule	Chile	1999	only	-	Apr	 4	3:00u	0	-
 Rule	Chile	1999	max	-	Oct	Sun>=9	4:00u	1:00	S
-Rule	Chile	2000	max	-	Mar	Sun>=9	3:00u	0	-
+Rule	Chile	2000	2007	-	Mar	Sun>=9	3:00u	0	-
+# N.B.: the end of March 29 in Chile is March 30 in Universal time,
+# which is used below in specifying the transition.
+Rule	Chile	2008	only	-	Mar	30	3:00u	0	-
+Rule	Chile	2009	max	-	Mar	Sun>=9	3:00u	0	-
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -1097,8 +1242,18 @@
 			-3:00	Uruguay	UY%sT
 
 # Venezuela
+#
+# From John Stainforth (2007-11-28):
+# ... the change for Venezuela originally expected for 2007-12-31 has
+# been brought forward to 2007-12-09.  The official announcement was
+# published today in the "Gaceta Oficial de la Republica Bolivariana
+# de Venezuela, numero 38.819" (official document for all laws or
+# resolution publication)
+# http://www.globovision.com/news.php?nid=72208
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Caracas	-4:27:44 -	LMT	1890
 			-4:27:40 -	CMT	1912 Feb 12 # Caracas Mean Time?
 			-4:30	-	VET	1965	     # Venezuela Time
-			-4:00	-	VET
+			-4:00	-	VET	2007 Dec  9 03:00
+			-4:30	-	VET

Modified: haiku/trunk/src/data/etc/timezones/zone.tab
===================================================================
--- haiku/trunk/src/data/etc/timezones/zone.tab	2008-05-09 19:56:25 UTC (rev 25401)
+++ haiku/trunk/src/data/etc/timezones/zone.tab	2008-05-09 20:26:56 UTC (rev 25402)
@@ -1,4 +1,4 @@
-# @(#)zone.tab	8.11
+# @(#)zone.tab	8.16
 #
 # TZ zone descriptions
 #
@@ -42,7 +42,8 @@
 AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Terre Adelie
 AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
 AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
-AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF, SL)
+AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF)
+AR	-3319-06621	America/Argentina/San_Luis	San Luis (SL)
 AR	-2411-06518	America/Argentina/Jujuy	Jujuy (JY)
 AR	-2649-06513	America/Argentina/Tucuman	Tucuman (TM)
 AR	-2828-06547	America/Argentina/Catamarca	Catamarca (CT), Chubut (CH)
@@ -77,6 +78,7 @@
 BH	+2623+05035	Asia/Bahrain
 BI	-0323+02922	Africa/Bujumbura
 BJ	+0629+00237	Africa/Porto-Novo
+BL	+1753-06251	America/St_Barthelemy
 BM	+3217-06446	Atlantic/Bermuda
 BN	+0456+11455	Asia/Brunei
 BO	-1630-06809	America/La_Paz
@@ -208,7 +210,7 @@
 IE	+5320-00615	Europe/Dublin
 IL	+3146+03514	Asia/Jerusalem
 IM	+5409-00428	Europe/Isle_of_Man
-IN	+2232+08822	Asia/Calcutta
+IN	+2232+08822	Asia/Kolkata
 IO	-0720+07225	Indian/Chagos
 IQ	+3321+04425	Asia/Baghdad
 IR	+3540+05126	Asia/Tehran
@@ -250,6 +252,7 @@
 MC	+4342+00723	Europe/Monaco
 MD	+4700+02850	Europe/Chisinau
 ME	+4226+01916	Europe/Podgorica
+MF	+1804-06305	America/Marigot
 MG	-1855+04731	Indian/Antananarivo
 MH	+0709+17112	Pacific/Majuro	most locations
 MH	+0905+16720	Pacific/Kwajalein	Kwajalein
@@ -339,8 +342,7 @@
 SG	+0117+10351	Asia/Singapore
 SH	-1555-00542	Atlantic/St_Helena
 SI	+4603+01431	Europe/Ljubljana
-SJ	+7800+01600	Arctic/Longyearbyen	Svalbard
-SJ	+7059-00805	Atlantic/Jan_Mayen	Jan Mayen
+SJ	+7800+01600	Arctic/Longyearbyen
 SK	+4809+01707	Europe/Bratislava
 SL	+0830-01315	Africa/Freetown
 SM	+4355+01228	Europe/San_Marino
@@ -410,7 +412,7 @@
 VE	+1030-06656	America/Caracas
 VG	+1827-06437	America/Tortola
 VI	+1821-06456	America/St_Thomas
-VN	+1045+10640	Asia/Saigon
+VN	+1045+10640	Asia/Ho_Chi_Minh
 VU	-1740+16825	Pacific/Efate
 WF	-1318-17610	Pacific/Wallis
 WS	-1350-17144	Pacific/Apia



From bonefish at mail.berlios.de  Fri May  9 22:37:46 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Fri, 9 May 2008 22:37:46 +0200
Subject: [Haiku-commits] r25403 - haiku/trunk/src/apps/terminal
Message-ID: <200805092037.m49Kbkir007105@sheep.berlios.de>

Author: bonefish
Date: 2008-05-09 22:37:45 +0200 (Fri, 09 May 2008)
New Revision: 25403
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25403&view=rev

Modified:
   haiku/trunk/src/apps/terminal/Shell.cpp
   haiku/trunk/src/apps/terminal/Shell.h
   haiku/trunk/src/apps/terminal/TermView.cpp
Log:
The terminal is not supposed to send signals to the shell. That's done
by the tty. Now I also understand the BeOS work-around to ignore SIGINT
in bash I removed recently.
I suppose the signal code is still needed for BeOS. If not please remove
it.


Modified: haiku/trunk/src/apps/terminal/Shell.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.cpp	2008-05-09 20:26:56 UTC (rev 25402)
+++ haiku/trunk/src/apps/terminal/Shell.cpp	2008-05-09 20:37:45 UTC (rev 25403)
@@ -194,16 +194,24 @@
 	struct winsize winSize;
 	winSize.ws_row = rows;
 	winSize.ws_col = columns;
+#ifdef __HAIKU__
+	if (ioctl(fFd, TIOCSWINSZ, &winSize) != 0)
+		return errno;
+	return B_OK;
+#else
 	ioctl(fFd, TIOCSWINSZ, &winSize);
 	return Signal(SIGWINCH);
+#endif
 }
 
 
+#ifndef __HAIKU__
 status_t
 Shell::Signal(int signal)
 {
 	return send_signal(-fProcessID, signal);
 }
+#endif
 
 
 status_t

Modified: haiku/trunk/src/apps/terminal/Shell.h
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.h	2008-05-09 20:26:56 UTC (rev 25402)
+++ haiku/trunk/src/apps/terminal/Shell.h	2008-05-09 20:37:45 UTC (rev 25403)
@@ -32,7 +32,9 @@
 	ssize_t		Write(const void *buffer, size_t numBytes);
 
 	status_t	UpdateWindowSize(int row, int columns);
+#ifndef __HAIKU__
 	status_t	Signal(int signal);
+#endif
 
 	status_t	GetAttr(struct termios &attr);
 	status_t	SetAttr(struct termios &attr);

Modified: haiku/trunk/src/apps/terminal/TermView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermView.cpp	2008-05-09 20:26:56 UTC (rev 25402)
+++ haiku/trunk/src/apps/terminal/TermView.cpp	2008-05-09 20:37:45 UTC (rev 25403)
@@ -1471,6 +1471,7 @@
 	currentMessage->FindInt32("key", &key);
 	currentMessage->FindInt32("raw_char", &rawChar);
 
+#ifndef __HAIKU__
 	// If bytes[0] equal intr character,
 	// send signal to shell process group.
 	struct termios tio;
@@ -1479,6 +1480,7 @@
 		if (tio.c_lflag & ISIG)
 			fShell->Signal(SIGINT);
 	}
+#endif
 
 	// Terminal filters RET, ENTER, F1...F12, and ARROW key code.
 	// TODO: Cleanup



From leavengood at gmail.com  Fri May  9 22:46:41 2008
From: leavengood at gmail.com (Ryan Leavengood)
Date: Fri, 9 May 2008 16:46:41 -0400
Subject: [Haiku-commits] r25388 - haiku/trunk/src/apps/terminal
In-Reply-To: <200805090115.m491FXR5028284@sheep.berlios.de>
References: <200805090115.m491FXR5028284@sheep.berlios.de>
Message-ID: 

On Thu, May 8, 2008 at 9:15 PM, mmu_man at BerliOS
 wrote:
>
> Color drop is currently disabled, for now it just pastes it as text if
> provided (#rrggbb form from BColorControl).

I for one don't think that is a bad feature. Though maybe it is better
to only get the text form in editors. But if you are using VIM or
another terminal editor it might be nice to be able to drop colors
into the terminal to get the hex values (for CSS, etc.)

Maybe a modifier could be used to choose what you get. Shift-drop
applies the color to the terminal, normal drop pastes the text, or
vice versa.

Ryan


From bonefish at mail.berlios.de  Fri May  9 23:21:23 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Fri, 9 May 2008 23:21:23 +0200
Subject: [Haiku-commits] r25404 -
	haiku/trunk/src/add-ons/kernel/file_systems/bfs
Message-ID: <200805092121.m49LLNaU011227@sheep.berlios.de>

Author: bonefish
Date: 2008-05-09 23:21:22 +0200 (Fri, 09 May 2008)
New Revision: 25404
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25404&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp
Log:
Don't create anything in a removed directory. Axel, please review. I
don't see how the locking in Remove()/Create() works.


Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp	2008-05-09 20:37:45 UTC (rev 25403)
+++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp	2008-05-09 21:21:22 UTC (rev 25404)
@@ -2320,6 +2320,15 @@
 	WriteLocked locker(parent != NULL ? &parent->Lock() : NULL);
 		// the parent directory is locked during the whole inode creation
 
+	if (parent != NULL && parent->IsDirectory()) {
+		// don't create anything in removed directories
+		bool removed;
+		if (get_vnode_removed(volume->FSVolume(), parent->ID(), &removed)
+				!= B_OK || removed) {
+			RETURN_ERROR(B_ENTRY_NOT_FOUND);
+		}
+	}
+
 	if (tree != NULL) {
 		// Does the file already exist?
 		off_t offset;



From mmu_man at mail.berlios.de  Fri May  9 23:48:59 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Fri, 9 May 2008 23:48:59 +0200
Subject: [Haiku-commits] r25405 - haiku/trunk/src/add-ons/kernel/drivers/tty
Message-ID: <200805092148.m49LmxnY013207@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-09 23:48:59 +0200 (Fri, 09 May 2008)
New Revision: 25405
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25405&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
   haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
Log:
- dump winsize info too.
- prepare for VTIME and VMIN handling: allow waiting with timeout.


Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2008-05-09 21:21:22 UTC (rev 25404)
+++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2008-05-09 21:48:59 UTC (rev 25405)
@@ -135,6 +135,7 @@
 		ReaderLocker(tty_cookie *cookie);
 		~ReaderLocker();
 
+		status_t AcquireReader(bigtime_t timeout);
 		status_t AcquireReader(bool dontBlock);
 
 	private:
@@ -393,7 +394,7 @@
  *	The request lock MUST NOT be held!
  */
 status_t
-RequestOwner::Wait(bool interruptable)
+RequestOwner::Wait(bool interruptable, bigtime_t timeout)
 {
 	TRACE(("%p->RequestOwner::Wait(%d)\n", this, interruptable));
 
@@ -420,7 +421,7 @@
 		// wait
 		TRACE(("%p->RequestOwner::Wait(): waiting for condition...\n", this));
 
-		error = entry.Wait();
+		error = entry.Wait(B_RELATIVE_TIMEOUT, timeout);
 
 		TRACE(("%p->RequestOwner::Wait(): condition occurred: %lx\n", this,
 			error));
@@ -677,7 +678,7 @@
 
 
 status_t 
-ReaderLocker::AcquireReader(bool dontBlock)
+ReaderLocker::AcquireReader(bigtime_t timeout)
 {
 	if (fCookie->closed)
 		return B_FILE_ERROR;
@@ -695,12 +696,12 @@
 
 	// We are not the first in queue or currently there's nothing to read:
 	// bail out, if we shall not block.
-	if (dontBlock)
+	if (timeout <= 0)
 		return B_WOULD_BLOCK;
 
 	// block until something happens
 	Unlock();
-	status = fRequestOwner.Wait(true);
+	status = fRequestOwner.Wait(true, timeout);
 	Lock();
 
 	if (status == B_OK)
@@ -713,6 +714,13 @@
 }
 
 
+status_t 
+ReaderLocker::AcquireReader(bool dontBlock)
+{
+	return AcquireReader(dontBlock ? 0 : B_INFINITE_TIMEOUT);
+}
+
+
 size_t
 ReaderLocker::_CheckAvailableBytes() const
 {
@@ -1456,8 +1464,9 @@
 		case TCWAITEVENT:		// BeOS (uint *)
 								// wait for event (timeout if !NULL)
 		case TCVTIME:			// BeOS (bigtime_t *) set highrez VTIME
+		case 'ochr':			// BeOS (int *) same as ichr for write
 			dprintf("tty: unsupported legacy opcode %lu\n", op);
-			// TODO;
+			// TODO ?
 			break;
 
 		case TCXONC:			// Unix, but even Linux doesn't handle it
@@ -1465,7 +1474,6 @@
 			break;
 
 		case TCQUERYCONNECTED:	// BeOS
-		case 'ochr':			// BeOS (int *) same as ichr for write
 			dprintf("tty: unsupported legacy opcode %lu\n", op);
 			// BeOS didn't implement them anyway
 			break;
@@ -1492,6 +1500,9 @@
 	bool dontBlock = (mode & O_NONBLOCK) != 0;
 	size_t length = *_length;
 	ssize_t bytesRead = 0;
+	bigtime_t timeout = dontBlock ? 0 : B_INFINITE_TIMEOUT;
+	bigtime_t vtime = 0LL;
+	size_t vmin = 0;
 
 	TRACE(("tty_input_read(tty = %p, length = %lu, mode = %lu)\n", tty, length, mode));
 
@@ -1506,7 +1517,7 @@
 	ReaderLocker locker(cookie);
 
 	while (bytesRead == 0) {
-		status_t status = locker.AcquireReader(dontBlock);
+		status_t status = locker.AcquireReader(timeout);
 		if (status != B_OK) {
 			*_length = 0;
 			return status;
@@ -1620,6 +1631,8 @@
 
 			writable = locker.AvailableBytes();
 
+			// XXX: do we need to support VMIN & VTIME for write() ?
+
 			// We need to restart the loop, since the termios flags might have
 			// changed in the meantime (while we've unlocked the tty). Note,
 			// that we don't re-get "echo" -- maybe we should.
@@ -1911,8 +1924,9 @@
 	kprintf("  pgrp_id:      %ld\n", settings.pgrp_id);
 	kprintf("  session_id:   %ld\n", settings.session_id);
 	// struct termios		termios;
-	// struct winsize		window_size;
-
+	kprintf("  wsize:        %u x %u c, %u x %u pxl\n", 
+		settings.window_size.ws_row, settings.window_size.ws_col, 
+		settings.window_size.ws_xpixel, settings.window_size.ws_ypixel);
 }
 
 static void

Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2008-05-09 21:21:22 UTC (rev 25404)
+++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2008-05-09 21:48:59 UTC (rev 25405)
@@ -91,7 +91,7 @@
 		void SetBytesNeeded(size_t bytesNeeded);
 		size_t BytesNeeded() const	{ return fBytesNeeded; }
 
-		status_t Wait(bool interruptable);
+		status_t Wait(bool interruptable, bigtime_t timeout=B_INFINITE_TIMEOUT);
 
 		bool IsFirstInQueues();
 



From axeld at mail.berlios.de  Sat May 10 00:05:51 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Sat, 10 May 2008 00:05:51 +0200
Subject: [Haiku-commits] r25406 -
	haiku/trunk/src/tests/system/kernel/device_manager/playground
Message-ID: <200805092205.m49M5pgt014368@sheep.berlios.de>

Author: axeld
Date: 2008-05-10 00:05:50 +0200 (Sat, 10 May 2008)
New Revision: 25406
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25406&view=rev

Modified:
   haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp
   haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h
Log:
* Work in progress: driver loading triggered by devfs.
* get_driver() now returns a result, as you may theoretically call it on
  any node (and not just your parent, which is guaranteed to be there).


Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp
===================================================================
--- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp	2008-05-09 21:48:59 UTC (rev 25405)
+++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp	2008-05-09 22:05:50 UTC (rev 25406)
@@ -96,7 +96,7 @@
 			const AttributeList& Attributes() const { return fAttributes; }
 
 			status_t		InitDriver();
-			void			UninitDriver();
+			bool			UninitDriver();
 
 			// The following two are only valid, if the node's driver is
 			// initialized
@@ -106,9 +106,12 @@
 			void			AddChild(device_node *node);
 			void			RemoveChild(device_node *node);
 			const NodeList&	Children() const { return fChildren; }
+			void			UninitUnusedChildren();
 
 			status_t		Register();
+			status_t		Probe(const char* devicePath);
 			bool			IsRegistered() const { return fRegistered; }
+			bool			IsInitialized() const { return fInitialized > 0; }
 
 private:
 			status_t		_RegisterFixed(uint32& registered);
@@ -123,12 +126,15 @@
 								float& bestSupport);
 			status_t		_RegisterPath(const char* path);
 			status_t		_RegisterDynamic();
+			status_t		_RemoveChildren();
+			bool			_UninitUnusedChildren();
 
 	device_node*			fParent;
 	NodeList				fChildren;
 	int32					fRefCount;
 	int32					fInitialized;
 	bool					fRegistered;
+	uint32					fFlags;
 
 	const char*				fModuleName;
 	driver_module_info*		fDriver;
@@ -137,9 +143,14 @@
 	AttributeList			fAttributes;
 };
 
+enum node_flags {
+	NODE_FLAG_REMOVE_ON_UNINIT	= 0x01
+};
+
 device_manager_info *gDeviceManager;
 
 static device_node *sRootNode;
+static recursive_lock sLock;
 
 
 //	#pragma mark - device_attr
@@ -371,6 +382,22 @@
 }
 
 
+static void
+uninit_unused()
+{
+	RecursiveLocker _(sLock);
+	sRootNode->UninitUnusedChildren();
+}
+
+
+static status_t
+probe_path(const char* path)
+{
+	RecursiveLocker _(sLock);
+	return sRootNode->Probe(path);
+}
+
+
 //	#pragma mark - device_node
 
 
@@ -407,12 +434,22 @@
 
 device_node::~device_node()
 {
-	AttributeList::Iterator iterator = fAttributes.GetIterator();
-	while (iterator.HasNext()) {
-		device_attr_private* attr = iterator.Next();
-		iterator.Remove();
+	// Delete children
+	NodeList::Iterator nodeIterator = fChildren.GetIterator();
+	while (nodeIterator.HasNext()) {
+		device_node* child = nodeIterator.Next();
+		nodeIterator.Remove();
+		delete child;
+	}
+
+	// Delete attributes
+	AttributeList::Iterator attrIterator = fAttributes.GetIterator();
+	while (attrIterator.HasNext()) {
+		device_attr_private* attr = attrIterator.Next();
+		attrIterator.Remove();
 		delete attr;
 	}
+
 	free((char*)fModuleName);
 }
 
@@ -448,17 +485,24 @@
 }
 
 
-void
+bool
 device_node::UninitDriver()
 {
 	if (fInitialized-- > 1)
-		return;
+		return false;
 
 	if (fDriver->uninit_driver != NULL)
 		fDriver->uninit_driver(this);
+
+	fDriver = NULL;
 	fDriverData = NULL;
 
 	put_module(ModuleName());
+
+	if ((fFlags & NODE_FLAG_REMOVE_ON_UNINIT) != 0)
+		delete this;
+
+	return true;
 }
 
 
@@ -807,9 +851,120 @@
 }
 
 
-//	#pragma mark -
+status_t
+device_node::_RemoveChildren()
+{
+	NodeList::Iterator iterator = fChildren.GetIterator();
+	while (iterator.HasNext()) {
+		device_node* child = iterator.Next();
 
+		if (!child->IsInitialized()) {
+			// this child is not used currently, and can be removed safely
+			iterator.Remove();
+			fRefCount--;
+			child->fParent = NULL;
+			delete child;
+		} else
+			child->fFlags |= NODE_FLAG_REMOVE_ON_UNINIT;
+	}
 
+	return fChildren.IsEmpty() ? B_OK : B_BUSY;
+}
+
+
+status_t
+device_node::Probe(const char* devicePath)
+{
+	uint16 type = 0;
+	uint16 subType = 0;
+	if (dm_get_attr_uint16(this, B_DEVICE_TYPE, &type, false) == B_OK
+		&& dm_get_attr_uint16(this, B_DEVICE_SUB_TYPE, &subType, false)
+			== B_OK) {
+		// Check if this node matches the device path
+		// TODO: maybe make this extendible via settings file?
+		bool matches = false;
+		if (!strcmp(devicePath, "disk")) {
+			matches = type == PCI_mass_storage;
+		} else if (!strcmp(devicePath, "audio")) {
+			matches = type == PCI_multimedia
+				&& (subType == PCI_audio || subType == PCI_hd_audio);
+		} else if (!strcmp(devicePath, "net")) {
+			matches = type == PCI_network;
+		} else if (!strcmp(devicePath, "graphics")) {
+			matches = type == PCI_display;
+		} else if (!strcmp(devicePath, "video")) {
+			matches = type == PCI_multimedia && subType == PCI_video;
+		}
+
+		if (matches) {
+			if (!fChildren.IsEmpty()) {
+				// We already have a driver that claims this node.
+				// Try to remove uninitialized children, so that this node
+				// can be re-evaluated
+				// TODO: try first if there is a better child!
+				// TODO: publish both devices, make new one busy as long
+				// as the old one is in use!
+				if (_RemoveChildren() != B_OK)
+					return B_OK;
+			}
+			return _RegisterDynamic();
+		}
+
+		return B_OK;
+	}
+
+	NodeList::Iterator iterator = fChildren.GetIterator();
+	while (iterator.HasNext()) {
+		device_node* child = iterator.Next();
+		
+		status_t status = child->Probe(devicePath);
+		if (status != B_OK)
+			return status;
+	}
+
+	return B_OK;
+}
+
+
+bool
+device_node::_UninitUnusedChildren()
+{
+	// First, we need to go to the leaf, and go back from there
+
+	bool uninit = true;
+
+	NodeList::Iterator iterator = fChildren.GetIterator();
+
+	while (iterator.HasNext()) {
+		device_node* child = iterator.Next();
+
+		if (!child->_UninitUnusedChildren())
+			uninit = false;
+	}
+
+	// Not all of our children could be uninitialized
+	if (!uninit)
+		return false;
+
+	if (!IsInitialized())
+		return true;
+
+	if ((DriverModule()->info.flags & B_KEEP_LOADED) != 0) {
+		// We must not get unloaded
+		return false;
+	}
+
+	return UninitDriver();
+}
+
+
+void
+device_node::UninitUnusedChildren()
+{
+	_UninitUnusedChildren();
+}
+
+
 //	#pragma mark - Device Manager module API
 
 
@@ -838,6 +993,8 @@
 	TRACE(("%p: register device \"%s\", parent %p\n", newNode, moduleName,
 		parent));
 
+	RecursiveLocker _(sLock);
+
 	status_t status = newNode->InitCheck();
 	if (status != B_OK)
 		goto err1;
@@ -890,13 +1047,18 @@
 }
 
 
-static void
+static status_t
 get_driver(device_node* node, driver_module_info** _module, void** _data)
 {
+	if (node->DriverModule() == NULL)
+		return B_NO_INIT;
+
 	if (_module != NULL)
 		*_module = node->DriverModule();
 	if (_data != NULL)
 		*_data = node->DriverData();
+
+	return B_OK;
 }
 
 
@@ -1136,8 +1298,14 @@
 		return 1;
 	}
 
+	recursive_lock_init(&sLock, "device manager");
+
 	dm_init_root_node();
 	dm_dump_node(sRootNode, 0);
 
+	probe_path("net");
+	uninit_unused();
+
+	recursive_lock_destroy(&sLock);
 	return 0;
 }

Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h
===================================================================
--- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h	2008-05-09 21:48:59 UTC (rev 25405)
+++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h	2008-05-09 22:05:50 UTC (rev 25406)
@@ -69,7 +69,7 @@
 					device_node **_node);
 	status_t (*unregister_device)(device_node *node);
 
-	void (*get_driver)(device_node *node, driver_module_info **_module,
+	status_t (*get_driver)(device_node *node, driver_module_info **_module,
 					void **_cookie);
 
 	device_node *(*root_device)();



From ingo_weinhold at gmx.de  Sat May 10 00:30:59 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Sat, 10 May 2008 00:30:59 +0200
Subject: [Haiku-commits] r25405 -
 haiku/trunk/src/add-ons/kernel/drivers/tty
In-Reply-To: <200805092148.m49LmxnY013207@sheep.berlios.de>
References: <200805092148.m49LmxnY013207@sheep.berlios.de>
Message-ID: <20080510003059.1031.4@knochen-vm.1210348621.fake>


On 2008-05-09 at 23:48:59 [+0200], mmu_man at BerliOS 
 -        status_t Wait(bool interruptable);
> +        status_t Wait(bool interruptable, bigtime_t 
> timeout=B_INFINITE_TIMEOUT);

For violating the operator spacing rule the style police fines you one beer, 
payable at next BeGeistert. :-)

CU, Ingo


From bonefish at mail.berlios.de  Sat May 10 02:53:14 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 02:53:14 +0200
Subject: [Haiku-commits] r25407 - haiku/trunk/src/system/kernel/fs
Message-ID: <200805100053.m4A0rEqU026006@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 02:53:13 +0200 (Sat, 10 May 2008)
New Revision: 25407
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25407&view=rev

Modified:
   haiku/trunk/src/system/kernel/fs/vfs.cpp
Log:
Advisory locking fixes:
* Made the access strategy to vnode::advisory_locking consistent.
  get_advisory_locking() was guarding it with sVnodeMutex,
  create_advisory_locking() was using atomic_pointer_test_and_set(), and
  release_advisory_lock() just set it unguardedly. We do use sVnodeMutex
  consequently, now.
* Beautified create_advisory_locking() (got rid of the gotos,
  reorganized the control flow).
* Fixed race conditions in acquire_advisory_lock(). It was always
  unlocking and relocking the advisory_locking object when it didn't
  have to wait, but in the meantime someone else could have changed the
  locking situation. Reorganized the control flow, so that it only drops
  the lock when it has to fail or wait. Using create_advisory_locking()
  upfront simplifies the code quite a bit (and fixes another race
  condition).

APR's testprocmutex test seems happy now, at least.


Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/vfs.cpp	2008-05-09 22:05:50 UTC (rev 25406)
+++ haiku/trunk/src/system/kernel/fs/vfs.cpp	2008-05-10 00:53:13 UTC (rev 25407)
@@ -27,6 +27,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -151,6 +152,21 @@
 	sem_id			lock;
 	sem_id			wait_sem;
 	LockList		locks;
+
+	advisory_locking()
+		:
+		lock(-1),
+		wait_sem(-1)
+	{
+	}
+
+	~advisory_locking()
+	{
+		if (lock >= 0)
+			delete_sem(lock);
+		if (wait_sem >= 0)
+			delete_sem(wait_sem);
+	}
 };
 
 static mutex sFileSystemsMutex;
@@ -189,7 +205,7 @@
 
 /*!	\brief Guards sVnodeTable.
 
-	The holder is allowed to read/write access sVnodeTable and to
+	The holder is allowed read/write access to sVnodeTable and to
 	any unbusy vnode in that table, save to the immutable fields (device, id,
 	private_node, mount) to which
 	only read-only access is allowed, and to the field covered_by, which is
@@ -1122,42 +1138,38 @@
 	if (vnode == NULL)
 		return B_FILE_ERROR;
 
-	struct advisory_locking *locking = new(std::nothrow) advisory_locking;
-	if (locking == NULL)
-		return B_NO_MEMORY;
+	ObjectDeleter lockingDeleter;
+	struct advisory_locking *locking = NULL;
 
-	status_t status;
+	while (get_advisory_locking(vnode) == NULL) {
+		// no locking object set on the vnode yet, create one
+		if (locking == NULL) {
+			locking = new(std::nothrow) advisory_locking;
+			if (locking == NULL)
+				return B_NO_MEMORY;
+			lockingDeleter.SetTo(locking);
 
-	locking->wait_sem = create_sem(0, "advisory lock");
-	if (locking->wait_sem < B_OK) {
-		status = locking->wait_sem;
-		goto err1;
-	}
+			locking->wait_sem = create_sem(0, "advisory lock");
+			if (locking->wait_sem < B_OK)
+				return locking->wait_sem;
 
-	locking->lock = create_sem(0, "advisory locking");
-	if (locking->lock < B_OK) {
-		status = locking->lock;
-		goto err2;
-	}
+			locking->lock = create_sem(0, "advisory locking");
+			if (locking->lock < B_OK)
+				return locking->lock;
+		}
 
-	// We need to set the locking structure atomically - someone
-	// else might set one at the same time
-	do {
-		if (atomic_pointer_test_and_set(&vnode->advisory_locking, locking,
-				(advisory_locking*)NULL) == NULL)
+		// set our newly created locking object
+		MutexLocker _(sVnodeMutex);
+		if (vnode->advisory_locking == NULL) {
+			vnode->advisory_locking = locking;
+			lockingDeleter.Detach();
 			return B_OK;
-	} while (get_advisory_locking(vnode) == NULL);
+		}
+	}
 
-	status = B_OK;
-		// we delete the one we've just created, but nevertheless, the vnode
-		// does have a locking structure now
+	// The vnode already had a locking object. That's just as well.
 
-	delete_sem(locking->lock);
-err2:
-	delete_sem(locking->wait_sem);
-err1:
-	delete locking;
-	return status;
+	return B_OK;
 }
 
 
@@ -1287,9 +1299,12 @@
 		// longer used
 		locking = get_advisory_locking(vnode);
 		if (locking != NULL) {
+			MutexLocker locker(sVnodeMutex);
+
 			// the locking could have been changed in the mean time
 			if (locking->locks.IsEmpty()) {
 				vnode->advisory_locking = NULL;
+				locker.Unlock();
 
 				// we've detached the locking from the vnode, so we can
 				// safely delete it
@@ -1298,6 +1313,7 @@
 				delete locking;
 			} else {
 				// the locking is in use again
+				locker.Unlock();
 				release_sem_etc(locking->lock, 1, B_DO_NOT_RESCHEDULE);
 			}
 		}
@@ -1328,19 +1344,25 @@
 
 	// TODO: do deadlock detection!
 
-restart:
-	// if this vnode has an advisory_locking structure attached,
-	// lock that one and search for any colliding file lock
-	struct advisory_locking *locking = get_advisory_locking(vnode);
-	team_id team = team_get_current_team_id();
-	sem_id waitForLock = -1;
+	struct advisory_locking *locking;
+	sem_id waitForLock;
 
-	if (locking != NULL) {
+	while (true) {
+		// if this vnode has an advisory_locking structure attached,
+		// lock that one and search for any colliding file lock
+		status = create_advisory_locking(vnode);
+		if (status != B_OK)
+			return status;
+
+		locking = vnode->advisory_locking;
+		team_id team = team_get_current_team_id();
+		waitForLock = -1;
+
 		// test for collisions
 		LockList::Iterator iterator = locking->locks.GetIterator();
 		while (iterator.HasNext()) {
 			struct advisory_lock *lock = iterator.Next();
-
+	
 			// TODO: locks from the same team might be joinable!
 			if (lock->team != team && advisory_lock_intersects(lock, flock)) {
 				// locks do overlap
@@ -1352,41 +1374,27 @@
 			}
 		}
 
-		if (waitForLock < B_OK || !wait)
-			put_advisory_locking(locking);
-	}
+		if (waitForLock < 0)
+			break;
 
-	// wait for the lock if we have to, or else return immediately
+		// We need to wait. Do that or fail now, if we've been asked not to.
 
-	if (waitForLock >= B_OK) {
-		if (!wait)
-			status = session != -1 ? B_WOULD_BLOCK : B_PERMISSION_DENIED;
-		else {
-			status = switch_sem_etc(locking->lock, waitForLock, 1,
-				B_CAN_INTERRUPT, 0);
-			if (status == B_OK) {
-				// see if we're still colliding
-				goto restart;
-			}
+		if (!wait) {
+			put_advisory_locking(locking);
+			return session != -1 ? B_WOULD_BLOCK : B_PERMISSION_DENIED;
 		}
-	}
 
-	if (status < B_OK)
-		return status;
-
-	// install new lock
-
-	locking = get_advisory_locking(vnode);
-	if (locking == NULL) {
-		// we need to create a new locking object
-		status = create_advisory_locking(vnode);
-		if (status < B_OK)
+		status = switch_sem_etc(locking->lock, waitForLock, 1,
+			B_CAN_INTERRUPT, 0);
+		if (status != B_OK && status != B_BAD_SEM_ID)
 			return status;
 
-		locking = vnode->advisory_locking;
-			// we own the locking object, so it can't go away
+		// We have been notified, but we need to re-lock the locking object. So
+		// go another round...
 	}
 
+	// install new lock
+
 	struct advisory_lock *lock = (struct advisory_lock *)malloc(
 		sizeof(struct advisory_lock));
 	if (lock == NULL) {



From mmu_man at mail.berlios.de  Sat May 10 04:07:15 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sat, 10 May 2008 04:07:15 +0200
Subject: [Haiku-commits] r25408 - haiku/trunk/src/add-ons/kernel/drivers/tty
Message-ID: <200805100207.m4A27F7v029669@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-10 04:07:12 +0200 (Sat, 10 May 2008)
New Revision: 25408
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25408&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
   haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
Log:
- dump termios struct for ttys
- implement VMIN & VTIME, at least it seems to work but it's 4am and it's overly weird, so please review.
See http://man.cx/termios and http://www.unixwiz.net/techtips/termios-vmin-vtime.html .


Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2008-05-10 00:53:13 UTC (rev 25407)
+++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2008-05-10 02:07:12 UTC (rev 25408)
@@ -135,7 +135,7 @@
 		ReaderLocker(tty_cookie *cookie);
 		~ReaderLocker();
 
-		status_t AcquireReader(bigtime_t timeout);
+		status_t AcquireReader(bigtime_t timeout, size_t minBytes);
 		status_t AcquireReader(bool dontBlock);
 
 	private:
@@ -678,7 +678,7 @@
 
 
 status_t 
-ReaderLocker::AcquireReader(bigtime_t timeout)
+ReaderLocker::AcquireReader(bigtime_t timeout, size_t minBytes)
 {
 	if (fCookie->closed)
 		return B_FILE_ERROR;
@@ -690,7 +690,7 @@
 	// check, if we're first in queue, and if there is something to read
 	if (fRequestOwner.IsFirstInQueues()) {
 		fBytes = _CheckAvailableBytes();
-		if (fBytes > 0)
+		if (fBytes > minBytes)
 			return B_OK;
 	}
 
@@ -717,7 +717,7 @@
 status_t 
 ReaderLocker::AcquireReader(bool dontBlock)
 {
-	return AcquireReader(dontBlock ? 0 : B_INFINITE_TIMEOUT);
+	return AcquireReader(dontBlock ? 0 : B_INFINITE_TIMEOUT, 0);
 }
 
 
@@ -1500,9 +1500,11 @@
 	bool dontBlock = (mode & O_NONBLOCK) != 0;
 	size_t length = *_length;
 	ssize_t bytesRead = 0;
+	bool canon = true;
 	bigtime_t timeout = dontBlock ? 0 : B_INFINITE_TIMEOUT;
-	bigtime_t vtime = 0LL;
+	bigtime_t vtime = timeout;
 	size_t vmin = 0;
+	size_t minRead = 0;
 
 	TRACE(("tty_input_read(tty = %p, length = %lu, mode = %lu)\n", tty, length, mode));
 
@@ -1516,22 +1518,56 @@
 
 	ReaderLocker locker(cookie);
 
+	// handle raw mode
+	if ((!tty->is_master) && ((tty->settings->termios.c_lflag & ICANON) == 0)) {
+		canon = false;
+		vmin = tty->settings->termios.c_cc[VMIN];
+		// for now behaviour is undefined when nonblocking is enabled
+		//if (!dontBlock) // XXX does it take precedence or not ?
+		vtime = tty->settings->termios.c_cc[VTIME] * 100000LL;
+		TRACE(("tty_input_read: -icanon vmin %lu, vtime %Ldus\n", vmin, vtime));
+
+		// yes it's weird but termios is!
+		if (vmin && vtime == 0LL)
+			vtime = B_INFINITE_TIMEOUT;
+		if (!vmin)
+			timeout = vtime;
+		// timeout starts at 1st char when vmin > 0
+		// so we first wait for 1 char only
+		minRead = 0;
+	}
+
 	while (bytesRead == 0) {
-		status_t status = locker.AcquireReader(timeout);
+		TRACE(("tty_input_read: AcquireReader(%Ldus, %ld)\n", timeout, minRead));
+		status_t status = locker.AcquireReader(timeout, minRead);
+		if (status == B_WOULD_BLOCK) {
+			*_length = 0;
+			return 0;
+		}
 		if (status != B_OK) {
 			*_length = 0;
 			return status;
 		}
 
 		size_t toRead = locker.AvailableBytes();
-		if (toRead == 0)
+
+		if (toRead) {
+			// raw mode: we have something, now retry with vmin and vtime
+			minRead = MAX(vmin-1, 0);
+			timeout = vtime;
+		}
+
+		if (toRead < vmin && timeout == B_INFINITE_TIMEOUT)
 			continue;
 		if (toRead > length)
 			toRead = length;
 
 		bool _hitEOF = false;
-		bool* hitEOF = (tty->pending_eof > 0 ? &_hitEOF : NULL);
+		bool* hitEOF = NULL;
 
+		if (canon && tty->pending_eof > 0)
+			hitEOF = &_hitEOF;
+
 		bytesRead = line_buffer_user_read(tty->input_buffer, (char *)buffer,
 			toRead, tty->settings->termios.c_cc[VEOF], hitEOF);
 		if (bytesRead < B_OK) {
@@ -1923,7 +1959,18 @@
 {
 	kprintf("  pgrp_id:      %ld\n", settings.pgrp_id);
 	kprintf("  session_id:   %ld\n", settings.session_id);
-	// struct termios		termios;
+
+	kprintf("  termios:\n");
+	kprintf("    c_iflag:    0x%08lx\n", settings.termios.c_iflag);
+	kprintf("    c_oflag:    0x%08lx\n", settings.termios.c_oflag);
+	kprintf("    c_cflag:    0x%08lx\n", settings.termios.c_cflag);
+	kprintf("    c_lflag:    0x%08lx\n", settings.termios.c_lflag);
+	kprintf("    c_line:     %d\n", settings.termios.c_line);
+	kprintf("    c_ispeed:   %u\n", settings.termios.c_ispeed);
+	kprintf("    c_ospeed:   %u\n", settings.termios.c_ospeed);
+	for (int i = 0; i < NCCS; i++)
+		kprintf("    c_cc[%02d]:   %d\n", i, settings.termios.c_cc[i]);
+
 	kprintf("  wsize:        %u x %u c, %u x %u pxl\n", 
 		settings.window_size.ws_row, settings.window_size.ws_col, 
 		settings.window_size.ws_xpixel, settings.window_size.ws_ypixel);
@@ -1932,6 +1979,7 @@
 static void
 dump_tty_struct(struct tty& tty)
 {
+	kprintf("  tty @:        %p\n", &tty);
 	kprintf("  index:        %ld\n", tty.index);
 	kprintf("  is_master:    %s\n", tty.is_master ? "true" : "false");
 	kprintf("  open_count:   %ld\n", tty.open_count);

Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2008-05-10 00:53:13 UTC (rev 25407)
+++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2008-05-10 02:07:12 UTC (rev 25408)
@@ -91,7 +91,7 @@
 		void SetBytesNeeded(size_t bytesNeeded);
 		size_t BytesNeeded() const	{ return fBytesNeeded; }
 
-		status_t Wait(bool interruptable, bigtime_t timeout=B_INFINITE_TIMEOUT);
+		status_t Wait(bool interruptable, bigtime_t timeout = B_INFINITE_TIMEOUT);
 
 		bool IsFirstInQueues();
 



From mmu_man at mail.berlios.de  Sat May 10 04:48:58 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sat, 10 May 2008 04:48:58 +0200
Subject: [Haiku-commits] r25409 - haiku/trunk/src/apps/terminal
Message-ID: <200805100248.m4A2mwb5000126@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-10 04:48:57 +0200 (Sat, 10 May 2008)
New Revision: 25409
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25409&view=rev

Modified:
   haiku/trunk/src/apps/terminal/TermParse.cpp
   haiku/trunk/src/apps/terminal/VTPrsTbl.c
Log:
- some more ANSI attributes
- changed comments to pragma comments for parse tables as it's huge, but sadly Pe doesn't make them clickable in the function list...


Modified: haiku/trunk/src/apps/terminal/TermParse.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.cpp	2008-05-10 02:07:12 UTC (rev 25408)
+++ haiku/trunk/src/apps/terminal/TermParse.cpp	2008-05-10 02:48:57 UTC (rev 25409)
@@ -675,6 +675,18 @@
 							attr |= INVERSE;
 							break;
 
+						case 22:	/* Not Bold	*/
+							attr &= ~BOLD;
+							break;
+
+						case 24:	/* Not Underline	*/
+							attr &= ~UNDERLINE;
+							break;
+
+						case 27:	/* Not Inverse	*/
+							attr &= ~INVERSE;
+							break;
+
 						case 30:
 						case 31:
 						case 32:

Modified: haiku/trunk/src/apps/terminal/VTPrsTbl.c
===================================================================
--- haiku/trunk/src/apps/terminal/VTPrsTbl.c	2008-05-10 02:07:12 UTC (rev 25408)
+++ haiku/trunk/src/apps/terminal/VTPrsTbl.c	2008-05-10 02:48:57 UTC (rev 25409)
@@ -33,7 +33,8 @@
 #define USE_MBCS
 #define USE_ISO2022
 
-int gUTF8GroundTable[] =	/* UTF8 coding ground table */
+// #pragma mark UTF8 coding ground table
+int gUTF8GroundTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -357,7 +358,8 @@
 CASE_UTF8_3BYTE,
 };
 
-int gCS96GroundTable[] =	/* charset 96 table */
+// #pragma mark charset 96 table
+int gCS96GroundTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -681,6 +683,7 @@
 CASE_IGNORE,
 };
 
+// #pragma mark ISO8859 table
 int gISO8859GroundTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
@@ -1005,7 +1008,8 @@
 CASE_PRINT_GR,
 };
 
-int gCsiTable[] =		/* ESC [ */
+// #pragma mark ESC [ - CSI table
+int gCsiTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -1329,7 +1333,8 @@
 CASE_GROUND_STATE,
 };
 
-int gDecTable[] =		/* ESC [ ? */
+// #pragma mark ESC [ ? - DEC table
+int gDecTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -1670,7 +1675,8 @@
 CASE_GROUND_STATE,
 };
 
-int gEscIgnoreTable[] =		/* CASE_ESC_IGNORE */
+// #pragma mark CASE_ESC_IGNORE table
+int gEscIgnoreTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -1995,7 +2001,8 @@
 CASE_GROUND_STATE,
 };
 
-int gEscTable[] =		/* ESC */
+// #pragma mark ESC table
+int gEscTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -2337,7 +2344,8 @@
 CASE_GROUND_STATE,
 };
 
-int gIesTable[] =		/* CASE_IGNORE_ESC */
+// #pragma mark CASE_IGNORE_ESC table
+int gIesTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE_STATE,
@@ -2661,7 +2669,8 @@
 CASE_GROUND_STATE,
 };
 
-int gIgnoreTable[] =		/* CASE_IGNORE_STATE */
+// #pragma mark CASE_IGNORE_STATE table
+int gIgnoreTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -2985,7 +2994,8 @@
 CASE_GROUND_STATE,
 };
 
-int gScrTable[] =		/* ESC # */
+// #pragma mark ESC # - SCR table
+int gScrTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -3309,7 +3319,8 @@
 CASE_GROUND_STATE,
 };
 
-int gScsTable[] =		/* ESC ( etc. */
+// #pragma mark ESC ( - SCS table
+int gScsTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -3737,6 +3748,7 @@
 };
 
 #ifdef USE_MBCS
+// #pragma mark MBCS table
 int gMbcsTable[] = {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -4060,6 +4072,7 @@
 CASE_GROUND_STATE,
 };
 
+// #pragma mark SMBCS table
 int gSmbcsTable[] = {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,
@@ -4385,7 +4398,8 @@
 
 #endif
 
-int gSJISGroundTable[] =	/* Shift-JIS ground table. */
+// #pragma mark Shift-JIS ground table
+int gSJISGroundTable[] =
 {
 /*	NUL		SOH		STX		ETX	*/
 CASE_IGNORE,



From axeld at pinc-software.de  Sat May 10 10:28:58 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Sat, 10 May 2008 10:28:58 +0200 CEST
Subject: [Haiku-commits] r25407 - haiku/trunk/src/system/kernel/fs
In-Reply-To: <200805100053.m4A0rEqU026006@sheep.berlios.de>
Message-ID: <682786142-BeMail@zon>

bonefish at BerliOS  wrote:
> * Made the access strategy to vnode::advisory_locking consistent.
>   get_advisory_locking() was guarding it with sVnodeMutex,
>   create_advisory_locking() was using atomic_pointer_test_and_set(), 
> and
>   release_advisory_lock() just set it unguardedly. We do use 
> sVnodeMutex
>   consequently, now.

Oops, didn't notice that one. Thanks! Even though I would have tried 
the lockless approach :-)

Bye,
   Axel.



From axeld at pinc-software.de  Sat May 10 10:31:24 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Sat, 10 May 2008 10:31:24 +0200 CEST
Subject: [Haiku-commits] r25405 -
 haiku/trunk/src/add-ons/kernel/drivers/tty
In-Reply-To: <20080510003059.1031.4@knochen-vm.1210348621.fake>
Message-ID: <828332875-BeMail@zon>

Ingo Weinhold  wrote:
> On 2008-05-09 at 23:48:59 [+0200], mmu_man at BerliOS 
>  > -        status_t Wait(bool interruptable);
> > +        status_t Wait(bool interruptable, bigtime_t 
> > timeout=B_INFINITE_TIMEOUT);
> For violating the operator spacing rule the style police fines you 
> one beer, 
> payable at next BeGeistert. :-)

Oh, that could get expensive over time :-)
I we won't get anything done anymore when we're all drunk...

Bye,
   Axel.



From revol at free.fr  Sat May 10 12:14:40 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Sat, 10 May 2008 12:14:40 +0200 CEST
Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support
In-Reply-To: <20080509182256.404.1@knochen-vm.1210348621.fake>
Message-ID: <456804710-BeMail@laptop>

> > What do you mean by compile-time check ?
> > #ifdef in portable code are only used on POSIX errors which were
> > already #defined...
> 
> Yeah, but since they are defined to enum members, those error codes 
> can't 
> be compared at compile-time. E.g. the check
> 
> #if EAGAIN != EWOULDBLOCK
> ...
> 
> (as used in APR) does work only, if they are defined to numerical 
> values.
> 

Right, I use that for signals often.

> Apropos error codes. Alas it seems the GNU tools are right assuming 
> that 
> error codes are positive. I hadn't found an evidence that this is 
> required 
> by POSIX before, but it actually is (cf. the errno.h specification). 
> I 
> suppose we should address that problem at some point in the future.

I already pointed out this several times on several projects.
I had to fix things like ffmpeg, libusb, OSS...
They all assumed such.

There is nothing we can do but get the standards fixed.
Because *they* are wrong, some of them changed their mind with existing 
software around (I always point to the opengroup page about errno).

Fran?ois.


From superstippi at gmx.de  Sat May 10 12:21:38 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Sat, 10 May 2008 12:21:38 +0200
Subject: [Haiku-commits] r25388 - haiku/trunk/src/apps/terminal
In-Reply-To: 
References: <200805090115.m491FXR5028284@sheep.berlios.de>
	
Message-ID: <20080510122138.727.1@stippis2.1210414696.fake>

Hi,

Ryan Leavengood wrote:
> Maybe a modifier could be used to choose what you get. Shift-drop applies 
> the color to the terminal, normal drop pastes the text, or vice versa.

+1

Best regards,
-Stephan


From axeld at pinc-software.de  Sat May 10 12:22:44 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Sat, 10 May 2008 12:22:44 +0200 CEST
Subject: [Haiku-commits]
 =?utf-8?q?r25404_-_haiku/trunk/src/add-ons/kernel?=
 =?utf-8?q?/file=5Fsystems/bfs?=
In-Reply-To: <200805092121.m49LLNaU011227@sheep.berlios.de>
Message-ID: <7508399130-BeMail@zon>

bonefish at BerliOS  wrote:
> Log:
> Don't create anything in a removed directory. Axel, please review. I
> don't see how the locking in Remove()/Create() works.

Does this fix an actual bug? If so, it should probably be moved into 
the VFS instead.
Create/remove locking works over transactions - those are always 
serialized.

Bye,
   Axel.



From revol at free.fr  Sat May 10 12:36:06 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Sat, 10 May 2008 12:36:06 +0200 CEST
Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support
In-Reply-To: 
Message-ID: <1742775390-BeMail@laptop>

> On Fri, May 9, 2008 at 11:22 AM, Ingo Weinhold  
> wrote:
> > Apropos error codes. Alas it seems the GNU tools are right assuming 
> > that
> > error codes are positive. I hadn't found an evidence that this is 
> > required
> > by POSIX before, but it actually is (cf. the errno.h 
> > specification). I
> > suppose we should address that problem at some point in the future.
> 
> That seems to be a more recent change:
> 
> Issue 6
> 
>     The following new requirements on POSIX implementations derive
> from alignment with the Single UNIX Specification:
> 
>     Values for errno are now required to be distinct positive values
> rather than non-zero values. This change is for alignment with the
> ISO/IEC 9899:1999 standard.
> 
> I'm not sure exactly when that update was made though.

Indeed, I always point to that page when explaining to buggy projects:

http://www.opengroup.org/onlinepubs/000095399/basedefs/errno.h.html

We should really complain to them and make it changed back.

I always end up doing something like:

#if EINVAL > 0
#define RETERR(e) (-(e))
#else
#define RETERR(e) (e)
#endif

(yes, not using __BEOS__!)

and change all the return -EFOO to return RETERR(EFOO).
(and return -errno, and other comparisons)

And oddly it just works even though errors are #defined to enums as 
Ingo said, I never noticed that really, not sure how it works but it 
does:

#include 
#include 

#if EINVAL > 0
#define RETERR(e) (-(e))
#else
#define RETERR(e) (e)
#endif

int main(void)
{
	int err = EIO;
	printf("errno 0x%08lx (%d) error 0x%08lx (%d)\n", err, err, 
RETERR(err), RETERR(err));
	return 0;
}

On zeta:
$ ./test_errno_sign
errno 0x80000001 (-2147483647) error 0x80000001 (-2147483647)

On linux:
revol at H555:~$ ./test_errno_sign
errno 0x00000005 (5) error 0xfffffffb (-5)

Ingo, are you sure cpp doesn't actually understand enums ?
Or maybe the fact that EINVAL isn't quantifiable by cpp makes all #if 
using it false ?

Ohhh, actually yes, doing:

#if EINVAL < 0
#define RETERR(e) (e)
#else
#define RETERR(e) (-(e))
#endif

makes it go nuts:
$ ./test_errno_sign
errno 0x80000001 (-2147483647) error 0x7fffffff (2147483647)

I suppose I was just lucky (but why didn't cpp complain then ?) to use 
the correct check in the first place :D

Now, I'm not sure all other OSes actually #define EINVAL correctly for 
cpp, so maybe this check can break some other OS (but I didn't receive 
any complain yet).
Another way would be to check at configure time, but oh well...

Fran?ois.



From revol at free.fr  Sat May 10 12:40:17 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Sat, 10 May 2008 12:40:17 +0200 CEST
Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support
In-Reply-To: <37179560993-BeMail@zon>
Message-ID: <1993970445-BeMail@laptop>

> "Rene Gollent"  wrote:
> > On Fri, May 9, 2008 at 11:22 AM, Ingo Weinhold <
> > ingo_weinhold at gmx.de> 
> > wrote:
> > > Apropos error codes. Alas it seems the GNU tools are right 
> > > assuming 
> > > that
> > > error codes are positive. I hadn't found an evidence that this is 
> > > required
> > > by POSIX before, but it actually is (cf. the errno.h 
> > > specification). I
> > > suppose we should address that problem at some point in the 
> > > future.
> > That seems to be a more recent change:
> > 
> > Issue 6
> > 
> >     The following new requirements on POSIX implementations derive
> > from alignment with the Single UNIX Specification:
> > 
> >     Values for errno are now required to be distinct positive 
> > values
> > rather than non-zero values. This change is for alignment with the
> > ISO/IEC 9899:1999 standard.
> > 
> > I'm not sure exactly when that update was made though.
> 
> I can't see what we can do about it either - it would just break 
> everything if we changed that.
> I find it rather intolerant to make such a change at a time when 
> there 
> were operating systems around that required them to be negative. I 
> also 
> don't really see any advantage in forcing them to be positive.

It allows for lazy linux coders to return -EFOO in other places than 
the kernel itself (it's a tradition in Unix to do that in the kernel).

Of course it would be even faster and less error-prone to return EFOO 
if EFOO was negative in the first place like we do ;)

Indeed it's intolerant, but at least I am used to that.
Besides, I don't think Be ever tried to validate their POSIX 
conformance, so they can probably oppose this to us.

Still we should try to make our point heard and try to change the 
standard back.

Fran?ois.


From revol at free.fr  Sat May 10 12:44:43 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Sat, 10 May 2008 12:44:43 +0200 CEST
Subject: [Haiku-commits] r25388 - haiku/trunk/src/apps/terminal
In-Reply-To: 
Message-ID: <2259862202-BeMail@laptop>

> On Thu, May 8, 2008 at 9:15 PM, mmu_man at BerliOS
>  wrote:
> >
> > Color drop is currently disabled, for now it just pastes it as text 
> > if
> > provided (#rrggbb form from BColorControl).
> 
> I for one don't think that is a bad feature. Though maybe it is 
> better
> to only get the text form in editors. But if you are using VIM or
> another terminal editor it might be nice to be able to drop colors
> into the terminal to get the hex values (for CSS, etc.)
> 
> Maybe a modifier could be used to choose what you get. Shift-drop
> applies the color to the terminal, normal drop pastes the text, or
> vice versa.
> 

Right, or just right mouse button (could eventually have a popup to 
choose).
Just no need to overfeature.

Fran?ois.


From revol at free.fr  Sat May 10 12:45:29 2008
From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol)
Date: Sat, 10 May 2008 12:45:29 +0200 CEST
Subject: [Haiku-commits] r25405 -
 haiku/trunk/src/add-ons/kernel/drivers/tty
In-Reply-To: <20080510003059.1031.4@knochen-vm.1210348621.fake>
Message-ID: <2305355677-BeMail@laptop>

> 
> On 2008-05-09 at 23:48:59 [+0200], mmu_man at BerliOS 
>  > -        status_t Wait(bool interruptable);
> > +        status_t Wait(bool interruptable, bigtime_t 
> > timeout=B_INFINITE_TIMEOUT);
> 
> For violating the operator spacing rule the style police fines you 
> one beer, 
> payable at next BeGeistert. :-)

I'll schedule a budget for that then, it's likely to happen again :D

Fran?ois.


From stippi at mail.berlios.de  Sat May 10 13:12:24 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Sat, 10 May 2008 13:12:24 +0200
Subject: [Haiku-commits] r25410 - haiku/trunk/src/apps/cdplayer
Message-ID: <200805101112.m4ABCORr011722@sheep.berlios.de>

Author: stippi
Date: 2008-05-10 13:12:23 +0200 (Sat, 10 May 2008)
New Revision: 25410
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25410&view=rev

Modified:
   haiku/trunk/src/apps/cdplayer/CDPlayer.cpp
Log:
Fix a few minor coding style violations.


Modified: haiku/trunk/src/apps/cdplayer/CDPlayer.cpp
===================================================================
--- haiku/trunk/src/apps/cdplayer/CDPlayer.cpp	2008-05-10 02:48:57 UTC (rev 25409)
+++ haiku/trunk/src/apps/cdplayer/CDPlayer.cpp	2008-05-10 11:12:23 UTC (rev 25410)
@@ -69,20 +69,21 @@
 //	#pragma mark -
 
 
-CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
+CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask,
+		uint32 flags)
 	: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
  	fCDQuery("freedb.freedb.org")
 {
-	SetViewColor(216,216,216);
+	SetViewColor(216, 216, 216);
 
 	fVolume = 255;
 
 	BuildGUI();
 
 	if (fCDDrive.CountDrives() < 1) {
-		BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD drives"
-									" on your computer or there is no system software"
-									" to support one. Sorry.", "OK");
+		BAlert *alert = new BAlert("CDPlayer", "It appears that there are no CD"
+			" drives on your computer or there is no system software to "
+			"support one. Sorry.", "OK");
 		alert->Go();
 		be_app->PostMessage(B_QUIT_REQUESTED);
 	}
@@ -124,7 +125,8 @@
 	r.bottom = 25;
 
 	float labelWidth, labelHeight;
-	fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty", B_FOLLOW_LEFT_RIGHT);
+	fCDTitle = new BStringView(r, "CDTitle", "CD drive is empty",
+		B_FOLLOW_LEFT_RIGHT);
 	fCDTitle->GetPreferredSize(&labelWidth, &labelHeight);
 	fCDTitle->ResizeTo(r.Width(), labelHeight);
 	box->AddChild(fCDTitle);
@@ -137,11 +139,13 @@
 
 	r.OffsetBy(0, r.Height() + 5);
 	r.right = r.left + (r.Width() / 2);
-	fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--", B_FOLLOW_LEFT_RIGHT);
+	fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--",
+		B_FOLLOW_LEFT_RIGHT);
 	box->AddChild(fTrackTime);
 
 	r.OffsetTo(box->Bounds().right / 2, r.top);
-	fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--", B_FOLLOW_RIGHT);
+	fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--",
+		B_FOLLOW_RIGHT);
 	fDiscTime->ResizeToPreferred();
 	fDiscTime->ResizeBy(10, 0);
 	box->AddChild(fDiscTime);
@@ -154,7 +158,8 @@
 		new BMessage(M_STOP), B_FOLLOW_BOTTOM, B_WILL_DRAW);
 	fStop->ResizeToPreferred();
 	fStop->MoveTo(10, box->Frame().bottom + 15);
-	fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_disabled"));
+	fStop->SetDisabled(BTranslationUtils::GetBitmap(B_PNG_FORMAT,
+		"stop_disabled"));
 	AddChild(fStop);
 	float stopTop = fStop->Frame().top;
 
@@ -254,7 +259,8 @@
 
 		case M_STOP:
 			if (fWindowState == kPaused) {
-				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
+				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
+					"play_up"),
 					BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
 				fPlay->SetState(1);
 			}
@@ -268,12 +274,14 @@
 			if (fWindowState == kPlaying) {
 				fWindowState = kPaused;
 				fCDDrive.Pause();
-				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "paused_up"),
+				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
+					"paused_up"),
 					BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
 			} else if (fWindowState == kPaused) {
 				fWindowState = kPlaying;
 				fCDDrive.Resume();
-				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_up"),
+				fPlay->SetBitmaps(0, BTranslationUtils::GetBitmap(B_PNG_FORMAT,
+					"play_up"),
 					BTranslationUtils::GetBitmap(B_PNG_FORMAT, "play_down"));
 			} else {
 				fWindowState = kPlaying;
@@ -447,7 +455,8 @@
 			// We have just discovered that we have no bananas
 			fWindowState = kNoCD;
 
-			// Because we are changing play states, we will need to update the GUI
+			// Because we are changing play states, we will need to update
+			// the GUI
 			fCDData.SetDiscID(-1);
 			SetLabel(fCDTitle, "CD drive is empty");
 
@@ -470,8 +479,8 @@
 		if (fWindowState == kPlaying) {
 			internalTrackChange = true;
 
-			// This means that the drive finished playing the song, so get the next one
-			// from the list and play it
+			// This means that the drive finished playing the song, so get
+			// the next one from the list and play it
 			int16 next = fPlayList.GetNextTrack();
 			if (next > 0)
 				fCDDrive.Play(next);
@@ -485,8 +494,8 @@
 	} else if (playState == kPaused)
 		fPlay->SetState(0);
 
-	// If we got this far, then there must be a CD in the drive. The next order on the agenda
-	// is to find out which CD it is
+	// If we got this far, then there must be a CD in the drive. The next order
+	// on the agenda is to find out which CD it is
 	int32 discId = fCDDrive.GetDiscID();
 	bool updateTrackGui = false;
 
@@ -498,8 +507,8 @@
 			fCDQuery.SetToCD(fCDDrive.GetDrivePath());
 
 		if (fCDQuery.Ready()) {
-			// Note that we only update the CD title for now. We still need a track number
-			// in order to update the display for the selected track
+			// Note that we only update the CD title for now. We still need a
+			// track number in order to update the display for the selected track
 			if (fCDQuery.GetData(&fCDData, 1000000)) {
 				BString display(fCDData.Artist());
 				display << " - " << fCDData.Album();
@@ -521,8 +530,9 @@
 			playlistTrack = driveTrack;
 
 			if (!internalTrackChange) {
-				// The main thing is that we need to make sure that the playlist and the drive's track
-				// stay in sync. The CD's track may have been changed by an outside source, so if
+				// The main thing is that we need to make sure that the
+				// playlist and the drive's track stay in sync. The CD's
+				// track may have been changed by an outside source, so if
 				// the drive is playing, check for playlist sync.
 				fPlayList.SetTrackCount(driveCount);
 				fPlayList.SetCurrentTrack(driveTrack);
@@ -533,16 +543,16 @@
 		if (playlistCount != driveCount) {
 			// This happens only when CDs are changed
 			if (driveCount < 0) {
-				// There is no CD in the drive. The playlist needs to have its track
-				// count set to 0 and it also needs to be rewound.
+				// There is no CD in the drive. The playlist needs to have its
+				// track count set to 0 and it also needs to be rewound.
 				fPlayList.SetStartingTrack(1);
 				fPlayList.SetTrackCount(0);
 				playlistTrack = 1;
 				playlistCount = 0;
 			} else {
-				// Two possible cases here: playlist is empty or playlist has a different
-				// number of tracks. In either case, the playlist needs to be reinitialized
-				// to the current track data
+				// Two possible cases here: playlist is empty or playlist has a
+				// different number of tracks. In either case, the playlist
+				// needs to be reinitialized to the current track data
 				fPlayList.SetStartingTrack(1);
 				fPlayList.SetTrackCount(driveCount);
 				playlistTrack = fPlayList.GetCurrentTrack();
@@ -564,7 +574,8 @@
 			if (whichTrack == 0)
 				whichTrack++;
 
-			currentTrackName << "Track " << whichTrack << ": " << fCDData.TrackAt(whichTrack - 1);
+			currentTrackName << "Track " << whichTrack << ": "
+				<< fCDData.TrackAt(whichTrack - 1);
 
 			SetLabel(fCurrentTrack, currentTrackName.String());
 
@@ -581,13 +592,15 @@
 
 	if (fCDDrive.GetTime(trackTime, discTime)) {
 		fCDDrive.GetTimeForDisc(discTotal);
-		sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld", discTime.GetMinutes(),
-			discTime.GetSeconds(), discTotal.GetMinutes(), discTotal.GetSeconds());
+		sprintf(timeString, "Disc: %ld:%.2ld / %ld:%.2ld",
+			discTime.GetMinutes(), discTime.GetSeconds(),
+			discTotal.GetMinutes(), discTotal.GetSeconds());
 		SetLabel(fDiscTime, timeString);
 
 		fCDDrive.GetTimeForTrack(playlistTrack, trackTotal);
-		sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld", trackTime.GetMinutes(),
-			trackTime.GetSeconds(), trackTotal.GetMinutes(), trackTotal.GetSeconds());
+		sprintf(timeString, "Track: %ld:%.2ld / %ld:%.2ld",
+			trackTime.GetMinutes(), trackTime.GetSeconds(),
+			trackTotal.GetMinutes(), trackTotal.GetSeconds());
 		SetLabel(fTrackTime, timeString);
 	} else {
 		SetLabel(fTrackTime, "Track: --:-- / --:--");
@@ -600,8 +613,8 @@
 
 
 CDPlayerWindow::CDPlayerWindow()
-	: BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW, B_NOT_RESIZABLE |
-		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
+	: BWindow(BRect (100, 100, 405, 280), "CDPlayer", B_TITLED_WINDOW,
+		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
 {
 }
 



From mmu_man at mail.berlios.de  Sat May 10 13:22:21 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sat, 10 May 2008 13:22:21 +0200
Subject: [Haiku-commits] r25411 - haiku/trunk/src/apps/terminal
Message-ID: <200805101122.m4ABMLHr029182@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-10 13:22:18 +0200 (Sat, 10 May 2008)
New Revision: 25411
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25411&view=rev

Modified:
   haiku/trunk/src/apps/terminal/Shell.cpp
   haiku/trunk/src/apps/terminal/Shell.h
   haiku/trunk/src/apps/terminal/TermView.cpp
Log:
Indeed we don't need this signal hack for BeOS, we just need to tell it the pgid. That reduces the number of things to remove later ;)


Modified: haiku/trunk/src/apps/terminal/Shell.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.cpp	2008-05-10 11:12:23 UTC (rev 25410)
+++ haiku/trunk/src/apps/terminal/Shell.cpp	2008-05-10 11:22:18 UTC (rev 25411)
@@ -194,27 +194,13 @@
 	struct winsize winSize;
 	winSize.ws_row = rows;
 	winSize.ws_col = columns;
-#ifdef __HAIKU__
 	if (ioctl(fFd, TIOCSWINSZ, &winSize) != 0)
 		return errno;
 	return B_OK;
-#else
-	ioctl(fFd, TIOCSWINSZ, &winSize);
-	return Signal(SIGWINCH);
-#endif
 }
 
 
-#ifndef __HAIKU__
 status_t
-Shell::Signal(int signal)
-{
-	return send_signal(-fProcessID, signal);
-}
-#endif
-
-
-status_t
 Shell::GetAttr(struct termios &attr)
 {
 	if (tcgetattr(fFd, &attr) < 0)
@@ -496,6 +482,9 @@
 
 		tcsetpgrp(0, getpgrp());
 			// set this process group ID as the controlling terminal
+#ifndef __HAIKU__
+		ioctl(0, 'pgid', getpid());
+#endif
 
 		/* pty open and set termios successful. */
 		handshake.status = PTY_OK;

Modified: haiku/trunk/src/apps/terminal/Shell.h
===================================================================
--- haiku/trunk/src/apps/terminal/Shell.h	2008-05-10 11:12:23 UTC (rev 25410)
+++ haiku/trunk/src/apps/terminal/Shell.h	2008-05-10 11:22:18 UTC (rev 25411)
@@ -32,9 +32,6 @@
 	ssize_t		Write(const void *buffer, size_t numBytes);
 
 	status_t	UpdateWindowSize(int row, int columns);
-#ifndef __HAIKU__
-	status_t	Signal(int signal);
-#endif
 
 	status_t	GetAttr(struct termios &attr);
 	status_t	SetAttr(struct termios &attr);

Modified: haiku/trunk/src/apps/terminal/TermView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermView.cpp	2008-05-10 11:12:23 UTC (rev 25410)
+++ haiku/trunk/src/apps/terminal/TermView.cpp	2008-05-10 11:22:18 UTC (rev 25411)
@@ -1471,17 +1471,6 @@
 	currentMessage->FindInt32("key", &key);
 	currentMessage->FindInt32("raw_char", &rawChar);
 
-#ifndef __HAIKU__
-	// If bytes[0] equal intr character,
-	// send signal to shell process group.
-	struct termios tio;
-	fShell->GetAttr(tio);
-	if (*bytes == tio.c_cc[VINTR]) {
-		if (tio.c_lflag & ISIG)
-			fShell->Signal(SIGINT);
-	}
-#endif
-
 	// Terminal filters RET, ENTER, F1...F12, and ARROW key code.
 	// TODO: Cleanup
 	if (numBytes == 1) {



From stippi at mail.berlios.de  Sat May 10 13:27:48 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Sat, 10 May 2008 13:27:48 +0200
Subject: [Haiku-commits] r25412 - haiku/trunk/src/apps/cdplayer
Message-ID: <200805101127.m4ABRmOB013717@sheep.berlios.de>

Author: stippi
Date: 2008-05-10 13:27:48 +0200 (Sat, 10 May 2008)
New Revision: 25412
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25412&view=rev

Modified:
   haiku/trunk/src/apps/cdplayer/CDPlayer.cpp
Log:
* Used ui_color() for default view color.
* Fixed Track and Disc time labels to be large enough. (Fixes #2201.)


Modified: haiku/trunk/src/apps/cdplayer/CDPlayer.cpp
===================================================================
--- haiku/trunk/src/apps/cdplayer/CDPlayer.cpp	2008-05-10 11:22:18 UTC (rev 25411)
+++ haiku/trunk/src/apps/cdplayer/CDPlayer.cpp	2008-05-10 11:27:48 UTC (rev 25412)
@@ -74,7 +74,7 @@
 	: BView(frame, name, resizeMask, flags | B_FRAME_EVENTS),
  	fCDQuery("freedb.freedb.org")
 {
-	SetViewColor(216, 216, 216);
+	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 
 	fVolume = 255;
 
@@ -139,19 +139,23 @@
 
 	r.OffsetBy(0, r.Height() + 5);
 	r.right = r.left + (r.Width() / 2);
-	fTrackTime = new BStringView(r, "TrackTime", "Track: --:-- / --:--",
+	fTrackTime = new BStringView(r, "TrackTime", "Track: 88:88 / 88:88",
 		B_FOLLOW_LEFT_RIGHT);
+	fTrackTime->ResizeToPreferred();
+	fTrackTime->SetText("Track: --:-- / --:--");
 	box->AddChild(fTrackTime);
 
-	r.OffsetTo(box->Bounds().right / 2, r.top);
-	fDiscTime = new BStringView(r, "DiscTime", "Disc: --:-- / --:--",
+	r.OffsetTo(fTrackTime->Frame().right + 5, r.top);
+	fDiscTime = new BStringView(r, "DiscTime", "Disc: 88:88 / 88:88",
 		B_FOLLOW_RIGHT);
 	fDiscTime->ResizeToPreferred();
-	fDiscTime->ResizeBy(10, 0);
+	fDiscTime->SetText("Disc: --:-- / --:--");
 	box->AddChild(fDiscTime);
 
-	box->ResizeTo(fCDTitle->Frame().right + 5, fDiscTime->Frame().bottom + 10);
+	float maxWidth = max_c(fDiscTime->Frame().right, fCDTitle->Frame().right);
 
+	box->ResizeTo(maxWidth + 5, fDiscTime->Frame().bottom + 10);
+
 	fStop = new DrawButton(BRect(0, 0, 1, 1), "Stop",
 		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_up"),
 		BTranslationUtils::GetBitmap(B_PNG_FORMAT, "stop_down"),



From stippi at mail.berlios.de  Sat May 10 13:41:29 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Sat, 10 May 2008 13:41:29 +0200
Subject: [Haiku-commits] r25413 - haiku/trunk/src/data/etc/keymaps
Message-ID: <200805101141.m4ABfT2c014713@sheep.berlios.de>

Author: stippi
Date: 2008-05-10 13:41:28 +0200 (Sat, 10 May 2008)
New Revision: 25413
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25413&view=rev

Modified:
   haiku/trunk/src/data/etc/keymaps/Japanese.keymap
Log:
Applied patch by SHINTA to enable Zenkaku/Hankaku key codes in Japanese keymap.


Modified: haiku/trunk/src/data/etc/keymaps/Japanese.keymap
===================================================================
--- haiku/trunk/src/data/etc/keymaps/Japanese.keymap	2008-05-10 11:27:48 UTC (rev 25412)
+++ haiku/trunk/src/data/etc/keymaps/Japanese.keymap	2008-05-10 11:41:28 UTC (rev 25413)
@@ -76,7 +76,7 @@
 Key 0x0e = 0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     
 Key 0x0f = 0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     
 Key 0x10 = 0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     0x10     
-Key 0x11 = ' '      ''       ''       ' '      ''       ''       ''       ' '      ''       
+Key 0x11 = 0xf3     0xf3     0xf3     0xf3     0xf3     0xf3     0xf3     0xf3     0xf3       
 Key 0x12 = '1'      '!'      ''       ' '      ''       '1'      '!'      ' '      ''       
 Key 0x13 = '2'      '"'      ''       ' '      ''       '2'      '"'      ' '      ''       
 Key 0x14 = '3'      '#'      ''       ' '      ''       '3'      '#'      ' '      ''       
@@ -169,7 +169,7 @@
 Key 0x6b = '\\'     '_'      0x1f     ' '      ''       '\\'     '_'      ' '      ''       
 Key 0x6c = ''       ''       ''       ''       ''       ''       ''       ''       ''       
 Key 0x6d = ''       ''       ''       ''       ''       ''       ''       ''       ''       
-Key 0x6e = ''       ''       ''       ''       ''       ''       ''       ''       ''       
+Key 0x6e = 0xf2    0xf2     0xf2     0xf2    0xf2     0xf2     0xf2     0xf2    0xf2     
 Key 0x6f = '='      '='      '='      '='      '='      '='      '='      '='      '='      
 Key 0x70 = ','      ','      ','      ','      ','      ','      ','      ','      ','      
 Key 0x71 = ''       ''       ''       ''       ''       ''       ''       ''       ''       



From axeld at mail.berlios.de  Sat May 10 13:44:02 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Sat, 10 May 2008 13:44:02 +0200
Subject: [Haiku-commits] r25414 - in haiku/trunk: headers/os/drivers
	headers/private/fs_shell headers/private/kernel/disk_device_manager
	headers/private/storage src/add-ons/kernel/file_systems/bfs
	src/add-ons/kernel/file_systems/cdda
	src/add-ons/kernel/file_systems/fat
	src/add-ons/kernel/file_systems/googlefs
	src/add-ons/kernel/file_systems/iso9660
	src/add-ons/kernel/file_systems/ntfs
	src/add-ons/kernel/file_systems/ramfs
	src/add-ons/kernel/file_systems/reiserfs
	src/add-ons/kernel/partitioning_systems/amiga
	src/add-ons/kernel/partitioning_systems/apple
	src/add-ons/kernel/partitioning_systems/atari
	src/add-ons/kernel/partitioning_systems/efi
	src/add-ons/kernel/partitioning_systems/intel
	src/add-ons/kernel/partitioning_systems/session
	src/kits/storage/disk_device
	src/system/kernel/disk_device_manager src/system/kernel/fs
Message-ID: <200805101144.m4ABi22d014889@sheep.berlios.de>

Author: axeld
Date: 2008-05-10 13:44:00 +0200 (Sat, 10 May 2008)
New Revision: 25414
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25414&view=rev

Modified:
   haiku/trunk/headers/os/drivers/fs_interface.h
   haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h
   haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h
   haiku/trunk/headers/private/kernel/disk_device_manager/ddm_modules.h
   haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h
   haiku/trunk/headers/private/storage/DiskDeviceRoster.h
   haiku/trunk/headers/private/storage/DiskSystem.h
   haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
   haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
   haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
   haiku/trunk/src/add-ons/kernel/file_systems/googlefs/googlefs.c
   haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp
   haiku/trunk/src/add-ons/kernel/file_systems/ntfs/kernel_interface.c
   haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp
   haiku/trunk/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/apple/apple.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/atari/atari.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp
   haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp
   haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp
   haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp
   haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp
   haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp
   haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp
   haiku/trunk/src/system/kernel/fs/devfs.cpp
   haiku/trunk/src/system/kernel/fs/rootfs.cpp
Log:
* Added BDiskSystem::ShortName() and everything needed to get it there.
* Added BDiskDeviceRoster::GetDiskSystem() method, that can get a disk system
  by short/pretty/module name - since they should all be unique, I put them
  in a single namespace, please complain if you don't like that :-)
* Cleaned up DiskSystem.h and DiskDeviceRoster.h according to the updated
  header guidelines.
* Renamed ntfs pretty name from "ntfs File System" to "Windows NT File System".


Modified: haiku/trunk/headers/os/drivers/fs_interface.h
===================================================================
--- haiku/trunk/headers/os/drivers/fs_interface.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/os/drivers/fs_interface.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -232,6 +232,7 @@
 
 typedef struct file_system_module_info {
 	struct module_info	info;
+	const char*			short_name;
 	const char*			pretty_name;
 	uint32				flags;	// DDM flags
 

Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h
===================================================================
--- haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -266,6 +266,7 @@
 
 typedef struct fssh_file_system_module_info {
 	struct fssh_module_info	info;
+	const char*				short_name;
 	const char*				pretty_name;
 	uint32_t				flags;	// DDM flags
 

Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h
===================================================================
--- haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
+ * Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -8,6 +8,7 @@
 #ifndef _K_DISK_DEVICE_SYSTEM_H
 #define _K_DISK_DEVICE_SYSTEM_H
 
+
 #include "disk_device_manager.h"
 
 
@@ -33,7 +34,8 @@
 			disk_system_id		ID() const;
 
 			const char*			Name() const;
-			const char*			PrettyName();
+			const char*			ShortName() const;
+			const char*			PrettyName() const;
 			uint32				Flags() const;
 
 			bool				IsFileSystem() const;
@@ -97,6 +99,7 @@
 	virtual	status_t			LoadModule();
 	virtual	void				UnloadModule();
 
+			status_t			SetShortName(const char* name);
 			status_t			SetPrettyName(const char* name);
 			void				SetFlags(uint32 flags);
 
@@ -105,6 +108,7 @@
 private:
 			disk_system_id		fID;
 			char*				fName;
+			char*				fShortName;
 			char*				fPrettyName;
 			uint32				fFlags;
 			int32				fLoadCounter;

Modified: haiku/trunk/headers/private/kernel/disk_device_manager/ddm_modules.h
===================================================================
--- haiku/trunk/headers/private/kernel/disk_device_manager/ddm_modules.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/kernel/disk_device_manager/ddm_modules.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,10 +1,12 @@
-// ddm_modules.h
-//
-// Interface to be implemented by partitioning modules.
-
+/*
+ * Copyright 2003-2008, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ */
 #ifndef _K_DISK_DEVICE_MODULES_H
 #define _K_DISK_DEVICE_MODULES_H
 
+//! Interface to be implemented by partitioning modules.
+
 #include 
 #include 
 #include 
@@ -12,6 +14,7 @@
 
 typedef struct partition_module_info {
 	module_info									module;
+	const char*									short_name;
 	const char*									pretty_name;
 	uint32										flags;
 

Modified: haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h
===================================================================
--- haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,5 +1,10 @@
-// ddm_userland_interface.h
-
+/*
+ * Copyright 2003-2008, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *		Ingo Weinhold, bonefish at users.sf.net
+ */
 #ifndef _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
 #define _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
 
@@ -49,6 +54,7 @@
 typedef struct user_disk_system_info {
 	disk_system_id	id;
 	char			name[B_FILE_NAME_LENGTH];	// better B_PATH_NAME_LENGTH?
+	char			short_name[B_OS_NAME_LENGTH];
 	char			pretty_name[B_OS_NAME_LENGTH];
 	uint32			flags;
 } user_disk_system_info;

Modified: haiku/trunk/headers/private/storage/DiskDeviceRoster.h
===================================================================
--- haiku/trunk/headers/private/storage/DiskDeviceRoster.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/storage/DiskDeviceRoster.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,8 +1,7 @@
-//----------------------------------------------------------------------
-//  This software is part of the OpenBeOS distribution and is covered 
-//  by the OpenBeOS license.
-//---------------------------------------------------------------------
-
+/*
+ * Copyright 2003-2008, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ */
 #ifndef _DISK_DEVICE_ROSTER_H
 #define _DISK_DEVICE_ROSTER_H
 
@@ -85,45 +84,52 @@
 
 class BDiskDeviceRoster {
 public:
-	BDiskDeviceRoster();
-	~BDiskDeviceRoster();
-	
-	status_t GetNextDevice(BDiskDevice *device);
-	status_t RewindDevices();
-	
-	status_t GetNextDiskSystem(BDiskSystem *system);
-	status_t RewindDiskSystems();
+							BDiskDeviceRoster();
+							~BDiskDeviceRoster();
 
-	partition_id RegisterFileDevice(const char *filename);
-		// publishes: /dev/disk/virtual/files//raw
-	status_t UnregisterFileDevice(const char *filename);
-	status_t UnregisterFileDevice(partition_id device);
+			status_t		GetNextDevice(BDiskDevice* device);
+			status_t		RewindDevices();
 
-	bool VisitEachDevice(BDiskDeviceVisitor *visitor,
-						 BDiskDevice *device = NULL);
-	bool VisitEachPartition(BDiskDeviceVisitor *visitor,
-							BDiskDevice *device = NULL,
-							BPartition **partition = NULL);
+			status_t		GetNextDiskSystem(BDiskSystem* system);
+			status_t		RewindDiskSystems();
 
-	bool VisitEachMountedPartition(BDiskDeviceVisitor *visitor,
-								   BDiskDevice *device = NULL,
-								   BPartition **partition = NULL);
-	bool VisitEachMountablePartition(BDiskDeviceVisitor *visitor,
-									 BDiskDevice *device = NULL,
-									 BPartition **partition = NULL);
-									 
-	status_t GetDeviceWithID(partition_id id, BDiskDevice *device) const;
-	status_t GetPartitionWithID(partition_id id, BDiskDevice *device,
-								BPartition **partition) const;
+			status_t		GetDiskSystem(BDiskSystem* system, const char* name);
 
-	status_t GetDeviceForPath(const char *filename, BDiskDevice *device);
-	status_t GetPartitionForPath(const char *filename, BDiskDevice *device,
-								 BPartition **partition);
+			partition_id	RegisterFileDevice(const char* filename);
+				// publishes: /dev/disk/virtual/files//raw
+			status_t		UnregisterFileDevice(const char* filename);
+			status_t		UnregisterFileDevice(partition_id device);
 
-	status_t StartWatching(BMessenger target,
-						   uint32 eventMask = B_DEVICE_REQUEST_ALL);
-	status_t StopWatching(BMessenger target);
+			bool			VisitEachDevice(BDiskDeviceVisitor* visitor,
+								BDiskDevice* device = NULL);
+			bool			VisitEachPartition(BDiskDeviceVisitor* visitor,
+								BDiskDevice* device = NULL,
+								BPartition** _partition = NULL);
 
+			bool			VisitEachMountedPartition(
+								BDiskDeviceVisitor* visitor,
+								BDiskDevice* device = NULL,
+								BPartition** _partition = NULL);
+			bool			VisitEachMountablePartition(
+								BDiskDeviceVisitor* visitor,
+								BDiskDevice* device = NULL,
+								BPartition** _partition = NULL);
+
+			status_t		GetDeviceWithID(partition_id id,
+								BDiskDevice* device) const;
+			status_t		GetPartitionWithID(partition_id id,
+								BDiskDevice* device,
+								BPartition** _partition) const;
+
+			status_t		GetDeviceForPath(const char* filename,
+								BDiskDevice* device);
+			status_t		GetPartitionForPath(const char* filename,
+								BDiskDevice* device, BPartition** _partition);
+
+			status_t		StartWatching(BMessenger target,
+								uint32 eventMask = B_DEVICE_REQUEST_ALL);
+			status_t		StopWatching(BMessenger target);
+
 private:
 #if 0
 	status_t _GetObjectWithID(const char *fieldName, partition_id id,
@@ -146,9 +152,9 @@
 										BDiskScannerPartitionAddOn **addOn);
 #endif	// 0
 private:
-	int32		fDeviceCookie;
-	int32		fDiskSystemCookie;
-	int32		fJobCookie;
+	int32					fDeviceCookie;
+	int32					fDiskSystemCookie;
+	int32					fJobCookie;
 //	BDirectory	*fPartitionAddOnDir;
 //	BDirectory	*fFSAddOnDir;
 //	int32		fPartitionAddOnDirIndex;

Modified: haiku/trunk/headers/private/storage/DiskSystem.h
===================================================================
--- haiku/trunk/headers/private/storage/DiskSystem.h	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/headers/private/storage/DiskSystem.h	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,15 +1,14 @@
-//----------------------------------------------------------------------
-//  This software is part of the OpenBeOS distribution and is covered 
-//  by the OpenBeOS license.
-//---------------------------------------------------------------------
-
+/*
+ * Copyright 2003-2008, Haiku Inc.
+ * Distributed under the terms of the MIT License.
+ */
 #ifndef _DISK_SYSTEM_H
 #define _DISK_SYSTEM_H
 
+
 #include 
 #include 
 
-
 class BPartition;
 class BString;
 struct user_disk_system_info;
@@ -17,52 +16,58 @@
 
 class BDiskSystem {
 public:
-	BDiskSystem();
-	BDiskSystem(const BDiskSystem& other);
-	~BDiskSystem();
+							BDiskSystem();
+							BDiskSystem(const BDiskSystem& other);
+							~BDiskSystem();
 
-	status_t InitCheck() const;
+			status_t		InitCheck() const;
 
-	const char *Name() const;
-	const char *PrettyName() const;
+			const char*		Name() const;
+			const char*		ShortName() const;
+			const char*		PrettyName() const;
 
-	bool SupportsDefragmenting(bool *whileMounted) const;
-	bool SupportsRepairing(bool checkOnly, bool *whileMounted) const;
-	bool SupportsResizing(bool *whileMounted) const;
-	bool SupportsResizingChild() const;
-	bool SupportsMoving(bool *whileMounted) const;
-	bool SupportsMovingChild() const;
-	bool SupportsName() const;
-	bool SupportsContentName() const;
-	bool SupportsSettingName() const;
-	bool SupportsSettingContentName(bool *whileMounted) const;
-	bool SupportsSettingType() const;
-	bool SupportsSettingParameters() const;
-	bool SupportsSettingContentParameters(bool *whileMounted) const;
-	bool SupportsCreatingChild() const;
-	bool SupportsDeletingChild() const;
-	bool SupportsInitializing() const;
+			bool			SupportsDefragmenting(bool* whileMounted) const;
+			bool			SupportsRepairing(bool checkOnly,
+								bool* whileMounted) const;
+			bool			SupportsResizing(bool* whileMounted) const;
+			bool			SupportsResizingChild() const;
+			bool			SupportsMoving(bool* whileMounted) const;
+			bool			SupportsMovingChild() const;
+			bool			SupportsName() const;
+			bool			SupportsContentName() const;
+			bool			SupportsSettingName() const;
+			bool			SupportsSettingContentName(
+								bool* whileMounted) const;
+			bool			SupportsSettingType() const;
+			bool			SupportsSettingParameters() const;
+			bool			SupportsSettingContentParameters(
+								bool* whileMounted) const;
+			bool			SupportsCreatingChild() const;
+			bool			SupportsDeletingChild() const;
+			bool			SupportsInitializing() const;
 
-	status_t GetTypeForContentType(const char *contentType,
-		BString* type) const;
+			status_t		GetTypeForContentType(const char* contentType,
+								BString* type) const;
 
-	bool IsPartitioningSystem() const;
-	bool IsFileSystem() const;
+			bool			IsPartitioningSystem() const;
+			bool			IsFileSystem() const;
 
-	BDiskSystem& operator=(const BDiskSystem& other);
+			BDiskSystem&	operator=(const BDiskSystem& other);
 
 private:
-	status_t _SetTo(disk_system_id id);
-	status_t _SetTo(const user_disk_system_info *info);
-	void _Unset();
+			status_t		_SetTo(disk_system_id id);
+			status_t		_SetTo(const user_disk_system_info* info);
+			void			_Unset();
 
+private:
 	friend class BDiskDeviceRoster;
 	friend class BPartition;
 
-	disk_system_id	fID;
-	BString			fName;
-	BString			fPrettyName;
-	uint32			fFlags;
+	disk_system_id			fID;
+	BString					fName;
+	BString					fShortName;
+	BString					fPrettyName;
+	uint32					fFlags;
 };
 
 #endif	// _DISK_SYSTEM_H

Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -2288,7 +2288,8 @@
 		bfs_std_ops,
 	},
 
-	"Be File System",
+	"bfs",						// short_name
+	"Be File System",			// pretty_name
 
 	// DDM flags
 	0

Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -2006,7 +2006,8 @@
 		cdda_std_ops,
 	},
 
-	"CDDA File System",
+	"cdda",					// short_name
+	"CDDA File System",		// pretty_name
 	0,	// DDM flags
 
 	cdda_identify_partition,

Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1313,7 +1313,8 @@
 		dos_std_ops,
 	},
 
-	"FAT32 File System",
+	"fat",					// short_name
+	"FAT32 File System",	// pretty_name
 	0,	// DDM flags
 
 	// scanning

Modified: haiku/trunk/src/add-ons/kernel/file_systems/googlefs/googlefs.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/googlefs/googlefs.c	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/googlefs/googlefs.c	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1619,7 +1619,8 @@
 		googlefs_std_ops,
 	},
 
-	GOOGLEFS_PRETTY_NAME,
+	"googlefs",					// short_name
+	GOOGLEFS_PRETTY_NAME,		// pretty_name
 	0,	// DDM flags
 
 	// scanning

Modified: haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -745,8 +745,9 @@
 		iso_std_ops,
 	},
 
-	"ISO9660 File System",
-	0,	// DDM flags
+	"iso9660",					// short_name
+	"ISO9660 File System",		// pretty_name
+	0,							// DDM flags
 
 	// scanning
 	fs_identify_partition,

Modified: haiku/trunk/src/add-ons/kernel/file_systems/ntfs/kernel_interface.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/ntfs/kernel_interface.c	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/ntfs/kernel_interface.c	2008-05-10 11:44:00 UTC (rev 25414)
@@ -84,8 +84,9 @@
 		ntfs_std_ops,
 	},
 
-	"ntfs File System",
-	0,	// DDM flags
+	"ntfs",						// short_name
+	"Windows NT File System",	// pretty_name
+	0,							// DDM flags
 
 	// scanning
 	fs_identify_partition,

Modified: haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -2069,8 +2069,9 @@
 		ramfs_std_ops,
 	},
 
-	"RAM File System",
-	0,	// DDM flags
+	"ramfs",				// short_name
+	"RAM File System",		// pretty_name
+	0,						// DDM flags
 
 	// scanning
 	NULL,	// identify_partition()

Modified: haiku/trunk/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -649,8 +649,9 @@
 		reiserfs_std_ops,
 	},
 
-	"Reiser File System",
-	0,	// DDM flags
+	"reiserfs",					// short_name
+	"Reiser File System",		// pretty_name
+	0,							// DDM flags
 
 	// scanning
 	NULL,	// identify_partition()

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -218,6 +218,7 @@
 		0,
 		amiga_rdb_std_ops
 	},
+	"amiga",							// short_name
 	AMIGA_PARTITION_NAME,				// pretty_name
 	0,									// flags
 

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/apple/apple.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/apple/apple.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/apple/apple.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -203,6 +203,7 @@
 		0,
 		apple_std_ops
 	},
+	"apple",							// short_name
 	APPLE_PARTITION_NAME,				// pretty_name
 	0,									// flags
 

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/atari/atari.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/atari/atari.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/atari/atari.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,7 +1,7 @@
 /*
-** Copyright 2003-2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
-** Distributed under the terms of the Haiku License.
-*/
+ * Copyright 2003-2004, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
 
 
 #include "atari.h"
@@ -222,6 +222,7 @@
 		0,
 		atari_std_ops
 	},
+	"atari",							// short_name
 	ATARI_PARTITION_NAME,				// pretty_name
 	0,									// flags
 
@@ -240,4 +241,3 @@
 	NULL
 };
 #endif
-

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
 
@@ -399,6 +399,7 @@
 		0,
 		efi_gpt_std_ops
 	},
+	"efi",									// short_name
 	EFI_PARTITION_NAME,						// pretty_name
 	0,										// flags
 

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
+ * Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -427,6 +427,7 @@
 		0,
 		pm_std_ops
 	},
+	"intel",							// short_name
 	INTEL_PARTITION_NAME,				// pretty_name
 
 	// flags
@@ -513,6 +514,7 @@
 		0,
 		ep_std_ops
 	},
+	"intel_extended",					// short_name
 	INTEL_EXTENDED_PARTITION_NAME,		// pretty_name
 
 	// flags

Modified: haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -114,6 +114,7 @@
 		0,
 		standard_operations
 	},
+	"session",							// short_name
 	SESSION_PARTITION_NAME,				// pretty_name
 	0,									// flags
 

Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp
===================================================================
--- haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,7 +1,11 @@
-//----------------------------------------------------------------------
-//  This software is part of the OpenBeOS distribution and is covered 
-//  by the OpenBeOS license.
-//---------------------------------------------------------------------
+/*
+ * Copyright 2003-2008, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *		Ingo Weinhold, bonefish at cs.tu-berlin.de
+ *		Axel D?rfler, axeld at pinc-software.de
+ */
 
 #include 
 
@@ -82,7 +86,7 @@
 		return B_BAD_VALUE;
 	size_t neededSize = 0;
 	partition_id id = _kern_get_next_disk_device_id(&fDeviceCookie,
-													&neededSize);
+		&neededSize);
 	if (id < 0)
 		return id;
 	return device->_SetTo(id, true, neededSize);
@@ -99,21 +103,21 @@
 	return B_OK;
 }
 
-// GetNextDiskSystem
+
 status_t
-BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem *system)
+BDiskDeviceRoster::GetNextDiskSystem(BDiskSystem* system)
 {
 	if (!system)
 		return B_BAD_VALUE;
 	user_disk_system_info info;
 	status_t error = _kern_get_next_disk_system_info(&fDiskSystemCookie,
-													 &info);
+		&info);
 	if (error == B_OK)
 		error = system->_SetTo(&info);
 	return error;
 }
 
-// RewindDiskSystems
+
 status_t
 BDiskDeviceRoster::RewindDiskSystems()
 {
@@ -122,7 +126,25 @@
 }
 
 
-// RegisterFileDevice
+status_t
+BDiskDeviceRoster::GetDiskSystem(BDiskSystem* system, const char* name)
+{
+	if (!system)
+		return B_BAD_VALUE;
+
+	int32 cookie = 0;
+	user_disk_system_info info;
+	while (_kern_get_next_disk_system_info(&fDiskSystemCookie, &info) == B_OK) {
+		if (!strcmp(name, info.name)
+			|| !strcmp(name, info.short_name)
+			|| !strcmp(name, info.pretty_name))
+			return system->_SetTo(&info);
+	}
+
+	return B_ENTRY_NOT_FOUND;
+}
+
+
 partition_id
 BDiskDeviceRoster::RegisterFileDevice(const char *filename)
 {

Modified: haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp
===================================================================
--- haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -16,20 +16,21 @@
 
 // constructor
 BDiskSystem::BDiskSystem()
-	: fID(B_NO_INIT),
-	  fName(),
-	  fPrettyName(),
-	  fFlags(0)
+	:
+	fID(B_NO_INIT),
+	fFlags(0)
 {
 }
 
 
 // copy constructor
 BDiskSystem::BDiskSystem(const BDiskSystem& other)
-	: fID(other.fID),
-	  fName(other.fName),
-	  fPrettyName(other.fPrettyName),
-	  fFlags(other.fFlags)
+	:
+	fID(other.fID),
+	fName(other.fName),
+	fShortName(other.fShortName),
+	fPrettyName(other.fPrettyName),
+	fFlags(other.fFlags)
 {
 }
 
@@ -44,7 +45,7 @@
 status_t
 BDiskSystem::InitCheck() const
 {
-	return (fID > 0 ? B_OK : fID);
+	return fID > 0 ? B_OK : fID;
 }
 
 
@@ -56,6 +57,14 @@
 }
 
 
+// ShortName
+const char*
+BDiskSystem::ShortName() const
+{
+	return fShortName.String();
+}
+
+
 // PrettyName
 const char*
 BDiskSystem::PrettyName() const
@@ -76,8 +85,8 @@
 	}
 
 	if (whileMounted) {
-		*whileMounted = (IsFileSystem()
-			&& (fFlags & B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED));
+		*whileMounted = IsFileSystem() && (fFlags
+				& B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED) != 0;
 	}
 
 	return true;
@@ -310,7 +319,7 @@
 bool
 BDiskSystem::IsPartitioningSystem() const
 {
-	return (InitCheck() == B_OK && !(fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM));
+	return InitCheck() == B_OK && !(fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM);
 }
 
 
@@ -318,7 +327,7 @@
 bool
 BDiskSystem::IsFileSystem() const
 {
-	return (InitCheck() == B_OK && (fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM));
+	return InitCheck() == B_OK && (fFlags & B_DISK_SYSTEM_IS_FILE_SYSTEM);
 }
 
 
@@ -328,6 +337,7 @@
 {
 	fID = other.fID;
 	fName = other.fName;
+	fShortName = other.fShortName;
 	fPrettyName = other.fPrettyName;
 	fFlags = other.fFlags;
 
@@ -364,6 +374,7 @@
 
 	fID = info->id;
 	fName = info->name;
+	fShortName = info->short_name;
 	fPrettyName = info->pretty_name;
 	fFlags = info->flags;
 

Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp
===================================================================
--- haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -22,6 +22,7 @@
 KDiskSystem::KDiskSystem(const char *name)
 	: fID(_NextID()),
 	  fName(NULL),
+	  fShortName(NULL),
 	  fPrettyName(NULL),
 	  fLoadCounter(0)
 {
@@ -33,6 +34,8 @@
 KDiskSystem::~KDiskSystem()
 {
 	free(fName);
+	free(fShortName);
+	free(fPrettyName);
 }
 
 
@@ -40,7 +43,7 @@
 status_t
 KDiskSystem::Init()
 {
-	return (fName ? B_OK : B_NO_MEMORY);
+	return fName ? B_OK : B_NO_MEMORY;
 }
 
 
@@ -68,9 +71,17 @@
 }
 
 
+// ShortName
+const char *
+KDiskSystem::ShortName() const
+{
+	return fShortName;
+}
+
+
 // PrettyName
 const char *
-KDiskSystem::PrettyName()
+KDiskSystem::PrettyName() const
 {
 	return fPrettyName;
 }
@@ -106,9 +117,11 @@
 {
 	if (!info)
 		return;
+
 	info->id = ID();
-	strcpy(info->name, Name());
-	strcpy(info->pretty_name, PrettyName());
+	strlcpy(info->name, Name(), sizeof(info->name));
+	strlcpy(info->short_name, ShortName(), sizeof(info->short_name));
+	strlcpy(info->pretty_name, PrettyName(), sizeof(info->pretty_name));
 	info->flags = Flags();
 }
 
@@ -339,6 +352,14 @@
 }
 
 
+// SetShortName
+status_t
+KDiskSystem::SetShortName(const char *name)
+{
+	return set_string(fShortName, name);
+}
+
+
 // SetPrettyName
 status_t
 KDiskSystem::SetPrettyName(const char *name)

Modified: haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp
===================================================================
--- haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -43,7 +43,10 @@
 	error = Load();
 	if (error != B_OK)
 		return error;
-	error = SetPrettyName(fModule->pretty_name);
+	error = SetShortName(fModule->short_name);
+	if (error == B_OK)
+		error = SetPrettyName(fModule->pretty_name);
+
 	SetFlags(fModule->flags | B_DISK_SYSTEM_IS_FILE_SYSTEM);
 	Unload();
 	return error;

Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp
===================================================================
--- haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -49,7 +49,10 @@
 	error = Load();
 	if (error != B_OK)
 		return error;
-	error = SetPrettyName(fModule->pretty_name);
+	error = SetShortName(fModule->short_name);
+	if (error == B_OK)
+		error = SetPrettyName(fModule->pretty_name);
+
 	SetFlags(fModule->flags & ~(uint32)B_DISK_SYSTEM_IS_FILE_SYSTEM);
 	Unload();
 	return error;

Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/devfs.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/system/kernel/fs/devfs.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -2655,8 +2655,9 @@
 		devfs_std_ops,
 	},
 
-	"Device File System",
-	0,	// DDM flags
+	"devfs",					// short_name
+	"Device File System",		// pretty_name
+	0,							// DDM flags
 
 	NULL,	// identify_partition()
 	NULL,	// scan_partition()

Modified: haiku/trunk/src/system/kernel/fs/rootfs.cpp
===================================================================
--- haiku/trunk/src/system/kernel/fs/rootfs.cpp	2008-05-10 11:41:28 UTC (rev 25413)
+++ haiku/trunk/src/system/kernel/fs/rootfs.cpp	2008-05-10 11:44:00 UTC (rev 25414)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -1216,8 +1216,9 @@
 		rootfs_std_ops,
 	},
 
-	"Root File System",
-	0,	// DDM flags
+	"rootfs",				// short_name
+	"Root File System",		// pretty_name
+	0,						// DDM flags
 
 	NULL,	// identify_partition()
 	NULL,	// scan_partition()



From axeld at pinc-software.de  Sat May 10 13:46:34 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Sat, 10 May 2008 13:46:34 +0200 CEST
Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support
In-Reply-To: <1993970445-BeMail@laptop>
Message-ID: <12538928882-BeMail@zon>

"Fran?ois Revol"  wrote:
> Still we should try to make our point heard and try to change the 
> standard back.

Any idea on how to do that?

Bye,
   Axel.



From mminutoli at gmail.com  Sat May 10 13:58:28 2008
From: mminutoli at gmail.com (Marco Minutoli)
Date: Sat, 10 May 2008 13:58:28 +0200
Subject: [Haiku-commits] r25414 - in haiku/trunk: headers/os/drivers
 headers/private/fs_shell headers/private/kernel/disk_device_manager
 headers/private/storage src/add-ons/kernel/file_systems/bfs
 src/add-ons/kernel/file_systems/cdda src/add-ons/kernel/file_systems/fat
 src/add-ons/kernel/file_systems/googlefs
 src/add-ons/kernel/file_systems/iso9660
 src/add-ons/kernel/file_systems/ntfs src/add-ons/kernel/file_systems/ramfs
 src/add-ons/kernel/file_systems/reiserfs
 src/add-ons/kernel/partitioning_systems/amiga
 src/add-ons/kernel/partitioning_systems/apple
 src/add-ons/kernel/partitioning_systems/atari
 src/add-ons/kernel/partitioning_systems/efi
 src/add-ons/kernel/partitioning_systems/intel
 src/add-ons/kernel/partitioning_systems/session
 src/kits/storage/disk_device src/system/kernel/disk_device_manager
 src/system/kernel/fs
In-Reply-To: <200805101144.m4ABi22d014889@sheep.berlios.de>
References: <200805101144.m4ABi22d014889@sheep.berlios.de>
Message-ID: <20080510135828.1e948334@paris.homenet>

On Sat, 10 May 2008 13:44:02 +0200
axeld at BerliOS  wrote:

> Author: axeld
> Date: 2008-05-10 13:44:00 +0200 (Sat, 10 May 2008)
> New Revision: 25414
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25414&view=rev
> 
> Modified:
>    haiku/trunk/headers/os/drivers/fs_interface.h
>    haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h
>    haiku/trunk/headers/private/kernel/disk_device_manager/KDiskSystem.h
>    haiku/trunk/headers/private/kernel/disk_device_manager/ddm_modules.h
>    haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h
>    haiku/trunk/headers/private/storage/DiskDeviceRoster.h
>    haiku/trunk/headers/private/storage/DiskSystem.h
>    haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
>    haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp
>    haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
>    haiku/trunk/src/add-ons/kernel/file_systems/googlefs/googlefs.c
>    haiku/trunk/src/add-ons/kernel/file_systems/iso9660/kernel_interface.cpp
>    haiku/trunk/src/add-ons/kernel/file_systems/ntfs/kernel_interface.c
>    haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp
>    haiku/trunk/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/amiga/amiga_rdb.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/apple/apple.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/atari/atari.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/efi/efi_gpt.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/intel/intel.cpp
>    haiku/trunk/src/add-ons/kernel/partitioning_systems/session/session.cpp
>    haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp
>    haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp
>    haiku/trunk/src/system/kernel/disk_device_manager/KDiskSystem.cpp
>    haiku/trunk/src/system/kernel/disk_device_manager/KFileSystem.cpp
>    haiku/trunk/src/system/kernel/disk_device_manager/KPartitioningSystem.cpp
>    haiku/trunk/src/system/kernel/fs/devfs.cpp
>    haiku/trunk/src/system/kernel/fs/rootfs.cpp
> Log:
> * Added BDiskSystem::ShortName() and everything needed to get it
> there.
> * Added BDiskDeviceRoster::GetDiskSystem() method, that can get a
> disk system by short/pretty/module name - since they should all be
> unique, I put them in a single namespace, please complain if you
> don't like that :-)
> * Cleaned up DiskSystem.h and DiskDeviceRoster.h according to the
> updated header guidelines.
> * Renamed ntfs pretty name from "ntfs File System" to "Windows NT
> File System".
> 
> 
Good, you beat me on time with this one :)

I am going to make mkfs use it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 

From stippi at mail.berlios.de  Sat May 10 14:24:28 2008
From: stippi at mail.berlios.de (stippi at BerliOS)
Date: Sat, 10 May 2008 14:24:28 +0200
Subject: [Haiku-commits] r25415 - haiku/trunk/src/preferences/time
Message-ID: <200805101224.m4ACOSIJ017655@sheep.berlios.de>

Author: stippi
Date: 2008-05-10 14:24:27 +0200 (Sat, 10 May 2008)
New Revision: 25415
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25415&view=rev

Modified:
   haiku/trunk/src/preferences/time/DateTimeView.cpp
   haiku/trunk/src/preferences/time/DateTimeView.h
   haiku/trunk/src/preferences/time/Time.cpp
   haiku/trunk/src/preferences/time/TimeWindow.cpp
   haiku/trunk/src/preferences/time/TimeWindow.h
   haiku/trunk/src/preferences/time/ZoneView.cpp
   haiku/trunk/src/preferences/time/ZoneView.h
Log:
Applied patch by Philippe Saint-Pierre:
* Extended the scope of the Revert feature to include changes to the time zone.
* Moved the Revert button out of the tab view, so that it indicates the above
  visually. The window now handles the Revert feature.
* Added Others/Greenwhich time zone which is equivalent to an "unset" time zone.


Modified: haiku/trunk/src/preferences/time/DateTimeView.cpp
===================================================================
--- haiku/trunk/src/preferences/time/DateTimeView.cpp	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/DateTimeView.cpp	2008-05-10 12:24:27 UTC (rev 25415)
@@ -15,9 +15,9 @@
 #include "DateTimeEdit.h"
 #include "TimeMessages.h"
 #include "DateTime.h"
+#include "TimeWindow.h"
 
 
-#include 
 #include 
 #include 
 #include 
@@ -69,10 +69,7 @@
 	if (!fInitialized) {
 		fInitialized = true;
 
-		fGmtTime->SetTarget(this);
-		fLocalTime->SetTarget(this);
 		fCalendarView->SetTarget(this);
-		fRevertButton->SetTarget(this);
 	}
 }
 
@@ -131,12 +128,10 @@
 		case kRTCUpdate:
 			fUseGmtTime = fGmtTime->Value() == B_CONTROL_ON;
 			_UpdateGmtSettings();
-			CheckCanRevert();
 			break;
 
 		case kMsgRevert:
 			_Revert();
-			fRevertButton->SetEnabled(false);
 			break;
 	
 		default:
@@ -146,7 +141,7 @@
 }
 
 
-void
+bool
 DateTimeView::CheckCanRevert()
 {
 	// check GMT vs Local setting
@@ -157,9 +152,7 @@
 	time_t changedNow;
 	time(&changedNow);
 
-	enable = enable || (changedNow != unchangedNow);
-
-	fRevertButton->SetEnabled(enable);
+	return enable || (changedNow != unchangedNow);
 }
 
 
@@ -266,20 +259,6 @@
 
 	fOldUseGmtTime = fUseGmtTime;
 
-	BRect rect = Bounds();
-
-	rect.left = 10;
-	rect.top = rect.bottom - 10;
-
-	fRevertButton = new BButton(rect, "revert", "Revert",
-		new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
-	
-	fRevertButton->ResizeToPreferred();
-	fRevertButton->SetEnabled(false);
-	float buttonHeight = fRevertButton->Bounds().Height();
-	fRevertButton->MoveBy(0, -buttonHeight);
-	AddChild(fRevertButton);
-
 	ResizeTo(fClock->Frame().right + 10.0, fGmtTime->Frame().bottom + 10.0);
 }
 

Modified: haiku/trunk/src/preferences/time/DateTimeView.h
===================================================================
--- haiku/trunk/src/preferences/time/DateTimeView.h	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/DateTimeView.h	2008-05-10 12:24:27 UTC (rev 25415)
@@ -20,7 +20,6 @@
 class BCalendarView;
 class BRadioButton;
 class TAnalogClock;
-class BButton;
 
 
 class DateTimeView : public BView {
@@ -32,7 +31,8 @@
 		virtual void 	Draw(BRect updaterect);
 		virtual void 	MessageReceived(BMessage *message);
 
-				void	CheckCanRevert();
+		bool			CheckCanRevert();
+		bool			GetUseGmtTime();
 
 	private:
 		void 			_InitView();
@@ -51,9 +51,7 @@
 		BCalendarView 	*fCalendarView;
 		TAnalogClock 	*fClock;
 
-		BButton			*fRevertButton;
-
-		bool 			fUseGmtTime;
+		bool			fUseGmtTime;
 		bool			fOldUseGmtTime;
 		bool			fInitialized;
 

Modified: haiku/trunk/src/preferences/time/Time.cpp
===================================================================
--- haiku/trunk/src/preferences/time/Time.cpp	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/Time.cpp	2008-05-10 12:24:27 UTC (rev 25415)
@@ -46,7 +46,7 @@
 {
 	BAlert *alert = new BAlert("about", 
 		"Time & Date, writen by:\n\n\tAndrew Edward McCall\n\tMike Berg\n\t"
-		"Julun\n\nCopyright 2004-2007, Haiku.", "OK");
+		"Julun\n\tPhilippe Saint-Pierre\n\nCopyright 2004-2008, Haiku.", "OK");
 	alert->Go();
 }
 

Modified: haiku/trunk/src/preferences/time/TimeWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/time/TimeWindow.cpp	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/TimeWindow.cpp	2008-05-10 12:24:27 UTC (rev 25415)
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 
 TTimeWindow::TTimeWindow(BRect rect)
@@ -37,19 +38,38 @@
 }
 
 
+void
+TTimeWindow::SetRevertStatus()
+{
+	fRevertButton->SetEnabled(fDateTimeView->CheckCanRevert() 
+		|| fTimeZoneView->CheckCanRevert());
+}
+
+
 void 
 TTimeWindow::MessageReceived(BMessage *message)
 {
 	switch(message->what) {
 		case H_USER_CHANGE:
 			fBaseView->ChangeTime(message);
-			fDateTimeView->CheckCanRevert();
+			SetRevertStatus();
 			break;
 		
 		case B_ABOUT_REQUESTED:
 			be_app->PostMessage(B_ABOUT_REQUESTED);
 			break;
 
+		case kMsgRevert:
+			fDateTimeView->MessageReceived(message);
+			fTimeZoneView->MessageReceived(message);
+			fRevertButton->SetEnabled(false);
+			break;
+
+		case kRTCUpdate:
+			fDateTimeView->MessageReceived(message);
+			SetRevertStatus();
+			break;
+
 		default:
 			BWindow::MessageReceived(message);
 			break;
@@ -101,8 +121,24 @@
 
 	fBaseView->AddChild(tabView);
 	tabView->ResizeBy(0.0, tabView->TabHeight());
+
+	BRect rect = Bounds();
+
+	rect.left = 10;
+	rect.top = rect.bottom - 10;
+
+	fRevertButton = new BButton(rect, "revert", "Revert",
+		new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
+	
+	fRevertButton->ResizeToPreferred();
+	fRevertButton->SetEnabled(false);
+	float buttonHeight = fRevertButton->Bounds().Height();
+	fRevertButton->MoveBy(0, -buttonHeight);
+	fBaseView->AddChild(fRevertButton);
+	fRevertButton->SetTarget(this);
+
 	fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0, 
-		tabView->Bounds().Height() + 10.0);
+		tabView->Bounds().Height() + buttonHeight + 30.0);
 
 	ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
 }

Modified: haiku/trunk/src/preferences/time/TimeWindow.h
===================================================================
--- haiku/trunk/src/preferences/time/TimeWindow.h	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/TimeWindow.h	2008-05-10 12:24:27 UTC (rev 25415)
@@ -27,6 +27,7 @@
 
 		virtual bool	QuitRequested();
 		virtual void	MessageReceived(BMessage *message);
+		void				SetRevertStatus();
 
 	private:
 		void 			_InitWindow();
@@ -36,6 +37,7 @@
 		TTimeBaseView 	*fBaseView;
 		DateTimeView 	*fDateTimeView;
 		TimeZoneView 	*fTimeZoneView;
+		BButton			*fRevertButton;
 };
 
 #endif	// TIME_WINDOW_H

Modified: haiku/trunk/src/preferences/time/ZoneView.cpp
===================================================================
--- haiku/trunk/src/preferences/time/ZoneView.cpp	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/ZoneView.cpp	2008-05-10 12:24:27 UTC (rev 25415)
@@ -1,10 +1,11 @@
 /*
- * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
+ * Copyright 2004-2008, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *		Mike Berg 
  *		Julun 
+ *		Philippe Saint-Pierre 
  */
 
 /*
@@ -21,6 +22,7 @@
 #include "ZoneView.h"
 #include "TimeMessages.h"
 #include "TZDisplay.h"
+#include "TimeWindow.h"
 
 
 #include 
@@ -37,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 
 #include 
@@ -67,6 +70,42 @@
 }
 
 
+bool
+TimeZoneView::CheckCanRevert()
+{
+	return fCurrentZone != fOldZone;
+}
+
+
+void
+TimeZoneView::_Revert()
+{
+	BPath parent;
+
+	fCurrentZone = fOldZone;
+	int32 czone;
+
+	if (strcmp(fCurrentZone.Leaf(), "Greenwich") == 0) {
+		if (BMenuItem* item = fRegionPopUp->FindItem("Others"))
+			item->SetMarked(true);
+		czone = FillCityList("Others");
+	} else {
+		fCurrentZone.GetParent(&parent);
+		if (BMenuItem* item = fRegionPopUp->FindItem(parent.Leaf()))
+			item->SetMarked(true);
+		czone = FillCityList(parent.Path());
+	}
+
+	if (czone > -1) {
+		fCityList->Select(czone);
+		fCityList->ScrollToSelection();
+		fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text());
+		SetPreview();
+	}
+	SetTimeZone();
+}
+
+
 TimeZoneView::~TimeZoneView()
 {
 }
@@ -87,11 +126,19 @@
 
 		// update displays	
 		BPath parent;
-		fCurrentZone.GetParent(&parent);
-		int32 czone = FillCityList(parent.Path());
-		if (czone > -1) {
-			fCityList->Select(czone);
-			fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text());
+		if (strcmp(fCurrentZone.Leaf(), "Greenwich") != 0) {
+			fCurrentZone.GetParent(&parent);
+			int32 czone = FillCityList(parent.Path());
+			if (czone > -1) {
+				fCityList->Select(czone);
+				fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text());
+			}
+		} else {
+			int32 czone = FillCityList("Others");
+			if (czone > -1) {
+				fCityList->Select(czone);
+				fCurrent->SetText(((TZoneItem *)fCityList->ItemAt(czone))->Text());
+			}
 		}
 	}
 	fCityList->ScrollToSelection();
@@ -120,9 +167,19 @@
 			break;
 		
 		case H_SET_TIME_ZONE:
+		{
 			SetTimeZone();
+			BMessage msg(*message);
+			msg.what = kRTCUpdate;
+			Window()->PostMessage(&msg);
+			((TTimeWindow*)Window())->SetRevertStatus();
 			break;
-		
+		}
+
+		case kMsgRevert:
+			_Revert();
+			break;
+
 		case H_CITY_CHANGED:
 			SetPreview();
 			break;	
@@ -242,7 +299,7 @@
 			
 			// skip Etc directory
 			if (itemtext.Compare("Etc", 3) == 0)
-			 	continue;
+				continue;
 			 
 			markit = itemtext.Compare(region.Leaf()) == 0;
 			
@@ -263,6 +320,12 @@
 			fRegionPopUp->AddItem(item);
 		}
 	}
+	BMessage *msg = new BMessage(H_REGION_CHANGED);
+	msg->AddString("region", "Others");
+
+	item = new BMenuItem("Others", msg);
+	item->SetMarked(strcmp(fCurrentZone.Leaf(), "Greenwich") == 0);
+	fRegionPopUp->AddItem(item);
 }
 
 
@@ -277,44 +340,54 @@
 		fCityList->MakeEmpty();
 	}
 
-	// Enter time zones directory. Find subdir with name that matches string
-	// stored in area. Enter subdirectory and count the items. For each item,
-	// add a StringItem to fCityList Time zones directory 
+ 	BStringItem *city;
+	int32 index = -1; 
+	if (strcmp(area, "Others") != 0) {
 
-	BPath path;
-	if (find_directory(B_BEOS_ETC_DIRECTORY, &path) != B_OK)
-		return 0;
+		// Enter time zones directory. Find subdir with name that matches string
+		// stored in area. Enter subdirectory and count the items. For each item,
+		// add a StringItem to fCityList Time zones directory 
 
-	path.Append("timezones");
+		BPath path;
+		if (find_directory(B_BEOS_ETC_DIRECTORY, &path) != B_OK)
+			return 0;
 
-	BPath Area(area);
- 	BDirectory zoneDir(path.Path()); 
- 	BDirectory cityDir;
- 	BStringItem *city;
- 	BString city_name;
- 	BEntry entry;
-	int32 index = -1; 
+		path.Append("timezones");
+
+		BPath Area(area);
+	 	BDirectory zoneDir(path.Path()); 
+	 	BDirectory cityDir;
+	 	BString city_name;
+	 	BEntry entry;
+
 	
-	//locate subdirectory:
-	if (zoneDir.Contains(Area.Leaf(), B_DIRECTORY_NODE)) {
-		cityDir.SetTo(&zoneDir, Area.Leaf());  
+		//locate subdirectory:
+		if (zoneDir.Contains(Area.Leaf(), B_DIRECTORY_NODE)) {
+			cityDir.SetTo(&zoneDir, Area.Leaf());  
 
-		// There is a subdir with a name that matches 'area'. That's the one!!
-		// Iterate over the items in the subdir, fill listview with TZoneItems
-		while(cityDir.GetNextEntry(&entry) == B_NO_ERROR) {
-			if (!entry.IsDirectory()) {
-				BPath zone(&entry);
-				city_name = zone.Leaf();
-				city_name.ReplaceAll("_IN", ", Indiana");
-				city_name.ReplaceAll("__Calif", ", Calif");
-				city_name.ReplaceAll("__", ", ");
-				city_name.ReplaceAll("_", " ");
-				city = new TZoneItem(city_name.String(), zone.Path());
-				fCityList->AddItem(city);
-				if (strcmp(fCurrentZone.Leaf(), zone.Leaf()) == 0)
-					index = fCityList->IndexOf(city);
+			// There is a subdir with a name that matches 'area'. That's the one!!
+			// Iterate over the items in the subdir, fill listview with TZoneItems
+			while(cityDir.GetNextEntry(&entry) == B_NO_ERROR) {
+				if (!entry.IsDirectory()) {
+					BPath zone(&entry);
+					city_name = zone.Leaf();
+					city_name.ReplaceAll("_IN", ", Indiana");
+					city_name.ReplaceAll("__Calif", ", Calif");
+					city_name.ReplaceAll("__", ", ");
+					city_name.ReplaceAll("_", " ");
+					city = new TZoneItem(city_name.String(), zone.Path());
+					fCityList->AddItem(city);
+					if (strcmp(fCurrentZone.Leaf(), zone.Leaf()) == 0)
+						index = fCityList->IndexOf(city);
+				}
 			}
 		}
+	} else {
+		city = new TZoneItem("Greenwich", "/boot/beos/etc/timezones/Greenwich");
+		fCityList->AddItem(city);
+		if (strcmp(fCurrentZone.Leaf(), "Greenwich") == 0) {
+			index = fCityList->IndexOf(city);
+		}
 	}
 	return index;
 }
@@ -363,13 +436,17 @@
 			tzLink.SetTo("/boot/beos/etc/timezones/Pacific/fiji");
 			// do something like set to a default GMT???
 		}
+		else if (!tzLink.Exists()) { // link doesn't exists
+			tzLink.SetTo("/boot/beos/etc/timezones/Greenwich");
+		}
  	} else {
- 		// set tzlink to a default
+ 		// directory doesn't exist
  		tzLink.SetTo("/boot/beos/etc/timezones/EST");
  	}
 #endif
 	// we need something in the current zone
 	fCurrentZone.SetTo(&tzLink);
+	fOldZone.SetTo(&tzLink);
 }
 
 
@@ -449,7 +526,7 @@
 
 	// update environment
 	SetTimeZone(target.Path());
-
+	
 	// update display
 	time_t current = time(0);
 	struct tm *ltime = localtime(¤t);

Modified: haiku/trunk/src/preferences/time/ZoneView.h
===================================================================
--- haiku/trunk/src/preferences/time/ZoneView.h	2008-05-10 11:44:00 UTC (rev 25414)
+++ haiku/trunk/src/preferences/time/ZoneView.h	2008-05-10 12:24:27 UTC (rev 25415)
@@ -28,6 +28,7 @@
 		
 		virtual void 	AttachedToWindow();
 		virtual void 	MessageReceived(BMessage *message);
+		bool			CheckCanRevert();
 
 	private:
 		void 			UpdateDateTime(BMessage *message);
@@ -39,6 +40,7 @@
 		void 			InitView();
 		void 			ReadTimeZoneLink();
 		void 			BuildRegionMenu();
+		void			_Revert();
 
 		// returns index of current zone
 		int32 			FillCityList(const char *area);
@@ -53,6 +55,7 @@
 		int32 			fHour;
 		int32 			fMinute;
 		BPath 			fCurrentZone;
+		BPath				fOldZone;
 		bool 			fInitialized;
 };
 



From korli at mail.berlios.de  Sat May 10 14:39:00 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 14:39:00 +0200
Subject: [Haiku-commits] r25416 - in haiku/trunk: headers/os/interface
	src/servers/input
Message-ID: <200805101239.m4ACd0Cc018524@sheep.berlios.de>

Author: korli
Date: 2008-05-10 14:38:57 +0200 (Sat, 10 May 2008)
New Revision: 25416
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25416&view=rev

Modified:
   haiku/trunk/headers/os/interface/InterfaceDefs.h
   haiku/trunk/src/servers/input/InputServer.cpp
Log:
* added B_KATAKANA_HIRAGANA and B_ZENKAKU_HANKAKU (used in Japanese keymap)
* Patch by Shinta: switch between input methods are now not only done with Alt+Space but Alt+Zenkaku/Hankaku.



Modified: haiku/trunk/headers/os/interface/InterfaceDefs.h
===================================================================
--- haiku/trunk/headers/os/interface/InterfaceDefs.h	2008-05-10 12:24:27 UTC (rev 25415)
+++ haiku/trunk/headers/os/interface/InterfaceDefs.h	2008-05-10 12:38:57 UTC (rev 25416)
@@ -62,7 +62,10 @@
 	B_PAGE_UP			= 0x0b,
 	B_PAGE_DOWN			= 0x0c,
 
-	B_FUNCTION_KEY		= 0x10
+	B_FUNCTION_KEY		= 0x10,
+	
+	B_KATAKANA_HIRAGANA	= 0xf2,
+	B_ZENKAKU_HANKAKU	= 0xf3
 };
 
 enum {

Modified: haiku/trunk/src/servers/input/InputServer.cpp
===================================================================
--- haiku/trunk/src/servers/input/InputServer.cpp	2008-05-10 12:24:27 UTC (rev 25415)
+++ haiku/trunk/src/servers/input/InputServer.cpp	2008-05-10 12:38:57 UTC (rev 25416)
@@ -1525,9 +1525,10 @@
 				PRINT(("SanitizeEvents: %lx, %lx\n", fKeyInfo.modifiers,
 					fKeyInfo.key_states[KEY_Spacebar >> 3]));
 
-				int8 byte;
-				if ((fKeyInfo.modifiers & B_COMMAND_KEY) != 0
-					&& event->FindInt8("byte", &byte) == B_OK && byte == ' ') {
+				int8 byte = 0;
+				event->FindInt8("byte", &byte);
+				if ((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 
+					&& (byte == ' ' || static_cast(byte) == B_ZENKAKU_HANKAKU)) {
 					SetNextMethod(!fKeyInfo.modifiers & B_SHIFT_KEY);
 
 					// this event isn't sent to the user



From superstippi at gmx.de  Sat May 10 14:55:08 2008
From: superstippi at gmx.de (Stephan Assmus)
Date: Sat, 10 May 2008 14:55:08 +0200
Subject: [Haiku-commits] r25416 - in haiku/trunk: headers/os/interface
 src/servers/input
In-Reply-To: <200805101239.m4ACd0Cc018524@sheep.berlios.de>
References: <200805101239.m4ACd0Cc018524@sheep.berlios.de>
Message-ID: <20080510145508.13841.4@stippis2.1210414696.fake>


korli at BerliOS wrote:
> Author: korli
> Date: 2008-05-10 14:38:57 +0200 (Sat, 10 May 2008) New Revision: 25416
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25416&view=rev
> 
> Modified:
>    haiku/trunk/headers/os/interface/InterfaceDefs.h
>    haiku/trunk/src/servers/input/InputServer.cpp
> Log:
> * added B_KATAKANA_HIRAGANA and B_ZENKAKU_HANKAKU (used in Japanese 
> keymap)
> * Patch by Shinta: switch between input methods are now not only done 
> with Alt+Space but Alt+Zenkaku/Hankaku.

You beat me to it... :-)

> Modified: haiku/trunk/src/servers/input/InputServer.cpp 
> ===================================================================
> --- haiku/trunk/src/servers/input/InputServer.cpp    2008-05-10 12:24:27 
> UTC (rev 25415)
> +++ haiku/trunk/src/servers/input/InputServer.cpp    2008-05-10 12:38:57 
> UTC (rev 25416)
> @@ -1525,9 +1525,10 @@
>                  PRINT(("SanitizeEvents: %lx, %lx\n", fKeyInfo.modifiers,
>                      fKeyInfo.key_states[KEY_Spacebar >> 3]));
>  
> -                int8 byte;
> -                if ((fKeyInfo.modifiers & B_COMMAND_KEY) != 0
> -                    && event->FindInt8("byte", &byte) == B_OK && byte == 
> ' ') {
> +                int8 byte = 0;
> +                event->FindInt8("byte", &byte);
> +                if ((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 
> +                    && (byte == ' ' || static_cast(byte) == 
> B_ZENKAKU_HANKAKU)) {
>                      SetNextMethod(!fKeyInfo.modifiers & B_SHIFT_KEY);

but this is not what SHINTA explained (and I think also not how his patch 
worked (not sure about those lined up compare operators, that's why I 
always use parenthesis)), I thought the point was that you didn't have to 
hold down a modifier key when using B_ZENKAKU_HANKAKU.

I was also wondering about the line below:

SetNextMethod(!fKeyInfo.modifiers & B_SHIFT_KEY);

Shouldn't that be

SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY));

?

Best regards,
-Stephan


From axeld at mail.berlios.de  Sat May 10 14:55:54 2008
From: axeld at mail.berlios.de (axeld at BerliOS)
Date: Sat, 10 May 2008 14:55:54 +0200
Subject: [Haiku-commits] r25417 - haiku/trunk/src/apps/sudoku
Message-ID: <200805101255.m4ACts5r019295@sheep.berlios.de>

Author: axeld
Date: 2008-05-10 14:55:53 +0200 (Sat, 10 May 2008)
New Revision: 25417
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25417&view=rev

Modified:
   haiku/trunk/src/apps/sudoku/SudokuView.cpp
Log:
* Turned off replicant handle for the time being; it's not really usable as
  a replicant yet.
* Improved CSS producing code.
* Cleanup.


Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp
===================================================================
--- haiku/trunk/src/apps/sudoku/SudokuView.cpp	2008-05-10 12:38:57 UTC (rev 25416)
+++ haiku/trunk/src/apps/sudoku/SudokuView.cpp	2008-05-10 12:55:53 UTC (rev 25417)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
+ * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
 
@@ -42,11 +42,13 @@
 {
 	InitObject(&settings);
 
+#if 0
 	BRect rect(Bounds());
 	rect.top = rect.bottom - 7;
 	rect.left = rect.right - 7;
-	BDragger *dw = new BDragger(rect, this);
-	AddChild(dw);
+	BDragger* dragger = new BDragger(rect, this);
+	AddChild(dragger);
+#endif
 }
 
 
@@ -254,40 +256,35 @@
 
 
 status_t
-SudokuView::SaveTo(entry_ref& ref, uint32 as)
+SudokuView::SaveTo(entry_ref& ref, uint32 exportAs)
 {
 	BFile file;
-
 	status_t status = file.SetTo(&ref, B_WRITE_ONLY | B_CREATE_FILE
 		| B_ERASE_FILE);
 	if (status < B_OK)
 		return status;
 
-	status = SaveTo(file, as);
-	
-	return status;
+	return SaveTo(file, exportAs);
 }
 
 
 status_t
-SudokuView::SaveTo(BDataIO &stream, uint32 as)
+SudokuView::SaveTo(BDataIO& stream, uint32 exportAs)
 {
-	BString text;
-	BFile *file = dynamic_cast(&stream);
-	char *line;
+	BFile* file = dynamic_cast(&stream);
 	uint32 i = 0;
-	status_t status = EINVAL;
 	BNodeInfo nodeInfo;
 
 	if (file)
 		nodeInfo.SetTo(file);
 
-	switch (as) {
+	switch (exportAs) {
 		case kExportAsText:
-			text = "# Written by Sudoku\n\n";
+		{
+			BString text = "# Written by Sudoku\n\n";
 			stream.Write(text.String(), text.Length());
 
-			line = text.LockBuffer(1024);
+			char* line = text.LockBuffer(1024);
 			memset(line, 0, 1024);
 			for (uint32 y = 0; y < fField->Size(); y++) {
 				for (uint32 x = 0; x < fField->Size(); x++) {
@@ -303,36 +300,49 @@
 			if (file)
 				nodeInfo.SetType("text/plain");
 			return B_OK;
+		}
+
 		case kExportAsHTML:
 		{
 			bool netPositiveFriendly = false;
-			text = "\n\n\n"
+			BString text = "\n\n\n"
 				"\n"
+				"td.sudoku_empty {  }\n";
+
+			// border styles: right bottom (none, small or large)
+			const char* kStyles[] = {"none", "small", "large"};
+			const char* kCssStyles[] = {"none", "solid 1px black",
+				"solid 3px black"};
+			enum style_type { kNone = 0, kSmall, kLarge };
+
+			for (int32 right = 0; right < 3; right++) {
+				for (int32 bottom = 0; bottom < 3; bottom++) {
+					text << "td.sudoku_";
+					if (right != bottom)
+						text << kStyles[right] << "_" << kStyles[bottom];
+					else
+						text << kStyles[right];
+
+					text << " { border-right: " << kCssStyles[right]
+						<< "; border-bottom: " << kCssStyles[bottom] << "; }\n";
+				}
+			}
+
+			text << "\n"
 				"\n\n\n";
 			stream.Write(text.String(), text.Length());
 
 			text = "";
 			stream.Write(text.String(), text.Length());
 
@@ -345,24 +355,31 @@
 					char buff[2];
 					_SetText(buff, fField->ValueAt(x, y));
 
-					char border_right = 's';
-					char border_bottom = 's';
-					if ((x+1) % fField->BlockSize() == 0)
-						border_right = 'l';
-					if ((y+1) % fField->BlockSize() == 0)
-						border_bottom = 'l';
+					BString style = "sudoku_";
+					style_type right = kSmall;
+					style_type bottom = kSmall;
+					if ((x + 1) % fField->BlockSize() == 0)
+						right = kLarge;
+					if ((y + 1) % fField->BlockSize() == 0)
+						bottom = kLarge;
 					if (x == fField->Size() - 1)
-						border_right = 'n';
+						right = kNone;
 					if (y == fField->Size() - 1)
-						border_bottom = 'n';
+						bottom = kNone;
 
+					if (right != bottom)
+						style << kStyles[right] << "_" << kStyles[bottom];
+					else
+						style << kStyles[right];
+
 					if (fField->ValueAt(x, y) == 0) {
 						text << "\n";
-						text << " ";
+						text << "class=\"sudoku sudoku_empty " << style;
+						text << "\">\n ";
 					} else if (fField->FlagsAt(x, y) & kInitialValue) {
 						text << "\n";
+						text << "class=\"sudoku sudoku_initial " << style
+							<< "\">\n";
 						if (netPositiveFriendly)
 							text << "";
 						text << buff;
@@ -370,7 +387,8 @@
 							text << "";
 					} else {
 						text << "\n";
+						text << "class=\"sudoku sudoku_filled sudoku_" << style
+							<< "\">\n";
 						if (netPositiveFriendly)
 							text << "";
 						text << buff;
@@ -390,50 +408,61 @@
 				nodeInfo.SetType("text/html");
 			return B_OK;
 		}
+
 		case kExportAsBitmap:
 		{
-			BMallocIO mio;
-			status = SaveTo(mio, kExportAsPicture);
+			BMallocIO mallocIO;
+			status_t status = SaveTo(mallocIO, kExportAsPicture);
 			if (status < B_OK)
 				return status;
-			mio.Seek(0LL, SEEK_SET);
+
+			mallocIO.Seek(0LL, SEEK_SET);
 			BPicture picture;
-			status = picture.Unflatten(&mio);
+			status = picture.Unflatten(&mallocIO);
 			if (status < B_OK)
 				return status;
-			BBitmap *bitmap = new BBitmap(Bounds(), B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
-			BView *view = new BView(Bounds(), "bitmap", B_FOLLOW_NONE, B_WILL_DRAW);
+
+			BBitmap* bitmap = new BBitmap(Bounds(), B_BITMAP_ACCEPTS_VIEWS,
+				B_RGB32);
+			BView* view = new BView(Bounds(), "bitmap", B_FOLLOW_NONE,
+				B_WILL_DRAW);
 			bitmap->AddChild(view);
+
 			if (bitmap->Lock()) {
 				view->DrawPicture(&picture);
 				view->Sync();
+
 				view->RemoveSelf();
 				delete view;
+					// it should not become part of the archive
 				bitmap->Unlock();
 			}
-			BMessage msg((uint32)B_OK);
-			status = bitmap->Archive(&msg);
-			if (status >= B_OK) {
-				status = msg.Flatten(&stream);
-			}
+
+			BMessage archive;
+			status = bitmap->Archive(&archive);
+			if (status >= B_OK)
+				status = archive.Flatten(&stream);
+
 			delete bitmap;
 			return status;
 		}
+
 		case kExportAsPicture:
 		{
 			BPicture picture;
 			BeginPicture(&picture);
 			Draw(Bounds());
-			if (EndPicture()) {
+
+			status_t status = B_ERROR;
+			if (EndPicture())
 				status = picture.Flatten(&stream);
-			}
+
 			return status;
 		}
+
 		default:
-			return EINVAL;
+			return B_BAD_VALUE;
 	}
-	
-	return status;
 }
 
 



From korli at mail.berlios.de  Sat May 10 15:05:53 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 15:05:53 +0200
Subject: [Haiku-commits] r25418 -
	haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich
Message-ID: <200805101305.m4AD5rH8020562@sheep.berlios.de>

Author: korli
Date: 2008-05-10 15:05:52 +0200 (Sat, 10 May 2008)
New Revision: 25418
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25418&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h
Log:
* added pci id for Nvidia Nforce MCP04 AC97 in auich
* clean up the pci ids


Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2008-05-10 12:55:53 UTC (rev 25417)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2008-05-10 13:05:52 UTC (rev 25418)
@@ -552,8 +552,9 @@
 			|| info.device_id == NVIDIA_nForce2_400_AC97_DEVICE_ID
 			|| info.device_id == NVIDIA_nForce3_AC97_DEVICE_ID
 			|| info.device_id == NVIDIA_nForce3_250_AC97_DEVICE_ID
-			|| info.device_id == NVIDIA_nForce4_AC97_DEVICE_ID
-			|| info.device_id == NVIDIA_nForce430_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_CK804_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_MCP51_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_MCP04_AC97_DEVICE_ID
 			)) 
 		|| (info.vendor_id == AMD_VENDOR_ID &&
 			(info.device_id == AMD_AMD8111_AC97_DEVICE_ID
@@ -801,8 +802,9 @@
 			|| info.device_id == NVIDIA_nForce2_400_AC97_DEVICE_ID
 			|| info.device_id == NVIDIA_nForce3_AC97_DEVICE_ID
 			|| info.device_id == NVIDIA_nForce3_250_AC97_DEVICE_ID
-			|| info.device_id == NVIDIA_nForce4_AC97_DEVICE_ID
-			|| info.device_id == NVIDIA_nForce430_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_CK804_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_MCP51_AC97_DEVICE_ID
+			|| info.device_id == NVIDIA_MCP04_AC97_DEVICE_ID
 			)) 
 		|| (info.vendor_id == AMD_VENDOR_ID &&
 			(info.device_id == AMD_AMD8111_AC97_DEVICE_ID

Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h	2008-05-10 12:55:53 UTC (rev 25417)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h	2008-05-10 13:05:52 UTC (rev 25418)
@@ -51,24 +51,25 @@
 #define INTEL_82801AB_AC97_DEVICE_ID	0x2425
 #define INTEL_82801BA_AC97_DEVICE_ID	0x2445
 #define INTEL_82801CA_AC97_DEVICE_ID	0x2485
-#define INTEL_82801DB_AC97_DEVICE_ID	0x24C5
-#define INTEL_82801EB_AC97_DEVICE_ID	0x24D5
-#define INTEL_82801FB_AC97_DEVICE_ID	0x266E
-#define INTEL_82801GB_AC97_DEVICE_ID	0x27DE
-#define INTEL_6300ESB_AC97_DEVICE_ID	0x25A6
+#define INTEL_82801DB_AC97_DEVICE_ID	0x24c5
+#define INTEL_82801EB_AC97_DEVICE_ID	0x24d5
+#define INTEL_82801FB_AC97_DEVICE_ID	0x266e
+#define INTEL_82801GB_AC97_DEVICE_ID	0x27de
+#define INTEL_6300ESB_AC97_DEVICE_ID	0x25a6
 #define SIS_VENDOR_ID		0x1039	/* Sis */
-#define SIS_SI7012_AC97_DEVICE_ID	0x7012
-#define NVIDIA_VENDOR_ID		0x10DE	/* Nvidia */
-#define NVIDIA_nForce_AC97_DEVICE_ID	0x01B1
-#define NVIDIA_nForce2_AC97_DEVICE_ID	0x006A
-#define NVIDIA_nForce2_400_AC97_DEVICE_ID	0x008A
-#define NVIDIA_nForce3_AC97_DEVICE_ID	0x00DA
-#define NVIDIA_nForce3_250_AC97_DEVICE_ID	0x00EA
-#define NVIDIA_nForce4_AC97_DEVICE_ID	0x0059
-#define NVIDIA_nForce430_AC97_DEVICE_ID	0x026b
+#define SIS_SI7012_AC97_DEVICE_ID		0x7012
+#define NVIDIA_VENDOR_ID	0x10de	/* Nvidia */
+#define NVIDIA_nForce_AC97_DEVICE_ID	0x01b1
+#define NVIDIA_nForce2_AC97_DEVICE_ID	0x006a
+#define NVIDIA_nForce2_400_AC97_DEVICE_ID	0x008a
+#define NVIDIA_nForce3_AC97_DEVICE_ID	0x00da
+#define NVIDIA_nForce3_250_AC97_DEVICE_ID	0x00ea
+#define NVIDIA_CK804_AC97_DEVICE_ID		0x0059
+#define NVIDIA_MCP51_AC97_DEVICE_ID		0x026b
+#define NVIDIA_MCP04_AC97_DEVICE_ID		0x003a
 #define AMD_VENDOR_ID		0x1022	/* Amd */
-#define AMD_AMD8111_AC97_DEVICE_ID	0x764d
-#define AMD_AMD768_AC97_DEVICE_ID	0x7445	
+#define AMD_AMD8111_AC97_DEVICE_ID		0x764d
+#define AMD_AMD768_AC97_DEVICE_ID		0x7445
 
 #define VERSION "Version alpha 1, Copyright (c) 2003 J?r?me Duval, compiled on " ## __DATE__ ## " " ## __TIME__ 
 #define DRIVER_NAME "auich"



From mmu_man at mail.berlios.de  Sat May 10 15:30:17 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sat, 10 May 2008 15:30:17 +0200
Subject: [Haiku-commits] r25419 - haiku/trunk/src/apps/terminal
Message-ID: <200805101330.m4ADUHmV022151@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-10 15:30:15 +0200 (Sat, 10 May 2008)
New Revision: 25419
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25419&view=rev

Modified:
   haiku/trunk/src/apps/terminal/TermParse.cpp
   haiku/trunk/src/apps/terminal/TermParse.h
Log:
added a dumpState() call to help debugging EscParse


Modified: haiku/trunk/src/apps/terminal/TermParse.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.cpp	2008-05-10 13:05:52 UTC (rev 25418)
+++ haiku/trunk/src/apps/terminal/TermParse.cpp	2008-05-10 13:30:15 UTC (rev 25419)
@@ -281,12 +281,48 @@
 }
 
 
+void
+TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
+{
+	static const struct {
+		int *p;
+		const char *name;
+	} tables[] = {
+#define T(t) \
+	{ t, #t }
+	T(gUTF8GroundTable),
+	T(gCS96GroundTable),
+	T(gISO8859GroundTable),
+	T(gSJISGroundTable),
+	T(gEscTable),
+	T(gCsiTable),
+	T(gDecTable),
+	T(gScrTable),
+	T(gIgnoreTable),
+	T(gIesTable),
+	T(gEscIgnoreTable),
+	T(gMbcsTable),
+	{ NULL, NULL }
+	};
+	int i;
+	fprintf(stderr, "groundtable: ");
+	for (i = 0; tables[i].p; i++)
+		if (tables[i].p == groundtable)
+			fprintf(stderr, "%s\t", tables[i].name);
+	fprintf(stderr, "parsestate: ");
+	for (i = 0; tables[i].p; i++)
+		if (tables[i].p == parsestate)
+			fprintf(stderr, "%s\t", tables[i].name);
+	fprintf(stderr, "char: 0x%02x (%d)\n", c, c);
+}
+
+
 int32
 TermParse::EscParse()
 {
 	int tmp;
 	int top, bot;
-	int cs96;
+	int cs96 = 0;
 	uchar curess = 0;
 	
 	uchar cbuf[4], dstbuf[4];
@@ -310,6 +346,8 @@
 		if (GetReaderBuf(c) < B_OK)
 			break;
 
+		//DumpState(groundtable, parsestate, c);
+
 		if (now_coding != fView->Encoding()) {
 			/*
 			 * Change coding, change parse table.

Modified: haiku/trunk/src/apps/terminal/TermParse.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermParse.h	2008-05-10 13:05:52 UTC (rev 25418)
+++ haiku/trunk/src/apps/terminal/TermParse.h	2008-05-10 13:30:15 UTC (rev 25419)
@@ -60,6 +60,8 @@
 	int32 EscParse();
 	int32 PtyReader();
 
+	void DumpState(int *groundtable, int *parsestate, uchar c);
+
 	static int32 _ptyreader_thread(void *);
 	static int32 _escparse_thread(void *);
 



From ingo_weinhold at gmx.de  Sat May 10 15:42:54 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Sat, 10 May 2008 15:42:54 +0200
Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support
In-Reply-To: <37179560993-BeMail@zon>
References: <37179560993-BeMail@zon>
Message-ID: <20080510154254.666.2@knochen-vm.1210421914.fake>


On 2008-05-09 at 19:43:08 [+0200], Axel D?rfler  
wrote:
> "Rene Gollent"  wrote:
> > On Fri, May 9, 2008 at 11:22 AM, Ingo Weinhold 
> > wrote:
> > > Apropos error codes. Alas it seems the GNU tools are right assuming
> > > that
> > > error codes are positive. I hadn't found an evidence that this is
> > > required
> > > by POSIX before, but it actually is (cf. the errno.h
> > > specification). I
> > > suppose we should address that problem at some point in the future.
> > That seems to be a more recent change:
> > 
> > Issue 6
> > 
> >     The following new requirements on POSIX implementations derive
> > from alignment with the Single UNIX Specification:
> > 
> >     Values for errno are now required to be distinct positive values
> > rather than non-zero values. This change is for alignment with the
> > ISO/IEC 9899:1999 standard.
> > 
> > I'm not sure exactly when that update was made though.
> 
> I can't see what we can do about it either - it would just break
> everything if we changed that.

We could change the POSIX error codes to positive but leave the BeOS error 
codes negative. When setting errno we would need to make sure that the 
value is positive. That would make programs happy that use only POSIX API. 
Applications using BeOS API only would be fine, too. Applications mixing 
them -- e.g. returning errno as a status_t and checking < B_OK instead of 
!= B_OK or returning errno as a ssize_t -- would break, though.

That'd would be a change affecting quite a bit of code, though, and I'm not 
very much in favor for it ATM.

> I find it rather intolerant to make such a change at a time when there
> were operating systems around that required them to be negative.

I wouldn't be surprised if the people working the standard weren't aware of 
BeOS (respectively that it uses negative error codes), and since it was 
already dead at that time, it might not have influenced the decision anyway.

> I also
> don't really see any advantage in forcing them to be positive.

Forcing them to a well-defined signedness has the advantage that API users 
can use the other range freely. And positive error codes are a UNIX 
tradition.

CU, Ingo


From korli at mail.berlios.de  Sat May 10 15:44:39 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 15:44:39 +0200
Subject: [Haiku-commits] r25420 -
	haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich
Message-ID: <200805101344.m4ADidPj022631@sheep.berlios.de>

Author: korli
Date: 2008-05-10 15:44:38 +0200 (Sat, 10 May 2008)
New Revision: 25420
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25420&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h
Log:
* synched license terms with current
* minor space cleanup
* support for revert enable amp for known models


Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2008-05-10 13:30:15 UTC (rev 25419)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2008-05-10 13:44:38 UTC (rev 25420)
@@ -33,8 +33,6 @@
 #include 
 #include "ac97.h"
 
-#define REVERSE_EAMP_POLARITY 0
-
 #include "debug.h"
 #include "io.h"
 
@@ -277,12 +275,20 @@
 
 void default_amp_enable(device_config *config, bool yesno)
 {
+	uint32 id;
 	LOG(("default_amp_enable\n"));
 	LOG(("powerdown register was = %#04x\n",auich_codec_read(config, AC97_POWERDOWN)));
-	#if REVERSE_EAMP_POLARITY
+	id = (config->subvendor_id << 16) | config->subsystem_id;
+	if (id == 0x161f202f
+		|| id == 0x161f203a
+		|| id == 0x161f204c
+		|| id == 0x104d8144
+		|| id == 0x104d8197
+		|| id == 0x104d81c0
+		|| id == 0x104d81c5) {
 		yesno = !yesno;
 		LOG(("using reverse eamp polarity\n"));
-	#endif
+	}
 	if (yesno)
 		auich_codec_write(config, AC97_POWERDOWN, auich_codec_read(config, AC97_POWERDOWN) & ~0x8000); /* switch on (low active) */
 	else

Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2008-05-10 13:30:15 UTC (rev 25419)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2008-05-10 13:44:38 UTC (rev 25420)
@@ -11,13 +11,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -411,7 +404,7 @@
 	// TRACE(("auich_int(%p)\n", card));
 	
 	sta = auich_reg_read_16(&card->config, AUICH_REG_GLOB_STA);
-	if(sta & card->interrupt_mask) {
+	if (sta & card->interrupt_mask) {
 		
 		if (sta & (STA_S0RI | STA_S1RI | STA_S2RI)) {
 			// ignore and clear resume interrupt(s)
@@ -422,9 +415,9 @@
 		
 		//TRACE(("interrupt !! %x\n", sta));
 		
-		LIST_FOREACH(stream, &card->streams, next) 
+		LIST_FOREACH(stream, &card->streams, next)
 			if (sta & stream->sta) {
-				sr = auich_reg_read_16(&card->config, 
+				sr = auich_reg_read_16(&card->config,
 					stream->base + GET_REG_SR(&stream->card->config));
 				sr &= SR_MASK;
 				
@@ -436,7 +429,7 @@
 				if (sr & SR_BCIS) {
 					curblk = auich_stream_curaddr(stream);
 									
-					auich_reg_write_8(&card->config, stream->base + AUICH_REG_X_LVI, 
+					auich_reg_write_8(&card->config, stream->base + AUICH_REG_X_LVI,
 						(curblk + 2) % AUICH_DMALIST_MAX);
 							
 					stream->trigblk = (curblk) % stream->blkmod;
@@ -448,14 +441,14 @@
 				}
 								
 				auich_reg_write_16(&card->config, 
-					stream->base + GET_REG_SR(&stream->card->config), sr);		
+					stream->base + GET_REG_SR(&stream->card->config), sr);
 			}
 	} else {
 		TRACE(("interrupt masked %x, ", card->interrupt_mask));
 		TRACE(("sta %x\n", sta));
 	}
 	
-	if(gotone)
+	if (gotone)
 		return B_INVOKE_SCHEDULER;
 
 	TRACE(("Got unhandled interrupt\n"));

Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h	2008-05-10 13:30:15 UTC (rev 25419)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.h	2008-05-10 13:44:38 UTC (rev 25420)
@@ -11,13 +11,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED



From korli at mail.berlios.de  Sat May 10 15:52:53 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 15:52:53 +0200
Subject: [Haiku-commits] r25421 - haiku/trunk/src/servers/input
Message-ID: <200805101352.m4ADqrMA023360@sheep.berlios.de>

Author: korli
Date: 2008-05-10 15:52:53 +0200 (Sat, 10 May 2008)
New Revision: 25421
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25421&view=rev

Modified:
   haiku/trunk/src/servers/input/InputServer.cpp
Log:
B_ZENKAKU_HANKAKU doesn't need B_COMMAND_KEY (I misunderstood the patch).


Modified: haiku/trunk/src/servers/input/InputServer.cpp
===================================================================
--- haiku/trunk/src/servers/input/InputServer.cpp	2008-05-10 13:44:38 UTC (rev 25420)
+++ haiku/trunk/src/servers/input/InputServer.cpp	2008-05-10 13:52:53 UTC (rev 25421)
@@ -1527,8 +1527,8 @@
 
 				int8 byte = 0;
 				event->FindInt8("byte", &byte);
-				if ((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 
-					&& (byte == ' ' || static_cast(byte) == B_ZENKAKU_HANKAKU)) {
+				if (((fKeyInfo.modifiers & B_COMMAND_KEY) != 0 && byte == ' ')
+					|| static_cast(byte) == B_ZENKAKU_HANKAKU) {
 					SetNextMethod(!fKeyInfo.modifiers & B_SHIFT_KEY);
 
 					// this event isn't sent to the user



From ingo_weinhold at gmx.de  Sat May 10 15:58:41 2008
From: ingo_weinhold at gmx.de (Ingo Weinhold)
Date: Sat, 10 May 2008 15:58:41 +0200
Subject: [Haiku-commits] r25404 -
 haiku/trunk/src/add-ons/kernel/file_systems/bfs
In-Reply-To: <7508399130-BeMail@zon>
References: <7508399130-BeMail@zon>
Message-ID: <20080510155841.744.3@knochen-vm.1210421914.fake>


On 2008-05-10 at 12:22:44 [+0200], Axel D?rfler  
wrote:
> bonefish at BerliOS  wrote:
> > Log:
> > Don't create anything in a removed directory. Axel, please review. I
> > don't see how the locking in Remove()/Create() works.
> 
> Does this fix an actual bug?

As the commit log says, you could create entries in a removed directory 
(mkdir /tmp/tt; cd /tmp/tt; rmdir /tmp/tt; touch a; mkdir b), which is 
certainly a bug.

> If so, it should probably be moved into
> the VFS instead.

Can't be done, since the serialization of write accesses is done in the FS.

> Create/remove locking works over transactions - those are always
> serialized.

Good, my change should be OK, then. The check could even be moved up a bit.

CU, Ingo


From korli at users.berlios.de  Sat May 10 16:04:17 2008
From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=)
Date: Sat, 10 May 2008 16:04:17 +0200
Subject: [Haiku-commits] r25416 - in haiku/trunk: headers/os/interface
	src/servers/input
In-Reply-To: <20080510145508.13841.4@stippis2.1210414696.fake>
References: <200805101239.m4ACd0Cc018524@sheep.berlios.de>
	<20080510145508.13841.4@stippis2.1210414696.fake>
Message-ID: 

2008/5/10 Stephan Assmus :
>
> but this is not what SHINTA explained (and I think also not how his patch
> worked (not sure about those lined up compare operators, that's why I
> always use parenthesis)), I thought the point was that you didn't have to
> hold down a modifier key when using B_ZENKAKU_HANKAKU.

Indeed, I misunderstood the patch.


> I was also wondering about the line below:
>
> SetNextMethod(!fKeyInfo.modifiers & B_SHIFT_KEY);
>
> Shouldn't that be
>
> SetNextMethod(!(fKeyInfo.modifiers & B_SHIFT_KEY));
>

The result is the same in either cases. I prefer "non pressed
modifiers" (vs pressed modifiers).

Bye,
J?r?me


From korli at mail.berlios.de  Sat May 10 16:09:07 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 16:09:07 +0200
Subject: [Haiku-commits] r25422 -
	haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich
Message-ID: <200805101409.m4AE97TD024236@sheep.berlios.de>

Author: korli
Date: 2008-05-10 16:09:06 +0200 (Sat, 10 May 2008)
New Revision: 25422
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25422&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
Log:
added a few more models for reversed enable amp


Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2008-05-10 13:52:53 UTC (rev 25421)
+++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2008-05-10 14:09:06 UTC (rev 25422)
@@ -285,7 +285,11 @@
 		|| id == 0x104d8144
 		|| id == 0x104d8197
 		|| id == 0x104d81c0
-		|| id == 0x104d81c5) {
+		|| id == 0x104d81c5
+		|| id == 0x103c3089
+		|| id == 0x103c309a
+		|| id == 0x10338213
+		|| id == 0x103382be) {
 		yesno = !yesno;
 		LOG(("using reverse eamp polarity\n"));
 	}



From korli at mail.berlios.de  Sat May 10 16:13:36 2008
From: korli at mail.berlios.de (korli at BerliOS)
Date: Sat, 10 May 2008 16:13:36 +0200
Subject: [Haiku-commits] r25423 - haiku/trunk/src/preferences/devices
Message-ID: <200805101413.m4AEDami024455@sheep.berlios.de>

Author: korli
Date: 2008-05-10 16:13:35 +0200 (Sat, 10 May 2008)
New Revision: 25423
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25423&view=rev

Modified:
   haiku/trunk/src/preferences/devices/pci.ids
Log:
update pci ids


Modified: haiku/trunk/src/preferences/devices/pci.ids
===================================================================
--- haiku/trunk/src/preferences/devices/pci.ids	2008-05-10 14:09:06 UTC (rev 25422)
+++ haiku/trunk/src/preferences/devices/pci.ids	2008-05-10 14:13:35 UTC (rev 25423)
@@ -11,7 +11,7 @@
 #	This file can be distributed under either the GNU General Public License
 #	(version 2 or higher) or the 3-clause BSD License.
 #
-#	Daily snapshot on Sun 2007-09-23 01:05:01
+#	Daily snapshot on Sat 2008-05-10 01:05:02
 #
 
 # Vendors, devices and subsystems. Please keep sorted.
@@ -40,6 +40,7 @@
 	4800  WinTV PVR-350
 	4801  WinTV PVR-250 MCE
 	4803  WinTV PVR-250
+	7801  WinTV HVR-1800 MCE
 	8003  WinTV PVR-150
 	8801  WinTV PVR-150
 	c801  WinTV PVR-150
@@ -84,7 +85,6 @@
 	7050  F5D7050 802.11g Wireless USB Adapter
 	705c  F5D7050 v4
 058f  Alcor Micro Corporation
-	9254  AU9254 (4-port USB hub)
 05a9  OmniVision
 	8519  OV519 series
 05e3  CyberDoor
@@ -98,11 +98,11 @@
 	1703  ISDN Adapter (PCI Bus, DV, W)
 	1704  ISDN Adapter (PCI Bus, D, C)
 067b  Prolific Technology, Inc.
-	2303  PL-2303 USB-to-Serial Converter
 	3507  PL-3507 Hi-Speed USB & IEEE 1394 Combo to IDE Bridge Controller
 069d  Hughes Network Systems (HNS)
 0721  Sapphire, Inc.
 07ca  AVerMedia Technologies Inc.
+	a301  AVerTV 301
 	b808  AVerTV DVB-T Volar (USB 2.0)
 07e2  ELMEG Communication Systems GmbH
 0842  NPG, Personal Grand Technology
@@ -203,8 +203,8 @@
 	ae10  Smart-2/P RAID Controller
 		0e11 4030  Smart-2/P Array Controller
 		0e11 4031  Smart-2SL Array Controller
-		0e11 4032  Smart Array Controller
-		0e11 4033  Smart 3100ES Array Controller
+		0e11 4032  Smart Array 3200 Controller
+		0e11 4033  Smart Array 3100ES Controller
 	ae29  MIS-L
 	ae2a  MPC
 	ae2b  MIS-E
@@ -291,7 +291,7 @@
 		4c53 1000  CC7/CR7/CP7/VC7/VP7/VR7 mainboard
 		4c53 1050  CT7 mainboard
 	0010  53C1510
-		0e11 4040  Integrated Array Controller
+		0e11 4040  Integrated Smart Array Controller
 		0e11 4048  RAID LC2 Controller
 		1000 1000  53C1510 PCI to Dual Channel Wide Ultra2 SCSI Controller (Intelligent mode)
 	0012  53c895a
@@ -305,6 +305,8 @@
 	0021  53c1010 66MHz  Ultra3 SCSI Adapter
 		1000 1000  LSI53C1000/1000R/1010R/1010-66 PCI to Ultra160 SCSI Controller
 		1000 1010  Asus TR-DLS onboard 53C1010-66
+		103c 1300  Ultra160 SCSI [AB306A]
+		103c 1310  Ultra160 SCSI [A9918A]
 		103c 1330  Ultra160 SCSI [A7059A]
 		103c 1340  Ultra160 SCSI [A7060A]
 		124b 1070  PMC-USCSI3
@@ -321,7 +323,7 @@
 		1028 1010  LSI U320 SCSI Controller
 		103c 12c5  Ultra320 SCSI [A7173A]
 		124b 1170  PMC-USCSI320
-		1734 1052  Primergy RX300 S2
+		1734 1052  PRIMERGY BX/RX/TX S2 series onboard SCSI(IME)
 	0031  53c1030ZC PCI-X Fusion-MPT Dual Ultra320 SCSI
 	0032  53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI
 		1000 1000  LSI53C1020/1030 PCI-X to Ultra320 SCSI Controller
@@ -349,6 +351,7 @@
 		1028 1f0e  SAS 6/iR Adapter RAID Controller
 		1028 1f0f  SAS 6/iR Integrated Blades RAID Controller
 		1028 1f10  SAS 6/iR Integrated RAID Controller
+	0059  MegaRAID SAS 8208ELP/8208ELP
 	005a  SAS1066E PCI-Express Fusion-MPT SAS
 	005c  SAS1064A PCI-X Fusion-MPT SAS
 	005e  SAS1066 PCI-X Fusion-MPT SAS
@@ -383,6 +386,8 @@
 		8086 34cd  Integrated RAID Controller SROMBSAS28E
 	0062  SAS1078 PCI-Express Fusion-MPT SAS
 		1000 0062  SAS1078 PCI-Express Fusion-MPT SAS
+	007c  MegaRAID SAS 1078DE
+		1014 0395  ServeRAID-AR10is SAS/SATA Controller
 	008f  53c875J
 		1092 8000  FirePort 40 SCSI Controller
 		1092 8760  FirePort 40 Dual SCSI Host Adapter
@@ -480,6 +485,7 @@
 	9100  INI-9100/9100W SCSI Host
 1002  ATI Technologies Inc
 	3150  M24 1P [Radeon Mobility X600]
+		103c 0934  nx8220
 	3151  M24 [FireMV 2400]
 	3152  M22 [Radeon Mobility X300]
 	3154  M24GL [Mobility FireGL V3200]
@@ -557,9 +563,10 @@
 		103c 0024  Pavilion ze4400 builtin Video
 		161f 2029  eMachines M5312 builtin Video
 	4337  Radeon IGP 330M/340M/350M
-		1014 053a  ThinkPad R40e (2684-HVG) builtin VGA controller
+		1014 053a  ThinkPad R40e
 		103c 0850  Radeon IGP 345M
 	4341  IXP150 AC'97 Audio Controller
+	4342  IXP200 3COM 3C920B Ethernet Controller
 	4345  EHCI USB Controller
 	4347  OHCI USB Controller #1
 	4348  OHCI USB Controller #2
@@ -578,61 +585,94 @@
 		107b 0300  MX6421
 	4371  IXP SB400 PCI-PCI Bridge
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4372  IXP SB400 SMBus Controller
 		1025 0080  Aspire 5024WLMMi
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4373  IXP SB400 USB2 Host Controller
 		1025 0080  Aspire 5024WLMMi
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4374  IXP SB400 USB Host Controller
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4375  IXP SB400 USB Host Controller
 		1025 0080  Aspire 5024WLMMi
 		103c 308b  MX6125
-	4376  Standard Dual Channel PCI IDE Controller
+		1462 7217  Aspire L250
+	4376  IXP SB400 IDE Controller
 		1025 0080  Aspire 5024WLMMi
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4377  IXP SB400 PCI-ISA Bridge
 		1025 0080  Aspire 5024WLMi
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	4378  SB400 AC'97 Modem Controller
 		1025 0080  Aspire 5024WLMMi
 		103c 308b  MX6125
-	4379  4379 Serial ATA Controller
-	437a  437A Serial ATA Controller
+	4379  IXP SB400 Serial ATA Controller
+		1462 7141  Aspire L250
+	437a  IXP SB400 Serial ATA Controller
 		1002 4379  4379 Serial ATA Controller
 		1002 437a  437A Serial ATA Controller
+		1462 7141  Aspire L250
 		14f1 8800  Leadtek WinFast TV2000XP Expert
-	437b  SB450 HDA Audio
+	437b  IXP SB4x0 High Definition Audio Controller
+		1002 437b  IXP SB4x0 High Definition Audio Controller
 		10cf 1326  Fujitsu Lifebook A3040
 		1734 10b8  Realtek High Definition Audio
 	4380  SB600 Non-Raid-5 SATA
+		103c 2813  DC5750 Microtower
+		17f2 5999  KI690-AM2 Motherboard
 	4381  SB600 Raid-5 SATA
 	4382  SB600 AC97 Audio
 	4383  SBx00 Azalia
+		0206 1028  Latitude D531
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	4384  SBx00 PCI to PCI Bridge
 	4385  SBx00 SMBus Controller
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	4386  SB600 USB Controller (EHCI)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	4387  SB600 USB (OHCI0)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	4388  SB600 USB (OHCI1)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	4389  SB600 USB (OHCI2)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	438a  SB600 USB (OHCI3)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	438b  SB600 USB (OHCI4)
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	438c  SB600 IDE
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	438d  SB600 PCI to LPC Bridge
+		103c 280a  DC5750 Microtower
+		17f2 5000  KI690-AM2 Motherboard
 	438e  SB600 AC97 Modem
-	4390  SB700 SATA Controller [IDE mode]
-	4391  SB700 SATA Controller [AHCI mode]
-	4392  SB700 SATA Controller [Non-RAID5 mode]
-	4393  SB700 SATA Controller [RAID5 mode]
-	4394  SB700 SATA Controller [SATA and FC Enabled]
-	4395  SB SATA Controller [AHCI mode with HyperFlash-PCIE]
-	4396  SB700 USB EHCI Controller
-	4397  SB700 USB OHCI0 Controller
-	4398  SB700 USB OHCI1 Controller
-	4399  SB700 USB OHCI2 Controller
-	439c  SB700 IDE
-	439d  SB700 LPC host controller
+	4390  SB700/SB800 SATA Controller [IDE mode]
+	4391  SB700/SB800 SATA Controller [AHCI mode]
+	4392  SB700/SB800 SATA Controller [Non-RAID5 mode]
+	4393  SB700/SB800 SATA Controller [RAID5 mode]
+	4394  SB700/SB800 SATA Controller [SATA and FC Enabled]
+	4395  SB800 SATA Controller [Storage mode with HyperFlash-PCIE]
+	4396  SB700/SB800 USB EHCI Controller
+	4397  SB700/SB800 USB OHCI0 Controller
+	4398  SB700/SB800 USB OHCI1 Controller
+	4399  SB700/SB800 USB OHCI2 Controller
+	439c  SB700/SB800 IDE Controller
+	439d  SB700/SB800 LPC host controller
 	4437  Radeon Mobility 7000 IGP
 	4554  210888ET [Mach64 ET]
 	4654  Mach64 VT
@@ -687,10 +727,11 @@
 		1028 00d1  PowerEdge 2550
 		1028 00d9  PowerEdge 2500
 		1028 0134  PowerEdge 600SC
+		1028 014a  PowerEdge 1750
 		1028 0165  PowerEdge 750
 		103c 10e1  NetServer Rage XL
 		107b 6400  6400 Server
-		1734 007a  Primergy RX300
+		1734 007a  PRIMERGY RX/TX series onboard VGA
 		8086 3411  SDS2 Mainboard
 		8086 3427  S875WP1-E mainboard
 		8086 5744  S845WD1-E mainboard
@@ -802,7 +843,7 @@
 	4c64  Radeon RV250 Ld [Radeon Mobility 9000 M9]
 	4c65  Radeon RV250 Le [Radeon Mobility 9000 M9]
 	4c66  Radeon RV250 [Mobility FireGL 9000]
-		1014 054d  Thinkpad T41
+		1014 054d  ThinkPad T41
 	4c67  Radeon RV250 Lg [Radeon Mobility 9000 M9]
 # Secondary chip to the Lf
 	4c6e  Radeon RV250 Ln [Radeon Mobility 9000 M9] (Secondary)
@@ -820,6 +861,7 @@
 	4e48  Radeon R350 [Radeon 9800 Pro]
 	4e49  Radeon R350 [Radeon 9800]
 	4e4a  RV350 NJ [Radeon 9800 XT]
+		1002 4e4a  R360 [Radeon 9800 XT]
 	4e4b  R350 NK [FireGL X2]
 	4e50  RV350 [Mobility Radeon 9600 M10]
 		1025 005a  TravelMate 290
@@ -843,6 +885,7 @@
 	4e68  Radeon R350 [Radeon 9800 Pro] (Secondary)
 	4e69  Radeon R350 [Radeon 9800] (Secondary)
 	4e6a  RV350 NJ [Radeon 9800 XT] (Secondary)
+		1002 4e6a  R360 [Radeon 9800 XT] (Secondary)
 		1002 4e71  M10 NQ [Radeon Mobility 9600]
 	4e71  M10 NQ [Radeon Mobility 9600] (Secondary)
 	4f72  RV250 [Radeon 9000 Series]
@@ -942,6 +985,8 @@
 # The IBM card doubles as an ATI PCI video adapter
 		1014 029a  Remote Supervisor Adapter II (RSA2)
 		1014 02c8  eServer xSeries server mainboard
+		1028 016c  PowerEdge 1850
+		1028 016d  PowerEdge 2850
 		1028 019a  PowerEdge SC1425
 		103c 1292  Radeon 7000
 		1458 4002  RV100 QY [RADEON 7000 PRO MAYA AV Series]
@@ -953,6 +998,10 @@
 		17ee 1001  Radeon 7000 64MB DDR + DVI
 	515a  Radeon RV100 QZ [Radeon 7000/VE]
 	515e  ES1000
+		1028 01df  PowerEdge SC440
+		1028 01e6  PowerEdge 860
+		1028 020f  PowerEdge R300
+		1028 0210  PowerEdge T300
 	515f  ES1000
 	5168  Radeon R200 Qh
 	5169  Radeon R200 Qi
@@ -1053,7 +1102,9 @@
 	5944  RV280 [Radeon 9200 SE (PCI)]
 	5950  RS480 Host Bridge
 		1025 0080  Aspire 5024WLMMi
+		103c 280a  DC5750 Microtower
 		103c 308b  MX6125
+		1462 7217  Aspire L250
 	5951  Radeon Xpress 200 (RS480/RS482/RX480/RX482) Chipset - Host bridge
 	5952  RD580 [CrossFire Xpress 3200] Chipset Host Bridge
 	5954  RS480 [Radeon Xpress 200G Series]
@@ -1062,7 +1113,7 @@
 		1002 5955  RS480 0x5955 [Radeon XPRESS 200M 5955 (PCIE)]
 		103c 308b  MX6125
 	5956  RD790 Northbridge only dual slot PCI-e_GFX and HT3 K8 part
-	5957  RX790 Northbridge only single slot PCI-e_GFX and HT3 K8 part
+	5957  RX780/RX790 Chipset Host Bridge
 	5958  RD780 Northbridge only dual slot PCI-e_GFX and HT1 K8 part
 	5960  RV280 [Radeon 9200 PRO]
 		17af 2020  Excalibur Radeon 9250
@@ -1089,8 +1140,11 @@
 		17af 2012  Radeon 9200 SE Excalibur
 		18bc 0170  Sapphire Radeon 9200 SE 128MB Game Buster
 		18bc 0173  GC-R9200L(SE)-C3H [Radeon 9200 Game Buster]
+	5965  RV280 [FireMV 2200 PCI]
 	5969  ES1000
 	5974  RS482 [Radeon Xpress 200]
+		103c 280a  DC5750 Microtower
+		1462 7141  Aspire L250
 	5975  RS485 [Radeon Xpress 1100 IGP]
 	5978  RD790 PCI to PCI bridge (external gfx0 port A)
 	5979  RD790 PCI to PCI bridge (external gfx0 port B)
@@ -1128,6 +1182,7 @@
 # Comes in pair with 5a38
 	5a39  RS480 PCI Bridge
 	5a3f  RS480 PCI Bridge
+		1462 7217  Aspire L250
 	5a41  RS400 [Radeon Xpress 200]
 	5a42  RS400 [Radeon Xpress 200M]
 	5a61  RC410 [Radeon Xpress 200]
@@ -1138,6 +1193,7 @@
 		1458 2102  GV-RX30S128D (X300SE)
 		1462 0400  RX300SE-TD128E (MS-8940 REV:200)
 		1462 0402  RX300SE-TD128E (MS-8940)
+		174b 0500  Radeon X300 (PCIE)
 		196d 1086  X300SE HM
 	5b62  RV380 [Radeon X600 (PCIE)]
 	5b63  RV370 [Sapphire X550 Silent]
@@ -1145,6 +1201,7 @@
 	5b65  RV370 5B65 [FireGL D1100 (PCIE)]
 	5b70  RV370 [Radeon X300SE]
 		1462 0403  RX300SE-TD128E (MS-8940) (secondary display)
+		174b 0501  Radeon X300SE
 		196d 1087  X300SE HM
 	5b72  RV380 [Radeon X600]
 	5b73  RV370 secondary [Sapphire X550 Silent]
@@ -1162,6 +1219,7 @@
 		17af 2013  Radeon 9200 SE Excalibur (Secondary)
 		18bc 0171  Radeon 9200 SE 128MB Game Buster (Secondary)
 		18bc 0172  GC-R9200L(SE)-C3H [Radeon 9200 Game Buster]
+	5d45  RV280 [FireMV 2200 PCI] (secondary)
 	5d48  M28 [Radeon Mobility X800XT]
 	5d49  M28 [Mobility FireGL V5100]
 	5d4a  Mobility Radeon X800
@@ -1212,6 +1270,7 @@
 		1002 0322  All-in-Wonder 2006 PCI-E Edition
 	7143  RV505 [Radeon X1550 Series]
 	7145  Radeon Mobility X1400
+		17aa 2006  Thinkpad T60 model 2007
 	7146  RV515 [Radeon X1300]
 		1002 0322  All-in-Wonder 2006 PCI-E Edition
 		1545 1996  Radeon X1300 512MB PCI-e
@@ -1228,6 +1287,7 @@
 	715f  RV505 CE [Radeon X1550 64-bit]
 	7162  RV515 PRO [Radeon X1300/X1550 Series] (Secondary)
 		1002 0323  All-in-Wonder 2006 PCI-E Edition (Secondary)
+	7163  RV505 [Radeon X1550 Series] (Secondary)
 	7166  RV515 [Radeon X1300] (Secondary)
 		1002 0323  All-in-Wonder 2006 PCI-E Edition (Secondary)
 		1545 1997  Radeon X1300 512MB PCI-e (Secondary)
@@ -1252,10 +1312,12 @@
 	71a7  RV516 [Radeon X1300/X1550 Series] (Secondary)
 	71bb  FireMV 2250 (Secondary)
 	71c0  RV530 [Radeon X1600]
+	71c1  Radeon X1650 Pro
 	71c2  RV530 [Radeon X1600]
 	71c4  M56GL [Mobility FireGL V5200]
 		17aa 2007  ThinkPad T60p
 	71c5  M56P [Radeon Mobility X1600]
+		103c 30a3  Compaq NW8440
 	71c6  RV530LE [Radeon X1600/X1650 PRO]
 	71c7  RV535 [Radeon X1650 Series]
 	71ce  RV530LE [Radeon X1600]
@@ -1264,6 +1326,7 @@
 	71d6  M66-XT [Mobility Radeon X1700]
 	71de  RV530LE [Radeon X1600]
 	71e0  RV530 [Radeon X1600] (Secondary)
+	71e1  Radeon X1650 Pro (Secondary)
 	71e2  RV530 [Radeon X1600] (Secondary)
 	71e6  RV530LE [Radeon X1650 PRO] (Secondary)
 	71e7  RV535 [Radeon X1650 Series]
@@ -1302,18 +1365,72 @@
 	7835  Radeon Mobility 9200 IGP
 	7838  Radeon 9100 IGP PCI/AGP Bridge
 	7910  RS690 Host Bridge
+		17f2 5000  KI690-AM2 Motherboard
 	7912  RS690 PCI to PCI Bridge (Internal gfx)
+	7913  RS690 PCI to PCI Bridge (PCI Express Graphics Port 0)
+	7915  RS690 PCI to PCI Bridge (PCI Express Port 1)
 	7916  RS690 PCI to PCI Bridge (PCI Express Port 2)
 	7917  RS690 PCI to PCI Bridge (PCI Express Port 3)
 	7919  Radeon X1200 Series Audio Controller
+		17f2 5000  KI690-AM2 Motherboard
 	791e  RS690 [Radeon X1200 Series]
+		17f2 5000  KI690-AM2 Motherboard
 	791f  RS690M [Radeon X1200 Series]
+	793b  RS600 audio device [Radeon Xpress 12xx Series]
 	793f  RS600 [Radeon Xpress 1200 Series]
 	7941  RS600 [Radeon Xpress 1200 Series]
 	7942  Radeon Xpress 1250
+	796e  Radeon 2100
 	7c37  RV350 AQ [Radeon 9600 SE]
+	9400  R600 [Radeon HD 2900 Series]
+		1002 3000  Sapphire Radeon HD 2900 XT
+	940a  R600GL [Fire GL V8650]
+	940b  R600GL [Fire GL V8600]
+	94c1  Radeon HD 2400 XT
+		1028 0211  Optiplex 755
+	94c3  RV610 video device [Radeon HD 2400 PRO]
+		1002 94c3  Radeon HD 2400PRO
+		174b e400  Sapphire HD 2400 PRO video device
+	94c4  RV610LE [Radeon HD 2400 Series]
+	94c8  Radeon HD 2400 XT
+	94c9  Mobility Radeon HD 2400
+		1002 94c9  Radeon HD2400
+	94cb  Radeon E2400
+	94cc  RV 610LE PCI [Radeon HD 2400]
+	9501  Radeon HD 3870
+	9504  Mobility Radeon HD 3850
+	9505  Radeon HD 3850
+	9507  RV670 [Radeon HD 3850]
+	9508  M88 XT Mobility Radeon HD 3870]
+	950f  R680 [Radeon HD 3870 x2]
+	9515  RV670 AGP [Radeon HD 3850]
+	9559  Mobilitiy Radeon HD 3600 Series
+	9581  M76 [Radeon Mobility HD 2600 Series]
+	9586  RV 630 XT AGP [Radeon HD 2600 XT AGP]
+	9587  RV630 [Radeon HD 2600 AGP Series]
+	9588  RV630 [Radeon HD 2600XT]
+		1458 216c  Radeon HD 2600 XT, 256MB GDDR3, 2x DVI, TV-out, PCIe (GV-RX26T256H)
 	9589  RV630 [Radeon HD 2600 Series]
-	aa08  RV630 audio device [Radeon HD 2600 Series]
+	9591  Mobilitiy Radeon HD 3650
+	9593  Radeon Mobility HD 3670
+	9596  RV635 PRO AGP [Radeon HD 3650]
+	9598  Mobilitiy Radeon HD 3600 Series
+	95c0  Mobilitiy Radeon HD 3470
+	95c4  Mobilitiy Radeon HD 3400 Series
+	95c5  Mobilitiy Radeon HD 3450
+	960f  RS780 Azalia controller
+	9610  Radeon HD 3200 Graphics
+	9611  Radeon 3100 Graphics
+	9612  RS780M/RS780MN [Radeon HD 3200 Graphics]
+	9613  RS780MC [Radeon HD 3100 Graphics]
+	9614  Radeon HD 3300 Graphics
+	aa00  R600 Audio Device [Radeon HD 2900 Series]
+	aa08  RV630/M76 audio device [Radeon HD 2600 Series]
+	aa10  RV610 audio device [Radeon HD 2400 PRO]
+		174b aa10  Sapphire HD 2400 PRO audio device
+	aa18  Radeon HD 3870 Audio device
+	aa20  RV635 Audio device [Radeon HD 3600 Series]
+	aa28  RV620 Audio device [Radeon HD 34xx Series]
 	cab0  AGP Bridge [IGP 320M]
 	cab2  RS200/RS200M AGP Bridge [IGP 340M]
 	cab3  R200 AGP Bridge [Mobility Radeon 7000 IGP]
@@ -1446,6 +1563,7 @@
 		1186 0100  DE-530+
 	0016  DGLPB [OPPO]
 	0017  PV-PCI Graphics Controller (ZLXp-L)
+	0018  Memory Channel interface
 	0019  DECchip 21142/43
 		1011 500a  DE500A Fast Ethernet
 		1011 500b  DE500B Fast Ethernet
@@ -1497,9 +1615,9 @@
 		1374 0003  56k Modem Cardbus
 	0045  DECchip 21553
 	0046  DECchip 21554
-		0e11 4050  Integrated Smart Array
-		0e11 4051  Integrated Smart Array
-		0e11 4058  Integrated Smart Array
+		0e11 4050  Smart Array 4200 Controller
+		0e11 4051  Smart Array 4250ES Controller
+		0e11 4058  Smart Array 431 Controller
 		103c 10c2  NetRAID-4M
 		12d9 000a  IP Telephony card
 		4c53 1050  CT7 mainboard
@@ -1685,6 +1803,8 @@
 	0302  Winnipeg PCI-X Host Bridge
 	0308  CalIOC2 PCI-E Root Port
 	0314  ZISC 036 Neural accelerator card
+	032d  Axon - Cell Companion Chip
+		1014 03a1  PCIe PowerXCell 8i Cell Accelerator Board
 	0339  Obsidian-E PCI-E SCSI controller
 		1014 030a  PCIe 3Gb SAS RAID Adapter (574E)
 		1014 033a  PCIe 3Gb SAS Adapter (57B3)
@@ -1855,6 +1975,18 @@
 		161f 3017  HDAMB
 	746e  AMD-8111 MC97 Modem
 	756b  AMD-8111 ACPI
+	9600  RS780 Host Bridge
+	9601  RS780 Host Bridge Alternate
+	9602  RS780 PCI to PCI bridge (int gfx)
+	9603  RS780 PCI to PCI bridge (ext gfx port 0)
+	9604  RS780 PCI to PCI bridge (PCIE port 0)
+	9605  RS780 PCI to PCI bridge (PCIE port 1)
+	9606  RS780 PCI to PCI bridge (PCIE port 2)
+	9607  RS780 PCI to PCI bridge (PCIE port 3)
+	9608  RS780 PCI to PCI bridge (PCIE port 4)
+	9609  RS780 PCI to PCI bridge (PCIE port 5)
+	960a  RS780 PCI to PCI bridge (NB-SB link)
+	960b  RS780 PCI to PCI bridge (ext gfx port 1)
 1023  Trident Microsystems
 	0194  82C194
 	2000  4DWave DX
@@ -1995,6 +2127,7 @@
 	000d  Embedded Remote Access: BMC/SMIC device
 	000e  PowerEdge Expandable RAID controller 4/Di
 	000f  PowerEdge Expandable RAID controller 4/Di
+		1028 014a  PowerEdge 1750
 	0010  Remote Access Card 4
 	0011  Remote Access Card 4 Daughter Card
 	0012  Remote Access Card 4 Daughter Card Virtual UART
@@ -2005,10 +2138,10 @@
 		1028 016f  PowerEdge Expandable RAID Controller 4e/Di
 		1028 0170  PowerEdge Expandable RAID Controller 4e/Di
 	0014  Remote Access Card 4 Daughter Card SMIC interface
-	0015  PowerEdge Expandable RAID controller 5i
+	0015  PowerEdge Expandable RAID controller 5
 		1028 1f01  PERC 5/E Adapter RAID Controller
 		1028 1f02  PERC 5/i Adapter RAID Controller
-		1028 1f03  PERC 5/i Adapter RAID Controller
+		1028 1f03  PERC 5/i Integrated RAID Controller
 1029  Siemens Nixdorf IS
 102a  LSI Logic
 	0000  HYDRA
@@ -2155,6 +2288,8 @@
 		102b 0f83  Millennium G550
 		102b 0f84  Millennium G550 Dual Head DDR 32Mb
 		102b 1e41  Millennium G550
+# Clearly the device name should not say AGP anymore...
+		102b 2300  Millennium G550 LP PCIE
 	2537  Millenium P650/P750
 		102b 1820  Millennium P750 64MB
 		102b 1830  Millennium P650 64MB
@@ -2169,6 +2304,7 @@
 		102b 1087  Millennium P650 LP PCIe 64MB
 		102b 2538  Parhelia APVe
 		102b 3007  QID Low-profile PCIe
+	2539  Millennium P690
 	4536  VIA Framegrabber
 	4cdc  Morphis Vision System Jpeg2000
 	4fc5  Morphis Vision System
@@ -2335,6 +2471,7 @@
 	0645  SiS645 Host & Memory & AGP Controller
 	0646  SiS645DX Host & Memory & AGP Controller
 	0648  645xx
+	0649  SiS649 Host
 	0650  650/M650 Host
 	0651  651 Host
 	0655  655 Host
@@ -2399,6 +2536,7 @@
 	6306  530/620 PCI/AGP VGA Display Adapter
 		1039 6306  SiS530,620 GUI Accelerator+3D
 	6325  65x/M650/740 PCI/AGP VGA Display Adapter
+		1039 6325  740 [315 graphics core] on ECS K7SOM+ motherboard
 	6326  86C326 5598/6326
 		1039 6326  SiS6326 GUI Accelerator
 		1092 0a50  SpeedStar A50
@@ -2413,10 +2551,10 @@
 		1734 1099  D2030-A1
 	6350  770/670 PCIE VGA Display Adapter
 	6351  771/671 PCIE VGA Display Adapter
-	7001  USB 1.0 Controller
+	7001  USB 1.1 Controller
 		1019 0a14  K7S5A motherboard
 		1039 7000  Onboard USB Controller
-		1462 5470  K7SOM+ 5.2C Motherboard
+		1462 5470  ECS K7SOM+ motherboard
 		1462 7010  MS-6701 motherboard
 		1734 1095  D2030-A1 Motherboard
 	7002  USB 2.0 Controller
@@ -2427,6 +2565,9 @@
 	7007  FireWire Controller
 		1462 701d  MS-6701
 	7012  AC'97 Sound Controller
+		1043 818f  A8S-X Motherboard
+		13f6 0300  ECS K7SOM+ motherboard
+		1462 5850  MSI 648 Max (MS-6585)
 		1462 7010  MS-6701 motherboard
 		15bd 1001  DFI 661FX motherboard
 		1734 109f  D2030-A1 Motherboard
@@ -2464,6 +2605,7 @@
 103b  Tatung Co. of America
 103c  Hewlett-Packard Company
 	002a  NX9000 Notebook
+	08bc  NX5000 Notebook
 	1005  A4977A Visualize EG
 	1008  Visualize FX
 	1028  Tach TL Fibre Channel Host Adapter
@@ -2510,6 +2652,7 @@
 	127b  sx1000 System Bus Adapter
 	127c  sx1000 I/O Controller
 	1290  Auxiliary Diva Serial Port
+		103c 1291  Diva SP2
 	1291  Auxiliary Diva Serial Port
 	12b4  zx1 QuickSilver AGP8x Local Bus Adapter
 	12eb  sx2000 System Bus Adapter
@@ -2520,6 +2663,7 @@
 	1302  RMP-3 Shared Memory Driver
 	1303  RMP-3 (Remote Management Processor)
 	1361  BCM4312 802.11a/b/g WLAN Controller
+	1371  Broadcom Corporation BCM4312 802.11a/b/g (rev 02)
 	2910  E2910A PCIBus Exerciser
 	2925  E2925A 32 Bit, 33 MHzPCI Exerciser & Analyzer
 	3080  Pavilion ze2028ea
@@ -2735,6 +2879,7 @@
 	8025  TSB82AA2 IEEE-1394b Link Layer Controller
 		1458 1000  GA-K8N Ultra-9 Mainboard
 	8026  TSB43AB21 IEEE-1394a-2000 Controller (PHY/Link)
+		1025 0035  TravelMate 660
 		1025 003c  Aspire 2001WLCi (Compaq CL50 motherboard)
 		103c 006a  NX9500
 		1043 808d  A7V333 mainboard.
@@ -2751,42 +2896,47 @@
 		1028 018d  Inspiron 700m/710m
 	8031  PCIxx21/x515 Cardbus Controller
 		1025 0080  Aspire 5024WLMi
-		103c 0934  HP Compaq nw8240 Mobile Workstation
+		103c 0934  Compaq nw8240/nx8220
 		103c 099c  NX6110/NC6120
 		103c 308b  MX6125
 	8032  OHCI Compliant IEEE 1394 Host Controller
 		1025 0080  Aspire 5024WLMi
-		103c 0934  HP Compaq nw8240 Mobile Workstation
+		103c 0934  Compaq nw8240/nx8220
 		103c 099c  NX6110/NC6120
 		103c 308b  MX6125
 	8033  PCIxx21 Integrated FlashMedia Controller
 		1025 0080  Aspire 5024WLMi
-		103c 0934  HP Compaq nw8240 Mobile Workstation
+		103c 0934  Compaq nw8240/nx8220
 		103c 099c  NX6110/NC6120
 		103c 308b  MX6125
 	8034  PCI6411/6421/6611/6621/7411/7421/7611/7621 Secure Digital Controller
 		1025 0080  Aspire 5024WLMi
-		103c 0934  HP Compaq nw8240 Mobile Workstation
+		103c 0934  Compaq nw8240/nx8220
 		103c 099c  NX6110/NC6120
 		103c 308b  MX6125
 	8035  PCI6411/6421/6611/6621/7411/7421/7611/7621 Smart Card Controller
-		103c 0934  HP Compaq nw8240 Mobile Workstation
+		103c 0934  Compaq nw8240/nx8220
 		103c 099c  NX6110/NC6120
 	8036  PCI6515 Cardbus Controller
 	8038  PCI6515 SmartCard Controller
 	8039  PCIxx12 Cardbus Controller
 		103c 309f  nx9420
 		103c 30a1  NC2400
+		103c 30a3  Compaq nw8440
 	803a  PCIxx12 OHCI Compliant IEEE 1394 Host Controller
 		103c 309f  nx9420
 		103c 30a1  NC2400
+		103c 30a3  Compaq nw8440
 	803b  5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)
 		103c 309f  nx9420
+		103c 30a3  Compaq nw8440
 	803c  PCIxx12 SDA Standard Compliant SD Host Controller
 		103c 309f  nx9420
+		103c 30a3  Compaq nw8440
 	803d  PCIxx12 GemCore based SmartCard controller
 		103c 309f  nx9420
 		103c 30a1  NC2400
+	8101  TSB43DB42 IEEE-1394a-2000 Controller (PHY/Link)
 	8201  PCI1620 Firmware Loading Function
 	8204  PCI7410,7510,7610 PCI Firmware Loading Function
 		1028 0139  Latitude D400
@@ -2828,7 +2978,7 @@
 	ac1a  PCI1210
 	ac1b  PCI1450
 		0e11 b113  Armada M700
-		1014 0130  Thinkpad T20/T22/A21m
+		1014 0130  ThinkPad A21m/T20/T22
 	ac1c  PCI1225
 		0e11 b121  Armada E500
 		1028 0088  Latitude CPi A400XT
@@ -2863,7 +3013,7 @@
 	ac51  PCI1420 PC card Cardbus Controller
 		0e11 004e  Evo N600c
 		1014 0148  ThinkPad A20m
-		1014 023b  ThinkPad T23 (2647-4MG)
+		1014 023b  ThinkPad T23
 		1028 00b1  Latitude C600
 		1028 012a  Latitude C640
 		1033 80cd  Versa Note VXi
@@ -2876,8 +3026,8 @@
 	ac55  PCI1520 PC card Cardbus Controller
 		1014 0512  ThinkPad T30/T40
 	ac56  PCI1510 PC card Cardbus Controller
-		1014 0512  Thinkpad R50e model 1634
-		1014 0528  ThinkPad R40e (2684-HVG) Cardbus Controller
+		1014 0512  ThinkPad R50e
+		1014 0528  ThinkPad R40e
 		17aa 2012  ThinkPad T60/R60 series
 	ac60  PCI2040 PCI to DSP Bridge Controller
 		175c 5100  ASI51xx Audio Adapter
@@ -2937,6 +3087,7 @@
 	3011  ColdFusion 3e Chipset Processor to I/O Controller
 	3012  ColdFusion 3e Chipset Memory Controller Hub
 	3017  Unassigned Hitachi Shared FC Device 3017
+	301d  PCIe-to-PCIe Bridge with Virtualization IO Assist Feature
 1055  Efar Microsystems
 	9130  SLC90E66 [Victory66] IDE
 	9460  SLC90E66 [Victory66] ISA
@@ -3092,13 +3243,15 @@
 	7275  PDC20277 (SBFastTrak133 Lite)
 	8002  SATAII150 SX8
 	8350  80333 [SuperTrak EX8350/EX16350], 80331 [SuperTrak EX8300/EX16300]
-	8650  81348 [SuperTrak EX4650/EX8650/EX8654/EX4650EL]
-		105a 4600  SuperTrak EX4650
+	8650  81384 [SuperTrak EX SAS and SATA RAID Controller]
+		105a 4600  SuperTrak EX4650A
+		105a 4601  SuperTrak EX4650
 		105a 4610  SuperTrak EX4650EL
 		105a 8600  SuperTrak EX8650EL
-		105a 8601  SuperTrak EX8650
+		105a 8601  SuperTrak EX8650A
 		105a 8602  SuperTrak EX8654
 		105a 8603  SuperTrak EX8658
+		105a 8604  SuperTrak EX8650
 		105a 8610  SuperTrak EX8650M
 		105a b600  SuperTrak EX16650
 	c350  80333 [SuperTrak EX12350]
@@ -3270,6 +3423,7 @@
 	0053  Shasta PCI Bridge
 	0054  Shasta PCI Bridge
 	0055  Shasta PCI Bridge
+	0057  U3 HT Bridge
 	0058  U3L AGP Bridge
 	0059  U3H AGP Bridge
 	0066  Intrepid2 AGP Bridge
@@ -3278,6 +3432,7 @@
 	0069  Intrepid2 ATA/100
 	006a  Intrepid2 Firewire
 	006b  Intrepid2 GMAC (Sun GEM)
+	0074  U4 HT Bridge
 	1645  Tigon3 Gigabit Ethernet NIC (BCM5701)
 106c  Hynix Semiconductor
 	8801  Dual Pentium ISA/PCI Motherboard
@@ -3357,6 +3512,7 @@
 	6312  SP202-based 2Gb Fibre Channel to PCI-X HBA
 	6322  SP212-based 2Gb Fibre Channel to PCI-X HBA
 	7220  IBA7220 InfiniBand HCA
+	8432  10GbE Converged Network Adapter (CNA)
 1078  Cyrix Corporation
 	0000  5510 [Grappa]
 	0001  PCI Master
@@ -3379,6 +3535,7 @@
 	204d  [GeForce 7800 GTX] Winfast PX7800 GTX TDH
 	2134  WinFast 3D S320 II
 	2971  [GeForce FX 5900] WinFast A350 TDH MyViVo
+	6654  Conexant CX23883 [WinFast DTV1800 H]
 107e  Interphase Corporation
 	0001  5515 ATM Adapter [Flipper]
 	0002  100 VG AnyLan Controller
@@ -3552,6 +3709,7 @@
 	2ca0  PCI-6034E
 	70a9  PCI-6528 (Digital I/O at 60V)
 	70b8  PCI-6251 [M Series - High Speed Multifunction DAQ]
+	7144  PXI-5124 (12-bit 200 MS/s Digitizer)
 	b001  IMAQ-PCI-1408
 	b011  IMAQ-PXI-1408
 	b021  IMAQ-PCI-1424
@@ -3597,6 +3755,7 @@
 	3512  SiI 3512 [SATALink/SATARaid] Serial ATA Controller
 		1095 3512  SiI 3512 SATALink Controller
 		1095 6512  SiI 3512 SATARaid Controller
+	3531  Sil 3531 [SATALink/SATARaid] Serial ATA Controller
 1096  Alacron
 1097  Appian Technology
 1098  Quantum Designs (H.K.) Ltd
@@ -4144,7 +4303,7 @@
 		10b9 1523  ALI M1523 ISA Bridge
 	1531  M1531 [Aladdin IV]
 	1533  M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+]
-		1014 053b  ThinkPad R40e (2684-HVG) PCI to ISA Bridge
+		1014 053b  ThinkPad R40e
 		10b9 1533  ALi M1533 Aladdin IV/V ISA Bridge
 	1541  M1541
 		10b9 1541  ALI M1541 Aladdin V/V+ AGP System Controller
@@ -4185,19 +4344,20 @@
 	5228  M5228 ALi ATA/RAID Controller
 	5229  M5229 IDE
 		1014 050f  ThinkPad R30
-		1014 053d  ThinkPad R40e (2684-HVG) builtin IDE
+		1014 053d  ThinkPad R40e
 		103c 0024  Pavilion ze4400 builtin IDE
 		1043 8053  A7A266 Motherboard IDE
 		1849 5229  ASRock 939Dual-SATA2 Motherboard IDE (PATA)
 	5235  M5225
 	5237  USB 1.1 Controller
-		1014 0540  ThinkPad R40e (2684-HVG) builtin USB
+		1014 0540  ThinkPad R40e
 		103c 0024  Pavilion ze4400 builtin USB
 		104d 810f  VAIO PCG-U1 USB/OHCI Revision 1.0
 		10b9 5237  ASRock 939Dual-SATA2 Motherboard
 		1849 5237  ASRock 939Dual-SATA2 Motherboard
 	5239  USB 2.0 Controller
 		10b9 5239  ASRock 939Dual-SATA2 Motherboard
+		1849 5239  ASRock 939Dual-SATA2 Motherboard
 	5243  M1541 PCI to AGP Controller
 	5246  AGP8X Controller
 	5247  PCI to AGP Controller
@@ -4213,11 +4373,12 @@
 	5281  ALi M5281 Serial ATA / RAID Host Controller
 	5287  ULi 5287 SATA
 	5288  ULi M5288 SATA
+		1043 8056  A8R-MVP Mainboard
 	5289  ULi 5289 SATA
 	5450  Lucent Technologies Soft Modem AMR
 	5451  M5451 PCI AC-Link Controller Audio Device
 		1014 0506  ThinkPad R30
-		1014 053e  ThinkPad R40e (2684-HVG) builtin Audio
+		1014 053e  ThinkPad R40e
 		103c 0024  Pavilion ze4400 builtin Audio
 		10b9 5451  HP Compaq nc4010 (DY885AA#ABN)
 	5453  M5453 PCI AC-Link Controller Modem Device
@@ -4225,7 +4386,7 @@
 		10b9 5455  ASRock 939Dual-SATA2 Motherboard
 		1849 0850  ASRock 939Dual-SATA2 Motherboard
 	5457  M5457 AC'97 Modem Controller
-		1014 0535  ThinkPad R40e (2684-HVG) builtin modem
+		1014 0535  ThinkPad R40e
 		103c 0024  Pavilion ze4400 builtin Modem Device
 	5459  SmartLink SmartPCI561 56K Modem
 	545a  SmartLink SmartPCI563 56K Modem
@@ -4234,9 +4395,10 @@
 	5473  M5473 SD-MMC Controller
 	7101  M7101 Power Management Controller [PMU]
 		1014 0510  ThinkPad R30
-		1014 053c  ThinkPad R40e (2684-HVG) Power Management Controller
+		1014 053c  ThinkPad R40e
 		103c 0024  Pavilion ze4400
 		10b9 7101  ASRock 939Dual-SATA2 Motherboard
+		1849 7101  ASRock 939Dual-SATA2 Motherboard
 10ba  Mitsubishi Electric Corp.
 	0301  AccelGraphics AccelECLIPSE
 	0304  AccelGALAXY A2100 [OEM Evans & Sutherland]
@@ -4292,7 +4454,7 @@
 	8005  NM2200 [MagicMedia 256AV Audio]
 		0e11 b0d1  MagicMedia 256AV Audio Device on Discovery
 		0e11 b126  MagicMedia 256AV Audio Device on Durango
-		1014 00dd  MagicMedia 256AV Audio Device on BlackTip Thinkpad
+		1014 00dd  ThinkPad 390/i1720/i1721
 		1025 1003  MagicMedia 256AV Audio Device on TravelMate 720
 		1028 0088  Latitude CPi A
 		1028 008f  MagicMedia 256AV Audio Device on Colorado Inspiron
@@ -4469,6 +4631,7 @@
 	004e  NV40GL [Quadro FX 4000]
 	0050  CK804 ISA Bridge
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 0c11  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
@@ -4476,30 +4639,35 @@
 	0051  CK804 ISA Bridge
 	0052  CK804 SMBus
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 0c11  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 3402  NF4 AM2L Mainboard
 	0053  CK804 IDE
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 5002  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 3402  NF4 AM2L Mainboard
 	0054  CK804 Serial ATA Controller
 		1043 815a  A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 b003  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 5401  NF4 AM2L Mainboard
 	0055  CK804 Serial ATA Controller
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 b003  GA-K8N Ultra-9 Mainboard
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 5401  NF4 AM2L Mainboard
 	0056  CK804 Ethernet Controller
 	0057  CK804 Ethernet Controller
 		1043 8141  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 e000  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
@@ -4507,16 +4675,19 @@
 	0058  CK804 AC'97 Modem
 	0059  CK804 AC'97 Audio Controller
 		1043 812a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 8211  NF4 AM2L Mainboard
 	005a  CK804 USB Controller
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 5004  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
 		1565 3402  NF4 AM2L Mainboard
 	005b  CK804 USB Controller
 		1043 815a  K8N4-E or A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		1458 5004  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
 		147b 1c1a  KN8-Ultra Mainboard
@@ -4525,6 +4696,7 @@
 	005d  CK804 PCIE Bridge
 	005e  CK804 Memory Controller
 		1043 815a  A8N-E Mainboard
+		10f1 2865  Tomcat K8E (S2865)
 		10f1 2891  Thunder K8SRE Mainboard
 		1458 5000  GA-K8N Ultra-9 Mainboard
 		1462 7100  MSI K8N Diamond
@@ -4542,8 +4714,10 @@
 	0066  nForce2 Ethernet Controller
 		1043 80a7  A7N8X Mainboard onboard nForce2 Ethernet
 		10de 0c11  nForce MCP-T Networking Adapter
+		a0a0 03b3  UK79G-1394 motherboard
 	0067  nForce2 USB Controller
 		1043 0c11  A7N8X Mainboard
+		a0a0 03b4  UK79G-1394 motherboard
 	0068  nForce2 USB Controller
 		1043 0c11  A7N8X Mainboard
 		a0a0 03b4  UK79G-1394 motherboard
@@ -4552,6 +4726,7 @@
 		a0a0 0304  UK79G-1394 motherboard
 	006b  nForce Audio Processing Unit
 		10de 006b  nForce2 MCP Audio Processing Unit
+		a0a0 0304  UK79G-1394 motherboard
 	006c  nForce2 External PCI Bridge
 	006d  nForce2 PCI Bridge
 	006e  nForce2 FireWire (IEEE 1394) Controller
@@ -4664,6 +4839,7 @@
 		1682 217e  XFX GeForce 6800 XTreme 256MB DDR3 AGP
 	00f8  NV45GL [Quadro FX 3400/4400]
 	00f9  NV45 [GeForce 6800 GTO]
+		10de 00f9  NV40 [GeForce 6800 GT]
 		1682 2120  GEFORCE 6800 GT PCI-E
 	00fa  NV36 [GeForce PCX 5750]
 	00fb  NV35 [GeForce PCX 5900]
@@ -4728,7 +4904,7 @@
 	0149  NV43 [GeForce Go 6600 GT]
 	014a  Quadro NVS 440
 	014c  Quadro FX 540 MXM
-	014d  NV18GL [Quadro FX 550]
+	014d  NV43GL [Quadro FX 550]
 	014e  NV43GL [Quadro FX 540]
 	014f  NV43 [GeForce 6200]
 	0150  NV15 [GeForce2 GTS/Pro]
@@ -4832,7 +5008,7 @@
 	01de  G72GL [Quadro FX 350]
 		10de 01dc  Quadro  FX Go350M
 	01df  G71 [GeForce 7300 GS]
-	01e0  nForce2 AGP (different version?)
+	01e0  nForce2 IGP2
 		147b 1c09  NV7 Motherboard
 	01e8  nForce2 AGP
 	01ea  nForce2 Memory Controller 0
@@ -4872,6 +5048,7 @@
 	0242  C51G [GeForce 6100]
 	0243  C51 PCI Express Bridge
 	0244  C51 [Geforce 6150 Go]
+		103c 30b5  Presario V3242AU
 		103c 30b7  Presario V6133CL
 		10de 0244  GeForce Go 6150
 	0245  C51 [Quadro NVS 210S/GeForce 6150LE]
@@ -4929,6 +5106,7 @@
 	026a  MCP51 MCI
 	026b  MCP51 AC97 Audio Controller
 	026c  MCP51 High Definition Audio
+		103c 30b5  Presario V3242AU
 		103c 30b7  Presario V6133CL
 		10de cb84  A8N-VM CSM Mainboard
 		1462 7207  K8NGM2 series
@@ -4948,6 +5126,7 @@
 		1458 5001  GA-M55plus-S3G
 		1462 7207  K8NGM2 series
 	0271  MCP51 PMU
+		103c 30b5  Presario V3242AU
 		103c 30b7  Presario V6133CL
 	0272  MCP51 Memory Controller 0
 	027e  C51 Memory Controller 2
@@ -4996,7 +5175,7 @@
 	02e3  GeForce 7900 GS
 # An oddball 7950 that doesn't show up on any official NVIDIA lists but was seen in the wild
 	02e4  GeForce 7950 GT AGP
-		1682 2271  PV-T71A-YDF3 (512MB)
+		1682 2271  PV-T71A-YDF7 (512MB)
 	02f0  C51 Host Bridge
 		103c 30b7  Presario V6133CL

[... truncated: 2122 lines follow ...]


From mmu_man at mail.berlios.de  Sat May 10 16:53:03 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sat, 10 May 2008 16:53:03 +0200
Subject: [Haiku-commits] r25424 - haiku/trunk/src/libs/ncurses/ncurses/tty
Message-ID: <200805101453.m4AEr38P026012@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-10 16:53:02 +0200 (Sat, 10 May 2008)
New Revision: 25424
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25424&view=rev

Modified:
   haiku/trunk/src/libs/ncurses/ncurses/tty/lib_twait.c
   haiku/trunk/src/libs/ncurses/ncurses/tty/tty_update.c
Log:
Don't ue ioctl('ichr') for Haiku, we support select().


Modified: haiku/trunk/src/libs/ncurses/ncurses/tty/lib_twait.c
===================================================================
--- haiku/trunk/src/libs/ncurses/ncurses/tty/lib_twait.c	2008-05-10 14:13:35 UTC (rev 25423)
+++ haiku/trunk/src/libs/ncurses/ncurses/tty/lib_twait.c	2008-05-10 14:53:02 UTC (rev 25424)
@@ -157,7 +157,7 @@
 #if USE_FUNC_POLL
     struct pollfd fd_list[2];
     struct pollfd *fds = fd_list;
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) && !defined(__HAIKU__)
 #elif HAVE_SELECT
     static fd_set set;
 #endif
@@ -258,7 +258,7 @@
 
 #endif
 
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) && !defined(__HAIKU__)
     /*
      * BeOS's select() is declared in socket.h, so the configure script does
      * not see it.  That's just as well, since that function works only for
@@ -424,7 +424,7 @@
 		    result |= (1 << count);
 		}
 	    }
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) && !defined(__HAIKU__)
 	    result = 1;		/* redundant, but simple */
 #elif HAVE_SELECT
 	    if ((mode & 2)

Modified: haiku/trunk/src/libs/ncurses/ncurses/tty/tty_update.c
===================================================================
--- haiku/trunk/src/libs/ncurses/ncurses/tty/tty_update.c	2008-05-10 14:13:35 UTC (rev 25423)
+++ haiku/trunk/src/libs/ncurses/ncurses/tty/tty_update.c	2008-05-10 14:53:02 UTC (rev 25424)
@@ -298,7 +298,7 @@
 	if (poll(fds, 1, 0) > 0) {
 	    have_pending = TRUE;
 	}
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) && !defined(__HAIKU__)
 	/*
 	 * BeOS's select() is declared in socket.h, so the configure script does
 	 * not see it.  That's just as well, since that function works only for



From bonefish at mail.berlios.de  Sat May 10 18:23:48 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 18:23:48 +0200
Subject: [Haiku-commits] r25425 - haiku/trunk/src/system/kernel
Message-ID: <200805101623.m4AGNmB0002687@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 18:23:48 +0200 (Sat, 10 May 2008)
New Revision: 25425
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25425&view=rev

Modified:
   haiku/trunk/src/system/kernel/wait_for_objects.cpp
Log:
Added poll() kernel tracing.


Modified: haiku/trunk/src/system/kernel/wait_for_objects.cpp
===================================================================
--- haiku/trunk/src/system/kernel/wait_for_objects.cpp	2008-05-10 14:53:02 UTC (rev 25424)
+++ haiku/trunk/src/system/kernel/wait_for_objects.cpp	2008-05-10 16:23:48 UTC (rev 25425)
@@ -221,6 +221,135 @@
 };
 
 
+class PollTraceEntry : public AbstractTraceEntry {
+	protected:
+		PollTraceEntry(pollfd* fds, int count, bool resultEvents)
+			:
+			fEntries(NULL),
+			fCount(0)
+		{
+			if (fds != NULL && count > 0) {
+				for (int i = 0; i < count; i++) {
+					if (resultEvents ? fds[i].revents : fds[i].events)
+						fCount++;
+				}
+			}
+
+			if (fCount == 0)
+				return;
+
+			fEntries = (FDEntry*)alloc_tracing_buffer(fCount * sizeof(FDEntry));
+			if (fEntries != NULL) {
+				for (int i = 0; i < fCount; fds++) {
+					uint16 events = resultEvents ? fds->revents : fds->events;
+					if (events != 0) {
+						fEntries[i].fd = fds->fd;
+						fEntries[i].events = events;
+						i++;
+					}
+				}
+			}
+		}
+
+		void AddDump(TraceOutput& out)
+		{
+			if (fEntries == NULL)
+				return;
+
+			static const struct {
+				const char*	name;
+				uint16		event;
+			} kEventNames[] = {
+				{ "r", POLLIN },
+				{ "w", POLLOUT },
+				{ "rb", POLLRDBAND },
+				{ "wb", POLLWRBAND },
+				{ "rp", POLLPRI },
+				{ "err", POLLERR },
+				{ "hup", POLLHUP },
+				{ "inv", POLLNVAL },
+				{ NULL, 0 }
+			};
+
+			bool firstFD = true;
+			for (int i = 0; i < fCount; i++) {
+				if (firstFD) {
+					out.Print("<%u: ", fEntries[i].fd);
+					firstFD = false;
+				} else
+					out.Print(", <%u: ", fEntries[i].fd);
+
+				bool firstEvent = true;
+				for (int k = 0; kEventNames[k].name != NULL; k++) {
+					if ((fEntries[i].events & kEventNames[k].event) != 0) {
+						if (firstEvent) {	
+							out.Print("%s", kEventNames[k].name);
+							firstEvent = false;
+						} else
+							out.Print(", %s", kEventNames[k].name);
+					}
+				}
+
+				out.Print(">");
+			}
+		}
+
+	protected:
+		struct FDEntry {
+			uint16	fd;
+			uint16	events;
+		};
+
+		FDEntry*	fEntries;
+		int			fCount;
+};
+
+
+class PollBegin : public PollTraceEntry {
+	public:
+		PollBegin(pollfd* fds, int count, bigtime_t timeout)
+			:
+			PollTraceEntry(fds, count, false),
+			fTimeout(timeout)
+		{
+			Initialized();
+		}
+
+		virtual void AddDump(TraceOutput& out)
+		{
+			out.Print("poll begin: ");
+			PollTraceEntry::AddDump(out);
+			out.Print(", timeout: %lld", fTimeout);
+		}
+
+	private:
+		bigtime_t	fTimeout;
+};
+
+
+class PollDone : public PollTraceEntry {
+	public:
+		PollDone(pollfd* fds, int count, int result)
+			:
+			PollTraceEntry(fds, result >= 0 ? count : 0, true),
+			fResult(result)
+		{
+			Initialized();
+		}
+
+		virtual void AddDump(TraceOutput& out)
+		{
+			if (fResult >= 0) {
+				out.Print("poll done:  count: %d: ", fResult);
+				PollTraceEntry::AddDump(out);
+			} else
+				out.Print("poll done:  error: 0x%x", fResult);
+		}
+
+	private:
+		int		fResult;
+};
+
 }	// namespace WaitForObjectsTracing
 
 #	define T(x)	new(std::nothrow) WaitForObjectsTracing::x
@@ -427,6 +556,8 @@
 	if (status != B_OK)
 		return status;
 
+	T(PollBegin(fds, numFDs, timeout));
+
 	// start polling file descriptors (by selecting them)
 
 	for (i = 0; i < numFDs; i++) {
@@ -484,6 +615,8 @@
 err:
 	put_select_sync(sync);
 
+	T(PollDone(fds, numFDs, count));
+
 	return count;
 }
 



From bonefish at mail.berlios.de  Sat May 10 18:26:05 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 18:26:05 +0200
Subject: [Haiku-commits] r25426 - haiku/trunk/src/tests/system/libroot/posix
Message-ID: <200805101626.m4AGQ514002864@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 18:26:05 +0200 (Sat, 10 May 2008)
New Revision: 25426
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25426&view=rev

Added:
   haiku/trunk/src/tests/system/libroot/posix/setjmp_test2.S
Modified:
   haiku/trunk/src/tests/system/libroot/posix/Jamfile
Log:
Test for setjmp() that demonstrates why it isn't a good idea to
manipulate the stack pointer as we do.


Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile
===================================================================
--- haiku/trunk/src/tests/system/libroot/posix/Jamfile	2008-05-10 16:23:48 UTC (rev 25425)
+++ haiku/trunk/src/tests/system/libroot/posix/Jamfile	2008-05-10 16:26:05 UTC (rev 25426)
@@ -20,6 +20,10 @@
 	: setjmp_test.c
 ;
 
+SimpleTest setjmp_test2
+	: setjmp_test2.S
+;
+
 SimpleTest signal_test
 	: signal_test.cpp
 ;

Added: haiku/trunk/src/tests/system/libroot/posix/setjmp_test2.S
===================================================================
--- haiku/trunk/src/tests/system/libroot/posix/setjmp_test2.S	2008-05-10 16:23:48 UTC (rev 25425)
+++ haiku/trunk/src/tests/system/libroot/posix/setjmp_test2.S	2008-05-10 16:26:05 UTC (rev 25426)
@@ -0,0 +1,12 @@
+#define FUNCTION(x) .global x; .type x, at function; x
+
+FUNCTION(main):
+	mov		$jmpBuffer, %eax
+	push	%eax
+	call	setjmp
+	add		$4, %esp
+
+	mov		$0, %eax
+	ret
+
+.comm	jmpBuffer, 1024, 32



From axeld at pinc-software.de  Sat May 10 18:40:19 2008
From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=)
Date: Sat, 10 May 2008 18:40:19 +0200 CEST
Subject: [Haiku-commits] r25404 -
 haiku/trunk/src/add-ons/kernel/file_systems/bfs
In-Reply-To: <20080510155841.744.3@knochen-vm.1210421914.fake>
Message-ID: <30163084731-BeMail@zon>

Ingo Weinhold  wrote:
> On 2008-05-10 at 12:22:44 [+0200], Axel D?rfler  
> > wrote:
> > bonefish at BerliOS  wrote:
> > > Log:
> > > Don't create anything in a removed directory. Axel, please 
> > > review. I
> > > don't see how the locking in Remove()/Create() works.
> > Does this fix an actual bug?
> As the commit log says, you could create entries in a removed 
> directory 
> (mkdir /tmp/tt; cd /tmp/tt; rmdir /tmp/tt; touch a; mkdir b), which 
> is 
> certainly a bug.

Yup :-)

> > If so, it should probably be moved into
> > the VFS instead.
> Can't be done, since the serialization of write accesses is done in 
> the FS.

You're right, bummer.

> > Create/remove locking works over transactions - those are always
> > serialized.
> Good, my change should be OK, then. The check could even be moved up 
> a bit.

Doesn't really matter, though.

Bye,
   Axel.



From bonefish at mail.berlios.de  Sat May 10 19:10:15 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 19:10:15 +0200
Subject: [Haiku-commits] r25427 -
	haiku/trunk/src/system/libroot/posix/arch/x86
Message-ID: <200805101710.m4AHAFuh026382@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 19:10:15 +0200 (Sat, 10 May 2008)
New Revision: 25427
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25427&view=rev

Modified:
   haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S
Log:
Fixed my fix. It would always return 1 now.


Modified: haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S	2008-05-10 16:26:05 UTC (rev 25426)
+++ haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S	2008-05-10 17:10:15 UTC (rev 25427)
@@ -21,8 +21,8 @@
 
 	/* If value is 0, setjmp() must return 1. */
 	test	%eax, %eax
+	jnz		1f
 	mov		$1, %eax
-	jnz		1f
 1:
 
 	// restore registers



From bonefish at mail.berlios.de  Sat May 10 19:16:10 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 19:16:10 +0200
Subject: [Haiku-commits] r25428 -
	haiku/trunk/src/system/libroot/posix/arch/x86
Message-ID: <200805101716.m4AHGAl7000640@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 19:16:09 +0200 (Sat, 10 May 2008)
New Revision: 25428
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25428&view=rev

Removed:
   haiku/trunk/src/system/libroot/posix/arch/x86/setjmp.S
Modified:
   haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile
   haiku/trunk/src/system/libroot/posix/arch/x86/sigsetjmp.S
Log:
Reimplemented setjmp(). It no longer offsets the caller's esp.


Modified: haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile	2008-05-10 17:10:15 UTC (rev 25427)
+++ haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile	2008-05-10 17:16:09 UTC (rev 25428)
@@ -7,7 +7,6 @@
 ;
 
 MergeObject posix_arch_$(TARGET_ARCH).o :
-	setjmp.S
 	sigsetjmp.S
 	siglongjmp.S
 

Deleted: haiku/trunk/src/system/libroot/posix/arch/x86/setjmp.S

Modified: haiku/trunk/src/system/libroot/posix/arch/x86/sigsetjmp.S
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/x86/sigsetjmp.S	2008-05-10 17:10:15 UTC (rev 25427)
+++ haiku/trunk/src/system/libroot/posix/arch/x86/sigsetjmp.S	2008-05-10 17:16:09 UTC (rev 25428)
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
  * Copyright 2004-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
@@ -15,23 +16,45 @@
  *	if it was asked to do this.
  */
 
-
 /* int sigsetjmp(jmp_buf buffer, int saveMask) */
 FUNCTION(__sigsetjmp):
 FUNCTION(sigsetjmp):
+	// return address to %edx, stack pointer for return to %ecx (both are
+	// scratch registers)
+	mov		0(%esp), %edx
+	lea		4(%esp), %ecx
+
+	// buffer to %eax
 	mov		4(%esp), %eax
 
-	// fill __jmp_buf structure with current registers (%ecx can be clobbered)
+sigsetjmp_setjmp_entry:
+	// fill __jmp_buf structure with current registers
 	mov		%ebx, JMP_REGS_EBX(%eax)
 	mov		%esi, JMP_REGS_ESI(%eax)
 	mov		%edi, JMP_REGS_EDI(%eax)
 	mov		%ebp, JMP_REGS_EBP(%eax)
 
 	// save stack and return address (because that's where we intend to jump to)
-	lea		4(%esp,1), %ecx
 	mov		%ecx, JMP_REGS_ESP(%eax)
-	mov		0(%esp), %ecx
-	mov		%ecx, JMP_REGS_PC(%eax)
+	mov		%edx, JMP_REGS_PC(%eax)
 
 	jmp		__setjmp_save_sigs
 
+
+/* int setjmp(jmp_buf buffer) */
+FUNCTION(setjmp):
+	// prepare %edx, %ecx, and %eax for sigsetjmp
+	mov		0(%esp), %edx
+	lea		4(%esp), %ecx
+	mov		(%ecx), %eax
+
+	// let sigsetjmp do the real work
+	pushl	$0							// saveMask
+	push	%eax						// buffer
+	call	sigsetjmp_setjmp_entry
+	add		$8, %esp
+
+	ret
+
+
+#pragma weak _setjmp=setjmp



From anevilyak at gmail.com  Sat May 10 19:36:30 2008
From: anevilyak at gmail.com (Rene Gollent)
Date: Sat, 10 May 2008 12:36:30 -0500
Subject: [Haiku-commits] r25428 -
	haiku/trunk/src/system/libroot/posix/arch/x86
In-Reply-To: <200805101716.m4AHGAl7000640@sheep.berlios.de>
References: <200805101716.m4AHGAl7000640@sheep.berlios.de>
Message-ID: 

Hi Ingo,

On Sat, May 10, 2008 at 12:16 PM, bonefish at BerliOS
 wrote:
> Author: bonefish
> Date: 2008-05-10 19:16:09 +0200 (Sat, 10 May 2008)
> New Revision: 25428
> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25428&view=rev
>
> Removed:
>   haiku/trunk/src/system/libroot/posix/arch/x86/setjmp.S
> Modified:
>   haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile
>   haiku/trunk/src/system/libroot/posix/arch/x86/sigsetjmp.S
> Log:
> Reimplemented setjmp(). It no longer offsets the caller's esp.
>

Should setjmp.S also be removed from system/kernel/lib/Jamfile? That
fails to build now because of not finding that file.

Regards,

Rene


From bonefish at mail.berlios.de  Sat May 10 19:39:29 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 19:39:29 +0200
Subject: [Haiku-commits] r25429 - haiku/trunk/src/system/kernel/lib
Message-ID: <200805101739.m4AHdTSM030293@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 19:39:29 +0200 (Sat, 10 May 2008)
New Revision: 25429
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25429&view=rev

Modified:
   haiku/trunk/src/system/kernel/lib/Jamfile
Log:
Forgot to check this one in. setjmp.S is no more.


Modified: haiku/trunk/src/system/kernel/lib/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/lib/Jamfile	2008-05-10 17:16:09 UTC (rev 25428)
+++ haiku/trunk/src/system/kernel/lib/Jamfile	2008-05-10 17:39:29 UTC (rev 25429)
@@ -130,7 +130,6 @@
 SEARCH_SOURCE += [ FDirName $(posixSources) string arch $(TARGET_ARCH) ] ;
 
 KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o :
-	setjmp.S
 	siglongjmp.S
 	sigsetjmp.S
 	kernel_setjmp_save_sigs.c



From bonefish at mail.berlios.de  Sat May 10 20:05:42 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 20:05:42 +0200
Subject: [Haiku-commits] r25430 - in haiku/trunk/src/system: kernel/lib
	libroot/posix/arch/x86
Message-ID: <200805101805.m4AI5gWp032247@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 20:05:41 +0200 (Sat, 10 May 2008)
New Revision: 25430
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25430&view=rev

Added:
   haiku/trunk/src/system/kernel/lib/kernel_longjmp_return.c
Modified:
   haiku/trunk/src/system/kernel/lib/Jamfile
   haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile
   haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S
Log:
siglongjmp() calls __longjmp_return() also on x86, now. This resets the
signal mask as required. and also makes my recent return value fix
unnecessary, since __longjmp_return() already does that.


Modified: haiku/trunk/src/system/kernel/lib/Jamfile
===================================================================
--- haiku/trunk/src/system/kernel/lib/Jamfile	2008-05-10 17:39:29 UTC (rev 25429)
+++ haiku/trunk/src/system/kernel/lib/Jamfile	2008-05-10 18:05:41 UTC (rev 25430)
@@ -132,6 +132,7 @@
 KernelMergeObject kernel_lib_posix_arch_$(TARGET_ARCH).o :
 	siglongjmp.S
 	sigsetjmp.S
+	kernel_longjmp_return.c
 	kernel_setjmp_save_sigs.c
 	arch_string.S				# TODO: Not needed for X86!
 

Added: haiku/trunk/src/system/kernel/lib/kernel_longjmp_return.c
===================================================================
--- haiku/trunk/src/system/kernel/lib/kernel_longjmp_return.c	2008-05-10 17:39:29 UTC (rev 25429)
+++ haiku/trunk/src/system/kernel/lib/kernel_longjmp_return.c	2008-05-10 18:05:41 UTC (rev 25430)
@@ -0,0 +1,17 @@
+/* 
+ * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include 
+
+
+/*!	This function is called by [sig]longjmp(). */
+
+int __longjmp_return(jmp_buf buffer, int value);
+
+int
+__longjmp_return(jmp_buf buffer, int value)
+{
+	return (value == 0 ? 1 : value);
+}

Modified: haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile	2008-05-10 17:39:29 UTC (rev 25429)
+++ haiku/trunk/src/system/libroot/posix/arch/x86/Jamfile	2008-05-10 18:05:41 UTC (rev 25430)
@@ -1,9 +1,8 @@
 SubDir HAIKU_TOP src system libroot posix arch x86 ;
 
-# TODO: siglongjmp.S should use __longjmp_return to restore the signal mask.
 local genericSources =
 	setjmp_save_sigs.c
-#	longjmp_return.c
+	longjmp_return.c
 ;
 
 MergeObject posix_arch_$(TARGET_ARCH).o :

Modified: haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S	2008-05-10 17:39:29 UTC (rev 25429)
+++ haiku/trunk/src/system/libroot/posix/arch/x86/siglongjmp.S	2008-05-10 18:05:41 UTC (rev 25430)
@@ -3,7 +3,6 @@
 ** Distributed under the terms of the Haiku License.
 */
 
-
 #include "setjmp_internal.h"
 
 
@@ -19,12 +18,6 @@
 	mov		4(%esp), %ecx
 	mov		8(%esp), %eax
 
-	/* If value is 0, setjmp() must return 1. */
-	test	%eax, %eax
-	jnz		1f
-	mov		$1, %eax
-1:
-
 	// restore registers
 	mov		JMP_REGS_EBX(%ecx), %ebx
 	mov		JMP_REGS_ESI(%ecx), %esi
@@ -32,8 +25,17 @@
 	mov		JMP_REGS_EBP(%ecx), %ebp
 	mov		JMP_REGS_ESP(%ecx), %esp
 
-	// jump back to the old program location
+	// prepare the stack so that we will return to the setjmp() program location
 	mov		JMP_REGS_PC(%ecx), %edx
-	jmp		*%edx
+	push	%edx				// return address
 
+	// let __setjmp_save_sigs deal with the signal mask and the return value
+	push	%eax				// value
+	push	%ecx				// buffer
+	call	__longjmp_return
+	add		$8, %esp
+
+	ret
+
+
 #pragma weak longjmp=siglongjmp



From bonefish at mail.berlios.de  Sat May 10 20:10:15 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 20:10:15 +0200
Subject: [Haiku-commits] r25431 - in
	haiku/trunk/src/system/libroot/posix/arch: m68k ppc
Message-ID: <200805101810.m4AIAFeQ032610@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 20:10:15 +0200 (Sat, 10 May 2008)
New Revision: 25431
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25431&view=rev

Removed:
   haiku/trunk/src/system/libroot/posix/arch/m68k/setjmp.S
   haiku/trunk/src/system/libroot/posix/arch/ppc/setjmp.S
Modified:
   haiku/trunk/src/system/libroot/posix/arch/m68k/Jamfile
   haiku/trunk/src/system/libroot/posix/arch/m68k/sigsetjmp.S
   haiku/trunk/src/system/libroot/posix/arch/ppc/Jamfile
   haiku/trunk/src/system/libroot/posix/arch/ppc/sigsetjmp.S
Log:
Moved setjmp() to sigsetjmp.S for ppc and m68k, too. Should fix the
kernel build. Haven't tested it though.


Modified: haiku/trunk/src/system/libroot/posix/arch/m68k/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/m68k/Jamfile	2008-05-10 18:05:41 UTC (rev 25430)
+++ haiku/trunk/src/system/libroot/posix/arch/m68k/Jamfile	2008-05-10 18:10:15 UTC (rev 25431)
@@ -6,7 +6,6 @@
 ;
 
 MergeObject posix_arch_$(TARGET_ARCH).o :
-	setjmp.S
 	sigsetjmp.S
 	siglongjmp.S
 

Deleted: haiku/trunk/src/system/libroot/posix/arch/m68k/setjmp.S

Modified: haiku/trunk/src/system/libroot/posix/arch/m68k/sigsetjmp.S
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/m68k/sigsetjmp.S	2008-05-10 18:05:41 UTC (rev 25430)
+++ haiku/trunk/src/system/libroot/posix/arch/m68k/sigsetjmp.S	2008-05-10 18:10:15 UTC (rev 25431)
@@ -25,3 +25,17 @@
 #warning M68K: check this.
 
 	jmp		__setjmp_save_sigs
+
+
+/* int setjmp(jmp_buf buffer) */
+FUNCTION(setjmp):
+	move.l	(%a7)+,%a0
+	move.l	(%a7)+,%d0
+	clr.l	-(%a7)		/* push 0 as 2nd arg */
+	move.l	%d0,-(%a7)
+	move.l	%a0,-(%a7)
+	// call __sigsetjmp with saveMask = 0
+	jmp	__sigsetjmp
+
+
+#pragma weak _setjmp=setjmp

Modified: haiku/trunk/src/system/libroot/posix/arch/ppc/Jamfile
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/ppc/Jamfile	2008-05-10 18:05:41 UTC (rev 25430)
+++ haiku/trunk/src/system/libroot/posix/arch/ppc/Jamfile	2008-05-10 18:10:15 UTC (rev 25431)
@@ -6,7 +6,6 @@
 ;
 
 MergeObject posix_arch_$(TARGET_ARCH).o :
-	setjmp.S
 	sigsetjmp.S
 	siglongjmp.S
 

Deleted: haiku/trunk/src/system/libroot/posix/arch/ppc/setjmp.S

Modified: haiku/trunk/src/system/libroot/posix/arch/ppc/sigsetjmp.S
===================================================================
--- haiku/trunk/src/system/libroot/posix/arch/ppc/sigsetjmp.S	2008-05-10 18:05:41 UTC (rev 25430)
+++ haiku/trunk/src/system/libroot/posix/arch/ppc/sigsetjmp.S	2008-05-10 18:10:15 UTC (rev 25431)
@@ -40,3 +40,12 @@
 	stw		%r0, JMP_REGS_CR(3)
 
 	b		__setjmp_save_sigs
+
+
+/* int setjmp(jmp_buf buffer) */
+FUNCTION(setjmp):
+	// call __sigsetjmp with saveMask = 0
+	addi	%r4, 0, 0
+	b		__sigsetjmp
+
+#pragma weak _setjmp=setjmp



From mmlr at mail.berlios.de  Sat May 10 23:09:45 2008
From: mmlr at mail.berlios.de (mmlr at BerliOS)
Date: Sat, 10 May 2008 23:09:45 +0200
Subject: [Haiku-commits] r25432 -
	haiku/trunk/src/add-ons/kernel/bus_managers/usb
Message-ID: <200805102109.m4AL9j5v015838@sheep.berlios.de>

Author: mmlr
Date: 2008-05-10 23:09:44 +0200 (Sat, 10 May 2008)
New Revision: 25432
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25432&view=rev

Modified:
   haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp
   haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h
Log:
* Clear the endpoints of an alternate interface that is going away before
  updating the active pointer as otherwise the endpoints of the new alternate
  would have been cleared instead of the old one (leaking endpoints).
* Only clear and re-initialize the endpoints of the interface we are setting
  an alterntate. Otherwise we tear down all the device endpoints which would
  result in a bad situation for composite devices where multiple drivers may
  use different functions (through different interfaces) of a device side by
  side.
* Minor cleanup.

Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp	2008-05-10 18:10:15 UTC (rev 25431)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Device.cpp	2008-05-10 21:09:44 UTC (rev 25432)
@@ -370,7 +370,7 @@
 	fCurrentConfiguration = &fConfigurations[index];
 
 	// Initialize all the endpoints that are now active
-	InitEndpoints();
+	InitEndpoints(-1);
 
 	// Wait some for the configuration being finished
 	if (!fIsRootHub)
@@ -380,13 +380,16 @@
 
 
 void
-Device::InitEndpoints()
+Device::InitEndpoints(int32 interfaceIndex)
 {
 	int8 hubAddress = 0;
 	if (Parent() && (Parent()->Type() & USB_OBJECT_HUB))
 		hubAddress = ((Hub *)Parent())->DeviceAddress();
 
 	for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) {
+		if (interfaceIndex >= 0 && j != (size_t)interfaceIndex)
+			continue;
+
 		usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active;
 		for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) {
 			usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i];
@@ -424,6 +427,7 @@
 	}
 }
 
+
 status_t
 Device::Unconfigure(bool atDeviceLevel)
 {
@@ -450,17 +454,20 @@
 
 	if (!fCurrentConfiguration)
 		return B_OK;
-	ClearEndpoints();
 
+	ClearEndpoints(-1);
 	fCurrentConfiguration = NULL;
 	return B_OK;
 }
 
 
 void
-Device::ClearEndpoints()
+Device::ClearEndpoints(int32 interfaceIndex)
 {
 	for (size_t j = 0; j < fCurrentConfiguration->interface_count; j++) {
+		if (interfaceIndex >= 0 && j != (size_t)interfaceIndex)
+			continue;
+
 		usb_interface_info *interfaceInfo = fCurrentConfiguration->interface[j].active;
 		for (size_t i = 0; i < interfaceInfo->endpoint_count; i++) {
 			usb_endpoint_info *endpoint = &interfaceInfo->endpoint[i];
@@ -474,12 +481,13 @@
 status_t
 Device::SetAltInterface(const usb_interface_info *interface)
 {
+	uint8 interfaceNumber = interface->descr->interface_number;
 	// Tell the device to set the alternate settings
 	status_t result = fDefaultPipe->SendRequest(
 		USB_REQTYPE_INTERFACE_OUT | USB_REQTYPE_STANDARD,	// type
 		USB_REQUEST_SET_INTERFACE,							// request
 		interface->descr->alternate_setting,				// value
-		interface->descr->interface_number,					// index
+		interfaceNumber,									// index
 		0,													// length
 		NULL,												// buffer
 		0,													// buffer length
@@ -488,15 +496,17 @@
 	if (result < B_OK)
 		return result;
 
-	// Update descriptor
+	// Clear the no longer active endpoints
+	ClearEndpoints(interfaceNumber);
+
+	// Update the active pointer of the interface list
 	usb_interface_list *interfaceList
-		= &fCurrentConfiguration->interface[interface->descr->interface_number];
+		= &fCurrentConfiguration->interface[interfaceNumber];
 	interfaceList->active
 		= &interfaceList->alt[interface->descr->alternate_setting];
 
-	ClearEndpoints();
-	InitEndpoints();
-
+	// Initialize the new endpoints
+	InitEndpoints(interfaceNumber);
 	return result;
 }
 

Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h	2008-05-10 18:10:15 UTC (rev 25431)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_p.h	2008-05-10 21:09:44 UTC (rev 25432)
@@ -443,8 +443,8 @@
 
 		status_t						SetAltInterface(const usb_interface_info *interface);
 
-		void							InitEndpoints();
-		void							ClearEndpoints();
+		void							InitEndpoints(int32 interfaceIndex);
+		void							ClearEndpoints(int32 interfaceIndex);
 
 virtual	status_t						ReportDevice(
 											usb_support_descriptor *supportDescriptors,



From bonefish at mail.berlios.de  Sat May 10 23:30:36 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 23:30:36 +0200
Subject: [Haiku-commits] r25433 - in haiku/trunk/headers/posix: . net
	netinet sys
Message-ID: <200805102130.m4ALUaX9017245@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 23:30:34 +0200 (Sat, 10 May 2008)
New Revision: 25433
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25433&view=rev

Modified:
   haiku/trunk/headers/posix/assert.h
   haiku/trunk/headers/posix/ctype.h
   haiku/trunk/headers/posix/fcntl.h
   haiku/trunk/headers/posix/inttypes.h
   haiku/trunk/headers/posix/libio.h
   haiku/trunk/headers/posix/limits.h
   haiku/trunk/headers/posix/math.h
   haiku/trunk/headers/posix/net/route.h
   haiku/trunk/headers/posix/netinet/in.h
   haiku/trunk/headers/posix/netinet/ip_var.h
   haiku/trunk/headers/posix/pthread.h
   haiku/trunk/headers/posix/setjmp.h
   haiku/trunk/headers/posix/shadow.h
   haiku/trunk/headers/posix/signal.h
   haiku/trunk/headers/posix/size_t.h
   haiku/trunk/headers/posix/stdint.h
   haiku/trunk/headers/posix/stdio.h
   haiku/trunk/headers/posix/stdio_post.h
   haiku/trunk/headers/posix/string.h
   haiku/trunk/headers/posix/sys/mman.h
   haiku/trunk/headers/posix/sys/poll.h
   haiku/trunk/headers/posix/sys/resource.h
   haiku/trunk/headers/posix/sys/stat.h
   haiku/trunk/headers/posix/sys/wait.h
   haiku/trunk/headers/posix/unistd.h
   haiku/trunk/headers/posix/wchar.h
   haiku/trunk/headers/posix/wchar_t.h
Log:
Patch by Andreas Faerber:
Replaced single-line comments by multi-line comments for ANSI C
compliance.


Modified: haiku/trunk/headers/posix/assert.h
===================================================================
--- haiku/trunk/headers/posix/assert.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/assert.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -7,7 +7,7 @@
 #undef assert
 
 #ifndef NDEBUG
-	// defining NDEBUG disables assert() functionality
+	/* defining NDEBUG disables assert() functionality */
 
 #ifdef __cplusplus
 extern "C" {
@@ -26,8 +26,8 @@
 #define assert(assertion) \
 	((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__))
 
-#else	// NDEBUG
-#	define assert(condition) ;
+#else	/* NDEBUG */
+#	define assert(condition) ((void)0)
 #endif
 
 #endif	/* _ASSERT_H_ */

Modified: haiku/trunk/headers/posix/ctype.h
===================================================================
--- haiku/trunk/headers/posix/ctype.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/ctype.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -74,4 +74,4 @@
 }
 #endif
 
-#endif // _CTYPE_H
+#endif /* _CTYPE_H */

Modified: haiku/trunk/headers/posix/fcntl.h
===================================================================
--- haiku/trunk/headers/posix/fcntl.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/fcntl.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -53,7 +53,7 @@
 #define O_RSYNC			0x00020000	/* read synchronized I/O file integrity */
 #define O_DSYNC			0x00040000	/* write synchronized I/O data integrity */
 
-// TODO: currently not implemented additions:
+/* TODO: currently not implemented additions: */
 #define O_NOFOLLOW		0x00080000
 	/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
 #define O_NOCACHE		0x00100000	/* doesn't use the file system cache if possible */

Modified: haiku/trunk/headers/posix/inttypes.h
===================================================================
--- haiku/trunk/headers/posix/inttypes.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/inttypes.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -204,8 +204,8 @@
 
 extern intmax_t		strtoimax(const char *string, char **_end, int base);
 extern uintmax_t	strtoumax(const char *string, char **_end, int base);
-//extern intmax_t		wcstoimax(const __wchar_t *, __wchar_t **, int);
-//extern uintmax_t	wcstoumax(const __wchar_t *, __wchar_t **, int);
+/* extern intmax_t		wcstoimax(const __wchar_t *, __wchar_t **, int); */
+/* extern uintmax_t	wcstoumax(const __wchar_t *, __wchar_t **, int); */
 
 #ifdef __cplusplus
 }

Modified: haiku/trunk/headers/posix/libio.h
===================================================================
--- haiku/trunk/headers/posix/libio.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/libio.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -138,7 +138,7 @@
 	struct _IO_FILE *_chain;
 
 	int		_fileno;
-//	int		_blksize;
+/*	int		_blksize; */
 	int		_flags2;
 	off_t	_old_offset; /* This used to be _offset but it's too small. */
 		/* -> not true on BeOS, but who cares */
@@ -151,14 +151,14 @@
 	_IO_lock_t *_lock;
 
 	off_t	_offset;
-//#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+/* #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T */
 	/* Wide character stream stuff.  */
 	struct _IO_codecvt *_codecvt;
 	struct _IO_wide_data *_wide_data;
-//#else
-//	void	*__pad1;
-//	void	*__pad2;
-//#endif
+/* #else
+ *	void	*__pad1;
+ *	void	*__pad2;
+ * #endif */
 	int _mode;
 	/* Make sure we don't get into trouble again.  */
 	char _unused2[15 * sizeof (int) - 2 * sizeof (void *)];

Modified: haiku/trunk/headers/posix/limits.h
===================================================================
--- haiku/trunk/headers/posix/limits.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/limits.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -1,6 +1,6 @@
 #ifndef _LIBC_LIMITS_H_
 #define _LIBC_LIMITS_H_
-	// Note: The header guard is checked in gcc's limits.h.
+	/* Note: The header guard is checked in gcc's limits.h. */
 
 #include 		/* for DBL_DIG, FLT_DIG, etc */
 

Modified: haiku/trunk/headers/posix/math.h
===================================================================
--- haiku/trunk/headers/posix/math.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/math.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -34,7 +34,7 @@
 #define __huge_valf_t	union { unsigned char __c[4]; long __l; float __f; }
 #define HUGE_VALF		(((__huge_valf_t) { __l: __HUGE_VALF_v }).__f)
 
-// ToDo: define HUGE_VALL for long doubles
+/* ToDo: define HUGE_VALL for long doubles */
 
 #define __NAN_VALF_v	0x7fc00000L
 #define NAN				(((__huge_valf_t) { __l: __NAN_VALF_v }).__f)
@@ -146,7 +146,7 @@
 extern long double	roundl(long double x);
 extern long		lroundl(long double x);
 
-// TODO: add and fix those!
+/* TODO: add and fix those! */
 extern /*long*/ double	lgamma(/*long*/ double x);
 
 /* some BSD non-ANSI or POSIX math functions */

Modified: haiku/trunk/headers/posix/net/route.h
===================================================================
--- haiku/trunk/headers/posix/net/route.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/net/route.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -20,8 +20,8 @@
 #define RTF_BLACKHOLE	0x00001000
 #define RTF_LOCAL		0x00200000
 
-// This structure is used to pass routes to and from the network stack
-// (via struct ifreq)
+/* This structure is used to pass routes to and from the network stack
+ * (via struct ifreq) */
 
 struct route_entry {
 	struct sockaddr	*destination;

Modified: haiku/trunk/headers/posix/netinet/in.h
===================================================================
--- haiku/trunk/headers/posix/netinet/in.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/netinet/in.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -22,7 +22,7 @@
  * and we are not allowed to import all the BeOS types here.
  */
 #ifndef htonl
-//	extern uint32_t __swap_int32(uint32_t);	/* private */
+/*	extern uint32_t __swap_int32(uint32_t); */	/* private */
 	extern unsigned long __swap_int32(unsigned long);	/* private */
 	extern uint16_t __swap_int16(uint16_t);	/* private */
 	#if 	BYTE_ORDER == LITTLE_ENDIAN

Modified: haiku/trunk/headers/posix/netinet/ip_var.h
===================================================================
--- haiku/trunk/headers/posix/netinet/ip_var.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/netinet/ip_var.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -138,7 +138,7 @@
         int32_t  ips_outhwcsum;          /* hardware checksummed on output */
 };
 
-//#ifdef _KERNEL_MODE
+/* #ifdef _KERNEL_MODE */
 
 #define IP_FORWARDING			0x1				/* most of ip header exists */
 #define IP_ALLOWBROADCAST		SO_BROADCAST	/* can send broadcast packets */
@@ -147,7 +147,7 @@
 #define IP_MTUDISC				0x10			/* pmtu discovery, set DF */
 
 #if 0
-//struct ipstat ipstat;
+/* struct ipstat ipstat; */
 
 void  ipv4_input(struct mbuf *, int);
 int   ipv4_output(struct mbuf *, struct mbuf *, struct route *, int, void *);

Modified: haiku/trunk/headers/posix/pthread.h
===================================================================
--- haiku/trunk/headers/posix/pthread.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/pthread.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -72,7 +72,7 @@
 #define PTHREAD_PRIO_INHERIT		1
 #define PTHREAD_PRIO_PROTECT		2
 
-//extern pthread_mutexattr_t pthread_mutexattr_default;
+/* extern pthread_mutexattr_t pthread_mutexattr_default; */
 
 /* private structure */
 struct __pthread_cleanup_handler {
@@ -176,13 +176,13 @@
 
 #if 0	/* Unimplemented attribute functions: */
 
-// mandatory!
+/* mandatory! */
 extern int pthread_attr_getschedparam(const pthread_attr_t *attr,
 	struct sched_param *param);
 extern int pthread_attr_setschedparam(pthread_attr_t *attr,
 	const struct sched_param *param);
 
-// [TPS]
+/* [TPS] */
 extern int pthread_attr_getinheritsched(const pthread_attr_t *attr,
 	int *inheritsched);
 extern int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
@@ -194,17 +194,17 @@
 	int *contentionscope);
 extern int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
 
-// [XSI]
+/* [XSI] */
 extern int pthread_attr_getguardsize(const pthread_attr_t *attr,
 	size_t *guardsize);
 extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
 
-// [TSA]
+/* [TSA] */
 extern int pthread_attr_getstackaddr(const pthread_attr_t *attr,
 	void **stackaddr);
 extern int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
 
-// [TSA TSS]
+/* [TSA TSS] */
 extern int pthread_attr_getstack(const pthread_attr_t *attr,
 	void **stackaddr, size_t *stacksize);
 extern int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize);

Modified: haiku/trunk/headers/posix/setjmp.h
===================================================================
--- haiku/trunk/headers/posix/setjmp.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/setjmp.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -7,7 +7,7 @@
 
 #include 
 
-// include architecture specific definitions
+/* include architecture specific definitions */
 #ifdef __INTEL__
 	#include 
 #elif __POWERPC__

Modified: haiku/trunk/headers/posix/shadow.h
===================================================================
--- haiku/trunk/headers/posix/shadow.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/shadow.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -49,4 +49,4 @@
 #endif
 
 
-#endif	// _SHADOW_H_
+#endif	/* _SHADOW_H_ */

Modified: haiku/trunk/headers/posix/signal.h
===================================================================
--- haiku/trunk/headers/posix/signal.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/signal.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -25,9 +25,9 @@
 #define SIG_ERR		((sighandler_t)-1)	/* an error occurred during signal processing */
 #define SIG_HOLD	((sighandler_t)3)	/* the signal was hold */
 
-// TODO: Support this structure, or more precisely the SA_SIGINFO flag. To do
-// this properly we need real-time signal support. Both are commented out for
-// the time being to not make "configure" scripts think we do support them.
+/* TODO: Support this structure, or more precisely the SA_SIGINFO flag. To do
+ * this properly we need real-time signal support. Both are commented out for
+ * the time being to not make "configure" scripts think we do support them. */
 #if 0
 typedef struct {
 	int		si_signo;	/* signal number */
@@ -61,7 +61,7 @@
 #define SA_NODEFER		0x08
 #define SA_RESTART		0x10
 #define SA_ONSTACK		0x20
-//#define SA_SIGINFO		0x40
+/* #define SA_SIGINFO		0x40 */
 #define SA_NOMASK		SA_NODEFER
 #define SA_STACK		SA_ONSTACK
 #define SA_ONESHOT		SA_RESETHAND
@@ -248,7 +248,7 @@
 
 typedef struct vregs vregs;
 
-// include architecture specific definitions
+/* include architecture specific definitions */
 #ifdef __INTEL__
         #include 
 #elif __POWERPC__

Modified: haiku/trunk/headers/posix/size_t.h
===================================================================
--- haiku/trunk/headers/posix/size_t.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/size_t.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -7,7 +7,7 @@
 
 #include 
 
-// TODO: ATM gcc's stddef.h defines ssize_t for BeOS.h. We should fix this.
-//typedef long signed int		ssize_t;
+/* TODO: ATM gcc's stddef.h defines ssize_t for BeOS.h. We should fix this.
+ * typedef long signed int		ssize_t; */
 
 #endif /* _SIZE_T_H_ */

Modified: haiku/trunk/headers/posix/stdint.h
===================================================================
--- haiku/trunk/headers/posix/stdint.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/stdint.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -131,7 +131,7 @@
 
 #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
 
-// Macros of Integer Constant Expressions
+/* Macros of Integer Constant Expressions */
 #define INT8_C(value) 	value
 #define INT16_C(value) 	value
 #define INT32_C(value) 	value
@@ -142,7 +142,7 @@
 #define UINT32_C(value) value ## U
 #define UINT64_C(value) value ## ULL
 
-// Macros for greatest-width integer constant expressions
+/* Macros for greatest-width integer constant expressions */
 #define INTMAX_C(value) 	value ## LL
 #define UINTMAX_C(value) 	value ## ULL
 

Modified: haiku/trunk/headers/posix/stdio.h
===================================================================
--- haiku/trunk/headers/posix/stdio.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/stdio.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -10,8 +10,8 @@
 #include 
 
 
-// Dodge gcc 2.95.3's fixincludes hack stdio_va_list by including this string:
-// __gnuc_va_list
+/* Dodge gcc 2.95.3's fixincludes hack stdio_va_list by including this string:
+ * __gnuc_va_list */
 
 
 #define BUFSIZ			1024

Modified: haiku/trunk/headers/posix/stdio_post.h
===================================================================
--- haiku/trunk/headers/posix/stdio_post.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/stdio_post.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -4,11 +4,11 @@
 #ifndef _STDIO_POST_H_
 #define _STDIO_POST_H_
 
-// "Private"/inline functions of our BeOS compatible stdio implementation
+/* "Private"/inline functions of our BeOS compatible stdio implementation */
 
-// ToDo: this is a work in progress to make our stdio
-//		BeOS' GNU/libio (almost) binary compatible
-//		We may not yet be compatible!
+/* ToDo: this is a work in progress to make our stdio
+ *		BeOS' GNU/libio (almost) binary compatible
+ *		We may not yet be compatible! */
 
 #ifndef _STDIO_H_
 #	error "This file must be included from stdio.h!"
@@ -19,9 +19,9 @@
 #endif
 
 extern char _single_threaded;
-	// this boolean value is true (1) if there is only the main thread
-	// running - as soon as you spawn the first thread, it's set to
-	// false (0)
+	/* this boolean value is true (1) if there is only the main thread
+	 * running - as soon as you spawn the first thread, it's set to
+	 * false (0) */
 
 #ifdef __cplusplus
 }

Modified: haiku/trunk/headers/posix/string.h
===================================================================
--- haiku/trunk/headers/posix/string.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/string.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -37,7 +37,7 @@
 extern char		*strstr(const char *string, const char *searchString);
 
 extern char		*strchrnul(const char *string, int character);
-	// this is a GNU extension
+	/* this is a GNU extension */
 
 extern char		*strpbrk(const char *string, const char *set);
 extern char		*strtok(char *string, const char *set);
@@ -66,10 +66,10 @@
 
 extern size_t	strnlen(const char *string, size_t count);
 
-//extern char		*strlwr(char *string);
-//extern char		*strupr(char *string);
+/* extern char		*strlwr(char *string); */
+/* extern char		*strupr(char *string); */
 
-//extern char		*strsep(char **stringPointer, const char *delimiter);
+/* extern char		*strsep(char **stringPointer, const char *delimiter); */
 
 extern const char	*strsignal(int signal);
 

Modified: haiku/trunk/headers/posix/sys/mman.h
===================================================================
--- haiku/trunk/headers/posix/sys/mman.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/sys/mman.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -9,20 +9,20 @@
 #include 
 
 
-// memory protection for mmap() and others
+/* memory protection for mmap() and others */
 #define PROT_READ		0x01
 #define PROT_WRITE		0x02
 #define PROT_EXEC		0x04
 #define PROT_NONE		0x00
 
-// mmap() flags
+/* mmap() flags */
 #define MAP_SHARED		0x01			/* changes are seen by others */
 #define MAP_PRIVATE		0x02			/* changes are only seen by caller */
 #define MAP_FIXED		0x04			/* require mapping to specified addr */
 #define MAP_ANONYMOUS	0x08			/* no underlying object */
 #define MAP_ANON		MAP_ANONYMOUS
 
-// mmap() error return code
+/* mmap() error return code */
 #define MAP_FAILED		((void*)-1)
 
 
@@ -38,4 +38,4 @@
 __END_DECLS
 
 
-#endif	// _SYS_MMAN_H
+#endif	/* _SYS_MMAN_H */

Modified: haiku/trunk/headers/posix/sys/poll.h
===================================================================
--- haiku/trunk/headers/posix/sys/poll.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/sys/poll.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -7,7 +7,7 @@
 
 
 #include 
-	// for compatibility with legacy applications
+	/* for compatibility with legacy applications */
 
 
 #endif	/* _SYS_POLL_H */

Modified: haiku/trunk/headers/posix/sys/resource.h
===================================================================
--- haiku/trunk/headers/posix/sys/resource.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/sys/resource.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -17,7 +17,7 @@
 	rlim_t	rlim_max;		/* hard limit */
 };
 
-// ToDo: the only supported mode is RLIMIT_NOFILE right now
+/* ToDo: the only supported mode is RLIMIT_NOFILE right now */
 #define RLIMIT_CORE		0	/* size of the core file */
 #define RLIMIT_CPU		1	/* CPU time per team */
 #define	RLIMIT_DATA		2	/* data segment size */
@@ -62,9 +62,9 @@
 extern int getrlimit(int resource, struct rlimit * rlp);
 extern int setrlimit(int resource, const struct rlimit * rlp);
 
-// ToDo: The following POSIX calls are missing (in BeOS as well):
-//int getpriority(int which, id_t who);
-//int setpriority(int which, id_t who, int priority);
+/* ToDo: The following POSIX calls are missing (in BeOS as well):
+ * int getpriority(int which, id_t who);
+ * int setpriority(int which, id_t who, int priority); */
 
 #ifdef __cplusplus
 }

Modified: haiku/trunk/headers/posix/sys/stat.h
===================================================================
--- haiku/trunk/headers/posix/sys/stat.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/sys/stat.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -24,10 +24,10 @@
 	time_t			st_ctime;		/* last change time, not creation time */
 	time_t			st_crtime;		/* creation time */
 
-	// Haiku extensions:
-	// TODO: we might also define special types for files and TTYs
-	// TODO: we should find another solution for this, as BStatable::GetStat()
-	//		can only retrieve the R5 stat structure
+	/* Haiku extensions:
+	 * TODO: we might also define special types for files and TTYs
+	 * TODO: we should find another solution for this, as BStatable::GetStat()
+	 *		can only retrieve the R5 stat structure */
 	unsigned int	st_type;		/* attribute/index type */
 };
 
@@ -110,13 +110,13 @@
 extern int    mkfifo(const char *path, mode_t mode);
 extern mode_t umask(mode_t cmask);
 
-// This achieves backwards compatibility with R5
-#if 0 //def HAIKU_TARGET_PLATFORM_HAIKU
+/* This achieves backwards compatibility with R5 */
+#if 0 /* def HAIKU_TARGET_PLATFORM_HAIKU */
 #define stat(fd, st) _stat(fd, st, sizeof(struct stat))
 #define fstat(fd, st) _fstat(fd, st, sizeof(struct stat))
 #define lstat(fd, st) _lstat(fd, st, sizeof(struct stat))
 #else
-// ... and this fixes the build for R5 for now
+/* ... and this fixes the build for R5 for now */
 extern int    stat(const char *path, struct stat *st);
 extern int    fstat(int fd, struct stat *st);
 extern int    lstat(const char *path, struct stat *st);

Modified: haiku/trunk/headers/posix/sys/wait.h
===================================================================
--- haiku/trunk/headers/posix/sys/wait.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/sys/wait.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -27,8 +27,8 @@
 #define WIFCORED(value)		((value) & 0x10000)
 #define WIFCONTINUED(value)	((value) & 0x20000)
 
-// TODO: waitid() is part of the real-time signal extension. Uncomment when
-// implemented!
+/* TODO: waitid() is part of the real-time signal extension. Uncomment when
+ * implemented! */
 #if 0
 /* ID types for waitid() */
 typedef enum {
@@ -36,7 +36,7 @@
 	P_PID,		/* wait for the child whose process ID matches */
 	P_PGID		/* wait for any child whose process group ID matches */
 } idtype_t;
-#endif	// 0
+#endif	/* 0 */
 
 
 #ifdef __cplusplus
@@ -45,7 +45,7 @@
 
 extern pid_t wait(int *_status);
 extern pid_t waitpid(pid_t pid, int *_status, int options);
-//extern int waitid(idtype_t idType, id_t id, siginfo_t *info, int options);
+/* extern int waitid(idtype_t idType, id_t id, siginfo_t *info, int options); */
 
 #ifdef __cplusplus
 }

Modified: haiku/trunk/headers/posix/unistd.h
===================================================================
--- haiku/trunk/headers/posix/unistd.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/unistd.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -208,7 +208,7 @@
 extern char *optarg;
 extern int optind, opterr, optopt;
 
-// ToDo: should be moved to stdlib.h
+/* ToDo: should be moved to stdlib.h */
 extern char **environ;
 
 #ifdef __cplusplus

Modified: haiku/trunk/headers/posix/wchar.h
===================================================================
--- haiku/trunk/headers/posix/wchar.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/wchar.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -10,8 +10,8 @@
 #include 
 #include 
 
-// stddef.h is not supposed to define wint_t, but gcc 2.95.3's one does.
-// In all other cases we will do that.
+/* stddef.h is not supposed to define wint_t, but gcc 2.95.3's one does.
+ * In all other cases we will do that. */
 #ifndef _WINT_T
 #define _WINT_T
 
@@ -21,7 +21,7 @@
 
 typedef __WINT_TYPE__ wint_t;
 
-#endif	// _WINT_T
+#endif	/* _WINT_T */
 
 typedef int wctype_t;
 

Modified: haiku/trunk/headers/posix/wchar_t.h
===================================================================
--- haiku/trunk/headers/posix/wchar_t.h	2008-05-10 21:09:44 UTC (rev 25432)
+++ haiku/trunk/headers/posix/wchar_t.h	2008-05-10 21:30:34 UTC (rev 25433)
@@ -3,5 +3,5 @@
  * Distributed under the terms of the MIT License.
  */
 
-// Include GCC's stddef.h. It defines wchar_t.
+/* Include GCC's stddef.h. It defines wchar_t. */
 #include 



From bonefish at mail.berlios.de  Sat May 10 23:34:51 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 23:34:51 +0200
Subject: [Haiku-commits] r25434 - in haiku/trunk: headers/os/kernel
	src/system/kernel
Message-ID: <200805102134.m4ALYpEU017492@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 23:34:51 +0200 (Sat, 10 May 2008)
New Revision: 25434
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25434&view=rev

Modified:
   haiku/trunk/headers/os/kernel/OS.h
   haiku/trunk/src/system/kernel/thread.cpp
Log:
Added timeout constant B_ABSOLUTE_REAL_TIME_TIMEOUT which specifies a
timeout relative to the Epoch.


Modified: haiku/trunk/headers/os/kernel/OS.h
===================================================================
--- haiku/trunk/headers/os/kernel/OS.h	2008-05-10 21:30:34 UTC (rev 25433)
+++ haiku/trunk/headers/os/kernel/OS.h	2008-05-10 21:34:51 UTC (rev 25434)
@@ -25,9 +25,16 @@
 #define B_INFINITE_TIMEOUT	(9223372036854775807LL)
 
 enum {
-	B_TIMEOUT			= 8,	/* relative timeout */
-	B_RELATIVE_TIMEOUT	= 8,	/* fails after a relative timeout with B_WOULD_BLOCK */
-	B_ABSOLUTE_TIMEOUT	= 16	/* fails after an absolute timeout with B_WOULD BLOCK */
+	B_TIMEOUT						= 0x8,	/* relative timeout */
+	B_RELATIVE_TIMEOUT				= 0x8,	/* fails after a relative timeout
+												with B_TIMED_OUT */
+	B_ABSOLUTE_TIMEOUT				= 0x10,	/* fails after an absolute timeout
+												with B_TIMED_OUT */
+
+	/* experimental Haiku only API */
+	B_TIMEOUT_REAL_TIME_BASE		= 0x40,
+	B_ABSOLUTE_REAL_TIME_TIMEOUT	= B_ABSOLUTE_TIMEOUT
+										| B_TIMEOUT_REAL_TIME_BASE
 };
 
 /*-------------------------------------------------------------*/

Modified: haiku/trunk/src/system/kernel/thread.cpp
===================================================================
--- haiku/trunk/src/system/kernel/thread.cpp	2008-05-10 21:30:34 UTC (rev 25433)
+++ haiku/trunk/src/system/kernel/thread.cpp	2008-05-10 21:34:51 UTC (rev 25434)
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2271,8 +2272,14 @@
 		// avoids nasty race conditions and deadlock problems that could
 		// otherwise occur between our cancel_timer() and a concurrently
 		// executing thread_block_timeout().
-		uint32 timerFlags = (timeoutFlags & B_RELATIVE_TIMEOUT)
-			? B_ONE_SHOT_RELATIVE_TIMER : B_ONE_SHOT_ABSOLUTE_TIMER;
+		uint32 timerFlags;
+		if ((timeoutFlags & B_RELATIVE_TIMEOUT) != 0) {
+			timerFlags = B_ONE_SHOT_RELATIVE_TIMER;
+		} else {
+			timerFlags = B_ONE_SHOT_ABSOLUTE_TIMER;
+			if ((timeoutFlags & B_TIMEOUT_REAL_TIME_BASE) != 0)
+				timeout -= rtc_boot_time();
+		}
 		timerFlags |= B_TIMER_ACQUIRE_THREAD_LOCK;
 
 		// install the timer



From bonefish at mail.berlios.de  Sat May 10 23:44:03 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 23:44:03 +0200
Subject: [Haiku-commits] r25435 - in haiku/trunk/src/system: kernel/posix
	libroot/posix/pthread
Message-ID: <200805102144.m4ALi3ab018171@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 23:44:03 +0200 (Sat, 10 May 2008)
New Revision: 25435
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25435&view=rev

Modified:
   haiku/trunk/src/system/kernel/posix/realtime_sem.cpp
   haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c
   haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c
Log:
Use the new B_ABSOLUTE_REAL_TIME_TIMEOUT. Fixes pthread_cond_timedwait()
and pthread_mutex_timedlock() which were waiting system time relative
although their timeout parameter is Epoch relative.


Modified: haiku/trunk/src/system/kernel/posix/realtime_sem.cpp
===================================================================
--- haiku/trunk/src/system/kernel/posix/realtime_sem.cpp	2008-05-10 21:34:51 UTC (rev 25434)
+++ haiku/trunk/src/system/kernel/posix/realtime_sem.cpp	2008-05-10 21:44:03 UTC (rev 25435)
@@ -15,7 +15,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -740,9 +739,8 @@
 		} else if (timeout == B_INFINITE_TIMEOUT) {
 			error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT, 0);
 		} else {
-			error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT,
-				timeout - rtc_boot_time());
-					// The given absolute timeout is relative to the Epoch.
+			error = acquire_sem_etc(id, 1,
+				B_CAN_INTERRUPT | B_ABSOLUTE_REAL_TIME_TIMEOUT, timeout);
 		}
 
 		return error == B_BAD_SEM_ID ? B_BAD_VALUE : error;

Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c
===================================================================
--- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c	2008-05-10 21:34:51 UTC (rev 25434)
+++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c	2008-05-10 21:44:03 UTC (rev 25435)
@@ -108,7 +108,8 @@
 
 	do {
 		status = acquire_sem_etc(cond->sem, 1,
-			timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout);
+			timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_REAL_TIME_TIMEOUT,
+			timeout);
 	} while (status == B_OK && atomic_get(&cond->event_counter) == event);
 
 	pthread_mutex_lock(_mutex);

Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c
===================================================================
--- haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c	2008-05-10 21:34:51 UTC (rev 25434)
+++ haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c	2008-05-10 21:44:03 UTC (rev 25435)
@@ -147,7 +147,9 @@
 	if (!mutex->attr.process_shared || atomic_add(&mutex->count, 1) > 0) {
 		// this mutex is already locked by someone else, so we need
 		// to wait
-		status = acquire_sem_etc(mutex->sem, 1, timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout);
+		status = acquire_sem_etc(mutex->sem, 1,
+			timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_REAL_TIME_TIMEOUT,
+			timeout);
 	}
 
 	if (status == B_OK) {



From bonefish at mail.berlios.de  Sat May 10 23:52:44 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sat, 10 May 2008 23:52:44 +0200
Subject: [Haiku-commits] r25436 - haiku/trunk/src/apps/aboutsystem
Message-ID: <200805102152.m4ALqiSf018605@sheep.berlios.de>

Author: bonefish
Date: 2008-05-10 23:52:44 +0200 (Sat, 10 May 2008)
New Revision: 25436
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25436&view=rev

Modified:
   haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp
Log:
Typo, spotted by Andreas Faerber.


Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp
===================================================================
--- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp	2008-05-10 21:44:03 UTC (rev 25435)
+++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp	2008-05-10 21:52:44 UTC (rev 25436)
@@ -516,7 +516,7 @@
 		"released under the GPL and LGPL licences:\n"
 		"GNU C Library, "
 		"GNU coretools, diffutils, findutils, "
-		"shareutils, gawk, bison, m4, make, "
+		"sharutils, gawk, bison, m4, make, "
 		"gdb, wget, ncurses, termcap, "
 		"Bourne Again Shell.\n"
 		"Copyright " B_UTF8_COPYRIGHT " The Free Software Foundation.",



From bonefish at mail.berlios.de  Sun May 11 00:21:53 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sun, 11 May 2008 00:21:53 +0200
Subject: [Haiku-commits] r25437 - haiku/trunk/src/system/runtime_loader
Message-ID: <200805102221.m4AMLrnl020373@sheep.berlios.de>

Author: bonefish
Date: 2008-05-11 00:21:52 +0200 (Sun, 11 May 2008)
New Revision: 25437
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25437&view=rev

Modified:
   haiku/trunk/src/system/runtime_loader/elf.cpp
Log:
Changed FATAL macro to always dprintf() the error. Additionally it still
prints to stdout, but only until the program and its dependencies are
loaded. Failed attempts to load add-ons and the like doesn't pollute
stdout anymore.


Modified: haiku/trunk/src/system/runtime_loader/elf.cpp
===================================================================
--- haiku/trunk/src/system/runtime_loader/elf.cpp	2008-05-10 21:52:44 UTC (rev 25436)
+++ haiku/trunk/src/system/runtime_loader/elf.cpp	2008-05-10 22:21:52 UTC (rev 25437)
@@ -82,6 +82,7 @@
 static uint32 sLoadedImageCount = 0;
 static image_t *sProgramImage;
 static KMessage sErrorMessage;
+static bool sProgramLoaded = false;
 
 // a recursive lock
 static sem_id rld_sem;
@@ -89,9 +90,6 @@
 static int32 rld_sem_count;
 
 
-#ifdef TRACE_RLD
-#	define FATAL(x...) dprintf("runtime_loader: " x);
-
 void
 dprintf(const char *format, ...)
 {
@@ -105,11 +103,15 @@
 
 	va_end(list);
 }
-#else
-#	define FATAL(x...) printf("runtime_loader: " x);
-#endif
 
+#define FATAL(x...)							\
+	do {									\
+		dprintf("runtime_loader: " x);		\
+		if (!sProgramLoaded)				\
+			printf("runtime_loader: " x);	\
+	} while (false)
 
+
 /*!	Mini atoi(), so we don't have to include the libroot dependencies.
  */
 int
@@ -1607,6 +1609,8 @@
 
 	rld_unlock();
 
+	sProgramLoaded = true;
+
 	KTRACE("rld: load_program(\"%s\") done: entry: %p, id: %ld", path,
 		*_entry, sProgramImage->id);
 



From bonefish at mail.berlios.de  Sun May 11 00:22:09 2008
From: bonefish at mail.berlios.de (bonefish at BerliOS)
Date: Sun, 11 May 2008 00:22:09 +0200
Subject: [Haiku-commits] r25438 - haiku/trunk/src/system/runtime_loader
Message-ID: <200805102222.m4AMM97I020413@sheep.berlios.de>

Author: bonefish
Date: 2008-05-11 00:22:08 +0200 (Sun, 11 May 2008)
New Revision: 25438
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25438&view=rev

Modified:
   haiku/trunk/src/system/runtime_loader/runtime_loader.c
Log:
Fixed warning.


Modified: haiku/trunk/src/system/runtime_loader/runtime_loader.c
===================================================================
--- haiku/trunk/src/system/runtime_loader/runtime_loader.c	2008-05-10 22:21:52 UTC (rev 25437)
+++ haiku/trunk/src/system/runtime_loader/runtime_loader.c	2008-05-10 22:22:08 UTC (rev 25438)
@@ -326,7 +326,7 @@
 		}
 	} else if (status == B_OK) {
 		struct Elf32_Ehdr *elfHeader = (struct Elf32_Ehdr *)buffer;
-		if (elfHeader->e_entry == NULL) {
+		if (elfHeader->e_entry == 0) {
 			// we don't like to open shared libraries
 			status = B_NOT_AN_EXECUTABLE;
 		} else if (invoker)



From mmlr at mail.berlios.de  Sun May 11 01:50:43 2008
From: mmlr at mail.berlios.de (mmlr at BerliOS)
Date: Sun, 11 May 2008 01:50:43 +0200
Subject: [Haiku-commits] r25439 - in
	haiku/trunk/src/add-ons/kernel/drivers/network: . usb_ecm
Message-ID: <200805102350.m4ANohSS021576@sheep.berlios.de>

Author: mmlr
Date: 2008-05-11 01:50:41 +0200 (Sun, 11 May 2008)
New Revision: 25439
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25439&view=rev

Added:
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/BeOSCompatibility.h
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Jamfile
   haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/kernel_cpp.h
Modified:
   haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile
Log:
Adding USB ECM (Ethernet Control Model) driver. This driver should support
devices of the CDC class (2 - communication) with ECM subclass (6) interfaces.
This type of device can be for example a USB to ethernet adapter or current
UMTS cell phones that support the Wireless Mobile Communications Devices (WMC)
standard.
Note that there is also another, similar, thing called EEM (Ethernet Emulation
Model) which we want to support too and is why I called this driver "usb_ecm"
instead of just "usb_network".
This driver was written in less than half a day and while it works nicely with
my Sony Ericsson K850i (comitting over this very device/driver), it does not
yet contain features like link state reporting and multicast and may obviously
contain a few bugs.

Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile	2008-05-10 23:50:41 UTC (rev 25439)
@@ -7,6 +7,7 @@
 SubInclude HAIKU_TOP src add-ons kernel drivers network rtl8139 ;
 SubInclude HAIKU_TOP src add-ons kernel drivers network rtl8169 ;
 SubInclude HAIKU_TOP src add-ons kernel drivers network sis900 ;
+SubInclude HAIKU_TOP src add-ons kernel drivers network usb_ecm ;
 SubInclude HAIKU_TOP src add-ons kernel drivers network via_rhine ;
 SubInclude HAIKU_TOP src add-ons kernel drivers network vlance ;
 SubInclude HAIKU_TOP src add-ons kernel drivers network wb840 ;

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/BeOSCompatibility.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/BeOSCompatibility.h	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/BeOSCompatibility.h	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,59 @@
+/*
+	Driver for USB Ethernet Control Model devices
+	Copyright (C) 2008 Michael Lotz 
+	Distributed under the terms of the MIT license.
+*/
+#ifndef HAIKU_TARGET_PLATFORM_HAIKU
+#ifndef _BEOS_COMPATIBILITY_H_
+#define _BEOS_COMPATIBILITY_H_
+
+#include 
+
+#define USB_ENDPOINT_ATTR_CONTROL		0x00
+#define USB_ENDPOINT_ATTR_ISOCHRONOUS	0x01
+#define USB_ENDPOINT_ATTR_BULK			0x02 
+#define USB_ENDPOINT_ATTR_INTERRUPT		0x03 
+#define USB_ENDPOINT_ATTR_MASK			0x03 
+
+#define USB_ENDPOINT_ADDR_DIR_IN	 	0x80
+#define USB_ENDPOINT_ADDR_DIR_OUT		0x00
+
+typedef struct mutex {
+	sem_id	sem;
+	int32	count;
+} mutex;
+
+
+static inline void
+mutex_init(mutex *lock, const char *name)
+{
+	lock->sem = create_sem(0, name);
+	lock->count = 0;
+}
+
+
+static inline void
+mutex_destroy(mutex *lock)
+{
+	delete_sem(lock->sem);
+}
+
+
+static inline status_t
+mutex_lock(mutex *lock)
+{
+	if (atomic_add(&lock->count, -1) < 0)
+		return acquire_sem(lock->sem);
+	return B_OK;
+}
+
+
+static inline void
+mutex_unlock(mutex *lock)
+{
+	if (atomic_add(&lock->count, 1) < -1)
+		release_sem(lock->sem);
+}
+
+#endif /* !HAIKU_TARGET_PLATFORM_HAIKU */
+#endif /* _BEOS_COMPATIBILITY_H_ */

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,273 @@
+/*
+	Driver for USB Ethernet Control Model devices
+	Copyright (C) 2008 Michael Lotz 
+	Distributed under the terms of the MIT license.
+*/
+#include 
+#include 
+#include 
+
+#ifdef HAIKU_TARGET_PLATFORM_HAIKU
+#include  // for mutex
+#else
+#include "BeOSCompatibility.h" // for pseudo mutex
+#endif
+
+#include "Driver.h"
+#include "ECMDevice.h"
+
+static const char *sDeviceBaseName = "net/usb_ecm/";
+ECMDevice *gECMDevices[MAX_DEVICES];
+char *gDeviceNames[MAX_DEVICES + 1];
+usb_module_info *gUSBModule = NULL;
+mutex gDriverLock;
+
+
+status_t
+usb_ecm_device_added(usb_device device, void **cookie)
+{
+	*cookie = NULL;
+
+	ECMDevice *ecmDevice = new ECMDevice(device);
+	status_t status = ecmDevice->InitCheck();
+	if (status < B_OK) {
+		delete ecmDevice;
+		return status;
+	}
+
+	mutex_lock(&gDriverLock);
+	for (int32 i = 0; i < MAX_DEVICES; i++) {
+		if (gECMDevices[i] != NULL)
+			continue;
+
+		gECMDevices[i] = ecmDevice;
+		*cookie = ecmDevice;
+
+		TRACE_ALWAYS("ecm device %ld added\n", i);
+		mutex_unlock(&gDriverLock);
+		return B_OK;
+	}
+
+	// no space for the device
+	delete ecmDevice;
+	mutex_unlock(&gDriverLock);
+	return B_ERROR;
+}
+
+
+status_t
+usb_ecm_device_removed(void *cookie)
+{
+	mutex_lock(&gDriverLock);
+
+	ECMDevice *device = (ECMDevice *)cookie;
+	for (int32 i = 0; i < MAX_DEVICES; i++) {
+		if (gECMDevices[i] == device) {
+			if (device->IsOpen()) {
+				// the device will be deleted upon being freed
+				device->Removed();
+			} else {
+				gECMDevices[i] = NULL;
+				delete device;
+			}
+			break;
+		}
+	}
+
+	mutex_unlock(&gDriverLock);
+	return B_OK;
+}
+
+
+//#pragma mark -
+
+
+status_t
+init_hardware()
+{
+	TRACE("init_hardware()\n");
+	return B_OK;
+}
+
+
+status_t
+init_driver()
+{
+	TRACE("init_driver()\n");
+	status_t status = get_module(B_USB_MODULE_NAME,
+		(module_info **)&gUSBModule);
+	if (status < B_OK)
+		return status;
+
+	for (int32 i = 0; i < MAX_DEVICES; i++)
+		gECMDevices[i] = NULL;
+
+	gDeviceNames[0] = NULL;
+	mutex_init(&gDriverLock, DRIVER_NAME"_devices");
+
+	static usb_notify_hooks notifyHooks = {
+		&usb_ecm_device_added,
+		&usb_ecm_device_removed
+	};
+
+	static usb_support_descriptor supportDescriptor = {
+		USB_INTERFACE_CLASS_CDC, /* CDC - Communication Device Class */
+		USB_INTERFACE_SUBCLASS_ECM, /* ECM - Ethernet Control Model */
+		0, 0, 0 /* no protocol, vendor or device */
+	};
+
+	gUSBModule->register_driver(DRIVER_NAME, &supportDescriptor, 1, NULL);
+	gUSBModule->install_notify(DRIVER_NAME, ¬ifyHooks);
+	return B_OK;
+}
+
+
+void
+uninit_driver()
+{
+	TRACE("uninit_driver()\n");
+	gUSBModule->uninstall_notify(DRIVER_NAME);
+	mutex_lock(&gDriverLock);
+
+	for (int32 i = 0; i < MAX_DEVICES; i++) {
+		if (gECMDevices[i]) {
+			delete gECMDevices[i];
+			gECMDevices[i] = NULL;
+		}
+	}
+
+	for (int32 i = 0; gDeviceNames[i]; i++) {
+		free(gDeviceNames[i]);
+		gDeviceNames[i] = NULL;
+	}
+
+	mutex_destroy(&gDriverLock);
+	put_module(B_USB_MODULE_NAME);
+}
+
+
+static status_t
+usb_ecm_open(const char *name, uint32 flags, void **cookie)
+{
+	TRACE("open(%s, %lu, %p)\n", name, flags, cookie);
+	mutex_lock(&gDriverLock);
+
+	*cookie = NULL;
+	status_t status = ENODEV;
+	int32 index = strtol(name + strlen(sDeviceBaseName), NULL, 10);
+	if (index >= 0 && index < MAX_DEVICES && gECMDevices[index]) {
+		status = gECMDevices[index]->Open(flags);
+		*cookie = gECMDevices[index];
+	}
+
+	mutex_unlock(&gDriverLock);
+	return status;
+}
+
+
+static status_t
+usb_ecm_read(void *cookie, off_t position, void *buffer, size_t *numBytes)
+{
+	TRACE("read(%p, %Ld, %p, %lu)\n", cookie, position, buffer, *numBytes);
+	ECMDevice *device = (ECMDevice *)cookie;
+	return device->Read((uint8 *)buffer, numBytes);
+}
+
+
+static status_t
+usb_ecm_write(void *cookie, off_t position, const void *buffer,
+	size_t *numBytes)
+{
+	TRACE("write(%p, %Ld, %p, %lu)\n", cookie, position, buffer, *numBytes);
+	ECMDevice *device = (ECMDevice *)cookie;
+	return device->Write((const uint8 *)buffer, numBytes);
+}
+
+
+static status_t
+usb_ecm_control(void *cookie, uint32 op, void *buffer, size_t length)
+{
+	TRACE("control(%p, %lu, %p, %lu)\n", cookie, op, buffer, length);
+	ECMDevice *device = (ECMDevice *)cookie;
+	return device->Control(op, buffer, length);
+}
+
+
+static status_t
+usb_ecm_close(void *cookie)
+{
+	TRACE("close(%p)\n", cookie);
+	ECMDevice *device = (ECMDevice *)cookie;
+	return device->Close();
+}
+
+
+static status_t
+usb_ecm_free(void *cookie)
+{
+	TRACE("free(%p)\n", cookie);
+	ECMDevice *device = (ECMDevice *)cookie;
+	mutex_lock(&gDriverLock);
+	status_t status = device->Free();
+	for (int32 i = 0; i < MAX_DEVICES; i++) {
+		if (gECMDevices[i] == device) {
+			// the device is removed already but as it was open the
+			// removed hook has not deleted the object
+			gECMDevices[i] = NULL;
+			delete device;
+			break;
+		}
+	}
+
+	mutex_unlock(&gDriverLock);
+	return status;
+}
+
+
+const char **
+publish_devices()
+{
+	TRACE("publish_devices()\n");
+	for (int32 i = 0; gDeviceNames[i]; i++) {
+		free(gDeviceNames[i]);
+		gDeviceNames[i] = NULL;
+	}
+
+	int32 deviceCount = 0;
+	mutex_lock(&gDriverLock);
+	for (int32 i = 0; i < MAX_DEVICES; i++) {
+		if (gECMDevices[i] == NULL)
+			continue;
+
+		gDeviceNames[deviceCount] = (char *)malloc(strlen(sDeviceBaseName) + 4);
+		if (gDeviceNames[deviceCount]) {
+			sprintf(gDeviceNames[deviceCount], "%s%ld", sDeviceBaseName, i);
+			TRACE("publishing %s\n", gDeviceNames[deviceCount]);
+			deviceCount++;
+		} else
+			TRACE_ALWAYS("publish_devices - no memory to allocate device name\n");
+	}
+
+	gDeviceNames[deviceCount] = NULL;
+	mutex_unlock(&gDriverLock);
+	return (const char **)&gDeviceNames[0];
+}
+
+
+device_hooks *
+find_device(const char *name)
+{
+	TRACE("find_device(%s)\n", name);
+	static device_hooks deviceHooks = {
+		usb_ecm_open,
+		usb_ecm_close,
+		usb_ecm_free,
+		usb_ecm_control,
+		usb_ecm_read,
+		usb_ecm_write,
+		NULL,				/* select */
+		NULL				/* deselect */
+	};
+
+	return &deviceHooks;
+}

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,61 @@
+/*
+	Driver for USB Ethernet Control Model devices
+	Copyright (C) 2008 Michael Lotz 
+	Distributed under the terms of the MIT license.
+*/
+#ifndef _USB_ECM_DRIVER_H_
+#define _USB_ECM_DRIVER_H_
+
+#include 
+#include 
+#include 
+#include 
+
+#include "kernel_cpp.h"
+
+#define DRIVER_NAME	"usb_ecm"
+#define MAX_DEVICES	8
+
+/* class and subclass codes */
+#define USB_INTERFACE_CLASS_CDC			0x02
+#define USB_INTERFACE_SUBCLASS_ECM		0x06
+#define USB_INTERFACE_CLASS_CDC_DATA	0x0a
+#define USB_INTERFACE_SUBCLASS_DATA		0x00
+
+/* communication device descriptor subtypes */
+#define FUNCTIONAL_SUBTYPE_UNION		0x06
+#define FUNCTIONAL_SUBTYPE_ETHERNET		0x0f
+
+typedef struct ethernet_functional_descriptor_s {
+	uint8	functional_descriptor_subtype;
+	uint8	mac_address_index;
+	uint32	ethernet_statistics;
+	uint16	max_segment_size;
+	uint16	num_multi_cast_filters;
+	uint8	num_wakeup_pattern_filters;
+} _PACKED ethernet_functional_descriptor;
+
+extern usb_module_info *gUSBModule;
+
+extern "C" {
+status_t	usb_ecm_device_added(usb_device device, void **cookie);
+status_t	usb_ecm_device_removed(void *cookie);
+
+status_t	init_hardware();
+void		uninit_driver();
+
+status_t	usb_ecm_open(const char *name, uint32 flags, void **cookie);
+status_t	usb_ecm_read(void *cookie, off_t position, void *buffer, size_t *numBytes);
+status_t	usb_ecm_write(void *cookie, off_t position, const void *buffer, size_t *numBytes);
+status_t	usb_ecm_control(void *cookie, uint32 op, void *buffer, size_t length);
+status_t	usb_ecm_close(void *cookie);
+status_t	usb_ecm_free(void *cookie);
+
+const char **publish_devices();
+device_hooks *find_device(const char *name);
+}
+
+#define	TRACE(x...)			/*dprintf(DRIVER_NAME ": " x)*/
+#define TRACE_ALWAYS(x...)	dprintf(DRIVER_NAME ": " x)
+
+#endif //_USB_ECM_DRIVER_H_

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,382 @@
+/*
+	Driver for USB Ethernet Control Model devices
+	Copyright (C) 2008 Michael Lotz 
+	Distributed under the terms of the MIT license.
+*/
+#include 
+#include 
+#include 
+
+#include "BeOSCompatibility.h"
+#include "ECMDevice.h"
+#include "Driver.h"
+
+ECMDevice::ECMDevice(usb_device device)
+	:	fStatus(B_ERROR),
+		fOpen(false),
+		fRemoved(false),
+		fDevice(device),
+		fControlInterfaceIndex(0),
+		fDataInterfaceIndex(0),
+		fMACAddressIndex(0),
+		fMaxSegmentSize(0),
+		fControlEndpoint(0),
+		fReadEndpoint(0),
+		fWriteEndpoint(0)
+{
+	const usb_device_descriptor *deviceDescriptor
+		= gUSBModule->get_device_descriptor(device);
+	const usb_configuration_info *config
+		= gUSBModule->get_nth_configuration(device, 0);
+
+	if (deviceDescriptor == NULL || config == NULL) {
+		TRACE_ALWAYS("failed to get basic device info\n");
+		return;
+	}
+
+	TRACE_ALWAYS("creating device: vendor: 0x%04x; device: 0x%04x\n",
+		deviceDescriptor->vendor_id, deviceDescriptor->product_id);
+
+	uint8 controlIndex = 0;
+	uint8 dataIndex = 0;
+	bool foundUnionDescriptor = false;
+	bool foundEthernetDescriptor = false;
+	for (size_t i = 0; i < config->interface_count
+		&& (!foundUnionDescriptor || !foundEthernetDescriptor); i++) {
+		usb_interface_info *interface = config->interface[i].active;
+		usb_interface_descriptor *descriptor = interface->descr;
+		if (descriptor->interface_class == USB_INTERFACE_CLASS_CDC
+			&& descriptor->interface_subclass == USB_INTERFACE_SUBCLASS_ECM
+			&& interface->generic_count > 0) {
+			// try to find and interpret the union and ethernet functional
+			// descriptors
+			for (size_t j = 0; j < interface->generic_count; j++) {
+				usb_generic_descriptor *generic = &interface->generic[j]->generic;
+				if (generic->length >= 5
+					&& generic->data[0] == FUNCTIONAL_SUBTYPE_UNION) {
+					controlIndex = generic->data[1];
+					dataIndex = generic->data[2];
+					foundUnionDescriptor = true;
+				} else if (generic->length >= sizeof(ethernet_functional_descriptor)
+					&& generic->data[0] == FUNCTIONAL_SUBTYPE_ETHERNET) {
+					ethernet_functional_descriptor *ethernet
+						= (ethernet_functional_descriptor *)generic->data;
+					fMACAddressIndex = ethernet->mac_address_index;
+					fMaxSegmentSize = ethernet->max_segment_size;
+					foundEthernetDescriptor = true;
+				}
+
+				if (foundUnionDescriptor && foundEthernetDescriptor)
+					break;
+			}
+		}
+	}
+
+	if (!foundUnionDescriptor) {
+		TRACE_ALWAYS("did not find a union descriptor\n");
+		return;
+	}
+
+	if (!foundEthernetDescriptor) {
+		TRACE_ALWAYS("did not find an ethernet descriptor\n");
+		return;
+	}
+
+	if (_ReadMACAddress() != B_OK) {
+		TRACE_ALWAYS("failed to read mac address\n");
+		return;
+	}
+
+	if (controlIndex >= config->interface_count) {
+		TRACE_ALWAYS("control interface index invalid\n");
+		return;
+	}
+
+	// check that the indicated control interface fits our needs
+	usb_interface_info *interface = config->interface[controlIndex].active;
+	usb_interface_descriptor *descriptor = interface->descr;
+	if ((descriptor->interface_class != USB_INTERFACE_CLASS_CDC
+		|| descriptor->interface_subclass != USB_INTERFACE_SUBCLASS_ECM)
+		|| interface->endpoint_count == 0) {
+		TRACE_ALWAYS("control interface invalid\n");
+		return;
+	}
+
+	fControlInterfaceIndex = controlIndex;
+	fControlEndpoint = interface->endpoint[0].handle;
+
+	if (dataIndex >= config->interface_count) {
+		TRACE_ALWAYS("data interface index invalid\n");
+		return;
+	}
+
+	// check that the indicated data interface fits our needs
+	if (config->interface[dataIndex].alt_count < 2) {
+		TRACE_ALWAYS("data interface does not provide two alternate interfaces\n");
+		return;
+	}
+
+	// alternate 0 is the disabled, endpoint-less default interface
+	interface = &config->interface[dataIndex].alt[1];
+	descriptor = interface->descr;
+	if (descriptor->interface_class != USB_INTERFACE_CLASS_CDC_DATA
+		|| interface->endpoint_count < 2) {
+		TRACE_ALWAYS("data interface invalid\n");
+		return;
+	}
+
+	fDataInterfaceIndex = dataIndex;
+	fNotifyRead = create_sem(0, DRIVER_NAME"_notify_read");
+	if (fNotifyRead < B_OK) {
+		TRACE_ALWAYS("failed to create read notify sem\n");
+		return;
+	}
+
+	fNotifyWrite = create_sem(0, DRIVER_NAME"_notify_write");
+	if (fNotifyWrite < B_OK) {
+		TRACE_ALWAYS("failed to create write notify sem\n");
+		delete_sem(fNotifyRead);
+		return;
+	}
+
+	fStatus = B_OK;
+}
+
+
+ECMDevice::~ECMDevice()
+{
+	delete_sem(fNotifyRead);
+	delete_sem(fNotifyWrite);
+}
+
+
+status_t
+ECMDevice::Open(uint32 flags)
+{
+	if (fOpen)
+		return B_BUSY;
+
+	// reset the device by switching the data interface to the disabled first
+	// interface and then enable it by setting the second actual data interface
+	const usb_configuration_info *config
+		= gUSBModule->get_nth_configuration(fDevice, 0);
+
+	gUSBModule->set_alt_interface(fDevice,
+		&config->interface[fDataInterfaceIndex].alt[0]);
+
+	// update to the changed config
+	config = gUSBModule->get_nth_configuration(fDevice, 0);
+	gUSBModule->set_alt_interface(fDevice,
+		&config->interface[fDataInterfaceIndex].alt[1]);
+
+	// update again
+	config = gUSBModule->get_nth_configuration(fDevice, 0);
+	usb_interface_info *interface = config->interface[fDataInterfaceIndex].active;
+	if (interface->endpoint_count < 2) {
+		TRACE_ALWAYS("setting the data alternate interface failed\n");
+		return B_ERROR;
+	}
+
+	if (!(interface->endpoint[0].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN))
+		fWriteEndpoint = interface->endpoint[0].handle;
+	else
+		fReadEndpoint = interface->endpoint[0].handle;
+
+	if (interface->endpoint[1].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
+		fReadEndpoint = interface->endpoint[1].handle;
+	else
+		fWriteEndpoint = interface->endpoint[1].handle;
+
+	if (fReadEndpoint == 0 || fWriteEndpoint == 0) {
+		TRACE_ALWAYS("no read and write endpoints found\n");
+		return B_ERROR;
+	}
+
+	// the device should now be ready
+	fOpen = true;
+	return B_OK;
+}
+
+
+status_t
+ECMDevice::Close()
+{
+	if (fRemoved) {
+		fOpen = false;
+		return B_OK;
+	}
+
+	gUSBModule->cancel_queued_transfers(fReadEndpoint);
+	gUSBModule->cancel_queued_transfers(fWriteEndpoint);
+
+	// put the device into non-connected mode again by switching the data
+	// interface to the disabled alternate
+	const usb_configuration_info *config
+		= gUSBModule->get_nth_configuration(fDevice, 0);
+
+	gUSBModule->set_alt_interface(fDevice,
+		&config->interface[fDataInterfaceIndex].alt[0]);
+
+	fOpen = false;
+	return B_OK;
+}
+
+
+status_t
+ECMDevice::Free()
+{
+	return B_OK;
+}
+
+
+status_t
+ECMDevice::Read(uint8 *buffer, size_t *numBytes)
+{
+	if (fRemoved) {
+		*numBytes = 0;
+		return B_ERROR;
+	}
+
+	status_t result = gUSBModule->queue_bulk(fReadEndpoint, buffer, *numBytes,
+		_ReadCallback, this);
+	if (result != B_OK) {
+		*numBytes = 0;
+		return result;
+	}
+
+	result = acquire_sem_etc(fNotifyRead, 1, B_CAN_INTERRUPT, 0);
+	if (result < B_OK) {
+		*numBytes = 0;
+		return result;
+	}
+
+	if (fStatusRead != B_OK) {
+		TRACE_ALWAYS("device status error 0x%08lx\n", fStatusRead);
+		result = gUSBModule->clear_feature(fReadEndpoint,
+			USB_FEATURE_ENDPOINT_HALT);
+		if (result != B_OK) {
+			TRACE_ALWAYS("failed to clear halt state\n");
+			*numBytes = 0;
+			return result;
+		}
+	}
+
+	*numBytes = fActualLengthRead;
+	return B_OK;
+}
+
+
+status_t
+ECMDevice::Write(const uint8 *buffer, size_t *numBytes)
+{
+	if (fRemoved) {
+		*numBytes = 0;
+		return B_ERROR;
+	}
+
+	status_t result = gUSBModule->queue_bulk(fWriteEndpoint, (uint8 *)buffer,
+		*numBytes, _WriteCallback, this);
+	if (result != B_OK) {
+		*numBytes = 0;
+		return result;
+	}
+
+	result = acquire_sem_etc(fNotifyWrite, 1, B_CAN_INTERRUPT, 0);
+	if (result < B_OK) {
+		*numBytes = 0;
+		return result;
+	}
+
+	if (fStatusWrite != B_OK) {
+		TRACE_ALWAYS("device status error 0x%08lx\n", fStatusWrite);
+		result = gUSBModule->clear_feature(fWriteEndpoint,
+			USB_FEATURE_ENDPOINT_HALT);
+		if (result != B_OK) {
+			TRACE_ALWAYS("failed to clear halt state\n");
+			*numBytes = 0;
+			return result;
+		}
+	}
+
+	*numBytes = fActualLengthWrite;
+	return B_OK;
+}
+
+
+status_t
+ECMDevice::Control(uint32 op, void *buffer, size_t length)
+{
+	switch (op) {
+		case ETHER_INIT:
+			return B_OK;
+
+		case ETHER_GETADDR:
+			memcpy(buffer, &fMACAddress, sizeof(fMACAddress));
+			return B_OK;
+
+		case ETHER_GETFRAMESIZE:
+			*(uint32 *)buffer = fMaxSegmentSize;
+			return B_OK;
+
+		default:
+			TRACE_ALWAYS("unsupported ioctl %lu\n", op);
+	}
+
+	return B_DEV_INVALID_IOCTL;
+}
+
+
+status_t
+ECMDevice::_ReadMACAddress()
+{
+	if (fMACAddressIndex == 0)
+		return B_BAD_VALUE;
+
+	size_t actualLength = 0;
+	size_t macStringLength = 26;
+	uint8 macString[macStringLength];
+	status_t result = gUSBModule->get_descriptor(fDevice, USB_DESCRIPTOR_STRING,
+		fMACAddressIndex, 0, macString, macStringLength, &actualLength);
+	if (result != B_OK)
+		return result;
+
+	if (actualLength != macStringLength) {
+		TRACE_ALWAYS("did not retrieve full mac address\n");
+		return B_ERROR;
+	}
+
+	char macPart[3];
+	macPart[2] = 0;
+	for (int32 i = 0; i < 6; i++) {
+		macPart[0] = macString[2 + i * 4 + 0];
+		macPart[1] = macString[2 + i * 4 + 2];
+		fMACAddress[i] = strtol(macPart, NULL, 16);
+	}
+
+	TRACE_ALWAYS("read mac address: %02x:%02x:%02x:%02x:%02x:%02x\n",
+		fMACAddress[0], fMACAddress[1], fMACAddress[2], fMACAddress[3],
+		fMACAddress[4], fMACAddress[5]);
+	return B_OK;
+}
+
+
+void
+ECMDevice::_ReadCallback(void *cookie, int32 status, void *data,
+	uint32 actualLength)
+{
+	ECMDevice *device = (ECMDevice *)cookie;
+	device->fActualLengthRead = actualLength;
+	device->fStatusRead = status;
+	release_sem_etc(device->fNotifyRead, 1, B_DO_NOT_RESCHEDULE);
+}
+
+
+void
+ECMDevice::_WriteCallback(void *cookie, int32 status, void *data,
+	uint32 actualLength)
+{
+	ECMDevice *device = (ECMDevice *)cookie;
+	device->fActualLengthWrite = actualLength;
+	device->fStatusWrite = status;
+	release_sem_etc(device->fNotifyWrite, 1, B_DO_NOT_RESCHEDULE);
+}

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,63 @@
+/*
+	Driver for USB Ethernet Control Model devices
+	Copyright (C) 2008 Michael Lotz 
+	Distributed under the terms of the MIT license.
+*/
+#ifndef _USB_ECM_DEVICE_H_
+#define _USB_ECM_DEVICE_H_
+
+#include "Driver.h"
+
+class ECMDevice {
+public:
+							ECMDevice(usb_device device);
+							~ECMDevice();
+
+		status_t			InitCheck() { return fStatus; };
+
+		status_t			Open(uint32 flags);
+		bool				IsOpen() { return fOpen; };
+
+		status_t			Close();
+		status_t			Free();
+
+		status_t			Read(uint8 *buffer, size_t *numBytes);
+		status_t			Write(const uint8 *buffer, size_t *numBytes);
+		status_t			Control(uint32 op, void *buffer, size_t length);
+
+		void				Removed() { fRemoved = true; };
+		bool				IsRemoved() { return fRemoved; };
+
+private:
+static	void				_ReadCallback(void *cookie, int32 status,
+								void *data, uint32 actualLength);
+static	void				_WriteCallback(void *cookie, int32 status,
+								void *data, uint32 actualLength);
+
+		status_t			_ReadMACAddress();
+
+		status_t			fStatus;
+		bool				fOpen;
+		bool				fRemoved;
+		usb_device			fDevice;
+
+		uint8				fMACAddress[6];
+
+		uint8				fControlInterfaceIndex;
+		uint8				fDataInterfaceIndex;
+		uint8				fMACAddressIndex;
+		uint16				fMaxSegmentSize;
+
+		usb_pipe			fControlEndpoint;
+		usb_pipe			fReadEndpoint;
+		usb_pipe			fWriteEndpoint;
+
+		uint32				fActualLengthRead;
+		uint32				fActualLengthWrite;
+		int32				fStatusRead;
+		int32				fStatusWrite;
+		sem_id				fNotifyRead;
+		sem_id				fNotifyWrite;
+};
+
+#endif //_USB_ECM_DEVICE_H_

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Jamfile
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Jamfile	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Jamfile	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,10 @@
+SubDir HAIKU_TOP src add-ons kernel drivers network usb_ecm ;
+
+SetSubDirSupportedPlatformsBeOSCompatible ;
+
+UsePrivateHeaders kernel net ;
+
+KernelAddon usb_ecm :
+	Driver.cpp
+	ECMDevice.cpp
+	;

Added: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/kernel_cpp.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/kernel_cpp.h	2008-05-10 22:22:08 UTC (rev 25438)
+++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/kernel_cpp.h	2008-05-10 23:50:41 UTC (rev 25439)
@@ -0,0 +1,45 @@
+#ifndef _KERNEL_CPP_H_
+#define _KERNEL_CPP_H_
+
+#include 
+
+inline void *
+operator new(size_t size)
+{
+	return malloc(size);
+}
+
+
+inline void *
+operator new[](size_t size)
+{
+	return malloc(size);
+}
+
+
+inline void
+operator delete(void *pointer)
+{
+	free(pointer);
+}
+
+
+inline void
+operator delete[](void *pointer)
+{
+	free(pointer);
+}
+
+
+inline void
+terminate(void)
+{
+}
+
+
+static inline void
+__throw()
+{
+}
+
+#endif // _KERNEL_CPP_H_



From mmu_man at mail.berlios.de  Sun May 11 02:02:27 2008
From: mmu_man at mail.berlios.de (mmu_man at BerliOS)
Date: Sun, 11 May 2008 02:02:27 +0200
Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch
Message-ID: <200805110002.m4B02RVw025334@sheep.berlios.de>

Author: mmu_man
Date: 2008-05-11 02:02:26 +0200 (Sun, 11 May 2008)
New Revision: 25440
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25440&view=rev

Added:
   haiku/trunk/src/apps/webwatch/
   haiku/trunk/src/apps/webwatch/WatchApp.cpp
   haiku/trunk/src/apps/webwatch/WatchApp.h
   haiku/trunk/src/apps/webwatch/WatchView.cpp
   haiku/trunk/src/apps/webwatch/WatchView.h
   haiku/trunk/src/apps/webwatch/WebWatch.rsrc
   haiku/trunk/src/apps/webwatch/makefile
   haiku/trunk/src/apps/webwatch/readme.html
Log:
Sources for Matthijs Hollemans' WebWatch app, I don't use it (anyone actually using @beats ?) but it's quite cute and could serve as nice sample code. And it's under MIT licence.
Oddly this is version 1.5 while bebits still has 1.4 :)


Added: haiku/trunk/src/apps/webwatch/WatchApp.cpp
===================================================================
--- haiku/trunk/src/apps/webwatch/WatchApp.cpp	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/WatchApp.cpp	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1999-2003 Matthijs Hollemans
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+
+#include "WatchApp.h"
+#include "WatchView.h"
+
+////////////////////////////////////////////////////////////////////////////////
+
+BView* instantiate_deskbar_item()
+{
+	return new WatchView;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+WatchApp::WatchApp() : BApplication(APP_SIGNATURE)
+{
+	// Here we tell the Deskbar that we want to add a new replicant, and
+	// where it can find this replicant (in our app). Because we only run
+	// less than a second, there is no need for our title to appear inside
+	// the Deskbar. Therefore, the application flags inside our resource
+	// file should be set to B_BACKGROUND_APP.
+
+	BDeskbar deskbar;
+	if (!deskbar.HasItem(DESKBAR_ITEM_NAME))
+	{
+		entry_ref ref;
+		be_roster->FindApp(APP_SIGNATURE, &ref);
+		deskbar.AddItem(&ref);
+	}
+	
+	PostMessage(B_QUIT_REQUESTED);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+int main() 
+{
+	WatchApp watchApp;
+	watchApp.Run();
+	return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////

Added: haiku/trunk/src/apps/webwatch/WatchApp.h
===================================================================
--- haiku/trunk/src/apps/webwatch/WatchApp.h	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/WatchApp.h	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1999-2003 Matthijs Hollemans
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef WATCHAPP_H
+#define WATCHAPP_H
+
+#include 
+
+#define VERSION "1.5"
+#define APP_SIGNATURE "application/x-vnd.mahlzeit.webwatch"
+#define DESKBAR_ITEM_NAME "WebWatch2"
+#define REPLICANT_CLASS "WatchView"
+
+class WatchApp : public BApplication 
+{
+public:
+	WatchApp();
+};
+
+extern "C" _EXPORT BView* instantiate_deskbar_item();
+
+#endif // WATCHAPP_H

Added: haiku/trunk/src/apps/webwatch/WatchView.cpp
===================================================================
--- haiku/trunk/src/apps/webwatch/WatchView.cpp	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/WatchView.cpp	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 1999-2003 Matthijs Hollemans
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "WatchApp.h"
+#include "WatchView.h"
+
+const rgb_color COLOR_FOREGROUND = { 0, 0, 0 };
+
+////////////////////////////////////////////////////////////////////////////////
+
+WatchView::WatchView()
+	: BView(BRect(0, 0, 1, 1), 0, 0, 0)
+{
+	// Do nothing.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+WatchView::WatchView(BMessage* message)
+	: BView(
+		BRect(0, 0, 15, 15), DESKBAR_ITEM_NAME, B_FOLLOW_NONE,
+		B_WILL_DRAW | B_PULSE_NEEDED) 
+{
+	oldTime = 0;
+
+	//SetFont(be_bold_font);
+	SetFont(be_plain_font);
+	
+	// Calculate the maximum width for our replicant. Note that the Deskbar
+	// accepts replicants that are wider than 16 pixels, but not replicants
+	// that are higher than 16 pixels.
+
+	float width = StringWidth("@999") + 4;
+	ResizeTo(width, 15);
+
+	SetViewColor(B_TRANSPARENT_COLOR);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+__declspec(dllexport) WatchView* WatchView::Instantiate(BMessage* archive)
+{
+	if (validate_instantiation(archive, REPLICANT_CLASS)) 
+	{
+		return new WatchView(archive);
+	}
+
+	return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+status_t WatchView::Archive(BMessage* archive, bool deep) const
+{
+	super::Archive(archive, deep);
+  
+	archive->AddString("add_on", APP_SIGNATURE);
+	archive->AddString("class", REPLICANT_CLASS);
+
+	return B_OK;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::Draw(BRect updateRect)
+{
+	super::Draw(updateRect);
+
+	char string[5];
+	sprintf(string, "@%03ld", GetInternetTime());
+	
+	font_height height;         // center the text horizontally
+	GetFontHeight(&height);     // and vertically in the Deskbar
+	BRect rect = Bounds();
+	float width = StringWidth(string);
+	float x = 1 + (rect.Width() - width)/2;
+	float y = height.ascent
+			    + (rect.Height() - (height.ascent + height.descent))/2;
+
+	SetHighColor(Parent()->ViewColor());
+	FillRect(updateRect);
+
+	SetLowColor(Parent()->ViewColor());
+	SetHighColor(COLOR_FOREGROUND);
+	SetDrawingMode(B_OP_OVER);
+	DrawString(string, BPoint(x, y));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::MouseDown(BPoint point) 
+{
+	BPopUpMenu* menu = new BPopUpMenu("WatchView", false, false);
+
+	menu->AddItem(new BMenuItem(
+		"About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED)));
+
+	menu->AddItem(new BMenuItem(
+		"Quit", new BMessage(B_QUIT_REQUESTED)));
+
+	menu->SetTargetForItems(this);
+
+	ConvertToScreen(&point); 
+	menu->Go(point, true, false, true); 
+
+	delete menu;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::MessageReceived(BMessage* msg)
+{
+	switch (msg->what) 
+	{
+		case B_ABOUT_REQUESTED: OnAboutRequested();          break;
+		case B_QUIT_REQUESTED:  OnQuitRequested();           break;
+		default:                super::MessageReceived(msg); break;
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::OnAboutRequested()
+{
+	(new BAlert(
+		NULL, 
+		"WebWatch " VERSION
+		"\nAn Internet Time clock for your Deskbar\n\n"
+		"Created by Matthijs Hollemans\n"
+		"mahlzeit at users.sourceforge.net\n\n"
+		"Thanks to Jason Parks for his help.\n",
+		"Okay"))->Go(NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::OnQuitRequested()
+{
+	// According to the Be Book, we are not allowed to do this
+	// since we're a view that's sitting on the Deskbar's shelf.
+	// But it works just fine for me, and I see no other way to
+	// make a Deskbar replicant quit itself.
+
+	BDeskbar deskbar;
+	deskbar.RemoveItem(DESKBAR_ITEM_NAME);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+void WatchView::Pulse()
+{
+	int32 currentTime = GetInternetTime();
+	if (oldTime != currentTime)
+	{
+		oldTime = currentTime;
+		Invalidate();
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+int32 WatchView::GetInternetTime()
+{
+	// First we get the current time as the number of seconds since
+	// 1 January 1970 GMT and add an hour's worth of seconds to adjust
+	// for the Biel Mean Time (BMT). Then we get the number of seconds
+	// that have passed today, and divide it with the length of a beat
+	// to get the number of elapsed beats.
+
+	return (int32) (((real_time_clock() + 3600) % 86400) / 86.4);
+}
+
+////////////////////////////////////////////////////////////////////////////////

Added: haiku/trunk/src/apps/webwatch/WatchView.h
===================================================================
--- haiku/trunk/src/apps/webwatch/WatchView.h	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/WatchView.h	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1999-2003 Matthijs Hollemans
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a 
+ * copy of this software and associated documentation files (the "Software"), 
+ * to deal in the Software without restriction, including without limitation 
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ * and/or sell copies of the Software, and to permit persons to whom the 
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in 
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef WATCHVIEW_H
+#define WATCHVIEW_H
+
+#include 
+
+class WatchView : public BView 
+{
+public:
+
+	// This constructor is used by the WatchApp class to install the
+	// WebWatch replicant into the Deskbar.
+	WatchView();
+
+	// This constructor is used to "rehydrate" the archived WatchView
+	// object after the Deskbar (or any other BShelf) has received it.
+	WatchView(BMessage* message);
+
+	// Called by the Deskbar's shelf after it has received the message
+	// that contains our replicant. (To enable the Deskbar to find this
+	// function, we export it from the executable.) 
+	static WatchView* Instantiate(BMessage* archive);
+
+	// Archives the data that we need in order to instantiate ourselves.
+	virtual status_t Archive(BMessage* archive, bool deep = true) const;
+
+	virtual void Draw(BRect updateRect);
+	virtual void MouseDown(BPoint point);
+	virtual void MessageReceived(BMessage* message);
+
+	// Periodically checks whether the Internet Time has changed, and tells
+	// the view to redraw itself. The time between these checks depends on
+	// the pulse rate of the Deskbar window. By default the pulse rate is 500
+	// milliseconds, which is fine for our purposes. Note that other Deskbar
+	// replicants could possibly change the pulse rate of the Deskbar window.
+	virtual void Pulse();
+
+private:
+
+	typedef BView super;
+
+	void OnAboutRequested();
+	void OnQuitRequested();
+
+	// Calculates the current Internet Time.
+	int32 GetInternetTime();
+	
+	// The Internet Time from the last call to Pulse().
+	int32 oldTime;
+};
+
+#endif // WATCHVIEW_H

Added: haiku/trunk/src/apps/webwatch/WebWatch.rsrc
===================================================================
(Binary files differ)


Property changes on: haiku/trunk/src/apps/webwatch/WebWatch.rsrc
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: haiku/trunk/src/apps/webwatch/makefile
===================================================================
--- haiku/trunk/src/apps/webwatch/makefile	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/makefile	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,24 @@
+# Makefile for WebWatch
+
+NAME= WebWatch
+TYPE= APP
+SRCS= WatchApp.cpp WatchView.cpp
+RSRCS= WebWatch.rsrc
+LIBS= be
+LIBPATHS= 
+SYSTEM_INCLUDE_PATHS = 
+LOCAL_INCLUDE_PATHS = 
+OPTIMIZE= FULL
+DEFINES= 
+WARNINGS = ALL
+SYMBOLS = FALSE
+DEBUGGER = FALSE
+COMPILER_FLAGS =
+LINKER_FLAGS =
+
+include /boot/develop/etc/makefile-engine
+
+release:
+	@strip $(OBJ_DIR)/$(NAME)
+	@xres -o $(OBJ_DIR)/$(NAME) $(RSRCS)
+	@mimeset -f $(OBJ_DIR)/$(NAME)

Added: haiku/trunk/src/apps/webwatch/readme.html
===================================================================
--- haiku/trunk/src/apps/webwatch/readme.html	2008-05-10 23:50:41 UTC (rev 25439)
+++ haiku/trunk/src/apps/webwatch/readme.html	2008-05-11 00:02:26 UTC (rev 25440)
@@ -0,0 +1,117 @@
+
+
+
+WebWatch
+
+
+
+
+

WebWatch 1.5

+ +

Released on Thursday, 13 February 2003
+Created by Matthijs +Hollemans

+ +

What is it

+ +

WebWatch is an unofficial port of Swatch's Internet Time utility for BeOS +R5 or higher that runs inside the Deskbar.

+ +

Someone at Swatch (you know, the company that makes the watches) came up +with an idea for a universal time format that eliminates time zones and +geographical borders. The idea is very simple: time is no longer measured in +hours, minutes, and seconds, but in "beats." A single day consists of 1000 +beats, so each beat corresponds to 1 minute and 26.4 seconds.

+ +

This "Internet Time" is the same all over the world, because it is measured +relatively to something called the Biel Mean Time (BMT), a new meridian that +lies in Switzerland. A day in Internet Time begins at midnight BMT, or @000 +Swatch Beats, 12 noon is equivalent to @500 beats, and so on. So if it's @812 +at my place, it's also 812 beats at yours and everyone else's.

+ +

Please check out the Swatch website +for more information.

+ +

How to use it

+ +

Simply double-click the WebWatch icon to install WebWatch into the Deskbar. +To get rid of it, right-click WebWatch in the Deskbar and select +the Quit option from the pop-up menu.

+ +

Legal stuff

+ +

This version of WebWatch is open source and may be distributed under the +terms of the MIT license. Note that the author is in no way affiliated with +Swatch, and fully respects their copyrights and trademarks.

+ +

Copyright (c) 1999-2003 Matthijs Hollemans

+ +

Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions:

+ +

The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software.

+ +

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE.

+ +

History

+ +

Version 1.5 (Thursday, 13 February 2003)

+ +
    +
  • Cleaned up the source code.
  • +
  • Now uses the plain font, not the bold font.
  • +
+ +

Version 1.4 (Saturday, 9 December 2000)

+ +
    +
  • With certain fonts, WebWatch didn't always fit in the Deskbar.
  • +
+ +

Version 1.3 (Sunday, 26 November 2000)

+ +
    +
  • The time is now written using a bold font, making it better readable.
  • +
  • Thanks to Jason Parks for turning WebWatch into a real Deskbar add-on. +Because of this, WebWatch no longer needs to be installed in the +UserBootscript; the Deskbar starts it automatically. This also means that +WebWatch is now BeOS R5 or higher only.
  • +
+ +

Version 1.2 (Tuesday, 26 September 2000)

+ +
    +
  • Finally fixed a long-standing bug with WebWatch's background color. Now it +uses the same color as the Deskbar.
  • +
+ +

Version 1.1 (Tuesday, 28 March 2000)

+ +
    +
  • New release for BeOS R5. Older versions of WebWatch came with source +code only, which was automatically compiled during installation. However, +because of header file changes between R5 and older versions of the BeOS, +and because the free version of BeOS R5 doesn't necessarily include +development tools, WebWatch 1.1 is already compiled. This means that it +only runs on the Intel platform, since I don't have a PowerPC machine.
  • +
+ +

Version 1.0 (Saturday, 14 August 1999)

+ +
    +
  • First version.
  • +
+ + + From leavengood at gmail.com Sun May 11 02:17:34 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 10 May 2008 20:17:34 -0400 Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <200805110002.m4B02RVw025334@sheep.berlios.de> References: <200805110002.m4B02RVw025334@sheep.berlios.de> Message-ID: On 5/10/08, mmu_man at BerliOS wrote: > > Sources for Matthijs Hollemans' WebWatch app I really don't think this belongs in our repo. The idea of "beats" to measure time is cute and all, and the code looks fine, but I don't see this as something we would want to include with Haiku. I think there are plenty of other apps and demos in Haiku that demonstrate features included in this. I think we need to be more strict about what we put in our repo. But this code could be part of a greater BeOS demo/sample code pack, which I plan to put together eventually. That will be pretty much independent of Haiku and the Haiku repo. Regards, Ryan From mmu_man at mail.berlios.de Sun May 11 02:32:05 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 May 2008 02:32:05 +0200 Subject: [Haiku-commits] r25441 - in haiku/trunk/src/apps: . webwatch Message-ID: <200805110032.m4B0W5vk029690@sheep.berlios.de> Author: mmu_man Date: 2008-05-11 02:32:02 +0200 (Sun, 11 May 2008) New Revision: 25441 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25441&view=rev Added: haiku/trunk/src/apps/webwatch/Jamfile haiku/trunk/src/apps/webwatch/WebWatch.rdef Removed: haiku/trunk/src/apps/webwatch/WebWatch.rsrc haiku/trunk/src/apps/webwatch/makefile Modified: haiku/trunk/src/apps/Jamfile Log: - add a jamfile and rdef - remove makefile and rsrc as it builds fine from jam - add to the build Modified: haiku/trunk/src/apps/Jamfile =================================================================== --- haiku/trunk/src/apps/Jamfile 2008-05-11 00:02:26 UTC (rev 25440) +++ haiku/trunk/src/apps/Jamfile 2008-05-11 00:32:02 UTC (rev 25441) @@ -42,5 +42,6 @@ SubInclude HAIKU_TOP src apps terminal ; SubInclude HAIKU_TOP src apps tracker ; SubInclude HAIKU_TOP src apps tv ; +SubInclude HAIKU_TOP src apps webwatch ; SubInclude HAIKU_TOP src apps workspaces ; Added: haiku/trunk/src/apps/webwatch/Jamfile =================================================================== --- haiku/trunk/src/apps/webwatch/Jamfile 2008-05-11 00:02:26 UTC (rev 25440) +++ haiku/trunk/src/apps/webwatch/Jamfile 2008-05-11 00:32:02 UTC (rev 25441) @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src apps webwatch ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +#UsePrivateHeaders app ; +#UsePrivateHeaders shared ; +#UsePrivateHeaders tracker ; +#SubDirHdrs $(HAIKU_TOP) src kits tracker ; + +Application WebWatch : + WatchApp.cpp + WatchView.cpp + : be + : WebWatch.rdef +; + Added: haiku/trunk/src/apps/webwatch/WebWatch.rdef =================================================================== --- haiku/trunk/src/apps/webwatch/WebWatch.rdef 2008-05-11 00:02:26 UTC (rev 25440) +++ haiku/trunk/src/apps/webwatch/WebWatch.rdef 2008-05-11 00:32:02 UTC (rev 25441) @@ -0,0 +1,20 @@ + +resource app_signature "application/x-vnd.mahlzeit.webwatch"; + +resource app_version { + major = 1, + middle = 5, + minor = 0, + variety = B_APPV_FINAL, + internal = 0, + short_info = "WebWatch", + long_info = "WebWatch 1.5.0 ?1999-2003 Matthijs Hollemans.,\n" + "?2008 Haiku, Inc.\n" + "A port of Swatch Internet Time " +}; + +resource app_flags B_SINGLE_LAUNCH | B_BACKGROUND_APP; + +/*resource file_types message { +};*/ + Deleted: haiku/trunk/src/apps/webwatch/WebWatch.rsrc Deleted: haiku/trunk/src/apps/webwatch/makefile From mmu_man at mail.berlios.de Sun May 11 02:40:59 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 May 2008 02:40:59 +0200 Subject: [Haiku-commits] r25442 - in haiku/trunk/src/apps: . autoraise Message-ID: <200805110040.m4B0exFA030411@sheep.berlios.de> Author: mmu_man Date: 2008-05-11 02:40:56 +0200 (Sun, 11 May 2008) New Revision: 25442 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25442&view=rev Added: haiku/trunk/src/apps/autoraise/ haiku/trunk/src/apps/autoraise/AutoRaise.rsrc haiku/trunk/src/apps/autoraise/AutoRaise.txt haiku/trunk/src/apps/autoraise/AutoRaiseApp.cpp haiku/trunk/src/apps/autoraise/AutoRaiseApp.h haiku/trunk/src/apps/autoraise/AutoRaiseIcon.cpp haiku/trunk/src/apps/autoraise/AutoRaiseIcon.h haiku/trunk/src/apps/autoraise/common.h haiku/trunk/src/apps/autoraise/makefile haiku/trunk/src/apps/autoraise/settings.cpp haiku/trunk/src/apps/autoraise/settings.h Log: The code for my (very useful if you ask me) AutoRaise deskbar addon that brings the focussed window to front after a timeout. MIT of course. Added: haiku/trunk/src/apps/autoraise/AutoRaise.rsrc =================================================================== (Binary files differ) Property changes on: haiku/trunk/src/apps/autoraise/AutoRaise.rsrc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: haiku/trunk/src/apps/autoraise/AutoRaise.txt =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaise.txt 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/AutoRaise.txt 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,41 @@ +AutoRaise : beyond FocusFollowsMouse, for BeOS +(c) 2002, mmu_man, revol at free.fr +Released under MIT licence, +usual disclaimer applies, blah blah blah... + + +This tiny Deskbar replicant is a window autoraiser. It will bring to front whatever window is under the mouse after a selectable delay. + + +Installation: +- put the AutoRaise folder where you want (I suggest /boot/apps), +- you can delete the src/ folder if you aren't interested in the sources, +- double-click on either the 'Put me in Deskbar', or 'Put me in Deskbar (persistant)', the later will keep it in between boots. + + +Alternately, you can run it in a Terminal: +AutoRaise --deskbar + +or, if you want it to be reloaded on each boot: +AutoRaise --deskbar --persist + + +Customisation: +* Left-click will toggles activation. + +* right-click brings a menu: + * Active: check it to activate auto raising + * Mode: The default mode (option 1) is to raise every window. You can also set it so it only raises the Deskbar, whenever you have the mouse on top of it, even if you have a window over it (option 2), or rather only when your mouse is over a visible part of it (option 3). + * Inactive behaviour: This sets up the mouse behaviour when AutoRaise is NOT active. This takes effects only when it's not active (either immediately or when you disables it). It's the same control as the "Focus follows mouse" in the Mouse preferences panel, however I recommend you don't run the preference panel while AutoRaise is active, as it will conflict, and you will get funky behaviour :)) + * Delay: allows you to change the delay before the focused window is brought to front. + +Informations: +There is a special version for Dano, since it provides some helpful API... +To get it just recompile it, it will detect itself it is compiled under R5.1. +I'm not sure the Dano version still compiles however, as I begun this proggy under Dano, but finished it in R5, and didn't check back, since I don't use it much. + +The R5 version has a problem on tabs, because there isn't any mean to know the window tab position and size. So it acts as if the tab was as wide as the window, (it uses the outer region). + + +The code was based on parts of Deskscope, 2000 Shamyl Zakariya +Sorry it's really ugly, but it does the job :) Added: haiku/trunk/src/apps/autoraise/AutoRaiseApp.cpp =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaiseApp.cpp 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/AutoRaiseApp.cpp 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,98 @@ +#include "AutoRaiseApp.h" +#include "AutoRaiseIcon.h" + +AutoRaiseApp::AutoRaiseApp() + : BApplication( APP_SIG ) +{ + removeFromDeskbar(NULL); + _directToDeskbar = false; + + //since the tray item shows an icon, and the class TrayView needs to be able to know the location + //of the executing binary, we write into the settings file this critical information when the app is fired up + app_info info; + be_app->GetAppInfo(&info); + + //now, put the path into the settings file + AutoRaiseSettings settings; + settings.SetAppPath(info.ref); +} + +AutoRaiseApp::~AutoRaiseApp() +{ + return; +} + +void AutoRaiseApp::ArgvReceived(int32 argc, char ** argv) +{ + BString option; + bool inDeskbar = false, persist = false; + + for (int32 i = 1; i < argc; i++) + { + option = argv[i]; + if (option.IFindFirst("deskbar") != B_ERROR) + inDeskbar = true; + + if (option.IFindFirst("persist") != B_ERROR) + persist = true; + } + + if (inDeskbar && !persist) + { + printf(APP_NAME" being put into Tray (one shot)...\n"); + + PutInTray(false); + + _directToDeskbar = true; + + } + else if (inDeskbar && persist) + { + printf(APP_NAME" being put into Tray (persistant)...\n"); + + PutInTray(true); + + _directToDeskbar = true; + } + else + { + printf("\nUsage: "APP_NAME" [options]\n\t--deskbar\twill not open window, will just put "APP_NAME" into tray\n\t--persist will put "APP_NAME" into tray such that it remains between bootings\n"); + } + + be_app_messenger.SendMessage(B_QUIT_REQUESTED); +} + +void AutoRaiseApp::ReadyToRun() +{ + if (!_directToDeskbar) + { + printf("\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open window, will just put " APP_NAME " into tray\n\t--persist will put " APP_NAME " into tray such that it remains between bootings\n"); + BAlert *alert = new BAlert("usage box", APP_NAME ", (c) 2002, mmu_man\nUsage: " APP_NAME " [options]\n\t--deskbar\twill not open window, will just put " APP_NAME " into tray\n\t--persist will put "APP_NAME" into tray such that it remains between bootings\n", "Ok", NULL, NULL, + B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT); + alert->SetShortcut(0, B_ENTER); + alert->Go(); + be_app_messenger.SendMessage(B_QUIT_REQUESTED); + } +} + +void AutoRaiseApp::PutInTray(bool persist) +{ + BDeskbar db; + + if (!persist) + db.AddItem(new TrayView); + else { + BRoster roster; + entry_ref ref; + roster.FindApp(APP_SIG, &ref); + int32 id; + db.AddItem(&ref, &id); + } +} + +int main() +{ + AutoRaiseApp *app = new AutoRaiseApp(); + app->Run(); + +} Added: haiku/trunk/src/apps/autoraise/AutoRaiseApp.h =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaiseApp.h 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/AutoRaiseApp.h 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,26 @@ +#ifndef ICON_H +#define ICON_H + +#include +#include +#include + +#include "common.h" +#include "settings.h" + + +class AutoRaiseApp: public BApplication{ + protected: + bool _directToDeskbar; + + public: + AutoRaiseApp(); + virtual ~AutoRaiseApp(); + virtual bool QuitRequested() { return true; } + virtual void ArgvReceived(int32 argc, char ** args); + virtual void ReadyToRun(); + + void PutInTray(bool); +}; + +#endif Added: haiku/trunk/src/apps/autoraise/AutoRaiseIcon.cpp =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaiseIcon.cpp 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/AutoRaiseIcon.cpp 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,642 @@ +/* this is for the DANO hack (new, simpler version than the BStringIO hack) */ +#include +#ifdef B_BEOS_VERSION_DANO +#define private public +#include +#undef private +#endif + +#include "AutoRaiseIcon.h" +#include +#include +#include +#include +#include + + +extern "C" _EXPORT BView *instantiate_deskbar_item(void) +{ + puts("Instanciating AutoRaise TrayView..."); + return (new TrayView); +} + + +long removeFromDeskbar(void *) +{ + BDeskbar db; + if (db.RemoveItem(APP_NAME) != B_OK) + printf("Unable to remove AutoRaise from BDeskbar\n"); + + return 0; +} + +//************************************************** + +ConfigMenu::ConfigMenu(TrayView *tv, bool useMag) + :BPopUpMenu("config_popup", false, false){ + + BMenu *tmpm; + BMenuItem *tmpi; + BMessage *msg; + bigtime_t delay; + + AutoRaiseSettings *s = tv->Settings(); + + SetFont(be_plain_font); + + + BMenuItem *active = new BMenuItem("Active", new BMessage(MSG_TOOGLE_ACTIVE)); + active->SetMarked(s->Active()); + AddItem(active); + + tmpm = new BMenu("Mode"); + tmpm->SetFont(be_plain_font); + + msg = new BMessage(MSG_SET_MODE); + msg->AddInt32(AR_MODE, Mode_All); + tmpi = new BMenuItem("Default (all windows)", msg); + tmpi->SetMarked(s->Mode() == Mode_All); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_MODE); + msg->AddInt32(AR_MODE, Mode_DeskbarOver); + tmpi = new BMenuItem("Deskbar only (over its area)", msg); + tmpi->SetMarked(s->Mode() == Mode_DeskbarOver); +#ifdef USE_DANO_HACK + tmpi->SetEnabled(false); +#endif + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_MODE); + msg->AddInt32(AR_MODE, Mode_DeskbarTouch); + tmpi = new BMenuItem("Deskbar only (touch)", msg); + tmpi->SetMarked(s->Mode() == Mode_DeskbarTouch); + tmpm->AddItem(tmpi); + + + tmpm->SetTargetForItems(tv); + BMenuItem *modem = new BMenuItem(tmpm); + modem->SetEnabled(s->Active()); + AddItem(modem); + + tmpm = new BMenu("Inactive behaviour"); + tmpm->SetFont(be_plain_font); + + msg = new BMessage(MSG_SET_BEHAVIOUR); + msg->AddInt32(AR_BEHAVIOUR, B_NORMAL_MOUSE); + tmpi = new BMenuItem("Normal", msg); + tmpi->SetMarked(tv->fNormalMM == B_NORMAL_MOUSE); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_BEHAVIOUR); + msg->AddInt32(AR_BEHAVIOUR, B_FOCUS_FOLLOWS_MOUSE); + tmpi = new BMenuItem("Focus follows mouse", msg); + tmpi->SetMarked(tv->fNormalMM == B_FOCUS_FOLLOWS_MOUSE); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_BEHAVIOUR); + msg->AddInt32(AR_BEHAVIOUR, B_WARP_MOUSE); + tmpi = new BMenuItem("Warping (ffm)", msg); + tmpi->SetMarked(tv->fNormalMM == B_WARP_MOUSE); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_BEHAVIOUR); + msg->AddInt32(AR_BEHAVIOUR, B_INSTANT_WARP_MOUSE); + tmpi = new BMenuItem("Instant warping (ffm)", msg); + tmpi->SetMarked(tv->fNormalMM == B_INSTANT_WARP_MOUSE); + tmpm->AddItem(tmpi); + + tmpm->SetTargetForItems(tv); + BMenuItem *behavm = new BMenuItem(tmpm); + AddItem(behavm); + + + tmpm = new BMenu("Delay"); + tmpm->SetFont(be_plain_font); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 100000LL); + tmpi = new BMenuItem("0.1 s", msg); + tmpi->SetMarked(tv->raise_delay == 100000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 200000LL); + tmpi = new BMenuItem("0.2 s", msg); + tmpi->SetMarked(tv->raise_delay == 200000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 500000LL); + tmpi = new BMenuItem("0.5 s", msg); + tmpi->SetMarked(tv->raise_delay == 500000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 1000000LL); + tmpi = new BMenuItem("1 s", msg); + tmpi->SetMarked(tv->raise_delay == 1000000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 2000000LL); + tmpi = new BMenuItem("2 s", msg); + tmpi->SetMarked(tv->raise_delay == 2000000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 3000000LL); + tmpi = new BMenuItem("3 s", msg); + tmpi->SetMarked(tv->raise_delay == 3000000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 4000000LL); + tmpi = new BMenuItem("4 s", msg); + tmpi->SetMarked(tv->raise_delay == 4000000LL); + tmpm->AddItem(tmpi); + + msg = new BMessage(MSG_SET_DELAY); + msg->AddInt64(AR_DELAY, 5000000LL); + tmpi = new BMenuItem("5 s", msg); + tmpi->SetMarked(tv->raise_delay == 5000000LL); + tmpm->AddItem(tmpi); + + tmpm->SetTargetForItems(tv); + BMenuItem *delaym = new BMenuItem(tmpm); + delaym->SetEnabled(s->Active()); + + AddItem(delaym); + + AddSeparatorItem(); +// AddItem(new BMenuItem("Settings...", new BMessage(OPEN_SETTINGS))); + + AddItem(new BMenuItem("About "APP_NAME, new BMessage(B_ABOUT_REQUESTED))); + AddItem(new BMenuItem("Remove from tray", new BMessage(REMOVE_FROM_TRAY))); + + SetTargetForItems(tv); + SetAsyncAutoDestruct(true); +} + +ConfigMenu::~ConfigMenu() {} + +//************************************************ + +TrayView::TrayView() + :BView(BRect(0, 0, B_MINI_ICON, B_MINI_ICON -1), "AutoRaise", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW){ + _init(); //Initialization common to both constructors +} + +//Rehydratable constructor +TrayView::TrayView(BMessage *mdArchive):BView(mdArchive){ + _init(); //As above +} + +void TrayView::GetPreferredSize(float *w, float *h) +{ + *w = B_MINI_ICON; + *h = B_MINI_ICON - 1; +} + +void TrayView::_init() +{ + thread_info ti; + status_t err; + + watching = false; + _settings = new AutoRaiseSettings; + + _appPath = _settings->AppPath(); + + raise_delay = _settings->Delay(); + current_window = 0; + polling_delay = 100000; + fPollerSem = create_sem(0, "AutoRaise poller sync"); + last_raiser_thread = 0; + fNormalMM = mouse_mode(); + + _activeIcon = NULL; + _inactiveIcon = NULL; + + get_thread_info(find_thread(NULL), &ti); + fDeskbarTeam = ti.team; + +#ifndef USE_DANO_HACK + resume_thread(poller_thread = spawn_thread(poller, "AutoRaise desktop poller", B_NORMAL_PRIORITY, (void *)this)); +#endif + + //determine paths to icon files based on app path in settings file + + BResources res; + BFile theapp(&_appPath, B_READ_ONLY); + if ((err = res.SetTo(&theapp)) != B_OK) { + + printf("Unable to find the app to get the resources !!!\n"); +// removeFromDeskbar(NULL); +// delete _settings; +// return; + } + + size_t bmsz; + char *p; + + p = (char *)res.LoadResource('MICN', ACTIVE_ICON, &bmsz); + _activeIcon = new BBitmap(BRect(0, 0, B_MINI_ICON-1, B_MINI_ICON -1), B_CMAP8); + if (!p) + puts("ERROR loading active icon"); + else + _activeIcon->SetBits(p, B_MINI_ICON*B_MINI_ICON, 0, B_CMAP8); + + p = (char *)res.LoadResource('MICN', INACTIVE_ICON, &bmsz); + _inactiveIcon = new BBitmap(BRect(0, 0, B_MINI_ICON-1, B_MINI_ICON -1), B_CMAP8); + if (!p) + puts("ERROR loading inactive icon"); + else + _inactiveIcon->SetBits(p, B_MINI_ICON*B_MINI_ICON, 0, B_CMAP8); + + + SetDrawingMode(B_OP_ALPHA); + SetFlags(Flags() | B_WILL_DRAW); + + // begin watching if we want + // (doesn't work here, better do it in AttachedToWindow()) +} + +TrayView::~TrayView(){ + status_t ret; + + if (watching) { +#ifdef USE_DANO_HACK + be_roster->StopWatching(this); +#else +// acquire_sem(fPollerSem); +#endif + set_mouse_mode(fNormalMM); + watching = false; + } + delete_sem(fPollerSem); +#ifndef USE_DANO_HACK + wait_for_thread(poller_thread, &ret); +#endif + if (_activeIcon) delete _activeIcon; + if (_inactiveIcon) delete _inactiveIcon; + if (_settings) delete _settings; + + return; +} + +//Dehydrate into a message (called by the DeskBar) +status_t TrayView::Archive(BMessage *data, bool deep = true) const { +// BEntry appentry(&_appPath, true); +// BPath appPath(&appentry); + status_t error=BView::Archive(data, deep); + data->AddString("add_on", APP_SIG); +// data->AddFlat("_appPath", (BFlattenable *) &_appPath); + data->AddRef("_appPath", &_appPath); + + return B_NO_ERROR; +} + +//Rehydrate the View from a given message (called by the DeskBar) +TrayView *TrayView::Instantiate(BMessage *data) { + + if (!validate_instantiation(data, "TrayView")) + { + return NULL; + } + + return (new TrayView(data)); +} + +void TrayView::AttachedToWindow() { + if(Parent()) + SetViewColor(Parent()->ViewColor()); + if (_settings->Active()) { + fNormalMM = mouse_mode(); + set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE); +#ifdef USE_DANO_HACK + be_roster->StartWatching(this, B_REQUEST_WINDOW_ACTIVATED); +#else + release_sem(fPollerSem); +#endif + watching = true; + } +} + +void TrayView::Draw(BRect updaterect) { + BRect bnds(Bounds()); + + if (Parent()) SetHighColor(Parent()->ViewColor()); + else SetHighColor(189, 186, 189, 255); + FillRect(bnds); + + if (_settings->Active()) + { + if (_activeIcon) DrawBitmap(_activeIcon); + } + else + { + if (_inactiveIcon) DrawBitmap(_inactiveIcon); + } +} + +void TrayView::MouseDown(BPoint where) { + BWindow *window = Window(); /*To handle the MouseDown message*/ + if (!window) /*Check for proper instantiation*/ + return; + + BMessage *mouseMsg = window->CurrentMessage(); + if (!mouseMsg) /*Check for existence*/ + return; + + if (mouseMsg->what == B_MOUSE_DOWN) { + /*Variables for storing the button pressed / modifying key*/ + uint32 buttons = 0; + uint32 modifiers = 0; + + /*Get the button pressed*/ + mouseMsg->FindInt32("buttons", (int32 *) &buttons); + /*Get modifier key (if any)*/ + mouseMsg->FindInt32("modifiers", (int32 *) &modifiers); + + /*Now perform action*/ + switch(buttons) { + case B_PRIMARY_MOUSE_BUTTON: + { + SetActive(!_settings->Active()); + + break; + } + case B_SECONDARY_MOUSE_BUTTON: + { + ConvertToScreen(&where); + + //menu will delete itself (see constructor of ConfigMenu), + //so all we're concerned about is calling Go() asynchronously + ConfigMenu *menu = new ConfigMenu(this, false); + menu->Go(where, true, true, ConvertToScreen(Bounds()), true); + + break; + } + } + } +} + + +int32 fronter(void *arg) +{ + TrayView *tv = (TrayView *)arg; + int32 tok = tv->current_window; + int32 ws = current_workspace(); + sem_id sem = tv->fPollerSem; + int32 *tl, tlc; + window_info *wi; + + snooze(tv->raise_delay); + +#ifndef USE_DANO_HACK + if (acquire_sem(sem) != B_OK) + return B_OK; // this really needs a better locking model... +#endif + if (ws != current_workspace()) + goto end; // don't touch windows if we changed workspace + if (tv->last_raiser_thread != find_thread(NULL)) + goto end; // seems a newer one has been spawn, exit +PRINT(("tok = %ld cw = %ld\n", tok, tv->current_window)); + if (tok == tv->current_window) { + bool doZoom = false; + BRect zoomRect(0.0f, 0.0f, 10.0f, 10.0f); + do_window_action(tok, B_BRING_TO_FRONT, zoomRect, doZoom); + } + + end: + release_sem(sem); + return B_OK; +} + +#ifndef USE_DANO_HACK + +int32 poller(void *arg) +{ + TrayView *tv = (TrayView *)arg; + volatile int32 tok = tv->current_window; + int32 *tl = NULL; + int32 i, tlc; + window_info *wi = NULL; + + int pass=0; + BPoint mouse; + uint32 buttons; + + while (acquire_sem(tv->fPollerSem) == B_OK) { + release_sem(tv->fPollerSem); + pass++; + BLooper *l = tv->Looper(); + if (!l || l->LockWithTimeout(500000) != B_OK) + continue; + tv->GetMouse(&mouse, &buttons); + tv->ConvertToScreen(&mouse); + tv->Looper()->Unlock(); + if (buttons) // we don't want to interfere when the user is moving a window or something... + goto zzz; + + tl = get_token_list(-1, &tlc); + for (i=0; ilayer < 3) // we hit the desktop or a window not on this WS + goto zzz; + if ((wi->window_left > wi->window_right) || (wi->window_top > wi->window_bottom)) + goto zzz; // invalid window ? +/* +printf("if (!%s && (%li, %li)isin(%li)(%li, %li, %li, %li) && (%li != %li) ", wi->is_mini?"true":"false", + (long)mouse.x, (long)mouse.y, i, wi->window_left, wi->window_right, wi->window_top, wi->window_bottom, wi->id, tok); +*/ + + + if ((!wi->is_mini) + && (((long)mouse.x) > wi->window_left) && (((long)mouse.x) < wi->window_right) + && (((long)mouse.y) > wi->window_top) && (((long)mouse.y) < wi->window_bottom)) { +//((tv->_settings->Mode() != Mode_DeskbarOver) || (wi->team == tv->fDeskbarTeam)) + + if ((tv->_settings->Mode() == Mode_All) && (wi->id == tv->current_window)) + goto zzz; // already raised + + if ((tv->_settings->Mode() == Mode_All) || (wi->team == tv->fDeskbarTeam)) { + tv->current_window = wi->id; + tok = wi->id; + resume_thread(tv->last_raiser_thread = spawn_thread(fronter, "fronter", B_NORMAL_PRIORITY, (void *)tv)); + goto zzz; + } else if (tv->_settings->Mode() == Mode_DeskbarTouch) // give up, before we find Deskbar under it + goto zzz; + } + free(wi); + wi=NULL; + } else + goto zzz; + } + zzz: +// puts(""); + if (wi) free(wi); + wi = NULL; + if (tl) free(tl); + tl = NULL; + snooze(tv->polling_delay); + } + return B_OK; +} + +#endif + +void TrayView::MessageReceived(BMessage* message) +{ + BMessenger msgr; + int32 *tl, tlc; + port_id pi; + int32 tok; + window_info *wi; + + BAlert *alert; + bigtime_t delay; + int32 mode; + bool wasactive; + BPoint mouse; + uint32 buttons; + + switch(message->what) + { + case MSG_TOOGLE_ACTIVE: + SetActive(!_settings->Active()); + break; + case MSG_SET_ACTIVE: + SetActive(true); + break; + case MSG_SET_INACTIVE: + SetActive(false); + break; + case MSG_SET_DELAY: + delay = DEFAULT_DELAY; + message->FindInt64(AR_DELAY, &delay); + raise_delay = delay; + _settings->SetDelay(delay); + break; + case MSG_SET_MODE: + mode = Mode_All; + message->FindInt32(AR_MODE, &mode); + _settings->SetMode(mode); + break; + case MSG_SET_BEHAVIOUR: + message->FindInt32(AR_BEHAVIOUR, &mode); + wasactive = _settings->Active(); + if (wasactive) + SetActive(false); + fNormalMM = (mode_mouse)mode; + set_mouse_mode(fNormalMM); + if (wasactive) + SetActive(true); + break; + case REMOVE_FROM_TRAY: + { + thread_id tid = spawn_thread(removeFromDeskbar, "RemoveFromDeskbar", B_NORMAL_PRIORITY, NULL); + if (tid) resume_thread(tid); + + break; + } + case B_ABOUT_REQUESTED: + alert = new BAlert("about box", "AutoRaise, (c) 2002, mmu_man\nEnjoy :-)", "Ok", NULL, NULL, + B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT); + alert->SetShortcut(0, B_ENTER); + alert->Go(NULL); // use asynchronous version + break; + case OPEN_SETTINGS: + + break; +#ifdef USE_DANO_HACK + case B_SOME_WINDOW_ACTIVATED: +// printf("Window Activated\n"); +// message->PrintToStream(); + GetMouse(&mouse, &buttons); + if (buttons) + break; + if (message->FindMessenger("be:window", &msgr) < B_OK) + puts("BMsgr ERROR"); + else { + bool doZoom = false; + BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f); + pi = msgr.fPort; +// printf("port:%li (%lx)\n", pi, pi); + + tl = get_token_list(msgr.Team(), &tlc); +// printf("tokens (team %li): (%li) ", msgr.Team(), tlc); + for (tlc; tlc; tlc--) { +// printf("%li ", tl[tlc-1]); + wi = get_window_info(tl[tlc-1]); + if (wi) { + if (wi->client_port == pi) { + if ((wi->layer < 3) // we hit the desktop or a window not on this WS + || (wi->window_left > wi->window_right) || (wi->window_top > wi->window_bottom) + || (wi->is_mini) + || (/*(_settings->Mode() == Mode_All) && */(wi->id == current_window))) { + // already raised + free(wi); + break; + } + + if ((_settings->Mode() == Mode_All) || (wi->team == fDeskbarTeam)) { + PRINT(("raising wi=%li, cp=%ld, pi=%ld team=%ld DBteam=%ld\n", wi->id, wi->client_port, pi, wi->team, fDeskbarTeam)); + current_window = wi->id; + tok = wi->id; + resume_thread(last_raiser_thread = spawn_thread(fronter, "fronter", B_NORMAL_PRIORITY, (void *)this)); + } else { + current_window = wi->id; + } + } + free(wi); + } + } +// puts(""); + free(tl); + } + break; +#endif + default: + BView::MessageReceived(message); + } +} + +AutoRaiseSettings *TrayView::Settings() const +{ + return _settings; +} + +void TrayView::SetActive(bool st) +{ + _settings->SetActive(st); + if (_settings->Active()) + { + if (!watching) { + fNormalMM = mouse_mode(); + set_mouse_mode(B_FOCUS_FOLLOWS_MOUSE); +#ifdef USE_DANO_HACK + be_roster->StartWatching(this, B_REQUEST_WINDOW_ACTIVATED); +#else + release_sem(fPollerSem); +#endif + watching = true; + } + } + else + { + if (watching) { +#ifdef USE_DANO_HACK + be_roster->StopWatching(this); +#else + acquire_sem(fPollerSem); +#endif + set_mouse_mode(fNormalMM); + watching = false; + } + } + Invalidate(); +} + Added: haiku/trunk/src/apps/autoraise/AutoRaiseIcon.h =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaiseIcon.h 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/AutoRaiseIcon.h 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,94 @@ +#ifndef TRAY_VIEW +#define TRAY_VIEW + +#include +#include +#include +#include + + +#include "common.h" +#include "settings.h" +#include + +//exported instantiator function +extern "C" _EXPORT BView* instantiate_deskbar_item(); + + +//since we can't remove the view from the deskbar from within the same thread +//as tray view, a thread will be spawned and this function called. It removed TrayView +//from the Deskbar +long removeFromDeskbar(void *); + +class _EXPORT TrayView; + + +/********************************************* + class TrayView derived from BView + + The icon in the Deskbar tray, provides the fundamental + user interface. Archivable, so it can be flattened and fired + at the deskbar. + +*********************************************/ + +class TrayView:public BView{ + private: + + BBitmap *_activeIcon, *_inactiveIcon; + entry_ref _appPath; + bool watching; + + void _init(void); //initialization common to all constructors + + public: + AutoRaiseSettings *_settings; + mode_mouse fNormalMM; + volatile int32 current_window; // id + bigtime_t raise_delay; + volatile thread_id last_raiser_thread; + team_id fDeskbarTeam; + + bigtime_t polling_delay; // for !DANO + sem_id fPollerSem; + thread_id poller_thread; + + TrayView(); + TrayView(BMessage *mdArchive); + virtual ~TrayView(); + + virtual status_t Archive(BMessage *data, bool deep = true) const; + static TrayView *Instantiate(BMessage *data); + + virtual void Draw(BRect updateRect ); + virtual void AttachedToWindow(); + virtual void MouseDown(BPoint where); + virtual void MessageReceived(BMessage* message); + virtual void GetPreferredSize(float *w, float *h); + + AutoRaiseSettings *Settings() const; + void SetActive(bool); +}; + +int32 fronter(void *); +int32 poller(void *); + +/********************************************* + ConfigMenu derived from BPopUpMenu + Provides the contextual left-click menu for the + TrayView. Fires it's messages at the TrayView specified + in it's constructor; + Also, it's by default set to asynchronously destruct, + so it's basically a fire & forget kinda fella. +*********************************************/ + +class ConfigMenu: public BPopUpMenu{ + private: + + public: + ConfigMenu(TrayView *tv, bool useMag); + virtual ~ConfigMenu(); +}; + + +#endif Added: haiku/trunk/src/apps/autoraise/common.h =================================================================== --- haiku/trunk/src/apps/autoraise/common.h 2008-05-11 00:32:02 UTC (rev 25441) +++ haiku/trunk/src/apps/autoraise/common.h 2008-05-11 00:40:56 UTC (rev 25442) @@ -0,0 +1,106 @@ +#ifndef COMMON_H +#define COMMON_H + +#include + +#include +#include +#include +#include + + +// R5.1 has a very helpful API... +#if (B_BEOS_VERSION == 0x0510) +#define USE_DANO_HACK +#endif + +/*************************************************** + common.h + Constants used by app +***************************************************/ + +// used to check the image to use to get the resources +#define APP_NAME "AutoRaise" +#define APP_SIG "application/x-vnd.mmu.AutoRaise" +#define SETTINGS_FILE "x-vnd.mmu.AutoRaise_settings" + +//names of data segments in settings file +//also used in messages + +#define DEFAULT_DELAY 500000LL + +// float: delay before raise +#define AR_DELAY "ar:delay" +// bool: last state +#define AR_ACTIVE "ar:active" + +#define AR_MODE "ar:mode" +enum { + Mode_All, + Mode_DeskbarOver, + Mode_DeskbarTouch +}; + +#define AR_BEHAVIOUR "ar:behaviour" + +// resources +#define ACTIVE_ICON "AR:ON" +#define INACTIVE_ICON "AR:OFF" + +// messages + +#define ADD_TO_TRAY 'zATT' +#define REMOVE_FROM_TRAY 'zRFT' + [... truncated: 345 lines follow ...] From mmu_man at mail.berlios.de Sun May 11 03:02:35 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 May 2008 03:02:35 +0200 Subject: [Haiku-commits] r25443 - in haiku/trunk/src/apps: . autoraise Message-ID: <200805110102.m4B12Zvd032132@sheep.berlios.de> Author: mmu_man Date: 2008-05-11 03:02:34 +0200 (Sun, 11 May 2008) New Revision: 25443 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25443&view=rev Added: haiku/trunk/src/apps/autoraise/AutoRaise.rdef haiku/trunk/src/apps/autoraise/Jamfile Removed: haiku/trunk/src/apps/autoraise/AutoRaise.rsrc haiku/trunk/src/apps/autoraise/makefile Modified: haiku/trunk/src/apps/Jamfile Log: - add jamfile & rdef - remove makefile & rsrc - hook to the build. Modified: haiku/trunk/src/apps/Jamfile =================================================================== --- haiku/trunk/src/apps/Jamfile 2008-05-11 00:40:56 UTC (rev 25442) +++ haiku/trunk/src/apps/Jamfile 2008-05-11 01:02:34 UTC (rev 25443) @@ -3,6 +3,7 @@ SubInclude HAIKU_TOP src apps 3dmov ; SubInclude HAIKU_TOP src apps aboutsystem ; SubInclude HAIKU_TOP src apps activitymonitor ; +SubInclude HAIKU_TOP src apps autoraise ; SubInclude HAIKU_TOP src apps bsnow ; SubInclude HAIKU_TOP src apps bootman ; SubInclude HAIKU_TOP src apps cdplayer ; Added: haiku/trunk/src/apps/autoraise/AutoRaise.rdef =================================================================== --- haiku/trunk/src/apps/autoraise/AutoRaise.rdef 2008-05-11 00:40:56 UTC (rev 25442) +++ haiku/trunk/src/apps/autoraise/AutoRaise.rdef 2008-05-11 01:02:34 UTC (rev 25443) @@ -0,0 +1,236 @@ + +resource app_signature "application/x-vnd.mmu.AutoRaise"; + +resource app_version { + major = 0, + middle = 0, + minor = 1, + variety = B_APPV_FINAL, + internal = 0, + short_info = "AutoRaise", + long_info = "AutoRaise 0.0.1 ?2002-2008 Fran?ois Revol.,\n" + "?2008 Haiku, Inc.\n" + "Automatic window raise" +}; + +resource app_flags B_SINGLE_LAUNCH; + +/*resource file_types message { +};*/ + +resource(104, "AddToDeskbar") #'ICON' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B5B5B0010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B7CC5001010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B7CC5001010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B7CC5001010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B7CC5001010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFF005B7CC5001010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFF000000005B7CC50000000010FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FF193F3F005B5B5B7C7C7CC50010103F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F10" + $"0EFF101010007C7C7C7CC5001010101010101010101010101010101010101010" + $"191917171717007C7CC500101017171717171717171717171717171717173F10" + $"FF13000017171700C50010101717001700001717171717001717170017173F10" + $"FFFF2A0017171717001010171700001717170017171700170017001700173F10" + $"19132A0017171717171017170017001717170017001700170017001700173F10" + $"FF132A0017171717171717171717001717001717171700170017001700173F10" + $"19132A0017171717171717171717001700171717001700170017001700173F10" + $"19FF2A0017171717171717171717001700171717171700170017001700173F10" + $"FF13000017171717171717171717001700000017171717001717170017173F10" + $"19FF171717171717171717171717171717171717171717171717171717173F10" + $"19133F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F10" + $"FF19101010101010101010101010101010101010101010101010101010101010" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(101, "BEOS:L:STD_ICON") #'ICON' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000FFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF006D6D4747470000FFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF006D94943F3F476D9400FFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF009494000000943F949400FFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0094003F868600946D947F00FFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0094003F6000868600947F7F00FFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF009400606000608600947F7F00FFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF009400606000606086007F7F00FFFFFFFF" + $"FF0F0F0F0F0F0F0F0F0FFFFFFFFFFF009400606000006086007F7F00FFFFFFFF" + $"FF0FFCFCFCFCFCFCFC00FFFFFFFFFF009400866060600086007F7F00FFFFFFFF" + $"FF0FF9F9F9F9F9F9F90F0F0F0F0FFF009494008686868600947F7F00FFFFFFFF" + $"FF0F191919191919191919191900FF009494940000000094947F7F00FFFFFFFF" + $"FF0F193F3F3F3F3F3F3F3F3F1900FFFF0000949494949494947F7F000F0FFFFF" + $"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFFFF000094949494947F00000F0FFFFF" + $"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFFFFFFFF000000949400000F0FFFFFFF" + $"FF0F193F3F3F3F3F3F3F3F3F1900FFFFFFFFFFFFFFFFFF0000000E0FFFFFFFFF" + $"FF0F193F3F3F3F0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0F193F3F3F3F0F1313131313001300FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0F193F3F3F3F0F131313131313130F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0F193F3F3F3F0F193F193F1900191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0F19191919190F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0000000000000F190019001900191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF0F191919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF00000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(102, "AR:OFF") #'ICON' array { + $"0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0FF9F9F9F9F9F9F90F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C1919190F0F0F0F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F13131313131300FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1313131313130F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C1919190F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"000000000F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(103, "AR:ON") #'ICON' array { + $"0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0FF9F9F9F9F9F9F90F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F1900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F19000F0F0F0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C193F3F3F3F3F3F3F3F190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"0C191919191919191919190019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"00000000000000000000000019191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF0F1919191919191919191900FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(104, "AddToDeskbar") #'MICN' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFF000000FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF007C00FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF007C00FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF007C00FFFFFFFFFFFFFFFFFFFF" + $"FFFFFF007C00FFFFFFFFFFFFFFFFFFFF" + $"000000007C00000000FFFFFFFFFFFFFF" + $"3F007C7C7C7C7C003F3F3F3F3F3F3F3F" + $"3F10007C7C7C00101010101010101010" + $"171717007C0017171700170017003F10" + $"17171717001717171717000017003F10" + $"17171717171717170017170017003F10" + $"173F3F3F3F3F3F3F3F3F3F3F3F3F3F10" + $"17101010101010101010101010101010" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" +}; + +resource(101, "BEOS:M:STD_ICON") #'MICN' array { + $"0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFF" + $"0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFF" + $"0FF9F9F9F9F9F9F90F0F0F0FFFFFFFFF" + $"0C1919190F0F0F0F0F0F0F0FFFFFFFFF" + $"0C193F3F0F13131313131300FFFFFFFF" + $"0C193F3F0F1313131313130F0F0F0F0F" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C1919190F1919191919191919191900" + $"000000000F1919191919191919191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF000000000000000000000000" +}; + +resource(102, "AR:OFF") #'MICN' array { + $"0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFF" + $"0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFF" + $"0FF9F9F9F9F9F9F90F0F0F0FFFFFFFFF" + $"0C1919190F0F0F0F0F0F0F0FFFFFFFFF" + $"0C193F3F0F13131313131300FFFFFFFF" + $"0C193F3F0F1313131313130F0F0F0F0F" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C193F3F0F1919191919191919191900" + $"0C1919190F1919191919191919191900" + $"000000000F1919191919191919191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF000000000000000000000000" +}; + +resource(103, "AR:ON") #'MICN' array { + $"0F0F0F0F0F0F0F0F0FFFFFFFFFFFFFFF" + $"0FFCFCFCFCFCFCFC00FFFFFFFFFFFFFF" + $"0FF9F9F9F9F9F9F90F0F0F0FFFFFFFFF" + $"0C1919191919191919191900FFFFFFFF" + $"0C193F3F3F3F3F3F3F3F1900FFFFFFFF" + $"0C193F3F3F3F3F3F3F3F19000F0F0F0F" + $"0C193F3F3F3F3F3F3F3F190019191900" + $"0C193F3F3F3F3F3F3F3F190019191900" + $"0C193F3F3F3F3F3F3F3F190019191900" + $"0C193F3F3F3F3F3F3F3F190019191900" + $"0C193F3F3F3F3F3F3F3F190019191900" + $"0C191919191919191919190019191900" + $"00000000000000000000000019191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF0F1919191919191919191900" + $"FFFFFFFF000000000000000000000000" +}; + Deleted: haiku/trunk/src/apps/autoraise/AutoRaise.rsrc Added: haiku/trunk/src/apps/autoraise/Jamfile =================================================================== --- haiku/trunk/src/apps/autoraise/Jamfile 2008-05-11 00:40:56 UTC (rev 25442) +++ haiku/trunk/src/apps/autoraise/Jamfile 2008-05-11 01:02:34 UTC (rev 25443) @@ -0,0 +1,12 @@ +SubDir HAIKU_TOP src apps autoraise ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +Application AutoRaise : + AutoRaiseApp.cpp + AutoRaiseIcon.cpp + settings.cpp + : be $(TARGET_LIBSTDC++) + : AutoRaise.rdef +; + Deleted: haiku/trunk/src/apps/autoraise/makefile From dlmcpaul at mail.berlios.de Sun May 11 04:07:02 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Sun, 11 May 2008 04:07:02 +0200 Subject: [Haiku-commits] r25444 - in haiku/trunk/src/add-ons/media/plugins/mov_reader: . libMOV Message-ID: <200805110207.m4B272YB004049@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-11 04:07:01 +0200 (Sun, 11 May 2008) New Revision: 25444 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25444&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.h haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp Log: fix issue 1779 - crash on mov with audio Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp 2008-05-11 01:02:34 UTC (rev 25443) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp 2008-05-11 02:07:01 UTC (rev 25444) @@ -439,7 +439,7 @@ return &theMainHeader; } -const AudioMetaData *MOVFileReader::AudioFormat(uint32 stream_index, size_t *size) +const AudioMetaData *MOVFileReader::AudioFormat(uint32 stream_index) { if (IsAudio(stream_index)) { Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.h 2008-05-11 01:02:34 UTC (rev 25443) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.h 2008-05-11 02:07:01 UTC (rev 25444) @@ -113,7 +113,7 @@ bool GetNextChunkInfo(uint32 stream_index, uint32 pFrameNo, off_t *start, uint32 *size, bool *keyframe); // Return all Audio Meta Data - const AudioMetaData *AudioFormat(uint32 stream_index, size_t *size = 0); + const AudioMetaData *AudioFormat(uint32 stream_index); // Return all Video Meta Data const VideoMetaData *VideoFormat(uint32 stream_index); Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-11 01:02:34 UTC (rev 25443) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-11 02:07:01 UTC (rev 25444) @@ -252,6 +252,7 @@ format->u.raw_audio.buffer_size = stream_header->suggested_buffer_size; } else { + description.family = B_QUICKTIME_FORMAT_FAMILY; description.u.quicktime.codec = audio_format->compression; if (B_OK != formats.GetFormatFor(description, format)) { @@ -278,6 +279,8 @@ format->u.encoded_audio.output.frame_rate = cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; break; + case AUDIO_IMA4: + default: TRACE("OTHER\n"); format->u.encoded_audio.bit_rate = 8 * cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; @@ -287,49 +290,16 @@ } } -/* if (audio_format->compression == 0x0001) { - // a raw PCM format - description.family = B_BEOS_FORMAT_FAMILY; - description.u.beos.format = B_BEOS_FORMAT_RAW_AUDIO; - if (B_OK != formats.GetFormatFor(description, format)) - format->type = B_MEDIA_RAW_AUDIO; - format->u.raw_audio.frame_rate = audio_format->SampleRate; - format->u.raw_audio.channel_count = audio_format->NoOfChannels; - if (audio_format->bits_per_sample <= 8) - format->u.raw_audio.format = B_AUDIO_FORMAT_UINT8; - else if (audio_format->bits_per_sample <= 16) - format->u.raw_audio.format = B_AUDIO_FORMAT_INT16; - else if (audio_format->bits_per_sample <= 24) - format->u.raw_audio.format = B_AUDIO_FORMAT_INT24; - else if (audio_format->bits_per_sample <= 32) - format->u.raw_audio.format = B_AUDIO_FORMAT_INT32; - else { - ERROR("movReader::AllocateCookie: unhandled bits per sample %d\n", audio_format->bits_per_sample); - return B_ERROR; - } - format->u.raw_audio.format |= B_AUDIO_FORMAT_CHANNEL_ORDER_WAVE; - format->u.raw_audio.byte_order = B_MEDIA_BIG_ENDIAN; - format->u.raw_audio.buffer_size = stream_header->suggested_buffer_size; - } else { - // some encoded format - description.family = B_WAV_FORMAT_FAMILY; - description.u.wav.codec = audio_format->compression; - if (B_OK != formats.GetFormatFor(description, format)) - format->type = B_MEDIA_ENCODED_AUDIO; - format->u.encoded_audio.bit_rate = 8 * audio_format->PacketSize; - TRACE("bit_rate %.3f\n", format->u.encoded_audio.bit_rate); - format->u.encoded_audio.output.frame_rate = audio_format->SampleRate; - format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; - } - */ // this doesn't seem to work (it's not even a fourcc) format->user_data_type = B_CODEC_TYPE_INFO; *(uint32 *)format->user_data = audio_format->compression; format->user_data[4] = 0; - // put the Audio struct, including extra data, into the format meta data. - size_t size; - const void *data = theFileReader->AudioFormat(cookie->stream, &size); - format->SetMetaData(data, size); + // Some codecs have additional setup data that they need, put it in metadata + size_t size = audio_format->VOLSize; + const void *data = audio_format->theVOL; + if (size > 0) { + format->SetMetaData(data, size); + } #ifdef TRACE_MOV_READER uint8 *p = 18 + (uint8 *)data; @@ -382,6 +352,7 @@ format->user_data_type = B_CODEC_TYPE_INFO; *(uint32 *)format->user_data = description.u.quicktime.codec; format->user_data[4] = 0; + format->u.encoded_video.max_bit_rate = 8 * theFileReader->MovMainHeader()->max_bytes_per_sec; format->u.encoded_video.avg_bit_rate = format->u.encoded_video.max_bit_rate / 2; // XXX fix this format->u.encoded_video.output.field_rate = cookie->frames_per_sec_rate / (float)cookie->frames_per_sec_scale; @@ -391,7 +362,6 @@ format->u.encoded_video.output.orientation = B_VIDEO_TOP_LEFT_RIGHT; format->u.encoded_video.output.pixel_width_aspect = 1; format->u.encoded_video.output.pixel_height_aspect = 1; - // format->u.encoded_video.output.display.format = 0; format->u.encoded_video.output.display.line_width = theFileReader->MovMainHeader()->width; format->u.encoded_video.output.display.line_count = cookie->line_count; format->u.encoded_video.output.display.bytes_per_row = 0; // format->u.encoded_video.output.display.line_width * 4; @@ -402,11 +372,11 @@ TRACE("max_bit_rate %.3f\n", format->u.encoded_video.max_bit_rate); TRACE("field_rate %.3f\n", format->u.encoded_video.output.field_rate); - // Set the VOL - if (video_format->VOLSize > 0) { - TRACE("VOL SIZE %ld\n", video_format->VOLSize); - size_t size = video_format->VOLSize; - const void *data = video_format->theVOL; + // Some decoders need additional metadata passed via a special Atom + size_t size = video_format->VOLSize; + const void *data = video_format->theVOL; + if (size > 0) { + TRACE("VOL SIZE %ld\n", size); format->SetMetaData(data, size); } @@ -439,8 +409,18 @@ *frameCount = cookie->frame_count; *duration = cookie->duration; *format = cookie->format; - *infoBuffer = 0; - *infoSize = 0; + + // Copy metadata to infoBuffer + if (theFileReader->IsVideo(cookie->stream)) { + const VideoMetaData *video_format = theFileReader->VideoFormat(cookie->stream); + *infoBuffer = video_format->theVOL; + *infoSize = video_format->VOLSize; + } else { + const AudioMetaData *audio_format = theFileReader->AudioFormat(cookie->stream); + *infoBuffer = audio_format->theVOL; + *infoSize = audio_format->VOLSize; + } + return B_OK; } From dlmcpaul at mail.berlios.de Sun May 11 04:44:42 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Sun, 11 May 2008 04:44:42 +0200 Subject: [Haiku-commits] r25445 - haiku/trunk/src/add-ons/media/plugins/mp4_reader Message-ID: <200805110244.m4B2igCk006045@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-11 04:44:39 +0200 (Sun, 11 May 2008) New Revision: 25445 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25445&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp Log: change printf to TRACE. Turn off TRACEing Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp 2008-05-11 02:07:01 UTC (rev 25444) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp 2008-05-11 02:44:39 UTC (rev 25445) @@ -38,7 +38,7 @@ #include -#define TRACE_MP4_READER +//#define TRACE_MP4_READER #ifdef TRACE_MP4_READER # define TRACE printf #else @@ -308,12 +308,12 @@ // Setting a bitrate seems to cause more problems than it solves format->u.encoded_audio.bit_rate = audio_format->BitRate; // usually 128000 for AAC - printf("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize); + TRACE("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize); - printf("Audio frame_rate %f, channel_count %ld, format %ld, buffer_size %ld, frame_size %ld, bit_rate %f\n", + TRACE("Audio frame_rate %f, channel_count %ld, format %ld, buffer_size %ld, frame_size %ld, bit_rate %f\n", format->u.encoded_audio.output.frame_rate, format->u.encoded_audio.output.channel_count, format->u.encoded_audio.output.format,format->u.encoded_audio.output.buffer_size, format->u.encoded_audio.frame_size, format->u.encoded_audio.bit_rate); - printf("Track %d MP4 Audio FrameCount %ld\n",cookie->stream,theFileReader->getFrameCount(cookie->stream)); + TRACE("Track %d MP4 Audio FrameCount %ld\n",cookie->stream,theFileReader->getFrameCount(cookie->stream)); break; default: @@ -341,7 +341,9 @@ data = audio_format->theDecoderConfig; if (size > 0) { if (format->SetMetaData(data, size) != B_OK) { - printf("Failed to set Decoder Config\n"); + ERROR("Failed to set Decoder Config\n"); + delete cookie; + return B_ERROR; } } @@ -455,7 +457,9 @@ if (size > 0) { TRACE("Decoder Config Found Size is %ld\n",size); if (format->SetMetaData(data, size) != B_OK) { - printf("Failed to set Decoder Config\n"); + ERROR("Failed to set Decoder Config\n"); + delete cookie; + return B_ERROR; } #ifdef TRACE_MP4_READER From koki at digintrans.com Sun May 11 04:47:28 2008 From: koki at digintrans.com (Jorge G. Mare (aka Koki)) Date: Sat, 10 May 2008 19:47:28 -0700 Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: References: <200805110002.m4B02RVw025334@sheep.berlios.de> Message-ID: <48265E40.8030305@digintrans.com> Ryan Leavengood wrote: > On 5/10/08, mmu_man at BerliOS wrote: > >> Sources for Matthijs Hollemans' WebWatch app >> > > I really don't think this belongs in our repo. The idea of "beats" to > measure time is cute and all, and the code looks fine, but I don't see > this as something we would want to include with Haiku. I think there > are plenty of other apps and demos in Haiku that demonstrate features > included in this. > > I think we need to be more strict about what we put in our repo. > > But this code could be part of a greater BeOS demo/sample code pack, > which I plan to put together eventually. That will be pretty much > independent of Haiku and the Haiku repo. > The sources being in the Haiku repo does not necessarily equate to the app being included in the eventual official Haiku distro(s). IMHO, there is value in keeping this sort of code where anyone can easily access it, so why not leave it in the Haiku repo for now? If/when you (or anybody else for that matter) eventually put(s) together a demo/sample pack, then it can be migrated/removed. Cheers, Koki From axeld at pinc-software.de Sun May 11 10:37:50 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 10:37:50 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <569173682-BeMail@zon> "Ryan Leavengood" wrote: > But this code could be part of a greater BeOS demo/sample code pack, > which I plan to put together eventually. That will be pretty much > independent of Haiku and the Haiku repo. Does speak anything against maintaing that sample code pack in the Haiku repository? Of course, those apps shouldn't end up in src/apps/ but a special directory. Bye, Axel. From superstippi at gmx.de Sun May 11 11:45:59 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 11 May 2008 11:45:59 +0200 Subject: [Haiku-commits] r25439 - in haiku/trunk/src/add-ons/kernel/drivers/network: . usb_ecm In-Reply-To: <200805102350.m4ANohSS021576@sheep.berlios.de> References: <200805102350.m4ANohSS021576@sheep.berlios.de> Message-ID: <20080511114559.750.1@stippis2.1210496147.fake> Hi Michael, your driver writing skills are pretty cool! I find it very easy to follow your code. Here are the only things that I spotted: > + uint8 controlIndex = 0; > + uint8 dataIndex = 0; > + bool foundUnionDescriptor = false; > + bool foundEthernetDescriptor = false; > + for (size_t i = 0; i < config->interface_count > + && (!foundUnionDescriptor || !foundEthernetDescriptor); i++) { > + usb_interface_info *interface = config->interface[i].active; > + usb_interface_descriptor *descriptor = interface->descr; > + if (descriptor->interface_class == USB_INTERFACE_CLASS_CDC > + && descriptor->interface_subclass == > USB_INTERFACE_SUBCLASS_ECM > + && interface->generic_count > 0) { > + // try to find and interpret the union and ethernet > functional > + // descriptors > + for (size_t j = 0; j < interface->generic_count; j++) { > + usb_generic_descriptor *generic = > &interface->generic[j]->generic; > + if (generic->length >= 5 > + && generic->data[0] == FUNCTIONAL_SUBTYPE_UNION) { > + controlIndex = generic->data[1]; > + dataIndex = generic->data[2]; > + foundUnionDescriptor = true; > + } else if (generic->length >= > sizeof(ethernet_functional_descriptor) > + && generic->data[0] == FUNCTIONAL_SUBTYPE_ETHERNET) { > + ethernet_functional_descriptor *ethernet > + = (ethernet_functional_descriptor > *)generic->data; > + fMACAddressIndex = ethernet->mac_address_index; > + fMaxSegmentSize = ethernet->max_segment_size; > + foundEthernetDescriptor = true; > + } > + > + if (foundUnionDescriptor && foundEthernetDescriptor) > + break; You could probably simplify some redundant checks above. > +status_t > +ECMDevice::Read(uint8 *buffer, size_t *numBytes) > +{ > + if (fRemoved) { > + *numBytes = 0; > + return B_ERROR; > + } > + > + status_t result = gUSBModule->queue_bulk(fReadEndpoint, buffer, > *numBytes, > + _ReadCallback, this); > + if (result != B_OK) { > + *numBytes = 0; > + return result; > + } > + > + result = acquire_sem_etc(fNotifyRead, 1, B_CAN_INTERRUPT, 0); > + if (result < B_OK) { > + *numBytes = 0; > + return result; > + } Are you not handling B_INTERRUPTED on purpose? > +status_t > +ECMDevice::Write(const uint8 *buffer, size_t *numBytes) > +{ > + if (fRemoved) { > + *numBytes = 0; > + return B_ERROR; > + } > + > + status_t result = gUSBModule->queue_bulk(fWriteEndpoint, (uint8 > *)buffer, > + *numBytes, _WriteCallback, this); > + if (result != B_OK) { > + *numBytes = 0; > + return result; > + } > + > + result = acquire_sem_etc(fNotifyWrite, 1, B_CAN_INTERRUPT, 0); > + if (result < B_OK) { > + *numBytes = 0; > + return result; > + } Same here. Last question: how is the driver being picked up as a network driver? Best regards, -Stephan From axeld at mail.berlios.de Sun May 11 14:08:15 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 May 2008 14:08:15 +0200 Subject: [Haiku-commits] r25446 - in haiku/trunk/src/tests/add-ons/translators: . exif Message-ID: <200805111208.m4BC8Fkx020066@sheep.berlios.de> Author: axeld Date: 2008-05-11 14:08:15 +0200 (Sun, 11 May 2008) New Revision: 25446 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25446&view=rev Added: haiku/trunk/src/tests/add-ons/translators/exif/ haiku/trunk/src/tests/add-ons/translators/exif/Jamfile haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp Modified: haiku/trunk/src/tests/add-ons/translators/Jamfile Log: Wrote a small test program that can reproduce the problem in bug #2206. Modified: haiku/trunk/src/tests/add-ons/translators/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/translators/Jamfile 2008-05-11 02:44:39 UTC (rev 25445) +++ haiku/trunk/src/tests/add-ons/translators/Jamfile 2008-05-11 12:08:15 UTC (rev 25446) @@ -26,3 +26,5 @@ TIFFTranslatorTest.cpp : $(libtranslation) be $(TARGET_LIBSTDC++) ; + +SubInclude HAIKU_TOP src tests add-ons translators exif ; Added: haiku/trunk/src/tests/add-ons/translators/exif/Jamfile =================================================================== --- haiku/trunk/src/tests/add-ons/translators/exif/Jamfile 2008-05-11 02:44:39 UTC (rev 25445) +++ haiku/trunk/src/tests/add-ons/translators/exif/Jamfile 2008-05-11 12:08:15 UTC (rev 25446) @@ -0,0 +1,19 @@ +SubDir HAIKU_TOP src tests add-ons translators exif ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +SubDirSysHdrs [ FDirName $(HAIKU_TOP) src add-ons translators jpeg ] ; +SubDirSysHdrs [ FDirName $(HAIKU_TOP) src add-ons translators raw ] ; + # for TIFF.h and ReadHelper.h + +SimpleTest dump_exif : + dump_exif.cpp + exif_parser.cpp + + : be +; + +SEARCH on [ FGristFiles + exif_parser.cpp + ] = [ FDirName $(HAIKU_TOP) src add-ons translators jpeg ] ; + Added: haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp 2008-05-11 02:44:39 UTC (rev 25445) +++ haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp 2008-05-11 12:08:15 UTC (rev 25446) @@ -0,0 +1,125 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "exif_parser.h" + +#include +#include + +#include +#include +#include +#include + +#include "ReadHelper.h" +#include "TIFF.h" + + +static status_t +process_exif(uint8* data, uint32 length) +{ + if (memcmp(data + 2, "Exif", 4)) + return B_BAD_TYPE; + + BMemoryIO source(data + 8, length - 8); + BMessage exif; + status_t status = convert_exif_to_message(source, exif); + if (status == B_OK) + exif.PrintToStream(); + + return status; +} + + +static status_t +process_jpeg(BPositionIO& stream) +{ + enum { + START_OF_IMAGE_MARKER = 0xd8, + EXIF_MARKER = 0xe1 + }; + + uint8 header[2]; + if (stream.Read(&header, 2) != 2) + return B_IO_ERROR; + if (header[0] != 0xff || header[1] != START_OF_IMAGE_MARKER) + return B_BAD_TYPE; + + while (true) { + // read marker + uint8 marker; + for (int32 i = 0; i < 7; i++) { + if (stream.Read(&marker, 1) != 1) + return B_BAD_TYPE; + + if (marker != 0xff) + break; + } + + if (marker == 0xff) + return B_BAD_TYPE; + + // get length of section + + uint16 length; + if (stream.Read(&length, 2) != 2) + return B_BAD_TYPE; + + swap_data(B_UINT16_TYPE, &length, 2, B_SWAP_BENDIAN_TO_HOST); + + if (marker == EXIF_MARKER) { + // read in section + stream.Seek(-2, SEEK_CUR); + + uint8 exifData[length]; + if (stream.Read(exifData, length) == length + && process_exif(exifData, length) == B_OK) + return B_OK; + } else { + // ignore section + stream.Seek(length - 2, SEEK_CUR); + } + } + + return B_BAD_VALUE; +} + + +static status_t +process_file(entry_ref& ref) +{ + BFile file(&ref, B_READ_WRITE); + status_t status = file.InitCheck(); + if (status != B_OK) + return status; + + // read EXIF + + BBufferIO stream(&file, 65536, false); + status = process_jpeg(file); + if (status < B_OK) { + fprintf(stderr, "%s: processing JPEG file failed: %s\n", ref.name, + strerror(status)); + return status; + } + + return B_OK; +} + + +int +main(int argc, char **argv) +{ + for (int i = 1; i < argc; i++) { + BEntry entry(argv[i]); + entry_ref ref; + if (entry.InitCheck() != B_OK || entry.GetRef(&ref) != B_OK) + continue; + + process_file(ref); + } + return -1; +} From axeld at mail.berlios.de Sun May 11 14:28:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 May 2008 14:28:02 +0200 Subject: [Haiku-commits] r25447 - in haiku/trunk/src: add-ons/translators/jpeg tests/add-ons/translators/exif Message-ID: <200805111228.m4BCS21Z021039@sheep.berlios.de> Author: axeld Date: 2008-05-11 14:28:01 +0200 (Sun, 11 May 2008) New Revision: 25447 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25447&view=rev Modified: haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp Log: * The EXIF parser now keeps a set of visited offsets to avoid entering endless loops with corrupted data. * This fixes bug #2206. Modified: haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp 2008-05-11 12:08:15 UTC (rev 25446) +++ haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp 2008-05-11 12:28:01 UTC (rev 25447) @@ -1,20 +1,21 @@ /* - * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. */ #include "exif_parser.h" -#include - -#include - #include +#include #include #include +#include +#include + + enum { TAG_EXIF_OFFSET = 0x8769, TAG_SUB_DIR_OFFSET = 0xa005, @@ -37,8 +38,8 @@ / sizeof(kDefaultTags[0]); -static status_t parse_tiff_directory(TReadHelper& read, BMessage& target, - const convert_tag* tags, size_t tagCount); +static status_t parse_tiff_directory(TReadHelper& read, set& visited, + BMessage& target, const convert_tag* tags, size_t tagCount); static status_t @@ -226,10 +227,16 @@ static status_t -parse_tiff_directory(TReadHelper& read, off_t offset, BMessage& target, - const convert_tag* convertTags, size_t convertTagCount) +parse_tiff_directory(TReadHelper& read, set& visited, off_t offset, + BMessage& target, const convert_tag* convertTags, size_t convertTagCount) { + if (visited.find(offset) != visited.end()) { + // The EXIF data is obviously corrupt + return B_BAD_DATA; + } + read.Seek(offset, SEEK_SET); + visited.insert(offset); uint16 tags; read(tags); @@ -247,7 +254,7 @@ case TAG_EXIF_OFFSET: case TAG_SUB_DIR_OFFSET: { - status_t status = parse_tiff_directory(read, target, + status_t status = parse_tiff_directory(read, visited, target, convertTags, convertTagCount); if (status < B_OK) return status; @@ -263,7 +270,12 @@ } break; } + + if (visited.find(nextOffset) != visited.end()) + return B_BAD_DATA; + read.Seek(nextOffset, SEEK_SET); + visited.insert(nextOffset); } return B_OK; @@ -271,7 +283,7 @@ static status_t -parse_tiff_directory(TReadHelper& read, BMessage& target, +parse_tiff_directory(TReadHelper& read, set& visited, BMessage& target, const convert_tag* tags, size_t tagCount) { while (true) { @@ -280,7 +292,7 @@ if (offset == 0) break; - status_t status = parse_tiff_directory(read, offset, target, + status_t status = parse_tiff_directory(read, visited, offset, target, tags, tagCount); if (status < B_OK) return status; @@ -293,6 +305,11 @@ // #pragma mark - +/*! Converts the EXIF data that starts in \a source to a BMessage in \a target. + If the EXIF data is corrupt, this function will return an appropriate error + code. Nevertheless, there might be some data ending up in \a target that + was parsed until this point. +*/ status_t convert_exif_to_message(BPositionIO& source, BMessage& target, const convert_tag* tags, size_t tagCount) @@ -315,7 +332,8 @@ if (magic != 42) return B_BAD_TYPE; - return parse_tiff_directory(read, target, tags, tagCount); + set visitedOffsets; + return parse_tiff_directory(read, visitedOffsets, target, tags, tagCount); } Modified: haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp =================================================================== --- haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp 2008-05-11 12:08:15 UTC (rev 25446) +++ haiku/trunk/src/tests/add-ons/translators/exif/dump_exif.cpp 2008-05-11 12:28:01 UTC (rev 25447) @@ -27,9 +27,10 @@ BMemoryIO source(data + 8, length - 8); BMessage exif; status_t status = convert_exif_to_message(source, exif); - if (status == B_OK) - exif.PrintToStream(); + exif.PrintToStream(); + // even if it failed, some data might end up in the message + return status; } From dlmcpaul at mail.berlios.de Sun May 11 15:09:55 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Sun, 11 May 2008 15:09:55 +0200 Subject: [Haiku-commits] r25448 - in haiku/trunk/src/add-ons/media/plugins/mov_reader: . libMOV Message-ID: <200805111309.m4BD9tjk023045@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-11 15:09:54 +0200 (Sun, 11 May 2008) New Revision: 25448 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25448&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp Log: Hardcode IMA4 sound description Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp 2008-05-11 12:28:01 UTC (rev 25447) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVFileReader.cpp 2008-05-11 13:09:54 UTC (rev 25448) @@ -457,13 +457,26 @@ // Hmm 16bit format 32 bit FourCC. theAudio.compression = aSoundDescription.basefields.DataFormat; -// theAudio.compression = aSoundDescription.desc.CompressionID; theAudio.NoOfChannels = aSoundDescription.desc.NoOfChannels; theAudio.SampleSize = aSoundDescription.desc.SampleSize; theAudio.SampleRate = aSoundDescription.desc.SampleRate / 65536; // Convert from fixed point decimal to float - theAudio.PacketSize = uint32((theAudio.SampleRate * theAudio.NoOfChannels * theAudio.SampleSize) / 8); + if (aSoundDescription.bytesPerFrame == 0) { + // XXX probably not right + theAudio.FrameSize = aSoundDescription.desc.SampleSize / 8; + } else { + theAudio.FrameSize = aSoundDescription.bytesPerFrame; + } + + if (aSoundDescription.bytesPerPacket == 0) { + theAudio.BufferSize = uint32((theAudio.SampleSize * theAudio.NoOfChannels * theAudio.FrameSize) / 8); + } else { + theAudio.BufferSize = aSoundDescription.bytesPerPacket; + } + + theAudio.BitRate = theAudio.SampleSize * theAudio.NoOfChannels * theAudio.SampleRate; + theAudio.theVOL = aSoundDescription.theVOL; theAudio.VOLSize = aSoundDescription.VOLSize; Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp 2008-05-11 12:28:01 UTC (rev 25447) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp 2008-05-11 13:09:54 UTC (rev 25448) @@ -816,7 +816,8 @@ Read(&aSoundDescriptionV1->desc.PacketSize); Read(&aSoundDescriptionV1->desc.SampleRate); - if (aSoundDescriptionV1->desc.Version == 1) { + if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) { + printf("V1 Sound Description Found\n"); Read(&(aSoundDescriptionV1->samplesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerFrame)); @@ -824,14 +825,20 @@ } else { // Calculate? - aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; - if (aSoundDescriptionV1->basefields.DataFormat == 'ima4') { - aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 64 / 34; + if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) { + printf("Calculating IMA4 Sound Description\n"); + aSoundDescriptionV1->samplesPerPacket = 64; + aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34; + + aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; + aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame; } else { + printf("Calculating Sound Description\n"); + aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample; + aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize; + aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame; } - aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize; - aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame; } // 0 means we dont have one Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h 2008-05-11 12:28:01 UTC (rev 25447) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/QTStructs.h 2008-05-11 13:09:54 UTC (rev 25448) @@ -105,11 +105,13 @@ struct AudioMetaData { - uint32 compression; // compression used + uint32 compression; // compression type used uint16 NoOfChannels; // 1 = mono, 2 = stereo uint16 SampleSize; // bits per sample - float SampleRate; // Samples per second (OR Frames per second) - uint32 PacketSize; // (Sample Rate * NoOfchannels * SampleSize)/8 = bytes per second + float SampleRate; // Samples per second + uint32 BufferSize; // (Sample Rate * NoOfchannels * SampleSize) / 8 = bytes per second + uint32 FrameSize; // Size of a Frame (NoOfChannels * SampleSize) / 8 + float BitRate; // Bitrate of audio uint8 *theVOL; size_t VOLSize; }; Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-11 12:28:01 UTC (rev 25447) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-11 13:09:54 UTC (rev 25448) @@ -34,7 +34,7 @@ #include "mov_reader.h" -//#define TRACE_MOV_READER +#define TRACE_MOV_READER #ifdef TRACE_MOV_READER #define TRACE printf #else @@ -136,6 +136,8 @@ status_t movReader::AllocateCookie(int32 streamNumber, void **_cookie) { + uint32 codecID; + mov_cookie *cookie = new mov_cookie; *_cookie = cookie; @@ -172,6 +174,8 @@ return B_ERROR; } + codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression); + cookie->frame_count = theFileReader->getAudioFrameCount(cookie->stream); cookie->duration = theFileReader->getAudioDuration(cookie->stream); @@ -191,10 +195,10 @@ cookie->frames_per_sec_rate = stream_header->rate; cookie->frames_per_sec_scale = 1; TRACE("bytes_per_sec_rate %ld, bytes_per_sec_scale %ld (using rate)\n", cookie->bytes_per_sec_rate, cookie->bytes_per_sec_scale); - } else if (audio_format->PacketSize) { - cookie->bytes_per_sec_rate = audio_format->PacketSize; + } else if (audio_format->BufferSize) { + cookie->bytes_per_sec_rate = audio_format->BufferSize; cookie->bytes_per_sec_scale = 1; - cookie->frames_per_sec_rate = audio_format->PacketSize * 8 / audio_format->SampleSize / audio_format->NoOfChannels; + cookie->frames_per_sec_rate = audio_format->BufferSize * 8 / audio_format->SampleSize / audio_format->NoOfChannels; cookie->frames_per_sec_scale = 1; TRACE("bytes_per_sec_rate %ld, bytes_per_sec_scale %ld (using PacketSize)\n", cookie->bytes_per_sec_rate, cookie->bytes_per_sec_scale); } else { @@ -259,6 +263,26 @@ format->type = B_MEDIA_ENCODED_AUDIO; } + format->u.raw_audio.byte_order = B_MEDIA_BIG_ENDIAN; + + if (audio_format->SampleSize <= 8) + format->u.raw_audio.format = B_AUDIO_FORMAT_UINT8; + else if (audio_format->SampleSize <= 16) + format->u.raw_audio.format = B_AUDIO_FORMAT_INT16; + else if (audio_format->SampleSize <= 24) + format->u.raw_audio.format = B_AUDIO_FORMAT_INT24; + else if (audio_format->SampleSize <= 32) + format->u.raw_audio.format = B_AUDIO_FORMAT_INT32; + else { + ERROR("movReader::AllocateCookie: unhandled bits per sample %d\n", audio_format->SampleSize); + return B_ERROR; + } + + format->u.encoded_audio.frame_size = audio_format->FrameSize; + format->u.encoded_audio.output.buffer_size = audio_format->BufferSize; + + TRACE("compression "); + switch (audio_format->compression) { case AUDIO_MS_PCM02: TRACE("MS PCM02\n"); @@ -280,9 +304,13 @@ format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; break; case AUDIO_IMA4: - + TRACE("IMA4\n"); + format->u.encoded_audio.bit_rate = audio_format->BitRate; + format->u.encoded_audio.output.frame_rate = cookie->frames_per_sec_rate / cookie->frames_per_sec_scale;; + format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; + break; default: - TRACE("OTHER\n"); + TRACE("OTHER %s\n",(char *)(&codecID)); format->u.encoded_audio.bit_rate = 8 * cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; format->u.encoded_audio.output.frame_rate = cookie->frames_per_sec_rate / cookie->frames_per_sec_scale; format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; @@ -290,22 +318,18 @@ } } - // this doesn't seem to work (it's not even a fourcc) - format->user_data_type = B_CODEC_TYPE_INFO; - *(uint32 *)format->user_data = audio_format->compression; format->user_data[4] = 0; + TRACE("Audio NoOfChannels %d, SampleSize %d, SampleRate %f, FrameSize %ld\n",audio_format->NoOfChannels, audio_format->SampleSize, audio_format->SampleRate, audio_format->FrameSize); + + TRACE("Audio frame_rate %f, channel_count %ld, format %ld, buffer_size %ld, frame_size %ld, bit_rate %f\n", + format->u.encoded_audio.output.frame_rate, format->u.encoded_audio.output.channel_count, format->u.encoded_audio.output.format,format->u.encoded_audio.output.buffer_size, format->u.encoded_audio.frame_size, format->u.encoded_audio.bit_rate); // Some codecs have additional setup data that they need, put it in metadata size_t size = audio_format->VOLSize; const void *data = audio_format->theVOL; if (size > 0) { + TRACE("VOL SIZE %ld\n", size); format->SetMetaData(data, size); } - -#ifdef TRACE_MOV_READER - uint8 *p = 18 + (uint8 *)data; - TRACE("extra_data: %ld: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - size - 18, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]); -#endif return B_OK; } @@ -318,6 +342,8 @@ return B_ERROR; } + codecID = B_BENDIAN_TO_HOST_INT32(video_format->compression); + cookie->audio = false; cookie->line_count = theFileReader->MovMainHeader()->height; @@ -340,7 +366,7 @@ TRACE("frame_count %Ld\n", cookie->frame_count); TRACE("duration %.6f (%Ld)\n", cookie->duration / 1E6, cookie->duration); - TRACE("compression %s\n", (char *)(&video_format->compression)); + TRACE("compression %s\n", (char *)(&codecID)); description.family = B_QUICKTIME_FORMAT_FAMILY; if (stream_header->fourcc_handler == 'ekaf' || stream_header->fourcc_handler == 0) // 'fake' or 0 fourcc => used compression id From mmlr at mlotz.ch Sun May 11 15:11:35 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Sun, 11 May 2008 15:11:35 +0200 Subject: [Haiku-commits] r25439 - in haiku/trunk/src/add-ons/kernel/drivers/network: . usb_ecm In-Reply-To: <20080511114559.750.1@stippis2.1210496147.fake> References: <200805102350.m4ANohSS021576@sheep.berlios.de> <20080511114559.750.1@stippis2.1210496147.fake> Message-ID: <20080511125018.M81981@mlotz.ch> On Sun, 11 May 2008 11:45:59 +0200, Stephan Assmus wrote > your driver writing skills are pretty cool! I find it very easy to > follow your code. Here are the only things that I spotted: Thanks, you get used to it ;-). And this kind of device makes writing drivers pretty easy. Basically this simply puts anything coming from the network stack into a USB transfer and vice versa. And since our USB and network stacks are pretty straight forward, this really makes it simple to develop such drivers. >> + uint8 controlIndex = 0; >> + uint8 dataIndex = 0; >> + bool foundUnionDescriptor = false; >> + bool foundEthernetDescriptor = false; >> + for (size_t i = 0; i < config->interface_count >> + && (!foundUnionDescriptor || !foundEthernetDescriptor); i++) { >> + usb_interface_info *interface = config->interface[i].active; >> + usb_interface_descriptor *descriptor = interface->descr; >> + if (descriptor->interface_class == USB_INTERFACE_CLASS_CDC >> + && descriptor->interface_subclass == >> USB_INTERFACE_SUBCLASS_ECM >> + && interface->generic_count > 0) { >> + // try to find and interpret the union and ethernet >> functional >> + // descriptors >> + for (size_t j = 0; j < interface->generic_count; j++) { >> + usb_generic_descriptor *generic = >> &interface->generic[j]->generic; >> + if (generic->length >= 5 >> + && generic->data[0] == FUNCTIONAL_SUBTYPE_UNION) { >> + controlIndex = generic->data[1]; >> + dataIndex = generic->data[2]; >> + foundUnionDescriptor = true; >> + } else if (generic->length >= >> sizeof(ethernet_functional_descriptor) >> + && generic->data[0] == FUNCTIONAL_SUBTYPE_ETHERNET) { >> + ethernet_functional_descriptor *ethernet >> + = (ethernet_functional_descriptor >> *)generic->data; >> + fMACAddressIndex = ethernet->mac_address_index; >> + fMaxSegmentSize = ethernet->max_segment_size; >> + foundEthernetDescriptor = true; >> + } >> + >> + if (foundUnionDescriptor && foundEthernetDescriptor) >> + break; > > You could probably simplify some redundant checks above. I don't know to which checks you are referring to now. You mean because of control and data index? They may actually be 0, so I don't want to use them instead of the bools. Also I want to ensure that I find both of those headers. The (foundUnionDescriptor && foundEthernetDescriptor) are there because they break out of two different loops in case you referred to that one. In fact I just spotted a bug there where the union descriptors might be spread across different interfaces without the driver noticing ;-). > ... > Are you not handling B_INTERRUPTED on purpose? > ... > Same here. In fact I am. I want these calls to be interruptible. The network stack will simply retry when they fail, so nothing is lost in those cases. > Last question: how is the driver being picked up as a network driver? That depends a bit. It will publish the "/dev/net/usb_ecm/x" device(s) when you plug in a compatible device (interface class 2, subclass 6, protocol 0). Under Haiku they do not get picked up automatically though. You would have to use "ifconfig /dev/net/usb_ecm/x ... up" to get it working when plugging in at runtime. It appears though that anything else than static ip configuration does not really work. The network preferences refused to enable DHCP for me and there is no command line app to do that under Haiku AFAIK. This problem is probably caused by having two network devices. I think a bug report exists for that one. The easiest should be if you have it plugged in at boot and as your only network device. In this case it should behave just like a network card would and you should be able to configure and use it as you would with any other network device. Due to my cell phone data connection requiring DHCP and the above mentioned problem, I only used it successfully under BONE though, so it might be that it does not work under Haiku at all. I was only able to verify that it gets published and apparently started "some" traffic. Regards Michael From revol at free.fr Sun May 11 16:44:52 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 16:44:52 +0200 CEST Subject: [Haiku-commits] r25385 - haiku/trunk/headers/os/support In-Reply-To: <12538928882-BeMail@zon> Message-ID: <1247298966-BeMail@laptop> > "Fran?ois Revol" wrote: > > Still we should try to make our point heard and try to change the > > standard back. > > Any idea on how to do that? Surely you and I know someone at our old university who are or were at some standardization commitee. I recall someone who was at ANSI. They usually just meet to defend their own national view and chat a lot and drink coffee, so if we can get them do something useful... Also there is certainly a procedure to contest or ask to ammend the standards. Anyone feels like digging the opengroup site ? Fran?ois. From revol at free.fr Sun May 11 17:12:39 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:12:39 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25439_-_in_haiku/trunk/src/add-?= =?windows-1252?q?ons/kernel/drivers/network=3A_=2E_usb=5Fecm?= In-Reply-To: <200805102350.m4ANohSS021576@sheep.berlios.de> Message-ID: <2914079132-BeMail@laptop> > Adding USB ECM (Ethernet Control Model) driver. This driver should > support > devices of the CDC class (2 - communication) with ECM subclass (6) > interfaces. Oh, nice, I shall try this with my DSL modem (FreeBox) which has a USB port. Not that useful as it has an ethernet port too but eh :) Fran?ois. From revol at free.fr Sun May 11 17:15:28 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:15:28 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <3083749437-BeMail@laptop> > On 5/10/08, mmu_man at BerliOS wrote: > > > > Sources for Matthijs Hollemans' WebWatch app > > I really don't think this belongs in our repo. The idea of "beats" to > measure time is cute and all, and the code looks fine, but I don't > see > this as something we would want to include with Haiku. I think there > are plenty of other apps and demos in Haiku that demonstrate features > included in this. > > I think we need to be more strict about what we put in our repo. > > But this code could be part of a greater BeOS demo/sample code pack, > which I plan to put together eventually. That will be pretty much > independent of Haiku and the Haiku repo. > Well I didn't feel like creating a depot on osdrawer just for this. Once you have some other place set up for sample code it can easily be moved there. Meanwhile it makes sure it's available somewhere (the author's site seems down). Fran?ois. From revol at free.fr Sun May 11 17:18:20 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:18:20 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <48265E40.8030305@digintrans.com> Message-ID: <3255291798-BeMail@laptop> > Ryan Leavengood wrote: > > On 5/10/08, mmu_man at BerliOS wrote: > > > >> Sources for Matthijs Hollemans' WebWatch app > >> > > > > I really don't think this belongs in our repo. The idea of "beats" > > to > > measure time is cute and all, and the code looks fine, but I don't > > see > > this as something we would want to include with Haiku. I think > > there > > are plenty of other apps and demos in Haiku that demonstrate > > features > > included in this. > > > > I think we need to be more strict about what we put in our repo. > > > > But this code could be part of a greater BeOS demo/sample code > > pack, > > which I plan to put together eventually. That will be pretty much > > independent of Haiku and the Haiku repo. > > > > The sources being in the Haiku repo does not necessarily equate to > the > app being included in the eventual official Haiku distro(s). Exactly. > IMHO, there is value in keeping this sort of code where anyone can > easily access it, so why not leave it in the Haiku repo for now? There is actually a 3rdparty/ folder also, maybe it can be moved there too. > If/when you (or anybody else for that matter) eventually put(s) > together > a demo/sample pack, then it can be migrated/removed. I opened an osdrawer project for VNCviewer but this one was too small just for that. Meanwhile it provides a place where it can be updated and history is kept. Fran?ois. From revol at free.fr Sun May 11 17:20:14 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:20:14 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <569173682-BeMail@zon> Message-ID: <3369638322-BeMail@laptop> > "Ryan Leavengood" wrote: > > But this code could be part of a greater BeOS demo/sample code > > pack, > > which I plan to put together eventually. That will be pretty much > > independent of Haiku and the Haiku repo. > > Does speak anything against maintaing that sample code pack in the > Haiku repository? Of course, those apps shouldn't end up in src/apps/ > > but a special directory. > 3rdparty/samplecode/ ? Fran?ois. From revol at free.fr Sun May 11 17:21:57 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:21:57 +0200 CEST Subject: [Haiku-commits] r25439 - in haiku/trunk/src/add-ons/kernel/drivers/network: . usb_ecm In-Reply-To: <20080511114559.750.1@stippis2.1210496147.fake> Message-ID: <3472660441-BeMail@laptop> > Hi Michael, > > your driver writing skills are pretty cool! I find it very easy to > follow Hey, I can cheat using C++ too ! ;) Fran?ois. From leavengood at gmail.com Sun May 11 17:27:16 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Sun, 11 May 2008 11:27:16 -0400 Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <569173682-BeMail@zon> References: <569173682-BeMail@zon> Message-ID: On 5/11/08, Axel D?rfler wrote: > > Does speak anything against maintaing that sample code pack in the > Haiku repository? Of course, those apps shouldn't end up in src/apps/ > but a special directory. No, I want to use Git for the sample code project because I prefer that tool to SVN and I think it is more appropriate for this sort of project. I will then host it on either gitorious.org or github.com. Plus the Haiku svn repo is already ridiculously big and almost unmanageable and I do not want to make it worse. Ryan From revol at free.fr Sun May 11 17:30:29 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 17:30:29 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <3984558313-BeMail@laptop> > On 5/11/08, Axel D?rfler wrote: > > > > Does speak anything against maintaing that sample code pack in the > > Haiku repository? Of course, those apps shouldn't end up in src/ > > apps/ > > but a special directory. > > No, I want to use Git for the sample code project because I prefer > that tool to SVN and I think it is more appropriate for this sort of > project. I will then host it on either gitorious.org or github.com. > > Plus the Haiku svn repo is already ridiculously big and almost > unmanageable and I do not want to make it worse. Noone forces you to svn co trunk/ you can checkout only trunk/3rdparty/ samplecode/ if you need it. (only building with jam won't work). Fran?ois. From axeld at pinc-software.de Sun May 11 17:33:43 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 17:33:43 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25439_-_in_haiku/trunk/src/add-ons/ker?= =?utf-8?q?nel/drivers/network=3A_=2E_usb=5Fecm?= In-Reply-To: <20080511125018.M81981@mlotz.ch> Message-ID: <25522425049-BeMail@zon> "Michael Lotz" wrote: > > Last question: how is the driver being picked up as a network > > driver? > That depends a bit. It will publish the "/dev/net/usb_ecm/x" > device(s) when > you plug in a compatible device (interface class 2, subclass 6, > protocol 0). > Under Haiku they do not get picked up automatically though. You would > have to > use "ifconfig /dev/net/usb_ecm/x ... up" to get it working when > plugging in at > runtime. It appears though that anything else than static ip > configuration > does not really work. The network preferences refused to enable DHCP > for me > and there is no command line app to do that under Haiku AFAIK. This > problem is > probably caused by having two network devices. I think a bug report > exists for > that one. Actually, that one should be fixed already (IIRC :-)). The problem in this case is just that the net_server does only scan the devices once, and does not yet support node monitoring. Restarting the net_server should do the trick for now. If you want to add node monitoring to the net_server, feel free to do so, otherwise I put that on my list, too (I didn't really think about pluggable net devices when I wrote it, else I would probably have already integrated it) :-) In any case, there is a (still private) BPathMonitor class that waits to be used. DHCP currently also only works when the net_server is started. That's another thing I wanted to change, but I don't know yet if we want to have an API for that, or just use messaging. Bye, Axel. From axeld at pinc-software.de Sun May 11 17:52:33 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 17:52:33 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <26652176509-BeMail@zon> "Ryan Leavengood" wrote: > On 5/11/08, Axel D?rfler wrote: > > Does speak anything against maintaing that sample code pack in the > > Haiku repository? Of course, those apps shouldn't end up in src/ > > apps/ > > but a special directory. > No, I want to use Git for the sample code project because I prefer > that tool to SVN and I think it is more appropriate for this sort of > project. I will then host it on either gitorious.org or github.com. I don't know. For me, a tool like Git is only really useful if you don't always have access to the actual repository, or if you want to manage more than one tree for whatever reasons (and don't want to use the usual branches for this). Otherwise, I don't really see any advantages, so at least I don't see any with regards to a sample code repository. But I don't really have used git for more than the occasional checkout (but I have to say it's a lot less intuitive to use than other tools I used so far). > Plus the Haiku svn repo is already ridiculously big and almost > unmanageable and I do not want to make it worse. It certainly blows BerliOS limits quite a bit, but I don't really know what you mean by unmanageable. Bye, Axel. From bonefish at mail.berlios.de Sun May 11 17:56:42 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 11 May 2008 17:56:42 +0200 Subject: [Haiku-commits] r25449 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200805111556.m4BFug5t001298@sheep.berlios.de> Author: bonefish Date: 2008-05-11 17:56:42 +0200 (Sun, 11 May 2008) New Revision: 25449 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25449&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: Small test program triggering a self-deadlock in the memory allocator when a signal handler that itself uses the allocator is invoked while the thread originally was in the allocator. Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-05-11 13:09:54 UTC (rev 25448) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-05-11 15:56:42 UTC (rev 25449) @@ -24,6 +24,10 @@ : setjmp_test2.S ; +SimpleTest signal_in_allocator_test + : signal_in_allocator_test.cpp +; + SimpleTest signal_test : signal_test.cpp ; Added: haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test.cpp 2008-05-11 13:09:54 UTC (rev 25448) +++ haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test.cpp 2008-05-11 15:56:42 UTC (rev 25449) @@ -0,0 +1,78 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include +#include + +#include + + +static int64 sHandledSignals = 0; + + +static status_t +signal_pusher(void* data) +{ + team_info teamInfo; + get_team_info(B_CURRENT_TEAM, &teamInfo); + thread_id mainThread = teamInfo.team; + + while (true) { + send_signal(mainThread, SIGUSR1); + snooze(1000); + } + + return B_OK; +} + + +static void +signal_handler(int signal) +{ + free(malloc(10)); + sHandledSignals++; +} + + +int +main() +{ + const int testSeconds = 2; + printf("Trying to provoke allocator deadlock in signal handler.\n"); + printf("If successful test will finish in %d seconds...\n", testSeconds); + + // install signal handler + if (signal(SIGUSR1, signal_handler) == SIG_ERR) { + fprintf(stderr, "Error: Failed to install signal handler: %s\n", + strerror(errno)); + exit(1); + } + + // start signal thread + thread_id signalThread = spawn_thread(&signal_pusher, "signal pusher", + B_NORMAL_PRIORITY, NULL); + resume_thread(signalThread); + + bigtime_t endTime = system_time() + 1000000 * (bigtime_t)testSeconds; + while (system_time() < endTime) { + const int allocationCount = 1000; + void* allocations[allocationCount]; + for (int i = 0; i < allocationCount; i++) + allocations[i] = malloc(rand() % 50); + for (int i = 0; i < allocationCount; i++) + free(allocations[i]); + } + + kill_thread(signalThread); + snooze(1000); + + printf("test successful, handled %lld signals\n", sHandledSignals); + + return 0; +} From anevilyak at gmail.com Sun May 11 17:59:01 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 11 May 2008 10:59:01 -0500 Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <26652176509-BeMail@zon> References: <26652176509-BeMail@zon> Message-ID: On Sun, May 11, 2008 at 10:52 AM, Axel D?rfler wrote: > I don't know. For me, a tool like Git is only really useful if you > don't always have access to the actual repository, or if you want to > manage more than one tree for whatever reasons (and don't want to use > the usual branches for this). Otherwise, I don't really see any > advantages, so at least I don't see any with regards to a sample code > repository. But I don't really have used git for more than the > occasional checkout (but I have to say it's a lot less intuitive to use > than other tools I used so far). I keep a git-svn clone of the haiku repository on one of my servers at home. I usually find it quite handy if I want to check the logs for something or whatnot, since it's several orders of magnitude faster than doing pretty much anything with berlios over here in the US. > It certainly blows BerliOS limits quite a bit, but I don't really know > what you mean by unmanageable. BerliOS don't have a problem with that? What are the theoretical limits anyhow? Regards, Rene From bonefish at mail.berlios.de Sun May 11 18:02:14 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 11 May 2008 18:02:14 +0200 Subject: [Haiku-commits] r25450 - in haiku/trunk: headers/private/kernel src/system/kernel/vm Message-ID: <200805111602.m4BG2ELt001836@sheep.berlios.de> Author: bonefish Date: 2008-05-11 18:02:13 +0200 (Sun, 11 May 2008) New Revision: 25450 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25450&view=rev Modified: haiku/trunk/headers/private/kernel/vm.h haiku/trunk/src/system/kernel/vm/vm.cpp Log: Added new private area protection flag B_KERNEL_AREA, which prevents all changes to the area (delete, resize, clone) from userland. Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2008-05-11 15:56:42 UTC (rev 25449) +++ haiku/trunk/headers/private/kernel/vm.h 2008-05-11 16:02:13 UTC (rev 25450) @@ -44,14 +44,16 @@ (B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_KERNEL_EXECUTE_AREA \ | B_KERNEL_STACK_AREA) +// TODO: These aren't really a protection flags, but since the "protection" +// field is the only flag field, we currently use it for this. +// A cleaner approach would be appreciated - maybe just an official generic +// flags region in the protection field. #define B_OVERCOMMITTING_AREA 0x1000 #define B_SHARED_AREA 0x2000 - // TODO: These aren't really a protection flags, but since the "protection" - // field is the only flag field, we currently use it for this. - // A cleaner approach would be appreciated - maybe just an official generic - // flags region in the protection field. +#define B_KERNEL_AREA 0x4000 + // Usable from userland according to its protection flags, but the area + // itself is not deletable, resizable, etc from userland. - #define B_USER_AREA_FLAGS (B_USER_PROTECTION) #define B_KERNEL_AREA_FLAGS \ (B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA \ @@ -110,7 +112,7 @@ uint32 addressSpec, addr_t size, uint32 flags); area_id vm_create_anonymous_area(team_id team, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection, - bool unmapAddressRange); + bool unmapAddressRange, bool kernel); area_id vm_map_physical_memory(team_id team, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 protection, addr_t phys_addr); area_id vm_map_file(team_id aid, const char *name, void **address, @@ -124,8 +126,8 @@ uint32 addressSpec, uint32 protection, area_id sourceID); area_id vm_clone_area(team_id team, const char *name, void **address, uint32 addressSpec, uint32 protection, uint32 mapping, - area_id sourceArea); -status_t vm_delete_area(team_id teamID, area_id areaID); + area_id sourceArea, bool kernel); +status_t vm_delete_area(team_id teamID, area_id areaID, bool kernel); status_t vm_create_vnode_cache(struct vnode *vnode, struct vm_cache **_cache); struct vm_area *vm_area_lookup(struct vm_address_space *addressSpace, addr_t address); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-11 15:56:42 UTC (rev 25449) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-11 16:02:13 UTC (rev 25450) @@ -1194,7 +1194,8 @@ NOTE: At the moment deleting only complete areas is supported. */ static status_t -unmap_address_range(vm_address_space *addressSpace, addr_t address, addr_t size) +unmap_address_range(vm_address_space *addressSpace, addr_t address, addr_t size, + bool kernel) { // TODO: Support deleting partial areas! @@ -1210,7 +1211,24 @@ if (area != NULL && lastAddress - area->base < area->size - 1) return B_UNSUPPORTED; - // all areas (if any) are fully covered; let's delete them + // all areas (if any) are fully covered; we can delete them, + // but first we need to check, whether the caller is allowed to do that + if (!kernel) { + area = addressSpace->areas; + while (area != NULL) { + vm_area* nextArea = area->address_space_next; + + if (area->id != RESERVED_AREA_ID) { + if (area->base >= address && area->base < lastAddress) { + if ((area->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + } + } + + area = nextArea; + } + } + area = addressSpace->areas; while (area != NULL) { vm_area* nextArea = area->address_space_next; @@ -1235,7 +1253,7 @@ map_backing_store(vm_address_space *addressSpace, vm_cache *cache, void **_virtualAddress, off_t offset, addr_t size, uint32 addressSpec, int wiring, int protection, int mapping, vm_area **_area, - const char *areaName, bool unmapAddressRange) + const char *areaName, bool unmapAddressRange, bool kernel) { TRACE(("map_backing_store: aspace %p, cache %p, *vaddr %p, offset 0x%Lx, size %lu, addressSpec %ld, wiring %d, protection %d, _area %p, area_name '%s'\n", addressSpace, cache, *_virtualAddress, offset, size, addressSpec, @@ -1298,7 +1316,7 @@ if (addressSpec == B_EXACT_ADDRESS && unmapAddressRange) { status = unmap_address_range(addressSpace, (addr_t)*_virtualAddress, - size); + size, kernel); if (status != B_OK) goto err2; } @@ -1429,7 +1447,7 @@ area_id vm_create_anonymous_area(team_id team, const char *name, void **address, uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection, - bool unmapAddressRange) + bool unmapAddressRange, bool kernel) { vm_area *area; vm_cache *cache; @@ -1533,7 +1551,7 @@ status = map_backing_store(addressSpace, cache, address, 0, size, addressSpec, wiring, protection, REGION_NO_PRIVATE_MAP, &area, name, - unmapAddressRange); + unmapAddressRange, kernel); mutex_unlock(&cache->lock); @@ -1747,7 +1765,7 @@ status_t status = map_backing_store(locker.AddressSpace(), cache, _address, 0, size, addressSpec & ~B_MTR_MASK, B_FULL_LOCK, protection, - REGION_NO_PRIVATE_MAP, &area, name, false); + REGION_NO_PRIVATE_MAP, &area, name, false, true); mutex_unlock(&cache->lock); @@ -1829,7 +1847,7 @@ status = map_backing_store(locker.AddressSpace(), cache, address, 0, size, addressSpec, 0, B_KERNEL_READ_AREA, REGION_NO_PRIVATE_MAP, &area, name, - false); + false, true); mutex_unlock(&cache->lock); @@ -1897,7 +1915,7 @@ if (fd < 0) { return vm_create_anonymous_area(team, name, _address, addressSpec, size, - B_NO_LOCK, protection, addressSpec == B_EXACT_ADDRESS); + B_NO_LOCK, protection, addressSpec == B_EXACT_ADDRESS, kernel); } // get the open flags of the FD @@ -1938,7 +1956,7 @@ vm_area *area; status = map_backing_store(locker.AddressSpace(), cache, _address, offset, size, addressSpec, 0, protection, mapping, &area, name, - addressSpec == B_EXACT_ADDRESS); + addressSpec == B_EXACT_ADDRESS, kernel); mutex_unlock(&cache->lock); @@ -1998,7 +2016,8 @@ area_id vm_clone_area(team_id team, const char *name, void **address, - uint32 addressSpec, uint32 protection, uint32 mapping, area_id sourceID) + uint32 addressSpec, uint32 protection, uint32 mapping, area_id sourceID, + bool kernel) { vm_area *newArea = NULL; vm_area *sourceArea; @@ -2022,6 +2041,9 @@ if (sourceArea == NULL) return B_BAD_VALUE; + if (!kernel && (sourceArea->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + vm_cache *cache = vm_area_get_locked_cache(sourceArea); // ToDo: for now, B_USER_CLONEABLE is disabled, until all drivers @@ -2040,7 +2062,8 @@ else { status = map_backing_store(targetAddressSpace, cache, address, sourceArea->cache_offset, sourceArea->size, addressSpec, - sourceArea->wiring, protection, mapping, &newArea, name, false); + sourceArea->wiring, protection, mapping, &newArea, name, false, + kernel); } if (status == B_OK && mapping != REGION_PRIVATE_MAP) { // If the mapping is REGION_PRIVATE_MAP, map_backing_store() needed @@ -2164,7 +2187,7 @@ status_t -vm_delete_area(team_id team, area_id id) +vm_delete_area(team_id team, area_id id, bool kernel) { TRACE(("vm_delete_area(team = 0x%lx, area = 0x%lx)\n", team, id)); @@ -2174,6 +2197,9 @@ if (status < B_OK) return status; + if (!kernel && (area->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + delete_area(locker.AddressSpace(), area); return B_OK; } @@ -2303,7 +2329,7 @@ status = map_backing_store(targetAddressSpace, cache, _address, source->cache_offset, source->size, addressSpec, source->wiring, protection, sharedArea ? REGION_NO_PRIVATE_MAP : REGION_PRIVATE_MAP, - &target, name, false); + &target, name, false, true); if (status < B_OK) return status; @@ -2346,7 +2372,8 @@ static status_t -vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection) +vm_set_area_protection(team_id team, area_id areaID, uint32 newProtection, + bool kernel) { TRACE(("vm_set_area_protection(team = %#lx, area = %#lx, protection = %#lx)\n", team, areaID, newProtection)); @@ -2362,6 +2389,9 @@ &cache, true); AreaCacheLocker cacheLocker(cache); // already locked + if (!kernel && (area->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + if (area->protection == newProtection) return B_OK; @@ -4597,6 +4627,112 @@ } +static status_t +vm_resize_area(area_id areaID, size_t newSize, bool kernel) +{ + // is newSize a multiple of B_PAGE_SIZE? + if (newSize & (B_PAGE_SIZE - 1)) + return B_BAD_VALUE; + + // lock all affected address spaces and the cache + vm_area* area; + vm_cache* cache; + + MultiAddressSpaceLocker locker; + status_t status = locker.AddAreaCacheAndLock(areaID, true, true, area, + &cache); + if (status != B_OK) + return status; + AreaCacheLocker cacheLocker(cache); // already locked + + // enforce restrictions + if (!kernel) { + if ((area->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + // TODO: Enforce all restrictions (team, etc.)! + } + + size_t oldSize = area->size; + if (newSize == oldSize) + return B_OK; + + // Resize all areas of this area's cache + + if (cache->type != CACHE_TYPE_RAM) + return B_NOT_ALLOWED; + + if (oldSize < newSize) { + // We need to check if all areas of this cache can be resized + + for (vm_area* current = cache->areas; current != NULL; + current = current->cache_next) { + if (current->address_space_next + && current->address_space_next->base <= (current->base + + newSize)) { + // If the area was created inside a reserved area, it can + // also be resized in that area + // ToDo: if there is free space after the reserved area, it could be used as well... + vm_area *next = current->address_space_next; + if (next->id == RESERVED_AREA_ID + && next->cache_offset <= current->base + && next->base - 1 + next->size >= current->base - 1 + newSize) + continue; + + return B_ERROR; + } + } + } + + // Okay, looks good so far, so let's do it + + for (vm_area* current = cache->areas; current != NULL; + current = current->cache_next) { + if (current->address_space_next + && current->address_space_next->base <= (current->base + newSize)) { + vm_area *next = current->address_space_next; + if (next->id == RESERVED_AREA_ID + && next->cache_offset <= current->base + && next->base - 1 + next->size >= current->base - 1 + newSize) { + // resize reserved area + addr_t offset = current->base + newSize - next->base; + if (next->size <= offset) { + current->address_space_next = next->address_space_next; + free(next); + } else { + next->size -= offset; + next->base += offset; + } + } else { + status = B_ERROR; + break; + } + } + + current->size = newSize; + + // we also need to unmap all pages beyond the new size, if the area has shrinked + if (newSize < oldSize) { + vm_unmap_pages(current, current->base + newSize, oldSize - newSize, + false); + } + } + + if (status == B_OK) + status = vm_cache_resize(cache, newSize); + + if (status < B_OK) { + // This shouldn't really be possible, but hey, who knows + for (vm_area* current = cache->areas; current != NULL; + current = current->cache_next) { + current->size = oldSize; + } + } + + // TODO: we must honour the lock restrictions of this area + return status; +} + + // #pragma mark - kernel public API @@ -4980,106 +5116,14 @@ fix_protection(&newProtection); return vm_set_area_protection(vm_kernel_address_space_id(), area, - newProtection); + newProtection, true); } status_t resize_area(area_id areaID, size_t newSize) { - // is newSize a multiple of B_PAGE_SIZE? - if (newSize & (B_PAGE_SIZE - 1)) - return B_BAD_VALUE; - - // lock all affected address spaces and the cache - vm_area* area; - vm_cache* cache; - - MultiAddressSpaceLocker locker; - status_t status = locker.AddAreaCacheAndLock(areaID, true, true, area, - &cache); - if (status != B_OK) - return status; - AreaCacheLocker cacheLocker(cache); // already locked - - size_t oldSize = area->size; - if (newSize == oldSize) - return B_OK; - - // Resize all areas of this area's cache - - if (cache->type != CACHE_TYPE_RAM) - return B_NOT_ALLOWED; - - if (oldSize < newSize) { - // We need to check if all areas of this cache can be resized - - for (vm_area* current = cache->areas; current != NULL; - current = current->cache_next) { - if (current->address_space_next - && current->address_space_next->base <= (current->base - + newSize)) { - // If the area was created inside a reserved area, it can - // also be resized in that area - // ToDo: if there is free space after the reserved area, it could be used as well... - vm_area *next = current->address_space_next; - if (next->id == RESERVED_AREA_ID - && next->cache_offset <= current->base - && next->base - 1 + next->size >= current->base - 1 + newSize) - continue; - - return B_ERROR; - } - } - } - - // Okay, looks good so far, so let's do it - - for (vm_area* current = cache->areas; current != NULL; - current = current->cache_next) { - if (current->address_space_next - && current->address_space_next->base <= (current->base + newSize)) { - vm_area *next = current->address_space_next; - if (next->id == RESERVED_AREA_ID - && next->cache_offset <= current->base - && next->base - 1 + next->size >= current->base - 1 + newSize) { - // resize reserved area - addr_t offset = current->base + newSize - next->base; - if (next->size <= offset) { - current->address_space_next = next->address_space_next; - free(next); - } else { - next->size -= offset; - next->base += offset; - } - } else { - status = B_ERROR; - break; - } - } - - current->size = newSize; - - // we also need to unmap all pages beyond the new size, if the area has shrinked - if (newSize < oldSize) { - vm_unmap_pages(current, current->base + newSize, oldSize - newSize, - false); - } - } - - if (status == B_OK) - status = vm_cache_resize(cache, newSize); - - if (status < B_OK) { - // This shouldn't really be possible, but hey, who knows - for (vm_area* current = cache->areas; current != NULL; - current = current->cache_next) { - current->size = oldSize; - } - } - - // ToDo: we must honour the lock restrictions of this area - return status; + return vm_resize_area(areaID, newSize, true); } @@ -5090,7 +5134,8 @@ */ static area_id -transfer_area(area_id id, void **_address, uint32 addressSpec, team_id target) +transfer_area(area_id id, void **_address, uint32 addressSpec, team_id target, + bool kernel) { area_info info; status_t status = get_area_info(id, &info); @@ -5098,13 +5143,13 @@ return status; area_id clonedArea = vm_clone_area(target, info.name, _address, - addressSpec, info.protection, REGION_NO_PRIVATE_MAP, id); + addressSpec, info.protection, REGION_NO_PRIVATE_MAP, id, kernel); if (clonedArea < B_OK) return clonedArea; - status = vm_delete_area(info.team, id); + status = vm_delete_area(info.team, id, kernel); if (status < B_OK) { - vm_delete_area(target, clonedArea); + vm_delete_area(target, clonedArea, kernel); return status; } @@ -5134,7 +5179,7 @@ protection |= B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA; return vm_clone_area(vm_kernel_address_space_id(), name, _address, - addressSpec, protection, REGION_NO_PRIVATE_MAP, source); + addressSpec, protection, REGION_NO_PRIVATE_MAP, source, true); } @@ -5145,7 +5190,7 @@ fix_protection(&protection); return vm_create_anonymous_area(team->id, (char *)name, address, - addressSpec, size, lock, protection, false); + addressSpec, size, lock, protection, false, true); } @@ -5156,21 +5201,21 @@ fix_protection(&protection); return vm_create_anonymous_area(vm_kernel_address_space_id(), (char *)name, _address, - addressSpec, size, lock, protection, false); + addressSpec, size, lock, protection, false, true); } status_t delete_area_etc(struct team *team, area_id area) { - return vm_delete_area(team->id, area); + return vm_delete_area(team->id, area, true); } status_t delete_area(area_id area) { - return vm_delete_area(vm_kernel_address_space_id(), area); + return vm_delete_area(vm_kernel_address_space_id(), area, true); } @@ -5283,7 +5328,7 @@ fix_protection(&newProtection); return vm_set_area_protection(vm_current_user_address_space_id(), area, - newProtection); + newProtection, false); } @@ -5292,7 +5337,7 @@ { // ToDo: Since we restrict deleting of areas to those owned by the team, // we should also do that for resizing (check other functions, too). - return resize_area(area, newSize); + return vm_resize_area(area, newSize, false); } @@ -5311,7 +5356,7 @@ || user_memcpy(&address, userAddress, sizeof(address)) < B_OK) return B_BAD_ADDRESS; - area_id newArea = transfer_area(area, &address, addressSpec, target); + area_id newArea = transfer_area(area, &address, addressSpec, target, false); if (newArea < B_OK) return newArea; @@ -5347,7 +5392,7 @@ fix_protection(&protection); area_id clonedArea = vm_clone_area(vm_current_user_address_space_id(), name, &address, - addressSpec, protection, REGION_NO_PRIVATE_MAP, sourceArea); + addressSpec, protection, REGION_NO_PRIVATE_MAP, sourceArea, false); if (clonedArea < B_OK) return clonedArea; @@ -5389,7 +5434,8 @@ fix_protection(&protection); area_id area = vm_create_anonymous_area(vm_current_user_address_space_id(), - (char *)name, &address, addressSpec, size, lock, protection, false); + (char *)name, &address, addressSpec, size, lock, protection, false, + false); if (area >= B_OK && user_memcpy(userAddress, &address, sizeof(address)) < B_OK) { delete_area(area); @@ -5407,7 +5453,7 @@ // that you have created yourself from userland. // The documentation to delete_area() explicetly states that this // will be restricted in the future, and so it will. - return vm_delete_area(vm_current_user_address_space_id(), area); + return vm_delete_area(vm_current_user_address_space_id(), area, false); } @@ -5470,5 +5516,5 @@ return status; // unmap - return unmap_address_range(locker.AddressSpace(), address, size); + return unmap_address_range(locker.AddressSpace(), address, size, false); } From leavengood at gmail.com Sun May 11 18:21:57 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Sun, 11 May 2008 12:21:57 -0400 Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: <26652176509-BeMail@zon> References: <26652176509-BeMail@zon> Message-ID: On 5/11/08, Axel D?rfler wrote: > > I don't know. For me, a tool like Git is only really useful if you > don't always have access to the actual repository, or if you want to > manage more than one tree for whatever reasons (and don't want to use > the usual branches for this). Otherwise, I don't really see any > advantages, so at least I don't see any with regards to a sample code > repository. But I don't really have used git for more than the > occasional checkout (but I have to say it's a lot less intuitive to use > than other tools I used so far). I think GIt's usabiity has improved a lot recently. I certainly don't find it that hard. In fact it is very similar to svn, minus all the disadvantages of svn. You don't have to worry about who has commit access or not. People can work fairly independently with Git and then merge work with much less trouble than svn. Branches are cheap and easy, so that even small changes can be done on branches and then merged back. This means you can stop in the middle of your work and go back to the main branch to fix a small bug in the area you are working without the old svn hacks of having to save a backup of your current work and then "svn revert" to get back to the original. I hate doing that, but that is just what you have to do with Subversion. Git even has a special command "git stash" that does that kind of operation for you if you aren't in a special branch. History is tracked between branches and merges so you can see the true history of a file. File moves are tracked properly and automatically. You can browse the history without hitting the server. You can commit without hitting the server. You can have source code on multiple machines that are both used for development without having to resort to copying files around by hand (Git can pull or push to the multiple repos you have on each machine.) Git is its own backup system, since each person has a full copy of the repo. I'd love to see what would happen if Berlios lost Haiku's SVN repo. Hopefully that won't happen, but how sure can we be? In that case the irony would be that the history of Haiku would be saved by Git because Rene and other people have a Git clone of Haiku SVN repo with all the history. Git is also very efficient. The entire repo for Haiku with all the history fits in about 220 MB (not checked out.) > It certainly blows BerliOS limits quite a bit, but I don't really know > what you mean by unmanageable. As Rene says, doing anything with Berlios from the US is a huge pain. Of course you European folks don't see that, but that doesn't mean it isn't there ;) But even besides that, the repo is just huge, so that svn update, or God forbid, checking out all the code again, takes inordinate amounts of time. The more we keep adding stuff "just in case", or because it is the easiest thing, the worse it gets. Moving to Git would probably help, but it sounds like that won't ever happen. So at least for my own projects I am using Git. Ryan From bonefish at mail.berlios.de Sun May 11 18:25:36 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 11 May 2008 18:25:36 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 Message-ID: <200805111625.m4BGPapq003667@sheep.berlios.de> Author: bonefish Date: 2008-05-11 18:25:35 +0200 (Sun, 11 May 2008) New Revision: 25451 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25451&view=rev Added: haiku/trunk/headers/private/libroot/user_thread.h Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h haiku/trunk/headers/private/kernel/team.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/headers/private/kernel/tls.h haiku/trunk/src/system/kernel/Jamfile haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp haiku/trunk/src/system/kernel/signal.cpp haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/kernel/thread.cpp Log: * For each userland team the kernel creates an area in the userland address space that is fully locked and marked B_KERNEL_AREA. It can thus be accessed by the kernel without additional checks. * For each userland thread we do create a user_thread structure in that area. The structure is accessible from userland via TLS, using the private get_user_thread() function. * Introduced private userland functions [un]defer_signals(). They can be used to cheaply disable/re-enable signal delivery. They use the user_thread::defer_signals/pending_signals fields which are checked/updated by the kernel. Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_kernel.h 2008-05-11 16:25:35 UTC (rev 25451) @@ -32,7 +32,8 @@ #define USER_SIZE (KERNEL_BASE - 0x10000) #define USER_TOP (USER_BASE + USER_SIZE) -#define USER_STACK_REGION 0x70000000 -#define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION) +#define KERNEL_USER_DATA_BASE 0x6fff0000 +#define USER_STACK_REGION 0x70000000 +#define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION) #endif /* _KERNEL_ARCH_x86_KERNEL_H */ Modified: haiku/trunk/headers/private/kernel/team.h =================================================================== --- haiku/trunk/headers/private/kernel/team.h 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/headers/private/kernel/team.h 2008-05-11 16:25:35 UTC (rev 25451) @@ -47,6 +47,9 @@ 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); + // used in syscalls.c thread_id _user_load_image(int32 argCount, const char **args, int32 envCount, const char **env, int32 priority, uint32 flags, Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-05-11 16:25:35 UTC (rev 25451) @@ -71,6 +71,7 @@ struct image; // defined in image.c struct realtime_sem_context; // defined in realtime_sem.cpp struct select_info; +struct user_thread; // defined in libroot/user_thread.h struct death_entry { struct list_link link; @@ -165,6 +166,11 @@ #endif // __cplusplus +struct free_user_thread { + struct free_user_thread* next; + struct user_thread* thread; +}; + struct team { struct team *next; // next in hash struct team *siblings_next; @@ -199,6 +205,12 @@ struct list watcher_list; struct arch_team arch_info; + addr_t user_data; + area_id user_data_area; + size_t user_data_size; + size_t used_user_data; + struct free_user_thread* free_user_threads; + struct team_debug_info debug_info; bigtime_t dead_threads_kernel_time; @@ -239,13 +251,15 @@ size_t signal_stack_size; bool signal_stack_enabled; + bool in_kernel; + bool was_yielded; + + struct user_thread* user_thread; + struct { uint8 parameters[32]; } syscall_restart; - bool in_kernel; - bool was_yielded; - struct { status_t status; // current wait status uint32 flags; // interrupable flags Modified: haiku/trunk/headers/private/kernel/tls.h =================================================================== --- haiku/trunk/headers/private/kernel/tls.h 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/headers/private/kernel/tls.h 2008-05-11 16:25:35 UTC (rev 25451) @@ -17,6 +17,7 @@ TLS_THREAD_ID_SLOT, TLS_ERRNO_SLOT, TLS_ON_EXIT_THREAD_SLOT, + TLS_USER_THREAD_SLOT, // Note: these entries can safely be changed between // releases; 3rd party code always calls tls_allocate() Added: haiku/trunk/headers/private/libroot/user_thread.h =================================================================== --- haiku/trunk/headers/private/libroot/user_thread.h 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/headers/private/libroot/user_thread.h 2008-05-11 16:25:35 UTC (rev 25451) @@ -0,0 +1,48 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _LIBROOT_USER_THREAD_H +#define _LIBROOT_USER_THREAD_H + +#include +#include + +#include /* kernel header */ + + +struct user_thread { + int32 defer_signals; // counter; 0 == signals allowed + uint32 pending_signals; // signals that are pending, when + // signals are deferred + status_t wait_status; +}; + + +static inline user_thread* +get_user_thread() +{ + return (user_thread*)tls_get(TLS_USER_THREAD_SLOT); +} + + +static void inline +defer_signals() +{ + get_user_thread()->defer_signals++; +} + + +static void inline +undefer_signals() +{ + user_thread* thread = get_user_thread(); + if (--thread->defer_signals == 0 && thread->pending_signals != 0) { + // signals shall no longer be deferred -- call a dummy syscall to handle + // the pending ones + is_computer_on(); + } +} + + +#endif /* _LIBROOT_USER_THREAD_H */ Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-11 16:25:35 UTC (rev 25451) @@ -10,6 +10,7 @@ SubDirC++Flags $(defines) ; } +UsePrivateHeaders libroot ; UsePrivateHeaders shared ; UsePrivateHeaders runtime_loader ; Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-05-11 16:25:35 UTC (rev 25451) @@ -309,15 +309,17 @@ status_t arch_thread_init_tls(struct thread *thread) { - uint32 tls[TLS_THREAD_ID_SLOT + 1]; + uint32 tls[TLS_USER_THREAD_SLOT + 1]; int32 i; thread->user_local_storage = thread->user_stack_base + thread->user_stack_size; // initialize default TLS fields + memset(tls, 0, sizeof(tls)); tls[TLS_BASE_ADDRESS_SLOT] = thread->user_local_storage; tls[TLS_THREAD_ID_SLOT] = thread->id; + tls[TLS_USER_THREAD_SLOT] = (addr_t)thread->user_thread; return user_memcpy((void *)thread->user_local_storage, tls, sizeof(tls)); } Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-05-11 16:25:35 UTC (rev 25451) @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -42,6 +43,11 @@ #define DEFAULT_IGNORE_SIGNALS \ (SIGNAL_TO_MASK(SIGCHLD) | SIGNAL_TO_MASK(SIGWINCH) \ | SIGNAL_TO_MASK(SIGCONT)) +#define NON_DEFERRABLE_SIGNALS \ + (KILL_SIGNALS \ + | SIGNAL_TO_MASK(SIGILL) \ + | SIGNAL_TO_MASK(SIGFPE) \ + | SIGNAL_TO_MASK(SIGSEGV)) const char * const sigstr[NSIG] = { @@ -270,6 +276,14 @@ if (signalMask == 0) return 0; + if (thread->user_thread->defer_signals > 0 + && (signalMask & NON_DEFERRABLE_SIGNALS) == 0) { + thread->user_thread->pending_signals = signalMask; + return 0; + } + + thread->user_thread->pending_signals = 0; + bool restart = (atomic_and(&thread->flags, ~THREAD_FLAGS_DONT_RESTART_SYSCALL) & THREAD_FLAGS_DONT_RESTART_SYSCALL) == 0; Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-11 16:25:35 UTC (rev 25451) @@ -1,4 +1,5 @@ /* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * @@ -35,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +71,7 @@ size_t user_stack_size; addr_t user_local_storage; sigset_t sig_block_mask; + struct user_thread* user_thread; struct arch_fork_arg arch_info; }; @@ -830,6 +833,11 @@ team->state = TEAM_STATE_BIRTH; team->flags = 0; team->death_sem = -1; + team->user_data_area = -1; + team->user_data = 0; + team->used_user_data = 0; + team->user_data_size = 0; + team->free_user_threads = NULL; team->supplementary_groups = NULL; team->supplementary_group_count = 0; @@ -911,6 +919,11 @@ while (job_control_entry* entry = team->dead_children->entries.RemoveHead()) delete entry; + while (free_user_thread* entry = team->free_user_threads) { + team->free_user_threads = entry->next; + free(entry); + } + malloc_referenced_release(team->supplementary_groups); delete team->job_control_entry; @@ -935,7 +948,43 @@ } +static status_t +create_team_user_data(struct team* team) +{ + void* address = (void*)KERNEL_USER_DATA_BASE; + size_t size = 4 * B_PAGE_SIZE; + team->user_data_area = create_area_etc(team, "user area", &address, + B_BASE_ADDRESS, size, B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA); + if (team->user_data_area < 0) + return team->user_data_area; + + team->user_data = (addr_t)address; + team->used_user_data = 0; + team->user_data_size = size; + team->free_user_threads = NULL; + + return B_OK; +} + + static void +delete_team_user_data(struct team* team) +{ + if (team->user_data_area >= 0) { + delete_area_etc(team, team->user_data_area); + team->user_data = 0; + team->used_user_data = 0; + team->user_data_size = 0; + team->user_data_area = -1; + while (free_user_thread* entry = team->free_user_threads) { + team->free_user_threads = entry->next; + free(entry); + } + } +} + + +static void free_team_arg(struct team_arg *teamArg) { free_strings_array(teamArg->args, teamArg->arg_count); @@ -1004,6 +1053,9 @@ TRACE(("team_create_thread_start: entry thread %ld\n", t->id)); + // get a user thread for the main thread + t->user_thread = team_allocate_user_thread(team); + // create an initial primary stack area // Main stack area layout is currently as follows (starting from 0): @@ -1216,13 +1268,18 @@ else threadName = args[0]; + // create the user data area + status = create_team_user_data(team); + if (status != B_OK) + goto err4; + // Create a kernel thread, but under the context of the new team // The new thread will take over ownership of teamArgs thread = spawn_kernel_thread_etc(team_create_thread_start, threadName, B_NORMAL_PRIORITY, teamArgs, team->id, team->id); if (thread < 0) { status = thread; - goto err4; + goto err5; } // wait for the loader of the new team to finish its work @@ -1264,6 +1321,8 @@ return thread; +err5: + delete_team_user_data(team); err4: vm_put_address_space(team->address_space); err3: @@ -1362,6 +1421,7 @@ user_debug_prepare_for_exec(); + delete_team_user_data(team); vm_delete_areas(team->address_space); delete_owned_ports(team->id); sem_delete_owned_sems(team->id); @@ -1370,6 +1430,14 @@ delete_realtime_sem_context(team->realtime_sem_context); team->realtime_sem_context = NULL; + status = create_team_user_data(team); + if (status != B_OK) { + // creating the user data failed -- we're toast + // TODO: We should better keep the old user area in the first place. + exit_thread(status); + return status; + } + user_debug_finish_after_exec(); // rename the team @@ -1422,6 +1490,7 @@ thread->user_stack_size = forkArgs->user_stack_size; thread->user_local_storage = forkArgs->user_local_storage; thread->sig_block_mask = forkArgs->sig_block_mask; + thread->user_thread = forkArgs->user_thread; arch_thread_init_tls(thread); @@ -1509,6 +1578,8 @@ // ToDo: should be able to handle stack areas differently (ie. don't have them copy-on-write) // ToDo: all stacks of other threads than the current one could be left out + forkArgs->user_thread = NULL; + cookie = 0; while (get_next_area_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { void *address; @@ -1519,13 +1590,30 @@ break; } - if (info.area == parentThread->user_stack_area) + if (info.area == parentThread->user_stack_area) { forkArgs->user_stack_area = area; + } else if (info.area == parentTeam->user_data_area) { + team->user_data = (addr_t)address; + team->used_user_data = 0; + team->user_data_size = info.size; + team->user_data_area = area; + team->free_user_threads = NULL; + forkArgs->user_thread = team_allocate_user_thread(team); + } } if (status < B_OK) goto err4; + if (forkArgs->user_thread == NULL) { +#if KDEBUG + panic("user data area not found, parent area is %ld", + parentTeam->user_data_area); +#endif + status = B_ERROR; + goto err4; + } + forkArgs->user_stack_base = parentThread->user_stack_base; forkArgs->user_stack_size = parentThread->user_stack_size; forkArgs->user_local_storage = parentThread->user_local_storage; @@ -2558,6 +2646,68 @@ } +/*! The team lock must be held or the team must still be single threaded. +*/ +struct user_thread* +team_allocate_user_thread(struct team* team) +{ + if (team->user_data == 0) + return NULL; + + user_thread* thread = NULL; + + // take an entry from the free list, if any + if (struct free_user_thread* entry = team->free_user_threads) { + thread = entry->thread; + team->free_user_threads = entry->next; + deferred_free(entry); + return thread; + } else { + // enough space left? + size_t needed = _ALIGN(sizeof(user_thread)); + if (team->user_data_size - team->used_user_data < needed) + return NULL; + // TODO: This imposes a per team thread limit! We should resize the + // area, if necessary. That's problematic at this point, though, since + // we've got the team lock. + + thread = (user_thread*)(team->user_data + team->used_user_data); + team->used_user_data += needed; + } + + thread->defer_signals = 0; + thread->pending_signals = 0; + thread->wait_status = B_OK; + + return thread; +} + + +/*! The team lock must not be held. \a thread must be the current thread. +*/ +void +team_free_user_thread(struct thread* thread) +{ + user_thread* userThread = thread->user_thread; + if (userThread == NULL) + return; + + // create a free list entry + free_user_thread* entry + = (free_user_thread*)malloc(sizeof(free_user_thread)); + if (entry == NULL) { + // we have to leak the user thread :-/ + return; + } + + InterruptsSpinLocker _(team_spinlock); + + entry->thread = userThread; + entry->next = thread->team->free_user_threads; + thread->team->free_user_threads = entry; +} + + // #pragma mark - Public kernel API Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-05-11 16:02:13 UTC (rev 25450) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-05-11 16:25:35 UTC (rev 25451) @@ -444,7 +444,16 @@ GRAB_TEAM_LOCK(); // look at the team, make sure it's not being deleted team = team_get_team_struct_locked(attributes.team); - if (team != NULL && team->state != TEAM_STATE_DEATH) { + + if (team == NULL || team->state == TEAM_STATE_DEATH) + abort = true; + + if (!abort && !kernel) { + thread->user_thread = team_allocate_user_thread(team); + abort = thread->user_thread == NULL; + } + + if (!abort) { // Debug the new thread, if the parent thread required that (see above), // or the respective global team debug flag is set. But only, if a // debugger is installed for the team. @@ -457,8 +466,7 @@ } insert_thread_into_team(team, thread); - } else - abort = true; + } RELEASE_TEAM_LOCK(); if (abort) { @@ -1407,8 +1415,10 @@ if (team->main_thread == thread) { // this was the main thread in this team, so we will delete that as well deleteTeam = true; - } else + } else { threadDeathEntry = (death_entry*)malloc(sizeof(death_entry)); + team_free_user_thread(thread); + } // remove this thread from the current team and add it to the kernel // put the thread into the kernel team until it dies @@ -2937,4 +2947,3 @@ return common_setrlimit(resource, &resourceLimit); } - From bonefish at mail.berlios.de Sun May 11 18:30:28 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 11 May 2008 18:30:28 +0200 Subject: [Haiku-commits] r25452 - haiku/trunk/src/system/libroot/posix/malloc Message-ID: <200805111630.m4BGUShj004229@sheep.berlios.de> Author: bonefish Date: 2008-05-11 18:30:22 +0200 (Sun, 11 May 2008) New Revision: 25452 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25452&view=rev Modified: haiku/trunk/src/system/libroot/posix/malloc/Jamfile haiku/trunk/src/system/libroot/posix/malloc/wrapper.cpp Log: Use the [un]defer_signals() functions to prevent signal delivery while being in the allocator. Fixed bug #1965. Modified: haiku/trunk/src/system/libroot/posix/malloc/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/malloc/Jamfile 2008-05-11 16:25:35 UTC (rev 25451) +++ haiku/trunk/src/system/libroot/posix/malloc/Jamfile 2008-05-11 16:30:22 UTC (rev 25452) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src system libroot posix malloc ; UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; +UsePrivateHeaders libroot ; MergeObject posix_malloc.o : arch-specific.cpp Modified: haiku/trunk/src/system/libroot/posix/malloc/wrapper.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/malloc/wrapper.cpp 2008-05-11 16:25:35 UTC (rev 25451) +++ haiku/trunk/src/system/libroot/posix/malloc/wrapper.cpp 2008-05-11 16:30:22 UTC (rev 25452) @@ -29,6 +29,8 @@ #include #include +#include + #include "tracing_config.h" using namespace BPrivate; @@ -265,8 +267,11 @@ size += 2 * HEAP_WALL_SIZE; #endif + defer_signals(); + void *addr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size); if (addr == NULL) { + undefer_signals(); errno = B_NO_MEMORY; KTRACE("malloc(%lu) -> NULL", size); return NULL; @@ -275,6 +280,9 @@ #if HEAP_LEAK_CHECK add_address(addr, size); #endif + + undefer_signals(); + #if HEAP_WALL addr = set_wall(addr, size); #endif @@ -295,8 +303,11 @@ size += 2 * HEAP_WALL_SIZE; #endif + defer_signals(); + void *ptr = pHeap->getHeap(pHeap->getHeapIndex()).malloc(size); if (ptr == NULL) { + undefer_signals(); errno = B_NO_MEMORY; KTRACE("calloc(%lu, %lu) -> NULL", nelem, elsize); return NULL; @@ -305,6 +316,9 @@ #if HEAP_LEAK_CHECK add_address(ptr, size); #endif + + undefer_signals(); + #if HEAP_WALL ptr = set_wall(ptr, size); size -= 2 * HEAP_WALL_SIZE; @@ -321,17 +335,23 @@ free(void *ptr) { static processHeap *pHeap = getAllocator(); + #if HEAP_WALL if (ptr == NULL) return; KTRACE("free(%p)", ptr); ptr = check_wall((uint8*)ptr); #endif + + defer_signals(); + #if HEAP_LEAK_CHECK if (ptr != NULL) remove_address(ptr); #endif pHeap->free(ptr); + + undefer_signals(); } @@ -344,9 +364,13 @@ debug_printf("memalign() is not yet supported by the wall code.\n"); return NULL; #endif + + defer_signals(); + void *addr = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment, size); if (addr == NULL) { + undefer_signals(); errno = B_NO_MEMORY; KTRACE("memalign(%lu, %lu) -> NULL", alignment, size); return NULL; @@ -356,6 +380,8 @@ add_address(addr, size); #endif + undefer_signals(); + KTRACE("memalign(%lu, %lu) -> %p", alignment, size, addr); return addr; } @@ -372,9 +398,11 @@ return -1; #endif static processHeap *pHeap = getAllocator(); + defer_signals(); void *pointer = pHeap->getHeap(pHeap->getHeapIndex()).memalign(alignment, size); if (pointer == NULL) { + undefer_signals(); KTRACE("posix_memalign(%p, %lu, %lu) -> NULL", _pointer, alignment, size); return B_NO_MEMORY; @@ -384,6 +412,8 @@ add_address(pointer, size); #endif + undefer_signals(); + *_pointer = pointer; KTRACE("posix_memalign(%p, %lu, %lu) -> %p", _pointer, alignment, size, pointer); From revol at free.fr Sun May 11 18:36:14 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 18:36:14 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25451_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/private/kernel_headers/private/kernel/arch/x86_header?= =?windows-1252?q?s/private/libroot_src/system/kernel__src/system/kernel/a?= =?windows-1252?q?rch/x86?= In-Reply-To: <200805111625.m4BGPapq003667@sheep.berlios.de> Message-ID: <7929183321-BeMail@laptop> > Log: > * For each userland team the kernel creates an area in the userland > address space that is fully locked and marked B_KERNEL_AREA. It can > thus be accessed by the kernel without additional checks. > * For each userland thread we do create a user_thread structure in > that > area. The structure is accessible from userland via TLS, using the > private get_user_thread() function. While this seems a nice idea, > * Introduced private userland functions [un]defer_signals(). They can > be > used to cheaply disable/re-enable signal delivery. They use the > user_thread::defer_signals/pending_signals fields which are > checked/updated by the kernel. This opens a security can by allowing a thread to become totally unkillable... (or is KILLTHR not affected ? still it allows to indefinitely block others) Actually are malloc() and friends allowed in sighandlers anyway ? I've been told one should be very cautious on what to to in sighandlers and just defer processing by setting a flag. Fran?ois. From revol at free.fr Sun May 11 18:54:46 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 18:54:46 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <7929183321-BeMail@laptop> Message-ID: <9041995082-BeMail@laptop> > > Log: > > * For each userland team the kernel creates an area in the userland > > address space that is fully locked and marked B_KERNEL_AREA. It > > can > > thus be accessed by the kernel without additional checks. > > * For each userland thread we do create a user_thread structure in > > that > > area. The structure is accessible from userland via TLS, using > > the > > private get_user_thread() function. > > While this seems a nice idea, > > > * Introduced private userland functions [un]defer_signals(). They > > can > > be > > used to cheaply disable/re-enable signal delivery. They use the > > user_thread::defer_signals/pending_signals fields which are > > checked/updated by the kernel. > > This opens a security can by allowing a thread to become totally > unkillable... > (or is KILLTHR not affected ? still it allows to indefinitely block > others) > > Actually are malloc() and friends allowed in sighandlers anyway ? > I've been told one should be very cautious on what to to in > sighandlers > and just defer processing by setting a flag. Interesting readings: * Opengroup: http://www.opengroup.org/onlinepubs/000095399/functions/signal.html "If the signal occurs other than as the result of calling abort(), raise(), [CX] [Option Start] kill(), pthread_kill(), or sigqueue(), [Option End] the behavior is undefined if the signal handler refers to any object with static storage duration other than by assigning a value to an object declared as volatile sig_atomic_t, or if the signal handler calls any function in the standard library other than one of the functions listed in Signal Concepts. Furthermore, if such a call fails, the value of errno is unspecified." * What glibc says: http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC351 "You need to take special care in writing handler functions because they can be called asynchronously. That is, a handler might be called at any point in the program, unpredictably. " http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC357 "On most systems, malloc and free are not reentrant, because they use a static data structure which records what memory blocks are free. As a result, no library functions that allocate or free memory are reentrant. This includes functions that allocate space to store a result." "On the GNU system, malloc and free are safe to use in signal handlers because it blocks signals. As a result, the library functions that allocate space for a result are also safe in signal handlers." Either we can switch to the gnu malloc (grin) or fix our malloc to block signals around critical sections, but adding a security hole just to avoid fixing or to "do better than others who would deadlock" it is not an option. Should be easy to create a sigsafe_mutex struct with a mutex and signal backup. http://www.google.com/search?q=allowed+in+signal+handler http://www.google.com/search?q=deadlock+in+signal+handler -> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4873538 Fran?ois. From anevilyak at gmail.com Sun May 11 18:58:49 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 11 May 2008 11:58:49 -0500 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <9041995082-BeMail@laptop> References: <7929183321-BeMail@laptop> <9041995082-BeMail@laptop> Message-ID: On Sun, May 11, 2008 at 11:54 AM, Fran?ois Revol wrote: > "On most systems, malloc and free are not reentrant, because they use a > static data structure which records what memory blocks are free. As a > result, no library functions that allocate or free memory are > reentrant. This includes functions that allocate space to store a > result." I would've thought HOARD would be reentrant though, given its emphasis on multithreaded/multiprocessor scaling. Can anyone verify? Regards, Rene From axeld at mail.berlios.de Sun May 11 19:00:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 11 May 2008 19:00:16 +0200 Subject: [Haiku-commits] r25453 - haiku/trunk/src/tests/system/kernel/device_manager/playground Message-ID: <200805111700.m4BH0Gnw014569@sheep.berlios.de> Author: axeld Date: 2008-05-11 19:00:07 +0200 (Sun, 11 May 2008) New Revision: 25453 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25453&view=rev Added: haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp Log: More work-in-progress: * Added a generic (for all devices) and specific (for a specific device) video driver to be able to play with the replace mechanism (which is not yet done, but works well for the one usage case tested). * Added reference counting and initialize counting: now, each node owns a reference of its parent, and each initialized node owns an initialization reference of its parent. * Added locking. * Moved dump functionality into a member function. * The same node can now only added once - ie. if a bus tries to register the same device twice, it will fail. Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/Jamfile 2008-05-11 17:00:07 UTC (rev 25453) @@ -12,6 +12,8 @@ bus.cpp driver.cpp + generic_video_driver.cpp + specific_video_driver.cpp : be libkernelland_emu.so ; Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-11 17:00:07 UTC (rev 25453) @@ -71,6 +71,7 @@ } kDevices[] = { {0x1000, 0x0001, PCI_mass_storage, PCI_sata, PCI_sata_ahci}, {0x1001, 0x0001, PCI_network, PCI_ethernet, 0}, + {0x1001, 0x0002, PCI_display, 0, 0}, {0x1002, 0x0001, PCI_multimedia, PCI_audio, 0}, {0x1002, 0x0002, PCI_serial_bus, PCI_usb, PCI_usb_ehci}, }; Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-11 17:00:07 UTC (rev 25453) @@ -29,6 +29,10 @@ extern struct device_module_info gDeviceModuleInfo; extern struct driver_module_info gDriverModuleInfo; +extern struct device_module_info gGenericVideoDeviceModuleInfo; +extern struct driver_module_info gGenericVideoDriverModuleInfo; +extern struct device_module_info gSpecificVideoDeviceModuleInfo; +extern struct driver_module_info gSpecificVideoDriverModuleInfo; extern struct driver_module_info gBusModuleInfo; extern struct driver_module_info gBusDriverModuleInfo; @@ -113,6 +117,14 @@ bool IsRegistered() const { return fRegistered; } bool IsInitialized() const { return fInitialized > 0; } + void Acquire(); + bool Release(); + + int CompareTo(const device_attr* attributes) const; + device_node* FindChild(const device_attr* attributes) const; + + void Dump(int32 level = 0); + private: status_t _RegisterFixed(uint32& registered); bool _AlwaysRegisterDynamic(); @@ -361,27 +373,6 @@ } -void -dm_dump_node(device_node* node, int32 level) -{ - if (node == NULL) - return; - - put_level(level); - dprintf("(%ld) @%p \"%s\"\n", level, node, node->ModuleName()); - - AttributeList::Iterator attribute = node->Attributes().GetIterator(); - while (attribute.HasNext()) { - dump_attribute(attribute.Next(), level); - } - - NodeList::ConstIterator iterator = node->Children().GetIterator(); - while (iterator.HasNext()) { - dm_dump_node(iterator.Next(), level + 1); - } -} - - static void uninit_unused() { @@ -434,6 +425,8 @@ device_node::~device_node() { + TRACE(("delete node %p\n", this)); + // Delete children NodeList::Iterator nodeIterator = fChildren.GetIterator(); while (nodeIterator.HasNext()) { @@ -464,10 +457,20 @@ status_t device_node::InitDriver() { - if (fInitialized++ > 0) + if (fInitialized++ > 0) { + if (Parent() != NULL) { + Parent()->InitDriver(); + // acquire another reference to our parent as well + } + Acquire(); return B_OK; + } status_t status = get_module(ModuleName(), (module_info**)&fDriver); + if (status == B_OK && Parent() != NULL) { + // our parent always have to be initialized + status = Parent()->InitDriver(); + } if (status < B_OK) { fInitialized--; return status; @@ -475,12 +478,17 @@ if (fDriver->init_driver != NULL) status = fDriver->init_driver(this, &fDriverData); + if (status < B_OK) { fInitialized--; + put_module(ModuleName()); + fDriver = NULL; + fDriverData = NULL; return status; } + Acquire(); return B_OK; } @@ -488,8 +496,11 @@ bool device_node::UninitDriver() { - if (fInitialized-- > 1) + if (fInitialized-- > 1) { + Release(); return false; + } + TRACE(("uninit driver for node %p\n", this)); if (fDriver->uninit_driver != NULL) fDriver->uninit_driver(this); @@ -499,8 +510,12 @@ put_module(ModuleName()); + Release(); + if (Parent() != NULL) + Parent()->UninitDriver(); + if ((fFlags & NODE_FLAG_REMOVE_ON_UNINIT) != 0) - delete this; + Release(); return true; } @@ -510,7 +525,7 @@ device_node::AddChild(device_node* node) { // we must not be destroyed as long as we have children - fRefCount++; + Acquire(); node->fParent = this; fChildren.Add(node); } @@ -519,10 +534,9 @@ void device_node::RemoveChild(device_node* node) { - fRefCount--; - // TODO: we may need to destruct ourselves here! node->fParent = NULL; fChildren.Remove(node); + Release(); } @@ -784,7 +798,8 @@ while (_GetNextDriver(list, driver) == B_OK) { float support = driver->supports_device(this); if (support > 0.0) { -printf(" register module \"%s\", support %f\n", driver->info.name, support); + TRACE((" register module \"%s\", support %f\n", driver->info.name, + support)); if (driver->register_device(this) == B_OK) count++; } @@ -835,7 +850,8 @@ } if (bestDriver != NULL) { -printf(" register best module \"%s\", support %f\n", bestDriver->info.name, bestSupport); + TRACE((" register best module \"%s\", support %f\n", + bestDriver->info.name, bestSupport)); bestDriver->register_device(this); put_module(bestDriver->info.name); } @@ -861,9 +877,10 @@ if (!child->IsInitialized()) { // this child is not used currently, and can be removed safely iterator.Remove(); - fRefCount--; child->fParent = NULL; delete child; + if (Release()) + panic("died early"); } else child->fFlags |= NODE_FLAG_REMOVE_ON_UNINIT; } @@ -875,6 +892,12 @@ status_t device_node::Probe(const char* devicePath) { + status_t status = InitDriver(); + if (status < B_OK) + return status; + + MethodDeleter uninit(this, &device_node::UninitDriver); + uint16 type = 0; uint16 subType = 0; if (dm_get_attr_uint16(this, B_DEVICE_TYPE, &type, false) == B_OK @@ -917,7 +940,7 @@ while (iterator.HasNext()) { device_node* child = iterator.Next(); - status_t status = child->Probe(devicePath); + status = child->Probe(devicePath); if (status != B_OK) return status; } @@ -965,6 +988,91 @@ } +void +device_node::Acquire() +{ + atomic_add(&fRefCount, 1); +} + + +bool +device_node::Release() +{ + if (atomic_add(&fRefCount, -1) > 1) + return false; + + if (Parent() != NULL) + Parent()->RemoveChild(this); + delete this; + return true; +} + + +int +device_node::CompareTo(const device_attr* attributes) const +{ + if (attributes == NULL) + return -1; + + for (; attributes->name != NULL; attributes++) { + // find corresponding attribute + AttributeList::ConstIterator iterator = Attributes().GetIterator(); + device_attr_private* attr = NULL; + while (iterator.HasNext()) { + attr = iterator.Next(); + + if (!strcmp(attr->name, attributes->name)) + break; + } + if (!iterator.HasNext()) + return -1; + + int compare = device_attr_private::Compare(attr, attributes); + if (compare != 0) + return compare; + } + + return 0; +} + + +device_node* +device_node::FindChild(const device_attr* attributes) const +{ + if (attributes == NULL) + return NULL; + + NodeList::ConstIterator iterator = Children().GetIterator(); + while (iterator.HasNext()) { + device_node* child = iterator.Next(); + + if (!child->CompareTo(attributes)) + return child; + } + + return NULL; +} + + +void +device_node::Dump(int32 level = 0) +{ + put_level(level); + dprintf("(%ld) @%p \"%s\" (ref %ld, init %ld)\n", level, this, ModuleName(), + fRefCount, fInitialized); + + AttributeList::Iterator attribute = Attributes().GetIterator(); + while (attribute.HasNext()) { + dump_attribute(attribute.Next(), level); + } + + NodeList::ConstIterator iterator = Children().GetIterator(); + while (iterator.HasNext()) { + iterator.Next()->Dump(level + 1); + } +} + + // #pragma mark - Device Manager module API @@ -983,6 +1091,11 @@ if ((parent == NULL && sRootNode != NULL) || moduleName == NULL) return B_BAD_VALUE; + if (parent != NULL && parent->FindChild(attrs) != NULL) { + // A node like this one already exists for this parent + return B_NAME_IN_USE; + } + // TODO: handle I/O resources! device_node *newNode = new(std::nothrow) device_node(moduleName, attrs, @@ -999,16 +1112,16 @@ if (status != B_OK) goto err1; - status = newNode->InitDriver(); - if (status != B_OK) - goto err1; - // make it public if (parent != NULL) parent->AddChild(newNode); else sRootNode = newNode; + status = newNode->InitDriver(); + if (status != B_OK) + goto err1; + #if 0 // The following is done to reduce the stack usage of deeply nested // child device nodes. @@ -1063,8 +1176,11 @@ static device_node* -device_root(void) +get_device_root(void) { + if (sRootNode != NULL) + sRootNode->Acquire(); + return sRootNode; } @@ -1080,13 +1196,23 @@ static device_node* get_parent(device_node* node) { - return NULL; + if (node == NULL) + return NULL; + + RecursiveLocker _(sLock); + + device_node* parent = node->Parent(); + parent->Acquire(); + + return parent; } static void put_device_node(device_node* node) { + RecursiveLocker _(sLock); + node->Release(); } @@ -1229,7 +1355,7 @@ register_device, unregister_device, get_driver, - device_root, + get_device_root, get_next_child_device, get_parent, put_device_node, @@ -1284,11 +1410,19 @@ { _add_builtin_module((module_info*)&sDeviceManagerModule); _add_builtin_module((module_info*)&sDeviceRootModule); - _add_builtin_module((module_info*)&gDeviceModuleInfo); - _add_builtin_module((module_info*)&gDriverModuleInfo); + + // bus _add_builtin_module((module_info*)&gBusModuleInfo); _add_builtin_module((module_info*)&gBusDriverModuleInfo); + // sample driver + _add_builtin_module((module_info*)&gDriverModuleInfo); + _add_builtin_module((module_info*)&gDeviceModuleInfo); + + // generic video driver + _add_builtin_module((module_info*)&gGenericVideoDriverModuleInfo); + _add_builtin_module((module_info*)&gGenericVideoDeviceModuleInfo); + gDeviceManager = &sDeviceManagerModule; status_t status = _get_builtin_dependencies(); @@ -1301,11 +1435,23 @@ recursive_lock_init(&sLock, "device manager"); dm_init_root_node(); - dm_dump_node(sRootNode, 0); + sRootNode->Dump(); probe_path("net"); + probe_path("graphics"); + // TODO: opened devices need to keep a "initialized" reference of the + // device_node + + sRootNode->Dump(); uninit_unused(); + // add specific video driver - ie. simulate installing it + _add_builtin_module((module_info*)&gSpecificVideoDriverModuleInfo); + _add_builtin_module((module_info*)&gSpecificVideoDeviceModuleInfo); + probe_path("graphics"); + + uninit_unused(); + recursive_lock_destroy(&sLock); return 0; } Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-11 17:00:07 UTC (rev 25453) @@ -72,7 +72,7 @@ status_t (*get_driver)(device_node *node, driver_module_info **_module, void **_cookie); - device_node *(*root_device)(); + device_node *(*get_root_device)(); status_t (*get_next_child_device)(device_node *parent, device_node *node, const device_attr *attrs); device_node *(*get_parent)(device_node *node); Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-11 17:00:07 UTC (rev 25453) @@ -159,7 +159,7 @@ 0, NULL, }, - + supports_device, register_device, init_driver, Added: haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp 2008-05-11 17:00:07 UTC (rev 25453) @@ -0,0 +1,182 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "bus.h" + +#include +#include + + +#define DRIVER_MODULE_NAME "drivers/graphics/generic_driver/driver_v1" + + +// #pragma mark - driver + + +static float +supports_device(device_node *parent) +{ + bus_for_driver_module_info* module; + void* data; + gDeviceManager->get_driver(parent, (driver_module_info**)&module, &data); + + if (strcmp(module->info.info.name, BUS_FOR_DRIVER_NAME)) + return -1; + + uint16 type; + if (gDeviceManager->get_attr_uint16(parent, B_DEVICE_TYPE, &type, false) + != B_OK) + return -1; + + if (type == PCI_display) + return 0.1; + + return 0.0; +} + + +static status_t +register_device(device_node *parent) +{ + return gDeviceManager->register_device(parent, DRIVER_MODULE_NAME, NULL, + NULL, NULL); +} + + +static status_t +init_driver(device_node *node, void **_cookie) +{ + // also publishes any devices/nodes with dedicated calls + return B_OK; +} + + +static void +uninit_driver(device_node *node) +{ +} + + +static status_t +register_child_devices(device_node *node) +{ + return B_OK; +} + + +static void +device_removed(device_node *node) +{ +} + + +// #pragma mark - device + + +static status_t +init_device(void *deviceCookie) +{ + // called once before one or several open() calls + return B_ERROR; +} + + +static void +uninit_device(void *deviceCookie) +{ + // supposed to free deviceCookie, called when the last reference to + // the device is closed +} + + +static status_t +device_open(void *deviceCookie, int openMode, void **_cookie) +{ + // deviceCookie is an object attached to the published device + return B_ERROR; +} + + +static status_t +device_close(void *cookie) +{ + return B_ERROR; +} + + +static status_t +device_free(void *cookie) +{ + return B_ERROR; +} + + +static status_t +device_read(void *cookie, off_t pos, void *buffer, size_t *_length) +{ + return B_ERROR; +} + + +static status_t +device_write(void *cookie, off_t pos, const void *buffer, size_t *_length) +{ + return B_ERROR; +} + + +static status_t +device_ioctl(void *cookie, int32 op, void *buffer, size_t length) +{ + return B_ERROR; +} + + +static status_t +device_io(void *cookie, io_request *request) +{ + // new function to deal with I/O requests directly. + return B_ERROR; +} + + +// #pragma mark - + + +struct driver_module_info gGenericVideoDriverModuleInfo = { + { + DRIVER_MODULE_NAME, + 0, + NULL, + }, + + supports_device, + register_device, + init_driver, + uninit_driver, + register_child_devices, + NULL, + device_removed, +}; + +struct device_module_info gGenericVideoDeviceModuleInfo = { + { + "drivers/graphics/generic_driver/device_v1", + 0, + NULL, + }, + + init_device, + uninit_device, + + device_open, + device_close, + device_free, + device_read, + device_write, + device_ioctl, + device_io, +}; Added: haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp 2008-05-11 16:30:22 UTC (rev 25452) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp 2008-05-11 17:00:07 UTC (rev 25453) @@ -0,0 +1,180 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "bus.h" + +#include +#include + + +#define DRIVER_MODULE_NAME "drivers/graphics/specific_driver/driver_v1" + + +// #pragma mark - driver + + +static float +supports_device(device_node *parent) +{ + bus_for_driver_module_info* module; + void* data; + gDeviceManager->get_driver(parent, (driver_module_info**)&module, &data); + + if (strcmp(module->info.info.name, BUS_FOR_DRIVER_NAME)) + return -1; + + bus_info info; + if (module->get_bus_info(data, &info) == B_OK + && info.vendor_id == 0x1001 + && info.device_id == 0x0002) + return 0.8; + + return 0.0; +} + + +static status_t +register_device(device_node *parent) +{ + return gDeviceManager->register_device(parent, DRIVER_MODULE_NAME, NULL, + NULL, NULL); +} + + +static status_t +init_driver(device_node *node, void **_cookie) +{ + // also publishes any devices/nodes with dedicated calls + return B_OK; +} + + +static void +uninit_driver(device_node *node) +{ +} + + +static status_t +register_child_devices(device_node *node) +{ + return B_OK; +} + + +static void +device_removed(device_node *node) +{ +} + + +// #pragma mark - device + + +static status_t +init_device(void *deviceCookie) +{ + // called once before one or several open() calls + return B_ERROR; +} + + +static void +uninit_device(void *deviceCookie) +{ + // supposed to free deviceCookie, called when the last reference to + // the device is closed +} + + +static status_t +device_open(void *deviceCookie, int openMode, void **_cookie) +{ + // deviceCookie is an object attached to the published device + return B_ERROR; +} + + +static status_t +device_close(void *cookie) +{ + return B_ERROR; +} + + +static status_t +device_free(void *cookie) +{ + return B_ERROR; +} + + +static status_t +device_read(void *cookie, off_t pos, void *buffer, size_t *_length) +{ + return B_ERROR; +} + + +static status_t +device_write(void *cookie, off_t pos, const void *buffer, size_t *_length) +{ + return B_ERROR; +} + + +static status_t +device_ioctl(void *cookie, int32 op, void *buffer, size_t length) +{ + return B_ERROR; +} + + +static status_t +device_io(void *cookie, io_request *request) +{ + // new function to deal with I/O requests directly. + return B_ERROR; +} + + +// #pragma mark - + + +struct driver_module_info gSpecificVideoDriverModuleInfo = { + { + DRIVER_MODULE_NAME, + 0, + NULL, + }, + + supports_device, + register_device, + init_driver, + uninit_driver, + register_child_devices, + NULL, + device_removed, +}; + +struct device_module_info gSpecificVideoDeviceModuleInfo = { + { + "drivers/graphics/specific_driver/device_v1", + 0, + NULL, + }, + + init_device, + uninit_device, + + device_open, + device_close, + device_free, + device_read, + device_write, + device_ioctl, + device_io, +}; From revol at free.fr Sun May 11 19:03:33 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 19:03:33 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25451_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/private/kernel_headers/private/kernel/arch/x86_header?= =?windows-1252?q?s/private/libroot_src/system/kernel__src/system/kernel/a?= =?windows-1252?q?rch/x86?= In-Reply-To: Message-ID: <9568210426-BeMail@laptop> > On Sun, May 11, 2008 at 11:54 AM, Fran?ois Revol > wrote: > > "On most systems, malloc and free are not reentrant, because they > > use a > > static data structure which records what memory blocks are free. As > > a > > result, no library functions that allocate or free memory are > > reentrant. This includes functions that allocate space to store a > > result." > > I would've thought HOARD would be reentrant though, given its > emphasis > on multithreaded/multiprocessor scaling. Can anyone verify? Well as the glibc manual says the gnu allocator is reentrant, because it masks signals to assure it won't deadlock in critical sections. Indeed it's weird that hoard wouldn't do it yet. Or maybe it just assumes the locking functions it calls would do that and our don't yet ? Fran?ois. From ingo_weinhold at gmx.de Sun May 11 19:03:08 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 11 May 2008 19:03:08 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <7929183321-BeMail@laptop> References: <7929183321-BeMail@laptop> Message-ID: <20080511190308.644.1@knochen-vm.1210510002.fake> On 2008-05-11 at 18:36:14 [+0200], Fran?ois Revol wrote: > > Log: > > * For each userland team the kernel creates an area in the userland > > address space that is fully locked and marked B_KERNEL_AREA. It can > > thus be accessed by the kernel without additional checks. > > * For each userland thread we do create a user_thread structure in > > that > > area. The structure is accessible from userland via TLS, using the > > private get_user_thread() function. > > While this seems a nice idea, > > > * Introduced private userland functions [un]defer_signals(). They can > > be > > used to cheaply disable/re-enable signal delivery. They use the > > user_thread::defer_signals/pending_signals fields which are > > checked/updated by the kernel. > > This opens a security can by allowing a thread to become totally > unkillable... > (or is KILLTHR not affected ? still it allows to indefinitely block > others) SIGKILL[THR] are exempt. So are SIGILL, SIGSEGV, and SIGFPE ATM, since those are usually caused by the thread itself and it makes little sense to let it try to continue in those cases. Maybe other signals should be included as well or we want to check how they would be delivered (and deliver them when they are deadly) -- this needs a little fine-tuning, I guess. > Actually are malloc() and friends allowed in sighandlers anyway ? > I've been told one should be very cautious on what to to in sighandlers > and just defer processing by setting a flag. I'm not aware of any restrictions. Nor is bash. In some cases it even happily uses longjmp() and thus effectively never returns from the handler. CU, Ingo From anevilyak at mail.berlios.de Sun May 11 19:04:26 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 11 May 2008 19:04:26 +0200 Subject: [Haiku-commits] r25454 - haiku/trunk/src/add-ons/translators/jpeg Message-ID: <200805111704.m4BH4QLg018554@sheep.berlios.de> Author: anevilyak Date: 2008-05-11 19:04:25 +0200 (Sun, 11 May 2008) New Revision: 25454 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25454&view=rev Modified: haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp Log: Build fix for gcc4. Modified: haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp =================================================================== --- haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp 2008-05-11 17:00:07 UTC (rev 25453) +++ haiku/trunk/src/add-ons/translators/jpeg/exif_parser.cpp 2008-05-11 17:04:25 UTC (rev 25454) @@ -15,6 +15,7 @@ #include +using std::set; enum { TAG_EXIF_OFFSET = 0x8769, From revol at free.fr Sun May 11 19:10:56 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 19:10:56 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080511190308.644.1@knochen-vm.1210510002.fake> Message-ID: <10011450722-BeMail@laptop> > > On 2008-05-11 at 18:36:14 [+0200], Fran?ois Revol > wrote: > > > Log: > > > * For each userland team the kernel creates an area in the > > > userland > > > address space that is fully locked and marked B_KERNEL_AREA. It > > > can > > > thus be accessed by the kernel without additional checks. > > > * For each userland thread we do create a user_thread structure > > > in > > > that > > > area. The structure is accessible from userland via TLS, using > > > the > > > private get_user_thread() function. > > > > While this seems a nice idea, > > > > > * Introduced private userland functions [un]defer_signals(). They > > > can > > > be > > > used to cheaply disable/re-enable signal delivery. They use the > > > user_thread::defer_signals/pending_signals fields which are > > > checked/updated by the kernel. > > > > This opens a security can by allowing a thread to become totally > > unkillable... > > (or is KILLTHR not affected ? still it allows to indefinitely block > > others) > > SIGKILL[THR] are exempt. So are SIGILL, SIGSEGV, and SIGFPE ATM, > since > those are usually caused by the thread itself and it makes little > sense to > let it try to continue in those cases. Maybe other signals should be Some programs (jvm...) use SEGV to detect out of bound conditions to trigger exceptions in the interpreted program, so yes they continue from here. > > Actually are malloc() and friends allowed in sighandlers anyway ? > > I've been told one should be very cautious on what to to in > > sighandlers > > and just defer processing by setting a flag. > > I'm not aware of any restrictions. Nor is bash. In some cases it even > happily uses longjmp() and thus effectively never returns from the > handler. Because longjmp is specifically specified to be called from int handlers as some selected functions (see my other mail), this is not the case of malloc or free (even if some platforms remove this restriction by making them reentrant). Fran?ois. From axeld at pinc-software.de Sun May 11 19:09:47 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 19:09:47 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25450_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_src/system/kernel/vm?= In-Reply-To: <200805111602.m4BG2ELt001836@sheep.berlios.de> Message-ID: <31286715551-BeMail@zon> bonefish at BerliOS wrote: > +#define B_KERNEL_AREA 0x4000 > + // Usable from userland according to its protection flags, but the > area > + // itself is not deletable, resizable, etc from userland. Shouldn't that be true for all kernel areas automatically? I would rather have it the other way around - a flag that permits these changes. Bye, Axel. From revol at free.fr Sun May 11 19:15:50 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 19:15:50 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25453_-_haiku/trunk/src/tests/s?= =?windows-1252?q?ystem/kernel/device=5Fmanager/playground?= In-Reply-To: <200805111700.m4BH0Gnw014569@sheep.berlios.de> Message-ID: <10305665134-BeMail@laptop> > haiku/trunk/src/tests/system/kernel/device_manager/playground > /generic_video_driver.cpp > haiku/trunk/src/tests/system/kernel/device_manager/playground > /specific_video_driver.cpp I plan on having a look at it, I have some ideas on that, but first, does it still allow writing drivers in plain C ? :D Fran?ois. From ingo_weinhold at gmx.de Sun May 11 19:21:31 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 11 May 2008 19:21:31 +0200 Subject: [Haiku-commits] r25450 - in haiku/trunk: headers/private/kernel src/system/kernel/vm In-Reply-To: <31286715551-BeMail@zon> References: <31286715551-BeMail@zon> Message-ID: <20080511192131.742.2@knochen-vm.1210510002.fake> On 2008-05-11 at 19:09:47 [+0200], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > +#define B_KERNEL_AREA 0x4000 > > + // Usable from userland according to its protection flags, but the > > area > > + // itself is not deletable, resizable, etc from userland. > > Shouldn't that be true for all kernel areas automatically? I would > rather have it the other way around - a flag that permits these > changes. The flag is intended for userland areas only. My definition of userland area being that it belongs to a userland address space. CU, Ingo From ingo_weinhold at gmx.de Sun May 11 19:40:13 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 11 May 2008 19:40:13 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <10011450722-BeMail@laptop> References: <10011450722-BeMail@laptop> Message-ID: <20080511194013.775.3@knochen-vm.1210510002.fake> On 2008-05-11 at 19:10:56 [+0200], Fran?ois Revol wrote: > > On 2008-05-11 at 18:36:14 [+0200], Fran?ois Revol > > wrote: > > > This opens a security can by allowing a thread to become totally > > > unkillable... > > > (or is KILLTHR not affected ? still it allows to indefinitely block > > > others) > > > > SIGKILL[THR] are exempt. So are SIGILL, SIGSEGV, and SIGFPE ATM, > > since > > those are usually caused by the thread itself and it makes little > > sense to > > let it try to continue in those cases. Maybe other signals should be > > Some programs (jvm...) use SEGV to detect out of bound conditions to > trigger exceptions in the interpreted program, so yes they continue > from here. With "continue" I meant "continue without handling the signal". Blocking a SIGSEGV/SIGILL/SIGFPE would just result in an infinite loop (page fault, SIGSEGV, not handled, thread continues at the same location, page fault,...). > > > Actually are malloc() and friends allowed in sighandlers anyway ? > > > I've been told one should be very cautious on what to to in > > > sighandlers > > > and just defer processing by setting a flag. > > > > I'm not aware of any restrictions. Nor is bash. In some cases it even > > happily uses longjmp() and thus effectively never returns from the > > handler. > > Because longjmp is specifically specified to be called from int > handlers as some selected functions (see my other mail), this is not > the case of malloc or free (even if some platforms remove this > restriction by making them reentrant). It is not so much of interest what can be called from a signal handler, but when a signal handler can be called. longjmp()ing out of a signal handler that interrupted the memory allocator leaves the allocator's internal structures in an undefined state. Blocking signals is the only solution I see. It doesn't make the allocator functions reentrant (according to the common definition of reentrant), though. CU, Ingo From revol at free.fr Sun May 11 19:46:22 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 19:46:22 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080511194013.775.3@knochen-vm.1210510002.fake> Message-ID: <12137571805-BeMail@laptop> > > > > Actually are malloc() and friends allowed in sighandlers anyway > > > > ? > > > > I've been told one should be very cautious on what to to in > > > > sighandlers > > > > and just defer processing by setting a flag. > > > > > > I'm not aware of any restrictions. Nor is bash. In some cases it > > > even > > > happily uses longjmp() and thus effectively never returns from > > > the > > > handler. > > > > Because longjmp is specifically specified to be called from int > > handlers as some selected functions (see my other mail), this is > > not > > the case of malloc or free (even if some platforms remove this > > restriction by making them reentrant). > > It is not so much of interest what can be called from a signal > handler, but > when a signal handler can be called. longjmp()ing out of a signal > handler Indeed. > that interrupted the memory allocator leaves the allocator's internal > structures in an undefined state. Blocking signals is the only > solution I And that's what glibc does, just without resorting to changing the kernel. > see. It doesn't make the allocator functions reentrant (according to > the > common definition of reentrant), though. Yes it does, just not from the critical sections but that means everything else can call itself without deadlocking. Fran?ois. From ingo_weinhold at gmx.de Sun May 11 19:45:54 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 11 May 2008 19:45:54 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: References: <7929183321-BeMail@laptop> <9041995082-BeMail@laptop> Message-ID: <20080511194554.814.4@knochen-vm.1210510002.fake> On 2008-05-11 at 18:58:49 [+0200], Rene Gollent wrote: > On Sun, May 11, 2008 at 11:54 AM, Fran?ois Revol wrote: > > "On most systems, malloc and free are not reentrant, because they use a > > static data structure which records what memory blocks are free. As a > > result, no library functions that allocate or free memory are > > reentrant. This includes functions that allocate space to store a > > result." > > I would've thought HOARD would be reentrant though, given its emphasis > on multithreaded/multiprocessor scaling. Can anyone verify? A memory allocator cannot be reentrant, since it has to use static storage. The Hoard allocator is thread-safe though, and sports some optimizations for multithreaded use, if that's what you're referring to. CU, Ingo From mmu_man at mail.berlios.de Sun May 11 20:07:30 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 11 May 2008 20:07:30 +0200 Subject: [Haiku-commits] r25455 - haiku/trunk/3rdparty Message-ID: <200805111807.m4BI7Up4003464@sheep.berlios.de> Author: mmu_man Date: 2008-05-11 20:07:30 +0200 (Sun, 11 May 2008) New Revision: 25455 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25455&view=rev Modified: haiku/trunk/3rdparty/Jamfile Log: Automatically add subfolders with a Jamfile in 3rdparty. This allows hooking your own projects locally without having to touch this file, and have to resolve conflicts on svn up. One still must configure --enable-3rdparty of course or add this to UserBuildConfig: HAIKU_INCLUDE_3RDPARTY = 1 ; Modified: haiku/trunk/3rdparty/Jamfile =================================================================== --- haiku/trunk/3rdparty/Jamfile 2008-05-11 17:04:25 UTC (rev 25454) +++ haiku/trunk/3rdparty/Jamfile 2008-05-11 18:07:30 UTC (rev 25455) @@ -1,3 +1,10 @@ SubDir HAIKU_TOP 3rdparty ; -SubInclude HAIKU_TOP 3rdparty mmu_man ; +# automatically pick any subdir that contains a Jamfile +# this should allow hooking projects locally +# without having to touch this file and get conflicts when it is updated. +for subdir in [ GLOB $(SUBDIR) : [^.]* ] { + if [ GLOB $(subdir:G=) : Jamfile ] { + SubInclude HAIKU_TOP 3rdparty $(subdir:D=) ; + } +} From jackburton at mail.berlios.de Sun May 11 20:23:13 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 11 May 2008 20:23:13 +0200 Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal Message-ID: <200805111823.m4BINDB1004547@sheep.berlios.de> Author: jackburton Date: 2008-05-11 20:23:12 +0200 (Sun, 11 May 2008) New Revision: 25456 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25456&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: We shoulnd't mess with the pulse rate of the window, since if we are a replicant, the window is not ours. Blinking the cursor is now done with a BMessageRunner. Removed the dragger for the time being, since Terminal as a replicant has some issues. Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-11 18:07:30 UTC (rev 25455) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-11 18:23:12 UTC (rev 25456) @@ -84,17 +84,18 @@ const static uint32 kUpdateSigWinch = 'Rwin'; +const static uint32 kBlinkCursor = 'BlCr'; const static rgb_color kBlackColor = { 0, 0, 0, 255 }; const static rgb_color kWhiteColor = { 255, 255, 255, 255 }; - TermView::TermView(BRect frame, int32 argc, const char **argv, int32 historySize) : BView(frame, "termview", B_FOLLOW_ALL, - B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), + B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED), fShell(NULL), fWinchRunner(NULL), + fCursorBlinkRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -140,9 +141,10 @@ TermView::TermView(int rows, int columns, int32 argc, const char **argv, int32 historySize) : BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL, - B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), + B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED), fShell(NULL), fWinchRunner(NULL), + fCursorBlinkRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -185,13 +187,16 @@ _InitObject(argc, argv); SetTermSize(fTermRows, fTermColumns, true); + // TODO: Don't show the dragger, since replicant capabilities + // don't work very well ATM. + /* BRect rect(0, 0, 16, 16); rect.OffsetTo(Bounds().right - rect.Width(), Bounds().bottom - rect.Height()); SetFlags(Flags() | B_DRAW_ON_CHILDREN | B_FOLLOW_ALL); AddChild(new BDragger(rect, this, - B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW)); + B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW));*/ } @@ -200,6 +205,7 @@ BView(archive), fShell(NULL), fWinchRunner(NULL), + fCursorBlinkRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -1311,14 +1317,16 @@ if (fScrollBar) fScrollBar->SetSteps(fFontHeight, fFontHeight * fTermRows); + BMessenger thisMessenger(this); BMessage message(kUpdateSigWinch); - fWinchRunner = new (std::nothrow) BMessageRunner(BMessenger(this), &message, 500000); + fWinchRunner = + new (std::nothrow) BMessageRunner(thisMessenger, + &message, 500000); - // TODO: Since we can also be a replicant, messing - // with the window, which is not ours, is not nice: - // Switch to using a BMessageRunner for the - // blinking caret too. - Window()->SetPulseRate(1000000); + BMessage blinkMessage(kBlinkCursor); + fCursorBlinkRunner = + new (std::nothrow) BMessageRunner(thisMessenger, + &blinkMessage, 1000000); } @@ -1327,18 +1335,13 @@ { delete fWinchRunner; fWinchRunner = NULL; + + delete fCursorBlinkRunner; + fCursorBlinkRunner = NULL; } void -TermView::Pulse() -{ - //if (system_time() > fLastCursorTime + 1000000) - BlinkCursor(); -} - - -void TermView::Draw(BRect updateRect) { if (IsPrinting()) { @@ -1762,6 +1765,9 @@ // break; // } // } + case kBlinkCursor: + _BlinkCursor(); + break; case kUpdateSigWinch: _UpdateSIGWINCH(); break; Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2008-05-11 18:07:30 UTC (rev 25455) +++ haiku/trunk/src/apps/terminal/TermView.h 2008-05-11 18:23:12 UTC (rev 25456) @@ -123,7 +123,6 @@ protected: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); - virtual void Pulse(); virtual void Draw(BRect updateRect); virtual void WindowActivated(bool active); virtual void KeyDown(const char*, int32); @@ -194,6 +193,7 @@ Shell *fShell; BMessageRunner *fWinchRunner; + BMessageRunner *fCursorBlinkRunner; // Font and Width BFont fHalfFont; From revol at free.fr Sun May 11 20:27:15 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 20:27:15 +0200 CEST Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal In-Reply-To: <200805111823.m4BINDB1004547@sheep.berlios.de> Message-ID: <14590458769-BeMail@laptop> > We shoulnd't mess with the pulse rate of the window, since if we are > a > replicant, the window is not ours. Blinking the cursor is now done > with > a BMessageRunner. Indeed. > Removed the dragger for the time being, since Terminal as a replicant > has some issues. Well it crashes Tracker in Zeta when I tried to scroll up too much, but it actually instanciated correctly it seems. Besides if you can't test you can't fix ;) Fran?ois. From ingo_weinhold at gmx.de Sun May 11 20:26:45 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 11 May 2008 20:26:45 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <12137571805-BeMail@laptop> References: <12137571805-BeMail@laptop> Message-ID: <20080511202645.854.5@knochen-vm.1210510002.fake> On 2008-05-11 at 19:46:22 [+0200], Fran?ois Revol wrote: > > > that interrupted the memory allocator leaves the allocator's internal > > structures in an undefined state. Blocking signals is the only > > solution I > > And that's what glibc does, just without resorting to changing the > kernel. Interesting. How do they block signals then? > > see. It doesn't make the allocator functions reentrant (according to > > the > > common definition of reentrant), though. > > Yes it does, just not from the critical sections but that means > everything else can call itself without deadlocking. You seem to use a different definition of reentrant. Mine doesn't allow any memory allocator to be reentrant, since it relies on static storage. CU, Ingo From stefano.ceccherini at gmail.com Sun May 11 20:33:05 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Sun, 11 May 2008 20:33:05 +0200 Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal In-Reply-To: <14590458769-BeMail@laptop> References: <200805111823.m4BINDB1004547@sheep.berlios.de> <14590458769-BeMail@laptop> Message-ID: <894b9700805111133v72e8ce96o302239cbf8710e37@mail.gmail.com> 2008/5/11 Fran?ois Revol : > > We shoulnd't mess with the pulse rate of the window, since if we are > > a > > replicant, the window is not ours. Blinking the cursor is now done > > with > > a BMessageRunner. > > Indeed. > > > > Removed the dragger for the time being, since Terminal as a replicant > > has some issues. > > Well it crashes Tracker in Zeta when I tried to scroll up too much, but > it actually instanciated correctly it seems. The BDragger also scrolls up with the view and this is not nice :) > Besides if you can't test you can't fix ;) > Of course. But testing (for a developer) is very easy... just uncomment those few lines and you're done :) From jackburton at mail.berlios.de Sun May 11 20:34:30 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sun, 11 May 2008 20:34:30 +0200 Subject: [Haiku-commits] r25457 - haiku/trunk/src/apps/terminal Message-ID: <200805111834.m4BIYUK1005227@sheep.berlios.de> Author: jackburton Date: 2008-05-11 20:34:29 +0200 (Sun, 11 May 2008) New Revision: 25457 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25457&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp Log: typo which broke the build Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-11 18:23:12 UTC (rev 25456) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2008-05-11 18:34:29 UTC (rev 25457) @@ -1766,7 +1766,7 @@ // } // } case kBlinkCursor: - _BlinkCursor(); + BlinkCursor(); break; case kUpdateSigWinch: _UpdateSIGWINCH(); From superstippi at gmx.de Sun May 11 20:41:23 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 11 May 2008 20:41:23 +0200 Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700805111133v72e8ce96o302239cbf8710e37@mail.gmail.com> References: <200805111823.m4BINDB1004547@sheep.berlios.de> <14590458769-BeMail@laptop> <894b9700805111133v72e8ce96o302239cbf8710e37@mail.gmail.com> Message-ID: <20080511204123.1224.2@stippis2.1210529677.fake> Stefano Ceccherini wrote: > 2008/5/11 Fran?ois Revol : > > Besides if you can't test you can't fix ;) > > > Of course. But testing (for a developer) is very easy... just uncomment > those few lines and you're done :) +1. :-) Best regards, -Stephan From revol at free.fr Sun May 11 20:44:49 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 20:44:49 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080511202645.854.5@knochen-vm.1210510002.fake> Message-ID: <15644717196-BeMail@laptop> > > On 2008-05-11 at 19:46:22 [+0200], Fran?ois Revol > wrote: > > > > > that interrupted the memory allocator leaves the allocator's > > > internal > > > structures in an undefined state. Blocking signals is the only > > > solution I > > > > And that's what glibc does, just without resorting to changing the > > kernel. > > Interesting. How do they block signals then? Actually I'm wondering, it doesn't seem to have that many calls to sigaction in glibc-2.7/malloc/ or are mutex_lock() calls supposed to do that ? > > > see. It doesn't make the allocator functions reentrant (according > > > to > > > the > > > common definition of reentrant), though. > > > > Yes it does, just not from the critical sections but that means > > everything else can call itself without deadlocking. > > You seem to use a different definition of reentrant. Mine doesn't > allow any > memory allocator to be reentrant, since it relies on static storage. Well it seems opengroup and gnu don't really have the same either, I didn't bother checking if theirs was legal. Fran?ois. From revol at free.fr Sun May 11 20:46:47 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 20:46:47 +0200 CEST Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal In-Reply-To: <894b9700805111133v72e8ce96o302239cbf8710e37@mail.gmail.com> Message-ID: <15763002897-BeMail@laptop> > 2008/5/11 Fran?ois Revol : > > > We shoulnd't mess with the pulse rate of the window, since if we > > > are > > > a > > > replicant, the window is not ours. Blinking the cursor is now > > > done > > > with > > > a BMessageRunner. > > > > Indeed. > > Maybe we should document the fact that Pulse() should not be used unless you don't care about replicants, and MessageRunning be pointed to there. > > > > > Removed the dragger for the time being, since Terminal as a > > > replicant > > > has some issues. > > > > Well it crashes Tracker in Zeta when I tried to scroll up too > > much, but > > it actually instanciated correctly it seems. > > The BDragger also scrolls up with the view and this is not nice :) How about fixing ? :) > > Besides if you can't test you can't fix ;) > > > Of course. But testing (for a developer) is very easy... just > uncomment those few lines and you're done :) That's what all users should be currently, we're not at R1 yet :D Fran?ois. From axeld at pinc-software.de Sun May 11 20:49:59 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 20:49:59 +0200 CEST Subject: [Haiku-commits] r25450 - in haiku/trunk: headers/private/kernel src/system/kernel/vm In-Reply-To: <20080511192131.742.2@knochen-vm.1210510002.fake> Message-ID: <37298761922-BeMail@zon> Ingo Weinhold wrote: > On 2008-05-11 at 19:09:47 [+0200], Axel D?rfler > > wrote: > > bonefish at BerliOS wrote: > > > +#define B_KERNEL_AREA 0x4000 > > > + // Usable from userland according to its protection flags, > > > but the > > > area > > > + // itself is not deletable, resizable, etc from userland. > > Shouldn't that be true for all kernel areas automatically? I would > > rather have it the other way around - a flag that permits these > > changes. > The flag is intended for userland areas only. My definition of > userland > area being that it belongs to a userland address space. Yeah, I didn't understand it correctly before seeing your other changes :-) Bye, Axel. From axeld at pinc-software.de Sun May 11 20:51:38 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 20:51:38 +0200 CEST Subject: [Haiku-commits] r25453 - haiku/trunk/src/tests/system/kernel/device_manager/playground In-Reply-To: <10305665134-BeMail@laptop> Message-ID: <37398022853-BeMail@zon> "Fran?ois Revol" wrote: > > haiku/trunk/src/tests/system/kernel/device_manager/playground > > /generic_video_driver.cpp > > haiku/trunk/src/tests/system/kernel/device_manager/playground > > /specific_video_driver.cpp > I plan on having a look at it, I have some ideas on that, but first, > does it still allow writing drivers in plain C ? :D Of course :-) But what ideas are you talking about? I'm already pretty far with fleshing out the details, so earlier I can take those ideas into account, the better. Bye, Axel. From mmlr at mail.berlios.de Sun May 11 20:55:12 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 11 May 2008 20:55:12 +0200 Subject: [Haiku-commits] r25458 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm Message-ID: <200805111855.m4BItCip006726@sheep.berlios.de> Author: mmlr Date: 2008-05-11 20:55:12 +0200 (Sun, 11 May 2008) New Revision: 25458 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25458&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h Log: * Added support for device state change notifications and implemented the ETHER_GET_LINK_STATE and ETHER_SET_LINK_STATE_SEM to provide this information and notification. * Don't try to clear an endpoint halt in case of a B_CANCELED status in the callbacks as this is triggered by explicitly canceling transfers when the device is closed/removed. * Renamed the semaphore members to *Sem to distinguish them better. * Some minor other cleanup and some added comments. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h 2008-05-11 18:34:29 UTC (rev 25457) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h 2008-05-11 18:55:12 UTC (rev 25458) @@ -35,6 +35,24 @@ uint8 num_wakeup_pattern_filters; } _PACKED ethernet_functional_descriptor; +/* notification definitions */ +#define CDC_NOTIFY_NETWORK_CONNECTION 0x00 +#define CDC_NOTIFY_CONNECTION_SPEED_CHANGE 0x2a + +typedef struct cdc_notification_s { + uint8 request_type; + uint8 notification_code; + uint16 value; + uint16 index; + uint16 data_length; + uint8 data[0]; +} _PACKED cdc_notification; + +typedef struct cdc_connection_speed_s { + uint32 upstream_speed; /* in bits/s */ + uint32 downstream_speed; /* in bits/s */ +} _PACKED cdc_connection_speed; + extern usb_module_info *gUSBModule; extern "C" { Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-11 18:34:29 UTC (rev 25457) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-11 18:55:12 UTC (rev 25458) @@ -4,6 +4,7 @@ Distributed under the terms of the MIT license. */ #include +#include #include #include @@ -20,9 +21,17 @@ fDataInterfaceIndex(0), fMACAddressIndex(0), fMaxSegmentSize(0), - fControlEndpoint(0), + fNotifyEndpoint(0), fReadEndpoint(0), - fWriteEndpoint(0) + fWriteEndpoint(0), + fNotifyReadSem(-1), + fNotifyWriteSem(-1), + fNotifyBuffer(NULL), + fNotifyBufferLength(0), + fLinkStateChangeSem(-1), + fHasConnection(false), + fDownstreamSpeed(0), + fUpstreamSpeed(0) { const usb_device_descriptor *deviceDescriptor = gUSBModule->get_device_descriptor(device); @@ -50,6 +59,7 @@ && interface->generic_count > 0) { // try to find and interpret the union and ethernet functional // descriptors + foundUnionDescriptor = foundEthernetDescriptor = false; for (size_t j = 0; j < interface->generic_count; j++) { usb_generic_descriptor *generic = &interface->generic[j]->generic; if (generic->length >= 5 @@ -103,8 +113,24 @@ } fControlInterfaceIndex = controlIndex; - fControlEndpoint = interface->endpoint[0].handle; + fNotifyEndpoint = interface->endpoint[0].handle; + // setup notify buffer and try to schedule a notification transfer + fNotifyBufferLength = 64; + fNotifyBuffer = (uint8 *)malloc(fNotifyBufferLength); + if (fNotifyBuffer == NULL) { + TRACE_ALWAYS("out of memory for notify buffer allocation\n"); + return; + } + + if (gUSBModule->queue_interrupt(fNotifyEndpoint, fNotifyBuffer, + fNotifyBufferLength, _NotifyCallback, this) != B_OK) { + // we cannot use notifications - hardcode to active connection + fHasConnection = true; + fDownstreamSpeed = 1000 * 1000 * 10; // 10Mbps + fUpstreamSpeed = 1000 * 1000 * 10; // 10Mbps + } + if (dataIndex >= config->interface_count) { TRACE_ALWAYS("data interface index invalid\n"); return; @@ -126,16 +152,15 @@ } fDataInterfaceIndex = dataIndex; - fNotifyRead = create_sem(0, DRIVER_NAME"_notify_read"); - if (fNotifyRead < B_OK) { + fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read"); + if (fNotifyReadSem < B_OK) { TRACE_ALWAYS("failed to create read notify sem\n"); return; } - fNotifyWrite = create_sem(0, DRIVER_NAME"_notify_write"); - if (fNotifyWrite < B_OK) { + fNotifyWriteSem = create_sem(0, DRIVER_NAME"_notify_write"); + if (fNotifyWriteSem < B_OK) { TRACE_ALWAYS("failed to create write notify sem\n"); - delete_sem(fNotifyRead); return; } @@ -145,8 +170,13 @@ ECMDevice::~ECMDevice() { - delete_sem(fNotifyRead); - delete_sem(fNotifyWrite); + if (fNotifyReadSem >= B_OK) + delete_sem(fNotifyReadSem); + if (fNotifyWriteSem >= B_OK) + delete_sem(fNotifyWriteSem); + + gUSBModule->cancel_queued_transfers(fNotifyEndpoint); + free(fNotifyBuffer); } @@ -244,13 +274,13 @@ return result; } - result = acquire_sem_etc(fNotifyRead, 1, B_CAN_INTERRUPT, 0); + result = acquire_sem_etc(fNotifyReadSem, 1, B_CAN_INTERRUPT, 0); if (result < B_OK) { *numBytes = 0; return result; } - if (fStatusRead != B_OK) { + if (fStatusRead != B_OK && fStatusRead != B_CANCELED) { TRACE_ALWAYS("device status error 0x%08lx\n", fStatusRead); result = gUSBModule->clear_feature(fReadEndpoint, USB_FEATURE_ENDPOINT_HALT); @@ -281,13 +311,13 @@ return result; } - result = acquire_sem_etc(fNotifyWrite, 1, B_CAN_INTERRUPT, 0); + result = acquire_sem_etc(fNotifyWriteSem, 1, B_CAN_INTERRUPT, 0); if (result < B_OK) { *numBytes = 0; return result; } - if (fStatusWrite != B_OK) { + if (fStatusWrite != B_OK && fStatusWrite != B_CANCELED) { TRACE_ALWAYS("device status error 0x%08lx\n", fStatusWrite); result = gUSBModule->clear_feature(fWriteEndpoint, USB_FEATURE_ENDPOINT_HALT); @@ -318,6 +348,22 @@ *(uint32 *)buffer = fMaxSegmentSize; return B_OK; +#if HAIKU_TARGET_PLATFORM_HAIKU + case ETHER_SET_LINK_STATE_SEM: + fLinkStateChangeSem = *(sem_id *)buffer; + return B_OK; + + case ETHER_GET_LINK_STATE: + { + ether_link_state *state = (ether_link_state *)buffer; + state->media = IFM_ETHER | IFM_FULL_DUPLEX + | (fHasConnection ? IFM_ACTIVE : 0); + state->quality = 1000; + state->speed = fDownstreamSpeed / 1000; + return B_OK; + } +#endif + default: TRACE_ALWAYS("unsupported ioctl %lu\n", op); } @@ -367,7 +413,7 @@ ECMDevice *device = (ECMDevice *)cookie; device->fActualLengthRead = actualLength; device->fStatusRead = status; - release_sem_etc(device->fNotifyRead, 1, B_DO_NOT_RESCHEDULE); + release_sem_etc(device->fNotifyReadSem, 1, B_DO_NOT_RESCHEDULE); } @@ -378,5 +424,68 @@ ECMDevice *device = (ECMDevice *)cookie; device->fActualLengthWrite = actualLength; device->fStatusWrite = status; - release_sem_etc(device->fNotifyWrite, 1, B_DO_NOT_RESCHEDULE); + release_sem_etc(device->fNotifyWriteSem, 1, B_DO_NOT_RESCHEDULE); } + + +void +ECMDevice::_NotifyCallback(void *cookie, int32 status, void *data, + uint32 actualLength) +{ + if (status == B_CANCELED) + return; + + ECMDevice *device = (ECMDevice *)cookie; + if (status == B_OK && actualLength >= sizeof(cdc_notification)) { + bool linkStateChange = false; + cdc_notification *notification + = (cdc_notification *)device->fNotifyBuffer; + + switch (notification->notification_code) { + case CDC_NOTIFY_NETWORK_CONNECTION: + TRACE("connection state change to %d\n", notification->value); + device->fHasConnection = notification->value > 0; + linkStateChange = true; + break; + + case CDC_NOTIFY_CONNECTION_SPEED_CHANGE: + { + if (notification->data_length < sizeof(cdc_connection_speed) + || actualLength < sizeof(cdc_notification) + + sizeof(cdc_connection_speed)) { + TRACE_ALWAYS("not enough data in connection speed change\n"); + break; + } + + cdc_connection_speed *speed; + speed = (cdc_connection_speed *)¬ification->data[0]; + device->fUpstreamSpeed = speed->upstream_speed; + device->fDownstreamSpeed = speed->downstream_speed; + device->fHasConnection = true; + TRACE("connection speed change to %ld/%ld\n", + speed->downstream_speed, speed->upstream_speed); + linkStateChange = true; + break; + } + + default: + TRACE_ALWAYS("unsupported notification 0x%02x\n", + notification->notification_code); + break; + } + + if (linkStateChange && device->fLinkStateChangeSem >= B_OK) + release_sem_etc(device->fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); + } + + if (status != B_OK) { + TRACE_ALWAYS("device status error 0x%08lx\n", status); + if (gUSBModule->clear_feature(device->fNotifyEndpoint, + USB_FEATURE_ENDPOINT_HALT) != B_OK) + TRACE_ALWAYS("failed to clear halt state\n"); + } + + // schedule next notification buffer + gUSBModule->queue_interrupt(device->fNotifyEndpoint, device->fNotifyBuffer, + device->fNotifyBufferLength, _NotifyCallback, device); +} Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-11 18:34:29 UTC (rev 25457) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-11 18:55:12 UTC (rev 25458) @@ -33,31 +33,45 @@ void *data, uint32 actualLength); static void _WriteCallback(void *cookie, int32 status, void *data, uint32 actualLength); +static void _NotifyCallback(void *cookie, int32 status, + void *data, uint32 actualLength); status_t _ReadMACAddress(); + // state tracking status_t fStatus; bool fOpen; bool fRemoved; usb_device fDevice; - uint8 fMACAddress[6]; - + // interface and device infos uint8 fControlInterfaceIndex; uint8 fDataInterfaceIndex; uint8 fMACAddressIndex; uint16 fMaxSegmentSize; - usb_pipe fControlEndpoint; + // pipes for notifications and data io + usb_pipe fNotifyEndpoint; usb_pipe fReadEndpoint; usb_pipe fWriteEndpoint; + // data stores for async usb transfers uint32 fActualLengthRead; uint32 fActualLengthWrite; int32 fStatusRead; int32 fStatusWrite; - sem_id fNotifyRead; - sem_id fNotifyWrite; + sem_id fNotifyReadSem; + sem_id fNotifyWriteSem; + + uint8 * fNotifyBuffer; + uint32 fNotifyBufferLength; + + // connection data + sem_id fLinkStateChangeSem; + uint8 fMACAddress[6]; + bool fHasConnection; + uint32 fDownstreamSpeed; + uint32 fUpstreamSpeed; }; #endif //_USB_ECM_DEVICE_H_ From axeld at pinc-software.de Sun May 11 20:57:46 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 20:57:46 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25451_-_in_haiku/trunk=3A_headers/priv?= =?utf-8?q?ate/kernel_headers/private/kernel/arch/x86_headers/private/libr?= =?utf-8?q?oot_src/system/kernel__src/system/kernel/arch/x86?= In-Reply-To: <200805111625.m4BGPapq003667@sheep.berlios.de> Message-ID: <37765825318-BeMail@zon> bonefish at BerliOS wrote: > Log: > * For each userland team the kernel creates an area in the userland > address space that is fully locked and marked B_KERNEL_AREA. It can > thus be accessed by the kernel without additional checks. Not that I want to undermine your effort, but couldn't that have been solved entirely in the kernel? I mean in what way is this (ie. [un]defer_signals()) different to using sigprocmask()? Bye, Axel. From revol at free.fr Sun May 11 21:10:26 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 21:10:26 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25458_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/drivers/network/usb=5Fecm?= In-Reply-To: <200805111855.m4BItCip006726@sheep.berlios.de> Message-ID: <17181566681-BeMail@laptop> I'll be testing with my freebox right away: http://hardware4linux.info/component/21627/ [Device] Location ............... [/dev/bus/usb] /1/2 Class .................. 2 Subclass ............... 0 Protocol ............... 0 Vendor ID .............. 0x10eb Product ID ............. 0x0001 Version ................ 0x0100 Manufacturer String .... "FreeBox SA" Product String ......... "FreeBox 4" Serial Number .......... "1.00" [Configuration 0] [Interface 0] Class .............. 2 Subclass ........... 6 Protocol ........... 0 [Endpoint 0] MaxPacketSize .... 8 Interval ......... 64 Type ............. Interrupt Direction ........ Input Descriptor (0x24) .. 00 10 01 c3 ff Descriptor (0x24) .. 06 00 01 c3 ff Descriptor (0x24) .. 0f 07 00 00 00 00 ea 05 00 00 00 00 00 [Interface 1] Class .............. 10 Subclass ........... 0 Protocol ........... 0 [Endpoint 0] MaxPacketSize .... 64 Interval ......... 0 Type ............. Bulk Direction ........ Input [Endpoint 1] MaxPacketSize .... 64 Interval ......... 0 Type ............. Bulk Direction ........ Output Fran?ois. From revol at free.fr Sun May 11 21:17:47 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 21:17:47 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <37765825318-BeMail@zon> Message-ID: <17622124939-BeMail@laptop> > bonefish at BerliOS wrote: > > Log: > > * For each userland team the kernel creates an area in the userland > > address space that is fully locked and marked B_KERNEL_AREA. It > > can > > thus be accessed by the kernel without additional checks. > > Not that I want to undermine your effort, but couldn't that have been > solved entirely in the kernel? I mean in what way is this (ie. > [un]defer_signals()) different to using sigprocmask()? > Syscall latency I suppose... Fran?ois. From axeld at pinc-software.de Sun May 11 21:18:12 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 21:18:12 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <38991300044-BeMail@zon> "Ryan Leavengood" wrote: > On 5/11/08, Axel D?rfler wrote: > > I don't know. For me, a tool like Git is only really useful if you > > don't always have access to the actual repository, or if you want > > to > > manage more than one tree for whatever reasons (and don't want to > > use > > the usual branches for this). Otherwise, I don't really see any > > advantages, so at least I don't see any with regards to a sample > > code > > repository. But I don't really have used git for more than the > > occasional checkout (but I have to say it's a lot less intuitive > > to use > > than other tools I used so far). > I think GIt's usabiity has improved a lot recently. I certainly don't > find it that hard. In fact it is very similar to svn, minus all the > disadvantages of svn. [...] That all sounds very nice, but I still don't see why it has to be Git for this project other than your personal preference. Which is fine, of course :-) > Git is its own backup system, since each person has a full copy of > the > repo. I'd love to see what would happen if Berlios lost Haiku's SVN > repo. Hopefully that won't happen, but how sure can we be? In that > case the irony would be that the history of Haiku would be saved by > Git because Rene and other people have a Git clone of Haiku SVN repo > with all the history. I and others periodically download the full repository from BerliOS - just in case. But yours is probably more up to date. > Git is also very efficient. The entire repo for Haiku with all the > history fits in about 220 MB (not checked out.) That's indeed pretty impressive; the SVN repo I periodically get from BerliOS ways in about 400 MB. > > It certainly blows BerliOS limits quite a bit, but I don't really > > know > > what you mean by unmanageable. > As Rene says, doing anything with Berlios from the US is a huge pain. > Of course you European folks don't see that, but that doesn't mean it > isn't there ;) Okay, but that probably wouldn't go away if we switched to a Git server - as the bandwidth and responsiveness is usually limited by the server location and configuration. > But even besides that, the repo is just huge, so that svn update, or > God forbid, checking out all the code again, takes inordinate amounts > of time. The more we keep adding stuff "just in case", or because it > is the easiest thing, the worse it gets. A full checkout definitely takes some time (even though it's usually way less than an hour here), but "svn update" is pretty fast as long as I'm not using BeOS; it only takes a couple of seconds compared to several minutes on BeOS :-) > Moving to Git would probably > help, but it sounds like that won't ever happen. So at least for my > own projects I am using Git. I don't know if that never happens, but I think using git-svn is a good compromise for now; we could even host such a repository on our servers. It's just that I don't see the need to have more than one repository as long as that's available (which is obviously no real problem in Europe). And I definitely prefer rXXX revisions over how Git identifies a revision - that makes very clear what revision a specific release uses, and can be compared easily. Bye, Axel. From revol at free.fr Sun May 11 21:23:22 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 21:23:22 +0200 CEST Subject: [Haiku-commits] r25458 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <17181566681-BeMail@laptop> Message-ID: <17957816513-BeMail@laptop> > > I'll be testing with my freebox right away: > http://hardware4linux.info/component/21627/ > Testing on Zeta (with zeta's usb stack, I had to #ifdef on USB3.h btw) : KERN 'usb_enum_dpc'[20]: publish_command(usb_ecm): start KERN 'usb_enum_dpc'[20]: usb_ecm: creating device: vendor: 0x10eb; device: 0x0001 KERN 'usb_enum_dpc'[20]: usb_ecm: read mac address: 00:07:cb:00:00:ff KERN 'usb_enum_dpc'[20]: USBD: queue_interrupt: id_to_pipe failed for id 0 KERN 'usb_enum_dpc'[20]: usb_ecm: data interface does not provide two alternate interfaces KERN 'usb_enum_dpc'[20]: USBD: cancel_queued_transfers: id_to_pipe failed for id 0 KERN 'usb_enum_dpc'[20]: publish_command(usb_ecm) done Any reason you insist on the alt interface count ? Fran?ois. From revol at free.fr Sun May 11 21:48:44 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 11 May 2008 21:48:44 +0200 CEST Subject: [Haiku-commits] r25458 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <17957816513-BeMail@laptop> Message-ID: <19479375649-BeMail@laptop> > > > > I'll be testing with my freebox right away: > > http://hardware4linux.info/component/21627/ > > > > Testing on Zeta (with zeta's usb stack, I had to #ifdef on USB3.h > btw) > : This patch makes it recognized and published, though I can't dhcp on it yet. Fran?ois. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: usb_ecm.freebox.diff.txt URL: From mmlr at mail.berlios.de Sun May 11 22:07:11 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 11 May 2008 22:07:11 +0200 Subject: [Haiku-commits] r25459 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm Message-ID: <200805112007.m4BK7Bfi017301@sheep.berlios.de> Author: mmlr Date: 2008-05-11 22:07:11 +0200 (Sun, 11 May 2008) New Revision: 25459 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25459&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h Log: * Reset the connection state and speed when the underlaying device is removed. * Notify the stack of this by releasing the link state change sem (if present). * Also check for a removed device in the notify callback to prevent accessing a device that is going down. Removing the device under Haiku with an active link will now report the loss of connection. Still left to implement is to reuse a still existing device if the same device (based on its MAC) is replugged. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-11 18:55:12 UTC (rev 25458) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-11 20:07:11 UTC (rev 25459) @@ -372,6 +372,18 @@ } +void +ECMDevice::Removed() +{ + fRemoved = true; + fHasConnection = false; + fDownstreamSpeed = fUpstreamSpeed = 0; + + if (fLinkStateChangeSem >= B_OK) + release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); +} + + status_t ECMDevice::_ReadMACAddress() { @@ -432,10 +444,10 @@ ECMDevice::_NotifyCallback(void *cookie, int32 status, void *data, uint32 actualLength) { - if (status == B_CANCELED) + ECMDevice *device = (ECMDevice *)cookie; + if (status == B_CANCELED || device->fRemoved) return; - ECMDevice *device = (ECMDevice *)cookie; if (status == B_OK && actualLength >= sizeof(cdc_notification)) { bool linkStateChange = false; cdc_notification *notification Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-11 18:55:12 UTC (rev 25458) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-11 20:07:11 UTC (rev 25459) @@ -25,7 +25,7 @@ status_t Write(const uint8 *buffer, size_t *numBytes); status_t Control(uint32 op, void *buffer, size_t length); - void Removed() { fRemoved = true; }; + void Removed(); bool IsRemoved() { return fRemoved; }; private: From mmlr at mlotz.ch Sun May 11 22:50:10 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Sun, 11 May 2008 22:50:10 +0200 Subject: [Haiku-commits] r25458 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <19479375649-BeMail@laptop> References: <17957816513-BeMail@laptop> <19479375649-BeMail@laptop> Message-ID: <20080511203728.M8078@mlotz.ch> On Sun, 11 May 2008 21:48:44 +0200 CEST, Fran?ois Revol wrote >>> >>> I'll be testing with my freebox right away: >>> http://hardware4linux.info/component/21627/ >> >> Testing on Zeta (with zeta's usb stack, I had to #ifdef on USB3.h >> btw) > > This patch makes it recognized and published, though I can't dhcp on > it yet. The reason I insist on two alternate interfaces is simply because the standard insists on it. A conforming device needs to provide two alternates at the data interface index. The first being the "disabled" alternate that has no endpoints, while the second one is the "active" one that provides the two in and output endpoints. It is designed that way so that switching to the "active" alternate causes the device to actually open up the connection. In the case of a cell phone for example the device does not build up the connection until a host driver switches the interface to the active alternate. See http://www.usb.org/developers/devclass_docs/CDC1.2_WMC1.1.zip which includes the ECM specs. Are you sure that the device does not provide these alternates and it is not caused by the ZETA USB stack? The driver is not intended for anything besides the Haiku USB stack. It in fact relys on allowed behaviour that might not be met by either the R5 nor the ZETA USB stack. Therefore I would not recommend testing it with any other stack (it would probably deadlock). That's why I specifically have used the include BTW (when installing the Haiku USB stack under R5 I copy over the USB3.h). You should test this under Haiku and verify that you get the same errors. I would like to avoid working around other stacks' bugs if the device in question is in fact ok. If it turns out that this is one of those cases where the device implementation just doesn't follow the specs we will have to revert to working around of course. Regards Michael From haiku at kaldience.com Sun May 11 22:54:38 2008 From: haiku at kaldience.com (Maurice Kalinowski) Date: Sun, 11 May 2008 22:54:38 +0200 Subject: [Haiku-commits] r25455 - haiku/trunk/3rdparty In-Reply-To: <200805111807.m4BI7Up4003464@sheep.berlios.de> References: <200805111807.m4BI7Up4003464@sheep.berlios.de> Message-ID: <48275D0E.6020301@kaldience.com> mmu_man at BerliOS wrote: > Author: mmu_man > Date: 2008-05-11 20:07:30 +0200 (Sun, 11 May 2008) > New Revision: 25455 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25455&view=rev > > Modified: > haiku/trunk/3rdparty/Jamfile > Log: > Automatically add subfolders with a Jamfile in 3rdparty. > This allows hooking your own projects locally without having to touch this file, and have to resolve conflicts on svn up. > One still must configure --enable-3rdparty of course or add this to UserBuildConfig: > HAIKU_INCLUDE_3RDPARTY = 1 ; > Cool, thx. This is extremely useful to not always have it opened in the source control. But why are these options needed? You have to add the targets anyway to your user build, don't you? Maurice From axeld at pinc-software.de Sun May 11 23:23:21 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 23:23:21 +0200 CEST Subject: [Haiku-commits] r25456 - haiku/trunk/src/apps/terminal In-Reply-To: <15763002897-BeMail@laptop> Message-ID: <46500465100-BeMail@zon> "Fran?ois Revol" wrote: > > Of course. But testing (for a developer) is very easy... just > > uncomment those few lines and you're done :) > That's what all users should be currently, we're not at R1 yet :D There is no need to make something unusable - there is usually only a small percentage actually interested in working on some specific part. Bye, Axel. From axeld at pinc-software.de Sun May 11 23:27:18 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 23:27:18 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25459_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/network/usb=5Fecm?= In-Reply-To: <200805112007.m4BK7Bfi017301@sheep.berlios.de> Message-ID: <46737626584-BeMail@zon> mmlr at BerliOS wrote: > Removing the device under Haiku with an active link will now report > the loss of > connection. Still left to implement is to reuse a still existing > device if the > same device (based on its MAC) is replugged. Ideally, that shouldn't really be necessary - it would be nice if the net_server could detect removed devices, and delete their interfaces. If you replug it later, it should just be added again automatically. Through forced unpublishing, a device can be disconnected even if it is still opened. The network stack could easily detect this, too. Bye, Axel. From axeld at pinc-software.de Sun May 11 23:33:33 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 23:33:33 +0200 CEST Subject: [Haiku-commits] r25440 - in haiku/trunk/src/apps: . webwatch In-Reply-To: Message-ID: <47112527813-BeMail@zon> "Rene Gollent" wrote: > > It certainly blows BerliOS limits quite a bit, but I don't really > > know > > what you mean by unmanageable. > BerliOS don't have a problem with that? What are the theoretical > limits anyhow? They obviously don't have a problem with that, or at least they don't tell us :-) I don't know the limits offhand, I just remember vaguely that they are considerably lower than what we need. Bye, Axel. From axeld at pinc-software.de Sun May 11 23:37:47 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 11 May 2008 23:37:47 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <17622124939-BeMail@laptop> Message-ID: <47366330456-BeMail@zon> "Fran?ois Revol" wrote: > > bonefish at BerliOS wrote: > > > Log: > > > * For each userland team the kernel creates an area in the > > > userland > > > address space that is fully locked and marked B_KERNEL_AREA. It > > > can > > > thus be accessed by the kernel without additional checks. > > Not that I want to undermine your effort, but couldn't that have > > been > > solved entirely in the kernel? I mean in what way is this (ie. > > [un]defer_signals()) different to using sigprocmask()? > Syscall latency I suppose... Oh, good reason, actually :-) Bye, Axel. From ingo_weinhold at gmx.de Mon May 12 00:49:51 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 12 May 2008 00:49:51 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <15644717196-BeMail@laptop> References: <15644717196-BeMail@laptop> Message-ID: <20080512004951.1034.6@knochen-vm.1210510002.fake> On 2008-05-11 at 20:44:49 [+0200], Fran?ois Revol wrote: > > On 2008-05-11 at 19:46:22 [+0200], Fran?ois Revol > > wrote: > > > > > > > that interrupted the memory allocator leaves the allocator's > > > > internal > > > > structures in an undefined state. Blocking signals is the only > > > > solution I > > > > > > And that's what glibc does, just without resorting to changing the > > > kernel. > > > > Interesting. How do they block signals then? > > Actually I'm wondering, it doesn't seem to have that many calls to > sigaction in glibc-2.7/malloc/ The alternatives would be sigprocmask()/pthread_sigmask(), but grepping turns up neither. I tried to find the actual malloc() implementation, but I'm not sure, if I found it (public_mALLOc() I believe). The glibc code is so lovely. > or are mutex_lock() calls supposed to do > that ? Normally I wouldn't expect that locking a mutex blocks signals, but I'm blissfully ignorant wrt. glibc code. CU, Ingo From ingo_weinhold at gmx.de Mon May 12 01:00:51 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 12 May 2008 01:00:51 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <47366330456-BeMail@zon> References: <47366330456-BeMail@zon> Message-ID: <20080512010051.1067.7@knochen-vm.1210510002.fake> On 2008-05-11 at 23:37:47 [+0200], Axel D?rfler wrote: > "Fran?ois Revol" wrote: > > > bonefish at BerliOS wrote: > > > > Log: > > > > * For each userland team the kernel creates an area in the > > > > userland > > > > address space that is fully locked and marked B_KERNEL_AREA. It > > > > can > > > > thus be accessed by the kernel without additional checks. > > > Not that I want to undermine your effort, but couldn't that have > > > been > > > solved entirely in the kernel? I mean in what way is this (ie. > > > [un]defer_signals()) different to using sigprocmask()? > > Syscall latency I suppose... > > Oh, good reason, actually :-) Yeah, two extra syscalls per malloc()/free() would be a bit heavy. I stumbled over that when looking into the Solaris code wrt. to semaphores. Solaris seems to do a lot of threading stuff in userland. Another nice application for the user_thread structure is to make the thread blocking primitives cheaply available in userland. That will make it relatively easy and efficient to implement for instance a r/w lock. A benaphore, a thread queue and a few counters will suffice. CU, Ingo From axeld at pinc-software.de Mon May 12 10:28:26 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 12 May 2008 10:28:26 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080512010051.1067.7@knochen-vm.1210510002.fake> Message-ID: <2323007793-BeMail@zon> Ingo Weinhold wrote: > > Oh, good reason, actually :-) > Yeah, two extra syscalls per malloc()/free() would be a bit heavy. I > stumbled over that when looking into the Solaris code wrt. to > semaphores. > Solaris seems to do a lot of threading stuff in userland. > > Another nice application for the user_thread structure is to make the > thread blocking primitives cheaply available in userland. That will > make it > relatively easy and efficient to implement for instance a r/w lock. A > benaphore, a thread queue and a few counters will suffice. The only problem I have with this that it all needs to happen in locked down memory. Of course, 16 KB per team is not a problem, but the more we put in there, the more resources would be needed. Or is "wait_status" already enough, there? Right now, the limit is 1365 threads per team which is pretty much acceptable, I guess :-) Bye, Axel. From korli at mail.berlios.de Mon May 12 11:58:32 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 11:58:32 +0200 Subject: [Haiku-commits] r25460 - haiku/trunk/src/tests/system/benchmarks/libMicro Message-ID: <200805120958.m4C9wWqa027697@sheep.berlios.de> Author: korli Date: 2008-05-12 11:58:31 +0200 (Mon, 12 May 2008) New Revision: 25460 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25460&view=rev Modified: haiku/trunk/src/tests/system/benchmarks/libMicro/Jamfile Log: Patch from Kaoutsis to enable mutex and pthread_create tests. Modified: haiku/trunk/src/tests/system/benchmarks/libMicro/Jamfile =================================================================== --- haiku/trunk/src/tests/system/benchmarks/libMicro/Jamfile 2008-05-11 20:07:11 UTC (rev 25459) +++ haiku/trunk/src/tests/system/benchmarks/libMicro/Jamfile 2008-05-12 09:58:31 UTC (rev 25460) @@ -211,9 +211,9 @@ munmap.c : libmicro.a libroot.so ; -# atm unsupported -BinCommand mutex : - : libelided.a libroot.so ; +BinCommand mutex : + mutex.c + : libmicro.a libroot.so ; BinCommand nop : nop.c @@ -235,10 +235,9 @@ pread.c : libmicro.a libroot.so ; -# atm unsupported -# needs pthread_attr_setstacksize -BinCommand pthread_create : - : libelided.a libroot.so ; +BinCommand pthread_create : + pthread_create.c + : libmicro.a libroot.so ; BinCommand pwrite : pwrite.c From korli at mail.berlios.de Mon May 12 12:02:48 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 12:02:48 +0200 Subject: [Haiku-commits] r25461 - haiku/trunk/src/kits/tracker Message-ID: <200805121002.m4CA2m4S028257@sheep.berlios.de> Author: korli Date: 2008-05-12 12:02:48 +0200 (Mon, 12 May 2008) New Revision: 25461 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25461&view=rev Modified: haiku/trunk/src/kits/tracker/TrackerInitialState.cpp Log: Patch from Kaoutsis: replace hard coded path with find_directory(B_BEOS_ETC_DIRECTORY, ...) Modified: haiku/trunk/src/kits/tracker/TrackerInitialState.cpp =================================================================== --- haiku/trunk/src/kits/tracker/TrackerInitialState.cpp 2008-05-12 09:58:31 UTC (rev 25460) +++ haiku/trunk/src/kits/tracker/TrackerInitialState.cpp 2008-05-12 10:02:48 UTC (rev 25461) @@ -36,6 +36,7 @@ // add code to initialize a subset of the mime database, including // important sniffer rules +#include #include #include #include @@ -459,8 +460,18 @@ { // make the large Haiku Logo the default background -// BPath path; - BPath path("/boot/beos/etc/artwork"); + BPath path; + status_t status = find_directory(B_BEOS_ETC_DIRECTORY, &path); + if (status < B_OK) { + BString errorMessage; + errorMessage << "At " << __PRETTY_FUNCTION__ << "\n"; + errorMessage << "find_directory() failed. \nReason: "; + errorMessage << strerror(status); + (new BAlert("AlertError", errorMessage.String(), "OK", NULL, NULL, + B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); + return; + } + path.Append("artwork"); // FSFindTrackerSettingsDir(&path, false); // path.Append(kDefaultFolderTemplate); From korli at mail.berlios.de Mon May 12 12:33:01 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 12:33:01 +0200 Subject: [Haiku-commits] r25462 - haiku/trunk/src/bin/desklink Message-ID: <200805121033.m4CAX1vx002013@sheep.berlios.de> Author: korli Date: 2008-05-12 12:32:59 +0200 (Mon, 12 May 2008) New Revision: 25462 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25462&view=rev Modified: haiku/trunk/src/bin/desklink/desklink.cpp Log: Patch from Kaoutsis (I change a few things, like method names, introduced a private method for alerting, and the about menu item label). * the usual find_directory() fix * added a 'About...' menu item to the pop up menu. It uses the asynchronous Go() version (with the NULL argument); The synchronous version ate all the cpu, and don't know if that's a bug, since the alert was inside the MessageReceived() loop. Modified: haiku/trunk/src/bin/desklink/desklink.cpp =================================================================== --- haiku/trunk/src/bin/desklink/desklink.cpp 2008-05-12 10:02:48 UTC (rev 25461) +++ haiku/trunk/src/bin/desklink/desklink.cpp 2008-05-12 10:32:59 UTC (rev 25462) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku. All rights reserved. + * Copyright 2003-2008, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -51,6 +51,7 @@ // the application signature used by the replicant to find the // supporting code + class _EXPORT MediaReplicant; // the dragger part has to be exported @@ -75,10 +76,11 @@ virtual void MessageReceived(BMessage* message); private: - status_t LaunchByPath(const char *path); - status_t LaunchBySig(const char *sig); - void LoadSettings(); - void SaveSettings(); + void _AlertFindDirectory(status_t status, const char *where); + status_t _LaunchByPath(const char *path); + status_t _LaunchBySig(const char *sig); + void _LoadSettings(); + void _SaveSettings(); BBitmap* fSegments; VolumeSlider* fVolumeSlider; @@ -109,7 +111,7 @@ // Background Bitmap fSegments = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), B_CMAP8); fSegments->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_CMAP8); - LoadSettings(); + _LoadSettings(); } @@ -120,14 +122,14 @@ // Background Bitmap fSegments = new BBitmap(BRect(0, 0, 16 - 1, 16 - 1), B_CMAP8); fSegments->SetBits(kSpeakerBits, 16*16, 0, B_CMAP8); - LoadSettings(); + _LoadSettings(); } MediaReplicant::~MediaReplicant() { delete fSegments; - SaveSettings(); + _SaveSettings(); } @@ -159,41 +161,79 @@ case B_ABOUT_REQUESTED: (new BAlert("About Volume Control", "Volume Control (Replicant)\n" " Brought to you by J?r?me DUVAL.\n\n" - "Copyright " B_UTF8_COPYRIGHT "2003-2007, Haiku","OK"))->Go(); + "Copyright " B_UTF8_COPYRIGHT "2003-2008, Haiku","OK"))->Go(NULL); break; + case OPEN_MEDIA_PLAYER: + { + BPath mediaPlayerPath; + status_t status = find_directory(B_BEOS_APPS_DIRECTORY, &mediaPlayerPath); + if (status != B_OK) { + _AlertFindDirectory(status, __PRETTY_FUNCTION__); + break; + } + mediaPlayerPath.Append("MediaPlayer"); + // launch the media player app - if (LaunchBySig("application/x-vnd.Haiku-MediaPlayer") == B_OK - || LaunchBySig("application/x-vnd.Be.MediaPlayer") == B_OK - || LaunchByPath("/boot/beos/apps/MediaPlayer") == B_OK) + if (_LaunchBySig("application/x-vnd.Haiku-MediaPlayer") == B_OK + || _LaunchBySig("application/x-vnd.Be.MediaPlayer") == B_OK + || _LaunchByPath(mediaPlayerPath.Path()) == B_OK) break; (new BAlert("desklink", "Couldn't launch MediaPlayer", "OK"))->Go(); break; + } + case MEDIA_SETTINGS: + { + BPath mediaPrefsPath; + status_t status = find_directory(B_BEOS_PREFERENCES_DIRECTORY, + &mediaPrefsPath); + if (status != B_OK) { + _AlertFindDirectory(status, __PRETTY_FUNCTION__); + break; + } + mediaPrefsPath.Append("Media"); + // launch the media prefs app - if (LaunchBySig("application/x-vnd.Haiku-Media") == B_OK - || LaunchBySig("application/x-vnd.Be.MediaPrefs") == B_OK - || LaunchByPath("/boot/home/config/be/Preferences/Media") == B_OK) + if (_LaunchBySig("application/x-vnd.Haiku-Media") == B_OK + || _LaunchBySig("application/x-vnd.Be.MediaPrefs") == B_OK + || _LaunchByPath(mediaPrefsPath.Path()) == B_OK) break; (new BAlert("desklink", "Couldn't launch Media Preferences", "OK"))->Go(); break; + } + case SOUND_SETTINGS: + { + BPath soundsPrefsPath; + status_t status = find_directory(B_BEOS_PREFERENCES_DIRECTORY, + &soundsPrefsPath); + if (status != B_OK) { + _AlertFindDirectory(status, __PRETTY_FUNCTION__); + break; + } + soundsPrefsPath.Append("Sounds"); + // launch the sounds prefs app - if (LaunchBySig("application/x-vnd.Haiku-Sounds") == B_OK - || LaunchBySig("application/x-vnd.Be.SoundsPrefs") == B_OK - || LaunchByPath("/boot/home/config/be/Preferences/Sounds") == B_OK) + if (_LaunchBySig("application/x-vnd.Haiku-Sounds") == B_OK + || _LaunchBySig("application/x-vnd.Be.SoundsPrefs") == B_OK + || _LaunchByPath(soundsPrefsPath.Path()) == B_OK) break; (new BAlert("desklink", "Couldn't launch Sounds Preferences", "OK"))->Go(); break; + } + case TOGGLE_DONT_BEEP: fDontBeep = !fDontBeep; break; + case SET_VOLUME_WHICH: message->FindInt32("volwhich", &fVolumeWhich); break; + default: BView::MessageReceived(message); break; @@ -202,7 +242,7 @@ status_t -MediaReplicant::LaunchByPath(const char *path) +MediaReplicant::_LaunchByPath(const char *path) { BEntry ent; entry_ref ref; @@ -226,7 +266,7 @@ status_t -MediaReplicant::LaunchBySig(const char *sig) +MediaReplicant::_LaunchBySig(const char *sig) { app_info appInfo; status_t err; @@ -296,7 +336,12 @@ volMenu->AddItem(tmpItem); tmpItem->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT); menu->AddItem(volMenu); - + + menu->AddSeparatorItem(); + menu->SetFont(be_plain_font); + menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS, + new BMessage(B_ABOUT_REQUESTED))); + menu->SetTargetForItems(this); volMenu->SetTargetForItems(this); menu->Go(where, true, true, BRect(where - BPoint(4, 4), @@ -318,7 +363,7 @@ void -MediaReplicant::LoadSettings() +MediaReplicant::_LoadSettings() { fDontBeep = false; fVolumeWhich = VOLUME_USE_MIXER; @@ -339,7 +384,7 @@ void -MediaReplicant::SaveSettings() +MediaReplicant::_SaveSettings() { BPath p; if (find_directory(B_USER_SETTINGS_DIRECTORY, &p, false) < B_OK) @@ -357,6 +402,18 @@ } +void +MediaReplicant::_AlertFindDirectory(status_t status, const char *where) +{ + BString errorMessage; + errorMessage << "At " << where << "\n"; + errorMessage << "find_directory() failed. \nReason: "; + errorMessage << strerror(status); + (new BAlert("AlertError", errorMessage.String(), "OK", NULL, NULL, + B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); +} + + int main(int, char **argv) { From korli at mail.berlios.de Mon May 12 12:54:15 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 12:54:15 +0200 Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache Message-ID: <200805121054.m4CAsFo8002138@sheep.berlios.de> Author: korli Date: 2008-05-12 12:54:14 +0200 (Mon, 12 May 2008) New Revision: 25463 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25463&view=rev Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: block_cache_delete(): unlock the cache mutex before deleting the cache Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 10:32:59 UTC (rev 25462) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 10:54:14 UTC (rev 25463) @@ -2209,6 +2209,7 @@ delete transaction; } + locker.Unlock(); delete cache; } From superstippi at gmx.de Mon May 12 13:03:23 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 12 May 2008 13:03:23 +0200 Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache In-Reply-To: <200805121054.m4CAsFo8002138@sheep.berlios.de> References: <200805121054.m4CAsFo8002138@sheep.berlios.de> Message-ID: <20080512130323.1902.1@stippis2.1210584956.fake> korli at BerliOS wrote: > Author: korli > Date: 2008-05-12 12:54:14 +0200 (Mon, 12 May 2008) New Revision: 25463 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25463&view=rev > > Modified: > haiku/trunk/src/system/kernel/cache/block_cache.cpp > Log: > block_cache_delete(): unlock the cache mutex before deleting the cache > > > Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 > 10:32:59 UTC (rev 25462) > +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 > 10:54:14 UTC (rev 25463) > @@ -2209,6 +2209,7 @@ > delete transaction; > } > > + locker.Unlock(); > delete cache; > } Wow, yeah, that wasn't healthy! Could it be? 2059 finally nailed? Best regards, -Stephan From revol at free.fr Mon May 12 13:08:17 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 12 May 2008 13:08:17 +0200 CEST Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20080512130323.1902.1@stippis2.1210584956.fake> Message-ID: <3151696581-BeMail@laptop> > > + locker.Unlock(); > > delete cache; > > } > > Wow, yeah, that wasn't healthy! Could it be? 2059 finally nailed? > /me goes try to dump xemacs again. Axel btw it's from work.r5/src/ you need to make xemacs, I messed up. Let's see... Fran?ois. From mmlr at mail.berlios.de Mon May 12 13:22:37 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 12 May 2008 13:22:37 +0200 Subject: [Haiku-commits] r25464 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm Message-ID: <200805121122.m4CBMbG9007228@sheep.berlios.de> Author: mmlr Date: 2008-05-12 13:22:36 +0200 (Mon, 12 May 2008) New Revision: 25464 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25464&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h Log: * Implemented transparent device replugs. If the same device (by MAC address) is plugged in after having been unplugged the device will now reuse a still existing ECMDevice object. This allows for the link simply going down when a device is unplugged and going up again when the device is replugged. The nice thing is that due to the way our usb drivers work it doesn't matter where you replug the device, so you can switch it from one port to another or even from a highspeed to a fullspeed bus transparently. * Fix a race condition between the notify hook and the device removed hook. * Added some comments and extended some debug output to be more useful. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-12 10:54:14 UTC (rev 25463) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-12 11:22:36 UTC (rev 25464) @@ -28,14 +28,30 @@ { *cookie = NULL; + // check if this is a replug of an existing device first + mutex_lock(&gDriverLock); + for (int32 i = 0; i < MAX_DEVICES; i++) { + if (gECMDevices[i] == NULL) + continue; + + if (gECMDevices[i]->CompareAndReattach(device) != B_OK) + continue; + + TRACE_ALWAYS("ecm device %ld replugged\n", i); + *cookie = gECMDevices[i]; + mutex_unlock(&gDriverLock); + return B_OK; + } + + // no such device yet, create a new one ECMDevice *ecmDevice = new ECMDevice(device); status_t status = ecmDevice->InitCheck(); if (status < B_OK) { delete ecmDevice; + mutex_unlock(&gDriverLock); return status; } - mutex_lock(&gDriverLock); for (int32 i = 0; i < MAX_DEVICES; i++) { if (gECMDevices[i] != NULL) continue; @@ -156,7 +172,7 @@ status_t status = ENODEV; int32 index = strtol(name + strlen(sDeviceBaseName), NULL, 10); if (index >= 0 && index < MAX_DEVICES && gECMDevices[index]) { - status = gECMDevices[index]->Open(flags); + status = gECMDevices[index]->Open(); *cookie = gECMDevices[index]; } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-12 10:54:14 UTC (rev 25463) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.cpp 2008-05-12 11:22:36 UTC (rev 25464) @@ -16,6 +16,7 @@ : fStatus(B_ERROR), fOpen(false), fRemoved(false), + fInsideNotify(0), fDevice(device), fControlInterfaceIndex(0), fDataInterfaceIndex(0), @@ -35,87 +36,15 @@ { const usb_device_descriptor *deviceDescriptor = gUSBModule->get_device_descriptor(device); - const usb_configuration_info *config - = gUSBModule->get_nth_configuration(device, 0); - if (deviceDescriptor == NULL || config == NULL) { - TRACE_ALWAYS("failed to get basic device info\n"); + if (deviceDescriptor == NULL) { + TRACE_ALWAYS("failed to get device descriptor\n"); return; } - TRACE_ALWAYS("creating device: vendor: 0x%04x; device: 0x%04x\n", - deviceDescriptor->vendor_id, deviceDescriptor->product_id); + fVendorID = deviceDescriptor->vendor_id; + fProductID = deviceDescriptor->product_id; - uint8 controlIndex = 0; - uint8 dataIndex = 0; - bool foundUnionDescriptor = false; - bool foundEthernetDescriptor = false; - for (size_t i = 0; i < config->interface_count - && (!foundUnionDescriptor || !foundEthernetDescriptor); i++) { - usb_interface_info *interface = config->interface[i].active; - usb_interface_descriptor *descriptor = interface->descr; - if (descriptor->interface_class == USB_INTERFACE_CLASS_CDC - && descriptor->interface_subclass == USB_INTERFACE_SUBCLASS_ECM - && interface->generic_count > 0) { - // try to find and interpret the union and ethernet functional - // descriptors - foundUnionDescriptor = foundEthernetDescriptor = false; - for (size_t j = 0; j < interface->generic_count; j++) { - usb_generic_descriptor *generic = &interface->generic[j]->generic; - if (generic->length >= 5 - && generic->data[0] == FUNCTIONAL_SUBTYPE_UNION) { - controlIndex = generic->data[1]; - dataIndex = generic->data[2]; - foundUnionDescriptor = true; - } else if (generic->length >= sizeof(ethernet_functional_descriptor) - && generic->data[0] == FUNCTIONAL_SUBTYPE_ETHERNET) { - ethernet_functional_descriptor *ethernet - = (ethernet_functional_descriptor *)generic->data; - fMACAddressIndex = ethernet->mac_address_index; - fMaxSegmentSize = ethernet->max_segment_size; - foundEthernetDescriptor = true; - } - - if (foundUnionDescriptor && foundEthernetDescriptor) - break; - } - } - } - - if (!foundUnionDescriptor) { - TRACE_ALWAYS("did not find a union descriptor\n"); - return; - } - - if (!foundEthernetDescriptor) { - TRACE_ALWAYS("did not find an ethernet descriptor\n"); - return; - } - - if (_ReadMACAddress() != B_OK) { - TRACE_ALWAYS("failed to read mac address\n"); - return; - } - - if (controlIndex >= config->interface_count) { - TRACE_ALWAYS("control interface index invalid\n"); - return; - } - - // check that the indicated control interface fits our needs - usb_interface_info *interface = config->interface[controlIndex].active; - usb_interface_descriptor *descriptor = interface->descr; - if ((descriptor->interface_class != USB_INTERFACE_CLASS_CDC - || descriptor->interface_subclass != USB_INTERFACE_SUBCLASS_ECM) - || interface->endpoint_count == 0) { - TRACE_ALWAYS("control interface invalid\n"); - return; - } - - fControlInterfaceIndex = controlIndex; - fNotifyEndpoint = interface->endpoint[0].handle; - - // setup notify buffer and try to schedule a notification transfer fNotifyBufferLength = 64; fNotifyBuffer = (uint8 *)malloc(fNotifyBufferLength); if (fNotifyBuffer == NULL) { @@ -123,47 +52,28 @@ return; } - if (gUSBModule->queue_interrupt(fNotifyEndpoint, fNotifyBuffer, - fNotifyBufferLength, _NotifyCallback, this) != B_OK) { - // we cannot use notifications - hardcode to active connection - fHasConnection = true; - fDownstreamSpeed = 1000 * 1000 * 10; // 10Mbps - fUpstreamSpeed = 1000 * 1000 * 10; // 10Mbps - } - - if (dataIndex >= config->interface_count) { - TRACE_ALWAYS("data interface index invalid\n"); + fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read"); + if (fNotifyReadSem < B_OK) { + TRACE_ALWAYS("failed to create read notify sem\n"); return; } - // check that the indicated data interface fits our needs - if (config->interface[dataIndex].alt_count < 2) { - TRACE_ALWAYS("data interface does not provide two alternate interfaces\n"); + fNotifyWriteSem = create_sem(0, DRIVER_NAME"_notify_write"); + if (fNotifyWriteSem < B_OK) { + TRACE_ALWAYS("failed to create write notify sem\n"); return; } - // alternate 0 is the disabled, endpoint-less default interface - interface = &config->interface[dataIndex].alt[1]; - descriptor = interface->descr; - if (descriptor->interface_class != USB_INTERFACE_CLASS_CDC_DATA - || interface->endpoint_count < 2) { - TRACE_ALWAYS("data interface invalid\n"); + if (_SetupDevice() != B_OK) { + TRACE_ALWAYS("failed to setup device\n"); return; } - fDataInterfaceIndex = dataIndex; - fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read"); - if (fNotifyReadSem < B_OK) { - TRACE_ALWAYS("failed to create read notify sem\n"); + if (_ReadMACAddress(fDevice, fMACAddress) != B_OK) { + TRACE_ALWAYS("failed to read mac address\n"); return; } - fNotifyWriteSem = create_sem(0, DRIVER_NAME"_notify_write"); - if (fNotifyWriteSem < B_OK) { - TRACE_ALWAYS("failed to create write notify sem\n"); - return; - } - fStatus = B_OK; } @@ -175,16 +85,20 @@ if (fNotifyWriteSem >= B_OK) delete_sem(fNotifyWriteSem); - gUSBModule->cancel_queued_transfers(fNotifyEndpoint); + if (!fRemoved) + gUSBModule->cancel_queued_transfers(fNotifyEndpoint); + free(fNotifyBuffer); } status_t -ECMDevice::Open(uint32 flags) +ECMDevice::Open() { if (fOpen) return B_BUSY; + if (fRemoved) + return B_ERROR; // reset the device by switching the data interface to the disabled first // interface and then enable it by setting the second actual data interface @@ -280,12 +194,12 @@ return result; } - if (fStatusRead != B_OK && fStatusRead != B_CANCELED) { + if (fStatusRead != B_OK && fStatusRead != B_CANCELED && !fRemoved) { TRACE_ALWAYS("device status error 0x%08lx\n", fStatusRead); result = gUSBModule->clear_feature(fReadEndpoint, USB_FEATURE_ENDPOINT_HALT); if (result != B_OK) { - TRACE_ALWAYS("failed to clear halt state\n"); + TRACE_ALWAYS("failed to clear halt state on read\n"); *numBytes = 0; return result; } @@ -317,12 +231,12 @@ return result; } - if (fStatusWrite != B_OK && fStatusWrite != B_CANCELED) { + if (fStatusWrite != B_OK && fStatusWrite != B_CANCELED && !fRemoved) { TRACE_ALWAYS("device status error 0x%08lx\n", fStatusWrite); result = gUSBModule->clear_feature(fWriteEndpoint, USB_FEATURE_ENDPOINT_HALT); if (result != B_OK) { - TRACE_ALWAYS("failed to clear halt state\n"); + TRACE_ALWAYS("failed to clear halt state on write\n"); *numBytes = 0; return result; } @@ -379,21 +293,194 @@ fHasConnection = false; fDownstreamSpeed = fUpstreamSpeed = 0; + // the notify hook is different from the read and write hooks as it does + // itself schedule traffic (while the other hooks only release a semaphore + // to notify another thread which in turn safly checks for the removed + // case) - so we must ensure that we are not inside the notify hook anymore + // before returning, as we would otherwise violate the promise not to use + // any of the pipes after returning from the removed hook + while (atomic_add(&fInsideNotify, 0) != 0) + snooze(100); + + gUSBModule->cancel_queued_transfers(fNotifyEndpoint); + gUSBModule->cancel_queued_transfers(fReadEndpoint); + gUSBModule->cancel_queued_transfers(fWriteEndpoint); + if (fLinkStateChangeSem >= B_OK) release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); } status_t -ECMDevice::_ReadMACAddress() +ECMDevice::CompareAndReattach(usb_device device) { + const usb_device_descriptor *deviceDescriptor + = gUSBModule->get_device_descriptor(device); + + if (deviceDescriptor == NULL) { + TRACE_ALWAYS("failed to get device descriptor\n"); + return B_ERROR; + } + + if (deviceDescriptor->vendor_id != fVendorID + && deviceDescriptor->product_id != fProductID) { + // this certainly isn't the same device + return B_BAD_VALUE; + } + + // this might be the same device that was replugged - read the MAC address + // (which should be at the same index) to make sure + uint8 macBuffer[6]; + if (_ReadMACAddress(device, macBuffer) != B_OK + || memcmp(macBuffer, fMACAddress, sizeof(macBuffer)) != 0) { + // reading the MAC address failed or they are not the same + return B_BAD_VALUE; + } + + // this is the same device that was replugged - clear the removed state, + // re-setup the endpoints and transfers and open the device if it was + // previously opened + fDevice = device; + fRemoved = false; + status_t result = _SetupDevice(); + if (result != B_OK) { + fRemoved = true; + return result; + } + + // in case notifications do not work we will have a hardcoded connection + // need to register that and notify the network stack ourselfs if this is + // the case as the open will not result in a corresponding notification + bool noNotifications = fHasConnection; + + if (fOpen) { + fOpen = false; + result = Open(); + if (result == B_OK && noNotifications && fLinkStateChangeSem >= B_OK) + release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); + } + + return B_OK; +} + + +status_t +ECMDevice::_SetupDevice() +{ + const usb_configuration_info *config + = gUSBModule->get_nth_configuration(fDevice, 0); + + if (config == NULL) { + TRACE_ALWAYS("failed to get device configuration\n"); + return B_ERROR; + } + + uint8 controlIndex = 0; + uint8 dataIndex = 0; + bool foundUnionDescriptor = false; + bool foundEthernetDescriptor = false; + for (size_t i = 0; i < config->interface_count + && (!foundUnionDescriptor || !foundEthernetDescriptor); i++) { + usb_interface_info *interface = config->interface[i].active; + usb_interface_descriptor *descriptor = interface->descr; + if (descriptor->interface_class == USB_INTERFACE_CLASS_CDC + && descriptor->interface_subclass == USB_INTERFACE_SUBCLASS_ECM + && interface->generic_count > 0) { + // try to find and interpret the union and ethernet functional + // descriptors + foundUnionDescriptor = foundEthernetDescriptor = false; + for (size_t j = 0; j < interface->generic_count; j++) { + usb_generic_descriptor *generic = &interface->generic[j]->generic; + if (generic->length >= 5 + && generic->data[0] == FUNCTIONAL_SUBTYPE_UNION) { + controlIndex = generic->data[1]; + dataIndex = generic->data[2]; + foundUnionDescriptor = true; + } else if (generic->length >= sizeof(ethernet_functional_descriptor) + && generic->data[0] == FUNCTIONAL_SUBTYPE_ETHERNET) { + ethernet_functional_descriptor *ethernet + = (ethernet_functional_descriptor *)generic->data; + fMACAddressIndex = ethernet->mac_address_index; + fMaxSegmentSize = ethernet->max_segment_size; + foundEthernetDescriptor = true; + } + + if (foundUnionDescriptor && foundEthernetDescriptor) + break; + } + } + } + + if (!foundUnionDescriptor) { + TRACE_ALWAYS("did not find a union descriptor\n"); + return B_ERROR; + } + + if (!foundEthernetDescriptor) { + TRACE_ALWAYS("did not find an ethernet descriptor\n"); + return B_ERROR; + } + + if (controlIndex >= config->interface_count) { + TRACE_ALWAYS("control interface index invalid\n"); + return B_ERROR; + } + + // check that the indicated control interface fits our needs + usb_interface_info *interface = config->interface[controlIndex].active; + usb_interface_descriptor *descriptor = interface->descr; + if ((descriptor->interface_class != USB_INTERFACE_CLASS_CDC + || descriptor->interface_subclass != USB_INTERFACE_SUBCLASS_ECM) + || interface->endpoint_count == 0) { + TRACE_ALWAYS("control interface invalid\n"); + return B_ERROR; + } + + fControlInterfaceIndex = controlIndex; + fNotifyEndpoint = interface->endpoint[0].handle; + if (gUSBModule->queue_interrupt(fNotifyEndpoint, fNotifyBuffer, + fNotifyBufferLength, _NotifyCallback, this) != B_OK) { + // we cannot use notifications - hardcode to active connection + fHasConnection = true; + fDownstreamSpeed = 1000 * 1000 * 10; // 10Mbps + fUpstreamSpeed = 1000 * 1000 * 10; // 10Mbps + } + + if (dataIndex >= config->interface_count) { + TRACE_ALWAYS("data interface index invalid\n"); + return B_ERROR; + } + + // check that the indicated data interface fits our needs + if (config->interface[dataIndex].alt_count < 2) { + TRACE_ALWAYS("data interface does not provide two alternate interfaces\n"); + return B_ERROR; + } + + // alternate 0 is the disabled, endpoint-less default interface + interface = &config->interface[dataIndex].alt[1]; + descriptor = interface->descr; + if (descriptor->interface_class != USB_INTERFACE_CLASS_CDC_DATA + || interface->endpoint_count < 2) { + TRACE_ALWAYS("data interface invalid\n"); + return B_ERROR; + } + + fDataInterfaceIndex = dataIndex; + return B_OK; +} + + +status_t +ECMDevice::_ReadMACAddress(usb_device device, uint8 *buffer) +{ if (fMACAddressIndex == 0) return B_BAD_VALUE; size_t actualLength = 0; size_t macStringLength = 26; uint8 macString[macStringLength]; - status_t result = gUSBModule->get_descriptor(fDevice, USB_DESCRIPTOR_STRING, + status_t result = gUSBModule->get_descriptor(device, USB_DESCRIPTOR_STRING, fMACAddressIndex, 0, macString, macStringLength, &actualLength); if (result != B_OK) return result; @@ -408,12 +495,11 @@ for (int32 i = 0; i < 6; i++) { macPart[0] = macString[2 + i * 4 + 0]; macPart[1] = macString[2 + i * 4 + 2]; - fMACAddress[i] = strtol(macPart, NULL, 16); + buffer[i] = strtol(macPart, NULL, 16); } TRACE_ALWAYS("read mac address: %02x:%02x:%02x:%02x:%02x:%02x\n", - fMACAddress[0], fMACAddress[1], fMACAddress[2], fMACAddress[3], - fMACAddress[4], fMACAddress[5]); + buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); return B_OK; } @@ -445,8 +531,11 @@ uint32 actualLength) { ECMDevice *device = (ECMDevice *)cookie; - if (status == B_CANCELED || device->fRemoved) + atomic_add(&device->fInsideNotify, 1); + if (status == B_CANCELED || device->fRemoved) { + atomic_add(&device->fInsideNotify, -1); return; + } if (status == B_OK && actualLength >= sizeof(cdc_notification)) { bool linkStateChange = false; @@ -494,10 +583,11 @@ TRACE_ALWAYS("device status error 0x%08lx\n", status); if (gUSBModule->clear_feature(device->fNotifyEndpoint, USB_FEATURE_ENDPOINT_HALT) != B_OK) - TRACE_ALWAYS("failed to clear halt state\n"); + TRACE_ALWAYS("failed to clear halt state in notify hook\n"); } // schedule next notification buffer gUSBModule->queue_interrupt(device->fNotifyEndpoint, device->fNotifyBuffer, device->fNotifyBufferLength, _NotifyCallback, device); + atomic_add(&device->fInsideNotify, -1); } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-12 10:54:14 UTC (rev 25463) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/ECMDevice.h 2008-05-12 11:22:36 UTC (rev 25464) @@ -15,7 +15,7 @@ status_t InitCheck() { return fStatus; }; - status_t Open(uint32 flags); + status_t Open(); bool IsOpen() { return fOpen; }; status_t Close(); @@ -28,6 +28,8 @@ void Removed(); bool IsRemoved() { return fRemoved; }; + status_t CompareAndReattach(usb_device device); + private: static void _ReadCallback(void *cookie, int32 status, void *data, uint32 actualLength); @@ -36,13 +38,17 @@ static void _NotifyCallback(void *cookie, int32 status, void *data, uint32 actualLength); - status_t _ReadMACAddress(); + status_t _SetupDevice(); + status_t _ReadMACAddress(usb_device device, uint8 *buffer); // state tracking status_t fStatus; bool fOpen; bool fRemoved; + vint32 fInsideNotify; usb_device fDevice; + uint16 fVendorID; + uint16 fProductID; // interface and device infos uint8 fControlInterfaceIndex; From mmlr at mail.berlios.de Mon May 12 13:22:54 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 12 May 2008 13:22:54 +0200 Subject: [Haiku-commits] r25465 - haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial Message-ID: <200805121122.m4CBMsTf007905@sheep.berlios.de> Author: mmlr Date: 2008-05-12 13:22:53 +0200 (Mon, 12 May 2008) New Revision: 25465 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25465&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp Log: Fix typo that caused a too small buffer to be allocated for device names. Modified: haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp 2008-05-12 11:22:36 UTC (rev 25464) +++ haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp 2008-05-12 11:22:53 UTC (rev 25465) @@ -329,7 +329,7 @@ acquire_sem(gDriverLock); for(int32 i = 0; i < DEVICES_COUNT; i++) { if (gSerialDevices[i]) { - gDeviceNames[j] = (char *)malloc(strlen(sDeviceBaseName + 4)); + gDeviceNames[j] = (char *)malloc(strlen(sDeviceBaseName) + 4); if (gDeviceNames[j]) { sprintf(gDeviceNames[j], "%s%ld", sDeviceBaseName, i); j++; From revol at free.fr Mon May 12 13:28:15 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 12 May 2008 13:28:15 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25465_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/drivers/ports/usb=5Fserial?= In-Reply-To: <200805121122.m4CBMsTf007905@sheep.berlios.de> Message-ID: <4349296875-BeMail@laptop> > Author: mmlr > Date: 2008-05-12 13:22:53 +0200 (Mon, 12 May 2008) > New Revision: 25465 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25465&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial/Driver.cpp > Log: > Fix typo that caused a too small buffer to be allocated for device > names. Maybe we should factor out that kind of stuff, it could be handy to have a add/del_driver_device_name() and other funcs around. Fran?ois. From korli at mail.berlios.de Mon May 12 13:38:11 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 13:38:11 +0200 Subject: [Haiku-commits] r25466 - haiku/trunk/src/apps/installer Message-ID: <200805121138.m4CBcBoq029332@sheep.berlios.de> Author: korli Date: 2008-05-12 13:38:10 +0200 (Mon, 12 May 2008) New Revision: 25466 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25466&view=rev Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp haiku/trunk/src/apps/installer/CopyEngine.h haiku/trunk/src/apps/installer/InstallerCopyLoopControl.cpp haiku/trunk/src/apps/installer/InstallerCopyLoopControl.h haiku/trunk/src/apps/installer/InstallerWindow.cpp haiku/trunk/src/apps/installer/InstallerWindow.h Log: * Patch from Christian Fasshauer: provides a cancel button * fixed a few things: one couldn't restart the install process when cancelled, use B_QUIT_REQUESTED instead of QuitRequested(). Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-05-12 11:38:10 UTC (rev 25466) @@ -74,8 +74,10 @@ { status_t err = Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu()); - if (err != B_OK) + if (err != B_OK) { ERR("Start failed"); + BMessenger(fWindow).SendMessage(RESET_INSTALL); + } break; } } @@ -123,6 +125,9 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu) { CALLED(); + + fControl->Reset(); + status_t err = B_OK; PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked(); PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked(); @@ -182,6 +187,7 @@ "Try choosing a different disk or choose to not install optional " "items.", "Try installing anyway", "Cancel", 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { + BMessenger(fWindow).SendMessage(RESET_INSTALL); return B_OK; } @@ -203,6 +209,7 @@ if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) { SetStatusMessage("You can't install the contents of a disk onto " "itself. Please choose a different disk."); + BMessenger(fWindow).SendMessage(RESET_INSTALL); return B_OK; } @@ -213,6 +220,7 @@ "machine if you proceed.", "OK", "Cancel", 0, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) { SetStatusMessage("Installation stopped."); + BMessenger(fWindow).SendMessage(RESET_INSTALL); return B_OK; } @@ -230,16 +238,20 @@ BDirectory packageDir; int32 count = fPackages->CountItems(); for (int32 i = 0; i < count; i++) { + if (fControl->CheckUserCanceled()) + return B_OK; Package *p = static_cast(fPackages->ItemAt(i)); packageDir.SetTo(&srcDir, p->Folder()); CopyFolder(packageDir, targetDir); } } - LaunchFinishScript(targetDirectory); + if (!fControl->CheckUserCanceled()) { + LaunchFinishScript(targetDirectory); - BMessage msg(INSTALL_FINISHED); - BMessenger(fWindow).SendMessage(&msg); + BMessage msg(INSTALL_FINISHED); + BMessenger(fWindow).SendMessage(&msg); + } return B_OK; } @@ -250,7 +262,8 @@ { BEntry entry; status_t err; - while (srcDir.GetNextEntry(&entry) == B_OK) { + while (srcDir.GetNextEntry(&entry) == B_OK + && !fControl->CheckUserCanceled()) { StatStruct statbuf; entry.GetStat(&statbuf); @@ -299,6 +312,13 @@ } +bool +CopyEngine::Cancel() +{ + return fControl->Cancel(); +} + + // #pragma mark - Modified: haiku/trunk/src/apps/installer/CopyEngine.h =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.h 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/CopyEngine.h 2008-05-12 11:38:10 UTC (rev 25466) @@ -28,6 +28,7 @@ void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); void SetPackagesList(BList *list); void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; }; + bool Cancel(); private: void LaunchInitScript(BPath &path); void LaunchFinishScript(BPath &path); Modified: haiku/trunk/src/apps/installer/InstallerCopyLoopControl.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerCopyLoopControl.cpp 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/InstallerCopyLoopControl.cpp 2008-05-12 11:38:10 UTC (rev 25466) @@ -9,7 +9,8 @@ InstallerCopyLoopControl::InstallerCopyLoopControl(InstallerWindow *window) : fWindow(window), - fMessenger(window) + fMessenger(window), + fUserCanceled(false) { } @@ -48,7 +49,7 @@ bool InstallerCopyLoopControl::CheckUserCanceled() { - return false; + return fUserCanceled; } @@ -97,3 +98,21 @@ return false; } + +bool +InstallerCopyLoopControl::Cancel() +{ + fUserCanceled = (new BAlert("", + "Are you sure you want to to stop the installation?", + "Continue", "Stop", 0, + B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0; + return fUserCanceled; +} + + +void +InstallerCopyLoopControl::Reset() +{ + fUserCanceled = false; +} + Modified: haiku/trunk/src/apps/installer/InstallerCopyLoopControl.h =================================================================== --- haiku/trunk/src/apps/installer/InstallerCopyLoopControl.h 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/InstallerCopyLoopControl.h 2008-05-12 11:38:10 UTC (rev 25466) @@ -35,10 +35,13 @@ virtual bool ChecksumFile(const entry_ref *); virtual bool SkipAttribute(const char *attributeName); virtual bool PreserveAttribute(const char *attributeName); + bool Cancel(); + void Reset(); private: InstallerWindow *fWindow; BMessenger fMessenger; + bool fUserCanceled; }; #endif Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-05-12 11:38:10 UTC (rev 25466) @@ -71,6 +71,7 @@ : BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fDriveSetupLaunched(false), + fInstallStatus(kReadyForInstall), fLastSrcItem(NULL), fLastTargetItem(NULL) { @@ -110,6 +111,7 @@ "begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fBeginButton->MakeDefault(true); + fBeginButton->SetEnabled(false); fBackBox->AddChild(fBeginButton); fSetupButton = new BButton(BRect(bounds.left + 11, bounds.bottom - 35, @@ -135,18 +137,18 @@ fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false); - BRect fieldRect(bounds.left + 50, bounds.top + 70, bounds.right - 13, + BRect fieldRect(bounds.left + 13, bounds.top + 70, bounds.right - 13, bounds.top + 90); fSrcMenuField = new BMenuField(fieldRect, "srcMenuField", "Install from: ", fSrcMenu); - fSrcMenuField->SetDivider(bounds.right - 274); + fSrcMenuField->SetDivider(bounds.right - 300); fSrcMenuField->SetAlignment(B_ALIGN_RIGHT); fBackBox->AddChild(fSrcMenuField); fieldRect.OffsetBy(0, 23); fDestMenuField = new BMenuField(fieldRect, "destMenuField", "Onto: ", fDestMenu); - fDestMenuField->SetDivider(bounds.right - 274); + fDestMenuField->SetDivider(bounds.right - 300); fDestMenuField->SetAlignment(B_ALIGN_RIGHT); fBackBox->AddChild(fDestMenuField); @@ -182,20 +184,45 @@ InstallerWindow::MessageReceived(BMessage *msg) { switch (msg->what) { + case RESET_INSTALL: + fInstallStatus = kReadyForInstall; + fBeginButton->SetEnabled(true); + DisableInterface(false); + fBeginButton->SetLabel("Begin"); + break; case START_SCAN: StartScan(); + fBeginButton->SetEnabled(true); break; case BEGIN_MESSAGE: - { - BList *list = new BList(); - int32 size = 0; - fPackagesView->GetPackagesToInstall(list, &size); - fCopyEngine->SetPackagesList(list); - fCopyEngine->SetSpaceRequired(size); - BMessenger(fCopyEngine).SendMessage(ENGINE_START); - DisableInterface(true); + switch (fInstallStatus) { + case kReadyForInstall: + { + BList *list = new BList(); + int32 size = 0; + fPackagesView->GetPackagesToInstall(list, &size); + fCopyEngine->SetPackagesList(list); + fCopyEngine->SetSpaceRequired(size); + BMessenger(fCopyEngine).SendMessage(ENGINE_START); + fBeginButton->SetLabel("Stop"); + DisableInterface(true); + fInstallStatus = kInstalling; + break; + } + case kInstalling: + if (fCopyEngine->Cancel()) { + fInstallStatus = kCancelled; + SetStatusMessage("Installation cancelled."); + PostMessage(RESET_INSTALL); + } + break; + case kFinished: + PostMessage(B_QUIT_REQUESTED); + break; + case kCancelled: + break; + } break; - } case SHOW_BOTTOM_MESSAGE: ShowBottom(); break; @@ -224,6 +251,8 @@ break; } case STATUS_MESSAGE: { + if (fInstallStatus != kInstalling) + break; const char *status; if (msg->FindString("status", &status) == B_OK) { fLastStatus = fStatusView->Text(); @@ -233,6 +262,8 @@ break; } case INSTALL_FINISHED: + fBeginButton->SetLabel("Quit"); + fInstallStatus = kFinished; DisableInterface(false); break; case B_SOME_APP_LAUNCHED: @@ -242,6 +273,7 @@ if (msg->FindString("be:signature", &signature) == B_OK && strcasecmp(signature, DRIVESETUP_SIG) == 0) { fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED; + fBeginButton->SetEnabled(!fDriveSetupLaunched); DisableInterface(fDriveSetupLaunched); if (fDriveSetupLaunched) SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS @@ -307,7 +339,6 @@ void InstallerWindow::DisableInterface(bool disable) { - fBeginButton->SetEnabled(!disable); fSetupButton->SetEnabled(!disable); fSrcMenuField->SetEnabled(!disable); fDestMenuField->SetEnabled(!disable); Modified: haiku/trunk/src/apps/installer/InstallerWindow.h =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.h 2008-05-12 11:22:53 UTC (rev 25465) +++ haiku/trunk/src/apps/installer/InstallerWindow.h 2008-05-12 11:38:10 UTC (rev 25466) @@ -20,8 +20,16 @@ #define INSTALLER_RIGHT 402 +enum InstallStatus { + kReadyForInstall, + kInstalling, + kFinished, + kCancelled +}; + const uint32 STATUS_MESSAGE = 'iSTM'; const uint32 INSTALL_FINISHED = 'iIFN'; +const uint32 RESET_INSTALL = 'iRSI'; const char PACKAGES_DIRECTORY[] = "_packages_"; class InstallerWindow : public BWindow { @@ -46,6 +54,7 @@ BButton *fBeginButton, *fSetupButton; DrawButton *fDrawButton; bool fDriveSetupLaunched; + InstallStatus fInstallStatus; BTextView *fStatusView; BMenu* fSrcMenu, *fDestMenu; BMenuField* fSrcMenuField, *fDestMenuField; From korli at users.berlios.de Mon May 12 13:40:19 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 12 May 2008 13:40:19 +0200 Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20080512130323.1902.1@stippis2.1210584956.fake> References: <200805121054.m4CAsFo8002138@sheep.berlios.de> <20080512130323.1902.1@stippis2.1210584956.fake> Message-ID: 2008/5/12 Stephan Assmus : > > Wow, yeah, that wasn't healthy! Could it be? 2059 finally nailed? > No, the bug only happened when unmounting :) Bye, J?r?me From mmlr at mlotz.ch Mon May 12 13:52:50 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Mon, 12 May 2008 13:52:50 +0200 Subject: [Haiku-commits] r25465 - haiku/trunk/src/add-ons/kernel/drivers/ports/usb_serial In-Reply-To: <4349296875-BeMail@laptop> References: <200805121122.m4CBMsTf007905@sheep.berlios.de> <4349296875-BeMail@laptop> Message-ID: <20080512114702.M90426@mlotz.ch> On Mon, 12 May 2008 13:28:15 +0200 CEST, Fran?ois Revol wrote >> Fix typo that caused a too small buffer to be allocated for device >> names. > > Maybe we should factor out that kind of stuff, it could be handy to > have a > add/del_driver_device_name() and other funcs around. There are a few drivers that use a common way to do the whole device and name list operations. The problem is that it depends a bit on the driver if you can use such an interface. It depends on when/how you build your device names and if your device list has a 1:1 mapping with the device name list. Both things are usually not met in USB drivers as they usually are too dynamic because of the hot-plug architecture. For "normal" drivers such common functions to manage a device and a device name list should be helpful though. Regards Michael From superstippi at gmx.de Mon May 12 13:58:52 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 12 May 2008 13:58:52 +0200 Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache In-Reply-To: References: <200805121054.m4CAsFo8002138@sheep.berlios.de> <20080512130323.1902.1@stippis2.1210584956.fake> Message-ID: <20080512135852.3241.3@stippis2.1210584956.fake> J?r?me Duval wrote: > 2008/5/12 Stephan Assmus : > > > > Wow, yeah, that wasn't healthy! Could it be? 2059 finally nailed? > > > > No, the bug only happened when unmounting :) Nice catch anyways. I could just reproduce #2059, so yeah... it is still with us. :-\ Best regards, -Stephan From mmlr at mlotz.ch Mon May 12 14:00:14 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Mon, 12 May 2008 14:00:14 +0200 Subject: [Haiku-commits] r25459 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <46737626584-BeMail@zon> References: <200805112007.m4BK7Bfi017301@sheep.berlios.de> <46737626584-BeMail@zon> Message-ID: <20080512115300.M29672@mlotz.ch> On Sun, 11 May 2008 23:27:18 +0200 CEST, Axel D?rfler wrote > mmlr at BerliOS wrote: >> Removing the device under Haiku with an active link will now report >> the loss of >> connection. Still left to implement is to reuse a still existing >> device if the >> same device (based on its MAC) is replugged. > > Ideally, that shouldn't really be necessary - it would be nice if > the net_server could detect removed devices, and delete their > interfaces. If you replug it later, it should just be added again automatically. > Through forced unpublishing, a device can be disconnected even if it > is still opened. The network stack could easily detect this, too. Yes that would probably be the best solution in the long run. Anyway I have implemented transparent replugs now, as it isn't too complicated for this class of devices. BTW it turns out that restarting the net_server didn't do the trick to get the device recognized. It is only recognized if I boot with it plugged in. But when I boot with it and have the ipro1000 driver enabled too, then I cannot configure the device to use DHCP for some reason. Only when I remove the ipro1000 driver (that has no link attached in the test situation BTW) so the cell phone is the only network device it will work as expected (using DHCP). What I found out is that if I plug in the device (not detected by net_server) then quit the net_server and use ifconfig to make the device known (it appears in the network status and ifconfig) and then restart the net_server, it will vanish from both the network status and ifconfig again. Regards Michael From korli at users.berlios.de Mon May 12 14:52:11 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 12 May 2008 14:52:11 +0200 Subject: [Haiku-commits] r25463 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20080512135852.3241.3@stippis2.1210584956.fake> References: <200805121054.m4CAsFo8002138@sheep.berlios.de> <20080512130323.1902.1@stippis2.1210584956.fake> <20080512135852.3241.3@stippis2.1210584956.fake> Message-ID: 2008/5/12 Stephan Assmus : > Nice catch anyways. I could just reproduce #2059, so yeah... it is still > with us. :-\ > As I think again about it, it's not safe to unlock before deleting the cache. It should only be lock at the start of block_cache_delete() without a MutexLocker(). Thoughts ? Bye, J?r?me From korli at mail.berlios.de Mon May 12 14:57:00 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 14:57:00 +0200 Subject: [Haiku-commits] r25467 - haiku/trunk/src/system/kernel/cache Message-ID: <200805121257.m4CCv0Zn004064@sheep.berlios.de> Author: korli Date: 2008-05-12 14:56:59 +0200 (Mon, 12 May 2008) New Revision: 25467 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25467&view=rev Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: block_cache_delete(): only lock the cache mutex and avoid MutexLocker. the mutex is destroyed in the destructor. Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 11:38:10 UTC (rev 25466) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-05-12 12:56:59 UTC (rev 25467) @@ -2189,7 +2189,7 @@ if (allowWrites) block_cache_sync(cache); - MutexLocker locker(&cache->lock); + mutex_lock(&cache->lock); // free all blocks @@ -2209,7 +2209,6 @@ delete transaction; } - locker.Unlock(); delete cache; } From ingo_weinhold at gmx.de Mon May 12 15:20:03 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 12 May 2008 15:20:03 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <2323007793-BeMail@zon> References: <2323007793-BeMail@zon> Message-ID: <20080512152003.561.3@knochen-vm.1210596161.fake> On 2008-05-12 at 10:28:26 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > > Oh, good reason, actually :-) > > Yeah, two extra syscalls per malloc()/free() would be a bit heavy. I > > stumbled over that when looking into the Solaris code wrt. to > > semaphores. > > Solaris seems to do a lot of threading stuff in userland. > > > > Another nice application for the user_thread structure is to make the > > thread blocking primitives cheaply available in userland. That will > > make it > > relatively easy and efficient to implement for instance a r/w lock. A > > benaphore, a thread queue and a few counters will suffice. > > The only problem I have with this that it all needs to happen in locked > down memory. Of course, 16 KB per team is not a problem, but the more > we put in there, the more resources would be needed. Yep, right. In fact the area should grow dynamically as needed. I would want it to start with one page only and be resized whenever it is full. The only problem is that allocating the user_thread space currently happens with the team spinlock being held, so that the area can't be resized at that point. I'm sure the code can be reorganized to lift that constraint. > Or is "wait_status" already enough, there? For the thread blocking it is sufficient, yes. Though we might want to put more stuff there. Like the signal block mask, maybe even the signal handler array. > Right now, the limit is 1365 threads per team which is pretty much > acceptable, I guess :-) Yes, I suppose for most apps it will just suffice. :-) CU, Ingo From jackburton at mail.berlios.de Mon May 12 15:27:57 2008 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 12 May 2008 15:27:57 +0200 Subject: [Haiku-commits] r25468 - in haiku/trunk: headers/private/app src/kits/app Message-ID: <200805121327.m4CDRvcr006776@sheep.berlios.de> Author: jackburton Date: 2008-05-12 15:27:56 +0200 (Mon, 12 May 2008) New Revision: 25468 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25468&view=rev Removed: haiku/trunk/headers/private/app/PortQueue.h haiku/trunk/src/kits/app/PortQueue.cpp Modified: haiku/trunk/src/kits/app/Application.cpp haiku/trunk/src/kits/app/LinkReceiver.cpp haiku/trunk/src/kits/app/LinkSender.cpp Log: Removed PortQueue since it's not used. Small style (old) changes here and there. Deleted: haiku/trunk/headers/private/app/PortQueue.h Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-12 12:56:59 UTC (rev 25467) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-12 13:27:56 UTC (rev 25468) @@ -208,7 +208,6 @@ bigtime_t pulseRate; if (data->FindInt64("_pulse", &pulseRate) == B_OK) SetPulseRate(pulseRate); - } @@ -861,6 +860,8 @@ status_t BApplication::GetAppInfo(app_info *info) const { + if (be_app == NULL || be_roster == NULL) + return B_NO_INIT; return be_roster->GetRunningAppInfo(be_app->Team(), info); } @@ -879,9 +880,9 @@ bool found = false; // App is already running. Get its entry ref with - // GetRunningAppInfo() + // GetAppInfo() app_info appInfo; - if (be_app && be_roster->GetRunningAppInfo(be_app->Team(), &appInfo) == B_OK) { + if (be_app && be_app->GetAppInfo(&appInfo) == B_OK) { ref = appInfo.ref; found = true; } else { @@ -889,14 +890,16 @@ found = BPrivate::get_app_ref(&ref) == B_OK; } - if (found) { - BFile file(&ref, B_READ_ONLY); - if (file.InitCheck() == B_OK) { - BResources *resources = new BResources(); - if (resources->SetTo(&file, false) < B_OK) - delete resources; - else - sAppResources = resources; + if (!found) + return NULL; + + BFile file(&ref, B_READ_ONLY); + if (file.InitCheck() == B_OK) { + sAppResources = new (nothrow) BResources(&file, false); + if (sAppResources != NULL + && sAppResources->InitCheck() != B_OK) { + delete sAppResources; + sAppResources = NULL; } } Modified: haiku/trunk/src/kits/app/LinkReceiver.cpp =================================================================== --- haiku/trunk/src/kits/app/LinkReceiver.cpp 2008-05-12 12:56:59 UTC (rev 25467) +++ haiku/trunk/src/kits/app/LinkReceiver.cpp 2008-05-12 13:27:56 UTC (rev 25468) @@ -58,11 +58,9 @@ status_t LinkReceiver::GetNextMessage(int32 &code, bigtime_t timeout) { - int32 remaining; - fReadError = B_OK; - remaining = fDataSize - (fRecvStart + fReplySize); + int32 remaining = fDataSize - (fRecvStart + fReplySize); STRACE(("info: LinkReceiver GetNextReply() reports %ld bytes remaining in buffer.\n", remaining)); // find the position of the next message header in the buffer @@ -277,14 +275,12 @@ LinkReceiver::ReadString(char** _string, size_t* _length) { int32 length = 0; - status_t status; + status_t status = Read(&length); - status = Read(&length); if (status < B_OK) return status; char *string; - if (length < 0) { status = B_ERROR; goto err; @@ -309,6 +305,7 @@ if (_length) *_length = length; + *_string = string; return B_OK; @@ -324,9 +321,8 @@ LinkReceiver::ReadString(BString &string, size_t* _length) { int32 length = 0; - status_t status; + status_t status = Read(&length); - status = Read(&length); if (status < B_OK) return status; @@ -370,9 +366,8 @@ LinkReceiver::ReadString(char *buffer, size_t bufferLength) { int32 length = 0; - status_t status; + status_t status = Read(&length); - status = Read(&length); if (status < B_OK) return status; Modified: haiku/trunk/src/kits/app/LinkSender.cpp =================================================================== --- haiku/trunk/src/kits/app/LinkSender.cpp 2008-05-12 12:56:59 UTC (rev 25467) +++ haiku/trunk/src/kits/app/LinkSender.cpp 2008-05-12 13:27:56 UTC (rev 25468) @@ -195,8 +195,7 @@ return B_BUFFER_OVERFLOW; else if (newSize > kInitialBufferSize) newSize = (newSize + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); - - char *buffer = NULL; + if (newSize == fBufferSize) { // keep existing buffer if (_oldBuffer) @@ -205,7 +204,7 @@ } // create new larger buffer - buffer = (char *)malloc(newSize); + char *buffer = (char *)malloc(newSize); if (buffer == NULL) return B_NO_MEMORY; Deleted: haiku/trunk/src/kits/app/PortQueue.cpp From anevilyak at gmail.com Mon May 12 15:28:35 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Mon, 12 May 2008 08:28:35 -0500 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080512152003.561.3@knochen-vm.1210596161.fake> References: <2323007793-BeMail@zon> <20080512152003.561.3@knochen-vm.1210596161.fake> Message-ID: On Mon, May 12, 2008 at 8:20 AM, Ingo Weinhold wrote: > > Right now, the limit is 1365 threads per team which is pretty much > > acceptable, I guess :-) > > Yes, I suppose for most apps it will just suffice. :-) > The only place I could see that limit being a potential problem is some of the enterprise Java apps I've run into...some of those really really like to spawn a thread for absolutely everything. Regards, Rene From ingo_weinhold at gmx.de Mon May 12 15:31:12 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 12 May 2008 15:31:12 +0200 Subject: [Haiku-commits] r25467 - haiku/trunk/src/system/kernel/cache In-Reply-To: <200805121257.m4CCv0Zn004064@sheep.berlios.de> References: <200805121257.m4CCv0Zn004064@sheep.berlios.de> Message-ID: <20080512153112.596.4@knochen-vm.1210596161.fake> On 2008-05-12 at 14:57:00 [+0200], korli at BerliOS wrote: > Author: korli > Date: 2008-05-12 14:56:59 +0200 (Mon, 12 May 2008) > New Revision: 25467 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25467&view=rev > > Modified: > haiku/trunk/src/system/kernel/cache/block_cache.cpp > Log: > block_cache_delete(): only lock the cache mutex and avoid MutexLocker. the > mutex is destroyed in the destructor. Looks better now, though the locking is still not right. There's a potential deadlock between block_cache_delete() and get_next_locked_block_cache(), since they lock the cache's mutex and the sCachesLock in different order. Haven't looked through the rest of the code how it is done there. CU, Ingo From bonefish at mail.berlios.de Mon May 12 15:53:56 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 May 2008 15:53:56 +0200 Subject: [Haiku-commits] r25469 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200805121353.m4CDruMa009715@sheep.berlios.de> Author: bonefish Date: 2008-05-12 15:53:56 +0200 (Mon, 12 May 2008) New Revision: 25469 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25469&view=rev Modified: haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/thread.h haiku/trunk/src/system/kernel/thread.cpp Log: Added new syscalls _kern_block_thread()/_kern_unblock_thread[s](). Modified: haiku/trunk/headers/private/kernel/syscalls.h =================================================================== --- haiku/trunk/headers/private/kernel/syscalls.h 2008-05-12 13:27:56 UTC (rev 25468) +++ haiku/trunk/headers/private/kernel/syscalls.h 2008-05-12 13:53:56 UTC (rev 25469) @@ -130,6 +130,11 @@ extern status_t _kern_get_next_team_info(int32 *cookie, team_info *info); extern status_t _kern_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); +extern status_t _kern_block_thread(uint32 flags, bigtime_t timeout); +extern status_t _kern_unblock_thread(thread_id thread, status_t status); +extern status_t _kern_unblock_threads(thread_id* threads, uint32 count, + status_t status); + // user/group functions extern gid_t _kern_getgid(bool effective); extern uid_t _kern_getuid(bool effective); Modified: haiku/trunk/headers/private/kernel/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/thread.h 2008-05-12 13:27:56 UTC (rev 25468) +++ haiku/trunk/headers/private/kernel/thread.h 2008-05-12 13:53:56 UTC (rev 25469) @@ -117,6 +117,11 @@ status_t _user_get_thread_info(thread_id id, thread_info *info); status_t _user_get_next_thread_info(team_id team, int32 *cookie, thread_info *info); +status_t _user_block_thread(uint32 flags, bigtime_t timeout); +status_t _user_unblock_thread(thread_id thread, status_t status); +status_t _user_unblock_threads(thread_id* threads, uint32 count, + status_t status); + // ToDo: these don't belong here struct rlimit; int _user_getrlimit(int resource, struct rlimit * rlp); Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-05-12 13:27:56 UTC (rev 25468) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-05-12 13:53:56 UTC (rev 25469) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -2309,6 +2310,23 @@ } +/*! Thread spinlock must be held. +*/ +static status_t +user_unblock_thread(thread_id threadID, status_t status) +{ + struct thread* thread = thread_get_thread_struct_locked(threadID); + if (thread == NULL) + return B_BAD_THREAD_ID; + if (thread->user_thread == NULL) + return B_NOT_ALLOWED; + + thread_unblock_locked(thread, status); + + return B_OK; +} + + // #pragma mark - public kernel API @@ -2903,9 +2921,63 @@ } -// ToDo: the following two functions don't belong here +status_t +_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(); + InterruptsSpinLocker locker(thread_spinlock); + + // check, if already done + if (thread->user_thread->wait_status <= 0) + return thread->user_thread->wait_status; + + // nope, so wait + thread_prepare_to_block(thread, flags, THREAD_BLOCK_TYPE_OTHER, "user"); + status_t status = thread_block_with_timeout_locked(flags, timeout); + thread->user_thread->wait_status = status; + + return syscall_restart_handle_timeout_post(status, timeout); +} + + +status_t +_user_unblock_thread(thread_id threadID, status_t status) +{ + InterruptsSpinLocker locker(thread_spinlock); + return user_unblock_thread(threadID, status); +} + + +status_t +_user_unblock_threads(thread_id* userThreads, uint32 count, status_t status) +{ + enum { + MAX_USER_THREADS_TO_UNBLOCK = 128 + }; + + if (userThreads == NULL || !IS_USER_ADDRESS(userThreads)) + return B_BAD_ADDRESS; + if (count > MAX_USER_THREADS_TO_UNBLOCK) + return B_BAD_VALUE; + + thread_id threads[MAX_USER_THREADS_TO_UNBLOCK]; + if (user_memcpy(threads, userThreads, count * sizeof(thread_id)) != B_OK) + return B_BAD_ADDRESS; + + for (uint32 i = 0; i < count; i++) + user_unblock_thread(threads[i], status); + + return B_OK; +} + + +// TODO: the following two functions don't belong here + + int _user_getrlimit(int resource, struct rlimit *urlp) { From bonefish at mail.berlios.de Mon May 12 15:56:12 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 May 2008 15:56:12 +0200 Subject: [Haiku-commits] r25470 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread Message-ID: <200805121356.m4CDuCwc009910@sheep.berlios.de> Author: bonefish Date: 2008-05-12 15:56:11 +0200 (Mon, 12 May 2008) New Revision: 25470 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25470&view=rev Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp Modified: haiku/trunk/headers/posix/pthread.h haiku/trunk/src/system/libroot/posix/pthread/Jamfile Log: Added pthread rwlock support. Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2008-05-12 13:53:56 UTC (rev 25469) +++ haiku/trunk/headers/posix/pthread.h 2008-05-12 13:56:11 UTC (rev 25470) @@ -6,6 +6,7 @@ #define _PTHREAD_H_ +#include #include @@ -17,8 +18,8 @@ typedef struct _pthread_condattr *pthread_condattr_t; typedef int pthread_key_t; typedef struct _pthread_once pthread_once_t; -typedef struct _pthread_rwlock *pthread_rwlock_t; -typedef struct _pthread_rwlockattr *pthread_rwlockattr_t; +typedef struct _pthread_rwlock pthread_rwlock_t; +typedef struct _pthread_rwlockattr pthread_rwlockattr_t; typedef struct _pthread_barrier *pthread_barrier_t; typedef struct _pthread_barrierattr *pthread_barrierattr_t; typedef struct _pthread_spinlock *pthread_spinlock_t; @@ -28,7 +29,27 @@ pthread_mutex_t mutex; }; +struct _pthread_rwlock { + uint32_t flags; + int32_t owner; + union { + struct { + int32_t sem; + } shared; + struct { + int32_t lock_sem; + int32_t lock_count; + int32_t reader_count; + int32_t writer_count; + void* waiters[2]; + } local; + }; +}; +struct _pthread_rwlockattr { + uint32_t flags; +}; + enum pthread_mutex_type { PTHREAD_MUTEX_DEFAULT, PTHREAD_MUTEX_NORMAL, @@ -159,6 +180,28 @@ extern int pthread_condattr_setpshared(pthread_condattr_t *condAttr, int processShared); +/* rwlock functions */ +extern int pthread_rwlock_init(pthread_rwlock_t *lock, + const pthread_rwlockattr_t *attr); +extern int pthread_rwlock_destroy(pthread_rwlock_t *lock); +extern int pthread_rwlock_rdlock(pthread_rwlock_t *lock); +extern int pthread_rwlock_tryrdlock(pthread_rwlock_t *lock); +extern int pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, + const struct timespec *timeout); +extern int pthread_rwlock_wrlock(pthread_rwlock_t *lock); +extern int pthread_rwlock_trywrlock(pthread_rwlock_t *lock); +extern int pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, + const struct timespec *timeout); +extern int pthread_rwlock_unlock(pthread_rwlock_t *lock); + +/* rwlock attribute functions */ +extern int pthread_rwlockattr_init(pthread_rwlockattr_t *attr); +extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr); +extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, + int *shared); +extern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, + int shared); + /* misc. functions */ extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); Modified: haiku/trunk/src/system/libroot/posix/pthread/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-12 13:53:56 UTC (rev 25469) +++ haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-12 13:56:11 UTC (rev 25470) @@ -1,7 +1,7 @@ SubDir HAIKU_TOP src system libroot posix pthread ; UsePrivateKernelHeaders ; -UsePrivateHeaders libroot ; +UsePrivateHeaders libroot shared ; MergeObject posix_pthread.o : pthread.c @@ -15,5 +15,6 @@ pthread_mutex.c pthread_mutexattr.c pthread_once.c + pthread_rwlock.cpp ; Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp 2008-05-12 13:53:56 UTC (rev 25469) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp 2008-05-12 13:56:11 UTC (rev 25470) @@ -0,0 +1,430 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + +#include +#include +#include +#include +#include + + +#define MAX_READER_COUNT 1000000 + +#define RWLOCK_FLAG_SHARED 0x01 + + +struct Waiter : DoublyLinkedListLinkImpl { + Waiter(bool writer) + : + userThread(get_user_thread()), + thread(find_thread(NULL)), + writer(writer), + queued(false) + { + } + + user_thread* userThread; + thread_id thread; + status_t status; + bool writer; + bool queued; +}; + +typedef DoublyLinkedList WaiterList; + + +struct SharedRWLock { + uint32_t flags; + int32_t owner; + int32_t sem; + + status_t Init() + { + flags = RWLOCK_FLAG_SHARED; + owner = -1; + sem = create_sem(MAX_READER_COUNT, "pthread rwlock"); + + return sem >= 0 ? B_OK : EAGAIN; + } + + status_t Destroy() + { + if (sem < 0) + return B_BAD_VALUE; + return delete_sem(sem) == B_OK ? B_OK : B_BAD_VALUE; + } + + status_t ReadLock(bigtime_t timeout) + { + return acquire_sem_etc(sem, 1, + timeout >= 0 ? B_ABSOLUTE_REAL_TIME_TIMEOUT : 0, timeout); + } + + status_t WriteLock(bigtime_t timeout) + { + status_t error = acquire_sem_etc(sem, MAX_READER_COUNT, + timeout >= 0 ? B_ABSOLUTE_REAL_TIME_TIMEOUT : 0, timeout); + if (error == B_OK) + owner = find_thread(NULL); + return error; + } + + status_t Unlock() + { + if (find_thread(NULL) == owner) { + owner = -1; + return release_sem_etc(sem, MAX_READER_COUNT, 0); + } else + return release_sem(sem); + } +}; + + +struct LocalRWLock { + uint32_t flags; + int32_t owner; + int32_t lock_sem; + int32_t lock_count; + int32_t reader_count; + int32_t writer_count; + WaiterList waiters; + + status_t Init() + { + flags = 0; + owner = -1; + lock_sem = create_sem(0, "pthread rwlock"); + lock_count = 1; + reader_count = 0; + writer_count = 0; + new(&waiters) WaiterList; + + return lock_sem >= 0 ? B_OK : EAGAIN; + } + + status_t Destroy() + { + if (lock_sem < 0) + return B_BAD_VALUE; + return delete_sem(lock_sem) == B_OK ? B_OK : B_BAD_VALUE; + } + + bool StructureLock() + { + if (atomic_add((int32*)&lock_count, -1) <= 0) + acquire_sem(lock_sem); + return true; + } + + void StructureUnlock() + { + if (atomic_add((int32*)&lock_count, 1) < 0) + release_sem(lock_sem); + } + + status_t ReadLock(bigtime_t timeout) + { + Locker locker(this); + + if (writer_count == 0) { + reader_count++; + return B_OK; + } + + return _Wait(false, timeout); + } + + status_t WriteLock(bigtime_t timeout) + { + Locker locker(this); + + if (reader_count == 0 && writer_count == 0) { + writer_count++; + owner = find_thread(NULL); + return B_OK; + } + + return _Wait(true, timeout); + } + + status_t Unlock() + { + Locker locker(this); + + if (find_thread(NULL) == owner) { + writer_count--; + owner = -1; + } else + reader_count--; + + _Unblock(); + + return B_OK; + } + +private: + status_t _Wait(bool writer, bigtime_t timeout) + { + if (timeout == 0) + return B_TIMED_OUT; + + Waiter waiter(writer); + waiters.Add(&waiter); + waiter.queued = true; + waiter.userThread->wait_status = 1; + + if (writer) + writer_count++; + + StructureUnlock(); + status_t error = _kern_block_thread( + timeout >= 0 ? B_ABSOLUTE_REAL_TIME_TIMEOUT : 0, timeout); + StructureLock(); + + if (!waiter.queued) + return waiter.status; + + // we're still queued, which means an error (timeout, interrupt) + // occurred + waiters.Remove(&waiter); + + if (writer) + writer_count--; + + _Unblock(); + + return error; + } + + void _Unblock() + { + // Check whether there any waiting threads at all and whether anyone + // has the write lock + Waiter* waiter = waiters.Head(); + if (waiter == NULL || owner >= 0) + return; + + // writer at head of queue? + if (waiter->writer) { + if (reader_count == 0) { + waiter->status = B_OK; + waiter->queued = false; + waiters.Remove(waiter); + owner = waiter->thread; + + if (waiter->userThread->wait_status > 0) { + waiter->userThread->wait_status = B_OK; + _kern_unblock_thread(waiter->thread, B_OK); + } + } + return; + } + + // wake up one or more readers -- we unblock more than one reader at + // a time to save trips to the kernel + while (!waiters.IsEmpty() && !waiters.Head()->writer) { + static const int kMaxReaderUnblockCount = 128; + thread_id readers[kMaxReaderUnblockCount]; + int readerCount = 0; + + while (readerCount < kMaxReaderUnblockCount + && (waiter = waiters.Head()) != NULL + && !waiter->writer) { + waiter->status = B_OK; + waiter->queued = false; + waiters.Remove(waiter); + + if (waiter->userThread->wait_status > 0) { + waiter->userThread->wait_status = B_OK; + readers[readerCount++] = waiter->thread; + } + } + + if (readerCount > 0) + _kern_unblock_threads(readers, readerCount, B_OK); + } + } + + + struct Locking { + inline bool Lock(LocalRWLock* lockable) + { + return lockable->StructureLock(); + } + + inline void Unlock(LocalRWLock* lockable) + { + lockable->StructureUnlock(); + } + }; + typedef AutoLocker Locker; +}; + + +static void inline +assert_dummy() +{ + STATIC_ASSERT(sizeof(pthread_rwlock_t) >= sizeof(SharedRWLock)); + STATIC_ASSERT(sizeof(pthread_rwlock_t) >= sizeof(LocalRWLock)); +} + + +// #pragma mark - public lock functions + + +int +pthread_rwlock_init(pthread_rwlock_t* lock, const pthread_rwlockattr_t* attr) +{ + bool shared = attr != NULL && (attr->flags & RWLOCK_FLAG_SHARED) != 0; + + if (shared) + return ((SharedRWLock*)lock)->Init(); + else + return ((LocalRWLock*)lock)->Init(); +} + + +int +pthread_rwlock_destroy(pthread_rwlock_t* lock) +{ + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + return ((SharedRWLock*)lock)->Destroy(); + else + return ((LocalRWLock*)lock)->Destroy(); +} + + +int +pthread_rwlock_rdlock(pthread_rwlock_t* lock) +{ + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + return ((SharedRWLock*)lock)->ReadLock(B_INFINITE_TIMEOUT); + else + return ((LocalRWLock*)lock)->ReadLock(B_INFINITE_TIMEOUT); +} + + +int +pthread_rwlock_tryrdlock(pthread_rwlock_t* lock) +{ + status_t error; + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + error = ((SharedRWLock*)lock)->ReadLock(0); + else + error = ((LocalRWLock*)lock)->ReadLock(0); + + return error == B_TIMED_OUT ? EBUSY : error; +} + + +int pthread_rwlock_timedrdlock(pthread_rwlock_t* lock, + const struct timespec *timeout) +{ + bigtime_t timeoutMicros = timeout->tv_sec * 1000000LL + + timeout->tv_nsec / 1000LL; + + status_t error; + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + error = ((SharedRWLock*)lock)->ReadLock(timeoutMicros); + else + error = ((LocalRWLock*)lock)->ReadLock(timeoutMicros); + + return error == B_TIMED_OUT ? EBUSY : error; +} + + +int +pthread_rwlock_wrlock(pthread_rwlock_t* lock) +{ + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + return ((SharedRWLock*)lock)->WriteLock(B_INFINITE_TIMEOUT); + else + return ((LocalRWLock*)lock)->WriteLock(B_INFINITE_TIMEOUT); +} + + +int +pthread_rwlock_trywrlock(pthread_rwlock_t* lock) +{ + status_t error; + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + error = ((SharedRWLock*)lock)->WriteLock(0); + else + error = ((LocalRWLock*)lock)->WriteLock(0); + + return error == B_TIMED_OUT ? EBUSY : error; +} + + +int +pthread_rwlock_timedwrlock(pthread_rwlock_t* lock, + const struct timespec *timeout) +{ + bigtime_t timeoutMicros = timeout->tv_sec * 1000000LL + + timeout->tv_nsec / 1000LL; + + status_t error; + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + error = ((SharedRWLock*)lock)->WriteLock(timeoutMicros); + else + error = ((LocalRWLock*)lock)->WriteLock(timeoutMicros); + + return error == B_TIMED_OUT ? EBUSY : error; +} + + +int +pthread_rwlock_unlock(pthread_rwlock_t* lock) +{ + if ((lock->flags & RWLOCK_FLAG_SHARED) != 0) + return ((SharedRWLock*)lock)->Unlock(); + else + return ((LocalRWLock*)lock)->Unlock(); +} + + +// #pragma mark - public attribute functions + + +int +pthread_rwlockattr_init(pthread_rwlockattr_t* attr) +{ + attr->flags = 0; + return 0; +} + + +int +pthread_rwlockattr_destroy(pthread_rwlockattr_t* attr) +{ + return 0; +} + + +int +pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* attr, int* shared) +{ + *shared = (attr->flags & RWLOCK_FLAG_SHARED) != 0; + return 0; +} + + +int +pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr, int shared) +{ + if (shared) + attr->flags |= RWLOCK_FLAG_SHARED; + else + attr->flags &= ~RWLOCK_FLAG_SHARED; + + return 0; +} + From korli at users.berlios.de Mon May 12 17:14:25 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 12 May 2008 17:14:25 +0200 Subject: [Haiku-commits] r25467 - haiku/trunk/src/system/kernel/cache In-Reply-To: <20080512153112.596.4@knochen-vm.1210596161.fake> References: <200805121257.m4CCv0Zn004064@sheep.berlios.de> <20080512153112.596.4@knochen-vm.1210596161.fake> Message-ID: 2008/5/12 Ingo Weinhold : > Looks better now, though the locking is still not right. There's a potential > deadlock between block_cache_delete() and get_next_locked_block_cache(), > since they lock the cache's mutex and the sCachesLock in different order. Even if the cache's mutex is destroyed before locking sCachesLock ? > Haven't looked through the rest of the code how it is done there. > Axel would give some insights here :) Bye, J?r?me From ingo_weinhold at gmx.de Mon May 12 17:22:41 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 12 May 2008 17:22:41 +0200 Subject: [Haiku-commits] r25467 - haiku/trunk/src/system/kernel/cache In-Reply-To: References: <200805121257.m4CCv0Zn004064@sheep.berlios.de> <20080512153112.596.4@knochen-vm.1210596161.fake> Message-ID: <20080512172241.1769.7@knochen-vm.1210596161.fake> On 2008-05-12 at 17:14:25 [+0200], J?r?me Duval wrote: > 2008/5/12 Ingo Weinhold : > > Looks better now, though the locking is still not right. There's a > > potential > > deadlock between block_cache_delete() and get_next_locked_block_cache(), > > since they lock the cache's mutex and the sCachesLock in different order. > > Even if the cache's mutex is destroyed before locking sCachesLock ? Ah, good point. No, it's OK then. CU, Ingo From anevilyak at mail.berlios.de Mon May 12 18:05:54 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Mon, 12 May 2008 18:05:54 +0200 Subject: [Haiku-commits] r25471 - haiku/trunk/src/kits/app Message-ID: <200805121605.m4CG5s0t027824@sheep.berlios.de> Author: anevilyak Date: 2008-05-12 18:05:53 +0200 (Mon, 12 May 2008) New Revision: 25471 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25471&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: GCC4 fix. Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-12 13:56:11 UTC (rev 25470) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-12 16:05:53 UTC (rev 25471) @@ -895,7 +895,7 @@ BFile file(&ref, B_READ_ONLY); if (file.InitCheck() == B_OK) { - sAppResources = new (nothrow) BResources(&file, false); + sAppResources = new (std::nothrow) BResources(&file, false); if (sAppResources != NULL && sAppResources->InitCheck() != B_OK) { delete sAppResources; From korli at mail.berlios.de Mon May 12 18:55:48 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 18:55:48 +0200 Subject: [Haiku-commits] r25472 - in haiku/trunk: headers/private/shared src/add-ons/kernel/bus_managers/pci Message-ID: <200805121655.m4CGtmVN006163@sheep.berlios.de> Author: korli Date: 2008-05-12 18:55:47 +0200 (Mon, 12 May 2008) New Revision: 25472 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25472&view=rev Modified: haiku/trunk/headers/private/shared/pci-utils.h haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp Log: * the Chip field is currently unused in our pci ids list, so we prefer to provide the subsystem name when it is found as a second device description * adjusted pci device dump Modified: haiku/trunk/headers/private/shared/pci-utils.h =================================================================== --- haiku/trunk/headers/private/shared/pci-utils.h 2008-05-12 16:05:53 UTC (rev 25471) +++ haiku/trunk/headers/private/shared/pci-utils.h 2008-05-12 16:55:47 UTC (rev 25472) @@ -69,8 +69,9 @@ // search for the device for (i = 0; i < (int)PCI_DEVTABLE_LEN; i++) { if (PciDevTable[i].VenId == vendorID && PciDevTable[i].DevId == deviceID ) { - *devShort = PciDevTable[i].Chip && PciDevTable[i].Chip[0] ? PciDevTable[i].Chip : NULL; - *devFull = PciDevTable[i].ChipDesc && PciDevTable[i].ChipDesc[0] ? PciDevTable[i].ChipDesc : NULL; + *devShort = PciDevTable[i].ChipDesc && PciDevTable[i].ChipDesc[0] ? PciDevTable[i].ChipDesc : NULL; + if (PciDevTable[i].SubVenId == 0 || PciDevTable[i].SubDevId == 0) + i++; break; } } @@ -80,7 +81,6 @@ if (PciDevTable[i].VenId != vendorID || PciDevTable[i].DevId != deviceID) break; if (PciDevTable[i].SubVenId == subvendorID && PciDevTable[i].SubDevId == subsystemID ) { - *devShort = PciDevTable[i].Chip && PciDevTable[i].Chip[0] ? PciDevTable[i].Chip : NULL; *devFull = PciDevTable[i].ChipDesc && PciDevTable[i].ChipDesc[0] ? PciDevTable[i].ChipDesc : NULL; break; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2008-05-12 16:05:53 UTC (rev 25471) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_info.cpp 2008-05-12 16:55:47 UTC (rev 25472) @@ -178,13 +178,13 @@ if (!devShort && !devFull) { TRACE(("PCI: device %04x: Unknown\n", info->device_id)); } else if (devShort && devFull) { - TRACE(("PCI: device %04x: %s - %s\n", info->device_id, devShort, devFull)); + TRACE(("PCI: device %04x: %s (%s)\n", info->device_id, devShort, devFull)); } else { TRACE(("PCI: device %04x: %s\n", info->device_id, devShort ? devShort : devFull)); } #endif char classInfo[64]; - get_class_info(info->class_base, info->class_sub, info->class_api, classInfo, 64); + get_class_info(info->class_base, info->class_sub, info->class_api, classInfo, sizeof(classInfo)); TRACE(("PCI: info: %s\n", classInfo)); } TRACE(("PCI: line_size %02x, latency %02x, header_type %02x, BIST %02x\n", From korli at mail.berlios.de Mon May 12 19:16:06 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 19:16:06 +0200 Subject: [Haiku-commits] r25473 - haiku/trunk/src/bin/listdev Message-ID: <200805121716.m4CHG63w028409@sheep.berlios.de> Author: korli Date: 2008-05-12 19:16:05 +0200 (Mon, 12 May 2008) New Revision: 25473 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25473&view=rev Modified: haiku/trunk/src/bin/listdev/listdev.c Log: make use of subsystem id and subsystem vendor id Modified: haiku/trunk/src/bin/listdev/listdev.c =================================================================== --- haiku/trunk/src/bin/listdev/listdev.c 2008-05-12 16:55:47 UTC (rev 25472) +++ haiku/trunk/src/bin/listdev/listdev.c 2008-05-12 17:16:05 UTC (rev 25473) @@ -209,6 +209,12 @@ else if (!strcmp(attr.name, PCI_DEVICE_DEVICE_ID_ITEM) && attr.type == B_UINT16_TYPE) pci_device_id = attr.value.ui16; + else if (!strcmp(attr.name, PCI_DEVICE_SUBVENDOR_ID_ITEM) + && attr.type == B_UINT16_TYPE) + pci_subsystem_vendor_id = attr.value.ui16; + else if (!strcmp(attr.name, PCI_DEVICE_SUBSYSTEM_ID_ITEM) + && attr.type == B_UINT16_TYPE) + pci_subsystem_id = attr.value.ui16; break; case BUS_SCSI: if (!strcmp(attr.name, SCSI_DEVICE_TARGET_LUN_ITEM) @@ -273,7 +279,7 @@ if (!devShort && !devFull) { printf("device %04x: Unknown\n", pci_device_id); } else if (devShort && devFull) { - printf("device %04x: %s - %s\n", pci_device_id, devShort, devFull); + printf("device %04x: %s (%s)\n", pci_device_id, devShort, devFull); } else { printf("device %04x: %s\n", pci_device_id, devShort ? devShort : devFull); } From bonefish at mail.berlios.de Mon May 12 19:22:16 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 May 2008 19:22:16 +0200 Subject: [Haiku-commits] r25474 - haiku/trunk/src/system/libroot/posix/pthread Message-ID: <200805121722.m4CHMGsN004605@sheep.berlios.de> Author: bonefish Date: 2008-05-12 19:22:16 +0200 (Mon, 12 May 2008) New Revision: 25474 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25474&view=rev Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp Log: * reader_count was not incremented when a waiting reader was woken up. * Added comment clarifying the use of reader_count and writer_count. Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp 2008-05-12 17:16:05 UTC (rev 25473) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_rwlock.cpp 2008-05-12 17:22:16 UTC (rev 25474) @@ -95,6 +95,9 @@ int32_t lock_count; int32_t reader_count; int32_t writer_count; + // Note, that reader_count and writer_count are not used the same way. + // writer_count includes the write lock owner as well as waiting + // writers. reader_count includes read lock owners only. WaiterList waiters; status_t Init() @@ -245,6 +248,7 @@ if (waiter->userThread->wait_status > 0) { waiter->userThread->wait_status = B_OK; readers[readerCount++] = waiter->thread; + reader_count++; } } From axeld at pinc-software.de Mon May 12 19:48:08 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 12 May 2008 19:48:08 +0200 CEST Subject: [Haiku-commits] r25467 - haiku/trunk/src/system/kernel/cache In-Reply-To: Message-ID: <1419434385-BeMail@zon> "J?r?me Duval" wrote: > 2008/5/12 Ingo Weinhold : > > Looks better now, though the locking is still not right. There's a > > potential > > deadlock between block_cache_delete() and > > get_next_locked_block_cache(), > > since they lock the cache's mutex and the sCachesLock in different > > order. > Even if the cache's mutex is destroyed before locking sCachesLock ? > > > Haven't looked through the rest of the code how it is done there. > Axel would give some insights here :) Well, it looks good now, at least ;-) Now that you are familiar with the code, feel free to hunt down that block notifier bug, too :-)) Bye, Axel. From axeld at pinc-software.de Mon May 12 19:54:55 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 12 May 2008 19:54:55 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25459_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/network/usb=5Fecm?= In-Reply-To: <20080512115300.M29672@mlotz.ch> Message-ID: <1826443815-BeMail@zon> "Michael Lotz" wrote: > BTW it turns out that restarting the net_server didn't do the trick > to get the > device recognized. It is only recognized if I boot with it plugged > in. But That's understandable, as the net_server only tries to configure interfaces, when there aren't any yet -- maybe that's not yet the best solution, but in the end, you shouldn't ever need to restart the net_server anyway. If it finds an existing configuration, it assumes you did that for a reason. That means you would have to use ifconfig to delete the existing interfaces to make it search again. > when I boot with it and have the ipro1000 driver enabled too, then I > cannot > configure the device to use DHCP for some reason. Only when I remove > the > ipro1000 driver (that has no link attached in the test situation BTW) > so the > cell phone is the only network device it will work as expected (using > DHCP). Hmm... maybe that bug wasn't properly fixed after all? :-) > What I found out is that if I plug in the device (not detected by > net_server) > then quit the net_server and use ifconfig to make the device known > (it appears > in the network status and ifconfig) and then restart the net_server, > it will > vanish from both the network status and ifconfig again. Now that's very strange, and I don't have a good explanation for that. Or maybe it detected it as an incorrectly (or incompletely) configured interface, and removed it for that reason. Still a bit weird that it wouldn't try to reconfigure it then; I apparently didn't play much around with that, as there wasn't a USB device to play with back then : -) Bye, Axel. From axeld at pinc-software.de Mon May 12 20:00:09 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 12 May 2008 20:00:09 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080512152003.561.3@knochen-vm.1210596161.fake> Message-ID: <2140707314-BeMail@zon> Ingo Weinhold wrote: > > The only problem I have with this that it all needs to happen in > > locked > > down memory. Of course, 16 KB per team is not a problem, but the > > more > > we put in there, the more resources would be needed. > Yep, right. In fact the area should grow dynamically as needed. I > would > want it to start with one page only and be resized whenever it is > full. The > only problem is that allocating the user_thread space currently > happens > with the team spinlock being held, so that the area can't be resized > at > that point. I'm sure the code can be reorganized to lift that > constraint. You could create larger areas, and use the B_LAZY_LOCK method to lock them down. Then you would only need to touch them once when you are allowed to trigger a page fault. > > Or is "wait_status" already enough, there? > For the thread blocking it is sufficient, yes. Though we might want > to put > more stuff there. Like the signal block mask, maybe even the signal > handler > array. I don't know if signal handling is that performance critical usually, but if we encounter an app that benefits from that a lot (like Java, maybe), we can certainly think about that. > > Right now, the limit is 1365 threads per team which is pretty much > > acceptable, I guess :-) > Yes, I suppose for most apps it will just suffice. :-) Even the app_server will barely touch that limit :-) Bye, Axel. From korli at mail.berlios.de Mon May 12 20:16:18 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 20:16:18 +0200 Subject: [Haiku-commits] r25475 - haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich Message-ID: <200805121816.m4CIGI2A004199@sheep.berlios.de> Author: korli Date: 2008-05-12 20:16:16 +0200 (Mon, 12 May 2008) New Revision: 25475 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25475&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c Log: global status is a 32 bit register, we try to ack if any bit is left out Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2008-05-12 17:22:16 UTC (rev 25474) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2008-05-12 18:16:16 UTC (rev 25475) @@ -399,16 +399,17 @@ bool gotone = false; uint8 curblk; auich_stream *stream = NULL; - uint16 sr, sta; + uint32 sta; + uint16 sr; // TRACE(("auich_int(%p)\n", card)); - sta = auich_reg_read_16(&card->config, AUICH_REG_GLOB_STA); + sta = auich_reg_read_32(&card->config, AUICH_REG_GLOB_STA); if (sta & card->interrupt_mask) { if (sta & (STA_S0RI | STA_S1RI | STA_S2RI)) { // ignore and clear resume interrupt(s) - auich_reg_write_16(&card->config, AUICH_REG_GLOB_STA, sta & (STA_S0RI | STA_S1RI | STA_S2RI)); + auich_reg_write_32(&card->config, AUICH_REG_GLOB_STA, sta & (STA_S0RI | STA_S1RI | STA_S2RI)); TRACE(("interrupt !! %x\n", sta)); gotone = true; } @@ -442,10 +443,17 @@ auich_reg_write_16(&card->config, stream->base + GET_REG_SR(&stream->card->config), sr); + auich_reg_write_32(&card->config, AUICH_REG_GLOB_STA, stream->sta); + sta &= ~stream->sta; } + + if (sta != 0) { + dprintf("global status not fully handled %lx!\n", sta); + auich_reg_write_32(&card->config, AUICH_REG_GLOB_STA, sta); + } } else { - TRACE(("interrupt masked %x, ", card->interrupt_mask)); - TRACE(("sta %x\n", sta)); + TRACE(("interrupt masked %lx, ", card->interrupt_mask)); + TRACE(("sta %lx\n", sta)); } if (gotone) From korli at mail.berlios.de Mon May 12 20:38:39 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 12 May 2008 20:38:39 +0200 Subject: [Haiku-commits] r25476 - haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich Message-ID: <200805121838.m4CIcdYq014441@sheep.berlios.de> Author: korli Date: 2008-05-12 20:38:39 +0200 (Mon, 12 May 2008) New Revision: 25476 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25476&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c Log: apply STA_INTMASK to only handle interesting bits Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2008-05-12 18:16:16 UTC (rev 25475) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2008-05-12 18:38:39 UTC (rev 25476) @@ -404,7 +404,7 @@ // TRACE(("auich_int(%p)\n", card)); - sta = auich_reg_read_32(&card->config, AUICH_REG_GLOB_STA); + sta = auich_reg_read_32(&card->config, AUICH_REG_GLOB_STA) & STA_INTMASK; if (sta & card->interrupt_mask) { if (sta & (STA_S0RI | STA_S1RI | STA_S2RI)) { From stippi at mail.berlios.de Mon May 12 21:58:28 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 12 May 2008 21:58:28 +0200 Subject: [Haiku-commits] r25477 - haiku/trunk/src/apps/deskcalc Message-ID: <200805121958.m4CJwSMq029557@sheep.berlios.de> Author: stippi Date: 2008-05-12 21:58:20 +0200 (Mon, 12 May 2008) New Revision: 25477 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25477&view=rev Modified: haiku/trunk/src/apps/deskcalc/CalcView.cpp Log: BRoster::GetAppInfo() only works on running applications, for the replicant to find the DeskCalc icon, we need to use BRoster::FindApp() instead. Modified: haiku/trunk/src/apps/deskcalc/CalcView.cpp =================================================================== --- haiku/trunk/src/apps/deskcalc/CalcView.cpp 2008-05-12 18:38:39 UTC (rev 25476) +++ haiku/trunk/src/apps/deskcalc/CalcView.cpp 2008-05-12 19:58:20 UTC (rev 25477) @@ -1054,10 +1054,10 @@ void CalcView::_FetchAppIcon(BBitmap* into) { - app_info info; - be_roster->GetAppInfo(kAppSig, &info); - BFile file(&info.ref, B_READ_ONLY); + entry_ref appRef; + be_roster->FindApp(kAppSig, &appRef); + BFile file(&appRef, B_READ_ONLY); BAppFileInfo appInfo(&file); - if (appInfo.GetIcon(into, B_MINI_ICON) < B_OK) + if (appInfo.GetIcon(into, B_MINI_ICON) != B_OK) memset(into->Bits(), 0, into->BitsLength()); } From bonefish at mail.berlios.de Mon May 12 22:48:04 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 12 May 2008 22:48:04 +0200 Subject: [Haiku-commits] r25478 - haiku/trunk/src/system/libroot/posix/stdlib Message-ID: <200805122048.m4CKm4kS001377@sheep.berlios.de> Author: bonefish Date: 2008-05-12 22:48:03 +0200 (Mon, 12 May 2008) New Revision: 25478 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25478&view=rev Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c Log: * unsetenv() was moving too much memory, thus corrupting the data after its allocation. * Added TODO to use a benaphore. Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-05-12 19:58:20 UTC (rev 25477) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-05-12 20:48:03 UTC (rev 25478) @@ -23,6 +23,7 @@ return err; +// TODO: Use benaphore! static sem_id sEnvLock; static bool sCopied; @@ -212,9 +213,11 @@ env = find_variable(name, length, &index); if (env != NULL) { - // we don't free the memory for the slot, we just move the array contents + // we don't free the memory for the slot, we just move the array + // contents free(env); - memmove(environ + index, environ + index + 1, sizeof(char *) * (count_variables() + 1)); + memmove(environ + index, environ + index + 1, + sizeof(char *) * (count_variables() - index)); } release_sem(sEnvLock); From stippi at mail.berlios.de Mon May 12 23:10:08 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 12 May 2008 23:10:08 +0200 Subject: [Haiku-commits] r25479 - haiku/trunk/src/servers/app/drawing Message-ID: <200805122110.m4CLA8t7002647@sheep.berlios.de> Author: stippi Date: 2008-05-12 23:10:05 +0200 (Mon, 12 May 2008) New Revision: 25479 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25479&view=rev Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp Log: When drawing is double buffered, there is no excuse for a flickering cursor (including any drag bitmap). HWInterface::HideFloatingOverlays() was plain stupid, I know it did check double buffering at one point, but I must have removed that when messing with it. But copying anything from back to front buffer is now not overwriting the cursor area anymore, which is painted immediatly afterwards. Also moving the cursor invalidates only one rect if old and new cursor area overlap. All these changes should save some cycles too. Added TODO with regard to caching the on-the-fly cursor compositing buffer. If you have * a more recent computer * a decent VESA BIOS which supports your native resolution * don't need video overlays .. I recommend using the VESA driver. Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-05-12 20:48:03 UTC (rev 25478) +++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp 2008-05-12 21:10:05 UTC (rev 25479) @@ -226,7 +226,7 @@ if (fCursorObscured) { SetCursorVisible(true); } - BRect oldFrame = _CursorFrame(); + IntRect oldFrame = _CursorFrame(); fCursorLocation = p; if (fCursorVisible) { // Invalidate and _DrawCursor would not draw @@ -238,8 +238,13 @@ _RestoreCursorArea(); _DrawCursor(_CursorFrame()); } - Invalidate(oldFrame); - Invalidate(_CursorFrame()); + IntRect newFrame = _CursorFrame(); + if (newFrame.Intersects(oldFrame)) + Invalidate(oldFrame | newFrame); + else { + Invalidate(oldFrame); + Invalidate(newFrame); + } } } fFloatingOverlaysLock.Unlock(); @@ -334,16 +339,18 @@ uint32 srcBPR = backBuffer->BytesPerRow(); uint8* src = (uint8*)backBuffer->Bits(); - // convert to integer coordinates - int32 left = (int32)floorf(area.left); - int32 top = (int32)floorf(area.top); - int32 right = (int32)ceilf(area.right); - int32 bottom = (int32)ceilf(area.bottom); + BRegion region((BRect)area); + if (IsDoubleBuffered()) + region.Exclude((clipping_rect)_CursorFrame()); + + int32 count = region.CountRects(); + for (int32 i = 0; i < count; i++) { + clipping_rect r = region.RectAtInt(i); + // offset to left top pixel in source buffer (always B_RGBA32) + uint8* srcOffset = src + r.top * srcBPR + r.left * 4; + _CopyToFront(srcOffset, srcBPR, r.left, r.top, r.right, r.bottom); + } - // offset to left top pixel in source buffer (always B_RGBA32) - src += top * srcBPR + left * 4; - - _CopyToFront(src, srcBPR, left, top, right, bottom); _DrawCursor(area); return B_OK; @@ -415,6 +422,8 @@ bool HWInterface::HideFloatingOverlays(const BRect& area) { + if (IsDoubleBuffered()) + return false; if (!fFloatingOverlaysLock.Lock()) return false; if (fCursorAreaBackup && !fCursorAreaBackup->cursor_hidden) { @@ -436,6 +445,8 @@ bool HWInterface::HideFloatingOverlays() { + if (IsDoubleBuffered()) + return false; if (!fFloatingOverlaysLock.Lock()) return false; @@ -505,6 +516,7 @@ // blending buffer uint8* buffer = new uint8[width * height * 4]; + // TODO: cache this buffer // offset into back buffer uint8* src = (uint8*)backBuffer->Bits(); From mmu_man at mail.berlios.de Tue May 13 00:01:13 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 13 May 2008 00:01:13 +0200 Subject: [Haiku-commits] r25480 - haiku/trunk/src/system/kernel/fs Message-ID: <200805122201.m4CM1DBn007653@sheep.berlios.de> Author: mmu_man Date: 2008-05-13 00:01:12 +0200 (Tue, 13 May 2008) New Revision: 25480 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25480&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: The wonders of C++ in the kernel... you get C++ linkage by default :^) Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-05-12 21:10:05 UTC (rev 25479) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-05-12 22:01:12 UTC (rev 25480) @@ -616,7 +616,7 @@ /*! This is no longer part of the public kernel API, so we just export the symbol */ -status_t load_driver_symbols(const char *driverName); +extern "C" status_t load_driver_symbols(const char *driverName); status_t load_driver_symbols(const char *driverName) { From bonefish at mail.berlios.de Tue May 13 03:50:59 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 13 May 2008 03:50:59 +0200 Subject: [Haiku-commits] r25481 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread Message-ID: <200805130150.m4D1oxSe017852@sheep.berlios.de> Author: bonefish Date: 2008-05-13 03:50:54 +0200 (Tue, 13 May 2008) New Revision: 25481 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25481&view=rev Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.cpp Removed: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c Modified: haiku/trunk/headers/posix/pthread.h haiku/trunk/src/system/libroot/posix/pthread/Jamfile haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h Log: * Reimplemented pthread_once. The old one was neither thread-safe nor particularly efficient. * pthread_mutex implementation: - Removed the pthread_mutex_t indirection (the type was a pointer to the actual structure which was allocated on the heap), as it made sharing the mutex between processes impossible. - Removed the distinction between process shared and non-shared mutexes. Benaphores work just as well in shared memory, so we always use them. * Fixed some static initializer macros. PTHREAD_COND_INITIALIZER is still broken, since it doesn't work in C code. Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/headers/posix/pthread.h 2008-05-13 01:50:54 UTC (rev 25481) @@ -12,7 +12,7 @@ typedef int pthread_t; typedef struct _pthread_attr *pthread_attr_t; -typedef struct _pthread_mutex *pthread_mutex_t; +typedef struct _pthread_mutex pthread_mutex_t; typedef struct _pthread_mutexattr *pthread_mutexattr_t; typedef struct _pthread_cond *pthread_cond_t; typedef struct _pthread_condattr *pthread_condattr_t; @@ -24,9 +24,16 @@ typedef struct _pthread_barrierattr *pthread_barrierattr_t; typedef struct _pthread_spinlock *pthread_spinlock_t; +struct _pthread_mutex { + uint32_t flags; + int32_t count; + int32_t sem; + int32_t owner; + int32_t owner_count; +}; + struct _pthread_once { - int state; - pthread_mutex_t mutex; + int32_t state; }; struct _pthread_rwlock { @@ -84,9 +91,7 @@ #define PTHREAD_CANCEL_ASYNCHRONOUS 2 #define PTHREAD_CANCELED ((void *) 1) -#define PTHREAD_NEEDS_INIT 0 -#define PTHREAD_DONE_INIT 1 -#define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, NULL } +#define PTHREAD_ONCE_INIT { -1 } #define PTHREAD_BARRIER_SERIAL_THREAD -1 #define PTHREAD_PRIO_NONE 0 @@ -120,14 +125,13 @@ extern "C" { #endif -extern pthread_mutex_t _pthread_mutex_static_initializer(void); -extern pthread_mutex_t _pthread_recursive_mutex_static_initializer(void); -#define PTHREAD_MUTEX_INITIALIZER NULL +#define PTHREAD_MUTEX_INITIALIZER \ + { PTHREAD_MUTEX_DEFAULT, 0, -42, -1, 0 } #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ - pthread_recursive_mutex_static_initializer(); + { PTHREAD_MUTEX_RECURSIVE, 0, -42, -1, 0 } extern pthread_cond_t _pthread_cond_static_initializer(void); -#define PTHREAD_COND_INITIALIZER _pthread_cond_static_initializer(); +#define PTHREAD_COND_INITIALIZER _pthread_cond_static_initializer() /* mutex functions */ extern int pthread_mutex_destroy(pthread_mutex_t *mutex); @@ -205,7 +209,8 @@ /* misc. functions */ extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); -extern int pthread_once(pthread_once_t *once_control, void (*init_routine)()); +extern int pthread_once(pthread_once_t *once_control, + void (*init_routine)(void)); /* thread attributes functions */ extern int pthread_attr_destroy(pthread_attr_t *attr); Modified: haiku/trunk/src/system/libroot/posix/pthread/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2008-05-13 01:50:54 UTC (rev 25481) @@ -14,7 +14,7 @@ pthread_key.cpp pthread_mutex.c pthread_mutexattr.c - pthread_once.c + pthread_once.cpp pthread_rwlock.cpp ; Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2008-05-13 01:50:54 UTC (rev 25481) @@ -81,30 +81,30 @@ static status_t -cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) +cond_wait(pthread_cond *cond, pthread_mutex_t *mutex, bigtime_t timeout) { status_t status; int32 event; - if (cond == NULL || *_mutex == NULL) + if (cond == NULL || mutex == NULL) return B_BAD_VALUE; - if ((*_mutex)->owner != find_thread(NULL)) + if (mutex->owner != find_thread(NULL)) // POSIX suggests EPERM (= B_NOT_ALLOWED) to be returned // if this thread does not own the mutex return B_NOT_ALLOWED; - if (cond->mutex && cond->mutex != _mutex) + if (cond->mutex && cond->mutex != mutex) // POSIX suggests EINVAL (= B_BAD_VALUE) to be returned if // the same condition variable is used with multiple mutexes return B_BAD_VALUE; - cond->mutex = _mutex; + cond->mutex = mutex; cond->waiter_count++; event = atomic_get(&cond->event_counter); - pthread_mutex_unlock(_mutex); + pthread_mutex_unlock(mutex); do { status = acquire_sem_etc(cond->sem, 1, @@ -112,7 +112,7 @@ timeout); } while (status == B_OK && atomic_get(&cond->event_counter) == event); - pthread_mutex_lock(_mutex); + pthread_mutex_lock(mutex); cond->waiter_count--; // If there are no more waiters, we can change mutexes Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_mutex.c 2008-05-13 01:50:54 UTC (rev 25481) @@ -12,61 +12,32 @@ #include +#define MUTEX_FLAG_SHARED 0x80000000 +#define MUTEX_TYPE_BITS 0x0000000f +#define MUTEX_TYPE(mutex) ((mutex)->flags & MUTEX_TYPE_BITS) + + static const pthread_mutexattr pthread_mutexattr_default = { PTHREAD_MUTEX_DEFAULT, false }; -pthread_mutex_t -_pthread_recursive_mutex_static_initializer(void) -{ - pthread_mutex_t mutex; - pthread_mutexattr attr; - pthread_mutexattr_t attrPointer = &attr; - - attr.type = PTHREAD_MUTEX_RECURSIVE; - attr.process_shared = false; - - if (pthread_mutex_init(&mutex, &attrPointer) == B_OK) - return mutex; - - return NULL; -} - - -pthread_mutex_t -_pthread_mutex_static_initializer(void) -{ - pthread_mutex_t mutex; - if (pthread_mutex_init(&mutex, NULL) == B_OK) - return mutex; - - return NULL; -} - - int -pthread_mutex_init(pthread_mutex_t *_mutex, const pthread_mutexattr_t *_attr) +pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *_attr) { - pthread_mutex *mutex; const pthread_mutexattr *attr = NULL; - if (_mutex == NULL) + if (mutex == NULL) return B_BAD_VALUE; - mutex = (pthread_mutex *)malloc(sizeof(pthread_mutex)); - if (mutex == NULL) - return B_NO_MEMORY; - if (_attr != NULL) attr = *_attr; else attr = &pthread_mutexattr_default; - mutex->sem = create_sem(attr && attr->process_shared ? 0 : 1, "pthread_mutex"); + mutex->sem = create_sem(0, "pthread_mutex"); if (mutex->sem < B_OK) { - free(mutex); return B_WOULD_BLOCK; // stupid error code (EAGAIN) but demanded by POSIX } @@ -74,77 +45,57 @@ mutex->count = 0; mutex->owner = -1; mutex->owner_count = 0; - memcpy(&mutex->attr, attr, sizeof(pthread_mutexattr)); + mutex->flags = attr->type | (attr->process_shared ? MUTEX_FLAG_SHARED : 0); - *_mutex = mutex; return B_OK; } int -pthread_mutex_destroy(pthread_mutex_t *_mutex) +pthread_mutex_destroy(pthread_mutex_t *mutex) { - pthread_mutex *mutex; - - if (_mutex == NULL || (mutex = *_mutex) == NULL) + if (mutex == NULL) return B_BAD_VALUE; delete_sem(mutex->sem); - *_mutex = NULL; - free(mutex); return B_OK; } static status_t -mutex_unlock(pthread_mutex *mutex) +mutex_lock(pthread_mutex_t *mutex, bigtime_t timeout) { - if (mutex == NULL) - return B_BAD_VALUE; - - if (mutex->owner != find_thread(NULL)) { - // this is a bug in the calling application! - // ToDo: should we handle it in another way? - fprintf(stderr, "mutex unlocked from foreign thread!\n"); - } - - if (mutex->attr.type == PTHREAD_MUTEX_RECURSIVE) { - - if (mutex->owner_count-- > 1) - return B_OK; - - mutex->owner = -1; - } - - if (!mutex->attr.process_shared || atomic_add(&mutex->count, -1) > 1) - return release_sem(mutex->sem); - - return B_OK; -} - - -static status_t -mutex_lock(pthread_mutex *mutex, bigtime_t timeout) -{ thread_id thisThread = find_thread(NULL); status_t status = B_OK; if (mutex == NULL) return B_BAD_VALUE; - if (mutex->attr.type == PTHREAD_MUTEX_ERRORCHECK && mutex->owner == thisThread) { + // If statically initialized, we need to create the semaphore, now. + if (mutex->sem == -42) { + sem_id sem = create_sem(0, "pthread_mutex"); + if (sem < 0) + return EAGAIN; + + if (atomic_test_and_set((vint32*)&mutex->sem, sem, -42) != -42) + delete_sem(sem); + } + + if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_ERRORCHECK + && mutex->owner == thisThread) { // we detect this kind of deadlock and return an error return B_BUSY; } - if (mutex->attr.type == PTHREAD_MUTEX_RECURSIVE && mutex->owner == thisThread) { + if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE + && mutex->owner == thisThread) { // if we already hold the mutex, we don't need to grab it again mutex->owner_count++; return B_OK; } - if (!mutex->attr.process_shared || atomic_add(&mutex->count, 1) > 0) { + if (atomic_add((vint32*)&mutex->count, 1) > 0) { // this mutex is already locked by someone else, so we need // to wait status = acquire_sem_etc(mutex->sem, 1, @@ -163,30 +114,21 @@ int -pthread_mutex_lock(pthread_mutex_t *_mutex) +pthread_mutex_lock(pthread_mutex_t *mutex) { - if (_mutex == NULL) - return B_BAD_VALUE; - - if (*_mutex == NULL) - pthread_mutex_init(_mutex, NULL); - - return mutex_lock(*_mutex, B_INFINITE_TIMEOUT); + return mutex_lock(mutex, B_INFINITE_TIMEOUT); } int -pthread_mutex_trylock(pthread_mutex_t *_mutex) +pthread_mutex_trylock(pthread_mutex_t *mutex) { - if (_mutex == NULL) - return B_BAD_VALUE; - - return mutex_lock(*_mutex, 0); + return mutex_lock(mutex, 0); } int -pthread_mutex_timedlock(pthread_mutex_t *_mutex, const struct timespec *tv) +pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *tv) { bool invalidTime = false; status_t status; @@ -197,10 +139,7 @@ else invalidTime = true; - if (_mutex == NULL) - return B_BAD_VALUE; - - status = mutex_lock(*_mutex, timeout); + status = mutex_lock(mutex, timeout); if (status != B_OK && invalidTime) { // POSIX requires EINVAL (= B_BAD_VALUE) to be returned // if the timespec structure was invalid @@ -212,21 +151,35 @@ int -pthread_mutex_unlock(pthread_mutex_t *_mutex) +pthread_mutex_unlock(pthread_mutex_t *mutex) { - if (_mutex == NULL) + if (mutex == NULL) return B_BAD_VALUE; - return mutex_unlock(*_mutex); + if (mutex->owner != find_thread(NULL)) { + // this is a bug in the calling application! + // ToDo: should we handle it in another way? + fprintf(stderr, "mutex unlocked from foreign thread!\n"); + } + + if (MUTEX_TYPE(mutex) == PTHREAD_MUTEX_RECURSIVE) { + if (mutex->owner_count-- > 1) + return B_OK; + + mutex->owner = -1; + } + + if (atomic_add((vint32*)&mutex->count, -1) > 1) + return release_sem(mutex->sem); + + return B_OK; } int -pthread_mutex_getprioceiling(pthread_mutex_t *_mutex, int *_prioCeiling) +pthread_mutex_getprioceiling(pthread_mutex_t *mutex, int *_prioCeiling) { - pthread_mutex *mutex; - - if (_mutex == NULL || (mutex = *_mutex) == NULL || _prioCeiling == NULL) + if (mutex == NULL || _prioCeiling == NULL) return B_BAD_VALUE; *_prioCeiling = 0; @@ -237,15 +190,12 @@ int -pthread_mutex_setprioceiling(pthread_mutex_t *_mutex, int prioCeiling, int *_oldCeiling) +pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioCeiling, + int *_oldCeiling) { - pthread_mutex *mutex; - - if (_mutex == NULL || (mutex = *_mutex) == NULL) + if (mutex == NULL) return B_BAD_VALUE; // not implemented return B_NOT_ALLOWED; } - - Deleted: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_once.cpp 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_once.cpp 2008-05-13 01:50:54 UTC (rev 25481) @@ -0,0 +1,88 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + + +enum { + STATE_UNINITIALIZED = -1, // keep in sync with PTHREAD_ONCE_INIT + STATE_INITIALIZING = -2, + STATE_SPINNING = -3, + STATE_INITIALIZED = -4 +}; + + +int +pthread_once(pthread_once_t* onceControl, void (*initRoutine)(void)) +{ + // Algorithm: + // The state goes through at most four states: + // STATE_UNINITIALIZED: The initial uninitialized state. + // STATE_INITIALIZING: Set by the first thread entering the function. It + // will call initRoutine. + // semaphore/STATE_SPINNING: Set by the second thread entering the function, + // when the first thread is still executing initRoutine. The normal case is + // that the thread manages to create a semaphore. This thread (and all + // following threads) will block on the semaphore until the first thread is + // done. + // STATE_INITIALIZED: Set by the first thread when it returns from + // initRoutine. All following threads will return right away. + + int32 value = atomic_test_and_set((vint32*)&onceControl->state, + STATE_INITIALIZING, STATE_UNINITIALIZED); + + if (value == STATE_INITIALIZED) + return 0; + + if (value == STATE_UNINITIALIZED) { + // we're the first -- perform the initialization + initRoutine(); + + value = atomic_set((vint32*)&onceControl->state, STATE_INITIALIZED); + + // If someone else is waiting, we need to delete the semaphore. + if (value >= 0) + delete_sem(value); + + return 0; + } + + if (value == STATE_INITIALIZING) { + // someone is initializing -- we need to create a semaphore we can wait + // on + sem_id semaphore = create_sem(0, "pthread once"); + if (semaphore >= 0) { + // successfully created -- set it + value = atomic_test_and_set((vint32*)&onceControl->state, + semaphore, STATE_INITIALIZING); + if (value == STATE_INITIALIZING) + value = semaphore; + else + delete_sem(semaphore); + } else { + // Failed to create the semaphore. Can only happen when the system + // runs out of semaphores, but we can still handle the situation + // gracefully by spinning. + value = atomic_test_and_set((vint32*)&onceControl->state, + STATE_SPINNING, STATE_INITIALIZING); + if (value == STATE_INITIALIZING) + value = STATE_SPINNING; + } + } + + if (value >= 0) { + // wait on the semaphore + while (acquire_sem(value) == B_INTERRUPTED); + + return 0; + } else if (value == STATE_SPINNING) { + // out of semaphores -- spin + while (atomic_get((vint32*)&onceControl->state) == STATE_SPINNING); + } + + return 0; +} Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-05-13 01:50:54 UTC (rev 25481) @@ -33,14 +33,6 @@ bool process_shared; } pthread_mutexattr; -typedef struct _pthread_mutex { - vint32 count; - sem_id sem; - thread_id owner; - int32 owner_count; - pthread_mutexattr attr; -} pthread_mutex; - typedef struct _pthread_attr { int32 detach_state; int32 sched_priority; From ingo_weinhold at gmx.de Tue May 13 16:45:30 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 13 May 2008 16:45:30 +0200 Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <2140707314-BeMail@zon> References: <2140707314-BeMail@zon> Message-ID: <20080513164530.552.3@knochen-vm.1210688117.fake> On 2008-05-12 at 20:00:09 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > > The only problem I have with this that it all needs to happen in > > > locked > > > down memory. Of course, 16 KB per team is not a problem, but the > > > more > > > we put in there, the more resources would be needed. > > Yep, right. In fact the area should grow dynamically as needed. I > > would > > want it to start with one page only and be resized whenever it is > > full. The > > only problem is that allocating the user_thread space currently > > happens > > with the team spinlock being held, so that the area can't be resized > > at > > that point. I'm sure the code can be reorganized to lift that > > constraint. > > You could create larger areas, and use the B_LAZY_LOCK method to lock > them down. Then you would only need to touch them once when you are > allowed to trigger a page fault. This method has just the same problem as resizing the area. The only difference is that it guarantees a certain maximum (at the cost of committing more memory), while resizing might fail. I consider introducing a per-team mutex which could be used for certain team related stuff instead of using the teams spinlock. What do you think? > > > Or is "wait_status" already enough, there? > > For the thread blocking it is sufficient, yes. Though we might want > > to put > > more stuff there. Like the signal block mask, maybe even the signal > > handler > > array. > > I don't know if signal handling is that performance critical usually, > but if we encounter an app that benefits from that a lot (like Java, > maybe), we can certainly think about that. Bash does quite a bit of signal stuff, but I don't think it's really performance critical. So I agree, this optimization can wait, until we find an application that benefits significantly. CU, Ingo From axeld at pinc-software.de Tue May 13 17:54:12 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Tue, 13 May 2008 17:54:12 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080513164530.552.3@knochen-vm.1210688117.fake> Message-ID: <6112887493-BeMail@zon> Ingo Weinhold wrote: > > You could create larger areas, and use the B_LAZY_LOCK method to > > lock > > them down. Then you would only need to touch them once when you are > > allowed to trigger a page fault. > This method has just the same problem as resizing the area. The only > difference is that it guarantees a certain maximum (at the cost of > committing more memory), while resizing might fail. Indeed. As an improvement, one could use a smaller resizable area, and create a reserved area that can hold more space - then it would be guaranteed that the area is resizable as long as possible. > I consider introducing a per-team mutex which could be used for > certain > team related stuff instead of using the teams spinlock. What do you > think? Why not. We just have to be careful which fields we can secure with the mutex vs. the global spinlock; shouldn't be too many, I'd guess. Bye, Axel. From mmu_man at mail.berlios.de Tue May 13 19:32:55 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 13 May 2008 19:32:55 +0200 Subject: [Haiku-commits] r25482 - haiku/trunk/src/bin/make Message-ID: <200805131732.m4DHWtMe016916@sheep.berlios.de> Author: mmu_man Date: 2008-05-13 19:32:50 +0200 (Tue, 13 May 2008) New Revision: 25482 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25482&view=rev Modified: haiku/trunk/src/bin/make/config.h haiku/trunk/src/bin/make/make.rdef Log: Don't forget config.h and rdef when updating... it was still saying 3.80. Modified: haiku/trunk/src/bin/make/config.h =================================================================== --- haiku/trunk/src/bin/make/config.h 2008-05-13 01:50:54 UTC (rev 25481) +++ haiku/trunk/src/bin/make/config.h 2008-05-13 17:32:50 UTC (rev 25482) @@ -292,13 +292,13 @@ #define PACKAGE_NAME "GNU make" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU make 3.80" +#define PACKAGE_STRING "GNU make 3.81" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "make" /* Define to the version of this package. */ -#define PACKAGE_VERSION "3.80" +#define PACKAGE_VERSION "3.81" /* Define to 1 if the C compiler supports function prototypes. */ #define PROTOTYPES 1 @@ -351,7 +351,7 @@ /* #undef UMAX4_3 */ /* Version number of package */ -#define VERSION "3.80" +#define VERSION "3.81" /* Define if using the dmalloc debugging malloc package */ /* #undef WITH_DMALLOC */ Modified: haiku/trunk/src/bin/make/make.rdef =================================================================== --- haiku/trunk/src/bin/make/make.rdef 2008-05-13 01:50:54 UTC (rev 25481) +++ haiku/trunk/src/bin/make/make.rdef 2008-05-13 17:32:50 UTC (rev 25482) @@ -1,11 +1,11 @@ resource app_version { major = 3, - middle = 80, + middle = 81, minor = 0, variety = 5, internal = 0, - short_info = "3.80", - long_info = "3.80 ?2002 The Free Software Foundation" + short_info = "3.81", + long_info = "3.81 ?2006 The Free Software Foundation, Inc." }; From bonefish at mail.berlios.de Tue May 13 22:04:12 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 13 May 2008 22:04:12 +0200 Subject: [Haiku-commits] r25483 - haiku/trunk/src/system/kernel/vm Message-ID: <200805132004.m4DK4Cqs006025@sheep.berlios.de> Author: bonefish Date: 2008-05-13 22:04:11 +0200 (Tue, 13 May 2008) New Revision: 25483 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25483&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Fixed build with tracing turned on. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-13 17:32:50 UTC (rev 25482) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-05-13 20:04:11 UTC (rev 25483) @@ -1904,8 +1904,8 @@ // copy of a file at a given time, ie. later changes should not // make it into the mapped copy -- this will need quite some changes // to be done in a nice way - TRACE(("_vm_map_file(\"%s\", offset = %Ld, size = %lu, mapping %ld)\n", - path, offset, size, mapping)); + TRACE(("_vm_map_file(fd = %d, offset = %Ld, size = %lu, mapping %ld)\n", + fd, offset, size, mapping)); offset = ROUNDOWN(offset, B_PAGE_SIZE); size = PAGE_ALIGN(size); From bonefish at mail.berlios.de Wed May 14 00:15:46 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 14 May 2008 00:15:46 +0200 Subject: [Haiku-commits] r25484 - haiku/trunk/build/jam Message-ID: <200805132215.m4DMFkXg003039@sheep.berlios.de> Author: bonefish Date: 2008-05-14 00:15:45 +0200 (Wed, 14 May 2008) New Revision: 25484 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25484&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Added APR 0.9.17 optional package. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-13 20:04:11 UTC (rev 25483) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-13 22:15:45 UTC (rev 25484) @@ -20,6 +20,20 @@ OptionalPackageDependencies OpenSSH : OpenSSL ; +# APR +if [ IsOptionalHaikuImagePackageAdded APR ] { + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package APR available for gcc4" ; + } else { + local baseURL = http://haiku-files.org/files/optional-packages ; + InstallOptionalHaikuImagePackage apr-0.9.17-gcc2-2008-05-13 + : $(baseURL)/apr-0.9.17-gcc2-2008-05-13.zip + : + ; + } +} + + # Development if [ IsOptionalHaikuImagePackageAdded Development ] && $(TARGET_ARCH) = x86 { From bonefish at mail.berlios.de Wed May 14 01:41:09 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 14 May 2008 01:41:09 +0200 Subject: [Haiku-commits] r25485 - in haiku/trunk: build/jam src/kits/network src/kits/network/dns/irs src/kits/network/libnetapi Message-ID: <200805132341.m4DNf9Ua030863@sheep.berlios.de> Author: bonefish Date: 2008-05-14 01:41:09 +0200 (Wed, 14 May 2008) New Revision: 25485 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25485&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/kits/network/Jamfile haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp haiku/trunk/src/kits/network/libnetapi/Jamfile Log: * Made libnetapi a separate library again. * The built-in services are no longer added as resource to libnetwork, but as attribute. This removes the libbe dependency. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-13 22:15:45 UTC (rev 25484) +++ haiku/trunk/build/jam/HaikuImage 2008-05-13 23:41:09 UTC (rev 25485) @@ -64,9 +64,9 @@ Playground Pulse Sudoku ; BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so - libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so - libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so - libdevice.so libgame.so libscreensaver.so libroot.so + libtranslation.so libnetapi.so libnetwork.so libdebug.so libbsd.so + libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so + libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so libilmimf.so ; @@ -190,7 +190,7 @@ # libnetwork.so replaces quite a few libraries BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES - = libsocket.so libbind.so libnet.so libnetapi.so libbnetapi.so ; + = libsocket.so libbind.so libnet.so ; local lib ; for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { Modified: haiku/trunk/src/kits/network/Jamfile =================================================================== --- haiku/trunk/src/kits/network/Jamfile 2008-05-13 22:15:45 UTC (rev 25484) +++ haiku/trunk/src/kits/network/Jamfile 2008-05-13 23:41:09 UTC (rev 25485) @@ -3,18 +3,12 @@ UsePrivateHeaders libroot net shared ; UsePrivateKernelHeaders ; -local services = [ FGristFiles services ] ; -SEARCH on $(services) = [ FDirName $(SUBDIR) dns defaults ] ; -AddFileDataResource libnetwork.so : CSTR:201:services : $(services) ; - SharedLibrary libnetwork.so : init.cpp interfaces.cpp socket.cpp r5_compatibility.cpp : - netapi.o - dns_dst.o dns_inet.o dns_irs.o @@ -22,9 +16,11 @@ dns_nameser.o dns_resolv.o dns_private.o - - be ; +local services = [ FGristFiles services ] ; +SEARCH on $(services) = [ FDirName $(SUBDIR) dns defaults ] ; +AddFileDataAttribute libnetwork.so : services : string : $(services) ; + SubInclude HAIKU_TOP src kits network dns ; SubInclude HAIKU_TOP src kits network libnetapi ; Modified: haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp =================================================================== --- haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp 2008-05-13 22:15:45 UTC (rev 25484) +++ haiku/trunk/src/kits/network/dns/irs/lcl_sv.cpp 2008-05-13 23:41:09 UTC (rev 25485) @@ -63,10 +63,6 @@ #include "port_after.h" -#include -#include -#include - #include #include #include @@ -80,15 +76,16 @@ #include #include +#include +#include +#include + #define IRS_SV_MAXALIASES 35 struct service_private { FILE* file; char line[BUFSIZ+1]; - char* resource_file; - char* resource_end; - char* resource_line; struct servent servent; char* aliases[IRS_SV_MAXALIASES]; }; @@ -115,26 +112,9 @@ char * get_next_line(struct service_private* service) { - if (service->file != NULL) - return fgets(service->line, BUFSIZ, service->file); - if (service->resource_file == NULL) + if (service->file == NULL) return NULL; - - char* line = service->resource_line; - while (line < service->resource_end - && line[0] - && line[0] != '\n') - line++; - - if (service->resource_line >= service->resource_end - || service->resource_line == line) - return NULL; - - strlcpy(service->line, service->resource_line, - min_c(line + 1 - service->resource_line, BUFSIZ)); - service->resource_line = line + 1; - - return service->line; + return fgets(service->line, BUFSIZ, service->file); } @@ -149,7 +129,6 @@ if (service->file) fclose(service->file); - free(service->resource_file); memput(service, sizeof *service); memput(sv, sizeof *sv); } @@ -168,44 +147,55 @@ } if ((service->file = fopen(_PATH_SERVICES, "r")) != NULL) { - if (fcntl(fileno(service->file), F_SETFD, 1) == 0) + if (fcntl(fileno(service->file), F_SETFD, FD_CLOEXEC) == 0) return; fclose(service->file); service->file = NULL; } - // opening the standard file has file has failed, use resources + // opening the standard file has file has failed, use the attribute - if (service->resource_file != NULL) { - service->resource_line = service->resource_file; - return; + // find our library image + addr_t addressInImage = (addr_t)&sv_rewind; + const char* path = NULL; + image_info info; + int32 cookie; + + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + if (addressInImage >= (addr_t)info.text + && addressInImage < (addr_t)info.text + info.text_size) { + path = info.name; + break; + } } - image_info info; - if (find_own_image(&info) < B_OK) + if (path == NULL) return; - BFile file; - if (file.SetTo(info.name, B_READ_ONLY) < B_OK) + // open the library + int libraryFD = open(path, O_RDONLY); + if (libraryFD < 0) return; - BResources resources(&file); - if (resources.InitCheck() < B_OK) + // open the attribute + int attrFD = fs_open_attr(libraryFD, "services", B_STRING_TYPE, O_RDONLY); + close(libraryFD); + if (attrFD < 0) return; - size_t size; - const void* data = resources.LoadResource(B_STRING_TYPE, "services", &size); - if (data == NULL) + // attach it to a FILE + service->file = fdopen(attrFD, "r"); + if (service->file == NULL) { + close(attrFD); return; + } - service->resource_file = (char *)malloc(size); - if (service->resource_file == NULL) + if (fcntl(fileno(service->file), F_SETFD, FD_CLOEXEC) == 0) return; - memcpy(service->resource_file, data, size); - service->resource_line = service->resource_file; - service->resource_end = service->resource_file + size; + fclose(service->file); + service->file = NULL; } @@ -215,10 +205,10 @@ struct service_private *service = (struct service_private *)sv->private_data; char *p, *cp, **q; - if (service->file == NULL && service->resource_file == NULL) + if (service->file == NULL) sv_rewind(sv); - if (service->file == NULL && service->resource_file == NULL) + if (service->file == NULL) return NULL; again: Modified: haiku/trunk/src/kits/network/libnetapi/Jamfile =================================================================== --- haiku/trunk/src/kits/network/libnetapi/Jamfile 2008-05-13 22:15:45 UTC (rev 25484) +++ haiku/trunk/src/kits/network/libnetapi/Jamfile 2008-05-13 23:41:09 UTC (rev 25485) @@ -43,7 +43,8 @@ # boot home config lib ; boot home Desktop haiku-networkingkit lib ; } else { - MergeObject netapi.o : + SharedLibrary libnetapi.so : $(netapi_sources) + : be $(TARGET_NETWORK_LIBS) ; } From bonefish at mail.berlios.de Wed May 14 05:55:29 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 14 May 2008 05:55:29 +0200 Subject: [Haiku-commits] r25486 - in haiku/trunk: build/jam headers/private headers/private/kernel headers/private/kernel/arch/m68k headers/private/kernel/arch/ppc headers/private/kernel/arch/x86 headers/private/kernel/disk_device_manager headers/private/kernel/posix headers/private/libroot headers/private/system headers/private/system/arch headers/private/system/arch/m68k headers/private/system/arch/ppc headers/private/system/arch/x86 headers/private/system/posix src/add-ons/input_server/devices/keyboard src/add-ons/kernel/bus_managers/agp_gart src/add-ons/kernel/bus_managers/ide src/add-ons/kernel/bus_managers/isa src/add-ons/kernel/bus_managers/scsi src/add-ons/kernel/bus_managers/usb src/add-ons/kernel/busses/scsi/ahci src/add-ons/kernel/drivers/random src/add-ons/kernel/generic/block_io src/apps/powerstatus src/bin src/bin/listdev src/bin/multiuser src/bin/network/arp src/bin/network/netstat src/bin/strace src/kits/app src/kits/debug src/kits/network src/kits/opengl src/kits/storage sr! c/kits/storage/disk_device src/kits/translation src/preferences/time src/servers/app/drawing src/servers/input src/servers/media src/servers/registrar src/system/boot/loader src/system/glue src/system/kernel/arch/m68k src/system/kernel/arch/ppc src/system/kernel/arch/x86 src/system/kernel/lib src/system/libroot src/system/libroot/os src/system/libroot/os/arch/m68k src/system/libroot/os/arch/ppc src/system/libroot/os/arch/x86 src/system/libroot/posix src/system/libroot/posix/malloc src/system/libroot/posix/pthread src/system/libroot/posix/signal src/system/libroot/posix/stdio src/system/libroot/posix/stdlib src/system/libroot/posix/string src/system/libroot/posix/string/arch/x86 src/system/libroot/posix/sys src/system/libroot/posix/time src/system/libroot/posix/unistd src/system/runtime_loader src/tools/gensyscalls Message-ID: <200805140355.m4E3tTJc013523@sheep.berlios.de> Author: bonefish Date: 2008-05-14 05:55:16 +0200 (Wed, 14 May 2008) New Revision: 25486 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25486&view=rev Added: haiku/trunk/headers/private/system/ haiku/trunk/headers/private/system/arch/ haiku/trunk/headers/private/system/arch/m68k/ haiku/trunk/headers/private/system/arch/m68k/arch_commpage_defs.h haiku/trunk/headers/private/system/arch/m68k/arch_config.h haiku/trunk/headers/private/system/arch/m68k/arch_elf.h haiku/trunk/headers/private/system/arch/m68k/arch_real_time_data.h haiku/trunk/headers/private/system/arch/ppc/ haiku/trunk/headers/private/system/arch/ppc/arch_commpage_defs.h haiku/trunk/headers/private/system/arch/ppc/arch_config.h haiku/trunk/headers/private/system/arch/ppc/arch_elf.h haiku/trunk/headers/private/system/arch/ppc/arch_real_time_data.h haiku/trunk/headers/private/system/arch/x86/ haiku/trunk/headers/private/system/arch/x86/apm_defs.h haiku/trunk/headers/private/system/arch/x86/arch_commpage_defs.h haiku/trunk/headers/private/system/arch/x86/arch_config.h haiku/trunk/headers/private/system/arch/x86/arch_elf.h haiku/trunk/headers/private/system/arch/x86/arch_real_time_data.h haiku/trunk/headers/private/system/commpage_defs.h haiku/trunk/headers/private/system/ddm_userland_interface_defs.h haiku/trunk/headers/private/system/elf32.h haiku/trunk/headers/private/system/generic_syscall_defs.h haiku/trunk/headers/private/system/posix/ haiku/trunk/headers/private/system/posix/realtime_sem_defs.h haiku/trunk/headers/private/system/real_time_data.h haiku/trunk/headers/private/system/safemode_defs.h haiku/trunk/headers/private/system/syscall_process_info.h haiku/trunk/headers/private/system/syscalls.h haiku/trunk/headers/private/system/thread_defs.h haiku/trunk/headers/private/system/tls.h haiku/trunk/headers/private/system/user_runtime.h haiku/trunk/headers/private/system/user_thread_defs.h haiku/trunk/headers/private/system/vfs_defs.h haiku/trunk/headers/private/system/vm_defs.h Removed: haiku/trunk/headers/private/kernel/arch/m68k/arch_commpage.h haiku/trunk/headers/private/kernel/arch/m68k/arch_config.h haiku/trunk/headers/private/kernel/arch/m68k/arch_elf.h haiku/trunk/headers/private/kernel/arch/m68k/arch_real_time_data.h haiku/trunk/headers/private/kernel/arch/ppc/arch_commpage.h haiku/trunk/headers/private/kernel/arch/ppc/arch_config.h haiku/trunk/headers/private/kernel/arch/ppc/arch_elf.h haiku/trunk/headers/private/kernel/arch/ppc/arch_real_time_data.h haiku/trunk/headers/private/kernel/arch/x86/arch_commpage.h haiku/trunk/headers/private/kernel/arch/x86/arch_config.h haiku/trunk/headers/private/kernel/arch/x86/arch_elf.h haiku/trunk/headers/private/kernel/arch/x86/arch_real_time_data.h haiku/trunk/headers/private/kernel/elf32.h haiku/trunk/headers/private/kernel/real_time_data.h haiku/trunk/headers/private/kernel/syscall_process_info.h haiku/trunk/headers/private/kernel/syscalls.h haiku/trunk/headers/private/kernel/tls.h haiku/trunk/headers/private/kernel/user_runtime.h Modified: haiku/trunk/build/jam/BuildSetup haiku/trunk/build/jam/HeadersRules haiku/trunk/headers/private/kernel/arch/x86/apm.h haiku/trunk/headers/private/kernel/commpage.h haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h haiku/trunk/headers/private/kernel/generic_syscall.h haiku/trunk/headers/private/kernel/kernel.h haiku/trunk/headers/private/kernel/posix/realtime_sem.h haiku/trunk/headers/private/kernel/safemode.h haiku/trunk/headers/private/kernel/thread.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/libroot/user_thread.h haiku/trunk/src/add-ons/input_server/devices/keyboard/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/agp_gart/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/ide/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/isa/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/scsi/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/usb/Jamfile haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile haiku/trunk/src/add-ons/kernel/drivers/random/Jamfile haiku/trunk/src/add-ons/kernel/generic/block_io/virtual_memory.c haiku/trunk/src/apps/powerstatus/Jamfile haiku/trunk/src/apps/powerstatus/PowerStatusView.cpp haiku/trunk/src/bin/Jamfile haiku/trunk/src/bin/fdinfo.cpp haiku/trunk/src/bin/listdev/Jamfile haiku/trunk/src/bin/listdev/dm_wrapper.c haiku/trunk/src/bin/multiuser/Jamfile haiku/trunk/src/bin/network/arp/Jamfile haiku/trunk/src/bin/network/arp/arp.cpp haiku/trunk/src/bin/network/netstat/Jamfile haiku/trunk/src/bin/strace/Jamfile haiku/trunk/src/kits/app/Jamfile haiku/trunk/src/kits/debug/Jamfile haiku/trunk/src/kits/network/Jamfile haiku/trunk/src/kits/opengl/GLRendererRoster.cpp haiku/trunk/src/kits/opengl/Jamfile haiku/trunk/src/kits/storage/Jamfile haiku/trunk/src/kits/storage/disk_device/DiskDevice.cpp haiku/trunk/src/kits/storage/disk_device/DiskDeviceJobGenerator.cpp haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp haiku/trunk/src/kits/storage/disk_device/DiskSystem.cpp haiku/trunk/src/kits/storage/disk_device/MutablePartition.cpp haiku/trunk/src/kits/storage/disk_device/Partition.cpp haiku/trunk/src/kits/storage/disk_device/PartitioningInfo.cpp haiku/trunk/src/kits/translation/Jamfile haiku/trunk/src/kits/translation/TranslatorRoster.cpp haiku/trunk/src/preferences/time/Jamfile haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp haiku/trunk/src/servers/app/drawing/Jamfile haiku/trunk/src/servers/input/InputServer.cpp haiku/trunk/src/servers/input/Jamfile haiku/trunk/src/servers/media/AddOnManager.cpp haiku/trunk/src/servers/media/Jamfile haiku/trunk/src/servers/registrar/Jamfile haiku/trunk/src/system/boot/loader/Jamfile haiku/trunk/src/system/glue/Jamfile haiku/trunk/src/system/kernel/arch/m68k/Jamfile haiku/trunk/src/system/kernel/arch/ppc/Jamfile haiku/trunk/src/system/kernel/arch/x86/Jamfile haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S haiku/trunk/src/system/kernel/lib/kernel_vsprintf.c haiku/trunk/src/system/libroot/Jamfile haiku/trunk/src/system/libroot/os/Jamfile haiku/trunk/src/system/libroot/os/arch/m68k/Jamfile haiku/trunk/src/system/libroot/os/arch/ppc/Jamfile haiku/trunk/src/system/libroot/os/arch/x86/Jamfile haiku/trunk/src/system/libroot/os/arch/x86/syscalls.inc haiku/trunk/src/system/libroot/os/arch/x86/time.c haiku/trunk/src/system/libroot/os/thread.c haiku/trunk/src/system/libroot/os/time.c haiku/trunk/src/system/libroot/posix/Jamfile haiku/trunk/src/system/libroot/posix/malloc/Jamfile haiku/trunk/src/system/libroot/posix/pthread/Jamfile haiku/trunk/src/system/libroot/posix/pthread/pthread.c haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c haiku/trunk/src/system/libroot/posix/semaphore.cpp haiku/trunk/src/system/libroot/posix/signal/Jamfile haiku/trunk/src/system/libroot/posix/stdio/Jamfile haiku/trunk/src/system/libroot/posix/stdlib/Jamfile haiku/trunk/src/system/libroot/posix/string/Jamfile haiku/trunk/src/system/libroot/posix/string/arch/x86/arch_string.S haiku/trunk/src/system/libroot/posix/sys/Jamfile haiku/trunk/src/system/libroot/posix/sys/mman.cpp haiku/trunk/src/system/libroot/posix/sys/wait.c haiku/trunk/src/system/libroot/posix/time/Jamfile haiku/trunk/src/system/libroot/posix/unistd/Jamfile haiku/trunk/src/system/libroot/posix/unistd/conf.c haiku/trunk/src/system/runtime_loader/Jamfile haiku/trunk/src/system/runtime_loader/elf.cpp haiku/trunk/src/tools/gensyscalls/Jamfile Log: * Introduced new header directory headers/private/system which is supposed to contain headers shared by kernel and userland (mainly libroot). * Moved quite a few private kernel headers to the new location. Split several kernel headers into a shared part and one that is still kernel private. Adjusted all affected Jamfiles and source in the standard x86 build accordingly. The build for other architectures and for test code may be broken. * Quite a bit of userland code still includes private kernel headers. Mostly those are headers. The ones that aren't strictly kernel-only should be moved to some other place (maybe headers/private/shared/util). Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/build/jam/BuildSetup 2008-05-14 03:55:16 UTC (rev 25486) @@ -323,11 +323,17 @@ HAIKU_DEFINES += _BEOS_R5_COMPATIBLE_ ; } +# private shared kernel/libroot headers +HAIKU_PRIVATE_SYSTEM_HEADERS = + [ PrivateHeaders $(DOT) system system/arch/$(HAIKU_ARCH) ] +; + # private kernel headers to be used when compiling kernel code HAIKU_PRIVATE_KERNEL_HEADERS = [ PrivateHeaders $(DOT) kernel libroot kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] [ ArchHeaders $(HAIKU_ARCH) ] + $(HAIKU_PRIVATE_SYSTEM_HEADERS) ; # Add some grist to the libgcc objects @@ -550,6 +556,9 @@ # private kernel headers do be used when compiling kernel code HOST_PRIVATE_KERNEL_HEADERS = ; +# private shared kernel/libroot headers +HOST_PRIVATE_SYSTEM_HEADERS = ; + # under BeOS use copyattr instead of cp if $(HOST_PLATFORM_BEOS_COMPATIBLE) { @@ -748,6 +757,7 @@ KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS PRIVATE_KERNEL_HEADERS + PRIVATE_SYSTEM_HEADERS LIBSTDC++ LIBSUPC++ Modified: haiku/trunk/build/jam/HeadersRules =================================================================== --- haiku/trunk/build/jam/HeadersRules 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/build/jam/HeadersRules 2008-05-14 03:55:16 UTC (rev 25486) @@ -343,6 +343,11 @@ UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; } +rule UsePrivateSystemHeaders +{ + UseHeaders $(TARGET_PRIVATE_SYSTEM_HEADERS) : true ; +} + rule FStandardOSHeaders { local osIncludes = add-ons add-ons/file_system add-ons/graphics Deleted: haiku/trunk/headers/private/kernel/arch/m68k/arch_commpage.h Deleted: haiku/trunk/headers/private/kernel/arch/m68k/arch_config.h Deleted: haiku/trunk/headers/private/kernel/arch/m68k/arch_elf.h Deleted: haiku/trunk/headers/private/kernel/arch/m68k/arch_real_time_data.h Deleted: haiku/trunk/headers/private/kernel/arch/ppc/arch_commpage.h Deleted: haiku/trunk/headers/private/kernel/arch/ppc/arch_config.h Deleted: haiku/trunk/headers/private/kernel/arch/ppc/arch_elf.h Deleted: haiku/trunk/headers/private/kernel/arch/ppc/arch_real_time_data.h Modified: haiku/trunk/headers/private/kernel/arch/x86/apm.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/apm.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/arch/x86/apm.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -5,9 +5,11 @@ #ifndef KERNEL_APM_H #define KERNEL_APM_H - #include +#include + + struct kernel_args; @@ -47,17 +49,6 @@ } apm_info; -// temporary generic syscall interface -#define APM_SYSCALLS "apm" -#define APM_GET_BATTERY_INFO 1 - -struct battery_info { - bool online; - int32 percent; - time_t time_left; -}; - - #ifndef _BOOT_MODE #ifdef __cplusplus extern "C" { Deleted: haiku/trunk/headers/private/kernel/arch/x86/arch_commpage.h Deleted: haiku/trunk/headers/private/kernel/arch/x86/arch_config.h Deleted: haiku/trunk/headers/private/kernel/arch/x86/arch_elf.h Deleted: haiku/trunk/headers/private/kernel/arch/x86/arch_real_time_data.h Modified: haiku/trunk/headers/private/kernel/commpage.h =================================================================== --- haiku/trunk/headers/private/kernel/commpage.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/commpage.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -5,32 +5,11 @@ #ifndef _KERNEL_COMMPAGE_H #define _KERNEL_COMMPAGE_H -/*! Some systemwide commpage constants, used in the kernel and libroot */ +#include -#ifndef _ASSEMBLER -# include -#endif +#include -/* be careful what you put here, this file is included from assembly */ -#define COMMPAGE_ENTRY_MAGIC 0 -#define COMMPAGE_ENTRY_VERSION 1 -#define COMMPAGE_ENTRY_REAL_TIME_DATA 2 -#define COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC 3 - -#define COMMPAGE_SIZE (0x8000) -#define COMMPAGE_TABLE_ENTRIES 64 - -#define COMMPAGE_SIGNATURE 'COMM' -#define COMMPAGE_VERSION 1 - -#define USER_COMMPAGE_ADDR ARCH_USER_COMMPAGE_ADDR - // set by the architecture specific implementation - -#ifndef _ASSEMBLER - -#define USER_COMMPAGE_TABLE ((void**)(USER_COMMPAGE_ADDR)) - #ifdef __cplusplus extern "C" { #endif @@ -46,8 +25,4 @@ } // extern "C" #endif -#endif // ! _ASSEMBLER - -#include - #endif /* _KERNEL_COMMPAGE_H */ Modified: haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/disk_device_manager/ddm_userland_interface.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -12,62 +12,14 @@ #include +#include #include + #ifdef __cplusplus extern "C" { #endif -// userland partition representation -typedef struct user_partition_data user_partition_data; -struct user_partition_data { - partition_id id; - off_t offset; - off_t size; - off_t content_size; - uint32 block_size; - uint32 status; - uint32 flags; - dev_t volume; - int32 index; - int32 change_counter; // needed? - disk_system_id disk_system; - char *name; - char *content_name; - char *type; - char *content_type; - char *parameters; - char *content_parameters; - void *user_data; - int32 child_count; - user_partition_data *children[1]; -}; - -// userland disk device representation -typedef struct user_disk_device_data { - uint32 device_flags; - char *path; - user_partition_data device_partition_data; -} user_disk_device_data; - -// userland disk system representation -typedef struct user_disk_system_info { - disk_system_id id; - char name[B_FILE_NAME_LENGTH]; // better B_PATH_NAME_LENGTH? - char short_name[B_OS_NAME_LENGTH]; - char pretty_name[B_OS_NAME_LENGTH]; - uint32 flags; -} user_disk_system_info; - -// userland disk device job representation -typedef struct user_disk_device_job_info { - disk_job_id id; - uint32 type; - partition_id partition; - char description[256]; -} user_disk_device_job_info; - - /*! Syscalls entries */ // iterating, retrieving device/partition data Deleted: haiku/trunk/headers/private/kernel/elf32.h Modified: haiku/trunk/headers/private/kernel/generic_syscall.h =================================================================== --- haiku/trunk/headers/private/kernel/generic_syscall.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/generic_syscall.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -8,18 +8,15 @@ #include +#include + /* If we decide to make this API public, the contents of this file * should be moved to KernelExport.h */ typedef status_t (*syscall_hook)(const char *subsystem, uint32 function, void *buffer, size_t bufferSize); -/* predefined functions */ -#define B_RESERVED_SYSCALL_BASE 0x80000000 -#define B_SYSCALL_INFO (B_RESERVED_SYSCALL_BASE) - // gets a minimum version uint32, and fills it with the current version on return - /* syscall flags */ #define B_SYSCALL_NOT_REPLACEABLE 1 #define B_DO_NOT_REPLACE_SYSCALL 2 Modified: haiku/trunk/headers/private/kernel/kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/kernel.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -34,13 +34,6 @@ #endif #define KERNEL_STACK_GUARD_PAGES 1 -/** Size of the stack given to teams in user space */ -#define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024) // 16 MB -#define USER_STACK_SIZE (256 * 1024) // 256 kB -#define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB -#define MAX_USER_STACK_SIZE (16 * 1024 * 1024) // 16 MB -#define USER_STACK_GUARD_PAGES 4 // 16 kB - /** Size of the environmental variables space for a process */ #define ENV_SIZE (B_PAGE_SIZE * 8) Modified: haiku/trunk/headers/private/kernel/posix/realtime_sem.h =================================================================== --- haiku/trunk/headers/private/kernel/posix/realtime_sem.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/posix/realtime_sem.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -11,15 +11,12 @@ #include +#include + struct realtime_sem_context; -#define MAX_POSIX_SEMS_PER_TEAM 128 -#define MAX_POSIX_SEMS 1024 -#define MAX_POSIX_SEM_VALUE INT_MAX - - __BEGIN_DECLS void realtime_sem_init(); Deleted: haiku/trunk/headers/private/kernel/real_time_data.h Modified: haiku/trunk/headers/private/kernel/safemode.h =================================================================== --- haiku/trunk/headers/private/kernel/safemode.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/safemode.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -5,22 +5,11 @@ #ifndef _KERNEL_SAFEMODE_H #define _KERNEL_SAFEMODE_H - #include +#include -// these are BeOS compatible additions to the safemode -// constants in the driver_settings.h header -#define B_SAFEMODE_DISABLE_USER_ADD_ONS "disableuseraddons" -#define B_SAFEMODE_DISABLE_IDE_DMA "disableidedma" -#define B_SAFEMODE_DISABLE_ACPI "disable_acpi" -#define B_SAFEMODE_DISABLE_APM "disable_apm" -#define B_SAFEMODE_DISABLE_SMP "disable_smp" -#define B_SAFEMODE_DISABLE_HYPER_THREADING "disable_hyperthreading" -#define B_SAFEMODE_FAIL_SAFE_VIDEO_MODE "fail_safe_video_mode" - - #ifdef __cplusplus extern "C" { #endif Deleted: haiku/trunk/headers/private/kernel/syscall_process_info.h Deleted: haiku/trunk/headers/private/kernel/syscalls.h Modified: haiku/trunk/headers/private/kernel/thread.h =================================================================== --- haiku/trunk/headers/private/kernel/thread.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/thread.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -22,21 +22,7 @@ struct select_info; struct thread_creation_attributes; -struct thread_creation_attributes { - int32 (*entry)(thread_func, void *); - const char* name; - int32 priority; - void* args1; - void* args2; - void* stack_address; - size_t stack_size; - // when calling kernel only - team_id team; - thread_id thread; -}; - - #ifdef __cplusplus extern "C" { #endif Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -50,11 +51,6 @@ JOB_CONTROL_STATE_DEAD } job_control_state; -#define THREAD_RETURN_EXIT 0x1 -#define THREAD_RETURN_INTERRUPTED 0x2 -#define THREAD_STOPPED 0x3 -#define THREAD_CONTINUED 0x4 - // The type of object a thread blocks on (thread::wait::type, set by // thread_prepare_to_block()). enum { Deleted: haiku/trunk/headers/private/kernel/tls.h Deleted: haiku/trunk/headers/private/kernel/user_runtime.h Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/vfs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -21,7 +21,9 @@ #include #include +#include + #define DEFAULT_FD_TABLE_SIZE 256 #define MAX_FD_TABLE_SIZE 8192 #define DEFAULT_NODE_MONITORS 4096 @@ -54,13 +56,6 @@ uint32 max_monitors; } io_context; -struct fd_info { - int number; - int32 open_mode; - dev_t device; - ino_t node; -}; - /* macro to allocate a iovec array on the stack */ #define IOVECS(name, size) \ uint8 _##name[sizeof(iovecs) + (size)*sizeof(iovec)]; \ Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/kernel/vm.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -8,12 +8,12 @@ #ifndef _KERNEL_VM_H #define _KERNEL_VM_H +#include #include +#include -#include - struct kernel_args; struct team; struct vm_page; @@ -23,63 +23,6 @@ struct vnode; -// additional protection flags -// Note: the VM probably won't support all combinations - it will try -// its best, but create_area() will fail if it has to. -// Of course, the exact behaviour will be documented somewhere... -#define B_EXECUTE_AREA 0x04 -#define B_STACK_AREA 0x08 - // "stack" protection is not available on most platforms - it's used - // to only commit memory as needed, and have guard pages at the - // bottom of the stack. - // "execute" protection is currently ignored, but nevertheless, you - // should use it if you require to execute code in that area. - -#define B_KERNEL_EXECUTE_AREA 0x40 -#define B_KERNEL_STACK_AREA 0x80 - -#define B_USER_PROTECTION \ - (B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA | B_STACK_AREA) -#define B_KERNEL_PROTECTION \ - (B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_KERNEL_EXECUTE_AREA \ - | B_KERNEL_STACK_AREA) - -// TODO: These aren't really a protection flags, but since the "protection" -// field is the only flag field, we currently use it for this. -// A cleaner approach would be appreciated - maybe just an official generic -// flags region in the protection field. -#define B_OVERCOMMITTING_AREA 0x1000 -#define B_SHARED_AREA 0x2000 -#define B_KERNEL_AREA 0x4000 - // Usable from userland according to its protection flags, but the area - // itself is not deletable, resizable, etc from userland. - -#define B_USER_AREA_FLAGS (B_USER_PROTECTION) -#define B_KERNEL_AREA_FLAGS \ - (B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA \ - | B_SHARED_AREA) - -// flags for vm_get_physical_page() -enum { - PHYSICAL_PAGE_NO_WAIT = 0, - PHYSICAL_PAGE_CAN_WAIT, -}; - -// mapping argument for several internal VM functions -enum { - REGION_NO_PRIVATE_MAP = 0, - REGION_PRIVATE_MAP -}; - -enum { - // ToDo: these are here only temporarily - it's a private - // addition to the BeOS create_area() lock flags - B_ALREADY_WIRED = 6, -}; - -#define MEMORY_TYPE_SHIFT 28 - - #ifdef __cplusplus extern "C" { #endif Modified: haiku/trunk/headers/private/libroot/user_thread.h =================================================================== --- haiku/trunk/headers/private/libroot/user_thread.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/libroot/user_thread.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -8,17 +8,10 @@ #include #include -#include /* kernel header */ +#include +#include -struct user_thread { - int32 defer_signals; // counter; 0 == signals allowed - uint32 pending_signals; // signals that are pending, when - // signals are deferred - status_t wait_status; -}; - - static inline user_thread* get_user_thread() { Copied: haiku/trunk/headers/private/system/arch/m68k/arch_commpage_defs.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/m68k/arch_commpage.h) =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_commpage.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/headers/private/system/arch/m68k/arch_commpage_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,17 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_M68K_COMMPAGE_DEFS_H +#define _SYSTEM_ARCH_M68K_COMMPAGE_DEFS_H + +#ifndef _SYSTEM_COMMPAGE_DEFS_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_M68K_SYSCALL (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) +#define COMMPAGE_ENTRY_M68K_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1) + +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _SYSTEM_ARCH_M68K_COMMPAGE_DEFS_H */ Copied: haiku/trunk/headers/private/system/arch/m68k/arch_config.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/m68k/arch_config.h) Copied: haiku/trunk/headers/private/system/arch/m68k/arch_elf.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/m68k/arch_elf.h) Copied: haiku/trunk/headers/private/system/arch/m68k/arch_real_time_data.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/m68k/arch_real_time_data.h) Copied: haiku/trunk/headers/private/system/arch/ppc/arch_commpage_defs.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/ppc/arch_commpage.h) =================================================================== --- haiku/trunk/headers/private/kernel/arch/ppc/arch_commpage.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/headers/private/system/arch/ppc/arch_commpage_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,17 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_PPC_COMMPAGE_DEFS_H +#define _SYSTEM_ARCH_PPC_COMMPAGE_DEFS_H + +#ifndef _SYSTEM_COMMPAGE_DEFS_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_PPC_SYSCALL (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) +#define COMMPAGE_ENTRY_PPC_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1) + +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _SYSTEM_ARCH_PPC_COMMPAGE_DEFS_H */ Copied: haiku/trunk/headers/private/system/arch/ppc/arch_config.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/ppc/arch_config.h) Copied: haiku/trunk/headers/private/system/arch/ppc/arch_elf.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/ppc/arch_elf.h) Copied: haiku/trunk/headers/private/system/arch/ppc/arch_real_time_data.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/ppc/arch_real_time_data.h) Added: haiku/trunk/headers/private/system/arch/x86/apm_defs.h =================================================================== --- haiku/trunk/headers/private/system/arch/x86/apm_defs.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/system/arch/x86/apm_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,23 @@ +/* + * Copyright 2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef SYSTEM_ARCH_X86_APM_DEFS_H +#define SYSTEM_ARCH_X86_APM_DEFS_H + + +#include + + +// temporary generic syscall interface +#define APM_SYSCALLS "apm" +#define APM_GET_BATTERY_INFO 1 + +struct battery_info { + bool online; + int32 percent; + time_t time_left; +}; + + +#endif /* SYSTEM_ARCH_X86_APM_DEFS_H */ Copied: haiku/trunk/headers/private/system/arch/x86/arch_commpage_defs.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/x86/arch_commpage.h) =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_commpage.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/headers/private/system/arch/x86/arch_commpage_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,17 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_ARCH_x86_COMMPAGE_DEFS_H +#define _SYSTEM_ARCH_x86_COMMPAGE_DEFS_H + +#ifndef _SYSTEM_COMMPAGE_DEFS_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_X86_SYSCALL (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) +#define COMMPAGE_ENTRY_X86_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1) + +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _SYSTEM_ARCH_x86_COMMPAGE_DEFS_H */ Copied: haiku/trunk/headers/private/system/arch/x86/arch_config.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/x86/arch_config.h) Copied: haiku/trunk/headers/private/system/arch/x86/arch_elf.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/x86/arch_elf.h) Copied: haiku/trunk/headers/private/system/arch/x86/arch_real_time_data.h (from rev 25480, haiku/trunk/headers/private/kernel/arch/x86/arch_real_time_data.h) Added: haiku/trunk/headers/private/system/commpage_defs.h =================================================================== --- haiku/trunk/headers/private/system/commpage_defs.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/system/commpage_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,29 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_COMMPAGE_DEFS_H +#define _SYSTEM_COMMPAGE_DEFS_H + +/*! Some systemwide commpage constants, used in the kernel and libroot */ + +/* be careful what you put here, this file is included from assembly */ +#define COMMPAGE_ENTRY_MAGIC 0 +#define COMMPAGE_ENTRY_VERSION 1 +#define COMMPAGE_ENTRY_REAL_TIME_DATA 2 +#define COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC 3 + +#define COMMPAGE_SIZE (0x8000) +#define COMMPAGE_TABLE_ENTRIES 64 + +#define COMMPAGE_SIGNATURE 'COMM' +#define COMMPAGE_VERSION 1 + +#define USER_COMMPAGE_ADDR ARCH_USER_COMMPAGE_ADDR + // set by the architecture specific implementation + +#define USER_COMMPAGE_TABLE ((void**)(USER_COMMPAGE_ADDR)) + +#include + +#endif /* _SYSTEM_COMMPAGE_DEFS_H */ Added: haiku/trunk/headers/private/system/ddm_userland_interface_defs.h =================================================================== --- haiku/trunk/headers/private/system/ddm_userland_interface_defs.h 2008-05-13 23:41:09 UTC (rev 25485) +++ haiku/trunk/headers/private/system/ddm_userland_interface_defs.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,66 @@ +/* + * Copyright 2003-2008, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ingo Weinhold, bonefish at users.sf.net + */ +#ifndef _SYSTEM_DDM_USERLAND_INTERFACE_DEFS_H +#define _SYSTEM_DDM_USERLAND_INTERFACE_DEFS_H + +#include + +#include + + +// userland partition representation +typedef struct user_partition_data user_partition_data; +struct user_partition_data { + partition_id id; + off_t offset; + off_t size; + off_t content_size; + uint32 block_size; + uint32 status; + uint32 flags; + dev_t volume; + int32 index; + int32 change_counter; // needed? + disk_system_id disk_system; + char *name; + char *content_name; + char *type; + char *content_type; + char *parameters; + char *content_parameters; + void *user_data; + int32 child_count; + user_partition_data *children[1]; +}; + +// userland disk device representation +typedef struct user_disk_device_data { + uint32 device_flags; + char *path; + user_partition_data device_partition_data; +} user_disk_device_data; + +// userland disk system representation +typedef struct user_disk_system_info { + disk_system_id id; + char name[B_FILE_NAME_LENGTH]; // better B_PATH_NAME_LENGTH? + char short_name[B_OS_NAME_LENGTH]; + char pretty_name[B_OS_NAME_LENGTH]; + uint32 flags; +} user_disk_system_info; + +// userland disk device job representation +typedef struct user_disk_device_job_info { + disk_job_id id; + uint32 type; + partition_id partition; + char description[256]; +} user_disk_device_job_info; + + +#endif // _SYSTEM_DDM_USERLAND_INTERFACE_DEFS_H Copied: haiku/trunk/headers/private/system/elf32.h (from rev 25480, haiku/trunk/headers/private/kernel/elf32.h) =================================================================== --- haiku/trunk/headers/private/kernel/elf32.h 2008-05-12 22:01:12 UTC (rev 25480) +++ haiku/trunk/headers/private/system/elf32.h 2008-05-14 03:55:16 UTC (rev 25486) @@ -0,0 +1,312 @@ +/* + * Copyright 2002-2006, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT license. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ +#ifndef _ELF32_H +#define _ELF32_H + + +#include +#include + +#include + + +typedef uint32 Elf32_Addr; +typedef uint16 Elf32_Half; +typedef uint32 Elf32_Off; +typedef int32 Elf32_Sword; +typedef uint32 Elf32_Word; + + +/*** ELF header ***/ + +#define EI_NIDENT 16 + +struct Elf32_Ehdr { + uint8 e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; + +#ifdef __cplusplus + bool IsHostEndian() const; +#endif +}; + +#define ELF_MAGIC "\x7f""ELF" + +// e_ident[] indices +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +// architecture class (EI_CLASS) +#define ELFCLASS32 1 +#define ELFCLASS64 2 +// endian (EI_DATA) +#define ELFDATA2LSB 1 // little endian +#define ELFDATA2MSB 2 // big endian + + +/*** section header ***/ + +struct Elf32_Shdr { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +}; + +// special section indices +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_HIPROC 0xff1f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_HIRESERVE 0xffff + +// section header type +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 + +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +// section header flags +#define SHF_WRITE 1 +#define SHF_ALLOC 2 +#define SHF_EXECINSTR 4 + +#define SHF_MASKPROC 0xf0000000 + + +/*** program header ***/ + +struct Elf32_Phdr { + Elf32_Word p_type; + Elf32_Off p_offset; /* offset from the beginning of the file of the segment */ + Elf32_Addr p_vaddr; /* virtual address for the segment in memory */ + Elf32_Addr p_paddr; + Elf32_Word p_filesz; /* the size of the segment in the file */ + Elf32_Word p_memsz; /* the size of the segment in memory */ + Elf32_Word p_flags; + Elf32_Word p_align; + +#ifdef __cplusplus + bool IsReadWrite() const; + bool IsExecutable() const; +#endif +}; + +// program header segment types +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 + +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + +// program header segment flags +#define PF_EXECUTE 0x1 +#define PF_WRITE 0x2 +#define PF_READ 0x4 +#define PF_PROTECTION_MASK (PF_EXECUTE | PF_WRITE | PF_READ) + +#define PF_MASKPROC 0xf0000000 + +struct Elf32_Sym { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + uint8 st_info; + uint8 st_other; + Elf32_Half st_shndx; + +#ifdef __cplusplus + uint8 Bind() const; + uint8 Type() const; +#endif +}; + +#define ELF32_ST_BIND(i) ((i) >> 4) +#define ELF32_ST_TYPE(i) ((i) & 0xf) +#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf)) + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +#define STN_UNDEF 0 + +struct Elf32_Rel { + Elf32_Addr r_offset; + Elf32_Word r_info; + +#ifdef __cplusplus + uint8 SymbolIndex() const; + uint8 Type() const; +#endif +}; + +#ifdef __cplusplus +struct Elf32_Rela : public Elf32_Rel { +#else +struct Elf32_Rela { + Elf32_Addr r_offset; + Elf32_Word r_info; +#endif + Elf32_Sword r_addend; +}; + +#define ELF32_R_SYM(i) ((i) >> 8) +#define ELF32_R_TYPE(i) ((unsigned char)(i)) +#define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t)) + +struct Elf32_Dyn { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +}; + +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 [... truncated: 2091 lines follow ...] From korli at users.berlios.de Wed May 14 09:12:04 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 14 May 2008 09:12:04 +0200 Subject: [Haiku-commits] r25486 - in haiku/trunk: build/jam headers/private headers/private/kernel headers/private/kernel/arch/m68k headers/private/kernel/arch/ppc headers/private/kernel/arch/x86 headers/private/kernel/disk_device_manager headers/private/ Message-ID: Hi Ingo, 2008/5/14 bonefish at BerliOS : > * Introduced new header directory headers/private/system which is supposed > to contain headers shared by kernel and userland (mainly libroot). Sounds as a good improvement :) Bye, J?r?me From korli at users.berlios.de Wed May 14 09:13:11 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 14 May 2008 09:13:11 +0200 Subject: [Haiku-commits] r25485 - in haiku/trunk: build/jam src/kits/network src/kits/network/dns/irs src/kits/network/libnetapi In-Reply-To: <200805132341.m4DNf9Ua030863@sheep.berlios.de> References: <200805132341.m4DNf9Ua030863@sheep.berlios.de> Message-ID: Hi Ingo, 2008/5/14 bonefish at BerliOS : > @@ -190,7 +190,7 @@ > > # libnetwork.so replaces quite a few libraries > BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES > - = libsocket.so libbind.so libnet.so libnetapi.so libbnetapi.so ; > + = libsocket.so libbind.so libnet.so ; > > local lib ; > for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { > What about libbnetapi.so ? Is it an alias for libnetapi.so ? Bye, J?r?me From axeld at pinc-software.de Wed May 14 09:42:39 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 14 May 2008 09:42:39 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25485_-_in_haiku/trunk=3A_build/jam_sr?= =?utf-8?q?c/kits/network_src/kits/network/dns/irs_src/kits/network/libnet?= =?utf-8?q?api?= In-Reply-To: Message-ID: <601343909-BeMail@zon> "J?r?me Duval" wrote: > 2008/5/14 bonefish at BerliOS : > > @@ -190,7 +190,7 @@ > > > > # libnetwork.so replaces quite a few libraries > > BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES > > - = libsocket.so libbind.so libnet.so libnetapi.so > > libbnetapi.so ; > > + = libsocket.so libbind.so libnet.so ; > > > > local lib ; > > for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { > What about libbnetapi.so ? Is it an alias for libnetapi.so ? It's the BONE equivalent of libnetapi.so. I guess we should better only provide this one, and make libnetapi.so a symlink to it. The network init code currently cannot detect R5 code correctly in all situations due to this change (if an app only links against libnetapi.so, it has to be using the R5 API -- we cannot differentiate this case differently). Bye, Axel. From bonefish at mail.berlios.de Wed May 14 14:52:34 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 14 May 2008 14:52:34 +0200 Subject: [Haiku-commits] r25487 - haiku/trunk/headers/posix Message-ID: <200805141252.m4ECqYoD019607@sheep.berlios.de> Author: bonefish Date: 2008-05-14 14:52:34 +0200 (Wed, 14 May 2008) New Revision: 25487 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25487&view=rev Modified: haiku/trunk/headers/posix/pthread.h Log: Fixed potential warnings. Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2008-05-14 03:55:16 UTC (rev 25486) +++ haiku/trunk/headers/posix/pthread.h 2008-05-14 12:52:34 UTC (rev 25487) @@ -61,12 +61,12 @@ PTHREAD_MUTEX_DEFAULT, PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK, - PTHREAD_MUTEX_RECURSIVE, + PTHREAD_MUTEX_RECURSIVE }; enum pthread_process_shared { PTHREAD_PROCESS_PRIVATE, - PTHREAD_PROCESS_SHARED, + PTHREAD_PROCESS_SHARED }; /* From ingo_weinhold at gmx.de Wed May 14 14:57:44 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 14 May 2008 14:57:44 +0200 Subject: [Haiku-commits] r25485 - in haiku/trunk: build/jam src/kits/network src/kits/network/dns/irs src/kits/network/libnetapi In-Reply-To: <601343909-BeMail@zon> References: <601343909-BeMail@zon> Message-ID: <20080514145744.453.1@knochen-vm.1210767899.fake> On 2008-05-14 at 09:42:39 [+0200], Axel D?rfler wrote: > "J?r?me Duval" wrote: > > 2008/5/14 bonefish at BerliOS : > > > @@ -190,7 +190,7 @@ > > > > > > # libnetwork.so replaces quite a few libraries > > > BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES > > > - = libsocket.so libbind.so libnet.so libnetapi.so > > > libbnetapi.so ; > > > + = libsocket.so libbind.so libnet.so ; > > > > > > local lib ; > > > for lib in $(BEOS_SYSTEM_LIBS_LIBNETWORK_ALIASES) { > > What about libbnetapi.so ? Is it an alias for libnetapi.so ? > > It's the BONE equivalent of libnetapi.so. I guess we should better only > provide this one, and make libnetapi.so a symlink to it. OK, for some reason I though libbnetapi.so was ancient legacy. > The network init code currently cannot detect R5 code correctly in all > situations due to this change (if an app only links against > libnetapi.so, it has to be using the R5 API -- we cannot differentiate > this case differently). I'll add detection for that case. CU, Ingo From mmu_man at mail.berlios.de Wed May 14 15:32:53 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 14 May 2008 15:32:53 +0200 Subject: [Haiku-commits] r25488 - haiku/trunk/build/jam Message-ID: <200805141332.m4EDWrWe026707@sheep.berlios.de> Author: mmu_man Date: 2008-05-14 15:32:52 +0200 (Wed, 14 May 2008) New Revision: 25488 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25488&view=rev Modified: haiku/trunk/build/jam/BuildSetup Log: - add sunos as possible host - fix build (at least CodyCam), NETAPI lib is now libnetapi for Haiku... Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2008-05-14 12:52:34 UTC (rev 25487) +++ haiku/trunk/build/jam/BuildSetup 2008-05-14 13:32:52 UTC (rev 25488) @@ -359,7 +359,7 @@ # network libraries HAIKU_NETWORK_LIBS = network ; -HAIKU_NETAPI_LIB = network ; +HAIKU_NETAPI_LIB = netapi ; HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway # library and executable glue code @@ -453,7 +453,7 @@ # check the host platform compatibility SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host - : linux freebsd darwin ; + : linux freebsd darwin sunos ; if $(HOST_PLATFORM) = linux || $(HOST_PLATFORM) = freebsd || $(HOST_PLATFORM) = darwin { @@ -527,8 +527,8 @@ case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; case haiku_host : HOST_DEBUG_FLAGS ?= -ggdb ; case linux : HOST_DEBUG_FLAGS ?= -ggdb ; - case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; - case darwin : HOST_DEBUG_FLAGS ?= -ggdb ; + case freebsd : HOST_DEBUG_FLAGS ?= -ggdb ; + case darwin : HOST_DEBUG_FLAGS ?= -ggdb ; case * : HOST_DEBUG_FLAGS ?= -g ; } @@ -658,7 +658,7 @@ # network libraries if $(HOST_PLATFORM_HAIKU_COMPATIBLE) { HOST_NETWORK_LIBS = network ; - HOST_NETAPI_LIB = network ; + HOST_NETAPI_LIB = netapi ; HOST_SELECT_UNAME_ETC_LIB = ; # libroot } else if $(HOST_PLATFORM_BONE_COMPATIBLE) { HOST_NETWORK_LIBS = socket bind ; From bonefish at mail.berlios.de Wed May 14 15:49:49 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 14 May 2008 15:49:49 +0200 Subject: [Haiku-commits] r25489 - in haiku/trunk: build/jam headers/private/net src/kits/network src/kits/network/libnetapi Message-ID: <200805141349.m4EDnnU2028768@sheep.berlios.de> Author: bonefish Date: 2008-05-14 15:49:48 +0200 (Wed, 14 May 2008) New Revision: 25489 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25489&view=rev Added: haiku/trunk/src/kits/network/libnetapi/init.cpp Modified: haiku/trunk/build/jam/BuildSetup haiku/trunk/build/jam/HaikuImage haiku/trunk/headers/private/net/r5_compatibility.h haiku/trunk/src/kits/network/init.cpp haiku/trunk/src/kits/network/libnetapi/Jamfile haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp haiku/trunk/src/kits/network/socket.cpp Log: * Renamed libnetapi to libbnetapi. Create a symlink in the image. * Extended R5 compatibility check to also consider calls from libbnetapi. * Fixed incorrect R5 compatibility check in BNetEndpoint constructor. Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/build/jam/BuildSetup 2008-05-14 13:49:48 UTC (rev 25489) @@ -359,7 +359,7 @@ # network libraries HAIKU_NETWORK_LIBS = network ; -HAIKU_NETAPI_LIB = netapi ; +HAIKU_NETAPI_LIB = bnetapi ; HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway # library and executable glue code @@ -408,8 +408,8 @@ # init library name map { local i ; - for i in be game GL mail media midi midi2 network netapi opengl screensaver root z - textencoding tracker translation { + for i in be game GL mail media midi midi2 network bnetapi opengl + screensaver root z textencoding tracker translation { HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ; } HAIKU_LIBRARY_NAME_MAP_libstdc++ = $(HAIKU_LIBSTDC++) ; @@ -658,7 +658,7 @@ # network libraries if $(HOST_PLATFORM_HAIKU_COMPATIBLE) { HOST_NETWORK_LIBS = network ; - HOST_NETAPI_LIB = netapi ; + HOST_NETAPI_LIB = bnetapi ; HOST_SELECT_UNAME_ETC_LIB = ; # libroot } else if $(HOST_PLATFORM_BONE_COMPATIBLE) { HOST_NETWORK_LIBS = socket bind ; Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/build/jam/HaikuImage 2008-05-14 13:49:48 UTC (rev 25489) @@ -64,7 +64,7 @@ Playground Pulse Sudoku ; BEOS_SYSTEM_LIBS = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so - libtranslation.so libnetapi.so libnetwork.so libdebug.so libbsd.so + libtranslation.so libbnetapi.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so libfluidsynth.so liblpsolve55.so liblinprog.so libalm.so @@ -197,6 +197,8 @@ AddSymlinkToHaikuImage beos system lib : libnetwork.so : $(lib) ; } +AddSymlinkToHaikuImage beos system lib : libbnetapi.so : libnetapi.so ; + # libGL.so has GLUT built-in if $(TARGET_ARCH) = x86 { AddSymlinkToHaikuImage beos system lib : $(X86_ONLY)libGL.so : libglut.so ; Modified: haiku/trunk/headers/private/net/r5_compatibility.h =================================================================== --- haiku/trunk/headers/private/net/r5_compatibility.h 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/headers/private/net/r5_compatibility.h 2008-05-14 13:49:48 UTC (rev 25489) @@ -41,5 +41,7 @@ extern bool __gR5Compatibility; extern addr_t __gNetworkStart; extern addr_t __gNetworkEnd; +extern addr_t __gNetAPIStart; +extern addr_t __gNetAPIEnd; #endif // NET_R5_COMPATIBILITY_H Modified: haiku/trunk/src/kits/network/init.cpp =================================================================== --- haiku/trunk/src/kits/network/init.cpp 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/src/kits/network/init.cpp 2008-05-14 13:49:48 UTC (rev 25489) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -18,6 +18,8 @@ bool __gR5Compatibility = false; addr_t __gNetworkStart; addr_t __gNetworkEnd; +addr_t __gNetAPIStart; +addr_t __gNetAPIEnd; static void Modified: haiku/trunk/src/kits/network/libnetapi/Jamfile =================================================================== --- haiku/trunk/src/kits/network/libnetapi/Jamfile 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/src/kits/network/libnetapi/Jamfile 2008-05-14 13:49:48 UTC (rev 25489) @@ -5,6 +5,7 @@ UsePrivateHeaders net ; local netapi_sources = + init.cpp NetEndpoint.cpp NetAddress.cpp NetBuffer.cpp @@ -43,7 +44,7 @@ # boot home config lib ; boot home Desktop haiku-networkingkit lib ; } else { - SharedLibrary libnetapi.so : + SharedLibrary libbnetapi.so : $(netapi_sources) : be $(TARGET_NETWORK_LIBS) ; Modified: haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp =================================================================== --- haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/src/kits/network/libnetapi/NetEndpoint.cpp 2008-05-14 13:49:48 UTC (rev 25489) @@ -3,9 +3,6 @@ * Distributed under the terms of the MIT License. */ - -#include - #include #include @@ -28,7 +25,7 @@ fTimeout(B_INFINITE_TIMEOUT), fLastError(0) { - if ((fSocket = socket(__gR5Compatibility ? R5_AF_INET : AF_INET, type, 0)) < 0) + if ((fSocket = socket(AF_INET, type, 0)) < 0) fLastError = errno; else fInit = B_OK; Added: haiku/trunk/src/kits/network/libnetapi/init.cpp =================================================================== --- haiku/trunk/src/kits/network/libnetapi/init.cpp 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/src/kits/network/libnetapi/init.cpp 2008-05-14 13:49:48 UTC (rev 25489) @@ -0,0 +1,41 @@ +/* + * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + */ + +#include + +#include +#include + +#include + + +static void +find_own_image() +{ + int32 cookie = 0; + image_info info; + while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + if (((uint32)info.text <= (uint32)find_own_image + && (uint32)info.text + (uint32)info.text_size > (uint32)find_own_image)) { + // found us + __gNetAPIStart = (addr_t)min_c(info.text, info.data); + __gNetAPIEnd = min_c((addr_t)info.text + info.text_size, + (addr_t)info.data + info.data_size); + break; + } + } +} + + +extern "C" void +initialize_before() +{ + // If in compatibility mode get our code address range. + if (__gR5Compatibility) + find_own_image(); +} Modified: haiku/trunk/src/kits/network/socket.cpp =================================================================== --- haiku/trunk/src/kits/network/socket.cpp 2008-05-14 13:32:52 UTC (rev 25488) +++ haiku/trunk/src/kits/network/socket.cpp 2008-05-14 13:49:48 UTC (rev 25489) @@ -38,8 +38,12 @@ }; stack_frame* frame = (stack_frame*)get_stack_frame(); - if (frame->return_address >= __gNetworkStart && frame->return_address < __gNetworkEnd) + if (frame->return_address >= __gNetworkStart + && frame->return_address < __gNetworkEnd + || frame->return_address >= __gNetAPIStart + && frame->return_address < __gNetAPIEnd) { return false; + } return true; #endif From stippi at mail.berlios.de Wed May 14 17:47:22 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 17:47:22 +0200 Subject: [Haiku-commits] r25490 - haiku/trunk/src/kits/storage/disk_device Message-ID: <200805141547.m4EFlMQ0018003@sheep.berlios.de> Author: stippi Date: 2008-05-14 17:47:22 +0200 (Wed, 14 May 2008) New Revision: 25490 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25490&view=rev Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp Log: GetDiskSystem() is supposed to find the system by name, it should not influence the internal enumaration for GetNextDiskSystem(). The compiler spotted that one actually... :-) Modified: haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp =================================================================== --- haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp 2008-05-14 13:49:48 UTC (rev 25489) +++ haiku/trunk/src/kits/storage/disk_device/DiskDeviceRoster.cpp 2008-05-14 15:47:22 UTC (rev 25490) @@ -134,7 +134,7 @@ int32 cookie = 0; user_disk_system_info info; - while (_kern_get_next_disk_system_info(&fDiskSystemCookie, &info) == B_OK) { + while (_kern_get_next_disk_system_info(&cookie, &info) == B_OK) { if (!strcmp(name, info.name) || !strcmp(name, info.short_name) || !strcmp(name, info.pretty_name)) From stippi at mail.berlios.de Wed May 14 17:48:41 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 17:48:41 +0200 Subject: [Haiku-commits] r25491 - in haiku/trunk: build/jam src/bin src/bin/mkfs Message-ID: <200805141548.m4EFmf3s018074@sheep.berlios.de> Author: stippi Date: 2008-05-14 17:48:41 +0200 (Wed, 14 May 2008) New Revision: 25491 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25491&view=rev Added: haiku/trunk/src/bin/mkfs/ haiku/trunk/src/bin/mkfs/FsCreator.cpp haiku/trunk/src/bin/mkfs/FsCreator.h haiku/trunk/src/bin/mkfs/Jamfile haiku/trunk/src/bin/mkfs/main.cpp Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/bin/Jamfile Log: Applied patch by Marco Minutoli: Added a new command line utility "mkfs" which can initialize a given volume with a file system by it's short name via the new Disk Device API. Thanks! Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/build/jam/HaikuImage 2008-05-14 15:48:41 UTC (rev 25491) @@ -35,7 +35,7 @@ ideinfo idestatus ifconfig install installsound iroster isvolume join keymap kill less lessecho lesskey link listarea listattr listdev listimage listport listres listsem ln locate logger login logname ls lsindex m4 make - makebootable md5sum merge mimeset mkdos mkdir mkfifo mkindex modifiers mount + makebootable md5sum merge mimeset mkdos mkdir mkfifo mkfs mkindex modifiers mount mount_nfs mountvolume mv nc netstat nl nohup od open passwd paste patch pathchk pc ping play playfile playsound playwav pr prio printenv printf ps ptx pwd query quit readlink release renice rescan rlog rm rmattr rmindex Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/src/bin/Jamfile 2008-05-14 15:48:41 UTC (rev 25491) @@ -185,6 +185,7 @@ SubInclude HAIKU_TOP src bin makebootable ; #SubInclude HAIKU_TOP src bin makeudfimage ; SubInclude HAIKU_TOP src bin mkdos ; +SubInclude HAIKU_TOP src bin mkfs ; SubInclude HAIKU_TOP src bin multiuser ; SubInclude HAIKU_TOP src bin patch ; SubInclude HAIKU_TOP src bin pc ; Added: haiku/trunk/src/bin/mkfs/FsCreator.cpp =================================================================== --- haiku/trunk/src/bin/mkfs/FsCreator.cpp 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/src/bin/mkfs/FsCreator.cpp 2008-05-14 15:48:41 UTC (rev 25491) @@ -0,0 +1,138 @@ +/* + * Copyright 2008 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marco Minutoli, mminutoli at gmail.com + */ + +#include "FsCreator.h" + +#include + +#include + + +FsCreator::FsCreator(const char* devPath, BString& type, + BString& volumeName, const char* fsOpt, bool verbose) + : + fType(type), + fDevicePath(devPath), + fVolumeName(volumeName), + fFsOptions(fsOpt), + fVerbose(verbose) +{ + BDiskDeviceRoster roster; + status_t ret = roster.GetDeviceForPath(devPath, &fDevice); + if (ret != B_OK) { + std::cerr << "Error: Failed to get disk device for path " + << devPath << ": " << strerror(ret); + } +} + + +bool +FsCreator::Run() +{ + // check that the device is writable + if (fDevice.IsReadOnly()) { + std::cerr << "Error: Can't Inizialize the device. " + "It is read only.\n"; + return false; + } + + // check if the device is mounted + if (fDevice.IsMounted()) { + std::cerr << "Error: The device has to be unmounted before.\n"; + return false; + } + + BDiskSystem diskSystem; + BDiskDeviceRoster dDRoster; + bool found = false; + while (dDRoster.GetNextDiskSystem(&diskSystem) == B_OK) { + if (diskSystem.IsFileSystem() && diskSystem.SupportsInitializing()) { + if (diskSystem.ShortName() == fType) { + found = true; + break; + } + } + } + + if (!found) { + std::cerr << "Error: " << fType.String() + << " is an invalid or unsupported file system type.\n"; + return false; + } + + // prepare the device for modifications + status_t ret = fDevice.PrepareModifications(); + if (ret != B_OK) { + std::cerr << "Error: A problem occurred preparing the device for the" + "modifications\n"; + return false; + } + if (fVerbose) + std::cout << "Preparing for modifications...\n\n"; + + // validate parameters + BString name(fVolumeName); + if (fDevice.ValidateInitialize(diskSystem.PrettyName(), + &fVolumeName, fFsOptions) != B_OK) { + std::cerr << "Error: Parameters validation failed. " + "Check what you wrote\n"; + std::cerr << ret; + return false; + } + if (fVerbose) + std::cout << "Parameters Validation...\n\n"; + if (name != fVolumeName) + std::cout << "Volume name was adjusted to " + << fVolumeName.String() << std::endl; + + // Initialize the partition + ret = fDevice.Initialize(diskSystem.PrettyName(), + fVolumeName.String(), fFsOptions); + if (ret != B_OK) { + std::cerr << "Initialization failed: " << strerror(ret) << std::endl; + return false; + } + + std::cout << "\nAre you sure you want to do this now?\n" + << "\nALL YOUR DATA in " << fDevicePath.String() + << " will be lost forever.\n"; + + BString reply; + do { + std::cout << "Continue? [yes|no]: "; + reply = _ReadLine(); + if (reply == "") + reply = "no"; // silence is dissence + } while (reply != "yes" && reply != "no"); + + if (reply == "yes") { + ret = fDevice.CommitModifications(); + if (ret == B_OK) { + if (fVerbose) { + std::cout << "Volume " << fDevice.ContentName() + << " has been initialized successfully!\n"; + } + } else { + std::cout << "Error: Initialization of " << fDevice.ContentName() + << " failed: " << strerror(ret) << std::endl; + return false; + } + } + return true; +} + + +inline BString +FsCreator::_ReadLine() +{ + char line[255]; + + cin.getline(line, sizeof(line), '\n'); + + return line; +} Added: haiku/trunk/src/bin/mkfs/FsCreator.h =================================================================== --- haiku/trunk/src/bin/mkfs/FsCreator.h 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/src/bin/mkfs/FsCreator.h 2008-05-14 15:48:41 UTC (rev 25491) @@ -0,0 +1,34 @@ +/* + * Copyright 2008 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marco Minutoli, mminutoli at gmail.com + */ +#ifndef _FSCREATOR_H_ +#define _FSCREATOR_H_ + +#include + +#include +#include + +class FsCreator { +public: + FsCreator(const char* devPath, BString& type, BString& volumeName, + const char* fsOpt, bool verbose); + + bool Run(); +private: + inline BString _ReadLine(); + + BString fType; + BString fDevicePath; + BString& fVolumeName; + const char* fFsOptions; + BDiskDevice fDevice; + BPartition* fPartition; + const bool fVerbose; +}; + +#endif // _FSCREATOR_H_ Added: haiku/trunk/src/bin/mkfs/Jamfile =================================================================== --- haiku/trunk/src/bin/mkfs/Jamfile 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/src/bin/mkfs/Jamfile 2008-05-14 15:48:41 UTC (rev 25491) @@ -0,0 +1,9 @@ +SubDir HAIKU_TOP src bin mkfs ; + +UsePrivateHeaders shared ; +UsePrivateHeaders storage ; + +BinCommand mkfs : + main.cpp + FsCreator.cpp + : be $(TARGET_LIBSTDC++) ; Added: haiku/trunk/src/bin/mkfs/main.cpp =================================================================== --- haiku/trunk/src/bin/mkfs/main.cpp 2008-05-14 15:47:22 UTC (rev 25490) +++ haiku/trunk/src/bin/mkfs/main.cpp 2008-05-14 15:48:41 UTC (rev 25491) @@ -0,0 +1,116 @@ +/* + * Copyright 2008 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Marco Minutoli, mminutoli at gmail.com + */ + +#include +#include +#include +#include +#include +#include "FsCreator.h" + +extern "C" const char* __progname; +static const char* kProgramName = __progname; + +static const char* kUsage = +"Usage: %s -t \n" +"\n" +"Options:\n" +" -t, --type - set type of filesystem to create\n\n" +" -h, --help - print this help text\n" +" -o, --options - set fs specific options\n" +" -v, --verbose - set verbose output\n" +; + + +/* + * Print program help on the right stream + */ +inline void +print_help(bool out) +{ + fprintf(out ? stdout : stderr, kUsage, kProgramName, kProgramName); +} + + +/* + * Print program help and exit + */ +inline void +print_help_exit(bool out) +{ + print_help(out); + exit(out ? 0 : 1); +} + + +int +main(int argc, char* const* argv) +{ + const struct option longOptions[] = { + { "help", 0, NULL, 'h' }, + { "options", 0, NULL, 'o' }, + { "type", 1, NULL, 't' }, + { "verbose", 0, NULL, 'v' }, + { NULL, 0, NULL, 0 } + }; + const char *shortOptions = "t:o:hv"; + + // parse argument list + int32 nextOption; + BString fsType; + BString fsOptions; + bool verbose = false; + + nextOption = getopt_long(argc, argv, shortOptions, longOptions, NULL); + if (nextOption == 't') + fsType = optarg; + else + print_help_exit(nextOption == 'h' ? true : false); + + do { + nextOption = getopt_long(argc, argv, shortOptions, longOptions, NULL); + + switch (nextOption) { + case 't': // -t or --type again? + print_help_exit(false); + break; + case 'h': // -h or --help + print_help_exit(true); + break; + case 'v': // -v or --verbose + verbose = true; + break; + case 'o': // -o or --options + fsOptions << optarg; + break; + case '?': // invalid option + break; + case -1: // done with options + break; + default: // everything else + print_help(false); + abort(); + } + } while (nextOption != -1); + + // the device name should be the first non-option element + // right before the VolumeName + if (optind != argc - 2) + print_help_exit(false); + const char* devPath = argv[optind]; + BString volName = argv[argc-1]; + + FsCreator* creator = new FsCreator(devPath, fsType, volName, + fsOptions.String(), verbose); + if (creator == NULL) { + std::cerr << "Error: FsCreator can't be allocated\n"; + abort(); + } + + return creator->Run(); +} From axeld at mail.berlios.de Wed May 14 18:48:05 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 14 May 2008 18:48:05 +0200 Subject: [Haiku-commits] r25492 - haiku/trunk/src/apps/aboutsystem Message-ID: <200805141648.m4EGm5b6024510@sheep.berlios.de> Author: axeld Date: 2008-05-14 18:48:03 +0200 (Wed, 14 May 2008) New Revision: 25492 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25492&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Added Christian Fasshauer, and Marco Minutoli to the list of contributors. Shinta, if you can give me your full name, I would like to add you too :-) Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-14 15:48:41 UTC (rev 25491) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2008-05-14 16:48:03 UTC (rev 25492) @@ -426,6 +426,7 @@ "David Dengg\n" "John Drinkwater\n" "Cian Duffy\n" + "Christian Fasshauer\n" "Marc Flerackers\n" "Daniel Furrer\n" "Matthijs Hollemans\n" @@ -450,6 +451,7 @@ "Jerome Leveque\n" "Christof Lutteroth\n" "Graham MacDonald\n" + "Marco Minutoli\n" "Jan Mat?jek\n" "Brian Matzon\n" "Christopher ML Zumwalt May\n" From mmlr at mail.berlios.de Wed May 14 19:09:44 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 14 May 2008 19:09:44 +0200 Subject: [Haiku-commits] r25493 - haiku/trunk/build/jam Message-ID: <200805141709.m4EH9imO026199@sheep.berlios.de> Author: mmlr Date: 2008-05-14 19:09:43 +0200 (Wed, 14 May 2008) New Revision: 25493 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25493&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Adding the usb_ecm driver to the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-14 16:48:03 UTC (rev 25492) +++ haiku/trunk/build/jam/HaikuImage 2008-05-14 17:09:43 UTC (rev 25493) @@ -128,7 +128,7 @@ BEOS_ADD_ONS_DRIVERS_NET = $(X86_ONLY)3com etherpci $(X86_ONLY)ipro1000 $(X86_ONLY)rtl8139 rtl8169 sis900 $(X86_ONLY)via_rhine wb840 $(X86_ONLY)ipro100 $(X86_ONLY)nforce #vlance - $(X86_ONLY)marvell_yukon $(X86_ONLY)syskonnect + $(X86_ONLY)marvell_yukon $(X86_ONLY)syskonnect usb_ecm $(GPL_ONLY)bcm440x $(GPL_ONLY)bcm570x ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; From teammaui at web.de Wed May 14 21:43:28 2008 From: teammaui at web.de (=?utf-8?Q?Ralf_Sch=C3=BClke?=) Date: Wed, 14 May 2008 21:43:28 +0200 Subject: [Haiku-commits] r25488 - haiku/trunk/build/jam In-Reply-To: <200805141332.m4EDWrWe026707@sheep.berlios.de> References: <200805141332.m4EDWrWe026707@sheep.berlios.de> Message-ID: On Wed, 14 May 2008 15:32:53 +0200, mmu_man at BerliOS wrote: > # check the host platform compatibility > SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host > - : linux freebsd darwin ; > + : linux freebsd darwin sunos ; is sunos OpenSolaris too ? Ralf Sch?lke -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From stippi at mail.berlios.de Wed May 14 21:44:48 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 21:44:48 +0200 Subject: [Haiku-commits] r25494 - haiku/trunk/src/kits/app Message-ID: <200805141944.m4EJim7w019240@sheep.berlios.de> Author: stippi Date: 2008-05-14 21:44:47 +0200 (Wed, 14 May 2008) New Revision: 25494 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25494&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: If an error happens during extraction of the argument vectors in _ArgvReceived(), the array elements still need to be set to NULL otherwise the function will free() random pointers at the end. Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-14 17:09:43 UTC (rev 25493) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-14 19:44:47 UTC (rev 25494) @@ -1425,7 +1425,7 @@ if (message->FindInt32("argc", &argc) == B_OK && argc > 0) { // allocate a NULL terminated array argv = new char*[argc + 1]; - argv[argc] = NULL; + memset(argv, 0, sizeof(char*) * argc + 1); // copy the arguments for (int32 i = 0; error == B_OK && i < argc; i++) { From anevilyak at gmail.com Wed May 14 21:47:48 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Wed, 14 May 2008 14:47:48 -0500 Subject: [Haiku-commits] r25488 - haiku/trunk/build/jam In-Reply-To: References: <200805141332.m4EDWrWe026707@sheep.berlios.de> Message-ID: On Wed, May 14, 2008 at 2:43 PM, Ralf Sch?lke wrote: > On Wed, 14 May 2008 15:32:53 +0200, mmu_man at BerliOS > wrote: > > > # check the host platform compatibility > > SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host > > - : linux freebsd darwin ; > > + : linux freebsd darwin sunos ; > > > is sunos OpenSolaris too ? > > Ralf Sch?lke > -- *Solaris = sunos 5.x, yes. Regards, Rene From stippi at mail.berlios.de Wed May 14 21:51:37 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 21:51:37 +0200 Subject: [Haiku-commits] r25495 - haiku/trunk/src/kits/app Message-ID: <200805141951.m4EJpbLC020069@sheep.berlios.de> Author: stippi Date: 2008-05-14 21:51:36 +0200 (Wed, 14 May 2008) New Revision: 25495 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25495&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: Just spotted a mistake in my previous commit... and while I am at it, I can properly credit James Woodcock, who debugged this problem and whom I forgot to mention in my previous commit. Sorry! Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-14 19:44:47 UTC (rev 25494) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-14 19:51:36 UTC (rev 25495) @@ -1425,7 +1425,7 @@ if (message->FindInt32("argc", &argc) == B_OK && argc > 0) { // allocate a NULL terminated array argv = new char*[argc + 1]; - memset(argv, 0, sizeof(char*) * argc + 1); + memset(argv, 0, sizeof(char*) * (argc + 1)); // copy the arguments for (int32 i = 0; error == B_OK && i < argc; i++) { From axeld at mail.berlios.de Wed May 14 21:57:13 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 14 May 2008 21:57:13 +0200 Subject: [Haiku-commits] r25496 - haiku/trunk/src/kits/app Message-ID: <200805141957.m4EJvDoo020366@sheep.berlios.de> Author: axeld Date: 2008-05-14 21:57:12 +0200 (Wed, 14 May 2008) New Revision: 25496 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25496&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: * Reworked James Woodcock/stippi's patch a bit: since the remaining entries are NULL pointers anyway, we just adjust argc. * Made argv processing more safe, it will now check if the allocation of the argv array succeeded in the first place. Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-14 19:51:36 UTC (rev 25495) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-14 19:57:12 UTC (rev 25496) @@ -1424,8 +1424,9 @@ char **argv = NULL; if (message->FindInt32("argc", &argc) == B_OK && argc > 0) { // allocate a NULL terminated array - argv = new char*[argc + 1]; - memset(argv, 0, sizeof(char*) * (argc + 1)); + argv = new(std::nothrow) char*[argc + 1]; + if (argv == NULL) + return; // copy the arguments for (int32 i = 0; error == B_OK && i < argc; i++) { @@ -1435,8 +1436,11 @@ argv[i] = strdup(arg); if (argv[i] == NULL) error = B_NO_MEMORY; - } + } else + argc = i; } + + argv[argc] = NULL; } // call the hook @@ -1562,8 +1566,10 @@ message.AddInt32("argc", argc); // add argv - for (int32 i = 0; i < argc; i++) - message.AddString("argv", argv[i]); + for (int32 i = 0; i < argc; i++) { + if (argv[i] != NULL) + message.AddString("argv", argv[i]); + } // add current working directory char cwd[B_PATH_NAME_LENGTH]; From korli at mail.berlios.de Wed May 14 22:03:31 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 14 May 2008 22:03:31 +0200 Subject: [Haiku-commits] r25497 - haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich Message-ID: <200805142003.m4EK3VJB021212@sheep.berlios.de> Author: korli Date: 2008-05-14 22:03:29 +0200 (Wed, 14 May 2008) New Revision: 25497 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25497&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/config.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/io.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/io.h haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/multi.c Log: * updated ac97 code with the one from Marcus' ich driver * merged existing quirks (reversed amp enable and ad1981b) testing is welcome! Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c 2008-05-14 19:57:12 UTC (rev 25496) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c 2008-05-14 20:03:29 UTC (rev 25497) @@ -1,10 +1,8 @@ /* - * Auich BeOS Driver for Intel Southbridge audio + * AC97 interface * - * Copyright (c) 2003, Jerome Duval (jerome.duval at free.fr) - * - * Original code : BeOS Driver for Intel ICH AC'97 Link interface * Copyright (c) 2002, Marcus Overhagen + * Copyright (c) 2008, J?r?me Duval * * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, @@ -30,14 +28,20 @@ */ #include #include +#include #include #include "ac97.h" - #include "debug.h" -#include "io.h" #define B_UTF8_REGISTERED "\xC2\xAE" +bool ac97_reg_is_valid(ac97_dev *dev, uint8 reg); +void ac97_amp_enable(ac97_dev *dev, bool onoff); +void ac97_dump_capabilities(ac97_dev *dev); +void ac97_detect_capabilities(ac97_dev *dev); +void ac97_detect_rates(ac97_dev *dev); +void ac97_update_register_cache(ac97_dev *dev); + const char * stereo_enhancement_technique[] = { "No 3D Stereo Enhancement", @@ -58,7 +62,7 @@ "ESS Technology", "Harman International", "Nvidea", - "Philips", + "Philips" "Texas Instruments", "VLSI Technology", "TriTech", @@ -74,110 +78,112 @@ "Unknown (31)" }; -typedef void (* codec_init)(device_config *); -typedef void (* codec_amp_enable)(device_config *, bool); +void default_init(ac97_dev *dev); +void ad1819_init(ac97_dev *dev); +void ad1881_init(ac97_dev *dev); +void ad1885_init(ac97_dev *dev); +void ad1886_init(ac97_dev *dev); +void ad1980_init(ac97_dev *dev); +void ad1981b_init(ac97_dev *dev); +void alc650_init(ac97_dev *dev); +void stac9708_init(ac97_dev *dev); +void stac9721_init(ac97_dev *dev); +void stac9744_init(ac97_dev *dev); +void stac9756_init(ac97_dev *dev); +void tr28028_init(ac97_dev *dev); +void wm9701_init(ac97_dev *dev); +void wm9703_init(ac97_dev *dev); +void wm9704_init(ac97_dev *dev); -typedef struct codec_ops_tag -{ - codec_init init; - codec_amp_enable amp_enable; -} codec_ops; +bool ad1819_set_rate(ac97_dev *dev, uint8 reg, uint32 rate); +bool ad1819_get_rate(ac97_dev *dev, uint8 reg, uint32 *rate); -typedef struct codec_table_tag +typedef struct { uint32 id; uint32 mask; - codec_ops *ops; + codec_init init; const char *info; } codec_table; -void default_init(device_config *); -void ad1886_init(device_config *); -void ad1981b_init(device_config *); - -void default_amp_enable(device_config *, bool); -void cs4299_amp_enable(device_config *, bool); - -codec_ops default_ops = { default_init, default_amp_enable }; -codec_ops ad1886_ops = { ad1886_init, default_amp_enable }; -codec_ops ad1981b_ops = { ad1981b_init, default_amp_enable }; -codec_ops cs4299_ops = { default_init, cs4299_amp_enable }; - codec_table codecs[] = { - /* Vendor ID and description imported from FreeBSD src/sys/dev/sound/pcm/ac97.c */ - { 0x414b4d00, 0xffffffff, &default_ops, "Asahi Kasei AK4540" }, - { 0x414b4d01, 0xffffffff, &default_ops, "Asahi Kasei AK4542" }, - { 0x414b4d02, 0xffffffff, &default_ops, "Asahi Kasei AK4543" }, - { 0x43525900, 0xffffffff, &default_ops, "Cirrus Logic CS4297" }, - { 0x43525903, 0xffffffff, &default_ops, "Cirrus Logic CS4297" }, - { 0x43525913, 0xffffffff, &default_ops, "Cirrus Logic CS4297A" }, - { 0x43525914, 0xffffffff, &default_ops, "Cirrus Logic CS4297B" }, - { 0x43525923, 0xffffffff, &default_ops, "Cirrus Logic CS4294C" }, - { 0x4352592b, 0xffffffff, &default_ops, "Cirrus Logic CS4298C" }, - { 0x43525931, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299A" }, - { 0x43525933, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299C" }, - { 0x43525934, 0xffffffff, &cs4299_ops, "Cirrus Logic CS4299D" }, - { 0x43525941, 0xffffffff, &default_ops, "Cirrus Logic CS4201A" }, - { 0x43525951, 0xffffffff, &default_ops, "Cirrus Logic CS4205A" }, - { 0x43525961, 0xffffffff, &default_ops, "Cirrus Logic CS4291A" }, - { 0x45838308, 0xffffffff, &default_ops, "ESS Technology ES1921" }, - { 0x49434511, 0xffffffff, &default_ops, "ICEnsemble ICE1232" }, - { 0x4e534331, 0xffffffff, &default_ops, "National Semiconductor LM4549" }, - { 0x83847600, 0xffffffff, &default_ops, "SigmaTel STAC9700/9783/9784" }, - { 0x83847604, 0xffffffff, &default_ops, "SigmaTel STAC9701/9703/9704/9705" }, - { 0x83847605, 0xffffffff, &default_ops, "SigmaTel STAC9704" }, - { 0x83847608, 0xffffffff, &default_ops, "SigmaTel STAC9708/9711" }, - { 0x83847609, 0xffffffff, &default_ops, "SigmaTel STAC9721/9723" }, - { 0x83847644, 0xffffffff, &default_ops, "SigmaTel STAC9744" }, - { 0x83847656, 0xffffffff, &default_ops, "SigmaTel STAC9756/9757" }, - { 0x53494c22, 0xffffffff, &default_ops, "Silicon Laboratory Si3036" }, - { 0x53494c23, 0xffffffff, &default_ops, "Silicon Laboratory Si3038" }, - { 0x54524103, 0xffffffff, &default_ops, "TriTech TR?????" }, - { 0x54524106, 0xffffffff, &default_ops, "TriTech TR28026" }, - { 0x54524108, 0xffffffff, &default_ops, "TriTech TR28028" }, - { 0x54524123, 0xffffffff, &default_ops, "TriTech TR28602" }, - { 0x574d4c00, 0xffffffff, &default_ops, "Wolfson WM9701A" }, - { 0x574d4c03, 0xffffffff, &default_ops, "Wolfson WM9703/9704" }, - { 0x574d4c04, 0xffffffff, &default_ops, "Wolfson WM9704 (quad)" }, - /* Assembled from datasheets: */ - { 0x41445303, 0xffffffff, &default_ops, "Analog Devices AD1819B SoundPort"B_UTF8_REGISTERED }, - { 0x41445340, 0xffffffff, &default_ops, "Analog Devices AD1881 SoundMAX"B_UTF8_REGISTERED }, - { 0x41445348, 0xffffffff, &default_ops, "Analog Devices AD1881A SoundMAX"B_UTF8_REGISTERED }, - { 0x41445360, 0xffffffff, &default_ops, "Analog Devices AD1885 SoundMAX"B_UTF8_REGISTERED }, - { 0x41445361, 0xffffffff, &ad1886_ops, "Analog Devices AD1886 SoundMAX"B_UTF8_REGISTERED }, - { 0x41445362, 0xffffffff, &default_ops, "Analog Devices AD1887 SoundMAX"B_UTF8_REGISTERED }, - { 0x41445363, 0xffffffff, &default_ops, "Analog Devices AD1886A SoundMAX"B_UTF8_REGISTERED }, - { 0x41445371, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED }, - { 0x41445372, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED }, - { 0x41445374, 0xffffffff, &ad1981b_ops, "Analog Devices AD1981B SoundMAX"B_UTF8_REGISTERED }, - { 0x414c4320, 0xfffffff0, &default_ops, "Avance Logic (Realtek) ALC100/ALC100P, RL5383/RL5522" }, - { 0x414c4730, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC101" }, -#if 0 - { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC200/ALC200A" }, /* datasheet says id2 = 4710 */ - { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC201/ALC201A" }, /* 4710 or 4720 */ - { 0x414c4720, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC650" }, /* datasheet says id2 = 4720 */ -#else - { 0x414c4710, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC200/ALC200A or ALC201/ALC201A" }, - { 0x414c4720, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC650 or ALC201/ALC201A" }, -#endif - { 0x414c4740, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC202/ALC202A" }, + { CODEC_ID_AD1819, 0xffffffff, ad1819_init, "Analog Devices AD1819A, AD1819B SoundPort"B_UTF8_REGISTERED }, + { CODEC_ID_AD1881, 0xffffffff, ad1881_init, "Analog Devices AD1881 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1881A, 0xffffffff, ad1881_init, "Analog Devices AD1881A SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1885, 0xffffffff, ad1885_init, "Analog Devices AD1885 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1886, 0xffffffff, ad1886_init, "Analog Devices AD1886 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1886A, 0xffffffff, ad1881_init, "Analog Devices AD1886A SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1887, 0xffffffff, ad1881_init, "Analog Devices AD1887 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1888, 0xffffffff, ad1881_init, "Analog Devices AD1888 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1980, 0xffffffff, ad1980_init, "Analog Devices AD1980 SoundMAX"B_UTF8_REGISTERED }, + { 0x41445371, 0xffffffff, default_init, "Analog Devices 0x41445371 (???)" }, + { 0x41445372, 0xffffffff, default_init, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1981B, 0xffffffff, ad1981b_init, "Analog Devices AD1981B SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1985, 0xffffffff, default_init, "Analog Devices AD1985 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AD1986, 0xffffffff, default_init, "Analog Devices AD1986 SoundMAX"B_UTF8_REGISTERED }, + { CODEC_ID_AK4540, 0xffffffff, default_init, "Asahi Kasei AK4540" }, + { CODEC_ID_AK4542, 0xffffffff, default_init, "Asahi Kasei AK4542" }, + { CODEC_ID_AK4543, 0xffffffff, default_init, "Asahi Kasei AK4543" }, + { 0x414c4320, 0xfffffff0, default_init, "Avance Logic (Realtek) ALC100/ALC100P, RL5383/RL5522" }, + { 0x414c4730, 0xffffffff, default_init, "Avance Logic (Realtek) ALC101" }, + { CODEC_ID_ALC201A, 0xffffffff, default_init, "Avance Logic (Realtek) ALC200/ALC200A, ALC201/ALC201A" }, /* 0x4710 = ALC201A */ + { 0x414c4720, 0xffffffff, alc650_init, "Avance Logic (Realtek) ALC650" }, /* 0x4720 = ALC650 */ + { 0x414c4740, 0xffffffff, default_init, "Avance Logic (Realtek) ALC202/ALC202A" }, + { 0x434d4941, 0xffffffff, default_init, "C-Media CMI9738" }, + { 0x434d4961, 0xffffffff, default_init, "C-Media CMI9739" }, + { 0x43525900, 0xffffffff, default_init, "Cirrus Logic CS4297" }, + { 0x43525903, 0xffffffff, default_init, "Cirrus Logic CS4297" }, + { 0x43525913, 0xffffffff, default_init, "Cirrus Logic CS4297A" }, + { 0x43525914, 0xffffffff, default_init, "Cirrus Logic CS4297B" }, + { 0x43525923, 0xffffffff, default_init, "Cirrus Logic CS4294C" }, + { 0x4352592b, 0xffffffff, default_init, "Cirrus Logic CS4298C" }, + { CODEC_ID_CS4299A, 0xffffffff, default_init, "Cirrus Logic CS4299A" }, + { CODEC_ID_CS4299C, 0xffffffff, default_init, "Cirrus Logic CS4299C" }, + { CODEC_ID_CS4299D, 0xffffffff, default_init, "Cirrus Logic CS4299D" }, + { 0x43525941, 0xffffffff, default_init, "Cirrus Logic CS4201A" }, + { 0x43525951, 0xffffffff, default_init, "Cirrus Logic CS4205A" }, + { 0x43525961, 0xffffffff, default_init, "Cirrus Logic CS4291A" }, + { 0x45838308, 0xffffffff, default_init, "ESS Technology ES1921" }, + { 0x49434511, 0xffffffff, default_init, "ICEnsemble ICE1232" }, + { 0x4e534331, 0xffffffff, default_init, "National Semiconductor LM4549" }, + { CODEC_ID_STAC9700,0xffffffff, default_init, "SigmaTel STAC9700/9783/9784" }, + { CODEC_ID_STAC9704,0xffffffff, default_init, "SigmaTel STAC9701/03, STAC9704/07, STAC9705 (???)" }, + { CODEC_ID_STAC9705,0xffffffff, default_init, "SigmaTel STAC9704 (???)" }, + { CODEC_ID_STAC9708,0xffffffff, stac9708_init, "SigmaTel STAC9708/9711" }, + { CODEC_ID_STAC9721,0xffffffff, stac9721_init, "SigmaTel STAC9721/9723" }, + { CODEC_ID_STAC9744,0xffffffff, stac9744_init, "SigmaTel STAC9744" }, + { CODEC_ID_STAC9752,0xffffffff, default_init, "SigmaTel STAC9752/53" }, + { CODEC_ID_STAC9756,0xffffffff, stac9756_init, "SigmaTel STAC9756/9757" }, + { CODEC_ID_STAC9766,0xffffffff, default_init, "SigmaTel STAC9766/67" }, + { 0x53494c22, 0xffffffff, default_init, "Silicon Laboratory Si3036" }, + { 0x53494c23, 0xffffffff, default_init, "Silicon Laboratory Si3038" }, + { 0x54524103, 0xffffffff, default_init, "TriTech TR?????" }, + { 0x54524106, 0xffffffff, default_init, "TriTech TR28026" }, + { 0x54524108, 0xffffffff, tr28028_init, "TriTech TR28028" }, + { 0x54524123, 0xffffffff, default_init, "TriTech TR28602" }, + { 0x574d4c00, 0xffffffff, wm9701_init, "Wolfson WM9701A" }, + { 0x574d4c03, 0xffffffff, wm9703_init, "Wolfson WM9703/9704" }, + { 0x574d4c04, 0xffffffff, wm9704_init, "Wolfson WM9704 (quad)" }, /* Vendors only: */ - { 0x41445300, 0xffffff00, &default_ops, "Analog Devices" }, - { 0x414b4d00, 0xffffff00, &default_ops, "Asahi Kasei" }, - { 0x414c4700, 0xffffff00, &default_ops, "Avance Logic (Realtek)" }, - { 0x43525900, 0xffffff00, &default_ops, "Cirrus Logic" }, - { 0x45838300, 0xffffff00, &default_ops, "ESS Technology" }, - { 0x49434500, 0xffffff00, &default_ops, "ICEnsemble" }, - { 0x4e534300, 0xffffff00, &default_ops, "National Semiconductor" }, - { 0x83847600, 0xffffff00, &default_ops, "SigmaTel" }, - { 0x53494c00, 0xffffff00, &default_ops, "Silicon Laboratory" }, - { 0x54524100, 0xffffff00, &default_ops, "TriTech" }, - { 0x574d4c00, 0xffffff00, &default_ops, "Wolfson" }, - { 0x00000000, 0x00000000, &default_ops, "Unknown" } /* must be last one, matches every codec */ + { 0x41445300, 0xffffff00, default_init, "Analog Devices" }, + { 0x414b4d00, 0xffffff00, default_init, "Asahi Kasei" }, + { 0x414c4700, 0xffffff00, default_init, "Avance Logic (Realtek)" }, + { 0x434d4900, 0xffffff00, default_init, "C-Media" }, + { 0x43525900, 0xffffff00, default_init, "Cirrus Logic" }, + { 0x45838300, 0xffffff00, default_init, "ESS Technology" }, + { 0x49434500, 0xffffff00, default_init, "ICEnsemble" }, + { 0x4e534300, 0xffffff00, default_init, "National Semiconductor" }, + { 0x83847600, 0xffffff00, default_init, "SigmaTel" }, + { 0x53494c00, 0xffffff00, default_init, "Silicon Laboratory" }, + { 0x54524100, 0xffffff00, default_init, "TriTech" }, + { 0x574d4c00, 0xffffff00, default_init, "Wolfson" }, + { 0x00000000, 0x00000000, default_init, "Unknown" } /* must be last one, matches every codec */ }; -static codec_table * +codec_table *find_codec_table(uint32 codecid); + +codec_table * find_codec_table(uint32 codecid) { codec_table *codec; @@ -187,128 +193,761 @@ return codec; } -const char * -ac97_get_3d_stereo_enhancement(device_config *config) +void +ac97_attach(ac97_dev **_dev, codec_reg_read reg_read, codec_reg_write reg_write, void *cookie, + ushort subvendor_id, ushort subsystem_id) { - uint16 data; - data = auich_codec_read(config, AC97_RESET); - data = (data >> 10) & 31; - return stereo_enhancement_technique[data]; + ac97_dev *dev; + codec_table *codec; + + *_dev = dev = (ac97_dev *) malloc(sizeof(ac97_dev)); + dev->cookie = cookie; + dev->reg_read = reg_read; + dev->reg_write = reg_write; + dev->codec_id = (reg_read(cookie, AC97_VENDOR_ID1) << 16) | reg_read(cookie, AC97_VENDOR_ID2); + codec = find_codec_table(dev->codec_id); + dev->codec_info = codec->info; + dev->init = codec->init; + dev->set_rate = 0; + dev->get_rate = 0; + dev->clock = 48000; /* default clock on non-broken motherboards */ + dev->min_vsr = 0x0001; + dev->max_vsr = 0xffff; + dev->reversed_eamp_polarity = false; + dev->subsystem = (subvendor_id << 16) | subsystem_id; + + if (dev->subsystem == 0x161f202f + || dev->subsystem == 0x161f203a + || dev->subsystem == 0x161f204c + || dev->subsystem == 0x104d8144 + || dev->subsystem == 0x104d8197 + || dev->subsystem == 0x104d81c0 + || dev->subsystem == 0x104d81c5 + || dev->subsystem == 0x103c3089 + || dev->subsystem == 0x103c309a + || dev->subsystem == 0x10338213 + || dev->subsystem == 0x103382be) { + dev->reversed_eamp_polarity = true; + } + + /* reset the codec */ + LOG(("codec reset\n")); + ac97_reg_uncached_write(dev, AC97_RESET, 0x0000); + snooze(50000); // 50 ms + + /* setup register cache */ + ac97_update_register_cache(dev); + + dev->codec_3d_stereo_enhancement = stereo_enhancement_technique[(ac97_reg_cached_read(dev, AC97_RESET) >> 10) & 31]; + dev->capabilities = 0; + + ac97_reg_update_bits(dev, AC97_EXTENDED_STAT_CTRL, 1, 1); // enable variable rate audio + + ac97_detect_capabilities(dev); + + dev->init(dev); + ac97_amp_enable(dev, true); + + /* set mixer defaults, enabled Line-out sources are PCM-out, CD-in, Line-in */ + ac97_reg_update(dev, AC97_CENTER_LFE_VOLUME, 0x0000); /* set LFE & center volume 0dB */ + ac97_reg_update(dev, AC97_SURR_VOLUME, 0x0000); /* set surround volume 0dB */ + ac97_reg_update(dev, AC97_MASTER_VOLUME, 0x0000); /* set master output 0dB */ + ac97_reg_update(dev, AC97_AUX_OUT_VOLUME, 0x0000); /* set aux output 0dB */ + ac97_reg_update(dev, AC97_MONO_VOLUME, 0x0000); /* set mono output 0dB */ + ac97_reg_update(dev, AC97_PCM_OUT_VOLUME, 0x0808); /* enable pcm-out */ + ac97_reg_update(dev, AC97_CD_VOLUME, 0x0808); /* enable cd-in */ + ac97_reg_update(dev, AC97_LINE_IN_VOLUME, 0x0808); /* enable line-in */ + + /* set record line in */ + ac97_reg_update(dev, AC97_RECORD_SELECT, 0x0404); + + ac97_dump_capabilities(dev); } -const char * -ac97_get_vendor_id_description(device_config *config) +void +ac97_detach(ac97_dev *dev) { - uint32 id = ac97_get_vendor_id(config); - codec_table *codec = find_codec_table(id); - char f = (id >> 24) & 0xff; - char s = (id >> 16) & 0xff; - char t = (id >> 8) & 0xff; - if (f == 0) f = '?'; - if (s == 0) s = '?'; - if (t == 0) t = '?'; - LOG(("codec %c%c%c %u\n",f,s,t,id & 0xff)); - LOG(("info: %s\n",codec->info)); - return codec->info; + /* Mute everything */ + ac97_reg_update_bits(dev, AC97_CENTER_LFE_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_SURR_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_MASTER_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_AUX_OUT_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_MONO_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_PCM_OUT_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_CD_VOLUME, 0x8000, 0x8000); + ac97_reg_update_bits(dev, AC97_LINE_IN_VOLUME, 0x8000, 0x8000); + + ac97_amp_enable(dev, false); + + free(dev); } -uint32 -ac97_get_vendor_id(device_config *config) +void +ac97_suspend(ac97_dev *dev) { - uint16 data1; - uint16 data2; - data1 = auich_codec_read(config, AC97_VENDOR_ID1); - data2 = auich_codec_read(config, AC97_VENDOR_ID2); - return (((uint32)data1) << 16) | data2; + ac97_amp_enable(dev, false); } void -ac97_amp_enable(device_config *config, bool yesno) +ac97_resume(ac97_dev *dev) { - codec_table *codec; - LOG(("ac97_amp_enable\n")); - codec = find_codec_table(ac97_get_vendor_id(config)); - codec->ops->amp_enable(config, yesno); + ac97_amp_enable(dev, true); } void -ac97_init(device_config *config) +ac97_reg_cached_write(ac97_dev *dev, uint8 reg, uint16 value) { - codec_table *codec; - LOG(("ac97_init\n")); - codec = find_codec_table(ac97_get_vendor_id(config)); - codec->ops->init(config); + if (!ac97_reg_is_valid(dev, reg)) + return; + dev->reg_write(dev->cookie, reg, value); + dev->reg_cache[reg] = value; +} + +uint16 +ac97_reg_cached_read(ac97_dev *dev, uint8 reg) +{ + if (!ac97_reg_is_valid(dev, reg)) + return 0; + return dev->reg_cache[reg]; +} + +void +ac97_reg_uncached_write(ac97_dev *dev, uint8 reg, uint16 value) +{ + if (!ac97_reg_is_valid(dev, reg)) + return; + dev->reg_write(dev->cookie, reg, value); +} + +uint16 +ac97_reg_uncached_read(ac97_dev *dev, uint8 reg) +{ + if (!ac97_reg_is_valid(dev, reg)) + return 0; + return dev->reg_read(dev->cookie, reg); +} + +bool +ac97_reg_update(ac97_dev *dev, uint8 reg, uint16 value) +{ + if (!ac97_reg_is_valid(dev, reg)) + return false; + if (ac97_reg_cached_read(dev, reg) == value) + return false; + ac97_reg_cached_write(dev, reg, value); + return true; +} + +bool +ac97_reg_update_bits(ac97_dev *dev, uint8 reg, uint16 mask, uint16 value) +{ + uint16 old; + if (!ac97_reg_is_valid(dev, reg)) + return false; + old = ac97_reg_cached_read(dev, reg); + value &= mask; + value |= (old & ~mask); + if (old == value) + return false; + ac97_reg_cached_write(dev, reg, value); + return true; +} + +void +ac97_update_register_cache(ac97_dev *dev) +{ + int reg; + for (reg = 0; reg <= 0x7e; reg += 2) + dev->reg_cache[reg] = ac97_reg_uncached_read(dev, reg); +} + +bool +ac97_set_rate(ac97_dev *dev, uint8 reg, uint32 rate) +{ + uint32 value; + uint32 old; - auich_codec_write(config, AC97_EXTENDED_AUDIO_STATUS, - auich_codec_read(config, AC97_EXTENDED_AUDIO_STATUS) | 1); + if (dev->set_rate) + return dev->set_rate(dev, reg, rate); + + value = (uint32)((rate * 48000ULL) / dev->clock); /* need 64 bit calculation for rates 96000 or higher */ + + LOG(("ac97_set_rate: clock = %d, rate = %d, value = %d\n", dev->clock, rate, value)); + + /* if double rate audio is currently enabled, divide value by 2 */ + if (ac97_reg_cached_read(dev, AC97_EXTENDED_STAT_CTRL) & 0x0002) + value /= 2; + if (value < dev->min_vsr || value > dev->max_vsr) + return false; + + old = ac97_reg_cached_read(dev, reg); + ac97_reg_cached_write(dev, reg, value); + if (value != ac97_reg_uncached_read(dev, reg)) { + LOG(("ac97_set_rate failed, new rate %d\n", ac97_reg_uncached_read(dev, reg))); + ac97_reg_cached_write(dev, reg, old); + return false; + } + LOG(("ac97_set_rate done\n")); + return true; } -void default_init(device_config *config) +bool +ac97_get_rate(ac97_dev *dev, uint8 reg, uint32 *rate) { + uint32 value; + + if (dev->get_rate) + return dev->get_rate(dev, reg, rate); + + value = ac97_reg_cached_read(dev, reg); + if (value == 0) + return false; + + /* if double rate audio is currently enabled, multiply value by 2 */ + if (ac97_reg_cached_read(dev, AC97_EXTENDED_STAT_CTRL) & 0x0002) + value *= 2; + + *rate = (uint32)((value * (uint64)dev->clock) / 48000); /* need 64 bit calculation to avoid overflow*/ + return true; +} + +void +ac97_set_clock(ac97_dev *dev, uint32 clock) +{ + LOG(("ac97_set_clock: clock = %d\n", clock)); + dev->clock = clock; + ac97_detect_rates(dev); + ac97_dump_capabilities(dev); +} + +void +ac97_detect_capabilities(ac97_dev *dev) +{ + uint16 val; + + val = ac97_reg_cached_read(dev, AC97_RESET); + if (val & 0x0001) + dev->capabilities |= CAP_PCM_MIC; + if (val & 0x0004) + dev->capabilities |= CAP_BASS_TREBLE_CTRL; + if (val & 0x0008) + dev->capabilities |= CAP_SIMULATED_STEREO; + if (val & 0x0010) + dev->capabilities |= CAP_HEADPHONE_OUT; + if (val & 0x0020) + dev->capabilities |= CAP_LAUDNESS; + if (val & 0x0040) + dev->capabilities |= CAP_DAC_18BIT; + if (val & 0x0080) + dev->capabilities |= CAP_DAC_20BIT; + if (val & 0x0100) + dev->capabilities |= CAP_ADC_18BIT; + if (val & 0x0200) + dev->capabilities |= CAP_ADC_20BIT; + if (val & 0x7C00) + dev->capabilities |= CAP_3D_ENHANCEMENT; + + val = ac97_reg_cached_read(dev, AC97_EXTENDED_ID); + if (val & EXID_VRA) + dev->capabilities |= CAP_VARIABLE_PCM; + if (val & EXID_DRA) + dev->capabilities |= CAP_DOUBLE_PCM; + if (val & EXID_SPDIF) + dev->capabilities |= CAP_SPDIF; + if (val & EXID_VRM) + dev->capabilities |= CAP_VARIABLE_MIC; + if (val & EXID_CDAC) + dev->capabilities |= CAP_CENTER_DAC; + if (val & EXID_SDAC) + dev->capabilities |= CAP_SURR_DAC; + if (val & EXID_LDAC) + dev->capabilities |= CAP_LFE_DAC; + if (val & EXID_AMAP) + dev->capabilities |= CAP_AMAP; + if ((val & (EXID_REV0 | EXID_REV1)) == 0) + dev->capabilities |= CAP_REV21; + if ((val & (EXID_REV0 | EXID_REV1)) == EXID_REV0) + dev->capabilities |= CAP_REV22; + if ((val & (EXID_REV0 | EXID_REV1)) == EXID_REV1) + dev->capabilities |= CAP_REV23; + + ac97_detect_rates(dev); +} + +void +ac97_detect_rates(ac97_dev *dev) +{ + uint32 oldrate; + + dev->capabilities &= ~CAP_PCM_RATE_MASK; + + if (!ac97_get_rate(dev, AC97_PCM_FRONT_DAC_RATE, &oldrate)) + oldrate = 48000; + + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 20000)) + dev->capabilities |= CAP_PCM_RATE_CONTINUOUS; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 8000)) + dev->capabilities |= CAP_PCM_RATE_8000; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 11025)) + dev->capabilities |= CAP_PCM_RATE_11025; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 12000)) + dev->capabilities |= CAP_PCM_RATE_12000; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 16000)) + dev->capabilities |= CAP_PCM_RATE_16000; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 22050)) + dev->capabilities |= CAP_PCM_RATE_22050; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 24000)) + dev->capabilities |= CAP_PCM_RATE_24000; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 32000)) + dev->capabilities |= CAP_PCM_RATE_32000; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 44100)) + dev->capabilities |= CAP_PCM_RATE_44100; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 48000)) + dev->capabilities |= CAP_PCM_RATE_48000; + + if (dev->capabilities & CAP_DOUBLE_PCM) { + // enable double rate mode + if (ac97_reg_update_bits(dev, AC97_EXTENDED_STAT_CTRL, 0x0002, 0x0002)) { + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 88200)) + dev->capabilities |= CAP_PCM_RATE_88200; + if (ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 96000)) + dev->capabilities |= CAP_PCM_RATE_96000; + // disable double rate mode + ac97_reg_update_bits(dev, AC97_EXTENDED_STAT_CTRL, 0x0002, 0x0000); + } + } + + ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, oldrate); +} + +void +ac97_dump_capabilities(ac97_dev *dev) +{ + LOG(("AC97 capabilities:\n")); + if (ac97_has_capability(dev, CAP_PCM_MIC)) + LOG(("CAP_PCM_MIC\n")); + if (ac97_has_capability(dev, CAP_BASS_TREBLE_CTRL)) + LOG(("CAP_BASS_TREBLE_CTRL\n")); + if (ac97_has_capability(dev, CAP_SIMULATED_STEREO)) + LOG(("CAP_SIMULATED_STEREO\n")); + if (ac97_has_capability(dev, CAP_HEADPHONE_OUT)) + LOG(("CAP_HEADPHONE_OUT\n")); + if (ac97_has_capability(dev, CAP_LAUDNESS)) + LOG(("CAP_LAUDNESS\n")); + if (ac97_has_capability(dev, CAP_DAC_18BIT)) + LOG(("CAP_DAC_18BIT\n")); + if (ac97_has_capability(dev, CAP_DAC_20BIT)) + LOG(("CAP_DAC_20BIT\n")); + if (ac97_has_capability(dev, CAP_ADC_18BIT)) + LOG(("CAP_ADC_18BIT\n")); + if (ac97_has_capability(dev, CAP_ADC_20BIT)) + LOG(("CAP_ADC_20BIT\n")); + if (ac97_has_capability(dev, CAP_3D_ENHANCEMENT)) + LOG(("CAP_3D_ENHANCEMENT\n")); + if (ac97_has_capability(dev, CAP_VARIABLE_PCM)) + LOG(("CAP_VARIABLE_PCM\n")); + if (ac97_has_capability(dev, CAP_DOUBLE_PCM)) + LOG(("CAP_DOUBLE_PCM\n")); + if (ac97_has_capability(dev, CAP_VARIABLE_MIC)) + LOG(("CAP_VARIABLE_MIC\n")); + if (ac97_has_capability(dev, CAP_CENTER_DAC)) + LOG(("CAP_CENTER_DAC\n")); + if (ac97_has_capability(dev, CAP_SURR_DAC)) + LOG(("CAP_SURR_DAC\n")); + if (ac97_has_capability(dev, CAP_LFE_DAC)) + LOG(("CAP_LFE_DAC\n")); + if (ac97_has_capability(dev, CAP_AMAP)) + LOG(("CAP_AMAP\n")); + if (ac97_has_capability(dev, CAP_REV21)) + LOG(("CAP_REV21\n")); + if (ac97_has_capability(dev, CAP_REV22)) + LOG(("CAP_REV22\n")); + if (ac97_has_capability(dev, CAP_REV23)) + LOG(("CAP_REV23\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_CONTINUOUS)) + LOG(("CAP_PCM_RATE_CONTINUOUS\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_8000)) + LOG(("CAP_PCM_RATE_8000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_11025)) + LOG(("CAP_PCM_RATE_11025\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_12000)) + LOG(("CAP_PCM_RATE_12000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_16000)) + LOG(("CAP_PCM_RATE_16000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_22050)) + LOG(("CAP_PCM_RATE_22050\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_24000)) + LOG(("CAP_PCM_RATE_24000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_32000)) + LOG(("CAP_PCM_RATE_32000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_44100)) + LOG(("CAP_PCM_RATE_44100\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_48000)) + LOG(("CAP_PCM_RATE_48000\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_88200)) + LOG(("CAP_PCM_RATE_88200\n")); + if (ac97_has_capability(dev, CAP_PCM_RATE_96000)) + LOG(("CAP_PCM_RATE_96000\n")); +} + +bool +ac97_has_capability(ac97_dev *dev, uint64 cap) +{ + // return (dev->capabilities & cap); // does not work because of 64 bit to integer trucation + return (dev->capabilities & cap) != 0; +} + +/************************************************* + * Codec specific initialization, etc. + */ + +bool +ac97_reg_is_valid(ac97_dev *dev, uint8 reg) +{ + if (reg & 1) + return false; + if (reg > 0x7e) + return false; + + switch (dev->codec_id) { + case CODEC_ID_AK4540: + case CODEC_ID_AK4542: + if (reg < 0x1e || reg == 0x20 || reg == 0x26 || reg > 0x7a) + return true; + return false; + + case CODEC_ID_AD1819: + case CODEC_ID_AD1881: + case CODEC_ID_AD1881A: + if (reg < 0x3a || reg > 0x6e) + return true; + return false; + + case CODEC_ID_AD1885: + case CODEC_ID_AD1886: + case CODEC_ID_AD1886A: + case CODEC_ID_AD1887: + if (reg < 0x3c || reg == 0x5a || reg > 0x6e) + return true; + return false; + + case CODEC_ID_STAC9700: + case CODEC_ID_STAC9704: + case CODEC_ID_STAC9705: + case CODEC_ID_STAC9708: + case CODEC_ID_STAC9721: + case CODEC_ID_STAC9744: + case CODEC_ID_STAC9756: + if (reg < 0x3c || reg > 0x58) + return true; + return false; + + default: + return true; + } +} + +void ac97_amp_enable(ac97_dev *dev, bool yesno) +{ + switch (dev->codec_id) { + case CODEC_ID_CS4299A: + case CODEC_ID_CS4299C: + case CODEC_ID_CS4299D: + LOG(("cs4299_amp_enable\n")); + if (yesno) + ac97_reg_cached_write(dev, 0x68, 0x8004); + else + ac97_reg_cached_write(dev, 0x68, 0); + break; + + default: + LOG(("ac97_amp_enable, reverse eamp = %d\n", dev->reversed_eamp_polarity)); + LOG(("powerdown register was = %#04x\n", ac97_reg_uncached_read(dev, AC97_POWERDOWN))); + if (dev->reversed_eamp_polarity) + yesno = !yesno; + if (yesno) + ac97_reg_cached_write(dev, AC97_POWERDOWN, ac97_reg_uncached_read(dev, AC97_POWERDOWN) & ~0x8000); /* switch on (low active) */ + else + ac97_reg_cached_write(dev, AC97_POWERDOWN, ac97_reg_uncached_read(dev, AC97_POWERDOWN) | 0x8000); /* switch off */ + LOG(("powerdown register is = %#04x\n", ac97_reg_uncached_read(dev, AC97_POWERDOWN))); + break; + } +} + +bool +ad1819_set_rate(ac97_dev *dev, uint8 reg, uint32 rate) +{ + uint32 value; + + value = (uint32)((rate * 48000ULL) / dev->clock); /* need 64 bit calculation for rates 96000 or higher */ + + LOG(("ad1819_set_rate: clock = %d, rate = %d, value = %d\n", dev->clock, rate, value)); + + if (value < 0x1B58 || value > 0xBB80) + return false; + + switch (reg) { + case AC97_PCM_FRONT_DAC_RATE: + ac97_reg_cached_write(dev, AC97_AD_SAMPLE_RATE_0, value); + return true; + + case AC97_PCM_L_R_ADC_RATE: + ac97_reg_cached_write(dev, AC97_AD_SAMPLE_RATE_1, value); + return true; + + default: + return false; + } +} + +bool +ad1819_get_rate(ac97_dev *dev, uint8 reg, uint32 *rate) +{ + uint32 value; + + switch (reg) { + case AC97_PCM_FRONT_DAC_RATE: + value = ac97_reg_cached_read(dev, AC97_AD_SAMPLE_RATE_0); + break; + + case AC97_PCM_L_R_ADC_RATE: + value = ac97_reg_cached_read(dev, AC97_AD_SAMPLE_RATE_1); + break; + + default: + return false; + } + + *rate = (uint32)((value * (uint64)dev->clock) / 48000); /* need 64 bit calculation to avoid overflow*/ + return true; +} + + +void default_init(ac97_dev *dev) +{ LOG(("default_init\n")); } -void ad1886_init(device_config *config) +void ad1819_init(ac97_dev *dev) { + LOG(("ad1819_init\n")); + + /* Default config for system with single AD1819 codec */ + ac97_reg_cached_write(dev, AC97_AD_SERIAL_CONFIG, 0x7000); + ac97_update_register_cache(dev); + + /* The AD1819 chip has proprietary sample rate controls + * Setup sample rate 0 generator for DAC, + * Setup sample rate 1 generator for ADC, + * ARSR=1, DRSR=0, ALSR=1, DLSR=0 + */ + ac97_reg_cached_write(dev, AC97_AD_MISC_CONTROL, 0x0101); + /* connect special rate set/get functions */ + dev->set_rate = ad1819_set_rate; + dev->get_rate = ad1819_get_rate; + ac97_detect_rates(dev); + ac97_set_rate(dev, AC97_PCM_FRONT_DAC_RATE, 48000); + ac97_set_rate(dev, AC97_PCM_L_R_ADC_RATE, 48000); +} + +void ad1881_init(ac97_dev *dev) +{ + LOG(("ad1881_init\n")); + + /* Default config for system with single AD1819 codec, + * BROKEN on systems with master & slave codecs */ + ac97_reg_cached_write(dev, AC97_AD_SERIAL_CONFIG, 0x7000); + ac97_update_register_cache(dev); + + /* Setup DAC and ADC rate generator assignments compatible with AC97 */ + ac97_reg_cached_write(dev, AC97_AD_MISC_CONTROL, 0x0404); + + /* Setup variable frame rate limits */ + dev->min_vsr = 0x1B58; /* 7kHz */ + dev->max_vsr = 0xBB80; /* 48kHz */ +} + +void ad1885_init(ac97_dev *dev) +{ + LOG(("ad1885_init\n")); + ad1881_init(dev); + + /* disable jack sense 0 and 1 (JS0, JS1) to turn off automatic mute */ + ac97_reg_cached_write(dev, AC97_AD_JACK_SENSE, ac97_reg_cached_read(dev, AC97_AD_JACK_SENSE) | 0x0300); +} + +void ad1886_init(ac97_dev *dev) +{ LOG(("ad1886_init\n")); - auich_codec_write(config, AC97_AD_JACKSENSE, 0x0010); + ad1881_init(dev); + + /* change jack sense to always activate outputs*/ + ac97_reg_cached_write(dev, AC97_AD_JACK_SENSE, 0x0010); + /* change SPDIF to a valid value */ + ac97_reg_cached_write(dev, AC97_SPDIF_CONTROL, 0x2a20); } -void ad1981b_init(device_config *config) +void ad1980_init(ac97_dev *dev) { - uint32 id; + LOG(("ad1980_init\n")); + + /* Select only master codec, + * SPDIF and DAC are linked + */ + ac97_reg_cached_write(dev, AC97_AD_SERIAL_CONFIG, 0x1001); + ac97_update_register_cache(dev); + + /* Select Line-out driven with mixer data (not surround data) + * Select Headphone-out driven with mixer data (not surround data), + * LOSEL = 0, HPSEL = 1 + * XXX this one needs to be changed to support surround out + */ + ac97_reg_cached_write(dev, AC97_AD_MISC_CONTROL, 0x0400); +} + +void ad1981b_init(ac97_dev *dev) +{ LOG(("ad1981b_init\n")); - id = (config->subvendor_id << 16) | config->subsystem_id; - if (id == 0x103c0934 - || id == 0x103c006d - || id == 0x103c088c - || id == 0x103c0890 - || id == 0x103c0934 - || id == 0x103c0938 - || id == 0x103c0944 - || id == 0x103c099c) { - auich_codec_write(config, AC97_AD_JACKSENSE, - auich_codec_read(config, AC97_AD_JACKSENSE) | 0x0800); + if (dev->subsystem == 0x103c0934 + || dev->subsystem == 0x103c006d + || dev->subsystem == 0x103c088c + || dev->subsystem == 0x103c0890 + || dev->subsystem == 0x103c0934 + || dev->subsystem == 0x103c0938 + || dev->subsystem == 0x103c0944 + || dev->subsystem == 0x103c099c + || dev->subsystem == 0x101402d9) { + ac97_reg_cached_write(dev, AC97_AD_JACK_SENSE, + ac97_reg_cached_read(dev, AC97_AD_JACK_SENSE) | 0x0800); } } -void default_amp_enable(device_config *config, bool yesno) +void alc650_init(ac97_dev *dev) { - uint32 id; - LOG(("default_amp_enable\n")); - LOG(("powerdown register was = %#04x\n",auich_codec_read(config, AC97_POWERDOWN))); - id = (config->subvendor_id << 16) | config->subsystem_id; - if (id == 0x161f202f - || id == 0x161f203a - || id == 0x161f204c - || id == 0x104d8144 - || id == 0x104d8197 - || id == 0x104d81c0 - || id == 0x104d81c5 - || id == 0x103c3089 - || id == 0x103c309a - || id == 0x10338213 - || id == 0x103382be) { - yesno = !yesno; - LOG(("using reverse eamp polarity\n")); - } - if (yesno) - auich_codec_write(config, AC97_POWERDOWN, auich_codec_read(config, AC97_POWERDOWN) & ~0x8000); /* switch on (low active) */ - else - auich_codec_write(config, AC97_POWERDOWN, auich_codec_read(config, AC97_POWERDOWN) | 0x8000); /* switch off */ - LOG(("powerdown register is = %#04x\n", auich_codec_read(config, AC97_POWERDOWN))); + LOG(("alc650_init\n")); + + /* Enable Surround, LFE and Center downmix into Line-out, + * Set Surround-out as duplicated Line-out. + */ + ac97_reg_cached_write(dev, AC97_ALC650_MULTI_CHAN_CTRL, 0x0007); + + /* Set Surround DAC Volume to 0dB + * Set Center/LFE DAC Volume to 0dB + * (but both should already be set, as these are hardware reset defaults) + */ + ac97_reg_cached_write(dev, AC97_ALC650_SURR_VOLUME, 0x0808); + ac97_reg_cached_write(dev, AC97_ALC650_CEN_LFE_VOLUME, 0x0808); } -void cs4299_amp_enable(device_config *config, bool yesno) +void stac9708_init(ac97_dev *dev) { - LOG(("cs4299_amp_enable\n")); - if (yesno) - auich_codec_write(config, 0x68, 0x8004); - else - auich_codec_write(config, 0x68, 0); + LOG(("stac9708_init\n")); + /* ALSA initializes some registers that according to the + * documentation for this codec do not exist. If the + * following doesn't work, we may need to do that, too. + */ + /* The Analog Special reg is at 0x6C, other codecs have it at 0x6E */ + /* Set Analog Special to default (DAC/ADC -6dB disabled) */ + ac97_reg_cached_write(dev, 0x6C, 0x0000); + /* Set Multi Channel to default */ + ac97_reg_cached_write(dev, 0x74, 0x0000); [... truncated: 599 lines follow ...] From axeld at mail.berlios.de Wed May 14 22:05:41 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 14 May 2008 22:05:41 +0200 Subject: [Haiku-commits] r25498 - haiku/trunk/src/tests/system/kernel/device_manager/playground Message-ID: <200805142005.m4EK5fJH021335@sheep.berlios.de> Author: axeld Date: 2008-05-14 22:05:40 +0200 (Wed, 14 May 2008) New Revision: 25498 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25498&view=rev Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.h haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp Log: Work in progress: * added [un]publish_device() calls to the device manager. * added a very basic devfs emulation to the playground to be able to test how the manager reacts to opened devices. * renamed *_device() functions to *_node() in the device manager API. * made B_DEVICE_FIND_CHILD_FLAGS a generic flags field, and renamed it to B_DEVICE_FLAGS. * added support for keeping a driver loaded as long as its device is available. * implemented get_next_child_node(). * added test for device removal, and implemented unregister_node() for this. * fixed some bugs in the device node reference/initialization count maintenance. * moved more code from register_node() to device_node::Register(). * initialize the device_node::fFlags member to the value of B_DEVICE_FLAGS, and have additional private flags. * renamed UninitUnusedChildren() to UninitUnusedDriver(), and fixed this function by adding the new flag NODE_FLAG_REGISTER_INITIALIZED. * Now remembers the support when a driver is registered - this will be used later to be able to compare with a new driver without having to call supports_device() again. * Removed NODE_FLAG_REMOVE_ON_UNINIT again, as that was pretty stupid - there is reference counting for a reason. Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-14 20:03:29 UTC (rev 25497) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-14 20:05:40 UTC (rev 25498) @@ -10,9 +10,29 @@ #include -#define BUS_MODULE_NAME "bus_managers/sample_bus/driver_v1" +void +bus_trigger_device_removed(device_node* node) +{ + // the network device + device_attr attrs[] = { + {B_DEVICE_VENDOR_ID, B_UINT16_TYPE, {ui16: 0x1001}}, + {B_DEVICE_ID, B_UINT16_TYPE, {ui16: 0x0001}}, + {NULL} + }; + device_node* child = NULL; + while (gDeviceManager->get_next_child_node(node, attrs, &child) == B_OK) { + gDeviceManager->unregister_node(child); + } +} + +void +bus_trigger_device_added(device_node* node) +{ +} + + // #pragma mark - bus @@ -40,7 +60,7 @@ {NULL} }; - return gDeviceManager->register_device(parent, BUS_MODULE_NAME, attrs, NULL, + return gDeviceManager->register_node(parent, BUS_MODULE_NAME, attrs, NULL, NULL); } @@ -90,12 +110,11 @@ {B_DEVICE_INTERFACE, B_UINT16_TYPE, {ui16: kDevices[i].interface}}, - {B_DEVICE_FIND_CHILD_FLAGS, B_UINT32_TYPE, - {ui32: B_FIND_CHILD_ON_DEMAND}}, + {B_DEVICE_FLAGS, B_UINT32_TYPE, {ui32: B_FIND_CHILD_ON_DEMAND}}, {NULL} }; - gDeviceManager->register_device(node, BUS_FOR_DRIVER_NAME, attrs, NULL, + gDeviceManager->register_node(node, BUS_FOR_DRIVER_NAME, attrs, NULL, NULL); } @@ -107,7 +126,7 @@ #if 1 // this is supposed to fail - dprintf("non-existing child: %ld\n", gDeviceManager->register_device(node, + dprintf("non-existing child: %ld\n", gDeviceManager->register_node(node, BUS_FOR_DRIVER_NAME, attrs, NULL, NULL)); #endif return B_OK; Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.h =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.h 2008-05-14 20:03:29 UTC (rev 25497) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.h 2008-05-14 20:05:40 UTC (rev 25498) @@ -20,7 +20,14 @@ status_t (*get_bus_info)(void* cookie, bus_info* info); }; +// Note: this file is also used by the device manager test to control the bus +// driver + +#define BUS_MODULE_NAME "bus_managers/sample_bus/driver_v1" #define BUS_FOR_DRIVER_NAME "bus_managers/sample_bus/device/driver_v1" #define BUS_NAME "mybus" +extern void bus_trigger_device_removed(device_node* node); +extern void bus_trigger_device_added(device_node* node); + #endif // BUS_H Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-14 20:03:29 UTC (rev 25497) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-14 20:05:40 UTC (rev 25498) @@ -22,6 +22,7 @@ #include #include +#include "bus.h" #define TRACE(a) dprintf a @@ -69,7 +70,6 @@ typedef DoublyLinkedList AttributeList; - // I/O resource typedef struct io_resource_info { struct io_resource_info *prev, *next; @@ -77,13 +77,20 @@ io_resource resource; // info about actual resource } io_resource_info; +struct device : DoublyLinkedListLinkImpl { + device() : node(NULL), path(NULL), module_name(NULL) {} + ~device() + { + free((char*)path); + free((char*)module_name); + } -// a structure to put nodes into lists -struct node_entry { - struct list_link link; device_node* node; + const char* path; + const char* module_name; }; +typedef DoublyLinkedList DeviceList; typedef DoublyLinkedList NodeList; struct device_node : DoublyLinkedListLinkImpl { @@ -101,6 +108,7 @@ status_t InitDriver(); bool UninitDriver(); + void UninitUnusedDriver(); // The following two are only valid, if the node's driver is // initialized @@ -110,9 +118,9 @@ void AddChild(device_node *node); void RemoveChild(device_node *node); const NodeList& Children() const { return fChildren; } - void UninitUnusedChildren(); + void DeviceRemoved(); - status_t Register(); + status_t Register(device_node* parent); status_t Probe(const char* devicePath); bool IsRegistered() const { return fRegistered; } bool IsInitialized() const { return fInitialized > 0; } @@ -122,6 +130,7 @@ int CompareTo(const device_attr* attributes) const; device_node* FindChild(const device_attr* attributes) const; + device_node* FindChild(const char* moduleName) const; void Dump(int32 level = 0); @@ -139,7 +148,6 @@ status_t _RegisterPath(const char* path); status_t _RegisterDynamic(); status_t _RemoveChildren(); - bool _UninitUnusedChildren(); device_node* fParent; NodeList fChildren; @@ -147,16 +155,21 @@ int32 fInitialized; bool fRegistered; uint32 fFlags; + float fSupportsParent; const char* fModuleName; + driver_module_info* fDriver; void* fDriverData; AttributeList fAttributes; }; +// flags in addition to those specified by B_DEVICE_FLAGS enum node_flags { - NODE_FLAG_REMOVE_ON_UNINIT = 0x01 + NODE_FLAG_REGISTER_INITIALIZED = 0x00010000, + + NODE_FLAG_PUBLIC_MASK = 0x0000ffff }; device_manager_info *gDeviceManager; @@ -164,7 +177,10 @@ static device_node *sRootNode; static recursive_lock sLock; +static DeviceList sDeviceList; + // this is a *very* basic devfs emulation + // #pragma mark - device_attr @@ -376,19 +392,51 @@ static void uninit_unused() { + puts("uninit unused"); RecursiveLocker _(sLock); - sRootNode->UninitUnusedChildren(); + sRootNode->UninitUnusedDriver(); } static status_t probe_path(const char* path) { + printf("probe path \"%s\"\n", path); RecursiveLocker _(sLock); return sRootNode->Probe(path); } +static void +close_path(void* cookie) +{ + struct device* device = (struct device*)cookie; + + printf("close path \"%s\" (node %p)\n", device->path, device->node); + device->node->UninitDriver(); +} + + +static void* +open_path(const char* path) +{ + DeviceList::Iterator iterator = sDeviceList.GetIterator(); + while (iterator.HasNext()) { + struct device* device = iterator.Next(); + if (!strcmp(device->path, path)) { + status_t status = device->node->InitDriver(); + if (status != B_OK) + return NULL; + + printf("open path \"%s\" (node %p)\n", device->path, device->node); + return device; + } + } + + return NULL; +} + + // #pragma mark - device_node @@ -406,6 +454,8 @@ fRefCount = 1; fInitialized = 0; fRegistered = false; + fFlags = 0; + fSupportsParent = 0.0; fDriver = NULL; fDriverData = NULL; @@ -420,13 +470,20 @@ fAttributes.Add(attr); attrs++; } + + dm_get_attr_uint32(this, B_DEVICE_FLAGS, &fFlags, false); + fFlags &= NODE_FLAG_PUBLIC_MASK; } device_node::~device_node() { TRACE(("delete node %p\n", this)); + ASSERT(DriverModule() == NULL); + if (Parent() != NULL) + Parent()->RemoveChild(this); + // Delete children NodeList::Iterator nodeIterator = fChildren.GetIterator(); while (nodeIterator.HasNext()) { @@ -468,7 +525,7 @@ status_t status = get_module(ModuleName(), (module_info**)&fDriver); if (status == B_OK && Parent() != NULL) { - // our parent always have to be initialized + // our parent always has to be initialized status = Parent()->InitDriver(); } if (status < B_OK) { @@ -480,6 +537,8 @@ status = fDriver->init_driver(this, &fDriverData); if (status < B_OK) { + if (Parent() != NULL) + Parent()->UninitDriver(); fInitialized--; put_module(ModuleName()); @@ -497,9 +556,12 @@ device_node::UninitDriver() { if (fInitialized-- > 1) { + if (Parent() != NULL) + Parent()->UninitDriver(); Release(); return false; } + TRACE(("uninit driver for node %p\n", this)); if (fDriver->uninit_driver != NULL) @@ -510,13 +572,10 @@ put_module(ModuleName()); - Release(); if (Parent() != NULL) Parent()->UninitDriver(); + Release(); - if ((fFlags & NODE_FLAG_REMOVE_ON_UNINIT) != 0) - Release(); - return true; } @@ -540,13 +599,38 @@ } +/*! Registers this node, and all of its children that have to be registered. + Also initializes the driver and keeps it that way on return in case + it returns successfully. +*/ status_t -device_node::Register() +device_node::Register(device_node* parent) { - uint32 registered; - status_t status = _RegisterFixed(registered); + // make it public + if (parent != NULL) + parent->AddChild(this); + else + sRootNode = this; + + status_t status = InitDriver(); if (status != B_OK) return status; + + if ((fFlags & B_KEEP_DRIVER_LOADED) != 0) { + // We keep this driver loaded by having it always initialized + InitDriver(); + } + + fFlags |= NODE_FLAG_REGISTER_INITIALIZED; + // We don't uninitialize the driver - this is done by the caller + // in order to save reinitializing during driver loading. + + uint32 registered; + status = _RegisterFixed(registered); + if (status != B_OK) { + UninitUnusedDriver(); + return status; + } if (registered > 0) { fRegistered = true; return B_OK; @@ -556,8 +640,10 @@ if (DriverModule()->register_child_devices != NULL) { status = DriverModule()->register_child_devices(this); - if (status != B_OK) + if (status != B_OK) { + UninitUnusedDriver(); return status; + } if (!fChildren.IsEmpty()) { fRegistered = true; @@ -570,6 +656,8 @@ status = _RegisterDynamic(); if (status == B_OK) fRegistered = true; + else + UninitUnusedDriver(); return status; } @@ -578,7 +666,7 @@ /*! Registers any children that are identified via the B_DRIVER_FIXED_CHILD attribute. If any of these children cannot be registered, this call will fail (we - don't remove already registered children in this case). + don't remove children we already registered up to this point in this case). */ status_t device_node::_RegisterFixed(uint32& registered) @@ -828,18 +916,15 @@ status_t device_node::_RegisterDynamic() { - uint32 findFlags = 0; - dm_get_attr_uint32(this, B_DEVICE_FIND_CHILD_FLAGS, &findFlags, false); - // If this is our initial registration, we honour the B_FIND_CHILD_ON_DEMAND // requirements - if (!fRegistered && (findFlags & B_FIND_CHILD_ON_DEMAND) != 0 + if (!fRegistered && (fFlags & B_FIND_CHILD_ON_DEMAND) != 0 && !_AlwaysRegisterDynamic()) return B_OK; KPath path; - if ((findFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { + if ((fFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { // find the one driver driver_module_info* bestDriver = NULL; float bestSupport = 0.0; @@ -852,7 +937,16 @@ if (bestDriver != NULL) { TRACE((" register best module \"%s\", support %f\n", bestDriver->info.name, bestSupport)); - bestDriver->register_device(this); + if (bestDriver->register_device(this) == B_OK) { + // There can only be one node of this driver + // (usually only one at all, but there might be a new driver + // "waiting" for its turn) + device_node* child = FindChild(bestDriver->info.name); + if (child != NULL) + child->fSupportsParent = bestSupport; + // TODO: if this fails, we could try the second best driver, + // and so on... + } put_module(bestDriver->info.name); } } else { @@ -878,11 +972,12 @@ // this child is not used currently, and can be removed safely iterator.Remove(); child->fParent = NULL; - delete child; + child->Release(); + if (Release()) panic("died early"); } else - child->fFlags |= NODE_FLAG_REMOVE_ON_UNINIT; + child->Release(); } return fChildren.IsEmpty() ? B_OK : B_BUSY; @@ -939,7 +1034,7 @@ NodeList::Iterator iterator = fChildren.GetIterator(); while (iterator.HasNext()) { device_node* child = iterator.Next(); - + status = child->Probe(devicePath); if (status != B_OK) return status; @@ -949,42 +1044,57 @@ } -bool -device_node::_UninitUnusedChildren() +/*! Uninitializes all temporary references to the driver. The registration + process keeps the driver initialized to optimize the startup procedure; + this function gives this reference away again. +*/ +void +device_node::UninitUnusedDriver() { // First, we need to go to the leaf, and go back from there - bool uninit = true; - NodeList::Iterator iterator = fChildren.GetIterator(); - while (iterator.HasNext()) { device_node* child = iterator.Next(); - if (!child->_UninitUnusedChildren()) - uninit = false; + child->UninitUnusedDriver(); } - // Not all of our children could be uninitialized - if (!uninit) - return false; + if (!IsInitialized() + || (fFlags & NODE_FLAG_REGISTER_INITIALIZED) == 0) + return; - if (!IsInitialized()) - return true; + fFlags &= ~NODE_FLAG_REGISTER_INITIALIZED; - if ((DriverModule()->info.flags & B_KEEP_LOADED) != 0) { - // We must not get unloaded - return false; - } - - return UninitDriver(); + UninitDriver(); } +/*! Calls device_removed() on this node and all of its children - starting + with the deepest and last child. + It will also remove the one reference that every node gets on its creation. +*/ void -device_node::UninitUnusedChildren() +device_node::DeviceRemoved() { - _UninitUnusedChildren(); + NodeList::ConstIterator iterator = Children().GetIterator(); + while (iterator.HasNext()) { + device_node* child = iterator.Next(); + + child->DeviceRemoved(); + } + + if (IsInitialized() && DriverModule()->device_removed != NULL) + DriverModule()->device_removed(this); + + if ((fFlags & B_KEEP_DRIVER_LOADED) != 0) { + // There is no point in keeping this driver loaded when its device + // is gone + UninitDriver(); + } + + UninitUnusedDriver(); + Release(); } @@ -1001,8 +1111,6 @@ if (atomic_add(&fRefCount, -1) > 1) return false; - if (Parent() != NULL) - Parent()->RemoveChild(this); delete this; return true; } @@ -1054,6 +1162,24 @@ } +device_node* +device_node::FindChild(const char* moduleName) const +{ + if (moduleName == NULL) + return NULL; + + NodeList::ConstIterator iterator = Children().GetIterator(); + while (iterator.HasNext()) { + device_node* child = iterator.Next(); + + if (!strcmp(child->ModuleName(), moduleName)) + return child; + } + + return NULL; +} + + void device_node::Dump(int32 level = 0) { @@ -1077,14 +1203,14 @@ static status_t -rescan_device(device_node* node) +rescan_node(device_node* node) { return B_ERROR; } static status_t -register_device(device_node* parent, const char* moduleName, +register_node(device_node* parent, const char* moduleName, const device_attr* attrs, const io_resource* ioResources, device_node** _node) { @@ -1103,7 +1229,7 @@ if (newNode == NULL) return B_NO_MEMORY; - TRACE(("%p: register device \"%s\", parent %p\n", newNode, moduleName, + TRACE(("%p: register node \"%s\", parent %p\n", newNode, moduleName, parent)); RecursiveLocker _(sLock); @@ -1112,16 +1238,6 @@ if (status != B_OK) goto err1; - // make it public - if (parent != NULL) - parent->AddChild(newNode); - else - sRootNode = newNode; - - status = newNode->InitDriver(); - if (status != B_OK) - goto err1; - #if 0 // The following is done to reduce the stack usage of deeply nested // child device nodes. @@ -1136,7 +1252,7 @@ } #endif - status = newNode->Register(); + status = newNode->Register(parent); if (status < B_OK) { parent->RemoveChild(newNode); goto err1; @@ -1148,15 +1264,27 @@ return B_OK; err1: - delete newNode; + newNode->Release(); return status; } static status_t -unregister_device(device_node* node) +unregister_node(device_node* node) { - return B_ERROR; + TRACE(("unregister_node(node %p)\n", node)); + RecursiveLocker _(sLock); + + bool initialized = node->IsInitialized(); + + node->DeviceRemoved(); + + // TODO: We can't just remove it from its parent, as it might still be in + // use. However, we shouldn't really fail in this case, either. + // We should try to uninit the device - if it's just a bus, we can just do + // this. If it has devfs device, there are several options on how to do + // that (for example, by disconnecting the file descriptor). + return initialized ? B_BUSY : B_OK; } @@ -1176,7 +1304,7 @@ static device_node* -get_device_root(void) +get_root_node(void) { if (sRootNode != NULL) sRootNode->Acquire(); @@ -1186,15 +1314,48 @@ static status_t -get_next_child_device(device_node* parent, device_node* _node, - const device_attr* attrs) +get_next_child_node(device_node* parent, const device_attr* attributes, + device_node** _node) { - return B_ERROR; + RecursiveLocker _(sLock); + + NodeList::ConstIterator iterator = parent->Children().GetIterator(); + device_node* last = *_node; + + // skip those we already traversed + while (iterator.HasNext() && last != NULL) { + device_node* node = iterator.Next(); + + if (node != last) + continue; + } + + // find the next one that fits + while (iterator.HasNext()) { + device_node* node = iterator.Next(); + + if (!node->IsRegistered()) + continue; + + if (!node->CompareTo(attributes)) { + if (last != NULL) + last->Release(); + + node->Acquire(); + *_node = node; + return B_OK; + } + } + + if (last != NULL) + last->Release(); + + return B_ENTRY_NOT_FOUND; } static device_node* -get_parent(device_node* node) +get_parent_node(device_node* node) { if (node == NULL) return NULL; @@ -1209,13 +1370,50 @@ static void -put_device_node(device_node* node) +put_node(device_node* node) { RecursiveLocker _(sLock); node->Release(); } +static status_t +publish_device(device_node *node, const char *path, const char *moduleName) +{ + RecursiveLocker _(sLock); + dprintf("publish device: node %p, path %s, module %s\n", node, path, + moduleName); + + struct device* device = new(std::nothrow) ::device; + if (device == NULL) + return B_NO_MEMORY; + + device->node = node; + device->path = strdup(path); + device->module_name = strdup(moduleName); + + sDeviceList.Add(device); + return B_OK; +} + + +static status_t +unpublish_device(device_node *node, const char *path) +{ + DeviceList::Iterator iterator = sDeviceList.GetIterator(); + while (iterator.HasNext()) { + struct device* device = iterator.Next(); + if (!strcmp(device->path, path)) { + iterator.Remove(); + delete device; + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + status_t dm_get_attr_uint8(const device_node* node, const char* name, uint8* _value, bool recursive) @@ -1351,15 +1549,19 @@ }, // device nodes - rescan_device, - register_device, - unregister_device, + rescan_node, + register_node, + unregister_node, get_driver, - get_device_root, - get_next_child_device, - get_parent, - put_device_node, + get_root_node, + get_next_child_node, + get_parent_node, + put_node, + // devices + publish_device, + unpublish_device, + // attributes dm_get_attr_uint8, dm_get_attr_uint16, @@ -1380,12 +1582,12 @@ device_attr attrs[] = { {B_DEVICE_PRETTY_NAME, B_STRING_TYPE, {string: "Devices Root"}}, {B_DEVICE_BUS, B_STRING_TYPE, {string: "root"}}, - {B_DEVICE_FIND_CHILD_FLAGS, B_UINT32_TYPE, - {ui32: B_FIND_MULTIPLE_CHILDREN}}, + {B_DEVICE_FLAGS, B_UINT32_TYPE, + {ui32: B_FIND_MULTIPLE_CHILDREN | B_KEEP_DRIVER_LOADED }}, {NULL} }; - if (register_device(NULL, DEVICE_MANAGER_ROOT_NAME, attrs, NULL, NULL) + if (register_node(NULL, DEVICE_MANAGER_ROOT_NAME, attrs, NULL, NULL) != B_OK) { dprintf("Cannot register Devices Root Node\n"); } @@ -1439,12 +1641,19 @@ probe_path("net"); probe_path("graphics"); - // TODO: opened devices need to keep a "initialized" reference of the - // device_node - sRootNode->Dump(); + void* graphicsHandle = open_path("graphics/generic/0"); +// void* netHandle = open_path("net/sample/0"); + uninit_unused(); + puts("remove net driver"); + device_node* busNode = sRootNode->FindChild(BUS_MODULE_NAME); + bus_trigger_device_removed(busNode); + + close_path(graphicsHandle); +// close_path(netHandle); + // add specific video driver - ie. simulate installing it _add_builtin_module((module_info*)&gSpecificVideoDriverModuleInfo); _add_builtin_module((module_info*)&gSpecificVideoDeviceModuleInfo); Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-14 20:03:29 UTC (rev 25497) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-14 20:05:40 UTC (rev 25498) @@ -11,7 +11,7 @@ #include -// type of I/O resource +/* type of I/O resource */ enum { IO_MEM = 1, IO_PORT = 2, @@ -19,33 +19,35 @@ }; -// I/O resource description +/* I/O resource description */ typedef struct { uint32 type; - // type of I/O resource + /* type of I/O resource */ uint32 base; - // I/O memory: first physical address (32 bit) - // I/O port: first port address (16 bit) - // ISA DMA channel: channel number (0-7) + /* I/O memory: first physical address (32 bit) + * I/O port: first port address (16 bit) + * ISA DMA channel: channel number (0-7) + */ uint32 length; - // I/O memory: size of address range (32 bit) - // I/O port: size of port range (16 bit) - // ISA DMA channel: must be 1 + /* I/O memory: size of address range (32 bit) + * I/O port: size of port range (16 bit) + * ISA DMA channel: must be 1 + */ } io_resource; -// attribute of a device node +/* attribute of a device node */ typedef struct { const char *name; - type_code type; // for supported types, see value + type_code type; /* for supported types, see value */ union { - uint8 ui8; // B_UINT8_TYPE - uint16 ui16; // B_UINT16_TYPE - uint32 ui32; // B_UINT32_TYPE - uint64 ui64; // B_UINT64_TYPE - const char *string; // B_STRING_TYPE - struct { // B_RAW_TYPE + uint8 ui8; /* B_UINT8_TYPE */ + uint16 ui16; /* B_UINT16_TYPE */ + uint32 ui32; /* B_UINT32_TYPE */ + uint64 ui64; /* B_UINT64_TYPE */ + const char *string; /* B_STRING_TYPE */ + struct { /* B_RAW_TYPE */ const void *data; size_t length; } raw; @@ -57,27 +59,31 @@ typedef struct driver_module_info driver_module_info; -// interface of the device manager +/* interface of the device manager */ typedef struct device_manager_info { module_info info; - status_t (*rescan)(device_node *node); + status_t (*rescan_node)(device_node *node); - status_t (*register_device)(device_node *parent, const char *moduleName, + status_t (*register_node)(device_node *parent, const char *moduleName, const device_attr *attrs, const io_resource *ioResources, device_node **_node); - status_t (*unregister_device)(device_node *node); + status_t (*unregister_node)(device_node *node); status_t (*get_driver)(device_node *node, driver_module_info **_module, void **_cookie); - device_node *(*get_root_device)(); - status_t (*get_next_child_device)(device_node *parent, device_node *node, - const device_attr *attrs); - device_node *(*get_parent)(device_node *node); - void (*put_device_node)(device_node *node); + device_node *(*get_root_node)(); + status_t (*get_next_child_node)(device_node *parent, + const device_attr *attrs, device_node **node); + device_node *(*get_parent_node)(device_node *node); + void (*put_node)(device_node *node); + status_t (*publish_device)(device_node *node, const char *path, + const char *deviceModuleName); + status_t (*unpublish_device)(device_node *node, const char *path); + #if 0 status_t (*acquire_io_resources)(io_resource *resources); status_t (*release_io_resources)(const io_resource *resources); @@ -106,7 +112,7 @@ #define B_DEVICE_MANAGER_MODULE_NAME "system/device_manager/v1" -// interface of device driver +/* interface of device driver */ struct driver_module_info { module_info info; @@ -128,7 +134,7 @@ #define B_DEVICE_MAPPING "device/mapping" /* string */ #define B_DEVICE_BUS "device/bus" /* string */ #define B_DEVICE_FIXED_CHILD "device/fixed child" /* string */ -#define B_DEVICE_FIND_CHILD_FLAGS "device/find child flags" /* uint32 */ +#define B_DEVICE_FLAGS "device/flags" /* uint32 */ #define B_DEVICE_VENDOR_ID "device/vendor" /* uint16 */ #define B_DEVICE_ID "device/id" /* uint16 */ @@ -141,20 +147,21 @@ #define B_DEVICE_UNIQUE_ID "device/unique id" /* string */ -// find child flags +/* device flags */ #define B_FIND_CHILD_ON_DEMAND 0x01 #define B_FIND_MULTIPLE_CHILDREN 0x02 +#define B_KEEP_DRIVER_LOADED 0x04 -// interface of device +/* interface of device */ typedef struct io_request io_request; struct device_module_info { module_info info; - status_t (*init_device)(void *cookie); - void (*uninit_device)(void *cookie); + status_t (*init_device)(device_node *node, void **_deviceCookie); + void (*uninit_device)(void *deviceCookie); status_t (*device_open)(void *deviceCookie, int openMode, void **_cookie); status_t (*device_close)(void *cookie); Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-14 20:03:29 UTC (rev 25497) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-14 20:05:40 UTC (rev 25498) @@ -10,6 +10,7 @@ [... truncated: 165 lines follow ...] From stippi at mail.berlios.de Wed May 14 22:12:58 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 22:12:58 +0200 Subject: [Haiku-commits] r25499 - haiku/trunk/src/kits/app Message-ID: <200805142012.m4EKCwmM021908@sheep.berlios.de> Author: stippi Date: 2008-05-14 22:12:57 +0200 (Wed, 14 May 2008) New Revision: 25499 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25499&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: Print and error and the message in case _ArgvReceived() fails to parse the message correctly, it is a bit strange why the message should not follow protocol. Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-14 20:05:40 UTC (rev 25498) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-14 20:12:57 UTC (rev 25499) @@ -1447,6 +1447,11 @@ if (error == B_OK && argc > 0) ArgvReceived(argc, argv); + if (error != B_OK) { + fprintf(stderr, "Error parsing B_ARGV_RECEIVED message. Message:\n"); + message->PrintToStream(); + } + // cleanup if (argv) { for (int32 i = 0; i < argc; i++) From korli at users.berlios.de Wed May 14 22:17:02 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 14 May 2008 22:17:02 +0200 Subject: [Haiku-commits] r25499 - haiku/trunk/src/kits/app In-Reply-To: <200805142012.m4EKCwmM021908@sheep.berlios.de> References: <200805142012.m4EKCwmM021908@sheep.berlios.de> Message-ID: 2008/5/14 stippi at BerliOS : > + if (error != B_OK) { > + fprintf(stderr, "Error parsing B_ARGV_RECEIVED message. Message:\n"); > + message->PrintToStream(); Please note the message will be printed on stdout though (and not the first part). Bye, J?r?me From stippi at mail.berlios.de Wed May 14 22:33:54 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 14 May 2008 22:33:54 +0200 Subject: [Haiku-commits] r25500 - haiku/trunk/src/kits/app Message-ID: <200805142033.m4EKXsI9023400@sheep.berlios.de> Author: stippi Date: 2008-05-14 22:33:53 +0200 (Wed, 14 May 2008) New Revision: 25500 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25500&view=rev Modified: haiku/trunk/src/kits/app/Application.cpp Log: Print the error message to stdout, since that is where the message->PrintToStream() output goes. Thanks, Jerome, for the suggestion! Modified: haiku/trunk/src/kits/app/Application.cpp =================================================================== --- haiku/trunk/src/kits/app/Application.cpp 2008-05-14 20:12:57 UTC (rev 25499) +++ haiku/trunk/src/kits/app/Application.cpp 2008-05-14 20:33:53 UTC (rev 25500) @@ -1448,7 +1448,7 @@ ArgvReceived(argc, argv); if (error != B_OK) { - fprintf(stderr, "Error parsing B_ARGV_RECEIVED message. Message:\n"); + printf("Error parsing B_ARGV_RECEIVED message. Message:\n"); message->PrintToStream(); } From axeld at pinc-software.de Wed May 14 23:29:21 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 14 May 2008 23:29:21 +0200 CEST Subject: [Haiku-commits] r25451 - in haiku/trunk: headers/private/kernel headers/private/kernel/arch/x86 headers/private/libroot src/system/kernel src/system/kernel/arch/x86 In-Reply-To: <20080512004951.1034.6@knochen-vm.1210510002.fake> Message-ID: <50165422072-BeMail@zon> Ingo Weinhold wrote: > > Actually I'm wondering, it doesn't seem to have that many calls to > > sigaction in glibc-2.7/malloc/ > The alternatives would be sigprocmask()/pthread_sigmask(), but > grepping > turns up neither. I tried to find the actual malloc() implementation, > but > I'm not sure, if I found it (public_mALLOc() I believe). The glibc > code is > so lovely. Just had a look: that reminded me how thankful I am that Korli took over the glibc work :-) Anyway, it looks like it does not suppress any signals, I also can't imagine that their mutex_lock() suppesses signals (I had a look, but couldn't find anything there either). However, their malloc() uses "arenas" that hold the memory, and if trylocking one failed, it will go over to the next. So as long as there is an arena left, the code should indeed work in signal handlers, too. It doesn't really look that robust, but that could well be because I didn't dig in more. Bye, Axel. From anevilyak at mail.berlios.de Wed May 14 23:37:18 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Wed, 14 May 2008 23:37:18 +0200 Subject: [Haiku-commits] r25501 - haiku/trunk/src/add-ons/kernel/bus_managers/ata Message-ID: <200805142137.m4ELbIxB000046@sheep.berlios.de> Author: anevilyak Date: 2008-05-14 23:37:18 +0200 (Wed, 14 May 2008) New Revision: 25501 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25501&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile Log: Build fix from Ingo's header reorganization. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 20:33:53 UTC (rev 25500) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 21:37:18 UTC (rev 25501) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers ata ; UsePrivateHeaders drivers kernel ; +UsePrivateHeaders system ; UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ; UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; From ingo_weinhold at gmx.de Thu May 15 00:29:33 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 15 May 2008 00:29:33 +0200 Subject: [Haiku-commits] r25501 - haiku/trunk/src/add-ons/kernel/bus_managers/ata In-Reply-To: <200805142137.m4ELbIxB000046@sheep.berlios.de> References: <200805142137.m4ELbIxB000046@sheep.berlios.de> Message-ID: <20080515002933.428.2@knochen-vm.1210803215.fake> On 2008-05-14 at 23:37:18 [+0200], anevilyak at BerliOS wrote: > Author: anevilyak > Date: 2008-05-14 23:37:18 +0200 (Wed, 14 May 2008) > New Revision: 25501 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25501&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile > Log: > Build fix from Ingo's header reorganization. > > Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile > =================================================================== > --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 > 20:33:53 UTC (rev 25500) > +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 > 21:37:18 UTC (rev 25501) > @@ -1,6 +1,7 @@ > SubDir HAIKU_TOP src add-ons kernel bus_managers ata ; > > UsePrivateHeaders drivers kernel ; > +UsePrivateHeaders system ; > UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ; > UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) > ] ; BTW, there's a UsePrivateKernelHeaders which covers all those lines save for the "UsePrivateHeaders drivers". I guess the Jamfile was copied from one that preceded the rule. It is recommended to use it now, though. CU, Ingo From anevilyak at mail.berlios.de Thu May 15 01:03:33 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Thu, 15 May 2008 01:03:33 +0200 Subject: [Haiku-commits] r25502 - haiku/trunk/src/add-ons/kernel/bus_managers/ata Message-ID: <200805142303.m4EN3XH4019542@sheep.berlios.de> Author: anevilyak Date: 2008-05-15 01:03:31 +0200 (Thu, 15 May 2008) New Revision: 25502 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25502&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile Log: Cleanup as suggested by Ingo. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 21:37:18 UTC (rev 25501) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/Jamfile 2008-05-14 23:03:31 UTC (rev 25502) @@ -1,9 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers ata ; -UsePrivateHeaders drivers kernel ; -UsePrivateHeaders system ; -UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ; -UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ; +UsePrivateHeaders drivers ; +UsePrivateKernelHeaders ; KernelAddon ide : ata.c From anevilyak at gmail.com Thu May 15 01:03:57 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Wed, 14 May 2008 18:03:57 -0500 Subject: [Haiku-commits] r25501 - haiku/trunk/src/add-ons/kernel/bus_managers/ata In-Reply-To: <20080515002933.428.2@knochen-vm.1210803215.fake> References: <200805142137.m4ELbIxB000046@sheep.berlios.de> <20080515002933.428.2@knochen-vm.1210803215.fake> Message-ID: On Wed, May 14, 2008 at 5:29 PM, Ingo Weinhold wrote: > BTW, there's a UsePrivateKernelHeaders which covers all those lines save for > the "UsePrivateHeaders drivers". I guess the Jamfile was copied from one > that preceded the rule. It is recommended to use it now, though. > Thanks! Regards, Rene From stippi at mail.berlios.de Thu May 15 12:06:59 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 12:06:59 +0200 Subject: [Haiku-commits] r25503 - haiku/trunk/src/system/kernel/fs Message-ID: <200805151006.m4FA6xS6019137@sheep.berlios.de> Author: stippi Date: 2008-05-15 12:06:58 +0200 (Thu, 15 May 2008) New Revision: 25503 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25503&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: Use find_directory() in the devfs. Based on patch by Vasilis Kaoutsis. Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-05-14 23:03:31 UTC (rev 25502) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2008-05-15 10:06:58 UTC (rev 25503) @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -490,14 +491,26 @@ static int32 -get_priority(const char *path) +get_priority(const char* path) { - // TODO: use find_directory() - const char *kPaths[] = {"/boot/beos", "/boot/common", "/boot/home", NULL}; + // TODO: would it be better to initialize a static structure here + // using find_directory()? + const directory_which whichPath[] = { + B_BEOS_DIRECTORY, + B_COMMON_DIRECTORY, + B_USER_DIRECTORY + }; + KPath pathBuffer; - for (int32 i = 0; kPaths[i] != NULL; i++) { - if (!strncmp(kPaths[i], path, strlen(kPaths[i]))) - return i; + for (uint32 index = 0; index < sizeof(whichPath) / sizeof(whichPath[0]); + index++) { + if (find_directory(whichPath[index], gBootDevice, false, + pathBuffer.LockBuffer(), pathBuffer.BufferSize()) == B_OK) { + pathBuffer.UnlockBuffer(); + if (!strncmp(pathBuffer.Path(), path, pathBuffer.BufferSize())) + return index; + } else + pathBuffer.UnlockBuffer(); } return -1; @@ -2835,21 +2848,45 @@ extern "C" void devfs_add_preloaded_drivers(kernel_args* args) { + // NOTE: This function does not exit in case of error, since it + // needs to unload the images then. Also the return code of + // the path operations is kept separate from the add_driver() + // success, so that even if add_driver() fails for one driver, it + // is still tried for the other drivers. + // NOTE: The initialization success of the path objects is implicitely + // checked by the immediately following functions. + KPath basePath; + status_t pathStatus = find_directory(B_BEOS_ADDONS_DIRECTORY, + gBootDevice, false, basePath.LockBuffer(), basePath.BufferSize()); + if (pathStatus != B_OK) { + dprintf("devfs_add_preloaded_drivers: find_directory() failed: " + "%s\n", strerror(pathStatus)); + } + basePath.UnlockBuffer(); + if (pathStatus == B_OK) + pathStatus = basePath.Append("kernel"); + if (pathStatus != B_OK) { + dprintf("devfs_add_preloaded_drivers: constructing base driver " + "path failed: %s\n", strerror(pathStatus)); + } + struct preloaded_image* image; for (image = args->preloaded_images; image != NULL; image = image->next) { - if (!image->is_module && image->id >= 0) { - // fake an absolute path - char path[B_PATH_NAME_LENGTH]; - strlcpy(path, "/boot/beos/system/add-ons/kernel/", sizeof(path)); - strlcat(path, image->name, sizeof(path)); + if (image->is_module || image->id < 0) + continue; - // try to add the driver - status_t error = add_driver(path, image->id); - if (error != B_OK) { - dprintf("devfs_add_preloaded_drivers: Failed to add \"%s\"\n", - image->name); - unload_kernel_add_on(image->id); - } + KPath imagePath(basePath); + if (pathStatus == B_OK) + pathStatus = imagePath.Append(image->name); + + // try to add the driver + status_t addStatus = pathStatus; + if (pathStatus == B_OK) + addStatus = add_driver(imagePath.Path(), image->id); + if (addStatus != B_OK) { + dprintf("devfs_add_preloaded_drivers: Failed to add \"%s\"\n", + image->name); + unload_kernel_add_on(image->id); } } } From mauricek at mail.berlios.de Thu May 15 12:38:28 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Thu, 15 May 2008 12:38:28 +0200 Subject: [Haiku-commits] r25504 - haiku/trunk/src/bin/mkfs Message-ID: <200805151038.m4FAcSr7031736@sheep.berlios.de> Author: mauricek Date: 2008-05-15 12:38:24 +0200 (Thu, 15 May 2008) New Revision: 25504 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25504&view=rev Modified: haiku/trunk/src/bin/mkfs/FsCreator.cpp Log: gcc4 build fix Modified: haiku/trunk/src/bin/mkfs/FsCreator.cpp =================================================================== --- haiku/trunk/src/bin/mkfs/FsCreator.cpp 2008-05-15 10:06:58 UTC (rev 25503) +++ haiku/trunk/src/bin/mkfs/FsCreator.cpp 2008-05-15 10:38:24 UTC (rev 25504) @@ -132,7 +132,7 @@ { char line[255]; - cin.getline(line, sizeof(line), '\n'); + std::cin.getline(line, sizeof(line), '\n'); return line; } From mauricek at mail.berlios.de Thu May 15 12:46:26 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Thu, 15 May 2008 12:46:26 +0200 Subject: [Haiku-commits] r25505 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm Message-ID: <200805151046.m4FAkQMd009837@sheep.berlios.de> Author: mauricek Date: 2008-05-15 12:46:25 +0200 (Thu, 15 May 2008) New Revision: 25505 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25505&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp Log: gcc4 build fix. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-15 10:38:24 UTC (rev 25504) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-15 10:46:25 UTC (rev 25505) @@ -162,7 +162,7 @@ } -static status_t +extern "C" status_t usb_ecm_open(const char *name, uint32 flags, void **cookie) { TRACE("open(%s, %lu, %p)\n", name, flags, cookie); @@ -181,7 +181,7 @@ } -static status_t +extern "C" status_t usb_ecm_read(void *cookie, off_t position, void *buffer, size_t *numBytes) { TRACE("read(%p, %Ld, %p, %lu)\n", cookie, position, buffer, *numBytes); @@ -190,7 +190,7 @@ } -static status_t +extern "C" status_t usb_ecm_write(void *cookie, off_t position, const void *buffer, size_t *numBytes) { @@ -200,7 +200,7 @@ } -static status_t +extern "C" status_t usb_ecm_control(void *cookie, uint32 op, void *buffer, size_t length) { TRACE("control(%p, %lu, %p, %lu)\n", cookie, op, buffer, length); @@ -209,7 +209,7 @@ } -static status_t +extern "C" status_t usb_ecm_close(void *cookie) { TRACE("close(%p)\n", cookie); @@ -218,7 +218,7 @@ } -static status_t +extern "C" status_t usb_ecm_free(void *cookie) { TRACE("free(%p)\n", cookie); From stippi at mail.berlios.de Thu May 15 13:55:11 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 13:55:11 +0200 Subject: [Haiku-commits] r25506 - haiku/trunk/src/system/kernel Message-ID: <200805151155.m4FBtBWr024279@sheep.berlios.de> Author: stippi Date: 2008-05-15 13:55:09 +0200 (Thu, 15 May 2008) New Revision: 25506 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25506&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: Another patch by Vasilis Kaoutsis: Use find_directory() to find the runtime_loader when starting teams. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-15 10:46:25 UTC (rev 25505) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-15 11:55:09 UTC (rev 25506) @@ -17,9 +17,12 @@ #include #include +#include +#include #include #include +#include #include #include #include @@ -1168,14 +1171,28 @@ } free_team_arg(teamArgs); - // the arguments are already on the user stack, we no longer need them in this form + // the arguments are already on the user stack, we no longer need + // them in this form - // ToDo: don't use fixed paths! - err = elf_load_user_image("/boot/beos/system/runtime_loader", team, 0, &entry); + // find runtime_loader path + KPath runtimeLoaderPath; + err = find_directory(B_BEOS_SYSTEM_DIRECTORY, gBootDevice, false, + runtimeLoaderPath.LockBuffer(), runtimeLoaderPath.BufferSize()); if (err < B_OK) { + TRACE(("team_create_thread_start: find_directory() failed: %s\n", + strerror(err))); + return err; + } + runtimeLoaderPath.UnlockBuffer(); + err = runtimeLoaderPath.Append("runtime_loader"); + + if (err == B_OK) + err = elf_load_user_image(runtimeLoaderPath.Path(), team, 0, &entry); + if (err < B_OK) { // Luckily, we don't have to clean up the mess we created - that's // done for us by the normal team deletion process - TRACE(("team_create_thread_start: error when elf_load_user_image() %s\n", strerror(err))); + TRACE(("team_create_thread_start: elf_load_user_image() failed: " + "%s\n", strerror(err))); return err; } From stippi at mail.berlios.de Thu May 15 14:08:14 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 14:08:14 +0200 Subject: [Haiku-commits] r25507 - haiku/trunk/headers/private/kernel Message-ID: <200805151208.m4FC8E4h025326@sheep.berlios.de> Author: stippi Date: 2008-05-15 14:08:13 +0200 (Thu, 15 May 2008) New Revision: 25507 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25507&view=rev Modified: haiku/trunk/headers/private/kernel/kernel_daemon.h Log: Patch by Vasilis Kaoutsis: Fixed typo in comment. Modified: haiku/trunk/headers/private/kernel/kernel_daemon.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel_daemon.h 2008-05-15 11:55:09 UTC (rev 25506) +++ haiku/trunk/headers/private/kernel/kernel_daemon.h 2008-05-15 12:08:13 UTC (rev 25507) @@ -14,4 +14,4 @@ #endif status_t kernel_daemon_init(void); -#endif /* _KRENEL_DAEMON_H */ +#endif /* _KERNEL_DAEMON_H */ From stippi at mail.berlios.de Thu May 15 14:09:12 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 14:09:12 +0200 Subject: [Haiku-commits] r25508 - haiku/trunk/src/system/kernel/fs Message-ID: <200805151209.m4FC9CBZ025467@sheep.berlios.de> Author: stippi Date: 2008-05-15 14:09:12 +0200 (Thu, 15 May 2008) New Revision: 25508 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25508&view=rev Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp Log: Honour 80 char/line limit. Modified: haiku/trunk/src/system/kernel/fs/KPath.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-15 12:08:13 UTC (rev 25507) +++ haiku/trunk/src/system/kernel/fs/KPath.cpp 2008-05-15 12:09:12 UTC (rev 25508) @@ -253,7 +253,8 @@ // compute the result path len bool insertSlash = isComponent && fBuffer[fPathLength - 1] != '/' && component[0] != '/'; - size_t resultPathLength = fPathLength + componentLength + (insertSlash ? 1 : 0); + size_t resultPathLength = fPathLength + componentLength + + (insertSlash ? 1 : 0); if (resultPathLength >= fBufferSize) return B_BUFFER_OVERFLOW; From stippi at mail.berlios.de Thu May 15 14:10:13 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 14:10:13 +0200 Subject: [Haiku-commits] r25509 - haiku/trunk/src/system/kernel Message-ID: <200805151210.m4FCADoK025548@sheep.berlios.de> Author: stippi Date: 2008-05-15 14:10:12 +0200 (Thu, 15 May 2008) New Revision: 25509 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25509&view=rev Added: haiku/trunk/src/system/kernel/main.cpp Removed: haiku/trunk/src/system/kernel/main.c Modified: haiku/trunk/src/system/kernel/Jamfile Log: Patch by Vasilis Kaoutsis: * Renamed main.c to main.cpp * Use find_directory() to construct the Bootscript path. Modified: haiku/trunk/src/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/Jamfile 2008-05-15 12:09:12 UTC (rev 25508) +++ haiku/trunk/src/system/kernel/Jamfile 2008-05-15 12:10:12 UTC (rev 25509) @@ -29,7 +29,7 @@ kernel_daemon.cpp linkhack.c lock.cpp - main.c + main.cpp module.cpp Notifications.cpp port.cpp Deleted: haiku/trunk/src/system/kernel/main.c Copied: haiku/trunk/src/system/kernel/main.cpp (from rev 25502, haiku/trunk/src/system/kernel/main.c) =================================================================== --- haiku/trunk/src/system/kernel/main.c 2008-05-14 23:03:31 UTC (rev 25502) +++ haiku/trunk/src/system/kernel/main.cpp 2008-05-15 12:10:12 UTC (rev 25509) @@ -0,0 +1,333 @@ +/* + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ + +/*! This is main - initializes the kernel and launches the Bootscript */ + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +//#define TRACE_BOOT +#ifdef TRACE_BOOT +# define TRACE(x...) dprintf("INIT: " x) +#else +# define TRACE(x...) ; +#endif + +bool kernel_startup = true; + +static kernel_args sKernelArgs; +static uint32 sCpuRendezvous; +static uint32 sCpuRendezvous2; + +static int32 main2(void *); + +#ifdef __cplusplus +extern "C" { +#endif + +extern int _start(kernel_args *bootKernelArgs, int cpu); + /* keep compiler happy */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +int +_start(kernel_args *bootKernelArgs, int currentCPU) +{ + if (bootKernelArgs->kernel_args_size != sizeof(kernel_args) + || bootKernelArgs->version != CURRENT_KERNEL_ARGS_VERSION) { + // This is something we cannot handle right now - release kernels + // should always be able to handle the kernel_args of earlier + // released kernels. + debug_early_boot_message("Version mismatch between boot loader and " + "kernel!\n"); + return -1; + } + + smp_set_num_cpus(bootKernelArgs->num_cpus); + + // wait for all the cpus to get here + smp_cpu_rendezvous(&sCpuRendezvous, currentCPU); + + // the passed in kernel args are in a non-allocated range of memory + if (currentCPU == 0) + memcpy(&sKernelArgs, bootKernelArgs, sizeof(kernel_args)); + + smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU); + + // do any pre-booting cpu config + cpu_preboot_init_percpu(&sKernelArgs, currentCPU); + thread_preboot_init_percpu(&sKernelArgs, currentCPU); + + // if we're not a boot cpu, spin here until someone wakes us up + if (smp_trap_non_boot_cpus(currentCPU)) { + thread_id thread; + + // init platform + arch_platform_init(&sKernelArgs); + + // setup debug output + debug_init(&sKernelArgs); + set_dprintf_enabled(true); + dprintf("Welcome to kernel debugger output!\n"); + dprintf("Haiku revision: %lu\n", get_haiku_revision()); + + // init modules + TRACE("init CPU\n"); + cpu_init(&sKernelArgs); + cpu_init_percpu(&sKernelArgs, currentCPU); + TRACE("init interrupts\n"); + int_init(&sKernelArgs); + + TRACE("init VM\n"); + vm_init(&sKernelArgs); + // Before vm_init_post_sem() is called, we have to make sure that + // the boot loader allocated region is not used anymore + + // now we can use the heap and create areas + arch_platform_init_post_vm(&sKernelArgs); + lock_debug_init(); + TRACE("init driver_settings\n"); + boot_item_init(); + driver_settings_init(&sKernelArgs); + debug_init_post_vm(&sKernelArgs); + int_init_post_vm(&sKernelArgs); + cpu_init_post_vm(&sKernelArgs); + commpage_init(); + TRACE("init system info\n"); + system_info_init(&sKernelArgs); + + TRACE("init SMP\n"); + smp_init(&sKernelArgs); + TRACE("init timer\n"); + timer_init(&sKernelArgs); + TRACE("init real time clock\n"); + rtc_init(&sKernelArgs); + + TRACE("init semaphores\n"); + haiku_sem_init(&sKernelArgs); + condition_variable_init(); + + // now we can create and use semaphores + TRACE("init VM semaphores\n"); + vm_init_post_sem(&sKernelArgs); + TRACE("init driver_settings\n"); + driver_settings_init_post_sem(&sKernelArgs); + TRACE("init generic syscall\n"); + generic_syscall_init(); + TRACE("init cbuf\n"); + cbuf_init(); + TRACE("init teams\n"); + team_init(&sKernelArgs); + TRACE("init threads\n"); + thread_init(&sKernelArgs); + TRACE("init ports\n"); + port_init(&sKernelArgs); + TRACE("init kernel daemons\n"); + kernel_daemon_init(); + arch_platform_init_post_thread(&sKernelArgs); + realtime_sem_init(); + + TRACE("init VM threads\n"); + vm_init_post_thread(&sKernelArgs); + TRACE("init ELF loader\n"); + elf_init(&sKernelArgs); + TRACE("init scheduler\n"); + scheduler_init(); + TRACE("init notification services\n"); + notifications_init(); + TRACE("init VFS\n"); + vfs_init(&sKernelArgs); + + // bring up the AP cpus in a lock step fashion + TRACE("waking up AP cpus\n"); + sCpuRendezvous = sCpuRendezvous2 = 0; + smp_wake_up_non_boot_cpus(); + smp_cpu_rendezvous(&sCpuRendezvous, 0); // wait until they're booted + + // exit the kernel startup phase (mutexes, etc work from now on out) + TRACE("exiting kernel startup\n"); + kernel_startup = false; + + smp_cpu_rendezvous(&sCpuRendezvous2, 0); + // release the AP cpus to go enter the scheduler + + TRACE("enabling interrupts and starting scheduler on cpu 0\n"); + enable_interrupts(); + scheduler_start(); + + // start a thread to finish initializing the rest of the system + TRACE("starting main2 thread\n"); + thread = spawn_kernel_thread(&main2, "main2", B_NORMAL_PRIORITY, NULL); + TRACE("resuming main2 thread...\n"); + resume_thread(thread); + } else { + // lets make sure we're in sync with the main cpu + // the boot processor has probably been sending us + // tlb sync messages all along the way, but we've + // been ignoring them + arch_cpu_global_TLB_invalidate(); + + // this is run for each non boot processor after they've been set loose + cpu_init_percpu(&sKernelArgs, currentCPU); + smp_per_cpu_init(&sKernelArgs, currentCPU); + + // wait for all other AP cpus to get to this point + smp_cpu_rendezvous(&sCpuRendezvous, currentCPU); + smp_cpu_rendezvous(&sCpuRendezvous2, currentCPU); + + // welcome to the machine + enable_interrupts(); + scheduler_start(); + } + + TRACE("main: done... begin idle loop on cpu %d\n", currentCPU); + for (;;) + arch_cpu_idle(); + + return 0; +} + +static int32 +main2(void *unused) +{ + (void)(unused); + + TRACE("start of main2: initializing devices\n"); + + boot_splash_init(sKernelArgs.boot_splash); + + TRACE("Init modules\n"); + boot_splash_set_stage(BOOT_SPLASH_STAGE_1_INIT_MODULES); + module_init(&sKernelArgs); + + // ToDo: the preloaded image debug data is placed in the kernel args, and + // thus, if they are enabled, the kernel args shouldn't be freed, so + // that we don't have to copy them. + // What is yet missing is a mechanism that controls this (via driver settings). + if (0) { + // module_init() is supposed to be the last user of the kernel args + // Note: don't confuse the kernel_args structure (which is never freed) + // with the kernel args ranges it contains (and which are freed here). + vm_free_kernel_args(&sKernelArgs); + } + + // init userland debugging + TRACE("Init Userland debugging\n"); + init_user_debug(); + + // init the messaging service + TRACE("Init Messaging Service\n"); + init_messaging_service(); + + /* bootstrap all the filesystems */ + TRACE("Bootstrap file systems\n"); + boot_splash_set_stage(BOOT_SPLASH_STAGE_2_BOOTSTRAP_FS); + vfs_bootstrap_file_systems(); + + TRACE("Init Device Manager\n"); + boot_splash_set_stage(BOOT_SPLASH_STAGE_3_INIT_DEVICES); + device_manager_init(&sKernelArgs); + + TRACE("Add preloaded old-style drivers\n"); + devfs_add_preloaded_drivers(&sKernelArgs); + + int_init_post_device_manager(&sKernelArgs); + + TRACE("Mount boot file system\n"); + boot_splash_set_stage(BOOT_SPLASH_STAGE_4_MOUNT_BOOT_FS); + vfs_mount_boot_file_system(&sKernelArgs); + + // CPU specific modules may now be available + boot_splash_set_stage(BOOT_SPLASH_STAGE_5_INIT_CPU_MODULES); + cpu_init_post_modules(&sKernelArgs); + + TRACE("vm_init_post_modules\n"); + boot_splash_set_stage(BOOT_SPLASH_STAGE_6_INIT_VM_MODULES); + vm_init_post_modules(&sKernelArgs); + + TRACE("debug_init_post_modules\n"); + debug_init_post_modules(&sKernelArgs); + + TRACE("device_manager_init_post_modules\n"); + device_manager_init_post_modules(&sKernelArgs); + + boot_splash_set_stage(BOOT_SPLASH_STAGE_7_RUN_BOOT_SCRIPT); +// kernel_args_free(sKernelArgs.boot_splash); +// NOTE: We could introduce a syscall to draw more icons indicating +// stages in the boot script itself. Then we should not free the image. + + // start the init process + { + KPath bootScriptPath; + status_t status = find_directory(B_BEOS_SYSTEM_DIRECTORY, gBootDevice, + false, bootScriptPath.LockBuffer(), bootScriptPath.BufferSize()); + if (status != B_OK) + dprintf("main2: find_directory() failed: %s\n", strerror(status)); + bootScriptPath.UnlockBuffer(); + status = bootScriptPath.Append("boot/Bootscript"); + if (status != B_OK) { + dprintf("main2: constructing path to Bootscript failed: " + "%s\n", strerror(status)); + } + + const char *args[] = { "/bin/sh", bootScriptPath.Path(), NULL }; + int32 argc = 2; + thread_id thread; + + thread = load_image(argc, args, NULL); + if (thread >= B_OK) { + resume_thread(thread); + TRACE("Bootscript started\n"); + } else + dprintf("error starting \"%s\" error = %ld \n", args[0], thread); + } + + return 0; +} + From mmlr at mlotz.ch Thu May 15 14:20:22 2008 From: mmlr at mlotz.ch (Michael Lotz) Date: Thu, 15 May 2008 14:20:22 +0200 Subject: [Haiku-commits] r25505 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <200805151046.m4FAkQMd009837@sheep.berlios.de> References: <200805151046.m4FAkQMd009837@sheep.berlios.de> Message-ID: <20080515121744.M11872@mlotz.ch> On Thu, 15 May 2008 12:46:26 +0200, mauricek at BerliOS wrote > Author: mauricek > Date: 2008-05-15 12:46:25 +0200 (Thu, 15 May 2008) > New Revision: 25505 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25505&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp > Log: > gcc4 build fix. ... > -static status_t > +extern "C" status_t While this fixes the build I think it is not the right way to do it. These functions are fine being static, they just don't really need to be extern. The better way would be to remove the forward declarations instead and revert this change. I will commit that in the next minutes. Regards Michael From mmlr at mail.berlios.de Thu May 15 14:27:21 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 15 May 2008 14:27:21 +0200 Subject: [Haiku-commits] r25510 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm Message-ID: <200805151227.m4FCRLKX026658@sheep.berlios.de> Author: mmlr Date: 2008-05-15 14:27:20 +0200 (Thu, 15 May 2008) New Revision: 25510 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25510&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h Log: Fix the GCC4 build the other way around. Remove the unnecessary forward declarations and make the functions static again. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-15 12:10:12 UTC (rev 25509) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.cpp 2008-05-15 12:27:20 UTC (rev 25510) @@ -162,7 +162,7 @@ } -extern "C" status_t +static status_t usb_ecm_open(const char *name, uint32 flags, void **cookie) { TRACE("open(%s, %lu, %p)\n", name, flags, cookie); @@ -181,7 +181,7 @@ } -extern "C" status_t +static status_t usb_ecm_read(void *cookie, off_t position, void *buffer, size_t *numBytes) { TRACE("read(%p, %Ld, %p, %lu)\n", cookie, position, buffer, *numBytes); @@ -190,7 +190,7 @@ } -extern "C" status_t +static status_t usb_ecm_write(void *cookie, off_t position, const void *buffer, size_t *numBytes) { @@ -200,7 +200,7 @@ } -extern "C" status_t +static status_t usb_ecm_control(void *cookie, uint32 op, void *buffer, size_t length) { TRACE("control(%p, %lu, %p, %lu)\n", cookie, op, buffer, length); @@ -209,7 +209,7 @@ } -extern "C" status_t +static status_t usb_ecm_close(void *cookie) { TRACE("close(%p)\n", cookie); @@ -218,7 +218,7 @@ } -extern "C" status_t +static status_t usb_ecm_free(void *cookie) { TRACE("free(%p)\n", cookie); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h 2008-05-15 12:10:12 UTC (rev 25509) +++ haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm/Driver.h 2008-05-15 12:27:20 UTC (rev 25510) @@ -62,13 +62,6 @@ status_t init_hardware(); void uninit_driver(); -status_t usb_ecm_open(const char *name, uint32 flags, void **cookie); -status_t usb_ecm_read(void *cookie, off_t position, void *buffer, size_t *numBytes); -status_t usb_ecm_write(void *cookie, off_t position, const void *buffer, size_t *numBytes); -status_t usb_ecm_control(void *cookie, uint32 op, void *buffer, size_t length); -status_t usb_ecm_close(void *cookie); -status_t usb_ecm_free(void *cookie); - const char **publish_devices(); device_hooks *find_device(const char *name); } From stippi at mail.berlios.de Thu May 15 14:28:12 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 15 May 2008 14:28:12 +0200 Subject: [Haiku-commits] r25511 - haiku/trunk/src/system/kernel Message-ID: <200805151228.m4FCSC6H026718@sheep.berlios.de> Author: stippi Date: 2008-05-15 14:28:08 +0200 (Thu, 15 May 2008) New Revision: 25511 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25511&view=rev Modified: haiku/trunk/src/system/kernel/module.cpp Log: Another patch by Vasilis Kaoutsis: * Use find_directory() for the hash for preloaded modules. I am not sure this patch is needed, since it only concerns the hash. Please review. Modified: haiku/trunk/src/system/kernel/module.cpp =================================================================== --- haiku/trunk/src/system/kernel/module.cpp 2008-05-15 12:27:20 UTC (rev 25510) +++ haiku/trunk/src/system/kernel/module.cpp 2008-05-15 12:28:08 UTC (rev 25511) @@ -950,7 +950,8 @@ // that module). Also helpful for recurse_directory(). { // ToDo: this is kind of a hack to have the full path in the hash - // (it always assumes the preloaded add-ons to be in the system directory) + // (it always assumes the preloaded add-ons to be in the system + // directory) char path[B_FILE_NAME_LENGTH]; const char *name, *suffix; if (moduleImage->info[0] @@ -958,12 +959,31 @@ image->name)) != NULL) { // even if strlcpy() is used here, it's by no means safe // against buffer overflows - size_t length = strlcpy(path, "/boot/beos/system/add-ons/kernel/", - sizeof(path)); - strlcpy(path + length, name, strlen(image->name) - + 1 + (suffix - name)); + KPath addonsKernelPath; + status_t status = find_directory(B_BEOS_ADDONS_DIRECTORY, + gBootDevice, false, addonsKernelPath.LockBuffer(), + addonsKernelPath.BufferSize()); + if (status != B_OK) { + dprintf("register_preloaded_module_image: find_directory() " + "failed: %s\n", strerror(status)); + } + addonsKernelPath.UnlockBuffer(); + if (status == B_OK) { + status = addonsKernelPath.Append("kernel/"); + // KPath does not remove the trailing '/' + } + if (status == B_OK) { + size_t length = strlcpy(path, addonsKernelPath.Path(), + sizeof(path)); + strlcpy(path + length, name, strlen(image->name) + + 1 + (suffix - name)); - moduleImage->path = strdup(path); + moduleImage->path = strdup(path); + } else { + moduleImage->path = NULL; + // this will trigger B_NO_MEMORY, which is the only + // reason to get here anyways... + } } else moduleImage->path = strdup(image->name); } From haiku at kaldience.com Thu May 15 14:39:06 2008 From: haiku at kaldience.com (Maurice Kalinowski) Date: Thu, 15 May 2008 14:39:06 +0200 Subject: [Haiku-commits] r25505 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <20080515121744.M11872@mlotz.ch> References: <200805151046.m4FAkQMd009837@sheep.berlios.de> <20080515121744.M11872@mlotz.ch> Message-ID: <482C2EEA.3040703@kaldience.com> Michael Lotz wrote: > While this fixes the build I think it is not the right way to do it. These > functions are fine being static, they just don't really need to be extern. The > better way would be to remove the forward declarations instead and revert this > change. I will commit that in the next minutes. > Fine with me :) I wasn't sure which way should be the appropriate one and being in a so low-level area I assumed that it was supposed to be C. Thx for fixing it anyway. Maurice From marcusoverhagen at arcor.de Thu May 15 15:15:55 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 15 May 2008 15:15:55 +0200 (CEST) Subject: [Haiku-commits] r25505 - haiku/trunk/src/add-ons/kernel/drivers/network/usb_ecm In-Reply-To: <200805151046.m4FAkQMd009837@sheep.berlios.de> References: <200805151046.m4FAkQMd009837@sheep.berlios.de> Message-ID: <6608612.1210857355799.JavaMail.ngmail@webmail12> mauricek at BerliOS schrieb: > gcc4 build fix. > -static status_t > +extern "C" status_t Thats strange and should not be necessary. regards Marcus Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmf?hrer mit Movie Star Bewertungen von TV Movie. Au?erdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv From axeld at pinc-software.de Thu May 15 15:18:01 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 15 May 2008 15:18:01 +0200 CEST Subject: [Haiku-commits] r25511 - haiku/trunk/src/system/kernel In-Reply-To: <200805151228.m4FCSC6H026718@sheep.berlios.de> Message-ID: <16106089902-BeMail@zon> stippi at BerliOS wrote: > Another patch by Vasilis Kaoutsis: > * Use find_directory() for the hash for preloaded modules. I am not > sure this > patch is needed, since it only concerns the hash. Please review. Not really necessary. Same for the change in devfs.cpp AFAICT. But it shouldn't hurt either, as long as it doesn't fail :-) Bye, Axel. From axeld at mail.berlios.de Thu May 15 17:08:34 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 15 May 2008 17:08:34 +0200 Subject: [Haiku-commits] r25512 - haiku/trunk/src/tests/system/kernel/device_manager/playground Message-ID: <200805151508.m4FF8YxF011158@sheep.berlios.de> Author: axeld Date: 2008-05-15 17:08:33 +0200 (Thu, 15 May 2008) New Revision: 25512 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25512&view=rev Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp haiku/trunk/src/tests/system/kernel/device_manager/playground/specific_video_driver.cpp Log: This should be the last commit to this one, I'll next work on integrating it into the kernel: * Added device_removed() function to the device level as well. * A device_node now also tracks its published devices. * Made the driver API more consistent with the device API; instead of the node, they now get the driverCookie (so they now need to store the node themselves, the driver cookie could be retrieved via the node). Alternatively, one could either pass both, or have something similar to what Ingo did for the file systems, ie. pass a structure that contains both elements. Suggestions welcome. * Implemented device node replacement when a better driver becomes available: the new node (and its devices) is already published even though the old device is still in use. The new device is B_BUSY until the old one is closed. * Implemented an update cycle counter: this will prevent a device node from being probed again, if there is no new driver since the last time; eventually this will be moved into devfs, though. * Driver removal and replacement now works as expected in all tested scenarios (device removed, better driver installed, both with and without open device). Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-15 12:28:08 UTC (rev 25511) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/bus.cpp 2008-05-15 15:08:33 UTC (rev 25512) @@ -37,7 +37,7 @@ static float -supports_device(device_node *parent) +supports_device(device_node* parent) { const char* bus; if (gDeviceManager->get_attr_string(parent, B_DEVICE_BUS, &bus, false) @@ -52,7 +52,7 @@ static status_t -register_device(device_node *parent) +register_device(device_node* parent) { device_attr attrs[] = { {B_DEVICE_PRETTY_NAME, B_STRING_TYPE, {string: "My Bus"}}, @@ -66,7 +66,7 @@ static status_t -init_driver(device_node *node, void **_cookie) +init_driver(device_node* node, void** _cookie) { *_cookie = node; return B_OK; @@ -74,14 +74,16 @@ static void -uninit_driver(device_node *node) +uninit_driver(void* cookie) { } static status_t -register_child_devices(device_node *node) +register_child_devices(void* cookie) { + device_node* node = (device_node*)cookie; + const struct device_info { uint16 vendor; uint16 device; @@ -134,14 +136,14 @@ static status_t -rescan_child_devices(device_node *node) +rescan_child_devices(void* cookie) { return B_ERROR; } static void -device_removed(device_node *node) +device_removed(void* cookie) { } Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-15 12:28:08 UTC (rev 25511) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.cpp 2008-05-15 15:08:33 UTC (rev 25512) @@ -77,29 +77,44 @@ io_resource resource; // info about actual resource } io_resource_info; -struct device : DoublyLinkedListLinkImpl { - device() : node(NULL), path(NULL), module_name(NULL) {} - ~device() - { - free((char*)path); - free((char*)module_name); - } +class Device : public DoublyLinkedListLinkImpl { +public: + Device(device_node* node, const char* path, + const char* moduleName); + ~Device(); - device_node* node; - const char* path; - const char* module_name; + status_t InitCheck() const; + + device_node* Node() const { return fNode; } + const char* Path() const { return fPath; } + const char* ModuleName() const { return fModuleName; } + + status_t InitDevice(); + void UninitDevice(); + + device_module_info* DeviceModule() const { return fDeviceModule; } + void* DeviceData() const { return fDeviceData; } + +private: + device_node* fNode; + const char* fPath; + const char* fModuleName; + + int32 fInitialized; + device_module_info* fDeviceModule; + void* fDeviceData; }; -typedef DoublyLinkedList DeviceList; +typedef DoublyLinkedList DeviceList; typedef DoublyLinkedList NodeList; struct device_node : DoublyLinkedListLinkImpl { - device_node(const char *moduleName, - const device_attr *attrs, - const io_resource *resources); + device_node(const char* moduleName, + const device_attr* attrs, + const io_resource* resources); ~device_node(); - status_t InitCheck(); + status_t InitCheck() const; const char* ModuleName() const { return fModuleName; } device_node* Parent() const { return fParent; } @@ -121,13 +136,18 @@ void DeviceRemoved(); status_t Register(device_node* parent); - status_t Probe(const char* devicePath); + status_t Probe(const char* devicePath, uint32 updateCycle); bool IsRegistered() const { return fRegistered; } bool IsInitialized() const { return fInitialized > 0; } + uint32 Flags() const { return fFlags; } void Acquire(); bool Release(); + const DeviceList& Devices() const { return fDevices; } + void AddDevice(Device* device); + void RemoveDevice(Device* device); + int CompareTo(const device_attr* attributes) const; device_node* FindChild(const device_attr* attributes) const; device_node* FindChild(const char* moduleName) const; @@ -144,10 +164,13 @@ driver_module_info*& driver); status_t _FindBestDriver(const char* path, driver_module_info*& bestDriver, - float& bestSupport); + float& bestSupport, + device_node* previous = NULL); status_t _RegisterPath(const char* path); - status_t _RegisterDynamic(); + status_t _RegisterDynamic(device_node* previous = NULL); status_t _RemoveChildren(); + device_node* _FindCurrentChild(); + void _ReleaseWaiting(); device_node* fParent; NodeList fChildren; @@ -156,18 +179,23 @@ bool fRegistered; uint32 fFlags; float fSupportsParent; + uint32 fLastUpdateCycle; const char* fModuleName; driver_module_info* fDriver; void* fDriverData; + DeviceList fDevices; AttributeList fAttributes; }; // flags in addition to those specified by B_DEVICE_FLAGS enum node_flags { NODE_FLAG_REGISTER_INITIALIZED = 0x00010000, + NODE_FLAG_DEVICE_REMOVED = 0x00020000, + NODE_FLAG_OBSOLETE_DRIVER = 0x00040000, + NODE_FLAG_WAITING_FOR_DRIVER = 0x00080000, NODE_FLAG_PUBLIC_MASK = 0x0000ffff }; @@ -177,7 +205,7 @@ static device_node *sRootNode; static recursive_lock sLock; -static DeviceList sDeviceList; +static uint32 sDriverUpdateCycle = 1; // this is a *very* basic devfs emulation @@ -403,40 +431,157 @@ { printf("probe path \"%s\"\n", path); RecursiveLocker _(sLock); - return sRootNode->Probe(path); + return sRootNode->Probe(path, sDriverUpdateCycle); } static void close_path(void* cookie) { - struct device* device = (struct device*)cookie; + Device* device = (Device*)cookie; + if (device == NULL) + return; - printf("close path \"%s\" (node %p)\n", device->path, device->node); - device->node->UninitDriver(); + printf("close path \"%s\" (node %p)\n", device->Path(), device->Node()); + device->UninitDevice(); } -static void* -open_path(const char* path) +static Device* +get_device(device_node* node, const char* path) { - DeviceList::Iterator iterator = sDeviceList.GetIterator(); + DeviceList::ConstIterator iterator = node->Devices().GetIterator(); while (iterator.HasNext()) { - struct device* device = iterator.Next(); - if (!strcmp(device->path, path)) { - status_t status = device->node->InitDriver(); - if (status != B_OK) + Device* device = iterator.Next(); + if (!strcmp(device->Path(), path)) { + status_t status = device->InitDevice(); + if (status != B_OK) { + printf("opening path \"%s\" failed: %s\n", path, + strerror(status)); return NULL; + } - printf("open path \"%s\" (node %p)\n", device->path, device->node); + printf("open path \"%s\" (node %p)\n", device->Path(), + device->Node()); return device; } } + // search in children + + NodeList::ConstIterator nodeIterator = node->Children().GetIterator(); + while (nodeIterator.HasNext()) { + device_node* child = nodeIterator.Next(); + + Device* device = get_device(child, path); + if (device != NULL) + return device; + } + return NULL; } +static void* +open_path(const char* path) +{ + return get_device(sRootNode, path); +} + + +// #pragma mark - Device + + +Device::Device(device_node* node, const char* path, const char* moduleName) + : + fNode(node), + fInitialized(0), + fDeviceModule(NULL), + fDeviceData(NULL) +{ + fPath = strdup(path); + fModuleName = strdup(moduleName); +} + + +Device::~Device() +{ + free((char*)fPath); + free((char*)fModuleName); +} + + +status_t +Device::InitCheck() const +{ + return fPath != NULL && fModuleName != NULL ? B_OK : B_NO_MEMORY; +} + + +status_t +Device::InitDevice() +{ + if ((fNode->Flags() & NODE_FLAG_DEVICE_REMOVED) != 0) { + // TODO: maybe the device should be unlinked in devfs, too + return ENODEV; + } + if ((fNode->Flags() & NODE_FLAG_WAITING_FOR_DRIVER) != 0) + return B_BUSY; + + if (fInitialized++ > 0) { + fNode->InitDriver(); + // acquire another reference to our parent as well + return B_OK; + } + + status_t status = get_module(ModuleName(), (module_info**)&fDeviceModule); + if (status == B_OK) { + // our parent always has to be initialized + status = fNode->InitDriver(); + } + if (status < B_OK) { + fInitialized--; + return status; + } + + if (fDeviceModule->init_device != NULL) + status = fDeviceModule->init_device(fNode->DriverData(), &fDeviceData); + + if (status < B_OK) { + fNode->UninitDriver(); + fInitialized--; + + put_module(ModuleName()); + fDeviceModule = NULL; + fDeviceData = NULL; + } + + return status; +} + + +void +Device::UninitDevice() +{ + if (fInitialized-- > 1) { + fNode->UninitDriver(); + return; + } + + TRACE(("uninit driver for node %p\n", this)); + + if (fDeviceModule->uninit_device != NULL) + fDeviceModule->uninit_device(fDeviceData); + + fDeviceModule = NULL; + fDeviceData = NULL; + + put_module(ModuleName()); + + fNode->UninitDriver(); +} + + // #pragma mark - device_node @@ -456,6 +601,7 @@ fRegistered = false; fFlags = 0; fSupportsParent = 0.0; + fLastUpdateCycle = 0; fDriver = NULL; fDriverData = NULL; @@ -481,8 +627,14 @@ TRACE(("delete node %p\n", this)); ASSERT(DriverModule() == NULL); - if (Parent() != NULL) + if (Parent() != NULL) { + if ((fFlags & NODE_FLAG_OBSOLETE_DRIVER) != 0) { + // This driver has been obsoleted; another driver has been waiting + // for us - make it available + Parent()->_ReleaseWaiting(); + } Parent()->RemoveChild(this); + } // Delete children NodeList::Iterator nodeIterator = fChildren.GetIterator(); @@ -492,6 +644,15 @@ delete child; } + // Delete devices + DeviceList::Iterator deviceIterator = fDevices.GetIterator(); + while (deviceIterator.HasNext()) { + Device* device = deviceIterator.Next(); + deviceIterator.Remove(); + // TODO: unpublish! + delete device; + } + // Delete attributes AttributeList::Iterator attrIterator = fAttributes.GetIterator(); while (attrIterator.HasNext()) { @@ -505,7 +666,7 @@ status_t -device_node::InitCheck() +device_node::InitCheck() const { return fModuleName != NULL ? B_OK : B_NO_MEMORY; } @@ -565,7 +726,7 @@ TRACE(("uninit driver for node %p\n", this)); if (fDriver->uninit_driver != NULL) - fDriver->uninit_driver(this); + fDriver->uninit_driver(fDriverData); fDriver = NULL; fDriverData = NULL; @@ -849,14 +1010,19 @@ status_t device_node::_FindBestDriver(const char* path, driver_module_info*& bestDriver, - float& bestSupport) + float& bestSupport, device_node* previous) { if (bestDriver == NULL) - bestSupport = 0.0f; + bestSupport = previous != NULL ? previous->fSupportsParent : 0.0f; void* list = open_module_list_etc(path, "driver_v1"); driver_module_info* driver; while (_GetNextDriver(list, driver) == B_OK) { + if (previous != NULL && driver == previous->DriverModule()) { + put_module(driver->info.name); + continue; + } + float support = driver->supports_device(this); if (support > bestSupport) { if (bestDriver != NULL) @@ -914,7 +1080,7 @@ status_t -device_node::_RegisterDynamic() +device_node::_RegisterDynamic(device_node* previous) { // If this is our initial registration, we honour the B_FIND_CHILD_ON_DEMAND // requirements @@ -931,7 +1097,7 @@ void* cookie = NULL; while (_GetNextDriverPath(cookie, path) == B_OK) { - _FindBestDriver(path.Path(), bestDriver, bestSupport); + _FindBestDriver(path.Path(), bestDriver, bestSupport, previous); } if (bestDriver != NULL) { @@ -942,8 +1108,14 @@ // (usually only one at all, but there might be a new driver // "waiting" for its turn) device_node* child = FindChild(bestDriver->info.name); - if (child != NULL) + if (child != NULL) { child->fSupportsParent = bestSupport; + if (previous != NULL) { + previous->fFlags |= NODE_FLAG_OBSOLETE_DRIVER; + previous->Release(); + child->fFlags |= NODE_FLAG_WAITING_FOR_DRIVER; + } + } // TODO: if this fails, we could try the second best driver, // and so on... } @@ -961,37 +1133,59 @@ } +void +device_node::_ReleaseWaiting() +{ + NodeList::Iterator iterator = fChildren.GetIterator(); + while (iterator.HasNext()) { + device_node* child = iterator.Next(); + + child->fFlags &= ~NODE_FLAG_WAITING_FOR_DRIVER; + } +} + + status_t device_node::_RemoveChildren() { NodeList::Iterator iterator = fChildren.GetIterator(); while (iterator.HasNext()) { device_node* child = iterator.Next(); + child->Release(); + } - if (!child->IsInitialized()) { - // this child is not used currently, and can be removed safely - iterator.Remove(); - child->fParent = NULL; - child->Release(); + return fChildren.IsEmpty() ? B_OK : B_BUSY; +} - if (Release()) - panic("died early"); - } else - child->Release(); + +device_node* +device_node::_FindCurrentChild() +{ + NodeList::Iterator iterator = fChildren.GetIterator(); + while (iterator.HasNext()) { + device_node* child = iterator.Next(); + + if ((child->Flags() & NODE_FLAG_WAITING_FOR_DRIVER) == 0) + return child; } - return fChildren.IsEmpty() ? B_OK : B_BUSY; + return NULL; } status_t -device_node::Probe(const char* devicePath) +device_node::Probe(const char* devicePath, uint32 updateCycle) { + if ((fFlags & NODE_FLAG_DEVICE_REMOVED) != 0 + || updateCycle == fLastUpdateCycle) + return B_OK; + status_t status = InitDriver(); if (status < B_OK) return status; - MethodDeleter uninit(this, &device_node::UninitDriver); + MethodDeleter uninit(this, + &device_node::UninitDriver); uint16 type = 0; uint16 subType = 0; @@ -1015,17 +1209,26 @@ } if (matches) { - if (!fChildren.IsEmpty()) { - // We already have a driver that claims this node. - // Try to remove uninitialized children, so that this node - // can be re-evaluated - // TODO: try first if there is a better child! - // TODO: publish both devices, make new one busy as long - // as the old one is in use! - if (_RemoveChildren() != B_OK) - return B_OK; + device_node* previous = NULL; + + fLastUpdateCycle = updateCycle; + // This node will be probed in this update cycle + + if (!fChildren.IsEmpty() + && (fFlags & B_FIND_MULTIPLE_CHILDREN) == 0) { + // We already have a driver that claims this node; remove all + // (unused) nodes, and evaluate it again + _RemoveChildren(); + + previous = _FindCurrentChild(); + if (previous != NULL) { + // This driver is still active - give it back the reference + // that was stolen by _RemoveChildren() - _RegisterDynamic() + // will release it, if it really isn't needed anymore + previous->Acquire(); + } } - return _RegisterDynamic(); + return _RegisterDynamic(previous); } return B_OK; @@ -1035,7 +1238,7 @@ while (iterator.HasNext()) { device_node* child = iterator.Next(); - status = child->Probe(devicePath); + status = child->Probe(devicePath, updateCycle); if (status != B_OK) return status; } @@ -1077,6 +1280,7 @@ void device_node::DeviceRemoved() { + // notify children NodeList::ConstIterator iterator = Children().GetIterator(); while (iterator.HasNext()) { device_node* child = iterator.Next(); @@ -1084,6 +1288,18 @@ child->DeviceRemoved(); } + // notify devices + DeviceList::ConstIterator deviceIterator = Devices().GetIterator(); + while (deviceIterator.HasNext()) { + Device* device = deviceIterator.Next(); + + if (device->DeviceModule() != NULL + && device->DeviceModule()->device_removed != NULL) + device->DeviceModule()->device_removed(device->DeviceData()); + } + + fFlags |= NODE_FLAG_DEVICE_REMOVED; + if (IsInitialized() && DriverModule()->device_removed != NULL) DriverModule()->device_removed(this); @@ -1116,6 +1332,20 @@ } +void +device_node::AddDevice(Device* device) +{ + fDevices.Add(device); +} + + +void +device_node::RemoveDevice(Device* device) +{ + fDevices.Remove(device); +} + + int device_node::CompareTo(const device_attr* attributes) const { @@ -1154,7 +1384,9 @@ while (iterator.HasNext()) { device_node* child = iterator.Next(); - if (!child->CompareTo(attributes)) + // ignore nodes that are pending to be removed + if ((child->Flags() & NODE_FLAG_DEVICE_REMOVED) == 0 + && !child->CompareTo(attributes)) return child; } @@ -1269,6 +1501,12 @@ } +/*! Unregisters the device \a node. + + If the node is currently in use, this function will return B_BUSY to + indicate that the node hasn't been removed yet - it will still remove + the node as soon as possible. +*/ static status_t unregister_node(device_node* node) { @@ -1279,11 +1517,6 @@ node->DeviceRemoved(); - // TODO: We can't just remove it from its parent, as it might still be in - // use. However, we shouldn't really fail in this case, either. - // We should try to uninit the device - if it's just a bus, we can just do - // this. If it has devfs device, there are several options on how to do - // that (for example, by disconnecting the file descriptor). return initialized ? B_BUSY : B_OK; } @@ -1380,19 +1613,23 @@ static status_t publish_device(device_node *node, const char *path, const char *moduleName) { + if (path == NULL || !path[0] || moduleName == NULL || !moduleName[0]) + return B_BAD_VALUE; + RecursiveLocker _(sLock); dprintf("publish device: node %p, path %s, module %s\n", node, path, moduleName); - struct device* device = new(std::nothrow) ::device; + Device* device = new(std::nothrow) Device(node, path, moduleName); if (device == NULL) return B_NO_MEMORY; - device->node = node; - device->path = strdup(path); - device->module_name = strdup(moduleName); + if (device->InitCheck() != B_OK) { + delete device; + return B_NO_MEMORY; + } - sDeviceList.Add(device); + node->AddDevice(device); return B_OK; } @@ -1400,11 +1637,16 @@ static status_t unpublish_device(device_node *node, const char *path) { - DeviceList::Iterator iterator = sDeviceList.GetIterator(); + if (path == NULL) + return B_BAD_VALUE; + + RecursiveLocker _(sLock); + + DeviceList::ConstIterator iterator = node->Devices().GetIterator(); while (iterator.HasNext()) { - struct device* device = iterator.Next(); - if (!strcmp(device->path, path)) { - iterator.Remove(); + Device* device = iterator.Next(); + if (!strcmp(device->Path(), path)) { + node->RemoveDevice(device); delete device; return B_OK; } @@ -1642,8 +1884,7 @@ probe_path("net"); probe_path("graphics"); - void* graphicsHandle = open_path("graphics/generic/0"); -// void* netHandle = open_path("net/sample/0"); + void* netHandle = open_path("net/sample/0"); uninit_unused(); @@ -1651,14 +1892,26 @@ device_node* busNode = sRootNode->FindChild(BUS_MODULE_NAME); bus_trigger_device_removed(busNode); - close_path(graphicsHandle); -// close_path(netHandle); + close_path(netHandle); + // the net nodes must be removed with this call + void* graphicsHandle = open_path("graphics/generic/0"); + // add specific video driver - ie. simulate installing it _add_builtin_module((module_info*)&gSpecificVideoDriverModuleInfo); _add_builtin_module((module_info*)&gSpecificVideoDeviceModuleInfo); + sDriverUpdateCycle++; probe_path("graphics"); + open_path("graphics/specific/0"); + // this will fail + + close_path(graphicsHandle); + // the graphics drivers must be switched with this call + + graphicsHandle = open_path("graphics/specific/0"); + close_path(graphicsHandle); + uninit_unused(); recursive_lock_destroy(&sLock); Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-15 12:28:08 UTC (rev 25511) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/device_manager.h 2008-05-15 15:08:33 UTC (rev 25512) @@ -120,11 +120,11 @@ float (*supports_device)(device_node *parent); status_t (*register_device)(device_node *parent); - status_t (*init_driver)(device_node *node, void **_driverData); - void (*uninit_driver)(device_node *node); - status_t (*register_child_devices)(device_node *node); - status_t (*rescan_child_devices)(device_node *node); - void (*device_removed)(device_node *node); + status_t (*init_driver)(device_node *node, void **_driverCookie); + void (*uninit_driver)(void *driverCookie); + status_t (*register_child_devices)(void *driverCookie); + status_t (*rescan_child_devices)(void *driverCookie); + void (*device_removed)(void *driverCookie); }; @@ -160,8 +160,9 @@ struct device_module_info { module_info info; - status_t (*init_device)(device_node *node, void **_deviceCookie); + status_t (*init_device)(void *driverCookie, void **_deviceCookie); void (*uninit_device)(void *deviceCookie); + void (*device_removed)(void *deviceCookie); status_t (*device_open)(void *deviceCookie, int openMode, void **_cookie); status_t (*device_close)(void *cookie); Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-15 12:28:08 UTC (rev 25511) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/driver.cpp 2008-05-15 15:08:33 UTC (rev 25512) @@ -17,7 +17,7 @@ static float -supports_device(device_node *parent) +supports_device(device_node* parent) { #if 0 const char* bus; @@ -47,7 +47,7 @@ static status_t -register_device(device_node *parent) +register_device(device_node* parent) { return gDeviceManager->register_node(parent, DRIVER_MODULE_NAME, NULL, NULL, NULL); @@ -55,21 +55,24 @@ static status_t -init_driver(device_node *node, void **_cookie) +init_driver(device_node* node, void** _cookie) { + *_cookie = node; return B_OK; } static void -uninit_driver(device_node *node) +uninit_driver(void* cookie) { } static status_t -register_child_devices(device_node *node) +register_child_devices(void* cookie) { + device_node* node = (device_node*)cookie; + gDeviceManager->publish_device(node, "net/sample/0", DRIVER_DEVICE_MODULE_NAME); return B_OK; @@ -77,7 +80,7 @@ static void -device_removed(device_node *node) +driver_device_removed(void* cookie) { } @@ -86,23 +89,30 @@ static status_t -init_device(device_node *node, void **_deviceCookie) +init_device(void* driverCookie, void** _deviceCookie) { // called once before one or several open() calls - return B_ERROR; + return B_OK; } static void -uninit_device(void *deviceCookie) +uninit_device(void* deviceCookie) { // supposed to free deviceCookie, called when the last reference to // the device is closed } +static void +device_removed(void* deviceCookie) +{ + dprintf("network device removed!\n"); +} + + static status_t -device_open(void *deviceCookie, int openMode, void **_cookie) +device_open(void* deviceCookie, int openMode, void** _cookie) { // deviceCookie is an object attached to the published device return B_ERROR; @@ -110,42 +120,42 @@ static status_t -device_close(void *cookie) +device_close(void* cookie) { return B_ERROR; } static status_t -device_free(void *cookie) +device_free(void* cookie) { return B_ERROR; } static status_t -device_read(void *cookie, off_t pos, void *buffer, size_t *_length) +device_read(void* cookie, off_t pos, void* buffer, size_t* _length) { return B_ERROR; } static status_t -device_write(void *cookie, off_t pos, const void *buffer, size_t *_length) +device_write(void* cookie, off_t pos, const void* buffer, size_t* _length) { return B_ERROR; } static status_t -device_ioctl(void *cookie, int32 op, void *buffer, size_t length) +device_ioctl(void* cookie, int32 op, void* buffer, size_t length) { return B_ERROR; } static status_t -device_io(void *cookie, io_request *request) +device_io(void* cookie, io_request* request) { // new function to deal with I/O requests directly. return B_ERROR; @@ -168,7 +178,7 @@ uninit_driver, register_child_devices, NULL, - device_removed, + driver_device_removed, }; struct device_module_info gDeviceModuleInfo = { @@ -180,6 +190,7 @@ init_device, uninit_device, + device_removed, device_open, device_close, Modified: haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp 2008-05-15 12:28:08 UTC (rev 25511) +++ haiku/trunk/src/tests/system/kernel/device_manager/playground/generic_video_driver.cpp 2008-05-15 15:08:33 UTC (rev 25512) @@ -18,7 +18,7 @@ static float -supports_device(device_node *parent) +supports_device(device_node* parent) { bus_for_driver_module_info* module; void* data; @@ -40,7 +40,7 @@ static status_t -register_device(device_node *parent) +register_device(device_node* parent) { return gDeviceManager->register_node(parent, DRIVER_MODULE_NAME, NULL, NULL, NULL); @@ -48,21 +48,24 @@ static status_t -init_driver(device_node *node, void **_cookie) +init_driver(device_node* node, void** _cookie) { [... truncated: 240 lines follow ...] From revol at free.fr Thu May 15 17:40:05 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 15 May 2008 17:40:05 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r25512_-_haiku/trunk/src/tests/s?= =?windows-1252?q?ystem/kernel/device=5Fmanager/playground?= In-Reply-To: <200805151508.m4FF8YxF011158@sheep.berlios.de> Message-ID: <432809959-BeMail@laptop> > This should be the last commit to this one, I'll next work on > integrating it > into the kernel: Sorry I didn't have the time yet to look at it... > * Made the driver API more consistent with the device API; instead > of the node, > they now get the driverCookie (so they now need to store the node > themselves, > the driver cookie could be retrieved via the node). > Alternatively, one could either pass both, or have something > similar > to what > Ingo did for the file systems, ie. pass a structure that contains > both > elements. Suggestions welcome. One can also use cast or dereferencing of the 1st element, if you prefer keeping the device_node *: struct mydevice { device_node node; // must stay 1st int address, irq; ... }; ...open(...) { struct mydevice *c = malloc(sizeof(struct mydevice)); *cookie = &c.node; } Another otion is to have an opaque private ptr in the device_node, but that still requires casting (even if both can be allocated at once). Fran?ois. From bonefish at mail.berlios.de Thu May 15 22:47:43 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 15 May 2008 22:47:43 +0200 Subject: [Haiku-commits] r25513 - haiku/trunk/build/jam Message-ID: <200805152047.m4FKlhhx006706@sheep.berlios.de> Author: bonefish Date: 2008-05-15 22:47:42 +0200 (Thu, 15 May 2008) New Revision: 25513 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25513&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Added APR-util optional package. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-15 15:08:33 UTC (rev 25512) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-15 20:47:42 UTC (rev 25513) @@ -16,6 +16,7 @@ # package dependencies +OptionalPackageDependencies APR-util : APR ; OptionalPackageDependencies Development : Perl ; OptionalPackageDependencies OpenSSH : OpenSSL ; @@ -34,6 +35,20 @@ } +# APR-util +if [ IsOptionalHaikuImagePackageAdded APR-util ] { + if $(HAIKU_GCC_VERSION[1]) >= 4 { + Echo "No optional package APR-util available for gcc4" ; + } else { + local baseURL = http://haiku-files.org/files/optional-packages ; + InstallOptionalHaikuImagePackage apr-util-0.9.15-gcc2-2008-05-15 + : $(baseURL)/apr-util-0.9.15-gcc2-2008-05-15.zip + : + ; + } +} + + # Development if [ IsOptionalHaikuImagePackageAdded Development ] && $(TARGET_ARCH) = x86 { From bonefish at mail.berlios.de Thu May 15 22:50:44 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 15 May 2008 22:50:44 +0200 Subject: [Haiku-commits] r25514 - haiku/trunk/src/add-ons/kernel/network/protocols/unix Message-ID: <200805152050.m4FKoiDd006810@sheep.berlios.de> Author: bonefish Date: 2008-05-15 22:50:42 +0200 (Thu, 15 May 2008) New Revision: 25514 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25514&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp Log: * Corrected the read() behavior on a read-shutdown socket. All the data that arrived before the shutdown can still be read. * Debug some more returns. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-15 20:47:42 UTC (rev 25513) +++ haiku/trunk/src/add-ons/kernel/network/protocols/unix/UnixFifo.cpp 2008-05-15 20:50:42 UTC (rev 25514) @@ -311,8 +311,8 @@ TRACE("[%ld] %p->UnixFifo::Read(%p, %ld, %lld)\n", find_thread(NULL), this, vecs, vecCount, timeout); - if (IsReadShutdown()) - return UNIX_FIFO_SHUTDOWN; + if (IsReadShutdown() && fBuffer.Readable() == 0) + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); UnixRequest request(vecs, vecCount, NULL); fReaders.Add(&request); @@ -357,10 +357,10 @@ this, vecs, vecCount, ancillaryData, timeout); if (IsWriteShutdown()) - return UNIX_FIFO_SHUTDOWN; + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); if (IsReadShutdown()) - return EPIPE; + RETURN_ERROR(EPIPE); UnixRequest request(vecs, vecCount, ancillaryData); fWriters.Add(&request); @@ -444,7 +444,8 @@ if (fReaders.Head() != &request && timeout == 0) RETURN_ERROR(B_WOULD_BLOCK); - while (fReaders.Head() != &request && !IsReadShutdown()) { + while (fReaders.Head() != &request + && !(IsReadShutdown() && fBuffer.Readable() == 0)) { ConditionVariableEntry entry; fReadCondition.Add(&entry, B_CAN_INTERRUPT); @@ -456,10 +457,10 @@ RETURN_ERROR(error); } - if (IsReadShutdown()) - return UNIX_FIFO_SHUTDOWN; + if (fBuffer.Readable() == 0) { + if (IsReadShutdown()) + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); - if (fBuffer.Readable() == 0) { if (IsWriteShutdown()) RETURN_ERROR(0); @@ -482,12 +483,13 @@ RETURN_ERROR(error); } - if (IsReadShutdown()) - return UNIX_FIFO_SHUTDOWN; + if (fBuffer.Readable() == 0) { + if (IsReadShutdown()) + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); + if (IsWriteShutdown()) + RETURN_ERROR(0); + } - if (fBuffer.Readable() == 0 && IsWriteShutdown()) - RETURN_ERROR(0); - RETURN_ERROR(fBuffer.Read(request)); } @@ -512,10 +514,10 @@ } if (IsWriteShutdown()) - return UNIX_FIFO_SHUTDOWN; + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); if (IsReadShutdown()) - return EPIPE; + RETURN_ERROR(EPIPE); if (request.TotalSize() == 0) return 0; @@ -538,10 +540,10 @@ } if (IsWriteShutdown()) - return UNIX_FIFO_SHUTDOWN; + RETURN_ERROR(UNIX_FIFO_SHUTDOWN); if (IsReadShutdown()) - return EPIPE; + RETURN_ERROR(EPIPE); // write as much as we can error = fBuffer.Write(request); From bonefish at mail.berlios.de Thu May 15 23:06:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 15 May 2008 23:06:01 +0200 Subject: [Haiku-commits] r25515 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200805152106.m4FL61cR007760@sheep.berlios.de> Author: bonefish Date: 2008-05-15 23:05:59 +0200 (Thu, 15 May 2008) New Revision: 25515 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25515&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp Log: * Fixed read() on a read-shutdown socket. It must never wait. * Added TODO regarding read/write shutdown. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-15 20:50:42 UTC (rev 25514) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-15 21:05:59 UTC (rev 25515) @@ -702,8 +702,11 @@ if (direction == SHUT_RD || direction == SHUT_RDWR) fFlags |= FLAG_NO_RECEIVE; - if (direction == SHUT_WR || direction == SHUT_RDWR) + if (direction == SHUT_WR || direction == SHUT_RDWR) { + // TODO: That's not correct. After read/write shutting down the socket + // one should still be able to read previously arrived data. _Disconnect(false); + } return B_OK; } @@ -883,6 +886,9 @@ if ((flags & MSG_DONTWAIT) != 0 || socket->receive.timeout == 0) return B_WOULD_BLOCK; + if ((fFlags & FLAG_NO_RECEIVE) != 0) + return B_OK; + status_t status = fReceiveList.Wait(locker, timeout); if (status < B_OK) { // The Open Group base specification mentions that EINTR should be From korli at mail.berlios.de Fri May 16 00:07:42 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 16 May 2008 00:07:42 +0200 Subject: [Haiku-commits] r25516 - haiku/trunk/src/add-ons/kernel/bus_managers/acpi Message-ID: <200805152207.m4FM7gV9013998@sheep.berlios.de> Author: korli Date: 2008-05-16 00:07:42 +0200 (Fri, 16 May 2008) New Revision: 25516 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25516&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/Jamfile Log: fix the build Modified: haiku/trunk/src/add-ons/kernel/bus_managers/acpi/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/acpi/Jamfile 2008-05-15 21:05:59 UTC (rev 25515) +++ haiku/trunk/src/add-ons/kernel/bus_managers/acpi/Jamfile 2008-05-15 22:07:42 UTC (rev 25516) @@ -2,7 +2,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -UsePrivateHeaders kernel ; +UsePrivateKernelHeaders ; SubDirHdrs [ FDirName $(SUBDIR) include ] ; SubDirHdrs [ FDirName $(SUBDIR) include platform ] ; SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) pci ] ; From korli at mail.berlios.de Fri May 16 01:25:18 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 16 May 2008 01:25:18 +0200 Subject: [Haiku-commits] r25517 - haiku/trunk/src/bin Message-ID: <200805152325.m4FNPIdG026592@sheep.berlios.de> Author: korli Date: 2008-05-16 01:25:17 +0200 (Fri, 16 May 2008) New Revision: 25517 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25517&view=rev Modified: haiku/trunk/src/bin/ps.c Log: a waiting thread can wait on something else than a sem Modified: haiku/trunk/src/bin/ps.c =================================================================== --- haiku/trunk/src/bin/ps.c 2008-05-15 22:07:42 UTC (rev 25516) +++ haiku/trunk/src/bin/ps.c 2008-05-15 23:25:17 UTC (rev 25517) @@ -27,7 +27,7 @@ int32 thcookie; sem_info sinfo; char *thstate; - char *states[] = {"run", "rdy", "msg", "zzz", "sus", "sem" }; + char *states[] = {"run", "rdy", "msg", "zzz", "sus", "wait" }; system_info sysinfo; char *string_to_match; // match this in team name @@ -50,12 +50,12 @@ printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); thcookie = 0; while (get_next_thread_info(teaminfo.team, &thcookie, &thinfo) >= B_OK) { - if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING) + if (thinfo.state < B_THREAD_RUNNING || thinfo.state > B_THREAD_WAITING) thstate = "???"; else thstate = states[thinfo.state-1]; - printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); - if (thinfo.state == B_THREAD_WAITING) { + printf("%7ld %20s %4s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); + if (thinfo.state == B_THREAD_WAITING && thinfo.sem != -1) { status_t err = get_sem_info(thinfo.sem, &sinfo); if (!err) printf("%s(%ld)\n", sinfo.name, sinfo.sem); From korli at mail.berlios.de Fri May 16 01:37:34 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 16 May 2008 01:37:34 +0200 Subject: [Haiku-commits] r25518 - haiku/trunk/src/kits/interface Message-ID: <200805152337.m4FNbYYf011537@sheep.berlios.de> Author: korli Date: 2008-05-16 01:37:34 +0200 (Fri, 16 May 2008) New Revision: 25518 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25518&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: Patch from Shinta: don't send B_INPUT_METHOD_STOPPED when IM is not active fix bug #2220 Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2008-05-15 23:25:17 UTC (rev 25517) +++ haiku/trunk/src/kits/interface/TextView.cpp 2008-05-15 23:37:34 UTC (rev 25518) @@ -4568,12 +4568,13 @@ _BInlineInput_ *inlineInput = fInline; fInline = NULL; - if (inlineInput->IsActive() && Window()) + if (inlineInput->IsActive() && Window()) { _Refresh(inlineInput->Offset(), fText->Length() - inlineInput->Offset(), true, false); - BMessage message(B_INPUT_METHOD_EVENT); - message.AddInt32("be:opcode", B_INPUT_METHOD_STOPPED); - inlineInput->Method()->SendMessage(&message); + BMessage message(B_INPUT_METHOD_EVENT); + message.AddInt32("be:opcode", B_INPUT_METHOD_STOPPED); + inlineInput->Method()->SendMessage(&message); + } delete inlineInput; } From dlmcpaul at mail.berlios.de Fri May 16 04:29:12 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Fri, 16 May 2008 04:29:12 +0200 Subject: [Haiku-commits] r25519 - in haiku/trunk/src/add-ons/media/plugins: mov_reader mov_reader/libMOV mp4_reader mp4_reader/libMP4 Message-ID: <200805160229.m4G2TCPf024500@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-16 04:29:10 +0200 (Fri, 16 May 2008) New Revision: 25519 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25519&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp Log: set user data to contain codec id Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp 2008-05-15 23:37:34 UTC (rev 25518) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/libMOV/MOVParser.cpp 2008-05-16 02:29:10 UTC (rev 25519) @@ -817,7 +817,6 @@ Read(&aSoundDescriptionV1->desc.SampleRate); if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) { - printf("V1 Sound Description Found\n"); Read(&(aSoundDescriptionV1->samplesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerFrame)); @@ -826,14 +825,12 @@ } else { // Calculate? if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) { - printf("Calculating IMA4 Sound Description\n"); aSoundDescriptionV1->samplesPerPacket = 64; aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34; aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame; } else { - printf("Calculating Sound Description\n"); aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample; aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize; Modified: haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-15 23:37:34 UTC (rev 25518) +++ haiku/trunk/src/add-ons/media/plugins/mov_reader/mov_reader.cpp 2008-05-16 02:29:10 UTC (rev 25519) @@ -34,7 +34,7 @@ #include "mov_reader.h" -#define TRACE_MOV_READER +//#define TRACE_MOV_READER #ifdef TRACE_MOV_READER #define TRACE printf #else @@ -85,7 +85,7 @@ const char * movReader::Copyright() { - return "QUICKTIME & libMOV, " B_UTF8_COPYRIGHT " by David McPaul"; + return "mov_reader & libMOV, " B_UTF8_COPYRIGHT " by David McPaul"; } status_t @@ -331,6 +331,12 @@ format->SetMetaData(data, size); } + if (codecID != 0) { + // Put the codeid in the user data in case someone wants it + format->user_data_type = B_CODEC_TYPE_INFO; + *(uint32 *)format->user_data = codecID; format->user_data[4] = 0; + } + return B_OK; } @@ -406,6 +412,12 @@ format->SetMetaData(data, size); } + if (codecID != 0) { + // Put the codeid in the user data in case someone wants it + format->user_data_type = B_CODEC_TYPE_INFO; + *(uint32 *)format->user_data = codecID; format->user_data[4] = 0; + } + return B_OK; } Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp 2008-05-15 23:37:34 UTC (rev 25518) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp 2008-05-16 02:29:10 UTC (rev 25519) @@ -1182,8 +1182,8 @@ void WAVEAtom::OnOverrideAudioDescription(AudioDescription *pAudioDescription) { - pAudioDescription->codecSubType = 'alac'; - pAudioDescription->FrameSize = 4096; + pAudioDescription->codecSubType = 'mp3'; + pAudioDescription->FrameSize = 0; } void WAVEAtom::OnOverrideVideoDescription(VideoDescription *pVideoDescription) Modified: haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp 2008-05-15 23:37:34 UTC (rev 25518) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp 2008-05-16 02:29:10 UTC (rev 25519) @@ -89,7 +89,7 @@ const char * mp4Reader::Copyright() { - return "MPEG4 & libMP4, " B_UTF8_COPYRIGHT " by David McPaul"; + return "mp4_reader & libMP4, " B_UTF8_COPYRIGHT " by David McPaul"; } @@ -143,6 +143,8 @@ status_t mp4Reader::AllocateCookie(int32 streamNumber, void **_cookie) { + uint32 codecID = 0; + size_t size; const void *data; @@ -181,6 +183,7 @@ delete cookie; return B_ERROR; } + codecID = B_BENDIAN_TO_HOST_INT32(audio_format->compression); cookie->frame_count = theFileReader->getFrameCount(cookie->stream); cookie->duration = theFileReader->getAudioDuration(cookie->stream); @@ -289,6 +292,7 @@ format->u.encoded_audio.output.channel_count = audio_format->NoOfChannels; break; case 'mp4a': + codecID = B_BENDIAN_TO_HOST_INT32('aac '); case 'alac': TRACE("AAC audio (mp4a) or ALAC audio\n"); @@ -332,10 +336,6 @@ } } - // this doesn't seem to work (it's not even a fourcc) - format->user_data_type = B_CODEC_TYPE_INFO; - *(uint32 *)format->user_data = audio_format->compression; format->user_data[4] = 0; - // Set the DecoderConfigSize size = audio_format->DecoderConfigSize; data = audio_format->theDecoderConfig; @@ -355,6 +355,12 @@ } #endif + if (codecID != 0) { + // Put the codeid in the user data in case someone wants it + format->user_data_type = B_CODEC_TYPE_INFO; + *(uint32 *)format->user_data = codecID; format->user_data[4] = 0; + } + return B_OK; } @@ -366,6 +372,8 @@ return B_ERROR; } + codecID = B_BENDIAN_TO_HOST_INT32(video_format->compression); + cookie->audio = false; cookie->line_count = theFileReader->MovMainHeader()->height; @@ -406,9 +414,6 @@ if (B_OK != formats.GetFormatFor(description, format)) format->type = B_MEDIA_ENCODED_VIDEO; - format->user_data_type = B_CODEC_TYPE_INFO; - *(uint32 *)format->user_data = description.u.quicktime.codec; format->user_data[4] = 0; - // format->u.encoded_video.max_bit_rate = 8 * theFileReader->MovMainHeader()->max_bytes_per_sec; // format->u.encoded_video.avg_bit_rate = format->u.encoded_video.max_bit_rate / 2; // XXX fix this format->u.encoded_video.output.field_rate = cookie->frames_per_sec_rate / (float)cookie->frames_per_sec_scale; @@ -471,6 +476,12 @@ #endif } + if (codecID != 0) { + // Put the codeid in the user data in case someone wants it + format->user_data_type = B_CODEC_TYPE_INFO; + *(uint32 *)format->user_data = codecID; format->user_data[4] = 0; + } + return B_OK; } From dlmcpaul at mail.berlios.de Fri May 16 04:30:50 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Fri, 16 May 2008 04:30:50 +0200 Subject: [Haiku-commits] r25520 - haiku/trunk/src/apps/mediaplayer Message-ID: <200805160230.m4G2Uof3024673@sheep.berlios.de> Author: dlmcpaul Date: 2008-05-16 04:30:50 +0200 (Fri, 16 May 2008) New Revision: 25520 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25520&view=rev Modified: haiku/trunk/src/apps/mediaplayer/InfoWin.cpp Log: display codec id when codec not available\nSome layout changes too Modified: haiku/trunk/src/apps/mediaplayer/InfoWin.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/InfoWin.cpp 2008-05-16 02:29:10 UTC (rev 25519) +++ haiku/trunk/src/apps/mediaplayer/InfoWin.cpp 2008-05-16 02:30:50 UTC (rev 25520) @@ -34,7 +34,7 @@ #define NAME "File Info" -#define MIN_WIDTH 350 +#define MIN_WIDTH 400 #define BASE_HEIGHT (32 + 32) @@ -78,7 +78,7 @@ InfoWin::InfoWin(BPoint leftTop, Controller* controller) : BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1, - leftTop.y + 250), NAME, B_TITLED_WINDOW, + leftTop.y + 300), NAME, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE) , fController(controller) , fControllerObserver(new ControllerObserver(this, @@ -223,16 +223,16 @@ fLabelsView->SetText(""); fContentsView->SetText(""); fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue); - fLabelsView->Insert("\n"); + fLabelsView->Insert(" "); fContentsView->SetFontAndColor(be_plain_font, B_FONT_ALL); - fContentsView->Insert("\n"); +// fContentsView->Insert(""); fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kRed); status_t err; // video track format information if ((which & INFO_VIDEO) && fController->VideoTrackCount() > 0) { - fLabelsView->Insert("Video\n\n\n"); + fLabelsView->Insert("Video\n\n\n\n"); BString s; media_format format; media_raw_video_format videoFormat; @@ -243,9 +243,12 @@ videoFormat = format.u.encoded_video.output; media_codec_info mci; err = fController->GetVideoCodecInfo(&mci); - if (err < B_OK) - s << "(" << strerror(err) << ")"; - else + if (err < B_OK) { + s << "Haiku Media Kit:\n(" << strerror(err) << ")"; + if (format.user_data_type == B_CODEC_TYPE_INFO) { + s << (char *)format.user_data << " not supported"; + } + } else s << mci.pretty_name; //<< "(" << mci.short_name << ")"; } else if (format.type == B_MEDIA_RAW_VIDEO) { videoFormat = format.u.raw_video; @@ -262,7 +265,7 @@ // audio track format information if ((which & INFO_AUDIO) && fController->AudioTrackCount() > 0) { - fLabelsView->Insert("Audio\n\n\n"); + fLabelsView->Insert("Audio\n\n\n\n"); BString s; media_format format; media_raw_audio_format audioFormat; @@ -275,9 +278,12 @@ audioFormat = format.u.encoded_audio.output; media_codec_info mci; err = fController->GetAudioCodecInfo(&mci); - if (err < 0) - s << "(" << strerror(err) << ")"; - else + if (err < 0) { + s << "Haiku Media Kit:\n(" << strerror(err) << ") "; + if (format.user_data_type == B_CODEC_TYPE_INFO) { + s << (char *)format.user_data << " not supported"; + } + } else s << mci.pretty_name; //<< "(" << mci.short_name << ")"; } else if (format.type == B_MEDIA_RAW_AUDIO) { audioFormat = format.u.raw_audio; @@ -344,7 +350,7 @@ fContentsView->Insert("DrawBitmap\n"); fLabelsView->Insert("\n"); - fContentsView->Insert("\n"); + fContentsView->Insert("\n\n"); } if (which & INFO_TRANSPORT) { @@ -356,12 +362,12 @@ media_file_format ff; BString s; if (fController->GetFileFormatInfo(&ff) == B_OK) { - fLabelsView->Insert("Container\n\n"); + fLabelsView->Insert("Container\n"); s << ff.pretty_name; - s << "\n\n"; + s << "\n"; fContentsView->Insert(s.String()); } else - fContentsView->Insert("\n\n"); + fContentsView->Insert("\n"); fLabelsView->Insert("Location\n"); if (fController->GetLocation(&s) < B_OK) s = ""; @@ -389,7 +395,3 @@ ResizeToPreferred(); } - - - - From stippi at mail.berlios.de Fri May 16 10:47:38 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 16 May 2008 10:47:38 +0200 Subject: [Haiku-commits] r25521 - haiku/trunk/src/libs/icon Message-ID: <200805160847.m4G8lcVp004815@sheep.berlios.de> Author: stippi Date: 2008-05-16 10:47:38 +0200 (Fri, 16 May 2008) New Revision: 25521 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25521&view=rev Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp Log: Base the visibility decision for a shape (Level of Detail) on the global transform only, not combined with the shapes own scale, since that is likely not what the user intended. Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp =================================================================== --- haiku/trunk/src/libs/icon/IconRenderer.cpp 2008-05-16 02:30:50 UTC (rev 25520) +++ haiku/trunk/src/libs/icon/IconRenderer.cpp 2008-05-16 08:47:38 UTC (rev 25521) @@ -357,18 +357,17 @@ for (int32 i = 0; i < shapeCount; i++) { Shape* shape = fIcon->Shapes()->ShapeAtFast(i); + // don't render shape if the Level Of Detail falls out of range + if (fGlobalTransform.scale() < shape->MinVisibilityScale() + || fGlobalTransform.scale() > shape->MaxVisibilityScale()) + continue; + Transformation transform(*shape); transform.multiply(fGlobalTransform); // NOTE: this works only because "agg::trans_affine", // "Transformable" and "Transformation" are all the // same thing - // don't render shape if the Level Of Detail falls - // out of range - if (transform.scale() <= shape->MinVisibilityScale() - || transform.scale() > shape->MaxVisibilityScale()) - continue; - Style* style = shape->Style(); if (!style) continue; From stippi at mail.berlios.de Fri May 16 10:50:47 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 16 May 2008 10:50:47 +0200 Subject: [Haiku-commits] r25522 - haiku/trunk/src/libs/icon Message-ID: <200805160850.m4G8oljW004999@sheep.berlios.de> Author: stippi Date: 2008-05-16 10:50:45 +0200 (Fri, 16 May 2008) New Revision: 25522 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25522&view=rev Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp Log: Improved the coding style. Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp =================================================================== --- haiku/trunk/src/libs/icon/IconRenderer.cpp 2008-05-16 08:47:38 UTC (rev 25521) +++ haiku/trunk/src/libs/icon/IconRenderer.cpp 2008-05-16 08:50:45 UTC (rev 25522) @@ -84,9 +84,8 @@ private: template void _GenerateGradient(agg::rgba8* span, int x, int y, unsigned len, - GradientFunction function, int32 start, int32 end, - const agg::rgba8* gradientColors, - Transformation& gradientTransform); + GradientFunction function, int32 start, int32 end, + const agg::rgba8* gradientColors, Transformation& gradientTransform); BList fStyles; ::GammaTable& fGammaTable; @@ -105,10 +104,8 @@ } const rgb_color& c = styleItem->style->Color(); - fColor = agg::rgba8(fGammaTable.dir(c.red), - fGammaTable.dir(c.green), - fGammaTable.dir(c.blue), - c.alpha); + fColor = agg::rgba8(fGammaTable.dir(c.red), fGammaTable.dir(c.green), + fGammaTable.dir(c.blue), c.alpha); fColor.premultiply(); return fColor; } @@ -133,37 +130,37 @@ case GRADIENT_LINEAR: { agg::gradient_x function; _GenerateGradient(span, x, y, len, function, -64, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } case GRADIENT_CIRCULAR: { agg::gradient_radial function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } case GRADIENT_DIAMOND: { agg::gradient_diamond function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } case GRADIENT_CONIC: { agg::gradient_conic function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } case GRADIENT_XY: { agg::gradient_xy function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } case GRADIENT_SQRT_XY: { agg::gradient_sqrt_xy function; _GenerateGradient(span, x, y, len, function, 0, 64, colors, - styleItem->transformation); + styleItem->transformation); break; } } @@ -186,10 +183,8 @@ Interpolator interpolator(gradientTransform); ColorArray array(gradientColors); - GradientGenerator gradientGenerator(interpolator, - function, - array, - start, end); + GradientGenerator gradientGenerator(interpolator, function, array, + start, end); gradientGenerator.generate(span, x, y, len); } @@ -234,14 +229,11 @@ { // attach rendering buffer to bitmap fRenderingBuffer.attach((uint8*)bitmap->Bits(), - bitmap->Bounds().IntegerWidth() + 1, - bitmap->Bounds().IntegerHeight() + 1, - bitmap->BytesPerRow()); + bitmap->Bounds().IntegerWidth() + 1, + bitmap->Bounds().IntegerHeight() + 1, bitmap->BytesPerRow()); - fBaseRendererPre.clip_box(0, - 0, - fBitmap->Bounds().IntegerWidth(), - fBitmap->Bounds().IntegerHeight()); + fBaseRendererPre.clip_box(0, 0, fBitmap->Bounds().IntegerWidth(), + fBitmap->Bounds().IntegerHeight()); } // destructor @@ -335,10 +327,8 @@ return; // TODO: fix clip box for "clear" and "apply_gamma_inv" -// fBaseRendererPre.clip_box((int)floorf(r.left), -// (int)floorf(r.top), -// (int)ceilf(r.right), -// (int)ceilf(r.bottom)); +// fBaseRendererPre.clip_box((int)floorf(r.left), (int)floorf(r.top), +// (int)ceilf(r.right), (int)ceilf(r.bottom)); if (fBackground) memcpy(fBitmap->Bits(), fBackground->Bits(), fBitmap->BitsLength()); @@ -379,10 +369,9 @@ bool styleAdded = false; if (gradient && !gradient->InheritTransformation()) { styleAdded = styleHandler.AddStyle(shape->Style(), - fGlobalTransform); + fGlobalTransform); } else { - styleAdded = styleHandler.AddStyle(shape->Style(), - transform); + styleAdded = styleHandler.AddStyle(shape->Style(), transform); } if (!styleAdded) { @@ -424,12 +413,9 @@ void IconRenderer::_CommitRenderPass(StyleHandler& styleHandler, bool reset) { - agg::render_scanlines_compound(fRasterizer, - fScanline, - fBinaryScanline, - fBaseRendererPre, - fSpanAllocator, - styleHandler); + agg::render_scanlines_compound(fRasterizer, fScanline, fBinaryScanline, + fBaseRendererPre, fSpanAllocator, styleHandler); + if (reset) fRasterizer.reset(); } From marcusoverhagen at mail.berlios.de Sat May 17 00:17:22 2008 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 17 May 2008 00:17:22 +0200 Subject: [Haiku-commits] r25523 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200805162217.m4GMHM5W020809@sheep.berlios.de> Author: marcusoverhagen Date: 2008-05-17 00:17:21 +0200 (Sat, 17 May 2008) New Revision: 25523 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25523&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h Log: Added a "pcistatus" command to KDL that prints and clears the PCI device status register. Also clear the status register during init. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-05-16 08:50:45 UTC (rev 25522) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2008-05-16 22:17:21 UTC (rev 25523) @@ -248,6 +248,13 @@ } +static int +pcistatus(int argc, char **argv) +{ + sPCI->ClearDeviceStatus(NULL, true); + return 0; +} + // #pragma mark bus manager init/uninit status_t @@ -282,6 +289,8 @@ sPCI->InitDomainData(); sPCI->InitBus(); + add_debugger_command("pcistatus", &pcistatus, "dump and clear pci device status registers"); + return B_OK; } @@ -352,6 +361,7 @@ if (fRootBus) { DiscoverBus(fRootBus); RefreshDeviceInfo(fRootBus); + ClearDeviceStatus(fRootBus, false); } } @@ -651,6 +661,45 @@ void +PCI::ClearDeviceStatus(PCIBus *bus, bool dumpStatus) +{ + if (!bus) { + if (!fRootBus) + return; + bus = fRootBus; + } + + for (PCIDev *dev = bus->child; dev; dev = dev->next) { + uint16 status = ReadPciConfig(dev->domain, dev->bus, dev->dev, dev->func, PCI_status, 2); + if (dumpStatus) { + + kprintf("domain %u, bus %u, dev %2u, func %u, PCI device status 0x%04x\n", + dev->domain, dev->bus, dev->dev, dev->func, status); + if (status & (1 << 15)) + kprintf(" Detected Parity Error\n"); + if (status & (1 << 14)) + kprintf(" Signalled System Error\n"); + if (status & (1 << 13)) + kprintf(" Received Master-Abort\n"); + if (status & (1 << 12)) + kprintf(" Received Target-Abort\n"); + if (status & (1 << 11)) + kprintf(" Signalled Target-Abort\n"); + if (status & (1 << 8)) + kprintf(" Master Data Parity Error\n"); + } + WritePciConfig(dev->domain, dev->bus, dev->dev, dev->func, PCI_status, 2, status); + + if (dev->child) + ClearDeviceStatus(dev->child, dumpStatus); + } + + if (bus->next) + ClearDeviceStatus(bus->next, dumpStatus); +} + + +void PCI::DiscoverBus(PCIBus *bus) { FLOW("PCI: DiscoverBus, domain %u, bus %u\n", bus->domain, bus->bus); Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-05-16 08:50:45 UTC (rev 25522) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2008-05-16 22:17:21 UTC (rev 25523) @@ -83,6 +83,8 @@ status_t ResolveVirtualBus(uint8 virtualBus, int *domain, uint8 *bus); + void ClearDeviceStatus(PCIBus *bus, bool dumpStatus); + private: void EnumerateBus(int domain, uint8 bus, uint8 *subordinate_bus = NULL); From anevilyak at mail.berlios.de Sat May 17 00:31:36 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sat, 17 May 2008 00:31:36 +0200 Subject: [Haiku-commits] r25524 - haiku/trunk/build/jam Message-ID: <200805162231.m4GMVaNi024329@sheep.berlios.de> Author: anevilyak Date: 2008-05-17 00:31:35 +0200 (Sat, 17 May 2008) New Revision: 25524 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25524&view=rev Modified: haiku/trunk/build/jam/OptionalPackages Log: Add gcc4-compatible Vision optional package. Modified: haiku/trunk/build/jam/OptionalPackages =================================================================== --- haiku/trunk/build/jam/OptionalPackages 2008-05-16 22:17:21 UTC (rev 25523) +++ haiku/trunk/build/jam/OptionalPackages 2008-05-16 22:31:35 UTC (rev 25524) @@ -258,7 +258,12 @@ # Vision if [ IsOptionalHaikuImagePackageAdded Vision ] { if $(HAIKU_GCC_VERSION[1]) >= 4 { - Echo "No optional package Vision available for gcc4" ; + InstallOptionalHaikuImagePackage Vision + : http://vision.sf.net/Vision-0.9.7-H-30032008-gcc4.zip + : apps + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/apps/Vision-0.9.7-H-30032008/Vision ; } else { InstallOptionalHaikuImagePackage Vision : http://vision.sf.net/Vision-0.9.7-H-30032008.zip From bonefish at mail.berlios.de Sat May 17 12:21:39 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 17 May 2008 12:21:39 +0200 Subject: [Haiku-commits] r25525 - in haiku/trunk: headers/private/kernel src/add-ons/kernel/drivers/tty src/system/kernel src/system/kernel/fs Message-ID: <200805171021.m4HALdD0007704@sheep.berlios.de> Author: bonefish Date: 2008-05-17 12:21:37 +0200 (Sat, 17 May 2008) New Revision: 25525 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25525&view=rev Modified: haiku/trunk/headers/private/kernel/condition_variable.h haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp haiku/trunk/src/system/kernel/condition_variable.cpp haiku/trunk/src/system/kernel/fs/fifo.cpp haiku/trunk/src/system/kernel/team.cpp Log: axeld + bonefish: Changed condition variables so that it is allowed to block (e.g. lock mutexes etc.) between Add() and Wait(). This fixes #2059, since the block writer used them this way and could thusly fail to wait for a condition variable, causing a temporary stack object to be used past its lifetime. Modified: haiku/trunk/headers/private/kernel/condition_variable.h =================================================================== --- haiku/trunk/headers/private/kernel/condition_variable.h 2008-05-16 22:31:35 UTC (rev 25524) +++ haiku/trunk/headers/private/kernel/condition_variable.h 2008-05-17 10:21:37 UTC (rev 25525) @@ -27,9 +27,8 @@ inline ~ConditionVariableEntry(); #endif - bool Add(const void* object, uint32 flags = 0); - status_t Wait(uint32 timeoutFlags = 0, - bigtime_t timeout = 0); + bool Add(const void* object); + status_t Wait(uint32 flags = 0, bigtime_t timeout = 0); status_t Wait(const void* object, uint32 flags = 0, bigtime_t timeout = 0); @@ -42,6 +41,7 @@ private: ConditionVariable* fVariable; struct thread* fThread; + status_t fWaitStatus; friend class ConditionVariable; }; Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-16 22:31:35 UTC (rev 25524) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2008-05-17 10:21:37 UTC (rev 25525) @@ -414,14 +414,16 @@ // add an entry to wait on ConditionVariableEntry entry; - entry.Add(this, interruptable ? B_CAN_INTERRUPT : 0); + entry.Add(this); locker.Unlock(); // wait TRACE(("%p->RequestOwner::Wait(): waiting for condition...\n", this)); - error = entry.Wait(B_RELATIVE_TIMEOUT, timeout); + error = entry.Wait( + (interruptable ? B_CAN_INTERRUPT : 0) | B_RELATIVE_TIMEOUT, + timeout); TRACE(("%p->RequestOwner::Wait(): condition occurred: %lx\n", this, error)); Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2008-05-16 22:31:35 UTC (rev 25524) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2008-05-17 10:21:37 UTC (rev 25525) @@ -17,6 +17,10 @@ #include +#define STATUS_ADDED 1 +#define STATUS_WAITING 2 + + static const int kConditionVariableHashSize = 512; @@ -90,7 +94,7 @@ bool -ConditionVariableEntry::Add(const void* object, uint32 flags) +ConditionVariableEntry::Add(const void* object) { ASSERT(object != NULL); @@ -100,16 +104,12 @@ fVariable = sConditionVariableHash.Lookup(object); - thread_prepare_to_block(fThread, flags, - THREAD_BLOCK_TYPE_CONDITION_VARIABLE, fVariable); - if (fVariable == NULL) { - SpinLocker threadLocker(thread_spinlock); - thread_unblock_locked(fThread, B_ENTRY_NOT_FOUND); + fWaitStatus = B_ENTRY_NOT_FOUND; return false; } - // add to the queue for the variable + fWaitStatus = STATUS_ADDED; fVariable->fEntries.Add(this); return true; @@ -117,7 +117,7 @@ status_t -ConditionVariableEntry::Wait(uint32 timeoutFlags, bigtime_t timeout) +ConditionVariableEntry::Wait(uint32 flags, bigtime_t timeout) { if (!are_interrupts_enabled()) { panic("wait_for_condition_variable_entry() called with interrupts " @@ -127,15 +127,28 @@ InterruptsLocker _; + SpinLocker conditionLocker(sConditionVariablesLock); + + if (fVariable == NULL) + return fWaitStatus; + + thread_prepare_to_block(fThread, flags, + THREAD_BLOCK_TYPE_CONDITION_VARIABLE, fVariable); + + fWaitStatus = STATUS_WAITING; + + conditionLocker.Unlock(); + SpinLocker threadLocker(thread_spinlock); + status_t error; - if ((timeoutFlags & (B_RELATIVE_TIMEOUT | B_ABSOLUTE_TIMEOUT)) != 0) - error = thread_block_with_timeout_locked(timeoutFlags, timeout); + if ((flags & (B_RELATIVE_TIMEOUT | B_ABSOLUTE_TIMEOUT)) != 0) + error = thread_block_with_timeout_locked(flags, timeout); else error = thread_block_locked(thread_get_current_thread()); threadLocker.Unlock(); - SpinLocker locker(sConditionVariablesLock); + conditionLocker.Lock(); // remove entry from variable, if not done yet if (fVariable != NULL) { @@ -151,7 +164,7 @@ ConditionVariableEntry::Wait(const void* object, uint32 flags, bigtime_t timeout) { - if (Add(object, flags)) + if (Add(object)) return Wait(flags, timeout); return B_ENTRY_NOT_FOUND; } @@ -294,8 +307,14 @@ while (ConditionVariableEntry* entry = fEntries.RemoveHead()) { entry->fVariable = NULL; - thread_unblock_locked(entry->fThread, B_OK); + if (entry->fWaitStatus <= 0) + continue; + if (entry->fWaitStatus == STATUS_WAITING) + thread_unblock_locked(entry->fThread, result); + + entry->fWaitStatus = result; + if (!all) break; } Modified: haiku/trunk/src/system/kernel/fs/fifo.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fifo.cpp 2008-05-16 22:31:35 UTC (rev 25524) +++ haiku/trunk/src/system/kernel/fs/fifo.cpp 2008-05-17 10:21:37 UTC (rev 25525) @@ -358,13 +358,13 @@ return B_WOULD_BLOCK; ConditionVariableEntry entry; - entry.Add(this, B_CAN_INTERRUPT); + entry.Add(this); WriteRequest request(minToWrite); fWriteRequests.Add(&request); mutex_unlock(&fRequestLock); - status_t status = entry.Wait(); + status_t status = entry.Wait(B_CAN_INTERRUPT); mutex_lock(&fRequestLock); fWriteRequests.Remove(&request); Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-05-16 22:31:35 UTC (rev 25524) +++ haiku/trunk/src/system/kernel/team.cpp 2008-05-17 10:21:37 UTC (rev 25525) @@ -1867,7 +1867,7 @@ ConditionVariableEntry deadWaitEntry; if (status == B_WOULD_BLOCK && (flags & WNOHANG) == 0) - deadWaitEntry.Add(team->dead_children, B_CAN_INTERRUPT); + deadWaitEntry.Add(team->dead_children); locker.Unlock(); @@ -1888,7 +1888,7 @@ return status; } - status = deadWaitEntry.Wait(); + status = deadWaitEntry.Wait(B_CAN_INTERRUPT); if (status == B_INTERRUPTED) { T(WaitForChildDone(status)); return status; From superstippi at gmx.de Sat May 17 13:50:21 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 17 May 2008 13:50:21 +0200 Subject: [Haiku-commits] r25525 - in haiku/trunk: headers/private/kernel src/add-ons/kernel/drivers/tty src/system/kernel src/system/kernel/fs In-Reply-To: <200805171021.m4HALdD0007704@sheep.berlios.de> References: <200805171021.m4HALdD0007704@sheep.berlios.de> Message-ID: <20080517115021.320760@gmx.net> > Log: > axeld + bonefish: > Changed condition variables so that it is allowed to block (e.g. lock > mutexes etc.) between Add() and Wait(). This fixes #2059, since the > block writer used them this way and could thusly fail to wait for a > condition variable, causing a temporary stack object to be used past its > lifetime. Awesome news! As always, you guys have used your pair programming time very wisely! Thanks so much for fixing this! Best regards, -Stephan From bonefish at mail.berlios.de Sat May 17 13:56:25 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 17 May 2008 13:56:25 +0200 Subject: [Haiku-commits] r25526 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200805171156.m4HBuPne010568@sheep.berlios.de> Author: bonefish Date: 2008-05-17 13:56:25 +0200 (Sat, 17 May 2008) New Revision: 25526 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25526&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp Log: axeld + bonefish: _WaitForEstablished() must also accept states implying that the state has been established at some point. Fixes bug #2172. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-17 10:21:37 UTC (rev 25525) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-17 11:56:25 UTC (rev 25526) @@ -1117,7 +1117,7 @@ status_t TCPEndpoint::_WaitForEstablished(MutexLocker &locker, bigtime_t timeout) { - while (fState != ESTABLISHED) { + while (fState < ESTABLISHED) { if (socket->error != B_OK) return socket->error; From mmlr at mail.berlios.de Sat May 17 14:39:50 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sat, 17 May 2008 14:39:50 +0200 Subject: [Haiku-commits] r25527 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805171239.m4HCdo69014799@sheep.berlios.de> Author: mmlr Date: 2008-05-17 14:39:46 +0200 (Sat, 17 May 2008) New Revision: 25527 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25527&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_rh.cpp Log: * Getting familiar with the existing code * Cleanup (whitespace, nameing, code style) * Move around methods so they match the header order * Fix some obvious stuff * Initialize all members * Sync roothub code (this will be reworked to a common roothub) * Only minor functional changes (to the worse for now) Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-17 11:56:25 UTC (rev 25526) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-17 12:39:46 UTC (rev 25527) @@ -3,10 +3,11 @@ * Distributed under the terms of the MIT License. * * Authors: - * Jan-Rixt Van Hoye - * Salvatore Benedetto + * Jan-Rixt Van Hoye + * Salvatore Benedetto + * Michael Lotz */ - +#define TRACE_USB #include #include #include @@ -50,30 +51,34 @@ }; -//------------------------------------------------------ -// OHCI:: Reverse the bits in a value between 0 and 31 -// (Section 3.3.2) -//------------------------------------------------------ -static uint8 revbits[OHCI_NUMBER_OF_INTERRUPTS] = - { 0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0c, 0x1c, - 0x02, 0x12, 0x0a, 0x1a, 0x06, 0x16, 0x0e, 0x1e, - 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, - 0x03, 0x13, 0x0b, 0x1b, 0x07, 0x17, 0x0f, 0x1f }; - +// Reverse the bits in a value between 0 and 31 (Section 3.3.2) +static uint8 revbits[OHCI_NUMBER_OF_INTERRUPTS] = { + 0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0c, 0x1c, + 0x02, 0x12, 0x0a, 0x1a, 0x06, 0x16, 0x0e, 0x1e, + 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, + 0x03, 0x13, 0x0b, 0x1b, 0x07, 0x17, 0x0f, 0x1f +}; + OHCI::OHCI(pci_info *info, Stack *stack) : BusManager(stack), fPCIInfo(info), fStack(stack), + fOperationalRegisters(NULL), fRegisterArea(-1), fHccaArea(-1), + fHcca(NULL), + fInterruptEndpoints(NULL), fDummyControl(NULL), fDummyBulk(NULL), fDummyIsochronous(NULL), fFirstTransfer(NULL), fLastTransfer(NULL), + fFinishTransfersSem(-1), fFinishThread(-1), fStopFinishThread(false), + fHashGenericTable(NULL), + fHashIsochronousTable(NULL), fRootHub(NULL), fRootHubAddress(0), fPortCount(0) @@ -99,7 +104,7 @@ uint32 offset = sPCIModule->read_pci_config(fPCIInfo->bus, fPCIInfo->device, fPCIInfo->function, PCI_base_registers, 4); offset &= PCI_address_memory_32_mask; - TRACE(("usb_ohci: iospace offset: %lx\n", offset)); + TRACE(("usb_ohci: iospace offset: 0x%lx\n", offset)); fRegisterArea = map_physical_memory("OHCI memory mapped registers", (void *)offset, B_PAGE_SIZE, B_ANY_KERNEL_BLOCK_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA, @@ -109,31 +114,29 @@ return; } - TRACE(("usb_ohci: mapped operational registers: 0x%08lx\n", - *fOperationalRegisters)); + TRACE(("usb_ohci: mapped operational registers: %p\n", + fOperationalRegisters)); // Check the revision of the controller, which should be 10h uint32 revision = _ReadReg(OHCI_REVISION) & 0xff; TRACE(("usb_ohci: version %ld.%ld%s\n", OHCI_REVISION_HIGH(revision), - OHCI_REVISION_LOW(revision), OHCI_REVISION_LEGACY(revision) + OHCI_REVISION_LOW(revision), OHCI_REVISION_LEGACY(revision) ? ", legacy support" : "")); if (OHCI_REVISION_HIGH(revision) != 1 || OHCI_REVISION_LOW(revision) != 0) { TRACE_ERROR(("usb_ohci: unsupported OHCI revision\n")); return; } - // Set up the Host Controller Communications Area - // which is 256 bytes (2048 bits) and must be aligned void *hccaPhysicalAddress; fHccaArea = fStack->AllocateArea((void **)&fHcca, &hccaPhysicalAddress, - 2048, "USB OHCI Host Controller Communication Area"); + sizeof(ohci_hcca), "USB OHCI Host Controller Communication Area"); if (fHccaArea < B_OK) { TRACE_ERROR(("usb_ohci: unable to create the HCCA block area\n")); return; } - memset((void *)fHcca, 0, sizeof(ohci_hcca)); + memset(fHcca, 0, sizeof(ohci_hcca)); // Allocate hash tables fHashGenericTable = (ohci_general_td **) @@ -142,6 +145,7 @@ TRACE_ERROR(("usb_ohci: unable to allocate hash generic table\n")); return; } + fHashIsochronousTable = (ohci_isochronous_td **) malloc(sizeof(ohci_isochronous_td *) * OHCI_HASH_SIZE); if (fHashIsochronousTable == NULL) { @@ -183,7 +187,8 @@ _FreeEndpoint(fDummyIsochronous); return; } - for (uint32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) { + + for (int32 i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) { fInterruptEndpoints[i] = _AllocateEndpoint(); if (!fInterruptEndpoints[i]) { TRACE_ERROR(("ohci_usb: cannot allocate memory for" @@ -195,6 +200,7 @@ _FreeEndpoint(fDummyIsochronous); return; } + // Make them point all to the dummy isochronous endpoint fInterruptEndpoints[i]->flags |= OHCI_ENDPOINT_SKIP; fInterruptEndpoints[i]->next_physical_endpoint @@ -211,10 +217,11 @@ TRACE(("usb_ohci: SMM is in control of the host controller\n")); uint32 status = _ReadReg(OHCI_COMMAND_STATUS); _WriteReg(OHCI_COMMAND_STATUS, status | OHCI_OWNERSHIP_CHANGE_REQUEST); - for (uint32 i = 0; i < 100 && (control & OHCI_INTERRUPT_ROUTING); i++) { + for (uint32 i = 0; i < 100 && (control & OHCI_INTERRUPT_ROUTING); i++) { snooze(1000); control = _ReadReg(OHCI_CONTROL); } + if (!(control & OHCI_INTERRUPT_ROUTING)) { TRACE(("usb_ohci: SMM does not respond. Resetting...\n")); _WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET); @@ -242,12 +249,13 @@ for (uint32 i = 0; i < 10; i++) { spin(10); reset = _ReadReg(OHCI_COMMAND_STATUS) & OHCI_HOST_CONTROLLER_RESET; - if (!reset) + if (reset == 0) break; } + if (reset) { + restore_interrupts(former); TRACE_ERROR(("usb_ohci: Error resetting the host controller (timeout)\n")); - restore_interrupts(former); return; } @@ -281,7 +289,7 @@ // 90% periodic uint32 periodic = OHCI_PERIODIC(intervalValue); _WriteReg(OHCI_PERIODIC_START, periodic); - + // Fiddle the No Over Current Protection bit to avoid chip bug uint32 desca = _ReadReg(OHCI_RH_DESCRIPTOR_A); _WriteReg(OHCI_RH_DESCRIPTOR_A, desca | OHCI_RH_NO_OVER_CURRENT_PROTECTION); @@ -316,7 +324,7 @@ install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line, _InterruptHandler, (void *)this, 0); - TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n")); + TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n")); fInitOK = true; } @@ -328,30 +336,329 @@ delete_sem(fFinishTransfersSem); wait_for_thread(fFinishThread, &result); - if (fHccaArea > 0) + if (fHccaArea >= B_OK) delete_area(fHccaArea); - if (fRegisterArea > 0) + if (fRegisterArea >= B_OK) delete_area(fRegisterArea); - if (fHashGenericTable) - free(fHashGenericTable); - if (fHashIsochronousTable) - free(fHashIsochronousTable); - if (fDummyControl) - _FreeEndpoint(fDummyControl); - if (fDummyBulk) - _FreeEndpoint(fDummyBulk); - if (fDummyIsochronous) - _FreeEndpoint(fDummyIsochronous); - if (fRootHub) - delete fRootHub; - for (int i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) - if (fInterruptEndpoints[i]) + + free(fHashGenericTable); + free(fHashIsochronousTable); + + _FreeEndpoint(fDummyControl); + _FreeEndpoint(fDummyBulk); + _FreeEndpoint(fDummyIsochronous); + + if (fInterruptEndpoints != NULL) { + for (int i = 0; i < OHCI_NUMBER_OF_INTERRUPTS; i++) _FreeEndpoint(fInterruptEndpoints[i]); + } + delete [] fInterruptEndpoints; + delete fRootHub; + put_module(B_PCI_MODULE_NAME); } +status_t +OHCI::Start() +{ + TRACE(("usb_ohci: starting OHCI Host Controller\n")); + + if ((_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_MASK) + != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { + TRACE_ERROR(("usb_ohci: Controller not started!\n")); + return B_ERROR; + } else + TRACE(("usb_ohci: Controller is operational!\n")); + + fRootHubAddress = AllocateAddress(); + fRootHub = new(std::nothrow) OHCIRootHub(RootObject(), fRootHubAddress); + if (!fRootHub) { + TRACE_ERROR(("usb_ohci: no memory to allocate root hub\n")); + return B_NO_MEMORY; + } + + if (fRootHub->InitCheck() < B_OK) { + TRACE_ERROR(("usb_ohci: root hub failed init check\n")); + return B_ERROR; + } + + SetRootHub(fRootHub); + TRACE(("usb_ohci: Host Controller started\n")); + return BusManager::Start(); +} + + +status_t +OHCI::SubmitTransfer(Transfer *transfer) +{ + // short circuit the root hub + if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) + return fRootHub->ProcessTransfer(this, transfer); + + uint32 type = transfer->TransferPipe()->Type(); + if ((type & USB_OBJECT_CONTROL_PIPE)) { + TRACE(("usb_ohci: submitting control request\n")); + return _SubmitControlTransfer(transfer); + } + + if ((type & USB_OBJECT_BULK_PIPE)) { + TRACE(("usb_ohci: submitting bulk transfer\n")); + return _SubmitBulkTransfer(transfer); + } + + if (((type & USB_OBJECT_ISO_PIPE) || (type & USB_OBJECT_INTERRUPT_PIPE))) { + TRACE(("usb_ohci: submitting periodic transfer\n")); + return _SubmitPeriodicTransfer(transfer); + } + + TRACE_ERROR(("usb_ohci: tried to submit transfer for unknown pipe" + " type %lu\n", type)); + return B_ERROR; +} + + +status_t +OHCI::CancelQueuedTransfers(Pipe *pipe, bool force) +{ + if (pipe->Type() & USB_OBJECT_ISO_PIPE) + return _CancelQueuedIsochronousTransfers(pipe, force); + + if (!Lock()) + return B_ERROR; + + transfer_data *current = fFirstTransfer; + while (current) { + if (current->transfer->TransferPipe() == pipe) { + // Check if the skip bit is already set + if (!(current->endpoint->flags & OHCI_ENDPOINT_SKIP)) { + current->endpoint->flags |= OHCI_ENDPOINT_SKIP; + // In case the controller is processing + // this endpoint, wait for it to finish + snooze(1000); + } + + // Clear the endpoint + current->endpoint->head_logical_descriptor = NULL; + current->endpoint->head_physical_descriptor = 0; + current->endpoint->tail_logical_descriptor = NULL; + current->endpoint->tail_physical_descriptor = 0; + + if (!force) { + // If the transfer is canceled by force, the one causing the + // cancel is probably not the one who initiated the transfer + // and the callback is likely not safe anymore + current->transfer->Finished(B_CANCELED, 0); + } + current->canceled = true; + } + current = current->link; + } + + Unlock(); + + // notify the finisher so it can clean up the canceled transfers + release_sem_etc(fFinishTransfersSem, 1, B_DO_NOT_RESCHEDULE); + return B_OK; +} + + +status_t +OHCI::NotifyPipeChange(Pipe *pipe, usb_change change) +{ + TRACE(("usb_ohci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe)); + if (pipe->DeviceAddress() == fRootHubAddress) { + // no need to insert/remove endpoint descriptors for the root hub + return B_OK; + } + + switch (change) { + case USB_CHANGE_CREATED: { + TRACE(("usb_ohci: inserting endpoint\n")); + return _InsertEndpointForPipe(pipe); + } + + case USB_CHANGE_DESTROYED: { + TRACE(("usb_ohci: removing endpoint\n")); + return _RemoveEndpointForPipe(pipe); + } + + case USB_CHANGE_PIPE_POLICY_CHANGED: { + TRACE(("usb_ohci: pipe policy changing unhandled!\n")); + break; + } + + default: { + TRACE_ERROR(("usb_ohci: unknown pipe change!\n")); + return B_ERROR; + } + } + + return B_OK; +} + + +status_t +OHCI::AddTo(Stack *stack) +{ +#ifdef TRACE_USB + set_dprintf_enabled(true); +#ifndef __HAIKU__ + load_driver_symbols("ohci"); +#endif +#endif + + if (!sPCIModule) { + status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule); + if (status < B_OK) { + TRACE_ERROR(("usb_ohci: getting pci module failed! 0x%08lx\n", + status)); + return status; + } + } + + TRACE(("usb_ohci: searching devices\n")); + bool found = false; + pci_info *item = new(std::nothrow) pci_info; + if (!item) { + sPCIModule = NULL; + put_module(B_PCI_MODULE_NAME); + return B_NO_MEMORY; + } + + for (uint32 i = 0 ; sPCIModule->get_nth_pci_info(i, item) >= B_OK; i++) { + if (item->class_base == PCI_serial_bus && item->class_sub == PCI_usb + && item->class_api == PCI_usb_ohci) { + if (item->u.h0.interrupt_line == 0 + || item->u.h0.interrupt_line == 0xFF) { + TRACE_ERROR(("usb_ohci: found device with invalid IRQ -" + " check IRQ assignement\n")); + continue; + } + + TRACE(("usb_ohci: found device at IRQ %u\n", + item->u.h0.interrupt_line)); + OHCI *bus = new(std::nothrow) OHCI(item, stack); + if (!bus) { + delete item; + sPCIModule = NULL; + put_module(B_PCI_MODULE_NAME); + return B_NO_MEMORY; + } + + if (bus->InitCheck() < B_OK) { + TRACE_ERROR(("usb_ohci: bus failed init check\n")); + delete bus; + continue; + } + + // the bus took it away + item = new(std::nothrow) pci_info; + + bus->Start(); + stack->AddBusManager(bus); + found = true; + } + } + + if (!found) { + TRACE_ERROR(("usb_ohci: no devices found\n")); + delete item; + sPCIModule = NULL; + put_module(B_PCI_MODULE_NAME); + return ENODEV; + } + + delete item; + return B_OK; +} + + +status_t +OHCI::GetPortStatus(uint8 index, usb_port_status *status) +{ + TRACE(("usb_ohci::%s(%ud, )\n", __FUNCTION__, index)); + if (index >= fPortCount) + return B_BAD_INDEX; + + status->status = status->change = 0; + uint32 portStatus = _ReadReg(OHCI_RH_PORT_STATUS(index)); + + // status + if (portStatus & OHCI_RH_PORTSTATUS_CCS) + status->status |= PORT_STATUS_CONNECTION; + if (portStatus & OHCI_RH_PORTSTATUS_PES) + status->status |= PORT_STATUS_ENABLE; + if (portStatus & OHCI_RH_PORTSTATUS_PRS) + status->status |= PORT_STATUS_RESET; + if (portStatus & OHCI_RH_PORTSTATUS_LSDA) + status->status |= PORT_STATUS_LOW_SPEED; + if (portStatus & OHCI_RH_PORTSTATUS_PSS) + status->status |= PORT_STATUS_SUSPEND; + if (portStatus & OHCI_RH_PORTSTATUS_POCI) + status->status |= PORT_STATUS_OVER_CURRENT; + if (portStatus & OHCI_RH_PORTSTATUS_PPS) + status->status |= PORT_STATUS_POWER; + + // change + if (portStatus & OHCI_RH_PORTSTATUS_CSC) + status->change |= PORT_STATUS_CONNECTION; + if (portStatus & OHCI_RH_PORTSTATUS_PESC) + status->change |= PORT_STATUS_ENABLE; + if (portStatus & OHCI_RH_PORTSTATUS_PSSC) + status->change |= PORT_STATUS_SUSPEND; + if (portStatus & OHCI_RH_PORTSTATUS_OCIC) + status->change |= PORT_STATUS_OVER_CURRENT; + if (portStatus & OHCI_RH_PORTSTATUS_PRSC) + status->change |= PORT_STATUS_RESET; + + return B_OK; +} + + +status_t +OHCI::SetPortFeature(uint8 index, uint16 feature) +{ + TRACE(("usb_ohci: set port feature index %ud feature %ud)\n", index, feature)); + if (index > fPortCount) + return B_BAD_INDEX; + + switch (feature) { + case PORT_RESET: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PRS); + return B_OK; + + case PORT_POWER: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PPS); + return B_OK; + } + + return B_BAD_VALUE; +} + + +status_t +OHCI::ClearPortFeature(uint8 index, uint16 feature) +{ + TRACE(("usb_ohci: clear port feature index %ud feature %ud\n", index, feature)); + if (index > fPortCount) + return B_BAD_INDEX; + + switch (feature) { + case C_PORT_RESET: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); + return B_OK; + + case C_PORT_CONNECTION: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); + return B_OK; + } + + return B_BAD_VALUE; +} + + int32 OHCI::_InterruptHandler(void *data) { @@ -366,7 +673,6 @@ acquire_spinlock(&lock); uint32 status = 0; - uint32 acknowledge = 0; bool finishTransfers = false; int32 result = B_HANDLED_INTERRUPT; @@ -377,7 +683,7 @@ // HcInterruptStatus register needs to be accessed to determine that exact // interrupt cause. If HccDoneHead is nonzero, then a done list update // interrupt is indicated and if the LSb of the Dword is nonzero, then an - // additional interrupt event is indicated and HcInterruptStatus shuold be + // additional interrupt event is indicated and HcInterruptStatus should be // checked to determine its cause. uint32 doneHead = fHcca->done_head; if (doneHead != 0) { @@ -433,16 +739,100 @@ } +status_t +OHCI::_AddPendingTransfer(Transfer *transfer, ohci_endpoint_descriptor *endpoint, + ohci_general_td *firstDescriptor, ohci_general_td *dataDescriptor, bool directionIn) +{ + if (!transfer || !endpoint || !firstDescriptor) + return B_BAD_VALUE; + + transfer_data *data = new(std::nothrow) transfer_data; + if (!data) + return B_NO_MEMORY; + + status_t result = transfer->InitKernelAccess(); + if (result < B_OK) { + delete data; + return result; + } + + data->transfer = transfer; + data->endpoint = endpoint; + data->first_descriptor = firstDescriptor; + data->data_descriptor = dataDescriptor; + data->incoming = directionIn; + data->canceled = false; + data->link = NULL; + + if (!Lock()) { + delete data; + return B_ERROR; + } + + if (fLastTransfer) + fLastTransfer->link = data; + else + fFirstTransfer = data; + + fLastTransfer = data; + Unlock(); + + return B_OK; +} + + +status_t +OHCI::_CancelQueuedIsochronousTransfers(Pipe *pipe, bool force) +{ + // TODO + return B_ERROR; +} + + +status_t +OHCI::_UnlinkTransfer(transfer_data *transfer) +{ + if (!Lock()) + return B_ERROR; + + if (transfer == fFirstTransfer) { + // It was the first element + fFirstTransfer = fFirstTransfer->link; + if (transfer == fLastTransfer) { + // Also the only one + fLastTransfer = NULL; + } + } else { + transfer_data *current = fFirstTransfer->link; + transfer_data *previous = fFirstTransfer; + while (current != NULL) { + if (current == transfer) { + previous->link = current->link; + if (current == fLastTransfer) + fLastTransfer = previous; + break; + } + + previous = current; + current = current->link; + } + } + + Unlock(); + return B_OK; +} + + int32 OHCI::_FinishThread(void *data) { - ((OHCI *)data)->_FinishTransfer(); + ((OHCI *)data)->_FinishTransfers(); return B_OK; } void -OHCI::_FinishTransfer() +OHCI::_FinishTransfers() { while (!fStopFinishThread) { if (acquire_sem(fFinishTransfersSem) < B_OK) @@ -454,37 +844,41 @@ if (semCount > 0) acquire_sem_etc(fFinishTransfersSem, semCount, B_RELATIVE_TIMEOUT, 0); - uint32 done_list = fHcca->done_head & ~OHCI_DONE_INTERRUPTS; + uint32 doneList = fHcca->done_head & ~OHCI_DONE_INTERRUPTS; // If done_head is zero, there are not processed descriptors // in the done list and we have been woken up by CancelQueuedTransfers // or CancelQueuedIsochronousTransfers in order to do some clean up // and back to sleep. - if (done_list) { + if (doneList) { // Pull out the done list and reverse its order // for both general and isochronous descriptors - ohci_general_td *current, *top; - ohci_isochronous_td *isoCurrent, *isoTop; - for ( top = NULL, isoTop = NULL ; done_list != 0; ) { - if ((current = _FindDescriptorInHash(done_list))) { - done_list = current->next_physical_descriptor; + ohci_general_td *current = NULL; + ohci_general_td *top = NULL; + ohci_isochronous_td *isoCurrent = NULL; + ohci_isochronous_td *isoTop = NULL; + while (doneList != 0) { + current = _FindDescriptorInHash(doneList); + if (current != NULL) { + doneList = current->next_physical_descriptor; current->next_done_descriptor = (void *)top; top = current; continue; } - if ((isoCurrent = _FindIsoDescriptorInHash(done_list))) { - done_list = isoCurrent->next_physical_descriptor; + + isoCurrent = _FindIsoDescriptorInHash(doneList); + if (isoCurrent != NULL) { + doneList = isoCurrent->next_physical_descriptor; isoCurrent->next_done_descriptor = (void *)isoTop; isoTop = isoCurrent; continue; } - // TODO: Should I panic here? :) - TRACE_ERROR(("usb_ohci: address 0x%08lx not found!\n", - done_list)); + + TRACE_ERROR(("usb_ohci: address 0x%08lx not found!\n", doneList)); break; } // Acknowledge the interrupt - // TODO: Move the acknowledgement in the interrupt handler. + // TODO: Move the acknowledgement in the interrupt handler. // The done_head value can be passed through a shared variable. fHcca->done_head = 0; _WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_WRITEBACK_DONE_HEAD); @@ -496,7 +890,7 @@ } // Now process the general list - for (current = top; current != NULL; ) { + for (current = top; current != NULL;) { ohci_general_td *next = (ohci_general_td *)current->next_done_descriptor; @@ -516,12 +910,12 @@ // endpoint. // NOTE: There can(should) not be more than one // invalid descriptor from the same transfer in the - // done list, as the controller halt the endpoint right + // done list, as the controller halts the endpoint right // away if a descriptor fails. This means that, if we reversed // the order of the done list (which we did), there is - // not reason to look for more failed descriptors in the + // no reason to look for more failed descriptors in the // done list from the same transfer, as *BSD code does. - TRACE(("usb_ohci: transfer failed! ohci error code: %d\n", + TRACE_ERROR(("usb_ohci: transfer failed! ohci error code: %lu\n", conditionCode)); // Remove remaining descriptors from the same transfer @@ -531,7 +925,6 @@ // TODO: Fix the following with the appropriate error callbackStatus = B_DEV_MULTIPLE_ERRORS; transferDone = true; - continue; } else if (current->is_last) transferDone = true; @@ -541,29 +934,28 @@ if (transfer->data_descriptor && transfer->incoming) { // Read data out } else { - // How much was transfer? + // How much was transfered? } + if (transfer->transfer->IsFragmented()) { // TODO } } + _UnlinkTransfer(transfer); transfer->transfer->Finished(callbackStatus, actualLength); - // Update next before current gets deleted next = (ohci_general_td *)current->next_done_descriptor; _FreeDescriptorChain(transfer->first_descriptor); delete transfer->transfer; delete transfer; + } - } current = next; } - } - // Quick look for canceled transfer before - // we go back to sleep + // Quickly look for canceled transfer before we go back to sleep transfer_data *current = fFirstTransfer; while (current) { transfer_data *next = current->link; @@ -580,193 +972,8 @@ status_t -OHCI::_AppendChainDescriptorsToEndpoint(ohci_endpoint_descriptor *endpoint, - ohci_general_td *first, ohci_general_td *last) +OHCI::_SubmitControlTransfer(Transfer *transfer) { - endpoint->flags |= OHCI_ENDPOINT_SKIP; - snooze(1000); - - // TODO: Lock on endpoint - ohci_general_td *head = (ohci_general_td *)endpoint->head_logical_descriptor; - ohci_general_td *tail = (ohci_general_td *)endpoint->tail_logical_descriptor; - if (head != tail) { - // Find the last real descriptor - ohci_general_td *current = head; - while (current->next_logical_descriptor != tail) - current = (ohci_general_td *)current->next_logical_descriptor; - // Append to current - current->next_logical_descriptor = first; - current->next_physical_descriptor = first->physical_address; - } else { - // Endpoint has only the dummy descriptor - endpoint->head_logical_descriptor = first; - endpoint->head_physical_descriptor = first->physical_address; - } - - // Make the last descriptor point to the dummy - last->next_logical_descriptor = tail; - last->next_physical_descriptor = tail->physical_address; - - endpoint->flags &= ~OHCI_ENDPOINT_SKIP; - return B_OK; -} - - -void -OHCI::_RemoveTransferFromEndpoint(transfer_data *transfer) -{ - // TODO: Add lock for endpoint - ohci_endpoint_descriptor *endpoint = transfer->endpoint; - ohci_general_td *next = (ohci_general_td *)endpoint->head_logical_descriptor; - - // Find the first descriptor of a different transfer. - // Worst scenario we get the dummy descriptor - while ((transfer_data *)next->transfer == transfer) - next = (ohci_general_td *)next->next_logical_descriptor; - // Update head - endpoint->head_logical_descriptor = next; - endpoint->head_physical_descriptor = next->physical_address; -} - - -status_t -OHCI::_UnlinkTransfer(transfer_data *transfer) -{ - if (Lock()) { - if (transfer == fFirstTransfer) { - // It was the first element - fFirstTransfer = fFirstTransfer->link; - if (transfer == fLastTransfer) - // Also the only one - fLastTransfer = NULL; - } else { - transfer_data *data = fFirstTransfer->link; - transfer_data *previous = fFirstTransfer; - while (data != NULL) { - if (data == transfer) { - previous->link = data->link; - if (data == fLastTransfer) - fLastTransfer = previous; - break; - } - previous = data; - data = data->link; - } - } - Unlock(); - return B_OK; - } - return B_ERROR; -} - - -void -OHCI::_AddDescriptorToHash(ohci_general_td *descriptor) -{ - // TODO -} - - -void -OHCI::_RemoveDescriptorFromHash(ohci_general_td *descriptor) -{ - // TODO -} - - -ohci_general_td* -OHCI::_FindDescriptorInHash(uint32 physicalAddress) -{ - // TODO - return NULL; -} - - -void -OHCI::_AddIsoDescriptorToHash(ohci_isochronous_td *descriptor) -{ - // TODO -} - - -void -OHCI::_RemoveIsoDescriptorFromHash(ohci_isochronous_td *descriptor) -{ - // TODO -} - - -ohci_isochronous_td* -OHCI::_FindIsoDescriptorInHash(uint32 physicalAddress) -{ - // TODO - return NULL; -} - - -status_t -OHCI::Start() -{ - TRACE(("usb_ohci: starting OHCI Host Controller\n")); - - if ((_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_MASK) - != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { - TRACE_ERROR(("usb_ohci: Controller not started!\n")); - return B_ERROR; - } else { - TRACE(("usb_ohci: Controller is OPERATIONAL!\n")); - } - - fRootHubAddress = AllocateAddress(); - fRootHub = new(std::nothrow) OHCIRootHub(RootObject(), fRootHubAddress); - if (!fRootHub) { - TRACE_ERROR(("usb_ohci: no memory to allocate root hub\n")); - return B_NO_MEMORY; - } - - if (fRootHub->InitCheck() < B_OK) { - TRACE_ERROR(("usb_ohci: root hub failed init check\n")); - return B_ERROR; - } - - SetRootHub(fRootHub); - TRACE(("usb_ohci: Host Controller started\n")); - return BusManager::Start(); -} - - -status_t -OHCI::SubmitTransfer(Transfer *transfer) -{ - // short circuit the root hub - if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) - return fRootHub->ProcessTransfer(this, transfer); - - uint32 type = transfer->TransferPipe()->Type(); - if ((type & USB_OBJECT_CONTROL_PIPE)) { - TRACE(("usb_ohci: submitting control request\n")); - return _SubmitControlRequest(transfer); - } - - if ((type & USB_OBJECT_BULK_PIPE)) { - TRACE(("usb_ohci: submitting bulk transfer\n")); - return _SubmitBulkTransfer(transfer); - } - - if (((type & USB_OBJECT_ISO_PIPE) || (type & USB_OBJECT_INTERRUPT_PIPE))) { - TRACE(("usb_ohci: submitting periodic transfer\n")); - return _SubmitPeriodicTransfer(transfer); - } - - TRACE_ERROR(("usb_ohci: tried to submit transfer for unknown pipe" - " type %lu\n", type)); - return B_ERROR; -} - - -status_t -OHCI::_SubmitControlRequest(Transfer *transfer) -{ usb_request_data *requestData = transfer->RequestData(); bool directionIn = (requestData->RequestType & USB_REQTYPE_DEVICE_IN) > 0; @@ -776,36 +983,35 @@ TRACE_ERROR(("usb_ohci: failed to allocate setup descriptor\n")); return B_NO_MEMORY; } - // Flags set up could be moved into _CreateGeneralDescriptor + setupDescriptor->flags |= OHCI_TD_DIRECTION_PID_SETUP | OHCI_TD_NO_CONDITION_CODE | OHCI_TD_TOGGLE_0 - | OHCI_TD_SET_DELAY_INTERRUPT(6); // Not sure about this. + | OHCI_TD_SET_DELAY_INTERRUPT(7); - ohci_general_td *statusDescriptor - = _CreateGeneralDescriptor(0); + ohci_general_td *statusDescriptor = _CreateGeneralDescriptor(0); if (!statusDescriptor) { TRACE_ERROR(("usb_ohci: failed to allocate status descriptor\n")); _FreeGeneralDescriptor(setupDescriptor); return B_NO_MEMORY; } - statusDescriptor->flags + + statusDescriptor->flags |= (directionIn ? OHCI_TD_DIRECTION_PID_OUT : OHCI_TD_DIRECTION_PID_IN) | OHCI_TD_NO_CONDITION_CODE | OHCI_TD_TOGGLE_1 - | OHCI_TD_SET_DELAY_INTERRUPT(1); + | OHCI_TD_SET_DELAY_INTERRUPT(0); iovec vector; vector.iov_base = requestData; vector.iov_len = sizeof(usb_request_data); _WriteDescriptorChain(setupDescriptor, &vector, 1); [... truncated: 1254 lines follow ...] From mmlr at mail.berlios.de Sat May 17 14:41:58 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sat, 17 May 2008 14:41:58 +0200 Subject: [Haiku-commits] r25528 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805171241.m4HCfwcE015016@sheep.berlios.de> Author: mmlr Date: 2008-05-17 14:41:56 +0200 (Sat, 17 May 2008) New Revision: 25528 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25528&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp Log: * Sync roothub code between UHCI and EHCI (will be reworked to a common one) * Minor whitespace cleanup Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp 2008-05-17 12:39:46 UTC (rev 25527) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci_rh.cpp 2008-05-17 12:41:56 UTC (rev 25528) @@ -58,7 +58,7 @@ 0x09, // Interface class (9 = Hub) 0, // Interface subclass 0, // Interface protocol - 0, // Index of interface string + 0 // Index of interface string }, { // endpoint descriptor @@ -67,7 +67,7 @@ USB_REQTYPE_DEVICE_IN | 1, // Endpoint address (first in IN endpoint) 0x03, // Attributes (0x03 = interrupt endpoint) 8, // Max packet size - 0xFF // Interval + 0xff // Interval }, { // hub descriptor @@ -169,7 +169,7 @@ break; } - TRACE(("usb_ehci_roothub: set address: %d\n", request->Value)); + TRACE(("usb_ehci_roothub: set address: %d\n", request->Value)); status = B_OK; break; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2008-05-17 12:39:46 UTC (rev 25527) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci.cpp 2008-05-17 12:41:56 UTC (rev 25528) @@ -363,7 +363,7 @@ } // Set base pointer and reset frame number - WriteReg32(UHCI_FRBASEADD, (uint32)physicalAddress); + WriteReg32(UHCI_FRBASEADD, (uint32)physicalAddress); WriteReg16(UHCI_FRNUM, 0); // Set the max packet size for bandwidth reclamation to 64 bytes @@ -1295,7 +1295,7 @@ bool transferDone = false; uint16 currentFrame = ReadReg16(UHCI_FRNUM); - + // Process the frame list until one transfer is processed while (!transferDone) { // wait 1ms in order to be sure to be one position behind Modified: haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp 2008-05-17 12:39:46 UTC (rev 25527) +++ haiku/trunk/src/add-ons/kernel/busses/usb/uhci_rh.cpp 2008-05-17 12:41:56 UTC (rev 25528) @@ -8,9 +8,7 @@ */ #include "uhci.h" -#include - static usb_device_descriptor sUHCIRootHubDevice = { 18, // Descriptor length @@ -61,7 +59,7 @@ 0x09, // Interface class (9 = Hub) 0, // Interface subclass 0, // Interface protocol - 0, // Index of interface string + 0 // Index of interface string }, { // endpoint descriptor @@ -70,7 +68,7 @@ USB_REQTYPE_DEVICE_IN | 1, // Endpoint address (first in IN endpoint) 0x03, // Attributes (0x03 = interrupt endpoint) 8, // Max packet size - 0xFF // Interval + 0xff // Interval }, { // hub descriptor @@ -110,7 +108,6 @@ 'H', 'A', 'I', 'K', 'U', // Characters ' ', 'I', 'n', 'c', '.' } - }, { @@ -139,15 +136,19 @@ return B_ERROR; usb_request_data *request = transfer->RequestData(); + TRACE(("usb_ohci_roothub: request: %d\n", request->Request)); status_t status = B_TIMED_OUT; size_t actualLength = 0; switch (request->Request) { case USB_REQUEST_GET_STATUS: { if (request->Index == 0) { - // Get the hub status -- everything as 0 means all-right + // get hub status actualLength = MIN(sizeof(usb_port_status), transfer->DataLength()); + // the hub reports whether the local power failed (bit 0) + // and if there is a over-current condition (bit 1). + // everything as 0 means all is ok. memset(transfer->Data(), 0, actualLength); status = B_OK; break; @@ -159,6 +160,7 @@ memcpy(transfer->Data(), (void *)&portStatus, actualLength); status = B_OK; } + break; } @@ -224,7 +226,7 @@ case USB_REQUEST_CLEAR_FEATURE: { if (request->Index == 0) { - // We don't support any hub changes + // we don't support any hub changes TRACE_ERROR(("usb_uhci_roothub: clear feature: no hub changes\n")); break; } From teammaui at web.de Sat May 17 18:39:09 2008 From: teammaui at web.de (=?utf-8?Q?Ralf_Sch=C3=BClke?=) Date: Sat, 17 May 2008 18:39:09 +0200 Subject: [Haiku-commits] r25525 - in haiku/trunk: headers/private/kernel src/add-ons/kernel/drivers/tty src/system/kernel src/system/kernel/fs In-Reply-To: <20080517115021.320760@gmx.net> References: <200805171021.m4HALdD0007704@sheep.berlios.de> <20080517115021.320760@gmx.net> Message-ID: On Sat, 17 May 2008 13:50:21 +0200, Stephan Assmus wrote: >> Log: >> axeld + bonefish: >> Changed condition variables so that it is allowed to block (e.g. lock >> mutexes etc.) between Add() and Wait(). This fixes #2059, since the >> block writer used them this way and could thusly fail to wait for a >> condition variable, causing a temporary stack object to be used past its >> lifetime. > > Awesome news! As always, you guys have used your pair programming time > very wisely! Thanks so much for fixing this! > > Best regards, > -Stephan > Goodby #2059 stargater > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From stippi at mail.berlios.de Sat May 17 18:50:30 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 17 May 2008 18:50:30 +0200 Subject: [Haiku-commits] r25529 - haiku/trunk/src/kits/interface Message-ID: <200805171650.m4HGoUHu031701@sheep.berlios.de> Author: stippi Date: 2008-05-17 18:50:29 +0200 (Sat, 17 May 2008) New Revision: 25529 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25529&view=rev Modified: haiku/trunk/src/kits/interface/Screen.cpp Log: The compiler warns, and it is correct - DPMSState() and DPMSCapabilities are supposed to return flags, and not a status_t. Modified: haiku/trunk/src/kits/interface/Screen.cpp =================================================================== --- haiku/trunk/src/kits/interface/Screen.cpp 2008-05-17 12:41:56 UTC (rev 25528) +++ haiku/trunk/src/kits/interface/Screen.cpp 2008-05-17 16:50:29 UTC (rev 25529) @@ -451,7 +451,7 @@ { if (fScreen != NULL) return fScreen->DPMSState(); - return B_ERROR; + return 0; } @@ -462,7 +462,7 @@ { if (fScreen != NULL) return fScreen->DPMSCapabilites(); - return B_ERROR; + return 0; } From bonefish at mail.berlios.de Sat May 17 20:48:25 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 17 May 2008 20:48:25 +0200 Subject: [Haiku-commits] r25530 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200805171848.m4HImPY4002118@sheep.berlios.de> Author: bonefish Date: 2008-05-17 20:48:24 +0200 (Sat, 17 May 2008) New Revision: 25530 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25530&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h Log: axeld + bonefish: * Small style changes. * Currently ifdef'ed out potentially correct changes, that break Neon tests which otherwise succeed. Axel will investigate this further. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-17 16:50:29 UTC (rev 25529) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-05-17 18:48:24 UTC (rev 25530) @@ -466,7 +466,7 @@ { TRACE("Close()"); - MutexLocker lock(fLock); + MutexLocker locker(fLock); if (fState == LISTEN) delete_sem(fAcceptSemaphore); @@ -488,7 +488,7 @@ bigtime_t maximum = absolute_timeout(socket->linger * 1000000LL); while (fSendQueue.Used() > 0) { - status = fSendList.Wait(lock, maximum); + status = fSendList.Wait(locker, maximum); if (status == B_TIMED_OUT || status == B_WOULD_BLOCK) break; else if (status < B_OK) @@ -497,8 +497,22 @@ TRACE("Close(): after waiting, the SendQ was left with %lu bytes.", fSendQueue.Used()); +#if 0 +// TODO: For the following to work we also need to be notified when TIME_WAIT +// is entered. + } else if (fRoute != NULL && (fRoute->flags & RTF_LOCAL) != 0) { + // This is a local connection - just wait until we're done so that + // the port is available again + while (fState != CLOSED && fState != TIME_WAIT) { + if (socket->error != B_OK) + return socket->error; + + status_t status = fSendList.Wait(locker); + if (status < B_OK) + return status; + } +#endif // 0 } - return B_OK; } @@ -1117,7 +1131,13 @@ status_t TCPEndpoint::_WaitForEstablished(MutexLocker &locker, bigtime_t timeout) { +#if 0 +// TODO: Checking for CLOSED seems correct, but breaks several neon tests. +// When investigating this, also have a look at _Close() and _HandleReset(). + while (fState < ESTABLISHED && fState != CLOSED) { +#else while (fState < ESTABLISHED) { +#endif if (socket->error != B_OK) return socket->error; @@ -1141,6 +1161,13 @@ T(State(this)); fFlags |= FLAG_DELETE_ON_CLOSE; + +#if 0 +// TODO: Should probably be moved here (from _HandleReset()), but cf. the +// comment in _WaitForEstablished(). + fSendList.Signal(); + _NotifyReader(); +#endif } @@ -1150,8 +1177,11 @@ socket->error = error; _Close(); +#if 1 +// TODO: Should be moved to _Close(), but cf. comment in _WaitForEstablished(). fSendList.Signal(); _NotifyReader(); +#endif gSocketModule->notify(socket, B_SELECT_WRITE, error); gSocketModule->notify(socket, B_SELECT_ERROR, error); Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-05-17 16:50:29 UTC (rev 25529) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h 2008-05-17 18:48:24 UTC (rev 25530) @@ -27,12 +27,12 @@ class WaitList { public: - WaitList(const char *name); + WaitList(const char* name); ~WaitList(); status_t InitCheck() const; - status_t Wait(MutexLocker &, bigtime_t timeout); + status_t Wait(MutexLocker& locker, bigtime_t timeout = B_INFINITE_TIMEOUT); void Signal(); private: From bonefish at mail.berlios.de Sat May 17 20:59:20 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 17 May 2008 20:59:20 +0200 Subject: [Haiku-commits] r25531 - in haiku/trunk: build/config_headers headers/private/kernel src/system/kernel/debug Message-ID: <200805171859.m4HIxKNA002900@sheep.berlios.de> Author: bonefish Date: 2008-05-17 20:59:19 +0200 (Sat, 17 May 2008) New Revision: 25531 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25531&view=rev Modified: haiku/trunk/build/config_headers/tracing_config.h haiku/trunk/headers/private/kernel/tracing.h haiku/trunk/src/system/kernel/debug/tracing.cpp Log: * Fixed kernel tracing for gcc 4. The ABI changed in a way that isn't compatible with what our code assumed (pointers to objects of TraceEntry and its POD base class trace_entry aren't identical anymore). * Added optional stack traces for ktrace_printf() output in the kernel. Modified: haiku/trunk/build/config_headers/tracing_config.h =================================================================== --- haiku/trunk/build/config_headers/tracing_config.h 2008-05-17 18:48:24 UTC (rev 25530) +++ haiku/trunk/build/config_headers/tracing_config.h 2008-05-17 18:59:19 UTC (rev 25531) @@ -23,6 +23,7 @@ #define BLOCK_CACHE_TRANSACTION_TRACING 0 #define BMESSAGE_TRACING 0 #define KERNEL_HEAP_TRACING 0 +#define KTRACE_PRINTF_STACK_TRACE 0 /* stack trace depth */ #define PAGE_ALLOCATION_TRACING 0 #define PARANOIA_TRACING 0 #define PARANOIA_TRACING_STACK_TRACE 0 /* stack trace depth */ Modified: haiku/trunk/headers/private/kernel/tracing.h =================================================================== --- haiku/trunk/headers/private/kernel/tracing.h 2008-05-17 18:48:24 UTC (rev 25530) +++ haiku/trunk/headers/private/kernel/tracing.h 2008-05-17 18:59:19 UTC (rev 25531) @@ -62,7 +62,7 @@ bigtime_t fLastEntryTime; }; -class TraceEntry : public trace_entry { +class TraceEntry { public: TraceEntry(); virtual ~TraceEntry(); @@ -70,12 +70,22 @@ virtual void Dump(TraceOutput& out); virtual void DumpStackTrace(TraceOutput& out); - size_t Size() const { return size; } - uint16 Flags() const { return flags; } + size_t Size() const { return ToTraceEntry()->size; } + uint16 Flags() const { return ToTraceEntry()->flags; } void Initialized(); void* operator new(size_t size, const std::nothrow_t&) throw(); + + trace_entry* ToTraceEntry() const + { + return (trace_entry*)this - 1; + } + + static TraceEntry* FromTraceEntry(trace_entry* entry) + { + return (TraceEntry*)(entry + 1); + } }; class AbstractTraceEntry : public TraceEntry { Modified: haiku/trunk/src/system/kernel/debug/tracing.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-05-17 18:48:24 UTC (rev 25530) +++ haiku/trunk/src/system/kernel/debug/tracing.cpp 2008-05-17 18:59:19 UTC (rev 25531) @@ -96,7 +96,7 @@ // a buffer entry -- just skip it } else if (sFirstEntry->flags & ENTRY_INITIALIZED) { // fully initialized TraceEntry -- destroy it - ((TraceEntry*)sFirstEntry)->~TraceEntry(); + TraceEntry::FromTraceEntry(sFirstEntry)->~TraceEntry(); sEntries--; } else { // Not fully initialized TraceEntry. We can't free it, since @@ -326,7 +326,7 @@ TraceEntry::Initialized() { #if ENABLE_TRACING - flags |= ENTRY_INITIALIZED; + ToTraceEntry()->flags |= ENTRY_INITIALIZED; sWritten++; #endif } @@ -336,7 +336,8 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw() { #if ENABLE_TRACING - return allocate_entry(size, 0); + trace_entry* entry = allocate_entry(size + sizeof(trace_entry), 0); + return entry != NULL ? entry + 1 : NULL; #endif return NULL; } @@ -396,6 +397,10 @@ { fMessage = alloc_tracing_buffer_strcpy(message, 256, false); +#if KTRACE_PRINTF_STACK_TRACE + fStackTrace = capture_tracing_stack_trace( + KTRACE_PRINTF_STACK_TRACE, 1, false); +#endif Initialized(); } @@ -404,8 +409,18 @@ out.Print("kern: %s", fMessage); } +#if KTRACE_PRINTF_STACK_TRACE + virtual void DumpStackTrace(TraceOutput& out) + { + out.PrintStackTrace(fStackTrace); + } +#endif + private: char* fMessage; +#if KTRACE_PRINTF_STACK_TRACE + tracing_stack_trace* fStackTrace; +#endif }; @@ -704,7 +719,7 @@ TraceEntry* Current() const { - return (TraceEntry*)fEntry; + return TraceEntry::FromTraceEntry(fEntry); } TraceEntry* Next() @@ -981,10 +996,10 @@ lastToDump = -1; while (iterator.Index() > firstToCheck) { TraceEntry* entry = iterator.Previous(); - if ((entry->flags & ENTRY_INITIALIZED) != 0) { + if ((entry->Flags() & ENTRY_INITIALIZED) != 0) { out.Clear(); if (filter->Filter(entry, out)) { - entry->flags |= FILTER_MATCH; + entry->ToTraceEntry()->flags |= FILTER_MATCH; if (lastToDump == -1) lastToDump = iterator.Index(); firstToDump = iterator.Index(); @@ -993,7 +1008,7 @@ if (matching >= count) break; } else - entry->flags &= ~FILTER_MATCH; + entry->ToTraceEntry()->flags &= ~FILTER_MATCH; } } @@ -1023,10 +1038,10 @@ break; } - if ((entry->flags & ENTRY_INITIALIZED) != 0) { + if ((entry->Flags() & ENTRY_INITIALIZED) != 0) { out.Clear(); if (filter && (markedMatching - ? (entry->flags & FILTER_MATCH) == 0 + ? (entry->Flags() & FILTER_MATCH) == 0 : !filter->Filter(entry, out))) { continue; } From axeld at pinc-software.de Sat May 17 23:41:49 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 17 May 2008 23:41:49 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r25523_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/bus=5Fmanagers/pci?= In-Reply-To: <200805162217.m4GMHM5W020809@sheep.berlios.de> Message-ID: <8739632652-BeMail@zon> marcusoverhagen at BerliOS wrote: > Log: > Added a "pcistatus" command to KDL that prints and clears the PCI > device status register. > Also clear the status register during init. BTW, I'm currently on the way integrating the new device manager code, and that will also cause some changes to the PCI manager, but only in the interface parts. Just so that you don't rewrite/refactor it all right now :-) Bye, Axel. From bonefish at mail.berlios.de Sun May 18 01:25:17 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 01:25:17 +0200 Subject: [Haiku-commits] r25532 - haiku/trunk/src/system/runtime_loader Message-ID: <200805172325.m4HNPHVK009732@sheep.berlios.de> Author: bonefish Date: 2008-05-18 01:25:17 +0200 (Sun, 18 May 2008) New Revision: 25532 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25532&view=rev Modified: haiku/trunk/src/system/runtime_loader/elf.cpp haiku/trunk/src/system/runtime_loader/runtime_loader.c haiku/trunk/src/system/runtime_loader/runtime_loader_private.h Log: Added explicit support for loading executables compiled with the respectively other gcc version on a Haiku compiled with gcc 2 or gcc 4. The libraries for such an executable are first searched in "gcc4" respectively "gcc2" subdirectories of the standard search path directories. If not found there, we try again with the standard paths. Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-05-17 18:59:19 UTC (rev 25531) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-05-17 23:25:17 UTC (rev 25532) @@ -81,6 +81,7 @@ static image_t *sProgramImage; static KMessage sErrorMessage; static bool sProgramLoaded = false; +static const char *sSearchPathSubDir = NULL; // a recursive lock static sem_id rld_sem; @@ -1192,8 +1193,9 @@ strlcpy(path, name, sizeof(path)); - // Try to load explicit image path first - fd = open_executable(path, type, rpath, get_program_path()); + // find and open the file + fd = open_executable(path, type, rpath, get_program_path(), + sSearchPathSubDir); if (fd < 0) { FATAL("cannot open file %s\n", path); KTRACE("rld: load_container(\"%s\"): failed to open file", name); @@ -1270,8 +1272,20 @@ goto err2; } - if (!analyze_object_gcc_version(fd, image, eheader, sheaderSize, ph_buff, + if (analyze_object_gcc_version(fd, image, eheader, sheaderSize, ph_buff, sizeof(ph_buff))) { + // If this is the executable image, we init the search path + // subdir, if the compiler version doesn't match ours. + if (type == B_APP_IMAGE) { + #if __GNUC__ == 2 + if (image->gcc_version.major > 2) + sSearchPathSubDir = "gcc4"; + #elif __GNUC__ == 4 + if (image->gcc_version.major == 2) + sSearchPathSubDir = "gcc2"; + #endif + } + } else { FATAL("Failed to get gcc version for %s\n", path); // not really fatal, actually } Modified: haiku/trunk/src/system/runtime_loader/runtime_loader.c =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-05-17 18:59:19 UTC (rev 25531) +++ haiku/trunk/src/system/runtime_loader/runtime_loader.c 2008-05-17 23:25:17 UTC (rev 25532) @@ -90,7 +90,8 @@ static int try_open_executable(const char *dir, int dirLength, const char *name, - const char *programPath, char *path, size_t pathLength) + const char *programPath, const char *compatibilitySubDir, char *path, + size_t pathLength) { size_t nameLength = strlen(name); struct stat stat; @@ -99,6 +100,7 @@ // construct the path if (dirLength > 0) { char *buffer = path; + size_t subDirLen = 0; if (programPath == NULL) programPath = gProgramArgs->program_path; @@ -121,14 +123,23 @@ pathLength -= bytesCopied; dir += 2; dirLength -= 2; + } else if (compatibilitySubDir != NULL) { + // We're looking for a library or an add-on and the executable has + // not been compiled with a compiler compatible with the one the + // OS has been built with. Thus we only look in specific subdirs. + subDirLen = strlen(compatibilitySubDir) + 1; } - if (dirLength + 1 + nameLength >= pathLength) + if (dirLength + 1 + subDirLen + nameLength >= pathLength) return B_NAME_TOO_LONG; memcpy(buffer, dir, dirLength); buffer[dirLength] = '/'; - strcpy(buffer + dirLength + 1, name); + if (subDirLen > 0) { + memcpy(buffer + dirLength + 1, compatibilitySubDir, subDirLen - 1); + buffer[dirLength + subDirLen] = '/'; + } + strcpy(buffer + dirLength + 1 + subDirLen, name); } else { if (nameLength >= pathLength) return B_NAME_TOO_LONG; @@ -169,8 +180,8 @@ static int search_executable_in_path_list(const char *name, const char *pathList, - int pathListLen, const char *programPath, char *pathBuffer, - size_t pathBufferLength) + int pathListLen, const char *programPath, const char *compatibilitySubDir, + char *pathBuffer, size_t pathBufferLength) { const char *pathListEnd = pathList + pathListLen; status_t status = B_ENTRY_NOT_FOUND; @@ -187,7 +198,7 @@ pathEnd++; fd = try_open_executable(pathList, pathEnd - pathList, name, - programPath, pathBuffer, pathBufferLength); + programPath, compatibilitySubDir, pathBuffer, pathBufferLength); if (fd >= 0) { // see if it's a dir struct stat stat; @@ -210,7 +221,7 @@ int open_executable(char *name, image_type type, const char *rpath, - const char *programPath) + const char *programPath, const char *compatibilitySubDir) { const char *paths; char buffer[PATH_MAX]; @@ -240,11 +251,12 @@ // If there is no ';', we set only secondList to simplify things. if (firstList) { fd = search_executable_in_path_list(name, firstList, - semicolon - firstList, programPath, buffer, sizeof(buffer)); + semicolon - firstList, programPath, NULL, buffer, + sizeof(buffer)); } if (fd < 0) { fd = search_executable_in_path_list(name, secondList, - strlen(secondList), programPath, buffer, sizeof(buffer)); + strlen(secondList), programPath, NULL, buffer, sizeof(buffer)); } } @@ -253,7 +265,14 @@ paths = search_path_for_type(type); if (paths) { fd = search_executable_in_path_list(name, paths, strlen(paths), - programPath, buffer, sizeof(buffer)); + programPath, compatibilitySubDir, buffer, sizeof(buffer)); + + // If not found and a compatibility sub directory has been + // specified, look again in the standard search paths. + if (fd == B_ENTRY_NOT_FOUND && compatibilitySubDir != NULL) { + fd = search_executable_in_path_list(name, paths, strlen(paths), + programPath, NULL, buffer, sizeof(buffer)); + } } } @@ -288,7 +307,7 @@ strlcpy(path, name, sizeof(path)); - fd = open_executable(path, B_APP_IMAGE, NULL, NULL); + fd = open_executable(path, B_APP_IMAGE, NULL, NULL, NULL); if (fd < B_OK) return fd; Modified: haiku/trunk/src/system/runtime_loader/runtime_loader_private.h =================================================================== --- haiku/trunk/src/system/runtime_loader/runtime_loader_private.h 2008-05-17 18:59:19 UTC (rev 25531) +++ haiku/trunk/src/system/runtime_loader/runtime_loader_private.h 2008-05-17 23:25:17 UTC (rev 25532) @@ -24,7 +24,7 @@ int runtime_loader(void *arg); int open_executable(char *name, image_type type, const char *rpath, - const char *programPath); + const char *programPath, const char *compatibilitySubDir); status_t test_executable(const char *path, char *interpreter); void terminate_program(void); From bonefish at mail.berlios.de Sun May 18 01:27:38 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 01:27:38 +0200 Subject: [Haiku-commits] r25533 - haiku/trunk/src/bin/zip Message-ID: <200805172327.m4HNRcWo009986@sheep.berlios.de> Author: bonefish Date: 2008-05-18 01:27:38 +0200 (Sun, 18 May 2008) New Revision: 25533 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25533&view=rev Modified: haiku/trunk/src/bin/zip/beos.c Log: * Use 0 instead of the unportable EOK. * If not built for BeOS or Haiku, we use _kern_open() instead of open(), so we get attribute emulation support. Modified: haiku/trunk/src/bin/zip/beos.c =================================================================== --- haiku/trunk/src/bin/zip/beos.c 2008-05-17 23:25:17 UTC (rev 25532) +++ haiku/trunk/src/bin/zip/beos.c 2008-05-17 23:27:38 UTC (rev 25533) @@ -45,6 +45,11 @@ int utime OF((char *, time_t *)); #endif +#if !defined(__BEOS__) && !defined(__HAIKU__) +# define open(path, openMode) _kern_open(-1, (path), (openMode), 0) + extern int _kern_open(int fd, const char *path, int openMode, int perms); +#endif + extern char *label; local ulg label_time = 0; local ulg label_mode = 0; @@ -344,7 +349,7 @@ If get_attr_dir() fails, the buffer will be NULL, total_size will be 0, and an error will be returned: - EOK - no errors occurred + 0 - no errors occurred EINVAL - attr_buff was pointing at a buffer ENOMEM - insufficient memory for attribute buffer @@ -362,7 +367,7 @@ int get_attr_dir( const char *name, char **attr_buff, off_t *total_size ) { - int retval = EOK; + int retval = 0; int fd; DIR *fa_dir; struct dirent *fa_ent; @@ -372,7 +377,7 @@ struct attr_info fa_info; struct attr_info big_fa_info; - retval = EOK; + retval = 0; attrs_size = 0; /* gcc still says this is used uninitialized... */ *total_size = 0; @@ -426,7 +431,7 @@ fa_ent = fs_read_attr_dir( fa_dir ); while( fa_ent != NULL ) { retval = fs_stat_attr( fd, fa_ent->d_name, &fa_info ); - /* TODO: check retval != EOK */ + /* TODO: check retval != 0 */ this_size = strlen( fa_ent->d_name ) + 1; this_size += sizeof( struct attr_info ); @@ -440,7 +445,7 @@ *attr_buff = (char *)realloc( *attr_buff, attrs_size ); if( *attr_buff == NULL ) { retval = fs_close_attr_dir( fa_dir ); - /* TODO: check retval != EOK */ + /* TODO: check retval != 0 */ close( fd ); return ENOMEM; @@ -489,7 +494,7 @@ /* ----------------------------------------------------------------- */ /* Close the attribute directory. */ retval = fs_close_attr_dir( fa_dir ); - /* TODO: check retval != EOK */ + /* TODO: check retval != 0 */ /* ----------------------------------------------------------------- */ /* If the buffer is too big, shrink it. */ @@ -507,7 +512,7 @@ close( fd ); - return EOK; + return 0; } /* ---------------------------------------------------------------------- */ @@ -700,7 +705,7 @@ int retval; retval = get_attr_dir( z->name, &attrbuff, &attrsize ); - if( retval != EOK ) { + if( retval != 0 ) { return ZE_OPEN; } if( attrsize == 0 ) { From bonefish at mail.berlios.de Sun May 18 01:29:01 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 01:29:01 +0200 Subject: [Haiku-commits] r25534 - in haiku/trunk/src/tools: . zip zip/unix Message-ID: <200805172329.m4HNT1B4010108@sheep.berlios.de> Author: bonefish Date: 2008-05-18 01:29:01 +0200 (Sun, 18 May 2008) New Revision: 25534 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25534&view=rev Added: haiku/trunk/src/tools/zip/ haiku/trunk/src/tools/zip/Jamfile haiku/trunk/src/tools/zip/unix/ haiku/trunk/src/tools/zip/unix/osdep.h haiku/trunk/src/tools/zip/unix/zipup.h Modified: haiku/trunk/src/tools/Jamfile Log: Allow building zip as build tool. Tested under Linux only. Modified: haiku/trunk/src/tools/Jamfile =================================================================== --- haiku/trunk/src/tools/Jamfile 2008-05-17 23:27:38 UTC (rev 25533) +++ haiku/trunk/src/tools/Jamfile 2008-05-17 23:29:01 UTC (rev 25534) @@ -106,4 +106,5 @@ SubInclude HAIKU_TOP src tools unzip ; SubInclude HAIKU_TOP src tools vmdkimage ; SubInclude HAIKU_TOP src tools unflatten ; +SubInclude HAIKU_TOP src tools zip ; Added: haiku/trunk/src/tools/zip/Jamfile =================================================================== --- haiku/trunk/src/tools/zip/Jamfile 2008-05-17 23:27:38 UTC (rev 25533) +++ haiku/trunk/src/tools/zip/Jamfile 2008-05-17 23:29:01 UTC (rev 25534) @@ -0,0 +1,24 @@ +SubDir HAIKU_TOP src tools zip ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src bin zip ] ; + +USES_BE_API on zip = true ; + +DEFINES += UNIX ; + +BuildPlatformMain zip : + beos.c + crc32.c + crctab.c + crypt.c + deflate.c + fileio.c + globals.c + trees.c + ttyio.c + util.c + zip.c + zipfile.c + zipup.c + : $(HOST_LIBBE) $(HOST_LIBSUPC++) +; Added: haiku/trunk/src/tools/zip/unix/osdep.h =================================================================== --- haiku/trunk/src/tools/zip/unix/osdep.h 2008-05-17 23:27:38 UTC (rev 25533) +++ haiku/trunk/src/tools/zip/unix/osdep.h 2008-05-17 23:29:01 UTC (rev 25534) @@ -0,0 +1,59 @@ +/* + Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 1999-Oct-05 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, both of these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html +*/ +#include +#include +#include + +#include /* for B_NO_ERROR */ + +#define USE_EF_UT_TIME /* Enable use of "UT" extra field time info */ + +#define EB_L_BE_LEN 5 /* min size is an unsigned long and flag */ +#define EB_C_BE_LEN 5 /* Length of data in local EF and flag. */ + +#define EB_BE_FL_NATURAL 0x01 /* data is 'natural' (not compressed) */ +#define EB_BE_FL_BADBITS 0xfe /* bits currently undefined */ + +#ifndef ZP_NEED_MEMCOMPR +# define ZP_NEED_MEMCOMPR +#endif + +/* Set a file's MIME type. */ +#define BE_FILE_TYPE_NAME "BEOS:TYPE" +void setfiletype( const char *file, const char *type ); + +/* +DR9 'Be' extra-field layout: + +'Be' - signature +ef_size - size of data in this EF (little-endian unsigned short) +full_size - uncompressed data size (little-endian unsigned long) +flag - flags (byte) + flags & EB_BE_FL_NATURAL = the data is not compressed + flags & EB_BE_FL_BADBITS = the data is corrupted or we + can't handle it properly +data - compressed or uncompressed file attribute data + +If flag & EB_BE_FL_NATURAL, the data is not compressed; this optimisation is +necessary to prevent wasted space for files with small attributes (which +appears to be quite common on the Advanced Access DR9 release). In this +case, there should be ( ef_size - EB_L_BE_LEN ) bytes of data, and full_size +should equal ( ef_size - EB_L_BE_LEN ). + +If the data is compressed, there will be ( ef_size - EB_L_BE_LEN ) bytes of +compressed data, and full_size bytes of uncompressed data. + +If a file has absolutely no attributes, there will not be a 'Be' extra field. + +The uncompressed data is arranged like this: + +attr_name\0 - C string +struct attr_info (big-endian) +attr_data (length in attr_info.size) +*/ Added: haiku/trunk/src/tools/zip/unix/zipup.h =================================================================== --- haiku/trunk/src/tools/zip/unix/zipup.h 2008-05-17 23:27:38 UTC (rev 25533) +++ haiku/trunk/src/tools/zip/unix/zipup.h 2008-05-17 23:29:01 UTC (rev 25534) @@ -0,0 +1,19 @@ +/* + Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + + See the accompanying file LICENSE, version 1999-Oct-05 or later + (the contents of which are also included in zip.h) for terms of use. + If, for some reason, both of these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html +*/ +#ifndef O_RDONLY +# include +#endif +#define fhow O_RDONLY +#define fbad (-1) +typedef int ftype; +#define zopen(n,p) open(n,p) +#define zread(f,b,n) read(f,b,n) +#define zclose(f) close(f) +#define zerr(f) (k == (extent)(-1L)) +#define zstdin 0 From bonefish at mail.berlios.de Sun May 18 01:31:05 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 01:31:05 +0200 Subject: [Haiku-commits] r25535 - haiku/trunk/build/jam Message-ID: <200805172331.m4HNV5Cg010298@sheep.berlios.de> Author: bonefish Date: 2008-05-18 01:31:04 +0200 (Sun, 18 May 2008) New Revision: 25535 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25535&view=rev Modified: haiku/trunk/build/jam/ImageRules Log: Added rules F{Files,Symlinks}In{Container,HaikuImage}Directory returning the targets/symlinks added to a container/Haiku image directory. Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2008-05-17 23:29:01 UTC (rev 25534) +++ haiku/trunk/build/jam/ImageRules 2008-05-17 23:31:04 UTC (rev 25535) @@ -178,6 +178,19 @@ } } +rule FFilesInContainerDirectory container : directoryTokens +{ + local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ; + local directory = [ FDirName $(directoryTokens) ] ; + directory = $(directory:G=$(containerGrist)) ; + + if [ on $(directory) return $(__is_on_image) ] { + on $(directory) return $(TARGETS_TO_INSTALL) ; + } + + return ; +} + rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName { # AddSymlinkToContainer : : @@ -202,6 +215,19 @@ SYMLINKS_TO_INSTALL on $(directory) += $(link) ; } +rule FSymlinksInContainerDirectory container : directoryTokens +{ + local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ; + local directory = [ FDirName $(directoryTokens) ] ; + directory = $(directory:G=$(containerGrist)) ; + + if [ on $(directory) return $(__is_on_image) ] { + on $(directory) return $(SYMLINKS_TO_INSTALL) ; + } + + return ; +} + rule CopyDirectoryToContainer container : directoryTokens : sourceDirectory : targetDirectoryName : excludePatterns : alwaysUpdate { @@ -573,6 +599,12 @@ : $(targets) : $(destName) ; } +rule FFilesInHaikuImageDirectory directoryTokens +{ + return [ FFilesInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME) + : $(directoryTokens) ] ; +} + rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName { # AddSymlinkToHaikuImage : [ : ] ; @@ -581,6 +613,12 @@ : $(linkTarget) : $(linkName) ; } +rule FSymlinksInHaikuImageDirectory directoryTokens +{ + return [ FSymlinksInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME) + : $(directoryTokens) ] ; +} + rule CopyDirectoryToHaikuImage directoryTokens : sourceDirectory : targetDirectoryName : excludePatterns : alwaysUpdate { From bonefish at mail.berlios.de Sun May 18 01:47:40 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 01:47:40 +0200 Subject: [Haiku-commits] r25536 - in haiku/trunk: . build/jam Message-ID: <200805172347.m4HNleRC011269@sheep.berlios.de> Author: bonefish Date: 2008-05-18 01:47:39 +0200 (Sun, 18 May 2008) New Revision: 25536 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25536&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/UserBuildConfig.ReadMe haiku/trunk/build/jam/UserBuildConfig.sample haiku/trunk/configure Log: Support for adding libraries compiled with the alternative gcc (2 vs. 4). One has to have a (fully configured) "generated" directory for the alternative gcc and specify it using the new option "--alternative-gcc-output-dir" when configuring the main build. Additionally the build variable HAIKU_ADD_ALTERNATIVE_GCC_LIBS has to be set to "1". If that has been done, when building the image a sub-jam is invoked that generates the alternative libs and zips them. The main-jam unzips them into the correct directory in the image. Note that the JAM build variable has to be set when using a jam executable not invoked by "jam". Tested with gcc 2 NetPositive, Pe, and FireFox under gcc 4 Haiku, and with a few of the standard gcc 4 Haiku apps under gcc 2 Haiku. Seems to work fine so far. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-05-17 23:31:04 UTC (rev 25535) +++ haiku/trunk/build/jam/HaikuImage 2008-05-17 23:47:39 UTC (rev 25536) @@ -425,6 +425,91 @@ : licenses : -x .svn ; +#pragma mark - Alternative GCC Libraries + + +# build a zip file with the system libs +# (used by another jam that wants to build a Haiku with alternative GCC +# libraries included) + +rule ZipTargets zipFile : targets +{ + Depends $(zipFile) : zip $(targets) ; + ZipTargets1 $(zipFile) : zip $(targets) ; +} + +actions ZipTargets1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(RM) "$(1)" + $(2[1]) -jy "$(1)" $(2[2-]) +} + +local alternativeSystemLibsZip = alternative_system_libs.zip ; +MakeLocate $(alternativeSystemLibsZip) : $(HAIKU_OUTPUT_DIR) ; + +# collect the targets we would install in the lib directory +local alternativeSystemLibs ; +local libTargets = [ FFilesInHaikuImageDirectory beos system lib ] ; +local libTarget ; +for libTarget in $(libTargets) { + alternativeSystemLibs += [ on $(libTarget) return $(TARGET) ] ; +} + +# collect the symlinks we would install in the lib directory +libTargets = [ FSymlinksInHaikuImageDirectory beos system lib ] ; +local tmpAlternativeLibDir + = [ FDirName $(HAIKU_OUTPUT_DIR) tmp alternativeLibs ] ; +for libTarget in $(libTargets) { + # We need to create actual symlinks, we can zip later. + local symlinkTarget = $(libTarget:BS) ; + MakeLocate $(symlinkTarget) : $(tmpAlternativeLibDir) ; + SymLink $(symlinkTarget) : [ on $(libTarget) return $(SYMLINK_TARGET) ] ; + alternativeSystemLibs += $(symlinkTarget) ; +} + +ZipTargets $(alternativeSystemLibsZip) : $(alternativeSystemLibs) ; + + +if $(HAIKU_ADD_ALTERNATIVE_GCC_LIBS) && $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) { + # let another jam build a zip with the system libraries + rule InvokeSubJam target : directory : jamLine + { + DIRECTORY on $(target) = $(directory) ; + COMMAND_LINE on $(target) = $(jamLine) ; + Always $(target) ; + InvokeSubJam1 $(target) ; + } + + actions InvokeSubJam1 + { + cd $(DIRECTORY) + $(JAM:E=jam) -q $(COMMAND_LINE) ; + } + + local otherAlternativeSystemLibsZip + = alternative_system_libs.zip ; + MakeLocate $(otherAlternativeSystemLibsZip) + : $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) ; + + InvokeSubJam $(otherAlternativeSystemLibsZip) + : $(HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR) + : "'alternative_system_libs.zip'" ; + + local libSubDir ; + + if $(HAIKU_GCC_VERSION[1]) = 2 { + libSubDir = gcc4 ; + } else { + libSubDir = gcc2 ; + } + + # install the alternative libs in the right directory + UnzipArchiveToHaikuImage beos system lib $(libSubDir) + : $(otherAlternativeSystemLibsZip) ; +} + + #pragma mark - Optional Packages Modified: haiku/trunk/build/jam/UserBuildConfig.ReadMe =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-05-17 23:31:04 UTC (rev 25535) +++ haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-05-17 23:47:39 UTC (rev 25536) @@ -128,6 +128,13 @@ # Add all available optional packages. HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; +# Add the libraries built with the alternative gcc version. The alternative +# gcc generated directory must have specified via the configure option +# --alternative-gcc-output-dir. Note, that a sub-jam will be executed. When +# using a jam that is not simply invoked by "jam", set the JAM build variable +# accordingly. +HAIKU_ADD_ALTERNATIVE_GCC_LIBS = 1 ; + # Specify scripts that shall be run when populating the image/installation # directory. The "early" script is run before anything has been copied onto # the image/into the installation directory. The "late" script is run after Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2008-05-17 23:31:04 UTC (rev 25535) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2008-05-17 23:47:39 UTC (rev 25536) @@ -32,3 +32,6 @@ # Add all available optional packages. #HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; + +# Add the libraries built with the alternative gcc version. +#HAIKU_ADD_ALTERNATIVE_GCC_LIBS = 1 ; Modified: haiku/trunk/configure =================================================================== --- haiku/trunk/configure 2008-05-17 23:31:04 UTC (rev 25535) +++ haiku/trunk/configure 2008-05-17 23:47:39 UTC (rev 25536) @@ -27,6 +27,13 @@ will not be binary compatible with BeOS R5. specifies the target architecture, either "x86" or "ppc". + --alternative-gcc-output-dir + Build a Haiku installation that supports running + executables built with a gcc version incompatible + with the primary gcc (e.g. gcc 2 executables under + a gcc 4 Haiku or vice versa). specifies the + output directory of the other gcc. The directory + must already be fully configured. --cross-tools-prefix Assume cross compilation. should be a path to the directory where the cross @@ -231,6 +238,7 @@ buildCrossTools= buildCrossToolsScript="$sourceDir/build/scripts/build_cross_tools" buildCrossToolsMachine= +alternativeGCCOutputDir= haikuRequiredLegacyGCCVersion="2.95.3-haiku-080323" export haikuRequiredLegacyGCCVersion @@ -254,33 +262,49 @@ case "$1" in --bochs-debug) bochs_debug=1; shift 1;; --build-cross-tools) assertparam "$1" $#; buildCrossTools=$2; shift 2;; - --build-cross-tools-gcc4) assertparams "$1" 2 $#; buildCrossTools=$3; - buildCrossToolsScript="${buildCrossToolsScript}_gcc4"; - case "$2" in - x86) haikuGCCMachine=i586-pc-haiku;; - ppc) haikuGCCMachine=powerpc-apple-haiku;; - m68k) haikuGCCMachine=m68k-unknown-haiku;; - *) echo "Unsupported target architecture: $2" - exit 1;; - esac - buildCrossToolsMachine=$haikuGCCMachine - shift 3;; - --cross-tools-prefix) assertparam "$1" $#; crossToolsPrefix=$2; shift 2;; + --build-cross-tools-gcc4) + assertparams "$1" 2 $# + buildCrossTools=$3 + buildCrossToolsScript="${buildCrossToolsScript}_gcc4" + case "$2" in + x86) haikuGCCMachine=i586-pc-haiku;; + ppc) haikuGCCMachine=powerpc-apple-haiku;; + m68k) haikuGCCMachine=m68k-unknown-haiku;; + *) echo "Unsupported target architecture: $2" + exit 1;; + esac + buildCrossToolsMachine=$haikuGCCMachine + shift 3 + ;; + --alternative-gcc-output-dir) + assertparam "$1" $# + cd $2 || exit 1 + alternativeGCCOutputDir=`pwd` + cd $currentDir + shift 2 + ;; + --cross-tools-prefix) + assertparam "$1" $# + crossToolsPrefix=$2 + shift 2 + ;; --help | -h) usage; exit 0;; --include-gpl-addons) include_gpl_addons=1; shift 1;; --include-3rdparty) include_3rdparty=1; shift 1;; --enable-multiuser) enable_multiuser=1; shift 1;; --distro-compatibility) - assertparam "$1" $#; distroCompatibility=$2; - case "$distroCompatibility" in - official) ;; - compatible) ;; - default) ;; - *) echo "Invalid distro compatibility" \ - "level: $distroCompatibility" - exit 1;; - esac - shift 2;; + assertparam "$1" $# + distroCompatibility=$2 + case "$distroCompatibility" in + official) ;; + compatible) ;; + default) ;; + *) echo "Invalid distro compatibility" \ + "level: $distroCompatibility" + exit 1;; + esac + shift 2 + ;; --target=*) target=`echo $1 | cut -d'=' -f2-`; shift 1;; --use-gcc-pipe) use_gcc_pipe=1; shift 1;; --use-32bit) use_32bit=1; shift 1;; @@ -358,14 +382,15 @@ TARGET_PLATFORM ?= "${target}" ; HOST_PLATFORM ?= "${buildPlatform}" ; -BOCHS_DEBUG_HACK ?= "${bochs_debug}" ; -INCLUDE_GPL_ADDONS ?= "${include_gpl_addons}" ; -HAIKU_INCLUDE_3RDPARTY ?= "${include_3rdparty}" ; -HAIKU_ENABLE_MULTIUSER ?= "${enable_multiuser}" ; -HAIKU_DISTRO_COMPATIBILITY ?= "${distroCompatibility}" ; -HAIKU_USE_GCC_PIPE ?= "${use_gcc_pipe}" ; -HAIKU_HOST_USE_32BIT ?= "${use_32bit}" ; -HAIKU_HOST_USE_XATTR ?= "${use_xattr}" ; +BOCHS_DEBUG_HACK ?= "${bochs_debug}" ; +INCLUDE_GPL_ADDONS ?= "${include_gpl_addons}" ; +HAIKU_INCLUDE_3RDPARTY ?= "${include_3rdparty}" ; +HAIKU_ENABLE_MULTIUSER ?= "${enable_multiuser}" ; +HAIKU_DISTRO_COMPATIBILITY ?= "${distroCompatibility}" ; +HAIKU_USE_GCC_PIPE ?= "${use_gcc_pipe}" ; +HAIKU_HOST_USE_32BIT ?= "${use_32bit}" ; +HAIKU_HOST_USE_XATTR ?= "${use_xattr}" ; +HAIKU_ALTERNATIVE_GCC_OUTPUT_DIR ?= ${alternativeGCCOutputDir} ; HAIKU_GCC_RAW_VERSION ?= ${haikuGCCVersion} ; HAIKU_GCC_MACHINE ?= ${haikuGCCMachine} ; @@ -429,11 +454,8 @@ EOF done -# Generate a boot strap Jamfile in the output directory, if it is not in -# the source dir. +# Generate a boot strap Jamfile in the output directory. -if [ "$currentDir" != "$sourceDir" ]; then - cat << EOF > $outputDir/Jamfile # automatically generated Jamfile @@ -443,6 +465,3 @@ include [ FDirName \$(HAIKU_TOP) Jamfile ] ; EOF - -fi - From bonefish at mail.berlios.de Sun May 18 02:01:19 2008 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 18 May 2008 02:01:19 +0200 Subject: [Haiku-commits] r25537 - haiku/trunk/build/jam Message-ID: <200805180001.m4I01J1A011810@sheep.berlios.de> Author: bonefish Date: 2008-05-18 02:01:17 +0200 (Sun, 18 May 2008) New Revision: 25537 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25537&view=rev Modified: haiku/trunk/build/jam/UserBuildConfig.ReadMe Log: Typo. Modified: haiku/trunk/build/jam/UserBuildConfig.ReadMe =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-05-17 23:47:39 UTC (rev 25536) +++ haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-05-18 00:01:17 UTC (rev 25537) @@ -129,7 +129,7 @@ HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; # Add the libraries built with the alternative gcc version. The alternative -# gcc generated directory must have specified via the configure option +# gcc generated directory must have been specified via the configure option # --alternative-gcc-output-dir. Note, that a sub-jam will be executed. When # using a jam that is not simply invoked by "jam", set the JAM build variable # accordingly. From anevilyak at gmail.com Sun May 18 05:50:57 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sat, 17 May 2008 22:50:57 -0500 Subject: [Haiku-commits] r25536 - in haiku/trunk: . build/jam In-Reply-To: <200805172347.m4HNleRC011269@sheep.berlios.de> References: <200805172347.m4HNleRC011269@sheep.berlios.de> Message-ID: On Sat, May 17, 2008 at 6:47 PM, bonefish at BerliOS wrote: > Author: bonefish > Date: 2008-05-18 01:47:39 +0200 (Sun, 18 May 2008) > New Revision: 25536 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25536&view=rev > > Modified: > haiku/trunk/build/jam/HaikuImage > haiku/trunk/build/jam/UserBuildConfig.ReadMe > haiku/trunk/build/jam/UserBuildConfig.sample > haiku/trunk/configure > Log: > Support for adding libraries compiled with the alternative gcc (2 vs. > 4). One has to have a (fully configured) "generated" directory for the > alternative gcc and specify it using the new option > "--alternative-gcc-output-dir" when configuring the main build. > Additionally the build variable HAIKU_ADD_ALTERNATIVE_GCC_LIBS has to be > set to "1". > > If that has been done, when building the image a sub-jam is invoked that > generates the alternative libs and zips them. The main-jam unzips them > into the correct directory in the image. Note that the JAM build > variable has to be set when using a jam executable not invoked by "jam". > > Tested with gcc 2 NetPositive, Pe, and FireFox under gcc 4 Haiku, and > with a few of the standard gcc 4 Haiku apps under gcc 2 Haiku. Seems to > work fine so far. > > Is there anything special that needs to be done to prepare the alternate gcc dir? I tried following these instructions and it failed saying it couldn't find generated-gcc2/Jamfile. No such file indeed exists but I don't see how to generate it. Regards, Rene From leavengood at gmail.com Sun May 18 05:51:50 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 17 May 2008 23:51:50 -0400 Subject: [Haiku-commits] r25532 - haiku/trunk/src/system/runtime_loader In-Reply-To: <200805172325.m4HNPHVK009732@sheep.berlios.de> References: <200805172325.m4HNPHVK009732@sheep.berlios.de> Message-ID: On 5/17/08, bonefish at BerliOS wrote: > Log: > Added explicit support for loading executables compiled with the > respectively other gcc version on a Haiku compiled with gcc 2 or gcc 4. > The libraries for such an executable are first searched in "gcc4" > respectively "gcc2" subdirectories of the standard search path > directories. If not found there, we try again with the standard paths. :-D Ryan From mmlr at mail.berlios.de Sun May 18 11:23:30 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 May 2008 11:23:30 +0200 Subject: [Haiku-commits] r25538 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805180923.m4I9NUPb027771@sheep.berlios.de> Author: mmlr Date: 2008-05-18 11:23:29 +0200 (Sun, 18 May 2008) New Revision: 25538 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25538&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h Log: * Make the operational register memory a uint8 * instead of a uint32 * so the driver has at least a chance of working (it previously always used wrong offsets for register access). * Remove the hash approach for now (I'm going to explore a few other ways of doing that first). * Reorder some stuff and check for errors in some more places. * More cleanup (mostly whitespace again). Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 00:01:17 UTC (rev 25537) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 09:23:29 UTC (rev 25538) @@ -77,8 +77,6 @@ fFinishTransfersSem(-1), fFinishThread(-1), fStopFinishThread(false), - fHashGenericTable(NULL), - fHashIsochronousTable(NULL), fRootHub(NULL), fRootHubAddress(0), fPortCount(0) @@ -138,35 +136,17 @@ memset(fHcca, 0, sizeof(ohci_hcca)); - // Allocate hash tables - fHashGenericTable = (ohci_general_td **) - malloc(sizeof(ohci_general_td *) * OHCI_HASH_SIZE); - if (fHashGenericTable == NULL) { - TRACE_ERROR(("usb_ohci: unable to allocate hash generic table\n")); - return; - } - - fHashIsochronousTable = (ohci_isochronous_td **) - malloc(sizeof(ohci_isochronous_td *) * OHCI_HASH_SIZE); - if (fHashIsochronousTable == NULL) { - free(fHashGenericTable); - TRACE_ERROR(("usb_ohci: unable to allocate hash isochronous table\n")); - return; - } - // Set Up Host controller // Dummy endpoints fDummyControl = _AllocateEndpoint(); if (!fDummyControl) return; - fDummyControl->flags |= OHCI_ENDPOINT_SKIP; fDummyBulk = _AllocateEndpoint(); if (!fDummyBulk) { _FreeEndpoint(fDummyControl); return; } - fDummyBulk->flags |= OHCI_ENDPOINT_SKIP; fDummyIsochronous = _AllocateEndpoint(); if (!fDummyIsochronous) { @@ -174,7 +154,6 @@ _FreeEndpoint(fDummyBulk); return; } - fDummyIsochronous->flags |= OHCI_ENDPOINT_SKIP; // Static endpoints that get linked in the HCCA fInterruptEndpoints = new(std::nothrow) @@ -202,7 +181,6 @@ } // Make them point all to the dummy isochronous endpoint - fInterruptEndpoints[i]->flags |= OHCI_ENDPOINT_SKIP; fInterruptEndpoints[i]->next_physical_endpoint = fDummyIsochronous->physical_address; } @@ -341,9 +319,6 @@ if (fRegisterArea >= B_OK) delete_area(fRegisterArea); - free(fHashGenericTable); - free(fHashIsochronousTable); - _FreeEndpoint(fDummyControl); _FreeEndpoint(fDummyBulk); _FreeEndpoint(fDummyIsochronous); @@ -365,9 +340,11 @@ { TRACE(("usb_ohci: starting OHCI Host Controller\n")); - if ((_ReadReg(OHCI_CONTROL) & OHCI_HC_FUNCTIONAL_STATE_MASK) + uint32 control = _ReadReg(OHCI_CONTROL); + if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK) != OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) { - TRACE_ERROR(("usb_ohci: Controller not started!\n")); + TRACE_ERROR(("usb_ohci: Controller not started (0x%08lx)!\n", + control)); return B_ERROR; } else TRACE(("usb_ohci: Controller is operational!\n")); @@ -578,7 +555,7 @@ status_t OHCI::GetPortStatus(uint8 index, usb_port_status *status) { - TRACE(("usb_ohci::%s(%ud, )\n", __FUNCTION__, index)); + TRACE(("usb_ohci: get port status %ud\n", index)); if (index >= fPortCount) return B_BAD_INDEX; @@ -857,7 +834,7 @@ ohci_isochronous_td *isoCurrent = NULL; ohci_isochronous_td *isoTop = NULL; while (doneList != 0) { - current = _FindDescriptorInHash(doneList); + current = NULL; //_FindDescriptorInHash(doneList); if (current != NULL) { doneList = current->next_physical_descriptor; current->next_done_descriptor = (void *)top; @@ -865,7 +842,7 @@ continue; } - isoCurrent = _FindIsoDescriptorInHash(doneList); + isoCurrent = NULL; //_FindIsoDescriptorInHash(doneList); if (isoCurrent != NULL) { doneList = isoCurrent->next_physical_descriptor; isoCurrent->next_done_descriptor = (void *)isoTop; @@ -1135,11 +1112,14 @@ return NULL; } + endpoint->flags = OHCI_ENDPOINT_SKIP; endpoint->physical_address = (addr_t)physicalAddress; endpoint->head_logical_descriptor = NULL; endpoint->head_physical_descriptor = 0; endpoint->tail_logical_descriptor = NULL; endpoint->tail_physical_descriptor = 0; + endpoint->next_logical_endpoint = NULL; + endpoint->next_physical_endpoint = 0; return endpoint; } @@ -1214,27 +1194,32 @@ endpoint->flags = flags; // Add the endpoint to the appropriate list - ohci_endpoint_descriptor *head = NULL; uint32 type = pipe->Type(); + ohci_endpoint_descriptor *head = NULL; if (type & USB_OBJECT_CONTROL_PIPE) head = fDummyControl; else if (type & USB_OBJECT_BULK_PIPE) head = fDummyBulk; else if (type & USB_OBJECT_INTERRUPT_PIPE) head = _FindInterruptEndpoint(pipe->Interval()); - else if (type & USB_OBJECT_ISO_PIPE) { - // Set the isochronous bit format - endpoint->flags |= OHCI_ENDPOINT_ISOCHRONOUS_FORMAT; + else if (type & USB_OBJECT_ISO_PIPE) head = fDummyIsochronous; - } else { + else TRACE_ERROR(("usb_ohci: unknown pipe type\n")); + + if (head == NULL) { + TRACE_ERROR(("usb_ohci: no list found for endpoint\n")); _FreeEndpoint(endpoint); - return B_BAD_VALUE; + return B_ERROR; } // Create (necessary) dummy descriptor if (pipe->Type() & USB_OBJECT_ISO_PIPE) { + // Set the isochronous bit format + endpoint->flags |= OHCI_ENDPOINT_ISOCHRONOUS_FORMAT; // TODO + _FreeEndpoint(endpoint); + return B_ERROR; } else { ohci_general_td *dummy = _CreateGeneralDescriptor(0); dummy->next_logical_descriptor = NULL; @@ -1245,15 +1230,23 @@ endpoint->tail_physical_descriptor = dummy->physical_address; } - // TODO: Change lock lo LockEndpoint() - Lock(); + if (!Lock()) { + if (endpoint->head_logical_descriptor) { + _FreeGeneralDescriptor( + (ohci_general_td *)endpoint->head_logical_descriptor); + } + + _FreeEndpoint(endpoint); + return B_ERROR; + } + pipe->SetControllerCookie((void *)endpoint); endpoint->next_logical_endpoint = head->next_logical_endpoint; endpoint->next_physical_endpoint = head->next_physical_endpoint; head->next_logical_endpoint = (void *)endpoint; head->next_physical_endpoint = (uint32)endpoint->physical_address; - Unlock(); + Unlock(); return B_OK; } @@ -1422,50 +1415,6 @@ } -void -OHCI::_AddDescriptorToHash(ohci_general_td *descriptor) -{ - // TODO -} - - -void -OHCI::_RemoveDescriptorFromHash(ohci_general_td *descriptor) -{ - // TODO -} - - -ohci_general_td* -OHCI::_FindDescriptorInHash(uint32 physicalAddress) -{ - // TODO - return NULL; -} - - -void -OHCI::_AddIsoDescriptorToHash(ohci_isochronous_td *descriptor) -{ - // TODO -} - - -void -OHCI::_RemoveIsoDescriptorFromHash(ohci_isochronous_td *descriptor) -{ - // TODO -} - - -ohci_isochronous_td* -OHCI::_FindIsoDescriptorInHash(uint32 physicalAddress) -{ - // TODO - return NULL; -} - - inline void OHCI::_WriteReg(uint32 reg, uint32 value) { Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2008-05-18 00:01:17 UTC (rev 25537) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h 2008-05-18 09:23:29 UTC (rev 25538) @@ -3,8 +3,9 @@ * Distributed under the terms of the MIT License. * * Authors: - * Jan-Rixt Van Hoye - * Salvatore Benedetto + * Jan-Rixt Van Hoye + * Salvatore Benedetto + * Michael Lotz */ #ifndef OHCI_H @@ -28,49 +29,14 @@ transfer_data_s *link; } transfer_data; -// -------------------------------------- -// OHCI:: Software isonchronous -// transfer descriptor -// -------------------------------------- -typedef struct hcd_soft_itransfer -{ - ohci_isochronous_td itd; - struct hcd_soft_itransfer *nextitd; // mirrors nexttd in ITD - struct hcd_soft_itransfer *dnext; // next in done list - addr_t physaddr; // physical address to the host controller isonchronous transfer - //LIST_ENTRY(hcd_soft_itransfer) hnext; - uint16 flags; // flags -#ifdef DIAGNOSTIC - char isdone; // is the transfer done? -#endif -}hcd_soft_itransfer; -#define OHCI_SITD_SIZE ((sizeof (struct hcd_soft_itransfer) + OHCI_ITD_ALIGN - 1) / OHCI_ITD_ALIGN * OHCI_ITD_ALIGN) -#define OHCI_SITD_CHUNK 64 - -#define OHCI_NUMBER_OF_ENDPOINTS (2 * OHCI_NUMBER_OF_INTERRUPTS - 1) - -// Note: the controller returns only the physical -// address of the first processed descriptor of -// an heterogeneous list (isochronous + generic). Unfortunately -// we don't have a way to know whether the descriptor is -// generic or isochronous, either way to translate the address back to -// kernel address. The physical address is used as the hash value. -// (Kindly borrowed from *BSD) - -#define OHCI_HASH_SIZE 128 -#define HASH(x) (((x) >> 4) % OHCI_HASH_SIZE) - - -class OHCI : public BusManager -{ +class OHCI : public BusManager { public: - OHCI(pci_info *info, Stack *stack); ~OHCI(); status_t Start(); -virtual status_t SubmitTransfer(Transfer *transfer); +virtual status_t SubmitTransfer(Transfer *transfer); virtual status_t CancelQueuedTransfers(Pipe *pipe, bool force); @@ -80,8 +46,8 @@ static status_t AddTo(Stack *stack); // Port operations - uint8 PortCount() { return fPortCount; }; - status_t GetPortStatus(uint8 index, + uint8 PortCount() { return fPortCount; }; + status_t GetPortStatus(uint8 index, usb_port_status *status); status_t SetPortFeature(uint8 index, uint16 feature); status_t ClearPortFeature(uint8 index, uint16 feature); @@ -152,31 +118,15 @@ void _FreeIsochronousDescriptor( ohci_isochronous_td *descriptor); - // Hash tables related methods - void _AddDescriptorToHash( - ohci_general_td *descriptor); - void _RemoveDescriptorFromHash( - ohci_general_td *descriptor); - ohci_general_td *_FindDescriptorInHash( - uint32 physicalAddress); - - void _AddIsoDescriptorToHash( - ohci_isochronous_td *descriptor); - void _RemoveIsoDescriptorFromHash( - ohci_isochronous_td *descriptor); - ohci_isochronous_td *_FindIsoDescriptorInHash( - uint32 physicalAddress); - - // Register functions inline void _WriteReg(uint32 reg, uint32 value); inline uint32 _ReadReg(uint32 reg); static pci_module_info *sPCIModule; - pci_info *fPCIInfo; + pci_info *fPCIInfo; Stack *fStack; - uint32 *fOperationalRegisters; + uint8 *fOperationalRegisters; area_id fRegisterArea; // Host Controller Communication Area related stuff @@ -196,12 +146,8 @@ thread_id fFinishThread; bool fStopFinishThread; - // Hash table - ohci_general_td **fHashGenericTable; - ohci_isochronous_td **fHashIsochronousTable; - // Root Hub - OHCIRootHub *fRootHub; + OHCIRootHub *fRootHub; uint8 fRootHubAddress; // Port management @@ -214,7 +160,7 @@ OHCIRootHub(Object *rootObject, int8 deviceAddress); -static status_t ProcessTransfer(OHCI *ohci, +static status_t ProcessTransfer(OHCI *ohci, Transfer *transfer); }; Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2008-05-18 00:01:17 UTC (rev 25537) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h 2008-05-18 09:23:29 UTC (rev 25538) @@ -5,6 +5,7 @@ * Authors: * Jan-Rixt Van Hoye * Salvatore Benedetto + * Michael Lotz */ #ifndef OHCI_HARDWARE_H @@ -271,15 +272,14 @@ #define OHCI_NUMBER_OF_INTERRUPTS 32 -typedef struct ohci_hcca -{ +typedef struct { uint32 interrupt_table[OHCI_NUMBER_OF_INTERRUPTS]; uint32 current_frame_number; uint32 done_head; // The following is 120 instead of 116 because the spec // only specifies 252 bytes uint8 reserved_for_hc[120]; -}; +} ohci_hcca; #define OHCI_DONE_INTERRUPTS 1 #define OHCI_HCCA_SIZE 256 @@ -292,20 +292,18 @@ // Endpoint descriptor structure (section 4.2) // -------------------------------- -typedef struct ohci_endpoint_descriptor -{ +typedef struct { // Hardware part uint32 flags; // Flags field uint32 tail_physical_descriptor; // Queue tail physical pointer uint32 head_physical_descriptor; // Queue head physical pointer uint32 next_physical_endpoint; // Physical pointer to the next endpoint // Software part - // TODO: What about type, state and interval (only interrupts) ? addr_t physical_address; // Physical pointer to this address void *tail_logical_descriptor; // Queue tail logical pointer void *head_logical_descriptor; // Queue head logical pointer void *next_logical_endpoint; // Logical pointer to the next endpoint -}; +} ohci_endpoint_descriptor; #define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f #define OHCI_ENDPOINT_GET_DEVICE_ADDRESS(s) ((s) & 0x7f) @@ -333,8 +331,7 @@ // General transfer descriptor structure (section 4.3.1) // -------------------------------- -typedef struct ohci_general_td -{ +typedef struct { // Hardware part 16 bytes uint32 flags; // Flags field uint32 buffer_physical; // Physical buffer pointer @@ -348,7 +345,7 @@ size_t buffer_size; // Size of the buffer void *transfer; // Pointer to the transfer_data bool is_last; // Last descriptor of the transfer -}; +} ohci_general_td; #define OHCI_BUFFER_ROUNDING 0x00040000 #define OHCI_TD_DIRECTION_PID_MASK 0x00180000 @@ -374,8 +371,7 @@ // -------------------------------- #define OHCI_ITD_NOFFSET 8 -typedef struct ohci_isochronous_td -{ +typedef struct { // Hardware part 32 byte uint32 flags; uint32 buffer_page_byte_0; // Physical page number of byte 0 @@ -386,7 +382,7 @@ addr_t physical_address; // Physical address of this descriptor void *next_logical_descriptor; // Logical pointer next descriptor void *next_done_descriptor; // Used for collision in the hash table -}; +} ohci_isochronous_td; #define OHCI_ITD_GET_STARTING_FRAME(x) ((x) & 0x0000ffff) #define OHCI_ITD_SET_STARTING_FRAME(x) ((x) & 0xffff) From mmlr at mail.berlios.de Sun May 18 11:36:06 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 May 2008 11:36:06 +0200 Subject: [Haiku-commits] r25539 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805180936.m4I9a64R028971@sheep.berlios.de> Author: mmlr Date: 2008-05-18 11:36:06 +0200 (Sun, 18 May 2008) New Revision: 25539 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25539&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: Acknowledge OHCI interrupts. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 09:23:29 UTC (rev 25538) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 09:36:06 UTC (rev 25539) @@ -650,6 +650,7 @@ acquire_spinlock(&lock); uint32 status = 0; + uint32 acknowledge = 0; bool finishTransfers = false; int32 result = B_HANDLED_INTERRUPT; @@ -679,20 +680,20 @@ } if (status & OHCI_SCHEDULING_OVERRUN) { - // TODO TRACE(("usb_ohci: scheduling overrun occured\n")); + acknowledge |= OHCI_SCHEDULING_OVERRUN; } if (status & OHCI_WRITEBACK_DONE_HEAD) { TRACE(("usb_ohci: transfer descriptor processed\n")); - // Ack it in the finisher thread, not here. + // Acknowledge it in the finisher thread, not here. result = B_INVOKE_SCHEDULER; finishTransfers = true; } if (status & OHCI_RESUME_DETECTED) { - // TODO TRACE(("usb_ohci: resume detected\n")); + acknowledge |= OHCI_RESUME_DETECTED; } if (status & OHCI_UNRECOVERABLE_ERROR) { @@ -703,10 +704,13 @@ } if (status & OHCI_ROOT_HUB_STATUS_CHANGE) { - // TODO TRACE(("usb_ohci: root hub status change\n")); + acknowledge |= OHCI_ROOT_HUB_STATUS_CHANGE; } + if (acknowledge != 0) + _WriteReg(OHCI_INTERRUPT_STATUS, acknowledge); + release_spinlock(&lock); if (finishTransfers) From mmlr at mail.berlios.de Sun May 18 12:27:32 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 May 2008 12:27:32 +0200 Subject: [Haiku-commits] r25540 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805181027.m4IARW1U032573@sheep.berlios.de> Author: mmlr Date: 2008-05-18 12:27:31 +0200 (Sun, 18 May 2008) New Revision: 25540 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25540&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: * Complete the roothub get/set/clear port feature functions * Reorder to match the usual order of the states/commands * Fix some debug output and make it more informative Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 09:36:06 UTC (rev 25539) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2008-05-18 10:27:31 UTC (rev 25540) @@ -555,9 +555,10 @@ status_t OHCI::GetPortStatus(uint8 index, usb_port_status *status) { - TRACE(("usb_ohci: get port status %ud\n", index)); - if (index >= fPortCount) + if (index >= fPortCount) { + TRACE_ERROR(("usb_ohci: get port status for invalid port %u\n", index)); return B_BAD_INDEX; + } status->status = status->change = 0; uint32 portStatus = _ReadReg(OHCI_RH_PORT_STATUS(index)); @@ -567,16 +568,16 @@ status->status |= PORT_STATUS_CONNECTION; if (portStatus & OHCI_RH_PORTSTATUS_PES) status->status |= PORT_STATUS_ENABLE; - if (portStatus & OHCI_RH_PORTSTATUS_PRS) - status->status |= PORT_STATUS_RESET; - if (portStatus & OHCI_RH_PORTSTATUS_LSDA) - status->status |= PORT_STATUS_LOW_SPEED; if (portStatus & OHCI_RH_PORTSTATUS_PSS) status->status |= PORT_STATUS_SUSPEND; if (portStatus & OHCI_RH_PORTSTATUS_POCI) status->status |= PORT_STATUS_OVER_CURRENT; + if (portStatus & OHCI_RH_PORTSTATUS_PRS) + status->status |= PORT_STATUS_RESET; if (portStatus & OHCI_RH_PORTSTATUS_PPS) status->status |= PORT_STATUS_POWER; + if (portStatus & OHCI_RH_PORTSTATUS_LSDA) + status->status |= PORT_STATUS_LOW_SPEED; // change if (portStatus & OHCI_RH_PORTSTATUS_CSC) @@ -590,6 +591,8 @@ if (portStatus & OHCI_RH_PORTSTATUS_PRSC) status->change |= PORT_STATUS_RESET; + TRACE(("usb_ohci: port %u status 0x%04x change 0x%04x\n", index, + status->status, status->change)); return B_OK; } @@ -597,11 +600,19 @@ status_t OHCI::SetPortFeature(uint8 index, uint16 feature) { - TRACE(("usb_ohci: set port feature index %ud feature %ud)\n", index, feature)); + TRACE(("usb_ohci: set port feature index %u feature %u\n", index, feature)); if (index > fPortCount) return B_BAD_INDEX; switch (feature) { + case PORT_ENABLE: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PES); + return B_OK; + + case PORT_SUSPEND: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PSS); + return B_OK; + case PORT_RESET: _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PRS); return B_OK; @@ -618,18 +629,42 @@ status_t OHCI::ClearPortFeature(uint8 index, uint16 feature) { - TRACE(("usb_ohci: clear port feature index %ud feature %ud\n", index, feature)); + TRACE(("usb_ohci: clear port feature index %u feature %u\n", index, feature)); if (index > fPortCount) return B_BAD_INDEX; switch (feature) { - case C_PORT_RESET: - _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); + case PORT_ENABLE: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CCS); return B_OK; + case PORT_SUSPEND: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_POCI); + return B_OK; + + case PORT_POWER: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_LSDA); + return B_OK; + case C_PORT_CONNECTION: _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_CSC); return B_OK; + + case C_PORT_ENABLE: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PESC); + return B_OK; + + case C_PORT_SUSPEND: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PSSC); + return B_OK; + + case C_PORT_OVER_CURRENT: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_OCIC); + return B_OK; + + case C_PORT_RESET: + _WriteReg(OHCI_RH_PORT_STATUS(index), OHCI_RH_PORTSTATUS_PRSC); + return B_OK; } return B_BAD_VALUE; From mmlr at mail.berlios.de Sun May 18 14:16:34 2008 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 18 May 2008 14:16:34 +0200 Subject: [Haiku-commits] r25541 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200805181216.m4ICGYE4031512@sheep.berlios.de> Author: mmlr Date: 2008-05-18 14:16:34 +0200 (Sun, 18 May 2008) New Revision: 25541 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=25541&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp haiku/trunk/src/add-ons/kernel/busses/usb/ohci.h haiku/trunk/src/add-ons/kernel/busses/usb/ohci_hardware.h Log: * Implement "tail switching" so that a new transfer descriptor chain can be appended to an endpoint descriptor without locking/disabling the endpoint. * Correct the direction of the data phase of a control transfer. * Some minor cleanup. Control requests without data phase (set address for example) might actually work now, but this is still untested. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp ==========================