From ingo_weinhold at gmx.de Fri Aug 1 01:20:23 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 01 Aug 2008 01:20:23 +0200 Subject: [Haiku-commits] r26706 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <2486063579-BeMail@laptop> References: <2486063579-BeMail@laptop> Message-ID: <20080801012023.653.1@knochen-vm.localdomain> On 2008-07-31 at 23:22:58 [+0200], Fran?ois Revol wrote: > > Log: > > * Removed no longer needed IOCTL_FILE_UNCACHED_IO definition. > > Don't we have O_SYNC open flag anyway to specify this in a more > standard manner ? We have, it's just not supported. :-) We also have a yet unsupported O_NOCACHE, which we need quite soon for the swap file support. CU, Ingo From ingo_weinhold at gmx.de Fri Aug 1 01:20:23 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 01 Aug 2008 01:20:23 +0200 Subject: [Haiku-commits] r26706 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <2486063579-BeMail@laptop> References: <2486063579-BeMail@laptop> Message-ID: <20080801012023.653.1@knochen-vm.localdomain> On 2008-07-31 at 23:22:58 [+0200], Fran?ois Revol wrote: > > Log: > > * Removed no longer needed IOCTL_FILE_UNCACHED_IO definition. > > Don't we have O_SYNC open flag anyway to specify this in a more > standard manner ? We have, it's just not supported. :-) We also have a yet unsupported O_NOCACHE, which we need quite soon for the swap file support. CU, Ingo From revol at free.fr Fri Aug 1 01:26:38 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 01 Aug 2008 01:26:38 +0200 CEST Subject: [Haiku-commits] r26706 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <20080801012023.653.1@knochen-vm.localdomain> Message-ID: <4748130433-BeMail@laptop> > > On 2008-07-31 at 23:22:58 [+0200], Fran?ois Revol > wrote: > > > Log: > > > * Removed no longer needed IOCTL_FILE_UNCACHED_IO definition. > > > > Don't we have O_SYNC open flag anyway to specify this in a more > > standard manner ? > > We have, it's just not supported. :-) We also have a yet unsupported > O_NOCACHE, which we need quite soon for the swap file support. There is also O_DIRECT and O_DSYNC but I'm not sure I'm awake enough to see the difference to all of them. Fran?ois. From bonefish at mail.berlios.de Fri Aug 1 01:46:07 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 1 Aug 2008 01:46:07 +0200 Subject: [Haiku-commits] r26709 - haiku/trunk/src/system/kernel Message-ID: <200807312346.m6VNk7IT020338@sheep.berlios.de> Author: bonefish Date: 2008-08-01 01:45:56 +0200 (Fri, 01 Aug 2008) New Revision: 26709 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26709&view=rev Modified: haiku/trunk/src/system/kernel/scheduler.cpp Log: Superfluous whitespace. Modified: haiku/trunk/src/system/kernel/scheduler.cpp =================================================================== --- haiku/trunk/src/system/kernel/scheduler.cpp 2008-07-31 21:59:06 UTC (rev 26708) +++ haiku/trunk/src/system/kernel/scheduler.cpp 2008-07-31 23:45:56 UTC (rev 26709) @@ -6,7 +6,7 @@ * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. * Distributed under the terms of the NewOS License. */ - + /*! The thread scheduler */ From bonefish at mail.berlios.de Fri Aug 1 01:54:20 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 1 Aug 2008 01:54:20 +0200 Subject: [Haiku-commits] r26710 - haiku/trunk/src/system/kernel/vm Message-ID: <200807312354.m6VNsKUn021627@sheep.berlios.de> Author: bonefish Date: 2008-08-01 01:54:14 +0200 (Fri, 01 Aug 2008) New Revision: 26710 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26710&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: The page queues no longer count added dummy pages. This fixes a problem in steal_pages() which uses the number of pages in the inactive queue as return criterion. It would thus return, if only marker pages were in the queue and no page could be stolen. This led to a busy loop in vm_page_allocate_page(). The whole system would become unusable when the thread in question was the heap grower, since it would starve everyone else due to its high priority. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-07-31 23:45:56 UTC (rev 26709) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-07-31 23:54:14 UTC (rev 26710) @@ -236,7 +236,8 @@ page->queue_next->queue_prev = NULL; queue->head = page->queue_next; - queue->count--; + if (page->type != PAGE_TYPE_DUMMY) + queue->count--; #ifdef DEBUG_PAGE_QUEUE if (page->queue != queue) { @@ -270,7 +271,8 @@ page->queue_next = NULL; if (queue->head == NULL) queue->head = page; - queue->count++; + if (page->type != PAGE_TYPE_DUMMY) + queue->count++; #ifdef DEBUG_PAGE_QUEUE page->queue = queue; @@ -296,7 +298,8 @@ page->queue_prev = NULL; if (queue->tail == NULL) queue->tail = page; - queue->count++; + if (page->type != PAGE_TYPE_DUMMY) + queue->count++; #ifdef DEBUG_PAGE_QUEUE page->queue = queue; @@ -324,7 +327,8 @@ else queue->head = page->queue_next; - queue->count--; + if (page->type != PAGE_TYPE_DUMMY) + queue->count--; #ifdef DEBUG_PAGE_QUEUE page->queue = NULL; @@ -370,7 +374,8 @@ if (queue->tail == before) queue->tail = page; - queue->count++; + if (page->type != PAGE_TYPE_DUMMY) + queue->count++; #ifdef DEBUG_PAGE_QUEUE page->queue = queue; From bonefish at mail.berlios.de Fri Aug 1 02:24:01 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 1 Aug 2008 02:24:01 +0200 Subject: [Haiku-commits] r26711 - haiku/trunk/src/system/kernel/vm Message-ID: <200808010024.m710O13g026056@sheep.berlios.de> Author: bonefish Date: 2008-08-01 02:23:56 +0200 (Fri, 01 Aug 2008) New Revision: 26711 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26711&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Added TODO -- food for thoughts. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-07-31 23:54:14 UTC (rev 26710) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-01 00:23:56 UTC (rev 26711) @@ -1719,6 +1719,19 @@ } cache->Unlock(); +// TODO: Allocating pages with the address space write locked is not a good +// idea, particularly if that's the kernel's address space. During that time the +// low memory handler will block (e.g. the block cache will try to delete +// areas). The cache backing our area has reserved the memory and thus there +// should be enough pages available (i.e. could be freed by page write/daemon), +// but this is not true for at least two reasons: +// * The pages for page directories/tables are not reserved from the available +// memory (we should do that!) and currently we don't reclaim them (and +// probably can't reclaim all of them anyway). Thus there are actually less +// pages than there should be. +// * ATM we write pages back using virtual addresses. The lower I/O layers will +// try to lock the memory, which will block, since that requires to read-lock +// the address space. vm_page_unreserve_pages(reservePages); break; } From axeld at pinc-software.de Fri Aug 1 11:07:19 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 01 Aug 2008 11:07:19 +0200 CEST Subject: [Haiku-commits] r26707 - in haiku/trunk/headers/os/bluetooth: . HCI In-Reply-To: <200807312111.m6VLBkG6017176@sheep.berlios.de> Message-ID: <7241822586-BeMail@zon> oruizdorantes at mail.berlios.de wrote: > Log: > Bring to the stack the LinkKey datatype by Mika Lindqvist Just some coding style comments: > @@ -1,5 +1,6 @@ > /* > * Copyright 2007 Oliver Ruiz Dorantes, > oliver.ruiz.dorantes_at_gmail.com > + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com > * > * All rights reserved. Distributed under the terms of the MIT > License. > * The last line with '*' should be removed. > @@ -170,7 +171,7 @@ > #define HCI_EVENT_RETURN_LINK_KEYS 0x15 > struct link_key_info { > bdaddr_t bdaddr; > - uint8 link_key[HCI_LINK_KEY_SIZE]; > + linkkey_t link_key; > } __attribute__ ((packed)) ; Why not use _PACKED instead? > --- haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h 2008-07-31 > 21:09:02 UTC (rev 26706) > +++ haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h 2008-07-31 > 21:11:42 UTC (rev 26707) > @@ -0,0 +1,73 @@ > +/* > + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com > + * > + * All rights reserved. Distributed under the terms of the MIT > License. > + * > + */ > + > +#ifndef _LINKKEY_UTILS_H Remove the lines with a single '*', remove the blank line between copyright notice and header guard. > +class LinkKeyUtils { > +public: > + static bool Compare(linkkey_t* lk1, linkkey_t* lk2) > + { > + return (memcmp(lk1, lk2, sizeof(linkkey_t)) == 0); > + } Single tab to indent, not two of them. No () for return, ie. it should look like this: return memcmp(lk1, lk2, sizeof(linkkey_t)) == 0; > + static linkkey_t NullKey() > + { > + return (linkkey_t) {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0}}; > + } No space between cast and term. > + static char* ToString(const linkkey_t lk) > + { > + > + // TODO: not safe > + static char str[50]; Why not just use snprintf() then? Please remove extraneous blank line. > + sprintf(str, > "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" > + > "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", > + lk.l[0], lk.l[1], lk.l[2], lk.l[3], > + lk.l[4], lk.l[5], lk.l[6], lk.l[7], > + lk.l[8], lk.l[9], lk.l[10], lk.l[11], > + lk.l[12], lk.l[13], lk.l[14], lk.l[15]); The arguments on the next line are indented exactly one tab, not this multi-tab-space mix. > + if (lkstr != NULL) > + { [...] > + if (count == 16) > + { Opening brackets go to the same line, not the next. > +#endif > \ No newline at end of file Please add a newline at the end of the file, too. > Modified: haiku/trunk/headers/os/bluetooth/bluetooth.h > =================================================================== [...] > -#define BLUETOOTH_PROTO_MAX 256 > +#define BLUETOOTH_PROTO_MAX 256 > > > #endif Header guard comment missing (ie. what does this #endif belong to?) There is a coding style guide on the net, and while it might not be 100% accurate, it's pretty close to what we *should* do. Bye, Axel. From axeld at mail.berlios.de Fri Aug 1 11:57:15 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 11:57:15 +0200 Subject: [Haiku-commits] r26712 - in haiku/trunk/headers/private: fs_shell kernel/util Message-ID: <200808010957.m719vFoT001588@sheep.berlios.de> Author: axeld Date: 2008-08-01 11:57:14 +0200 (Fri, 01 Aug 2008) New Revision: 26712 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26712&view=rev Modified: haiku/trunk/headers/private/fs_shell/SinglyLinkedList.h haiku/trunk/headers/private/kernel/util/SinglyLinkedList.h Log: * Minor cleanup. Modified: haiku/trunk/headers/private/fs_shell/SinglyLinkedList.h =================================================================== --- haiku/trunk/headers/private/fs_shell/SinglyLinkedList.h 2008-08-01 00:23:56 UTC (rev 26711) +++ haiku/trunk/headers/private/fs_shell/SinglyLinkedList.h 2008-08-01 09:57:14 UTC (rev 26712) @@ -23,7 +23,7 @@ SinglyLinkedListLink() : next(NULL) {} ~SinglyLinkedListLink() {} - Element *next; + Element* next; }; // SinglyLinkedListLinkImpl @@ -180,8 +180,7 @@ SINGLY_LINKED_LIST_CLASS_NAME::Add(Element* element) { if (element != NULL) { - Link* link = sGetLink(element); - link->next = fFirst; + sGetLink(element)->next = fFirst; fFirst = element; } } Modified: haiku/trunk/headers/private/kernel/util/SinglyLinkedList.h =================================================================== --- haiku/trunk/headers/private/kernel/util/SinglyLinkedList.h 2008-08-01 00:23:56 UTC (rev 26711) +++ haiku/trunk/headers/private/kernel/util/SinglyLinkedList.h 2008-08-01 09:57:14 UTC (rev 26712) @@ -17,7 +17,7 @@ SinglyLinkedListLink() : next(NULL) {} ~SinglyLinkedListLink() {} - Element *next; + Element* next; }; // SinglyLinkedListLinkImpl @@ -174,8 +174,7 @@ SINGLY_LINKED_LIST_CLASS_NAME::Add(Element* element) { if (element != NULL) { - Link* link = sGetLink(element); - link->next = fFirst; + sGetLink(element)->next = fFirst; fFirst = element; } } From axeld at mail.berlios.de Fri Aug 1 11:59:20 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 11:59:20 +0200 Subject: [Haiku-commits] r26713 - in haiku/trunk: headers/os/drivers headers/private/fs_shell src/system/kernel/fs src/tools/fs_shell Message-ID: <200808010959.m719xKXg001755@sheep.berlios.de> Author: axeld Date: 2008-08-01 11:59:19 +0200 (Fri, 01 Aug 2008) New Revision: 26713 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26713&view=rev Modified: haiku/trunk/headers/os/drivers/fs_interface.h haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/tools/fs_shell/vfs.cpp Log: * Added acquire_vnode() call that you can use to get another reference to an inode - unlike get_vnode() the busy flag won't prevent you from getting that reference. * Changed put_vnode() to return an error in case the vnode couldn't be found. Modified: haiku/trunk/headers/os/drivers/fs_interface.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_interface.h 2008-08-01 09:57:14 UTC (rev 26712) +++ haiku/trunk/headers/os/drivers/fs_interface.h 2008-08-01 09:59:19 UTC (rev 26713) @@ -309,6 +309,7 @@ extern status_t get_vnode(fs_volume *volume, ino_t vnodeID, void **_privateNode); extern status_t put_vnode(fs_volume *volume, ino_t vnodeID); +extern status_t acquire_vnode(fs_volume *volume, ino_t vnodeID); extern status_t remove_vnode(fs_volume *volume, ino_t vnodeID); extern status_t unremove_vnode(fs_volume *volume, ino_t vnodeID); extern status_t get_vnode_removed(fs_volume *volume, ino_t vnodeID, Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-01 09:57:14 UTC (rev 26712) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-01 09:59:19 UTC (rev 26713) @@ -905,6 +905,7 @@ #define publish_vnode fssh_publish_vnode #define get_vnode fssh_get_vnode #define put_vnode fssh_put_vnode +#define acquire_vnode fssh_acquire_vnode #define remove_vnode fssh_remove_vnode #define unremove_vnode fssh_unremove_vnode #define get_vnode_removed fssh_get_vnode_removed Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h 2008-08-01 09:57:14 UTC (rev 26712) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_interface.h 2008-08-01 09:59:19 UTC (rev 26713) @@ -347,6 +347,8 @@ fssh_vnode_id vnodeID, void **_privateNode); extern fssh_status_t fssh_put_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID); +extern fssh_status_t fssh_acquire_vnode(fssh_fs_volume *volume, + fssh_vnode_id vnodeID); extern fssh_status_t fssh_remove_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID); extern fssh_status_t fssh_unremove_vnode(fssh_fs_volume *volume, Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-01 09:57:14 UTC (rev 26712) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-01 09:59:19 UTC (rev 26713) @@ -3194,6 +3194,23 @@ extern "C" status_t +acquire_vnode(fs_volume *volume, ino_t vnodeID) +{ + struct vnode *vnode; + + mutex_lock(&sVnodeMutex); + vnode = lookup_vnode(volume->id, vnodeID); + mutex_unlock(&sVnodeMutex); + + if (vnode == NULL) + return B_BAD_VALUE; + + inc_vnode_ref_count(vnode); + return B_OK; +} + + +extern "C" status_t put_vnode(fs_volume *volume, ino_t vnodeID) { struct vnode *vnode; @@ -3202,9 +3219,10 @@ vnode = lookup_vnode(volume->id, vnodeID); mutex_unlock(&sVnodeMutex); - if (vnode) - dec_vnode_ref_count(vnode, false, true); + if (vnode == NULL) + return B_BAD_VALUE; + dec_vnode_ref_count(vnode, false, true); return B_OK; } Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/vfs.cpp 2008-08-01 09:57:14 UTC (rev 26712) +++ haiku/trunk/src/tools/fs_shell/vfs.cpp 2008-08-01 09:59:19 UTC (rev 26713) @@ -2018,6 +2018,23 @@ extern "C" fssh_status_t +fssh_acquire_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID) +{ + struct vnode *vnode; + + fssh_mutex_lock(&sVnodeMutex); + vnode = lookup_vnode(volume->id, vnodeID); + fssh_mutex_unlock(&sVnodeMutex); + + if (vnode == NULL) + return FSSH_B_BAD_VALUE; + + inc_vnode_ref_count(vnode); + return FSSH_B_OK; +} + + +extern "C" fssh_status_t fssh_put_vnode(fssh_fs_volume *volume, fssh_vnode_id vnodeID) { struct vnode *vnode; @@ -2026,9 +2043,10 @@ vnode = lookup_vnode(volume->id, vnodeID); fssh_mutex_unlock(&sVnodeMutex); - if (vnode) - dec_vnode_ref_count(vnode, true); + if (vnode == NULL) + return FSSH_B_BAD_VALUE; + dec_vnode_ref_count(vnode, true); return FSSH_B_OK; } From oliver.ruiz.dorantes at gmail.com Fri Aug 1 12:17:51 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Fri, 1 Aug 2008 12:17:51 +0200 Subject: [Haiku-commits] r26707 - in haiku/trunk/headers/os/bluetooth: . HCI In-Reply-To: <7241822586-BeMail@zon> References: <200807312111.m6VLBkG6017176@sheep.berlios.de> <7241822586-BeMail@zon> Message-ID: 2008/8/1 Axel D?rfler > oruizdorantes at mail.berlios.de wrote: > > Log: > > Bring to the stack the LinkKey datatype by Mika Lindqvist > > Just some coding style comments: Thanks Axel > > + static char* ToString(const linkkey_t lk) > > + { > > + > > + // TODO: not safe > > + static char str[50]; > > Why not just use snprintf() then? Its not due the size, but the static bar, whould not be thread safe. > There is a coding style guide on the net, and while it might not be > 100% accurate, it's pretty close to what we *should* do. Step by step all will be compilant, I promise ;) -- Oliver, http://urnenfeld.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From superstippi at gmx.de Fri Aug 1 12:23:38 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 01 Aug 2008 12:23:38 +0200 Subject: [Haiku-commits] r26707 - in haiku/trunk/headers/os/bluetooth: . HCI In-Reply-To: References: <200807312111.m6VLBkG6017176@sheep.berlios.de> <7241822586-BeMail@zon> Message-ID: <20080801122338.825.2@stippis2.1217581824.fake> Hi, Oliver Ruiz Dorantes wrote: > > > + static char* ToString(const linkkey_t lk) > > > + { > > > + > > > + // TODO: not safe > > > + static char str[50]; > > > > Why not just use snprintf() then? > > Its not due the size, but the static bar, whould not be thread safe. I thought so too when reading the patch. > > There is a coding style guide on the net, and while it might not be > > 100% accurate, it's pretty close to what we *should* do. > > Step by step all will be compilant, > I promise ;) Then please don't check in any more new code that violates the style guide. :-) Best regards, -Stephan From oliver.ruiz.dorantes at gmail.com Fri Aug 1 13:25:02 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Fri, 1 Aug 2008 13:25:02 +0200 Subject: [Haiku-commits] r26707 - in haiku/trunk/headers/os/bluetooth: . HCI In-Reply-To: <7241822586-BeMail@zon> References: <200807312111.m6VLBkG6017176@sheep.berlios.de> <7241822586-BeMail@zon> Message-ID: hi back 2008/8/1 Axel D?rfler > > -#define BLUETOOTH_PROTO_MAX 256 > > +#define BLUETOOTH_PROTO_MAX 256 > > > > > > #endif > > Header guard comment missing (ie. what does this #endif belong to?) I have not seen in the guidelines this point. Others rules for example regardling blank lines.. are also not really accurated regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From axeld at mail.berlios.de Fri Aug 1 14:07:41 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 14:07:41 +0200 Subject: [Haiku-commits] r26714 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808011207.m71C7f6R003937@sheep.berlios.de> Author: axeld Date: 2008-08-01 14:07:41 +0200 (Fri, 01 Aug 2008) New Revision: 26714 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26714&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp Log: * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2008-08-01 09:59:19 UTC (rev 26713) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2008-08-01 12:07:41 UTC (rev 26714) @@ -369,7 +369,8 @@ // replaying the log is the first thing we will do on this disk status = fJournal->ReplayLog(); if (status < B_OK) { - FATAL(("Replaying log failed, data may be corrupted, volume read-only.\n")); + FATAL(("Replaying log failed, data may be corrupted, volume " + "read-only.\n")); fFlags |= VOLUME_READ_ONLY; // TODO: if this is the boot volume, Bootscript will assume this // is a CD... @@ -405,6 +406,8 @@ delete fIndicesNode; fIndicesNode = NULL; } + } else { + // we don't use the vnode layer to access the indices node } // all went fine @@ -426,7 +429,6 @@ status_t Volume::Unmount() { - // Unlike in BeOS, we need to put the reference to our root node ourselves put_vnode(fVolume, ToVnode(Root())); fBlockAllocator.Uninitialize(); @@ -458,7 +460,8 @@ || run.AllocationGroup() > (int32)AllocationGroups() || run.Start() > (1UL << AllocationGroupShift()) || run.length == 0 - || uint32(run.Length() + run.Start()) > (1UL << AllocationGroupShift())) { + || uint32(run.Length() + run.Start()) + > (1UL << AllocationGroupShift())) { Panic(); FATAL(("*** invalid run(%d,%d,%d)\n", (int)run.AllocationGroup(), run.Start(), run.Length())); @@ -706,10 +709,6 @@ WriteSuperBlock(); transaction.Done(); -// put_vnode(ID(), fRootNode->ID()); -// if (fIndicesNode != NULL) -// put_vnode(ID(), fIndicesNode->ID()); - Sync(); opener.RemoveCache(true); return B_OK; From axeld at mail.berlios.de Fri Aug 1 14:28:30 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 14:28:30 +0200 Subject: [Haiku-commits] r26715 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808011228.m71CSUjD005693@sheep.berlios.de> Author: axeld Date: 2008-08-01 14:28:28 +0200 (Fri, 01 Aug 2008) New Revision: 26715 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26715&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Utility.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/system_dependencies.h Log: * Changed the inode write locking to be held as long as the transaction is running - this fixes several cases where someone could see outdated data when a transaction had to be reverted (the time between unlocking the inode and actually reverting the blocks). For that, Inodes can now be put into a singly linked list. * Added a TODO in Inode::WriteAt() which explains why it cannot use the above method: seems that our VFS/VM locking model isn't really that good. * Fixed a possible deadlock in Attribute::_Truncate() where the inode write lock was held before starting the transaction. * Added an InodeReadLocker convenience class, that should be used instead of ReadLocker - Inode::Lock() only still exists because of the needs of bfs_io(). * Moved the bfs_io() callback hooks out of the exported module API region, and removed their bfs_ prefix. * Added a Volume::IsInitializing() method that should be used rather than checking if Volume::ID() is >= 0. * Removed the MultiInodeLocker again, as it's pretty much superfluous now. * Moved openModeToAccess() to the Utility.h header. * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-01 12:07:41 UTC (rev 26714) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-01 12:28:28 UTC (rev 26715) @@ -58,9 +58,10 @@ // Opening the name attribute using this function is not allowed, // also using the reserved indices name, last_modified, and size // shouldn't be allowed. - // ToDo: we might think about allowing to update those values, but + // TODO: we might think about allowing to update those values, but // really change their corresponding values in the bfs_inode structure if (name[0] == FILE_NAME_NAME && name[1] == '\0' +// TODO: reenable this check -- some WonderBrush locale files used them /* || !strcmp(name, "name") || !strcmp(name, "last_modified") || !strcmp(name, "size")*/) @@ -223,9 +224,9 @@ } if (fAttribute != NULL) { - WriteLocker locker(fAttribute->Lock()); Transaction transaction(fAttribute->GetVolume(), fAttribute->BlockNumber()); + fAttribute->WriteLockInTransaction(transaction); status_t status = fAttribute->SetFileSize(transaction, 0); if (status >= B_OK) Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-01 12:07:41 UTC (rev 26714) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-01 12:28:28 UTC (rev 26715) @@ -241,7 +241,7 @@ if (fTree == NULL || fTree->fStream == NULL || offset == BPLUSTREE_NULL) RETURN_ERROR(B_BAD_VALUE); - // ToDo: scan the free nodes list and remove all nodes at the end + // TODO: scan the free nodes list and remove all nodes at the end // of the tree - perhaps that shouldn't be done everytime that // function is called, perhaps it should be done when the directory // inode is closed or based on some calculation or whatever... @@ -1258,7 +1258,7 @@ panic("tried to insert invalid value %Ld!\n", value); #endif - ASSERT_WRITE_LOCKED_RW_LOCK(&fStream->Lock()); + ASSERT_WRITE_LOCKED_INODE(fStream); Stack stack; if (_SeekDown(stack, key, keyLength) != B_OK) @@ -1649,7 +1649,7 @@ || keyLength > BPLUSTREE_MAX_KEY_LENGTH) RETURN_ERROR(B_BAD_VALUE); - ASSERT_WRITE_LOCKED_RW_LOCK(&fStream->Lock()); + ASSERT_WRITE_LOCKED_INODE(fStream); Stack stack; if (_SeekDown(stack, key, keyLength) != B_OK) @@ -1766,7 +1766,7 @@ if (fAllowDuplicates) RETURN_ERROR(B_BAD_TYPE); - ASSERT_WRITE_LOCKED_RW_LOCK(&fStream->Lock()); + ASSERT_WRITE_LOCKED_INODE(fStream); off_t nodeOffset = fHeader->RootNode(); CachedNode cached(this); @@ -1819,7 +1819,7 @@ if (fAllowDuplicates) RETURN_ERROR(B_BAD_TYPE); - ASSERT_READ_LOCKED_RW_LOCK(&fStream->Lock()); + ASSERT_READ_LOCKED_INODE(fStream); off_t nodeOffset = fHeader->RootNode(); CachedNode cached(this); @@ -1883,7 +1883,7 @@ RETURN_ERROR(B_BAD_VALUE); // lock access to stream - ReadLocker locker(fTree->fStream->Lock()); + InodeReadLocker locker(fTree->fStream); off_t nodeOffset = fTree->fHeader->RootNode(); CachedNode cached(fTree); @@ -1953,7 +1953,7 @@ return B_ENTRY_NOT_FOUND; // lock access to stream - ReadLocker locker(fTree->fStream->Lock()); + InodeReadLocker locker(fTree->fStream); CachedNode cached(fTree); const bplustree_node *node; @@ -2088,7 +2088,7 @@ RETURN_ERROR(B_BAD_VALUE); // lock access to stream - ReadLocker locker(fTree->fStream->Lock()); + InodeReadLocker locker(fTree->fStream); off_t nodeOffset = fTree->fHeader->RootNode(); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp 2008-08-01 12:07:41 UTC (rev 26714) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp 2008-08-01 12:28:28 UTC (rev 26715) @@ -75,7 +75,7 @@ if (indices == NULL) return B_ENTRY_NOT_FOUND; - ReadLocker locker(indices->Lock()); + InodeReadLocker locker(indices); BPlusTree *tree; if (indices->GetTree(&tree) != B_OK) @@ -201,7 +201,6 @@ return B_BAD_TYPE; } - // do we need to create the index directory first? if (fVolume->IndicesNode() == NULL) { status_t status = fVolume->CreateIndicesRoot(transaction); @@ -270,7 +269,7 @@ // remove the old key from the tree - WriteLocker locker(Node()->Lock()); + Node()->WriteLockInTransaction(transaction); if (oldKey != NULL) { status = tree->Remove(transaction, (const uint8 *)oldKey, oldLength, Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-01 12:07:41 UTC (rev 26714) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-01 12:28:28 UTC (rev 26715) @@ -169,7 +169,6 @@ fInode->Node().flags &= ~HOST_ENDIAN_TO_BFS_INT32(INODE_IN_USE); // this unblocks any pending bfs_read_vnode() calls fInode->Free(*fTransaction); - rw_lock_write_unlock(&fInode->Lock()); remove_vnode(volume->FSVolume(), fInode->ID()); } else volume->Free(*fTransaction, fRun); @@ -199,7 +198,7 @@ if (fInode == NULL) RETURN_ERROR(B_NO_MEMORY); - if (volume->ID() >= 0) { + if (!volume->IsInitializing()) { status = new_vnode(volume->FSVolume(), fInode->ID(), fInode, vnodeOps != NULL ? vnodeOps : &gBFSVnodeOps); if (status < B_OK) { @@ -209,7 +208,7 @@ } } - rw_lock_write_lock(&fInode->Lock()); + fInode->WriteLockInTransaction(*fTransaction); *_inode = fInode; return B_OK; } @@ -261,8 +260,6 @@ TRANSACTION_ABORTED, &_TransactionListener, fInode); } - rw_lock_write_unlock(&fInode->Lock()); - fTransaction = NULL; fInode = NULL; @@ -305,7 +302,7 @@ if (Flags() & INODE_DELETED) return B_NOT_ALLOWED; - // ToDo: Add some tests to check the integrity of the other stuff here, + // TODO: Add some tests to check the integrity of the other stuff here, // especially for the data_stream! return B_OK; @@ -1059,7 +1056,8 @@ } if (attribute != NULL) { - if (rw_lock_write_lock(&attribute->Lock()) == B_OK) { + // TODO: we need to lock the inode in the transaction, see WriteAt()! + if (rw_lock_write_lock(&attribute->fLock) == B_OK) { // Save the old attribute data (if this fails, oldLength will // reflect it) if (fVolume->CheckForLiveQuery(name) && attribute->Size() > 0) { @@ -1075,14 +1073,14 @@ if (status == B_OK) { // it does - remove its file - rw_lock_write_unlock(&attribute->Lock()); + rw_lock_write_unlock(&attribute->fLock); status = _RemoveAttribute(transaction, name, false, NULL); } else { // The attribute type might have been changed - we need to // adopt the new one attribute->Node().type = HOST_ENDIAN_TO_BFS_INT32(type); status = attribute->WriteBack(transaction); - rw_lock_write_unlock(&attribute->Lock()); + rw_lock_write_unlock(&attribute->fLock); if (status == B_OK) { status = attribute->WriteAt(transaction, pos, buffer, @@ -1167,7 +1165,7 @@ BPlusTree *tree; status_t status = attributes->GetTree(&tree); if (status == B_OK) { - ReadLocker locker(attributes->Lock()); + InodeReadLocker locker(attributes); ino_t id; status = tree->Find((uint8 *)name, (uint16)strlen(name), &id); @@ -1382,7 +1380,7 @@ if (pos < 0) return B_BAD_VALUE; - ReadLocker locker(Lock()); + InodeReadLocker locker(this); if (pos >= Size() || length == 0) { *_length = 0; @@ -1399,13 +1397,11 @@ Inode::WriteAt(Transaction &transaction, off_t pos, const uint8 *buffer, size_t *_length) { - WriteLocker locker(Lock()); - if (!locker.IsLocked()) - RETURN_ERROR(B_ERROR); + InodeReadLocker locker(this); // update the last modification time in memory, it will be written // back to the inode, and the index when the file is closed - // ToDo: should update the internal last modified time only at this point! + // TODO: should update the internal last modified time only at this point! Node().last_modified_time = HOST_ENDIAN_TO_BFS_INT64((bigtime_t)time(NULL) << INODE_TIME_SHIFT); @@ -1427,7 +1423,12 @@ if (changeSize && !transaction.IsStarted()) transaction.Start(fVolume, BlockNumber()); - locker.Lock(); + // TODO: we actually need to call WriteLockInTransaction() here, but we + // cannot do this with the current locking model (ie. file cache functions + // are not to be called with the inode lock held). + // But this cannot work anyway, since we hold the lock when calling + // file_cache_set_size(), too... (possible deadlock) + rw_lock_write_lock(&fLock); if (pos + length > Size()) { // let's grow the data stream to the size needed @@ -1453,7 +1454,7 @@ if (length == 0) return B_OK; - locker.Unlock(); + rw_lock_write_unlock(&fLock); return file_cache_write(FileCache(), NULL, pos, buffer, _length); } @@ -2117,7 +2118,7 @@ if (IsSymLink() && (Flags() & INODE_LONG_SYMLINK) == 0) return B_OK; - ReadLocker locker(Lock()); + InodeReadLocker locker(this); data_stream *data = &Node().data; status_t status = B_OK; @@ -2212,7 +2213,7 @@ if (GetTree(&tree) != B_OK) RETURN_ERROR(B_BAD_VALUE); - WriteLocker locker(Lock()); + WriteLockInTransaction(transaction); // does the file even exist? off_t id; @@ -2231,6 +2232,7 @@ } T(Remove(inode, name)); + inode->WriteLockInTransaction(transaction); // Inode::IsContainer() is true also for indices (furthermore, the S_IFDIR // bit is set for indices in BFS, not for attribute directories) - but you @@ -2318,14 +2320,16 @@ RETURN_ERROR(B_BAD_VALUE); } - WriteLocker locker(parent != NULL ? &parent->Lock() : NULL); + if (parent != NULL) { // the parent directory is locked during the whole inode creation + parent->WriteLockInTransaction(transaction); + } - if (parent != NULL && parent->IsDirectory()) { + if (parent != NULL && !volume->IsInitializing() && parent->IsContainer()) { // don't create anything in removed directories bool removed; if (get_vnode_removed(volume->FSVolume(), parent->ID(), &removed) - != B_OK || removed) { + == B_OK && removed) { RETURN_ERROR(B_ENTRY_NOT_FOUND); } } @@ -2362,7 +2366,7 @@ return status; // truncate the existing file - WriteLocker _(inode->Lock()); + inode->WriteLockInTransaction(transaction); status_t status = inode->SetFileSize(transaction, 0); if (status >= B_OK) Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2008-08-01 12:07:41 UTC (rev 26714) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2008-08-01 12:28:28 UTC (rev 26715) @@ -8,11 +8,11 @@ #include "system_dependencies.h" -#include "Volume.h" -#include "Journal.h" +#include "CachedBlock.h" #include "Chain.h" #include "Debug.h" -#include "CachedBlock.h" +#include "Journal.h" +#include "Volume.h" class BPlusTree; @@ -20,229 +20,292 @@ class AttributeIterator; class Index; class InodeAllocator; +class InodeReadLocker; class NodeGetter; +class Transaction; - enum inode_type { S_DIRECTORY = S_IFDIR, S_FILE = S_IFREG, S_SYMLINK = S_IFLNK, - S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX | S_LONG_LONG_INDEX - | S_ULONG_LONG_INDEX | S_FLOAT_INDEX | S_DOUBLE_INDEX) + S_INDEX_TYPES = (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX + | S_LONG_LONG_INDEX | S_ULONG_LONG_INDEX + | S_FLOAT_INDEX | S_DOUBLE_INDEX) }; -class Inode { - public: - Inode(Volume *volume, ino_t id); - Inode(Volume *volume, Transaction &transaction, ino_t id, - mode_t mode, block_run &run); - //Inode(CachedBlock *cached); - ~Inode(); - //bfs_inode *Node() const { return (bfs_inode *)fBlock; } - ino_t ID() const { return fID; } - off_t BlockNumber() const { return fVolume->VnodeToBlock(fID); } +class Inode : public SinglyLinkedListLinkImpl { +public: + Inode(Volume* volume, ino_t id); + Inode(Volume* volume, Transaction& transaction, + ino_t id, mode_t mode, block_run& run); + ~Inode(); - rw_lock &Lock() { return fLock; } - recursive_lock &SmallDataLock() { return fSmallDataLock; } - status_t WriteBack(Transaction &transaction); + ino_t ID() const { return fID; } + off_t BlockNumber() const + { return fVolume->VnodeToBlock(fID); } - bool IsContainer() const - { return S_ISDIR(Mode()); } - bool IsDirectory() const - { return (Mode() & (S_INDEX_DIR | S_ATTR_DIR | S_IFDIR)) - == S_IFDIR; } - bool IsIndex() const - { return (Mode() & (S_INDEX_DIR | 0777)) == S_INDEX_DIR; } - // that's a stupid check, but AFAIK the only possible method... + rw_lock& Lock() { return fLock; } + ReadLocker ReadLock() { return ReadLocker(fLock); } + void WriteLockInTransaction(Transaction& transaction) + { transaction.AddInode(this); } - bool IsAttributeDirectory() const - { return (Mode() & S_ATTR_DIR) != 0; } - bool IsAttribute() const - { return (Mode() & S_ATTR) != 0; } - bool IsFile() const - { return (Mode() & (S_IFMT | S_ATTR)) == S_FILE; } - bool IsRegularNode() const - { return (Mode() & (S_ATTR_DIR | S_INDEX_DIR | S_ATTR)) == 0; } - // a regular node in the standard namespace - // (i.e. not an index or attribute) - bool IsSymLink() const { return S_ISLNK(Mode()); } - bool HasUserAccessableStream() const { return IsFile(); } - // currently only files can be accessed with bfs_read()/bfs_write() + recursive_lock& SmallDataLock() { return fSmallDataLock; } + status_t WriteBack(Transaction& transaction); - bool IsDeleted() const { return (Flags() & INODE_DELETED) != 0; } + bool IsContainer() const + { return S_ISDIR(Mode()); } + bool IsDirectory() const + { return is_directory(Mode()); } + bool IsIndex() const + { return is_index(Mode()); } - mode_t Mode() const { return fNode.Mode(); } - uint32 Type() const { return fNode.Type(); } - int32 Flags() const { return fNode.Flags(); } + bool IsAttributeDirectory() const + { return (Mode() & S_ATTR_DIR) != 0; } + bool IsAttribute() const + { return (Mode() & S_ATTR) != 0; } + bool IsFile() const + { return (Mode() + & (S_IFMT | S_ATTR)) == S_FILE; } + bool IsRegularNode() const + { return (Mode() + & (S_ATTR_DIR | S_INDEX_DIR | S_ATTR)) + == 0; } + // a regular node in the standard namespace + // (i.e. not an index or attribute) + bool IsSymLink() const { return S_ISLNK(Mode()); } + bool HasUserAccessableStream() const { return IsFile(); } + // currently only files can be accessed with + // bfs_read()/bfs_write() - off_t Size() const { return fNode.data.Size(); } - off_t LastModified() const { return fNode.last_modified_time; } + bool IsDeleted() const + { return (Flags() & INODE_DELETED) != 0; } - const block_run &BlockRun() const { return fNode.inode_num; } - block_run &Parent() { return fNode.parent; } - block_run &Attributes() { return fNode.attributes; } + mode_t Mode() const { return fNode.Mode(); } + uint32 Type() const { return fNode.Type(); } + int32 Flags() const { return fNode.Flags(); } - Volume *GetVolume() const { return fVolume; } + off_t Size() const { return fNode.data.Size(); } + off_t LastModified() const + { return fNode.last_modified_time; } - status_t InitCheck(bool checkNode = true); + const block_run& BlockRun() const + { return fNode.inode_num; } + block_run& Parent() { return fNode.parent; } + block_run& Attributes() { return fNode.attributes; } - status_t CheckPermissions(int accessMode) const; + Volume* GetVolume() const { return fVolume; } - // small_data access methods - small_data *FindSmallData(const bfs_inode *node, - const char *name) const; - const char *Name(const bfs_inode *node) const; - status_t GetName(char *buffer, - size_t bufferSize = B_FILE_NAME_LENGTH) const; - status_t SetName(Transaction &transaction, const char *name); + status_t InitCheck(bool checkNode = true); - // high-level attribute methods - status_t ReadAttribute(const char *name, int32 type, off_t pos, - uint8 *buffer, size_t *_length); - status_t WriteAttribute(Transaction &transaction, const char *name, - int32 type, off_t pos, const uint8 *buffer, size_t *_length); - status_t RemoveAttribute(Transaction &transaction, const char *name); + status_t CheckPermissions(int accessMode) const; - // attribute methods - status_t GetAttribute(const char *name, Inode **attribute); - void ReleaseAttribute(Inode *attribute); - status_t CreateAttribute(Transaction &transaction, const char *name, - uint32 type, Inode **attribute); + // small_data access methods + small_data* FindSmallData(const bfs_inode* node, + const char* name) const; + const char* Name(const bfs_inode* node) const; + status_t GetName(char* buffer, + size_t bufferSize = B_FILE_NAME_LENGTH) const; + status_t SetName(Transaction& transaction, const char* name); - // for directories only: - status_t GetTree(BPlusTree **_tree); - bool IsEmpty(); + // high-level attribute methods + status_t ReadAttribute(const char* name, int32 type, + off_t pos, uint8* buffer, size_t* _length); + status_t WriteAttribute(Transaction& transaction, + const char* name, int32 type, off_t pos, + const uint8* buffer, size_t* _length); + status_t RemoveAttribute(Transaction& transaction, + const char* name); - // manipulating the data stream - status_t FindBlockRun(off_t pos, block_run &run, off_t &offset); + // attribute methods + status_t GetAttribute(const char* name, Inode** attribute); + void ReleaseAttribute(Inode* attribute); + status_t CreateAttribute(Transaction& transaction, + const char* name, uint32 type, + Inode** attribute); - status_t ReadAt(off_t pos, uint8 *buffer, size_t *length); - status_t WriteAt(Transaction &transaction, off_t pos, - const uint8 *buffer, size_t *length); - status_t FillGapWithZeros(off_t oldSize, off_t newSize); + // for directories only: + status_t GetTree(BPlusTree** _tree); + bool IsEmpty(); - status_t SetFileSize(Transaction &transaction, off_t size); - status_t Append(Transaction &transaction, off_t bytes); - status_t TrimPreallocation(Transaction &transaction); - bool NeedsTrimming(); + // manipulating the data stream + status_t FindBlockRun(off_t pos, block_run& run, + off_t& offset); - status_t Free(Transaction &transaction); - status_t Sync(); + status_t ReadAt(off_t pos, uint8* buffer, size_t* length); + status_t WriteAt(Transaction& transaction, off_t pos, + const uint8* buffer, size_t* length); + status_t FillGapWithZeros(off_t oldSize, off_t newSize); - bfs_inode &Node() { return fNode; } + status_t SetFileSize(Transaction& transaction, off_t size); + status_t Append(Transaction& transaction, off_t bytes); + status_t TrimPreallocation(Transaction& transaction); + bool NeedsTrimming(); - // create/remove inodes - status_t Remove(Transaction &transaction, const char *name, - ino_t *_id = NULL, bool isDirectory = false); - static status_t Create(Transaction &transaction, Inode *parent, - const char *name, int32 mode, int openMode, uint32 type, - bool *_created = NULL, ino_t *_id = NULL, Inode **_inode = NULL, - fs_vnode_ops *vnodeOps = NULL, uint32 publishFlags = 0); + status_t Free(Transaction& transaction); + status_t Sync(); - // index maintaining helper - void UpdateOldSize() - { fOldSize = Size(); } - void UpdateOldLastModified() - { fOldLastModified = Node().LastModifiedTime(); } - off_t OldSize() - { return fOldSize; } - off_t OldLastModified() - { return fOldLastModified; } + bfs_inode& Node() { return fNode; } - // file cache - void *FileCache() const { return fCache; } - void SetFileCache(void *cache) { fCache = cache; } - void *Map() const { return fMap; } - void SetMap(void *map) { fMap = map; } + // create/remove inodes + status_t Remove(Transaction& transaction, const char* name, + ino_t* _id = NULL, bool isDirectory = false); + static status_t Create(Transaction& transaction, Inode* parent, + const char* name, int32 mode, int openMode, + uint32 type, bool* _created = NULL, + ino_t* _id = NULL, Inode** _inode = NULL, + fs_vnode_ops* vnodeOps = NULL, + uint32 publishFlags = 0); - private: - Inode(const Inode &); - Inode &operator=(const Inode &); - // no implementation + // index maintaining helper + void UpdateOldSize() { fOldSize = Size(); } + void UpdateOldLastModified() + { fOldLastModified + = Node().LastModifiedTime(); } + off_t OldSize() { return fOldSize; } + off_t OldLastModified() { return fOldLastModified; } - friend class AttributeIterator; - friend class InodeAllocator; + // file cache + void* FileCache() const { return fCache; } + void SetFileCache(void* cache) { fCache = cache; } + void* Map() const { return fMap; } + void SetMap(void* map) { fMap = map; } - // small_data access methods - status_t _MakeSpaceForSmallData(Transaction &transaction, - bfs_inode *node, const char *name, int32 length); - status_t _RemoveSmallData(Transaction &transaction, NodeGetter &node, - const char *name); - status_t _AddSmallData(Transaction &transaction, NodeGetter &node, - const char *name, uint32 type, const uint8 *data, size_t length, - bool force = false); - status_t _GetNextSmallData(bfs_inode *node, - small_data **_smallData) const; - status_t _RemoveSmallData(bfs_inode *node, small_data *item, - int32 index); - status_t _RemoveAttribute(Transaction &transaction, const char *name, - bool hasIndex, Index *index); +#if _KERNEL_MODE && KDEBUG + void AssertReadLocked() + { ASSERT_READ_LOCKED_RW_LOCK(&fLock); } + void AssertWriteLocked() + { ASSERT_WRITE_LOCKED_RW_LOCK(&fLock); } +#endif - void _AddIterator(AttributeIterator *iterator); - void _RemoveIterator(AttributeIterator *iterator); +private: + Inode(const Inode& other); + Inode& operator=(const Inode& other); + // no implementation - status_t _FreeStaticStreamArray(Transaction &transaction, int32 level, - block_run run, off_t size, off_t offset, off_t &max); - status_t _FreeStreamArray(Transaction &transaction, block_run *array, - uint32 arrayLength, off_t size, off_t &offset, off_t &max); - status_t _AllocateBlockArray(Transaction &transaction, block_run &run); - status_t _GrowStream(Transaction &transaction, off_t size); - status_t _ShrinkStream(Transaction &transaction, off_t size); + friend class AttributeIterator; + friend class InodeAllocator; + friend class InodeReadLocker; + friend class Transaction; - private: - rw_lock fLock; - Volume *fVolume; - ino_t fID; - BPlusTree *fTree; - Inode *fAttributes; - void *fCache; - void *fMap; - bfs_inode fNode; + // small_data access methods + status_t _MakeSpaceForSmallData(Transaction& transaction, + bfs_inode* node, const char* name, + int32 length); + status_t _RemoveSmallData(Transaction& transaction, + NodeGetter& node, const char* name); + status_t _AddSmallData(Transaction& transaction, + NodeGetter& node, const char* name, uint32 type, + const uint8* data, size_t length, + bool force = false); + status_t _GetNextSmallData(bfs_inode* node, + small_data** _smallData) const; + status_t _RemoveSmallData(bfs_inode* node, small_data* item, + int32 index); + status_t _RemoveAttribute(Transaction& transaction, + const char* name, bool hasIndex, Index* index); - off_t fOldSize; - off_t fOldLastModified; - // we need those values to ensure we will remove - // the correct keys from the indices + void _AddIterator(AttributeIterator* iterator); + void _RemoveIterator(AttributeIterator* iterator); - mutable recursive_lock fSmallDataLock; - Chain fIterators; + status_t _FreeStaticStreamArray(Transaction& transaction, + int32 level, block_run run, off_t size, + off_t offset, off_t& max); + status_t _FreeStreamArray(Transaction& transaction, + block_run* array, uint32 arrayLength, + off_t size, off_t& offset, off_t& max); + status_t _AllocateBlockArray(Transaction& transaction, + block_run& run); + status_t _GrowStream(Transaction& transaction, off_t size); + status_t _ShrinkStream(Transaction& transaction, off_t size); + +private: + rw_lock fLock; + Volume* fVolume; + ino_t fID; + BPlusTree* fTree; + Inode* fAttributes; + void* fCache; + void* fMap; + bfs_inode fNode; + + off_t fOldSize; + off_t fOldLastModified; + // we need those values to ensure we will remove + // the correct keys from the indices + + mutable recursive_lock fSmallDataLock; + Chain fIterators; }; +#if _KERNEL_MODE && KDEBUG +# define ASSERT_READ_LOCKED_INODE(inode) inode->AssertReadLocked() +# define ASSERT_WRITE_LOCKED_INODE(inode) inode->AssertWriteLocked() +#else +# define ASSERT_READ_LOCKED_INODE(inode) +# define ASSERT_WRITE_LOCKED_INODE(inode) +#endif -class NodeGetter : public CachedBlock { - public: - NodeGetter(Volume *volume) - : CachedBlock(volume) - { - } +class InodeReadLocker { +public: + InodeReadLocker(Inode* inode) + : + fLock(&inode->fLock) + { + rw_lock_read_lock(fLock); + } - NodeGetter(Volume *volume, const Inode *inode) - : CachedBlock(volume) - { - SetTo(volume->VnodeToBlock(inode->ID())); - } + ~InodeReadLocker() + { + if (fLock != NULL) + rw_lock_read_unlock(fLock); + } - NodeGetter(Volume *volume, Transaction &transaction, - const Inode *inode, bool empty = false) - : CachedBlock(volume) - { - SetToWritable(transaction, volume->VnodeToBlock(inode->ID()), empty); + void Unlock() + { + if (fLock != NULL) { + rw_lock_read_unlock(fLock); + fLock = NULL; } + } - ~NodeGetter() - { - } +private: + rw_lock* fLock; +}; - const bfs_inode * - SetToNode(const Inode *inode) - { - return (const bfs_inode *)SetTo(fVolume->VnodeToBlock(inode->ID())); - } - const bfs_inode *Node() const { return (const bfs_inode *)Block(); } - bfs_inode *WritableNode() const { return (bfs_inode *)Block(); } +class NodeGetter : public CachedBlock { +public: + NodeGetter(Volume* volume) + : CachedBlock(volume) + { + } + + NodeGetter(Volume* volume, const Inode* inode) + : CachedBlock(volume) + { + SetTo(volume->VnodeToBlock(inode->ID())); + } + + NodeGetter(Volume* volume, Transaction& transaction, + const Inode* inode, bool empty = false) + : CachedBlock(volume) + { + SetToWritable(transaction, volume->VnodeToBlock(inode->ID()), empty); + } + + ~NodeGetter() + { + } + + const bfs_inode* SetToNode(const Inode* inode) + { + return (const bfs_inode*)SetTo(fVolume->VnodeToBlock(inode->ID())); + } + + const bfs_inode* Node() const { return (const bfs_inode*)Block(); } + bfs_inode* WritableNode() const { return (bfs_inode*)Block(); } }; @@ -251,114 +314,98 @@ // readable in some cases class Vnode { - public: - Vnode(Volume* volume, ino_t id) - : - fInode(NULL) - { - SetTo(volume, id); - } +public: + Vnode(Volume* volume, ino_t id) + : + fInode(NULL) + { + SetTo(volume, id); + } - Vnode(Volume* volume, block_run run) - : - fInode(NULL) - { - SetTo(volume, run); - } + Vnode(Volume* volume, block_run run) + : + fInode(NULL) + { + SetTo(volume, run); + } - Vnode() - : - fStatus(B_NO_INIT), - fInode(NULL) - { - } + Vnode() + : + fStatus(B_NO_INIT), + fInode(NULL) + { + } - ~Vnode() - { - Unset(); - } + ~Vnode() + { + Unset(); + } - status_t InitCheck() - { - return fStatus; - } + status_t InitCheck() + { + return fStatus; + } - void Unset() - { - if (fInode != NULL) { - put_vnode(fInode->GetVolume()->FSVolume(), fInode->ID()); - fInode = NULL; - fStatus = B_NO_INIT; - } + void Unset() + { + if (fInode != NULL) { + put_vnode(fInode->GetVolume()->FSVolume(), fInode->ID()); + fInode = NULL; + fStatus = B_NO_INIT; } + } - status_t SetTo(Volume* volume, ino_t id) - { - Unset(); + status_t SetTo(Volume* volume, ino_t id) + { + Unset(); - return fStatus = get_vnode(volume->FSVolume(), id, (void**)&fInode); - } + return fStatus = get_vnode(volume->FSVolume(), id, (void**)&fInode); + } - status_t SetTo(Volume* volume, block_run run) - { - return SetTo(volume, volume->ToVnode(run)); - } + status_t SetTo(Volume* volume, block_run run) + { + return SetTo(volume, volume->ToVnode(run)); + } - status_t Get(Inode** _inode) - { - *_inode = fInode; - return fStatus; - } + status_t Get(Inode** _inode) + { + *_inode = fInode; + return fStatus; + } - void Keep() - { - fInode = NULL; - } + void Keep() + { + fInode = NULL; + } - private: - status_t fStatus; - Inode* fInode; +private: + status_t fStatus; + Inode* fInode; }; class AttributeIterator { - public: - AttributeIterator(Inode *inode); - ~AttributeIterator(); +public: + AttributeIterator(Inode* inode); + ~AttributeIterator(); - status_t Rewind(); - status_t GetNext(char *name, size_t *length, uint32 *type, ino_t *id); + status_t Rewind(); + status_t GetNext(char* name, size_t* length, uint32* type, + ino_t* id); - private: - friend class Chain; - friend class Inode; +private: + friend class Chain; + friend class Inode; - void Update(uint16 index, int8 change); - AttributeIterator *fNext; + void Update(uint16 index, int8 change); - private: - int32 fCurrentSmallData; - Inode *fInode, *fAttributes; - TreeIterator *fIterator; - void *fBuffer; +private: + AttributeIterator* fNext; + int32 fCurrentSmallData; + Inode* fInode; + Inode* fAttributes; + TreeIterator* fIterator; + void* fBuffer; }; - -/*! - Converts the open mode, the open flags given to bfs_open(), into - access modes, e.g. since O_RDONLY requires read access to the - file, it will be converted to R_OK. -*/ -inline int -openModeToAccess(int openMode) -{ - openMode &= O_RWMASK; - if (openMode == O_RDONLY) - return R_OK; - else if (openMode == O_WRONLY) - return W_OK; - - return R_OK | W_OK; -} - -#endif /* INODE_H */ +#endif // INODE_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp [... truncated: 470 lines follow ...] From axeld at mail.berlios.de Fri Aug 1 16:02:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 16:02:02 +0200 Subject: [Haiku-commits] r26716 - haiku/trunk/src/servers/app Message-ID: <200808011402.m71E220e016478@sheep.berlios.de> Author: axeld Date: 2008-08-01 16:02:02 +0200 (Fri, 01 Aug 2008) New Revision: 26716 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26716&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp Log: * Made _LaunchInputServer() more robust: when launching by signature fails, we try its well-known location directly. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2008-08-01 12:28:28 UTC (rev 26715) +++ haiku/trunk/src/servers/app/Desktop.cpp 2008-08-01 14:02:02 UTC (rev 26716) @@ -412,8 +412,24 @@ { BRoster roster; status_t status = roster.Launch("application/x-vnd.Be-input_server"); - if (status != B_OK && status != B_ALREADY_RUNNING) - syslog(LOG_ERR, "Failed to launch the input server: %s!\n", strerror(status)); + if (status == B_OK || status == B_ALREADY_RUNNING) + return; + + // Could not load input_server by signature, try well-known location + + BEntry entry("/system/servers/input_server"); + entry_ref ref; + status_t entryStatus = entry.GetRef(&ref); + if (entryStatus == B_OK) + entryStatus = roster.Launch(&ref); + if (entryStatus == B_OK || entryStatus == B_ALREADY_RUNNING) { + syslog(LOG_ERR, "Failed to launch the input server by signature: %s!\n", + strerror(status)); + return; + } + + syslog(LOG_ERR, "Failed to launch the input server: %s!\n", + strerror(entryStatus)); } From stippi at mail.berlios.de Fri Aug 1 16:16:12 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Fri, 1 Aug 2008 16:16:12 +0200 Subject: [Haiku-commits] r26717 - haiku/trunk/src/apps/soundrecorder Message-ID: <200808011416.m71EGCDP018140@sheep.berlios.de> Author: stippi Date: 2008-08-01 16:16:05 +0200 (Fri, 01 Aug 2008) New Revision: 26717 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26717&view=rev Removed: haiku/trunk/src/apps/soundrecorder/array_delete.h Modified: haiku/trunk/src/apps/soundrecorder/FileUtils.cpp haiku/trunk/src/apps/soundrecorder/Jamfile haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp haiku/trunk/src/apps/soundrecorder/SoundConsumer.cpp haiku/trunk/src/apps/soundrecorder/SoundConsumer.h Log: * Use shared AutoDeleter.h instead of custom array deleter. * Improve code in FileUtils to copy attributes in chunks and improve error checking. Should also copy 0 size attributes now, since those are valid. * Craft SoundConsumer towards more style guide compliance. * Use new (std::nothrow) and check result. Modified: haiku/trunk/src/apps/soundrecorder/FileUtils.cpp =================================================================== --- haiku/trunk/src/apps/soundrecorder/FileUtils.cpp 2008-08-01 14:02:02 UTC (rev 26716) +++ haiku/trunk/src/apps/soundrecorder/FileUtils.cpp 2008-08-01 14:16:05 UTC (rev 26717) @@ -7,14 +7,22 @@ / Copyright 1998-1999, Be Incorporated, All Rights Reserved / *******************************************************************************/ +#include "FileUtils.h" +#include +#include +#include -#include #include -#include "array_delete.h" -#include "FileUtils.h" -status_t CopyFileData(BFile& dst, BFile& src) +#include "AutoDeleter.h" + + +using std::nothrow; + + +status_t +CopyFileData(BFile& dst, BFile& src) { struct stat src_stat; status_t err = src.GetStat(&src_stat); @@ -24,12 +32,13 @@ } size_t bufSize = src_stat.st_blksize; - if (! bufSize) { + if (bufSize == 0) bufSize = 32768; - } - char* buf = new char[bufSize]; - array_delete bufDelete(buf); + char* buf = new (nothrow) char[bufSize]; + if (buf == NULL) + return B_NO_MEMORY; + ArrayDeleter _(buf); printf("copy data, bufSize = %ld\n", bufSize); // copy data @@ -38,14 +47,18 @@ if (bytes > 0) { ssize_t result = dst.Write(buf, bytes); if (result != bytes) { - printf("result = %#010lx, bytes = %#010lx\n", (uint32) result, - (uint32) bytes); - return B_ERROR; + fprintf(stderr, "Failed to write %ld bytes: %s\n", bytes, + strerror((status_t)result)); + if (result < 0) + return (status_t)result; + else + return B_IO_ERROR; } } else { if (bytes < 0) { - printf(" bytes = %#010lx\n", (uint32) bytes); - return bytes; + fprintf(stderr, "Failed to read file: %s\n", strerror( + (status_t)bytes)); + return (status_t)bytes; } else { // EOF break; @@ -64,25 +77,49 @@ } -status_t CopyAttributes(BNode& dst, BNode& src) +status_t +CopyAttributes(BNode& dst, BNode& src) { // copy attributes src.RewindAttrs(); - char name[B_ATTR_NAME_LENGTH]; - while (src.GetNextAttrName(name) == B_OK) { + char attrName[B_ATTR_NAME_LENGTH]; + while (src.GetNextAttrName(attrName) == B_OK) { attr_info info; - if (src.GetAttrInfo(name, &info) == B_OK) { - size_t bufSize = info.size; - char* buf = new char[bufSize]; - array_delete bufDelete = buf; - - // copy one attribute - ssize_t bytes = src.ReadAttr(name, info.type, 0, buf, bufSize); - if (bytes > 0) { - dst.WriteAttr(name, info.type, 0, buf, bufSize); - } else { - return bytes; + if (src.GetAttrInfo(attrName, &info) != B_OK) { + fprintf(stderr, "Failed to read info for attribute '%s'\n", + attrName); + continue; + } + // copy one attribute in chunks of 4096 bytes + size_t size = 4096; + uint8 buffer[size]; + off_t offset = 0; + ssize_t read = src.ReadAttr(attrName, info.type, offset, buffer, + min_c(size, info.size)); + if (read < 0) { + fprintf(stderr, "Error reading attribute '%s'\n", attrName); + return (status_t)read; + } + // NOTE: Attributes of size 0 are perfectly valid! + while (read >= 0) { + ssize_t written = dst.WriteAttr(attrName, info.type, offset, buffer, + read); + if (written != read) { + fprintf(stderr, "Error writing attribute '%s'\n", attrName); + if (written < 0) + return (status_t)written; + else + return B_IO_ERROR; } + offset += read; + read = src.ReadAttr(attrName, info.type, offset, buffer, + min_c(size, info.size - offset)); + if (read < 0) { + fprintf(stderr, "Error reading attribute '%s'\n", attrName); + return (status_t)read; + } + if (read == 0) + break; } } @@ -90,7 +127,8 @@ } -status_t CopyFile(BFile& dst, BFile& src) +status_t +CopyFile(BFile& dst, BFile& src) { status_t err = CopyFileData(dst, src); if (err != B_OK) Modified: haiku/trunk/src/apps/soundrecorder/Jamfile =================================================================== --- haiku/trunk/src/apps/soundrecorder/Jamfile 2008-08-01 14:02:02 UTC (rev 26716) +++ haiku/trunk/src/apps/soundrecorder/Jamfile 2008-08-01 14:16:05 UTC (rev 26717) @@ -2,6 +2,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders shared ; + Application SoundRecorder : DrawButton.cpp DrawingTidbits.cpp Modified: haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp =================================================================== --- haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp 2008-08-01 14:02:02 UTC (rev 26716) +++ haiku/trunk/src/apps/soundrecorder/RecorderWindow.cpp 2008-08-01 14:16:05 UTC (rev 26717) @@ -43,7 +43,6 @@ #include "RecorderWindow.h" #include "SoundConsumer.h" #include "SoundListView.h" -#include "array_delete.h" #include "FileUtils.h" #if ! NDEBUG Modified: haiku/trunk/src/apps/soundrecorder/SoundConsumer.cpp =================================================================== --- haiku/trunk/src/apps/soundrecorder/SoundConsumer.cpp 2008-08-01 14:02:02 UTC (rev 26716) +++ haiku/trunk/src/apps/soundrecorder/SoundConsumer.cpp 2008-08-01 14:16:05 UTC (rev 26717) @@ -7,7 +7,9 @@ / Copyright 1998-1999, Be Incorporated, All Rights Reserved / *******************************************************************************/ +#include "SoundConsumer.h" +#include #include #include @@ -15,11 +17,13 @@ #include #include +#include "AutoDeleter.h" #include "SoundPrivate.h" -#include "SoundConsumer.h" -#include "array_delete.h" +using std::nothrow; + + // If we don't mind the format changing to another format while // running, we can define this to 1. Look for the symbol down in the source. #define ACCEPT_ANY_FORMAT_CHANGE 0 @@ -55,7 +59,8 @@ BMediaNode(name ? name : "SoundConsumer"), BBufferConsumer(B_MEDIA_RAW_AUDIO) { - NODE(stderr, "SoundConsumer::SoundConsumer(%p, %p, %p, %p)\n", name, recordFunc, notifyFunc, cookie); + NODE(stderr, "SoundConsumer::SoundConsumer(%p, %p, %p, %p)\n", name, + recordFunc, notifyFunc, cookie); if (!name) name = "SoundConsumer"; @@ -105,10 +110,8 @@ status_t -SoundConsumer::SetHooks( - SoundProcessFunc recordFunc, - SoundNotifyFunc notifyFunc, - void * cookie) +SoundConsumer::SetHooks(SoundProcessFunc recordFunc, SoundNotifyFunc notifyFunc, + void* cookie) { // SetHooks needs to be synchronized with the service thread, else we may // call the wrong hook function with the wrong cookie, which would be bad. @@ -134,31 +137,27 @@ } // Clean up. delete_port(cmd.reply); - } - else { - // Within the service thread, it's OK to just go ahead and do the change. + } else { + // Within the service thread, it's OK to just go ahead and do the + // change. DoHookChange(&cmd); } return err; } +// #pragma mark -BMediaNode-derived methods -//////////////////////////////////////////////////////////////////////////////// -// -// BMediaNode-derived methods -// -//////////////////////////////////////////////////////////////////////////////// - -port_id SoundConsumer::ControlPort() const +port_id +SoundConsumer::ControlPort() const { return m_port; } -BMediaAddOn* SoundConsumer::AddOn( - int32 * internal_id) const +BMediaAddOn* +SoundConsumer::AddOn(int32 * internal_id) const { // This object is instantiated inside an application. // Therefore, it has no add-on. @@ -167,8 +166,8 @@ } -void SoundConsumer::Start( - bigtime_t performance_time) +void +SoundConsumer::Start(bigtime_t performance_time) { // Since we are a consumer and just blindly accept buffers that are // thrown at us, we don't need to do anything special in Start()/Stop(). @@ -180,18 +179,15 @@ m_delta = performance_time - m_tmSeekTo; m_seeking = false; } - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_WILL_START, performance_time); - } - else { + else Notify(B_WILL_START, performance_time); - } } -void SoundConsumer::Stop( - bigtime_t performance_time, - bool immediate) +void +SoundConsumer::Stop(bigtime_t performance_time, bool immediate) { // Since we are a consumer and just blindly accept buffers that are // thrown at us, we don't need to do anything special in Start()/Stop(). @@ -201,18 +197,15 @@ // it's a Node over which we have complete control, we can live with // treating buffers received before the start time or after the stop // time as any other buffer. - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_WILL_STOP, performance_time, immediate); - } - else { + else Notify(B_WILL_STOP, performance_time, immediate); - } } -void SoundConsumer::Seek( - bigtime_t media_time, - bigtime_t performance_time) +void +SoundConsumer::Seek(bigtime_t media_time, bigtime_t performance_time) { // Seek() on a consumer just serves to offset the time stamp // of received buffers passed to our Record hook function. @@ -220,20 +213,19 @@ // to disk or otherwise store them. You may also want to // synchronize this node's media time with an upstream // producer's media time to make this offset meaningful. - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_WILL_SEEK, performance_time, media_time); - } - else { + else Notify(B_WILL_SEEK, performance_time, media_time); - } + m_tpSeekAt = performance_time; m_tmSeekTo = media_time; m_seeking = true; } -void SoundConsumer::SetRunMode( - run_mode mode) +void +SoundConsumer::SetRunMode(run_mode mode) { if (mode == BMediaNode::B_OFFLINE) { // BMediaNode::B_OFFLINE means we don't need to run in @@ -241,8 +233,7 @@ // thread. int32 new_prio = suggest_thread_priority(B_OFFLINE_PROCESSING); set_thread_priority(m_thread, new_prio); - } - else { + } else { // We're running in real time, so we'd better have // a big enough thread priority to handle it! // Here's where those magic scheduler values @@ -264,40 +255,39 @@ // * The amount of time we spend processing is // our ProcessingLatency(). bigtime_t period = 10000; - if (buffer_duration(m_input.format.u.raw_audio) > 0) { + if (buffer_duration(m_input.format.u.raw_audio) > 0) period = buffer_duration(m_input.format.u.raw_audio); - } + // assuming we're running for 500 us or less per buffer int32 new_prio = suggest_thread_priority(B_AUDIO_RECORDING, - period, period/2, ProcessingLatency()); + period, period / 2, ProcessingLatency()); set_thread_priority(m_thread, new_prio); } } -void SoundConsumer::TimeWarp( - bigtime_t at_real_time, - bigtime_t to_performance_time) +void +SoundConsumer::TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time) { // Since buffers will come pre-time-stamped, we only need to look // at them, so we can ignore the time warp as a consumer. if (m_notifyHook) { - (*m_notifyHook)(m_cookie, B_WILL_TIMEWARP, at_real_time, to_performance_time); - } - else { + (*m_notifyHook)(m_cookie, B_WILL_TIMEWARP, at_real_time, + to_performance_time); + } else Notify(B_WILL_TIMEWARP, at_real_time, to_performance_time); - } } -void SoundConsumer::Preroll() +void +SoundConsumer::Preroll() { // There is nothing for us to do in Preroll() } -void SoundConsumer::SetTimeSource( - BTimeSource * /* time_source */) +void +SoundConsumer::SetTimeSource(BTimeSource* /* time_source */) { // We don't need to do anything special to take note of the // fact that the time source changed, because we get our timing @@ -305,17 +295,14 @@ } -status_t SoundConsumer::HandleMessage( - int32 message, - const void * data, - size_t size) +status_t +SoundConsumer::HandleMessage(int32 message, const void* data, size_t size) { // Check with each of our superclasses to see if they // understand the message. If none of them do, call // BMediaNode::HandleBadMessage(). - if ((BBufferConsumer::HandleMessage(message, data, size) < 0) - && (BMediaNode::HandleMessage(message, data, size) < 0)) - { + if (BBufferConsumer::HandleMessage(message, data, size) < 0 + && BMediaNode::HandleMessage(message, data, size) < 0) { HandleBadMessage(message, data, size); return B_ERROR; } @@ -323,33 +310,23 @@ } +// #pragma mark - BBufferConsumer-derived methods - -//////////////////////////////////////////////////////////////////////////////// -// -// BBufferConsumer-derived methods -// -//////////////////////////////////////////////////////////////////////////////// - - - -status_t SoundConsumer::AcceptFormat( - const media_destination & dest, - media_format * format) +status_t +SoundConsumer::AcceptFormat(const media_destination& dest, media_format* format) { // We only accept formats aimed at our single input. - if (dest != m_input.destination) { + if (dest != m_input.destination) return B_MEDIA_BAD_DESTINATION; - } - // If no format is specified, we say we want raw audio. + if (format->type <= 0) { + // If no format is specified, we say we want raw audio. format->type = B_MEDIA_RAW_AUDIO; format->u.raw_audio = media_raw_audio_format::wildcard; - } - // If a non-raw-audio format is specified, we tell the world what - // we want, and that the specified format was unacceptable to us. - else if (format->type != B_MEDIA_RAW_AUDIO) { + } else if (format->type != B_MEDIA_RAW_AUDIO) { + // If a non-raw-audio format is specified, we tell the world what + // we want, and that the specified format was unacceptable to us. format->type = B_MEDIA_RAW_AUDIO; format->u.raw_audio = media_raw_audio_format::wildcard; return B_MEDIA_BAD_FORMAT; @@ -368,14 +345,13 @@ } -status_t SoundConsumer::GetNextInput( - int32 * cookie, - media_input * out_input) +status_t +SoundConsumer::GetNextInput(int32* cookie, media_input* out_input) { NODE(stderr, "SoundConsumer: GetNextInput()\n"); // The "next" is kind of misleading, since it's also used for // getting the first (and only) input. - if (!*cookie) { + if (*cookie == 0) { if (m_input.source == media_source::null) { // If there's no current connection, make sure we return a // reasonable format telling the world we accept any raw audio. @@ -394,16 +370,16 @@ } -void SoundConsumer::DisposeInputCookie( - int32 /* cookie */) +void +SoundConsumer::DisposeInputCookie(int32 /* cookie */) { // We didn't allocate any memory or set any state in GetNextInput() // so this function is a no-op. } -void SoundConsumer::BufferReceived( - BBuffer * buffer) +void +SoundConsumer::BufferReceived(BBuffer* buffer) { NODE(stderr, "SoundConsumer::BufferReceived()\n"); // Whee, a buffer! Update the seek info, if necessary. @@ -413,44 +389,44 @@ } // If there is a record hook, let the interested party have at it! if (m_recordHook) { - (*m_recordHook)(m_cookie, buffer->Header()->start_time-m_delta, buffer->Data(), buffer->Header()->size_used, m_input.format.u.raw_audio); + (*m_recordHook)(m_cookie, buffer->Header()->start_time-m_delta, + buffer->Data(), buffer->Header()->size_used, + m_input.format.u.raw_audio); + } else { + Record(buffer->Header()->start_time-m_delta, buffer->Data(), + buffer->Header()->size_used, m_input.format.u.raw_audio); } - else { - Record(buffer->Header()->start_time-m_delta, buffer->Data(), buffer->Header()->size_used, m_input.format.u.raw_audio); - } // Buffers should ALWAYS be recycled, else whomever is producing them // will starve. buffer->Recycle(); } -void SoundConsumer::ProducerDataStatus( - const media_destination & for_whom, - int32 status, - bigtime_t at_media_time) +void +SoundConsumer::ProducerDataStatus(const media_destination& for_whom, + int32 status, bigtime_t at_media_time) { - if (for_whom == m_input.destination) { - // Tell whomever is interested that the upstream producer will or won't - // send more data in the immediate future. - if (m_notifyHook) { - (*m_notifyHook)(m_cookie, B_PRODUCER_DATA_STATUS, status, at_media_time); - } - else { - Notify(B_PRODUCER_DATA_STATUS, status, at_media_time); - } - } + if (for_whom != m_input.destination) + return; + + // Tell whomever is interested that the upstream producer will or won't + // send more data in the immediate future. + if (m_notifyHook) { + (*m_notifyHook)(m_cookie, B_PRODUCER_DATA_STATUS, status, + at_media_time); + } else + Notify(B_PRODUCER_DATA_STATUS, status, at_media_time); } -status_t SoundConsumer::GetLatencyFor( - const media_destination & for_whom, - bigtime_t * out_latency, - media_node_id * out_timesource) +status_t +SoundConsumer::GetLatencyFor(const media_destination& for_whom, + bigtime_t* out_latency, media_node_id* out_timesource) { // We only accept requests for the one-and-only input of our Node. - if (for_whom != m_input.destination) { + if (for_whom != m_input.destination) return B_MEDIA_BAD_DESTINATION; - } + // Tell the world about our latency information (overridable by user). *out_latency = TotalLatency(); *out_timesource = TimeSource()->Node().node; @@ -458,32 +434,30 @@ } -status_t SoundConsumer::Connected( - const media_source & producer, - const media_destination & where, - const media_format & with_format, - media_input * out_input) +status_t +SoundConsumer::Connected(const media_source& producer, + const media_destination& where, const media_format& with_format, + media_input* out_input) { NODE(stderr, "SoundConsumer::Connected()\n"); // Only accept connection requests when we're not already connected. - if (m_input.source != media_source::null) { + if (m_input.source != media_source::null) return B_MEDIA_BAD_DESTINATION; - } + // Only accept connection requests on the one-and-only available input. - if (where != m_input.destination) { + if (where != m_input.destination) return B_MEDIA_BAD_DESTINATION; - } + // Other than that, we accept pretty much anything. The format has been // pre-cleared through AcceptFormat(), and we accept any format anyway. m_input.source = producer; m_input.format = with_format; // Tell whomever is interested that there's now a connection. - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_CONNECTED, m_input.name); - } - else { + else Notify(B_CONNECTED, m_input.name); - } + // This is the most important line -- return our connection information // to the world so it can use it! *out_input = m_input; @@ -491,75 +465,69 @@ } -void SoundConsumer::Disconnected( - const media_source & producer, - const media_destination & where) +void +SoundConsumer::Disconnected(const media_source& producer, + const media_destination& where) { // We can't disconnect something which isn't us. - if (where != m_input.destination) { + if (where != m_input.destination) return; - } // We can't disconnect from someone who isn't connected to us. - if (producer != m_input.source) { + if (producer != m_input.source) return; - } // Tell the interested party that it's time to leave. - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_DISCONNECTED); - } - else { + else Notify(B_DISCONNECTED); - } // Mark ourselves as not-connected. m_input.source = media_source::null; } -status_t SoundConsumer::FormatChanged( - const media_source & producer, - const media_destination & consumer, - int32 from_change_count, - const media_format & format) +status_t +SoundConsumer::FormatChanged(const media_source& producer, + const media_destination& consumer, int32 from_change_count, + const media_format& format) { NODE(stderr, "SoundConsumer::Connected()\n"); // The up-stream guy feels like changing the format. If we can accept // arbitrary format changes, we just say "OK". If, however, we're recording // to a file, that's not such a good idea; we only accept format changes // that are compatible with the format we're already using. You set this - // behaviour at compile time by defining ACCEPT_ANY_FORMAT_CHANGE to 1 or 0. + // behaviour at compile time by defining ACCEPT_ANY_FORMAT_CHANGE to 1 or + // 0. status_t err = B_OK; #if ACCEPT_ANY_FORMAT_CHANGE media_format fmt(format); err = AcceptFormat(m_input.destination, &fmt); #else if (m_input.source != media_source::null) { - err = format_is_compatible(format, m_input.format) ? B_OK : B_MEDIA_BAD_FORMAT; + err = format_is_compatible(format, m_input.format) ? B_OK + : B_MEDIA_BAD_FORMAT; } #endif if (err >= B_OK) { m_input.format = format; if (m_notifyHook) { - (*m_notifyHook)(m_cookie, B_FORMAT_CHANGED, &m_input.format.u.raw_audio); - } - else { + (*m_notifyHook)(m_cookie, B_FORMAT_CHANGED, + &m_input.format.u.raw_audio); + } else Notify(B_FORMAT_CHANGED, &m_input.format.u.raw_audio); - } } return err; } void -SoundConsumer::DoHookChange( - void * msg) +SoundConsumer::DoHookChange(void* msg) { // Tell the old guy we're changing the hooks ... - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_HOOKS_CHANGED); - } - else { + else Notify(B_HOOKS_CHANGED); - } + // ... and then do it. set_hooks_q * ptr = (set_hooks_q *)msg; m_recordHook = ptr->process; @@ -569,10 +537,10 @@ status_t -SoundConsumer::ThreadEntry( - void * obj) +SoundConsumer::ThreadEntry(void* cookie) { - ((SoundConsumer *)obj)->ServiceThread(); + SoundConsumer* consumer = (SoundConsumer*)cookie; + consumer->ServiceThread(); return 0; } @@ -587,9 +555,11 @@ // A media kit message will never be bigger than B_MEDIA_MESSAGE_SIZE. // Avoid wasing stack space by dynamically allocating at start. - char * msg = new char[B_MEDIA_MESSAGE_SIZE]; + char* msg = new (nothrow) char[B_MEDIA_MESSAGE_SIZE]; + if (msg == NULL) + return; // Make sure we clean up this data when we exit the function. - array_delete msg_delete(msg); + ArrayDeleter _(msg); int bad = 0; while (true) { // Call read_port_etc() with a timeout derived from a virtual function, @@ -598,57 +568,50 @@ int32 code = 0; status_t err = read_port_etc(m_port, &code, msg, B_MEDIA_MESSAGE_SIZE, B_TIMEOUT, timeout); - MESSAGE(stderr, "SoundConsumer::ServiceThread() port %ld message %#010lx\n", m_port, code); - // If we received a message, err will be the size of the message (including 0). - if (err >= 0) { + MESSAGE(stderr, "SoundConsumer::ServiceThread() port %ld message " + "%#010lx\n", m_port, code); + // If we received a message, err will be the size of the message + // (including 0). + if (err >= B_OK) { // Real messages reset the timeout time. m_trTimeout = 0; bad = 0; - // Check for our private stop message. if (code == MSG_QUIT_NOW) { - if (m_notifyHook) { + // Check for our private stop message. + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_NODE_DIES, 0); - } - else { + else Notify(B_NODE_DIES, 0); - } break; - } + } else if (code == MSG_CHANGE_HOOKS) { // Else check for our private change-hooks message. - else if (code == MSG_CHANGE_HOOKS) { DoHookChange(msg); // Write acknowledge to waiting thread. write_port(((set_hooks_q *)msg)->reply, 0, 0, 0); - } - // Else it has to be a regular media kit message; go ahead and - // dispatch it. - else { + } else { + // Else it has to be a regular media kit message; + // go ahead and dispatch it. HandleMessage(code, msg, err); } - } - // Timing out means that there was no buffer. Tell the interested party. - else if (err == B_TIMED_OUT) { - if (m_notifyHook) { + } else if (err == B_TIMED_OUT) { + // Timing out means that there was no buffer. Tell the interested + // party. + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_OP_TIMED_OUT, timeout); - } - else { + else Notify(B_OP_TIMED_OUT, timeout); - } - } - // Other errors are bad. - else { + } else { + // Other errors are bad. FPRINTF(stderr, "SoundConsumer: error %#010lx\n", err); bad++; // If we receive three bad reads with no good messages inbetween, - // things are probably not going to improve (like the port disappeared - // or something) so we call it a day. + // things are probably not going to improve (like the port + // disappeared or something) so we call it a day. if (bad > 3) { - if (m_notifyHook) { + if (m_notifyHook) (*m_notifyHook)(m_cookie, B_NODE_DIES, bad, err, code, msg); - } - else { + else Notify(B_NODE_DIES, bad, err, code, msg); - } break; } } @@ -664,8 +627,9 @@ // we've picked is to exponentially back off from one second and upwards. // While it's true that 44 back-offs will run us out of precision in a // bigtime_t, the time to actually reach 44 consecutive back-offs is longer - // than the expected market longevity of just about any piece of real estate. - // Is that the sound of an impending year-fifteen-million software problem? :-) + // than the expected market longevity of just about any piece of real + // estate. Is that the sound of an impending year-fifteen-million software + // problem? :-) m_trTimeout = (m_trTimeout < 1000000) ? 1000000 : m_trTimeout*2; return m_trTimeout; } @@ -689,12 +653,13 @@ return ProcessingLatency(); } + +// #pragma mark - + + void -SoundConsumer::Record( - bigtime_t /* time */, - const void * /* data */, - size_t /* size */, - const media_raw_audio_format & /* format */) +SoundConsumer::Record(bigtime_t /*time*/, const void* /*data*/, + size_t /*size*/, const media_raw_audio_format& /*format*/) { // If there is no record hook installed, we instead call this function // for received buffers. @@ -702,10 +667,8 @@ void -SoundConsumer::Notify( - int32 /* cause */, - ...) +SoundConsumer::Notify(int32 /*cause*/, ...) { - // If there is no notification hook installed, we instead call this function - // for giving notification of various events. + // If there is no notification hook installed, we instead call this + // function for giving notification of various events. } Modified: haiku/trunk/src/apps/soundrecorder/SoundConsumer.h =================================================================== --- haiku/trunk/src/apps/soundrecorder/SoundConsumer.h 2008-08-01 14:02:02 UTC (rev 26716) +++ haiku/trunk/src/apps/soundrecorder/SoundConsumer.h 2008-08-01 14:16:05 UTC (rev 26717) @@ -7,14 +7,9 @@ / Copyright 1998, Be Incorporated, All Rights Reserved / *******************************************************************************/ +#ifndef SOUND_CONSUMER_H +#define SOUND_CONSUMER_H - -#if !defined( _SoundConsumer_h ) -#define _SoundConsumer_h - -#include -#include "SoundUtils.h" - // To use this Consumer: // 1. Create Record and Notify hooks, or subclass SoundConsumer // if you'd rather use the inheritance hierarchy. @@ -33,141 +28,120 @@ // your Record function will see. // 6: When you're done, disconnect the Consumer, then delete it. -class SoundConsumer : - public BBufferConsumer -{ +#include +#include "SoundUtils.h" + + +class SoundConsumer : public BBufferConsumer { public: - SoundConsumer( - const char * name, - SoundProcessFunc recordFunc = NULL, - SoundNotifyFunc notifyFunc = NULL, - void * cookie = NULL); - ~SoundConsumer(); + SoundConsumer(const char* name, + SoundProcessFunc recordFunc = NULL, + SoundNotifyFunc notifyFunc = NULL, + void* cookie = NULL); + virtual ~SoundConsumer(); - // This function is OK to call from any thread. - status_t SetHooks( - SoundProcessFunc recordFunc = NULL, - SoundNotifyFunc notifyFunc = NULL, - void * cookie = NULL); + //This function is OK to call from any thread. + status_t SetHooks(SoundProcessFunc recordFunc = NULL, + SoundNotifyFunc notifyFunc = NULL, + void* cookie = NULL); - // The MediaNode interface + // The MediaNode interface public: -virtual port_id ControlPort() const; -virtual BMediaAddOn* AddOn( - int32 * internal_id) const; /* Who instantiated you -- or NULL for app class */ + virtual port_id ControlPort() const; + virtual BMediaAddOn* AddOn(int32* internalID) const; + // Who instantiated you -- or NULL for app class protected: + virtual void Start(bigtime_t performanceTime); + virtual void Stop(bigtime_t performanceTime, bool immediate); + virtual void Seek(bigtime_t mediaTime, + bigtime_t performanceTime); + virtual void SetRunMode(run_mode mode); + virtual void TimeWarp(bigtime_t atRealTime, + bigtime_t to_performanceTime); + virtual void Preroll(); + virtual void SetTimeSource(BTimeSource* timeSource); + virtual status_t HandleMessage(int32 message, const void* data, + size_t size); -virtual void Start( - bigtime_t performance_time); -virtual void Stop( - bigtime_t performance_time, - bool immediate); -virtual void Seek( - bigtime_t media_time, - bigtime_t performance_time); -virtual void SetRunMode( - run_mode mode); -virtual void TimeWarp( - bigtime_t at_real_time, - bigtime_t to_performance_time); -virtual void Preroll(); -virtual void SetTimeSource( - BTimeSource * time_source); -virtual status_t HandleMessage( - int32 message, - const void * data, - size_t size); + // The BufferConsumer interface + virtual status_t AcceptFormat(const media_destination& dest, + media_format* format); + virtual status_t GetNextInput(int32* cookie, + media_input* _input); + virtual void DisposeInputCookie(int32 cookie); + virtual void BufferReceived(BBuffer* buffer); + virtual void ProducerDataStatus( + const media_destination& forWhom, + int32 status, bigtime_t atMediaTime); + virtual status_t GetLatencyFor(const media_destination& forWhom, + bigtime_t* _latency, + media_node_id* _timesource); + virtual status_t Connected(const media_source& producer, + const media_destination& where, + const media_format& format, [... truncated: 147 lines follow ...] From axeld at mail.berlios.de Fri Aug 1 16:20:18 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 16:20:18 +0200 Subject: [Haiku-commits] r26718 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808011420.m71EKIBB018515@sheep.berlios.de> Author: axeld Date: 2008-08-01 16:20:16 +0200 (Fri, 01 Aug 2008) New Revision: 26718 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26718&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Chain.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/CachedBlock.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Utility.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * Replaced Chain with the new SinglyLinkedList. * Renamed openModeToAccess() to open_mode_to_access(). * Cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-01 14:20:16 UTC (rev 26718) @@ -67,7 +67,7 @@ || !strcmp(name, "size")*/) RETURN_ERROR(B_NOT_ALLOWED); - return fInode->CheckPermissions(openModeToAccess(openMode) + return fInode->CheckPermissions(open_mode_to_access(openMode) | (openMode & O_TRUNC ? W_OK : 0)); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-01 14:20:16 UTC (rev 26718) @@ -377,9 +377,10 @@ // traversing the tree - a TreeIterator doesn't lock the inode) mutex_lock(&fIteratorLock); - TreeIterator *iterator = NULL; - while ((iterator = fIterators.Next(iterator)) != NULL) - iterator->Stop(); + SinglyLinkedList::Iterator iterator + = fIterators.GetIterator(); + while (iterator.HasNext()) + iterator.Next()->Stop(); mutex_destroy(&fIteratorLock); } @@ -569,9 +570,10 @@ // any time, so we need to protect this loop MutexLocker _(fIteratorLock); - TreeIterator *iterator = NULL; - while ((iterator = fIterators.Next(iterator)) != NULL) - iterator->Update(offset, nextOffset, keyIndex, splitAt, change); + SinglyLinkedList::Iterator iterator + = fIterators.GetIterator(); + while (iterator.HasNext()) + iterator.Next()->Update(offset, nextOffset, keyIndex, splitAt, change); } @@ -1862,8 +1864,7 @@ TreeIterator::TreeIterator(BPlusTree *tree) : fTree(tree), - fCurrentNodeOffset(BPLUSTREE_NULL), - fNext(NULL) + fCurrentNodeOffset(BPLUSTREE_NULL) { tree->_AddIterator(this); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.h 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.h 2008-08-01 14:20:16 UTC (rev 26718) @@ -8,7 +8,6 @@ #include "bfs.h" #include "Journal.h" -#include "Chain.h" // #pragma mark - on-disk structures @@ -38,7 +37,7 @@ uint32 MaxNumberOfLevels() const { return BFS_ENDIAN_TO_HOST_INT32(max_number_of_levels); } - inline bool CheckNode(bplustree_node *node) const; + inline bool CheckNode(bplustree_node* node) const; inline bool IsValidLink(off_t link) const; } _PACKED; @@ -75,11 +74,11 @@ uint16 AllKeyLength() const { return BFS_ENDIAN_TO_HOST_INT16(all_key_length); } - inline uint16 *KeyLengths() const; - inline off_t *Values() const; - inline uint8 *Keys() const; + inline uint16* KeyLengths() const; + inline off_t* Values() const; + inline uint8* Keys() const; inline int32 Used() const; - uint8 *KeyAt(int32 index, uint16 *keyLength) const; + uint8* KeyAt(int32 index, uint16* keyLength) const; inline bool IsLeaf() const; @@ -87,8 +86,8 @@ uint8 CountDuplicates(off_t offset, bool isFragment) const; off_t DuplicateAt(off_t offset, bool isFragment, int8 index) const; uint32 FragmentsUsed(uint32 nodeSize) const; - inline duplicate_array *FragmentAt(int8 index) const; - inline duplicate_array *DuplicateArray() const; + inline duplicate_array* FragmentAt(int8 index) const; + inline duplicate_array* DuplicateArray() const; static inline uint8 LinkType(off_t link); static inline off_t MakeLink(uint8 type, off_t link, @@ -137,192 +136,198 @@ class CachedNode { - public: - CachedNode(BPlusTree *tree) - : - fTree(tree), - fNode(NULL) - { - } +public: + CachedNode(BPlusTree* tree) + : + fTree(tree), + fNode(NULL) + { + } - CachedNode(BPlusTree *tree, off_t offset, bool check = true) - : - fTree(tree), - fNode(NULL) - { - SetTo(offset, check); - } + CachedNode(BPlusTree* tree, off_t offset, bool check = true) + : + fTree(tree), + fNode(NULL) + { + SetTo(offset, check); + } - ~CachedNode() - { - Unset(); - } + ~CachedNode() + { + Unset(); + } - const bplustree_node *SetTo(off_t offset, bool check = true); - bplustree_node *SetToWritable(Transaction &transaction, off_t offset, - bool check = true); - bplustree_node *MakeWritable(Transaction &transaction); - const bplustree_header *SetToHeader(); - bplustree_header *SetToWritableHeader(Transaction &transaction); - bplustree_header *MakeWritableHeader(Transaction &transaction); + const bplustree_node* SetTo(off_t offset, bool check = true); + bplustree_node* SetToWritable(Transaction& transaction, off_t offset, + bool check = true); + bplustree_node* MakeWritable(Transaction& transaction); + const bplustree_header* SetToHeader(); + bplustree_header* SetToWritableHeader(Transaction& transaction); + bplustree_header* MakeWritableHeader(Transaction& transaction); - void UnsetUnchanged(Transaction &transaction); - void Unset(); + void UnsetUnchanged(Transaction& transaction); + void Unset(); - status_t Free(Transaction &transaction, off_t offset); - status_t Allocate(Transaction &transaction, bplustree_node **node, - off_t *offset); + status_t Free(Transaction& transaction, off_t offset); + status_t Allocate(Transaction& transaction, bplustree_node** node, + off_t* offset); - bool IsWritable() const { return fWritable; } - bplustree_node *Node() const { return fNode; } + bool IsWritable() const { return fWritable; } + bplustree_node* Node() const { return fNode; } - protected: - bplustree_node *InternalSetTo(Transaction *transaction, off_t offset); +protected: + bplustree_node* InternalSetTo(Transaction* transaction, off_t offset); - BPlusTree *fTree; - bplustree_node *fNode; - off_t fOffset; - off_t fBlockNumber; - bool fWritable; + BPlusTree* fTree; + bplustree_node* fNode; + off_t fOffset; + off_t fBlockNumber; + bool fWritable; }; class BPlusTree { - public: - BPlusTree(Transaction &transaction, Inode *stream, - int32 nodeSize = BPLUSTREE_NODE_SIZE); - BPlusTree(Inode *stream); - BPlusTree(); - ~BPlusTree(); +public: + BPlusTree(Transaction& transaction, Inode* stream, + int32 nodeSize = BPLUSTREE_NODE_SIZE); + BPlusTree(Inode* stream); + BPlusTree(); + ~BPlusTree(); - status_t SetTo(Transaction &transaction, Inode *stream, - int32 nodeSize = BPLUSTREE_NODE_SIZE); - status_t SetTo(Inode *stream); - status_t SetStream(Inode *stream); + status_t SetTo(Transaction& transaction, Inode* stream, + int32 nodeSize = BPLUSTREE_NODE_SIZE); + status_t SetTo(Inode* stream); + status_t SetStream(Inode* stream); - status_t InitCheck(); - status_t Validate(); + status_t InitCheck(); + status_t Validate(); - status_t Remove(Transaction &transaction, const uint8 *key, - uint16 keyLength, off_t value); - status_t Insert(Transaction &transaction, const uint8 *key, - uint16 keyLength, off_t value); + status_t Remove(Transaction& transaction, const uint8* key, + uint16 keyLength, off_t value); + status_t Insert(Transaction& transaction, const uint8* key, + uint16 keyLength, off_t value); - status_t Remove(Transaction &transaction, const char *key, - off_t value); - status_t Insert(Transaction &transaction, const char *key, - off_t value); - status_t Insert(Transaction &transaction, int32 key, off_t value); - status_t Insert(Transaction &transaction, uint32 key, off_t value); - status_t Insert(Transaction &transaction, int64 key, off_t value); - status_t Insert(Transaction &transaction, uint64 key, off_t value); - status_t Insert(Transaction &transaction, float key, off_t value); - status_t Insert(Transaction &transaction, double key, off_t value); + status_t Remove(Transaction& transaction, const char* key, + off_t value); + status_t Insert(Transaction& transaction, const char* key, + off_t value); + status_t Insert(Transaction& transaction, int32 key, + off_t value); + status_t Insert(Transaction& transaction, uint32 key, + off_t value); + status_t Insert(Transaction& transaction, int64 key, + off_t value); + status_t Insert(Transaction& transaction, uint64 key, + off_t value); + status_t Insert(Transaction& transaction, float key, + off_t value); + status_t Insert(Transaction& transaction, double key, + off_t value); - status_t Replace(Transaction &transaction, const uint8 *key, - uint16 keyLength, off_t value); - status_t Find(const uint8 *key, uint16 keyLength, off_t *value); + status_t Replace(Transaction& transaction, const uint8* key, + uint16 keyLength, off_t value); + status_t Find(const uint8* key, uint16 keyLength, off_t* value); - static int32 TypeCodeToKeyType(type_code code); - static int32 ModeToKeyType(mode_t mode); + static int32 TypeCodeToKeyType(type_code code); + static int32 ModeToKeyType(mode_t mode); - private: - BPlusTree(const BPlusTree &); - BPlusTree &operator=(const BPlusTree &); - // no implementation +private: + BPlusTree(const BPlusTree& other); + BPlusTree& operator=(const BPlusTree& other); + // no implementation - int32 _CompareKeys(const void *key1, int keylength1, - const void *key2, int keylength2); - status_t _FindKey(const bplustree_node *node, const uint8 *key, - uint16 keyLength, uint16 *index = NULL, - off_t *next = NULL); - status_t _SeekDown(Stack &stack, const uint8 *key, - uint16 keyLength); + int32 _CompareKeys(const void* key1, int keylength1, + const void* key2, int keylength2); + status_t _FindKey(const bplustree_node* node, const uint8* key, + uint16 keyLength, uint16* index = NULL, + off_t* next = NULL); + status_t _SeekDown(Stack& stack, const uint8* key, + uint16 keyLength); - status_t _FindFreeDuplicateFragment(Transaction &transaction, - const bplustree_node *node, CachedNode &cached, - off_t *_offset, bplustree_node **_fragment, - uint32 *_index); - status_t _InsertDuplicate(Transaction &transaction, - CachedNode &cached, const bplustree_node *node, - uint16 index, off_t value); - void _InsertKey(bplustree_node *node, uint16 index, uint8 *key, - uint16 keyLength, off_t value); - status_t _SplitNode(bplustree_node *node, off_t nodeOffset, - bplustree_node *other, off_t otherOffset, - uint16 *_keyIndex, uint8 *key, uint16 *_keyLength, - off_t *_value); + status_t _FindFreeDuplicateFragment(Transaction& transaction, + const bplustree_node* node, CachedNode& cached, + off_t* _offset, bplustree_node** _fragment, + uint32* _index); + status_t _InsertDuplicate(Transaction& transaction, + CachedNode& cached, const bplustree_node* node, + uint16 index, off_t value); + void _InsertKey(bplustree_node* node, uint16 index, + uint8* key, uint16 keyLength, off_t value); + status_t _SplitNode(bplustree_node* node, off_t nodeOffset, + bplustree_node* other, off_t otherOffset, + uint16* _keyIndex, uint8* key, uint16* _keyLength, + off_t* _value); - status_t _RemoveDuplicate(Transaction &transaction, - const bplustree_node *node, CachedNode &cached, - uint16 keyIndex, off_t value); - void _RemoveKey(bplustree_node *node, uint16 index); + status_t _RemoveDuplicate(Transaction& transaction, + const bplustree_node* node, CachedNode& cached, + uint16 keyIndex, off_t value); + void _RemoveKey(bplustree_node* node, uint16 index); - void _UpdateIterators(off_t offset, off_t nextOffset, - uint16 keyIndex, uint16 splitAt, int8 change); - void _AddIterator(TreeIterator *iterator); - void _RemoveIterator(TreeIterator *iterator); + void _UpdateIterators(off_t offset, off_t nextOffset, + uint16 keyIndex, uint16 splitAt, int8 change); + void _AddIterator(TreeIterator* iterator); + void _RemoveIterator(TreeIterator* iterator); - private: - friend class TreeIterator; - friend class CachedNode; +private: + friend class TreeIterator; + friend class CachedNode; - Inode *fStream; - const bplustree_header *fHeader; - CachedNode fCachedHeader; - int32 fNodeSize; - bool fAllowDuplicates; - status_t fStatus; - mutex fIteratorLock; - Chain fIterators; + Inode* fStream; + const bplustree_header* fHeader; + CachedNode fCachedHeader; + int32 fNodeSize; + bool fAllowDuplicates; + status_t fStatus; + mutex fIteratorLock; + SinglyLinkedList fIterators; }; // #pragma mark - helper classes/functions -extern int32 compareKeys(type_code type, const void *key1, int keyLength1, - const void *key2, int keyLength2); +extern int32 compareKeys(type_code type, const void* key1, int keyLength1, + const void* key2, int keyLength2); -class TreeIterator { - public: - TreeIterator(BPlusTree *tree); - ~TreeIterator(); +class TreeIterator : public SinglyLinkedListLinkImpl { +public: + TreeIterator(BPlusTree* tree); + ~TreeIterator(); - status_t Goto(int8 to); - status_t Traverse(int8 direction, void *key, uint16 *keyLength, - uint16 maxLength, off_t *value, - uint16 *duplicate = NULL); - status_t Find(const uint8 *key, uint16 keyLength); + status_t Goto(int8 to); + status_t Traverse(int8 direction, void* key, uint16* keyLength, + uint16 maxLength, off_t* value, + uint16* duplicate = NULL); + status_t Find(const uint8* key, uint16 keyLength); - status_t Rewind(); - status_t GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength, - off_t *value, uint16 *duplicate = NULL); - status_t GetPreviousEntry(void *key, uint16 *keyLength, - uint16 maxLength, off_t *value, - uint16 *duplicate = NULL); - void SkipDuplicates(); + status_t Rewind(); + status_t GetNextEntry(void* key, uint16* keyLength, + uint16 maxLength, off_t* value, + uint16* duplicate = NULL); + status_t GetPreviousEntry(void* key, uint16* keyLength, + uint16 maxLength, off_t* value, + uint16* duplicate = NULL); + void SkipDuplicates(); #ifdef DEBUG - void Dump(); + void Dump(); #endif - private: - BPlusTree *fTree; +private: + friend class BPlusTree; - off_t fCurrentNodeOffset; // traverse position - int32 fCurrentKey; - off_t fDuplicateNode; - uint16 fDuplicate, fNumDuplicates; - bool fIsFragment; + // called by BPlusTree + void Update(off_t offset, off_t nextOffset, uint16 keyIndex, + uint16 splitAt, int8 change); + void Stop(); - private: - friend class Chain; - friend class BPlusTree; - - void Update(off_t offset, off_t nextOffset, uint16 keyIndex, - uint16 splitAt, int8 change); - void Stop(); - TreeIterator *fNext; +private: + BPlusTree* fTree; + off_t fCurrentNodeOffset; + // traverse position + int32 fCurrentKey; + off_t fDuplicateNode; + uint16 fDuplicate, fNumDuplicates; + bool fIsFragment; }; @@ -331,67 +336,67 @@ inline status_t -BPlusTree::Remove(Transaction &transaction, const char *key, off_t value) +BPlusTree::Remove(Transaction& transaction, const char* key, off_t value) { if (fHeader->data_type != BPLUSTREE_STRING_TYPE) return B_BAD_TYPE; - return Remove(transaction, (uint8 *)key, strlen(key), value); + return Remove(transaction, (uint8*)key, strlen(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, const char *key, off_t value) +BPlusTree::Insert(Transaction& transaction, const char* key, off_t value) { if (fHeader->data_type != BPLUSTREE_STRING_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)key, strlen(key), value); + return Insert(transaction, (uint8*)key, strlen(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, int32 key, off_t value) +BPlusTree::Insert(Transaction& transaction, int32 key, off_t value) { if (fHeader->data_type != BPLUSTREE_INT32_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, uint32 key, off_t value) +BPlusTree::Insert(Transaction& transaction, uint32 key, off_t value) { if (fHeader->data_type != BPLUSTREE_UINT32_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, int64 key, off_t value) +BPlusTree::Insert(Transaction& transaction, int64 key, off_t value) { if (fHeader->data_type != BPLUSTREE_INT64_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, uint64 key, off_t value) +BPlusTree::Insert(Transaction& transaction, uint64 key, off_t value) { if (fHeader->data_type != BPLUSTREE_UINT64_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, float key, off_t value) +BPlusTree::Insert(Transaction& transaction, float key, off_t value) { if (fHeader->data_type != BPLUSTREE_FLOAT_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } inline status_t -BPlusTree::Insert(Transaction &transaction, double key, off_t value) +BPlusTree::Insert(Transaction& transaction, double key, off_t value) { if (fHeader->data_type != BPLUSTREE_DOUBLE_TYPE) return B_BAD_TYPE; - return Insert(transaction, (uint8 *)&key, sizeof(key), value); + return Insert(transaction, (uint8*)&key, sizeof(key), value); } @@ -405,16 +410,16 @@ } inline status_t -TreeIterator::GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength, - off_t *value, uint16 *duplicate) +TreeIterator::GetNextEntry(void* key, uint16* keyLength, uint16 maxLength, + off_t* value, uint16* duplicate) { return Traverse(BPLUSTREE_FORWARD, key, keyLength, maxLength, value, duplicate); } inline status_t -TreeIterator::GetPreviousEntry(void *key, uint16 *keyLength, uint16 maxLength, - off_t *value, uint16 *duplicate) +TreeIterator::GetPreviousEntry(void* key, uint16* keyLength, uint16 maxLength, + off_t* value, uint16* duplicate) { return Traverse(BPLUSTREE_BACKWARD, key, keyLength, maxLength, value, duplicate); @@ -425,14 +430,14 @@ inline bool -bplustree_header::CheckNode(bplustree_node *node) const +bplustree_header::CheckNode(bplustree_node* node) const { // sanity checks (links, all_key_count) return IsValidLink(node->LeftLink()) && IsValidLink(node->RightLink()) && IsValidLink(node->OverflowLink()) - && (int8 *)node->Values() + node->NumKeys() * sizeof(off_t) - <= (int8 *)node + NodeSize(); + && (int8*)node->Values() + node->NumKeys() * sizeof(off_t) + <= (int8*)node + NodeSize(); } @@ -447,25 +452,25 @@ // #pragma mark - bplustree_node inline functions -inline uint16 * +inline uint16* bplustree_node::KeyLengths() const { - return (uint16 *)(((char *)this) + key_align(sizeof(bplustree_node) + return (uint16*)(((char*)this) + key_align(sizeof(bplustree_node) + AllKeyLength())); } -inline off_t * +inline off_t* bplustree_node::Values() const { - return (off_t *)((char *)KeyLengths() + NumKeys() * sizeof(uint16)); + return (off_t*)((char*)KeyLengths() + NumKeys() * sizeof(uint16)); } -inline uint8 * +inline uint8* bplustree_node::Keys() const { - return (uint8 *)this + sizeof(bplustree_node); + return (uint8*)this + sizeof(bplustree_node); } @@ -484,25 +489,24 @@ } -inline duplicate_array * +inline duplicate_array* bplustree_node::FragmentAt(int8 index) const { - return (duplicate_array *)((off_t *)this - + index * (NUM_FRAGMENT_VALUES + 1)); + return (duplicate_array*)((off_t*)this + index * (NUM_FRAGMENT_VALUES + 1)); } -inline duplicate_array * +inline duplicate_array* bplustree_node::DuplicateArray() const { - return (duplicate_array *)&this->overflow_link; + return (duplicate_array*)&overflow_link; } inline uint8 bplustree_node::LinkType(off_t link) { - return *(uint64 *)&link >> 62; + return *(uint64*)&link >> 62; } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/CachedBlock.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/CachedBlock.h 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/CachedBlock.h 2008-08-01 14:20:16 UTC (rev 26718) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, 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 CACHED_BLOCK_H @@ -12,7 +12,6 @@ #include "Volume.h" #include "Journal.h" -#include "Chain.h" #include "Debug.h" @@ -23,34 +22,34 @@ class CachedBlock { public: - CachedBlock(Volume *volume); - CachedBlock(Volume *volume, off_t block); - CachedBlock(Volume *volume, block_run run); - CachedBlock(CachedBlock *cached); + CachedBlock(Volume* volume); + CachedBlock(Volume* volume, off_t block); + CachedBlock(Volume* volume, block_run run); + CachedBlock(CachedBlock* cached); ~CachedBlock(); inline void Keep(); inline void Unset(); - inline const uint8 *SetTo(off_t block, off_t base, size_t length); - inline const uint8 *SetTo(off_t block); - inline const uint8 *SetTo(block_run run); - inline uint8 *SetToWritable(Transaction &transaction, off_t block, + inline const uint8* SetTo(off_t block, off_t base, size_t length); + inline const uint8* SetTo(off_t block); + inline const uint8* SetTo(block_run run); + inline uint8* SetToWritable(Transaction& transaction, off_t block, off_t base, size_t length, bool empty = false); - inline uint8 *SetToWritable(Transaction &transaction, off_t block, + inline uint8* SetToWritable(Transaction& transaction, off_t block, bool empty = false); - inline uint8 *SetToWritable(Transaction &transaction, block_run run, + inline uint8* SetToWritable(Transaction& transaction, block_run run, bool empty = false); - inline status_t MakeWritable(Transaction &transaction); + inline status_t MakeWritable(Transaction& transaction); - const uint8 *Block() const { return fBlock; } + const uint8* Block() const { return fBlock; } off_t BlockNumber() const { return fBlockNumber; } uint32 BlockSize() const { return fVolume->BlockSize(); } uint32 BlockShift() const { return fVolume->BlockShift(); } private: - CachedBlock(const CachedBlock &); - CachedBlock &operator=(const CachedBlock &); + CachedBlock(const CachedBlock& other); + CachedBlock& operator=(const CachedBlock& other); // no implementation protected: @@ -64,7 +63,7 @@ inline -CachedBlock::CachedBlock(Volume *volume) +CachedBlock::CachedBlock(Volume* volume) : fVolume(volume), fBlockNumber(0), @@ -74,7 +73,7 @@ inline -CachedBlock::CachedBlock(Volume *volume, off_t block) +CachedBlock::CachedBlock(Volume* volume, off_t block) : fVolume(volume), fBlockNumber(0), @@ -85,7 +84,7 @@ inline -CachedBlock::CachedBlock(Volume *volume, block_run run) +CachedBlock::CachedBlock(Volume* volume, block_run run) : fVolume(volume), fBlockNumber(0), @@ -96,7 +95,7 @@ inline -CachedBlock::CachedBlock(CachedBlock *cached) +CachedBlock::CachedBlock(CachedBlock* cached) : fVolume(cached->fVolume), fBlockNumber(cached->BlockNumber()), @@ -130,42 +129,42 @@ } -inline const uint8 * +inline const uint8* CachedBlock::SetTo(off_t block, off_t base, size_t length) { Unset(); fBlockNumber = block; - return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(), + return fBlock = (uint8*)block_cache_get_etc(fVolume->BlockCache(), block, base, length); } -inline const uint8 * +inline const uint8* CachedBlock::SetTo(off_t block) { return SetTo(block, block, 1); } -inline const uint8 * +inline const uint8* CachedBlock::SetTo(block_run run) { return SetTo(fVolume->ToBlock(run)); } -inline uint8 * -CachedBlock::SetToWritable(Transaction &transaction, off_t block, off_t base, +inline uint8* +CachedBlock::SetToWritable(Transaction& transaction, off_t block, off_t base, size_t length, bool empty) { Unset(); fBlockNumber = block; if (empty) { - fBlock = (uint8 *)block_cache_get_empty(fVolume->BlockCache(), + fBlock = (uint8*)block_cache_get_empty(fVolume->BlockCache(), block, transaction.ID()); } else { - fBlock = (uint8 *)block_cache_get_writable_etc(fVolume->BlockCache(), + fBlock = (uint8*)block_cache_get_writable_etc(fVolume->BlockCache(), block, base, length, transaction.ID()); } @@ -173,22 +172,22 @@ } -inline uint8 * -CachedBlock::SetToWritable(Transaction &transaction, off_t block, bool empty) +inline uint8* +CachedBlock::SetToWritable(Transaction& transaction, off_t block, bool empty) { return SetToWritable(transaction, block, block, 1, empty); } -inline uint8 * -CachedBlock::SetToWritable(Transaction &transaction, block_run run, bool empty) +inline uint8* +CachedBlock::SetToWritable(Transaction& transaction, block_run run, bool empty) { return SetToWritable(transaction, fVolume->ToBlock(run), empty); } inline status_t -CachedBlock::MakeWritable(Transaction &transaction) +CachedBlock::MakeWritable(Transaction& transaction) { if (fBlock == NULL) return B_NO_INIT; @@ -197,5 +196,4 @@ transaction.ID()); } - -#endif /* CACHED_BLOCK_H */ +#endif // CACHED_BLOCK_H Deleted: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Chain.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-01 14:20:16 UTC (rev 26718) @@ -596,9 +596,10 @@ memset(item, 0, item->Size()); // update all current iterators - AttributeIterator *iterator = NULL; - while ((iterator = fIterators.Next(iterator)) != NULL) { - iterator->Update(index, -1); + SinglyLinkedList::Iterator iterator + = fIterators.GetIterator(); + while (iterator.HasNext()) { + iterator.Next()->Update(index, -1); } return B_OK; @@ -780,9 +781,10 @@ memset(item, 0, (uint8 *)node + fVolume->InodeSize() - (uint8 *)item); // update all current iterators - AttributeIterator *iterator = NULL; - while ((iterator = fIterators.Next(iterator)) != NULL) { - iterator->Update(index, 1); + SinglyLinkedList::Iterator iterator + = fIterators.GetIterator(); + while (iterator.HasNext()) { + iterator.Next()->Update(index, 1); } return B_OK; @@ -2356,7 +2358,7 @@ return B_IS_A_DIRECTORY; // we want to open the file, so we should have the rights to do so - if (inode->CheckPermissions(openModeToAccess(openMode)) != B_OK) + if (inode->CheckPermissions(open_mode_to_access(openMode)) != B_OK) return B_NOT_ALLOWED; if (openMode & O_TRUNC) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.h 2008-08-01 14:20:16 UTC (rev 26718) @@ -9,7 +9,6 @@ #include "system_dependencies.h" #include "CachedBlock.h" -#include "Chain.h" #include "Debug.h" #include "Journal.h" #include "Volume.h" @@ -236,7 +235,7 @@ // the correct keys from the indices mutable recursive_lock fSmallDataLock; - Chain fIterators; + SinglyLinkedList fIterators; }; #if _KERNEL_MODE && KDEBUG @@ -384,7 +383,7 @@ }; -class AttributeIterator { +class AttributeIterator : public SinglyLinkedListLinkImpl { public: AttributeIterator(Inode* inode); ~AttributeIterator(); @@ -394,13 +393,11 @@ ino_t* id); private: - friend class Chain; friend class Inode; void Update(uint16 index, int8 change); private: - AttributeIterator* fNext; int32 fCurrentSmallData; Inode* fInode; Inode* fAttributes; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2008-08-01 14:20:16 UTC (rev 26718) @@ -13,7 +13,6 @@ #endif #include "Volume.h" -#include "Chain.h" #include "Utility.h" Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.h 2008-08-01 14:16:05 UTC (rev 26717) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Query.h 2008-08-01 14:20:16 UTC (rev 26718) @@ -1,6 +1,5 @@ -/* Query - query parsing and evaluation - * - * Copyright 2001-2004, 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 QUERY_H @@ -8,9 +7,9 @@ #include "system_dependencies.h" -#include "Chain.h" #include "Index.h" + class Volume; class Term; class Equation; @@ -19,60 +18,58 @@ class Expression { - public: - Expression(char *expr); - ~Expression(); +public: + Expression(char* expr); + ~Expression(); - status_t InitCheck(); - const char *Position() const { return fPosition; } - Term *Root() const { return fTerm; } + status_t InitCheck(); + const char* Position() const { return fPosition; } + Term* Root() const { return fTerm; } - protected: - Term *ParseOr(char **expr); - Term *ParseAnd(char **expr); - Term *ParseEquation(char **expr); +protected: + Term* ParseOr(char** expr); + Term* ParseAnd(char** expr); + Term* ParseEquation(char** expr); - bool IsOperator(char **expr,char op); + bool IsOperator(char** expr, char op); - private: - Expression(const Expression &); - Expression &operator=(const Expression &); - // no implementation +private: + Expression(const Expression& other); + Expression& operator=(const Expression& other); + // no implementation - char *fPosition; - Term *fTerm; + char* fPosition; + Term* fTerm; }; [... truncated: 125 lines follow ...] From axeld at mail.berlios.de Fri Aug 1 17:02:04 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 17:02:04 +0200 Subject: [Haiku-commits] r26719 - in haiku/trunk: headers/posix src/system/libroot/posix/stdlib src/tests/system/libroot/posix Message-ID: <200808011502.m71F24SM021905@sheep.berlios.de> Author: axeld Date: 2008-08-01 17:02:03 +0200 (Fri, 01 Aug 2008) New Revision: 26719 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26719&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/clearenv.cpp Modified: haiku/trunk/headers/posix/stdlib.h haiku/trunk/src/system/libroot/posix/stdlib/env.c haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: * Sean C. Farley made me aware that some of the possible solutions to clear the environment would crash on Haiku. Added a small test application that just checks every one of those. * Fixed env locking (in userland, you better check against B_INTERRUPTED). * Made our code safe against an environ of NULL. * There is now an additional sManagedEnviron that points to the environment our code actually managed; whenever an application overrides environ, we'll get aware of it with the next *env() function invocation, and will handle it adequately. * Added non-POSIX clearenv() function. Modified: haiku/trunk/headers/posix/stdlib.h =================================================================== --- haiku/trunk/headers/posix/stdlib.h 2008-08-01 14:20:16 UTC (rev 26718) +++ haiku/trunk/headers/posix/stdlib.h 2008-08-01 15:02:03 UTC (rev 26719) @@ -22,21 +22,21 @@ /* random data structures (for thread-safe random numbers) */ struct random_data { - int *fptr; - int *rptr; - int *state; - int rand_type; - int rand_deg; - int rand_sep; - int *end_ptr; + int *fptr; + int *rptr; + int *state; + int rand_type; + int rand_deg; + int rand_sep; + int *end_ptr; }; struct drand48_data { - unsigned short int x[3]; - unsigned short int a[3]; - unsigned short int c; - unsigned short int old_x[3]; - int init; + unsigned short int x[3]; + unsigned short int a[3]; + unsigned short int c; + unsigned short int old_x[3]; + int init; }; @@ -73,6 +73,7 @@ /* environment variables */ extern char **environ; +extern int clearenv(void); extern char *getenv(const char *name); extern int putenv(const char *string); extern int setenv(char const *name, char const *value, int rewrite); @@ -102,7 +103,7 @@ extern int srandom_r(unsigned int seed, struct random_data *data); extern char *initstate(unsigned int seed, char *state, size_t size); extern char *setstate(char *state); -extern int initstate_r(unsigned int seed, void *stateBuffer, +extern int initstate_r(unsigned int seed, void *stateBuffer, size_t stateLength, struct random_data *data); extern int setstate_r(void *stateBuffer, struct random_data *data); @@ -164,7 +165,7 @@ extern size_t wcstombs(char *string, const wchar_t *pwcs, size_t maxSize); /* crypt */ -extern void setkey(const char *key); +extern void setkey(const char *key); /* pty functions */ Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 14:20:16 UTC (rev 26718) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 15:02:03 UTC (rev 26719) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -25,15 +25,35 @@ // TODO: Use benaphore! static sem_id sEnvLock; +static char **sManagedEnviron; static bool sCopied; char **environ = NULL; +static inline void +lock_variables(void) +{ + while (acquire_sem(sEnvLock) == B_INTERRUPTED) + ; +} + + +static inline void +unlock_variables(void) +{ + release_sem(sEnvLock); +} + + static int32 count_variables(void) { int32 i = 0; + + if (environ == NULL) + return 0; + while (environ[i]) i++; @@ -52,7 +72,7 @@ newEnv[count] = NULL; // null terminate the array - environ = newEnv; + environ = sManagedEnviron = newEnv; return count - 1; } @@ -63,6 +83,9 @@ { int32 i; + if (environ == NULL) + return NULL; + for (i = 0; environ[i] != NULL; i++) { if (!strncmp(name, environ[i], length) && environ[i][length] == '=') { if (_index != NULL) @@ -78,38 +101,44 @@ static status_t copy_environ_to_heap_if_needed(void) { - char **newEnv; - int32 i; + int32 i = 0; - if (sCopied) + if (sCopied && environ == sManagedEnviron) return B_OK; - newEnv = malloc((count_variables() + 1) * sizeof(char *)); - if (newEnv == NULL) + if (sManagedEnviron != NULL) { + // free previously used "environ"; it has been changed by an application + free(sManagedEnviron); + } + + sManagedEnviron = malloc((count_variables() + 1) * sizeof(char *)); + if (sManagedEnviron == NULL) return B_NO_MEMORY; - for (i = 0; environ[i]; i++) { - newEnv[i] = strdup(environ[i]); + if (environ != NULL) { + // copy from previous + for (; environ[i]; i++) { + sManagedEnviron[i] = strdup(environ[i]); + } } - newEnv[i] = NULL; + sManagedEnviron[i] = NULL; // null terminate the array - environ = newEnv; + environ = sManagedEnviron; sCopied = true; return B_OK; } static status_t -update_variable(const char *name, int32 length, const char *value, bool overwrite) +update_variable(const char *name, int32 length, const char *value, + bool overwrite) { - status_t status = B_OK; bool update = false; int32 index; char *env; - acquire_sem(sEnvLock); copy_environ_to_heap_if_needed(); env = find_variable(name, length, &index); @@ -120,24 +149,23 @@ } else if (env == NULL) { // add variable index = add_variable(); - if (index >= 0) - update = true; - else - status = index; + if (index < 0) + return B_NO_MEMORY; + + update = true; } if (update) { environ[index] = malloc(length + 2 + strlen(value)); - if (environ[index] != NULL) { - memcpy(environ[index], name, length); - environ[index][length] = '='; - strcpy(environ[index] + length + 1, value); - } else - status = B_NO_MEMORY; + if (environ[index] == NULL) + return B_NO_MEMORY; + + memcpy(environ[index], name, length); + environ[index][length] = '='; + strcpy(environ[index] + length + 1, value); } - release_sem(sEnvLock); - return status; + return B_OK; } @@ -148,30 +176,48 @@ } -void +// #pragma mark - libroot initializer + + +void __init_env(const struct user_space_program_args *args) { - // Following POSIX, there is no need to make any of the - // environment functions thread-safe - but we do it anyway + // Following POSIX, there is no need to make any of the environment + // functions thread-safe - but we do it anyway as much as possible to + // protect our implementation sEnvLock = create_sem(1, "env lock"); environ = args->env; + sManagedEnviron = NULL; atfork(environ_fork_hook); } -// #pragma mark - +// #pragma mark - public API +int +clearenv(void) +{ + lock_variables(); + + free(sManagedEnviron); + sManagedEnviron = environ = NULL; + + unlock_variables(); +} + + char * getenv(const char *name) { int32 length = strlen(name); char *value; - acquire_sem(sEnvLock); + lock_variables(); + value = find_variable(name, length, NULL); - release_sem(sEnvLock); + unlock_variables(); if (value == NULL) return NULL; @@ -190,7 +236,10 @@ return -1; } + lock_variables(); status = update_variable(name, strlen(name), value, overwrite); + unlock_variables(); + RETURN_AND_SET_ERRNO(status); } @@ -208,7 +257,8 @@ length = strlen(name); - acquire_sem(sEnvLock); + lock_variables(); + copy_environ_to_heap_if_needed(); env = find_variable(name, length, &index); @@ -220,7 +270,7 @@ sizeof(char *) * (count_variables() - index)); } - release_sem(sEnvLock); + unlock_variables(); return 0; } @@ -236,7 +286,10 @@ return -1; } + lock_variables(); status = update_variable(string, value - string, value + 1, true); + unlock_variables(); + RETURN_AND_SET_ERRNO(status); } Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-01 14:20:16 UTC (rev 26718) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-01 15:02:03 UTC (rev 26719) @@ -6,6 +6,10 @@ : SyslogTest.cpp syslog.cpp ; +SimpleTest clearenv + : clearenv.cpp +; + SimpleTest flock_test : flock_test.cpp ; Added: haiku/trunk/src/tests/system/libroot/posix/clearenv.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/clearenv.cpp 2008-08-01 14:20:16 UTC (rev 26718) +++ haiku/trunk/src/tests/system/libroot/posix/clearenv.cpp 2008-08-01 15:02:03 UTC (rev 26719) @@ -0,0 +1,64 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ + + +#include +#include + + +int gTestNr; + + +void +set_env() +{ + gTestNr++; + printf("Test %d...\n", gTestNr); + + if (setenv("TEST_VARIABLE", "42", true) != 0) + fprintf(stderr, "Test %d: setting variable failed!\n", gTestNr); +} + + +void +test_env() +{ + if (getenv("TEST_VARIABLE") != NULL) + fprintf(stderr, "Test %d: not cleared!\n", gTestNr); + if (setenv("OTHER_VARIABLE", "test", true) != 0) + fprintf(stderr, "Test %d: setting other failed!\n", gTestNr); +} + + +int +main(int argc, char** argv) +{ + set_env(); + environ = NULL; + test_env(); + + set_env(); + environ[0] = NULL; + test_env(); + + static char* emptyEnv[1] = {NULL}; + set_env(); + environ = emptyEnv; + test_env(); + + set_env(); + environ = (char**)calloc(1, sizeof(*environ)); + test_env(); + + // clearenv() is not part of the POSIX specs +#if 1 + set_env(); + clearenv(); + test_env(); +#endif + + return 0; +} + From axeld at mail.berlios.de Fri Aug 1 17:08:07 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 17:08:07 +0200 Subject: [Haiku-commits] r26720 - haiku/trunk/src/system/libroot/posix/stdlib Message-ID: <200808011508.m71F87g8022557@sheep.berlios.de> Author: axeld Date: 2008-08-01 17:08:06 +0200 (Fri, 01 Aug 2008) New Revision: 26720 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26720&view=rev Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c Log: * Instead of just deleting the array, we have to delete its contents, too. Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 15:02:03 UTC (rev 26719) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 15:08:06 UTC (rev 26720) @@ -46,6 +46,23 @@ } +static void +free_variables(void) +{ + int32 i; + + if (sManagedEnviron == NULL) + return; + + for (i = 0; sManagedEnviron[i] != NULL; i++) { + free(sManagedEnviron[i]); + } + + free(sManagedEnviron); + sManagedEnviron = NULL; +} + + static int32 count_variables(void) { @@ -108,7 +125,7 @@ if (sManagedEnviron != NULL) { // free previously used "environ"; it has been changed by an application - free(sManagedEnviron); + free_variables(); } sManagedEnviron = malloc((count_variables() + 1) * sizeof(char *)); @@ -201,8 +218,8 @@ { lock_variables(); - free(sManagedEnviron); - sManagedEnviron = environ = NULL; + free_variables(); + environ = NULL; unlock_variables(); } From ingo_weinhold at gmx.de Fri Aug 1 17:26:57 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 01 Aug 2008 17:26:57 +0200 Subject: [Haiku-commits] r26715 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <200808011228.m71CSUjD005693@sheep.berlios.de> References: <200808011228.m71CSUjD005693@sheep.berlios.de> Message-ID: <20080801172657.487.1@knochen-vm.localdomain> On 2008-08-01 at 14:28:30 [+0200], axeld at BerliOS wrote: > - locker.Lock(); > + // TODO: we actually need to call WriteLockInTransaction() here, but we > + // cannot do this with the current locking model (ie. file cache > functions > + // are not to be called with the inode lock held). > + // But this cannot work anyway, since we hold the lock when calling > + // file_cache_set_size(), too... (possible deadlock) > + rw_lock_write_lock(&fLock); I don't think the VFS/VM locking is to blame here. At least I can't see how to change it to avoid this problem. What could help is a different locking/transaction model in the BFS implementation. Changes in a transaction could be invisible to others until committed. I.e. in this case the file's size would be changed, but a reader could still access the file at the same time and would see the file with the old size. Another writer could also write in parallel, unless it would cause the file to be resized as well. I don't know how well the BFS structures allow to implement it this way though. CU, Ingo From mmu_man at mail.berlios.de Fri Aug 1 18:01:11 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Fri, 1 Aug 2008 18:01:11 +0200 Subject: [Haiku-commits] r26721 - haiku/trunk/src/system/boot/platform/atari_m68k Message-ID: <200808011601.m71G1Bra025759@sheep.berlios.de> Author: mmu_man Date: 2008-08-01 18:01:02 +0200 (Fri, 01 Aug 2008) New Revision: 26721 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26721&view=rev Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp haiku/trunk/src/system/boot/platform/atari_m68k/mmu.h haiku/trunk/src/system/boot/platform/atari_m68k/mmu_030.cpp haiku/trunk/src/system/boot/platform/atari_m68k/mmu_040.cpp Log: allocate all kernel page directories at boot, this will simplify later code a lot. Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-01 15:08:06 UTC (rev 26720) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-01 16:01:02 UTC (rev 26721) @@ -270,8 +270,12 @@ // set the root pointers gMMUOps->load_rp(gPageRoot); + // allocate second level tables for kernel space + // this will simplify mmu code a lot, and only wastes 32KB + gMMUOps->allocate_kernel_pgdirs(); // enable mmu translation gMMUOps->enable_paging(); + //XXX: check for errors //gKernelArgs.arch_args.num_pgtables = 0; gMMUOps->add_page_table(KERNEL_BASE); Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.h =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu.h 2008-08-01 15:08:06 UTC (rev 26720) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu.h 2008-08-01 16:01:02 UTC (rev 26721) @@ -31,6 +31,7 @@ status_t (*set_tt)(int which, addr_t pa, size_t len, uint32 perms); /* load root pointers */ status_t (*load_rp)(addr_t pa); + status_t (*allocate_kernel_pgdirs)(void); status_t (*enable_paging)(void); status_t (*add_page_table)(addr_t virtualAddress); void (*unmap_page)(addr_t virtualAddress); Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu_030.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu_030.cpp 2008-08-01 15:08:06 UTC (rev 26720) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu_030.cpp 2008-08-01 16:01:02 UTC (rev 26721) @@ -104,6 +104,30 @@ static status_t +allocate_kernel_pgdirs(void) +{ + page_root_entry *pr = gPageRoot; + page_directory_entry *pd; + addr_t tbl; + int i; + + // we'll fill in the 2nd half with ready made page dirs + for (i = NUM_ROOTENT_PER_TBL/2; i < NUM_ROOTENT_PER_TBL; i++) { + if (i % NUM_DIRTBL_PER_PAGE) + tbl += SIZ_DIRTBL; + else + tbl = mmu_get_next_page_tables(); + pr[i].addr = TA_TO_PREA(tbl); + pr[i].type = DT_ROOT; + pd = (page_directory_entry *)tbl; + for (int32 j = 0; j < NUM_DIRENT_PER_TBL; j++) + *(page_directory_entry_scalar *)(&pd[j]) = DFL_DIRENT_VAL; + } + return B_OK; +} + + +static status_t enable_paging(void) { TRACE(("mmu_030:enable_paging\n")); @@ -115,5 +139,6 @@ &initialize, &set_tt, &load_rp, + &allocate_kernel_pgdirs, &enable_paging }; Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu_040.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu_040.cpp 2008-08-01 15:08:06 UTC (rev 26720) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu_040.cpp 2008-08-01 16:01:02 UTC (rev 26721) @@ -108,6 +108,30 @@ static status_t +allocate_kernel_pgdirs(void) +{ + page_root_entry *pr = gPageRoot; + page_directory_entry *pd; + addr_t tbl; + int i; + + // we'll fill in the 2nd half with ready made page dirs + for (i = NUM_ROOTENT_PER_TBL/2; i < NUM_ROOTENT_PER_TBL; i++) { + if (i % NUM_DIRTBL_PER_PAGE) + tbl += SIZ_DIRTBL; + else + tbl = mmu_get_next_page_tables(); + pr[i].addr = TA_TO_PREA(tbl); + pr[i].type = DT_ROOT; + pd = (page_directory_entry *)tbl; + for (int32 j = 0; j < NUM_DIRENT_PER_TBL; j++) + *(page_directory_entry_scalar *)(&pd[j]) = DFL_DIRENT_VAL; + } + return B_OK; +} + + +static status_t enable_paging(void) { TRACE(("mmu_040:enable_paging\n")); @@ -137,6 +161,10 @@ // thanks to transparent translation index = VADDR_TO_PRENT(virtualAddress); + if (pr[index].type != DT_ROOT) + panic("invalid page root entry %d\n", index); +#if 0 + // not needed anymore if (pr[index].type != DT_ROOT) { unsigned aindex = index & ~(NUM_DIRTBL_PER_PAGE-1); /* aligned */ //TRACE(("missing page root entry %d ai %d\n", index, aindex)); @@ -157,6 +185,7 @@ tbl += SIZ_DIRTBL; } } +#endif pd = (page_directory_entry *)PRE_TO_TA(pr[index]); index = VADDR_TO_PDENT(virtualAddress); @@ -290,6 +319,7 @@ &initialize, &set_tt, &load_rp, + &allocate_kernel_pgdirs, &enable_paging, &add_page_table, &unmap_page, From axeld at mail.berlios.de Fri Aug 1 19:58:04 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 1 Aug 2008 19:58:04 +0200 Subject: [Haiku-commits] r26722 - haiku/trunk/src/system/libroot/posix/stdlib Message-ID: <200808011758.m71Hw4qr029307@sheep.berlios.de> Author: axeld Date: 2008-08-01 19:58:04 +0200 (Fri, 01 Aug 2008) New Revision: 26722 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26722&view=rev Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c Log: * clearenv() did not return anything, but should have returned 0 for success. * sCopied wasn't needed anymore due to the sManagedEnviron variable. * Minor cleanup, added a description to copy_environ_to_heap_if_needed(). Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 16:01:02 UTC (rev 26721) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-01 17:58:04 UTC (rev 26722) @@ -26,7 +26,6 @@ // TODO: Use benaphore! static sem_id sEnvLock; static char **sManagedEnviron; -static bool sCopied; char **environ = NULL; @@ -82,14 +81,14 @@ add_variable(void) { int32 count = count_variables() + 1; - char **newEnv = realloc(environ, (count + 1) * sizeof(char *)); - if (newEnv == NULL) + char **newEnviron = realloc(environ, (count + 1) * sizeof(char *)); + if (newEnviron == NULL) return B_NO_MEMORY; - newEnv[count] = NULL; + newEnviron[count] = NULL; // null terminate the array - environ = sManagedEnviron = newEnv; + environ = sManagedEnviron = newEnviron; return count - 1; } @@ -115,12 +114,20 @@ } +/*! Copies the environment from its current location into a heap managed + environment, if it's not already there. + + This is needed whenever the environment is changed, that is, when one + of the POSIX *env() functions is called, and we either used the environment + provided by the kernel, or by an application that changed \c environ + directly. +*/ static status_t copy_environ_to_heap_if_needed(void) { int32 i = 0; - if (sCopied && environ == sManagedEnviron) + if (environ == sManagedEnviron) return B_OK; if (sManagedEnviron != NULL) { @@ -143,7 +150,6 @@ // null terminate the array environ = sManagedEnviron; - sCopied = true; return B_OK; } @@ -222,6 +228,8 @@ environ = NULL; unlock_variables(); + + return 0; } From ingo_weinhold at gmx.de Fri Aug 1 23:09:18 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Fri, 01 Aug 2008 23:09:18 +0200 Subject: [Haiku-commits] r26706 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <4748130433-BeMail@laptop> References: <4748130433-BeMail@laptop> Message-ID: <20080801230918.462.1@knochen-vm.localdomain> On 2008-08-01 at 01:26:38 [+0200], Fran?ois Revol wrote: > > > > On 2008-07-31 at 23:22:58 [+0200], Fran?ois Revol > > wrote: > > > > Log: > > > > * Removed no longer needed IOCTL_FILE_UNCACHED_IO definition. > > > > > > Don't we have O_SYNC open flag anyway to specify this in a more > > > standard manner ? > > > > We have, it's just not supported. :-) We also have a yet unsupported > > O_NOCACHE, which we need quite soon for the swap file support. > > There is also O_DIRECT and O_DSYNC but I'm not sure I'm awake enough to > see the difference to all of them. I'm not sure where O_NOCACHE comes from, but O_DIRECT (used by Linux, FreeBSD, OpenSolaris) is the same thing. If I understand it correctly, O_DSYNC only causes the file data to be synced, while O_SYNC would additionally sync the metadata (analogously to fdatasync() vs. fsync()). CU, Ingo From axeld at pinc-software.de Fri Aug 1 23:10:47 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 01 Aug 2008 23:10:47 +0200 CEST Subject: [Haiku-commits] r26715 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <20080801172657.487.1@knochen-vm.localdomain> Message-ID: <50649257518-BeMail@zon> Ingo Weinhold wrote: > On 2008-08-01 at 14:28:30 [+0200], axeld at BerliOS < > axeld at mail.berlios.de> > wrote: > > - locker.Lock(); > > + // TODO: we actually need to call WriteLockInTransaction() > > here, but we > > + // cannot do this with the current locking model (ie. file > > cache > > functions > > + // are not to be called with the inode lock held). > > + // But this cannot work anyway, since we hold the lock when > > calling > > + // file_cache_set_size(), too... (possible deadlock) > > + rw_lock_write_lock(&fLock); > I don't think the VFS/VM locking is to blame here. At least I can't > see how > to change it to avoid this problem. What could help is a different > locking/transaction model in the BFS implementation. Changes in a > transaction > could be invisible to others until committed. I.e. in this case the > file's > size would be changed, but a reader could still access the file at > the same While this might help, I don't really see how we can make this a requirement for file system implementations. Furthermore, the file cache itself needs to be transaction aware as well in the future, and this wouldn't really simplify the matter. The only actual problem is the page writer, of course, as this one doesn't go through the file system to write a page, but its cache directly. Therefore, it locks the cache first, and the file system must still be able to perform additional locking to prevent changes to the disk structure. If BFS could lock the cache when doing changes to the inode, maybe we can get around the requirement of any additional locking in the I/O functions. Holding the cache lock would then be very similar to holding the read lock - it prevents changes unless you have already write locked the inode. This would also mean that we provide VMCache methods that require the caller to lock the cache. Does this sound like a possible solution? > time and would see the file with the old size. Another writer could > also > write in parallel, unless it would cause the file to be resized as > well. I > don't know how well the BFS structures allow to implement it this way > though. We would need to change the block cache to be able to use a different visibility models, but BFS would need to remember the last transaction for read access as well. When I wrote the block cache and designed its API, I stayed away from this, as this would require a lot of changes in BFS in the read path. I wanted to review that stuff once the file cache supported transactions as well. I think it would be best if the block and file caches would support different models to be chosen by the file system. Bye, Axel. From mmu_man at mail.berlios.de Sat Aug 2 02:31:21 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 2 Aug 2008 02:31:21 +0200 Subject: [Haiku-commits] r26723 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200808020031.m720VLNF022731@sheep.berlios.de> Author: mmu_man Date: 2008-08-02 02:31:19 +0200 (Sat, 02 Aug 2008) New Revision: 26723 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26723&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp Log: cleanup Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp 2008-08-01 17:58:04 UTC (rev 26722) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_cpu.cpp 2008-08-02 00:31:19 UTC (rev 26723) @@ -65,40 +65,16 @@ case 68020: case 68030: memcpy(&cpu_ops, &cpu_ops_030, sizeof(cpu_ops)); - /* - cpu_ops.flush_insn_pipeline = cpu_ops_030.flush_insn_pipeline; - cpu_ops.flush_atc_all = cpu_ops_030.flush_atc_all; - cpu_ops.flush_atc_user = cpu_ops_030.flush_atc_user; - cpu_ops.flush_atc_addr = cpu_ops_030.flush_atc_addr; - cpu_ops.flush_dcache = cpu_ops_030.flush_dcache; - cpu_ops.flush_icache = cpu_ops_030.flush_icache; - cpu_ops.idle = cpu_ops_030.idle; // NULL - */ break; -//#ifdef SUPPORTS_040 + case 68040: - memcpy(&cpu_ops, &cpu_ops_030, sizeof(cpu_ops)); - /* - cpu_ops.flush_insn_pipeline = cpu_ops_040.flush_insn_pipeline; - cpu_ops.flush_atc_all = cpu_ops_040.flush_atc_all; - cpu_ops.flush_atc_user = cpu_ops_040.flush_atc_user; - cpu_ops.flush_atc_addr = cpu_ops_040.flush_atc_addr; - cpu_ops.flush_dcache = cpu_ops_040.flush_dcache; - cpu_ops.flush_icache = cpu_ops_040.flush_icache; - cpu_ops.idle = cpu_ops_040.idle; // NULL - */ + memcpy(&cpu_ops, &cpu_ops_040, sizeof(cpu_ops)); break; -//#endif + #ifdef SUPPORTS_060 case 68060: - cpu_ops.flush_insn_pipeline = cpu_ops_060.flush_insn_pipeline; - cpu_ops.flush_atc_all = cpu_ops_060.flush_atc_all; - cpu_ops.flush_atc_user = cpu_ops_060.flush_atc_user; - cpu_ops.flush_atc_addr = cpu_ops_060.flush_atc_addr; - cpu_ops.flush_dcache = cpu_ops_060.flush_dcache; - cpu_ops.flush_icache = cpu_ops_060.flush_icache; - cpu_ops.idle = cpu_ops_060.idle; - break; + memcpy(&cpu_ops, &cpu_ops_060, sizeof(cpu_ops)); + break; #endif default: panic("unknown cpu_type %d\n", arch_cpu_type); @@ -132,7 +108,7 @@ arch_cpu_memory_read_barrier(void) { asm volatile ("nop;" : : : "memory"); -#warning M68k: check arch_cpu_memory_read_barrier +#warning M68k: check arch_cpu_memory_read_barrier (FNOP ?) } @@ -140,7 +116,7 @@ arch_cpu_memory_write_barrier(void) { asm volatile ("nop;" : : : "memory"); -#warning M68k: check arch_cpu_memory_write_barrier +#warning M68k: check arch_cpu_memory_write_barrier (FNOP ?) } From mmu_man at mail.berlios.de Sat Aug 2 02:34:41 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 2 Aug 2008 02:34:41 +0200 Subject: [Haiku-commits] r26724 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200808020034.m720YfJA023358@sheep.berlios.de> Author: mmu_man Date: 2008-08-02 02:34:40 +0200 (Sat, 02 Aug 2008) New Revision: 26724 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26724&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_exceptions.S Log: - don't movem a7, it's the stack pointer. the cpu saves it for us before processing exceptions. - push the address of the iframe before calling the C handler. Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_exceptions.S =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_exceptions.S 2008-08-02 00:31:19 UTC (rev 26723) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_exceptions.S 2008-08-02 00:34:40 UTC (rev 26724) @@ -94,7 +94,7 @@ FUNCTION(__m68k_exception_common): /* save regs */ - movem.l %d0-%d7/%a0-%a7,-(%sp) /* push the iframe address */ + movem.l %d0-%d7/%a0-%a6,-(%sp) /* push the iframe address */ /* save fp */ sub.l #FPU_STATE_sizeof,%sp fsave (%sp) @@ -108,7 +108,9 @@ sub.l #IFRAME_fpu-IFRAME_fp,%sp null_sav_2: - bsr m68k_exception_entry /* call C entry */ + move.l %sp,-(%sp) /* push address of iframe */ + bsr m68k_exception_entry /* call C entry */ + add.l #4,%sp /* restore fp */ tst.b IFRAME_fpu-IFRAME_fp(%sp) /* check for a null state */ @@ -123,7 +125,7 @@ frestore (%sp) add.l #FPU_STATE_sizeof,%sp /* restore regs */ - movem.l (%sp)+,%d0-%d7/%a0-%a7 + movem.l (%sp)+,%d0-%d7/%a0-%a6 rte From mmu_man at mail.berlios.de Sat Aug 2 02:36:35 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 2 Aug 2008 02:36:35 +0200 Subject: [Haiku-commits] r26725 - in haiku/trunk: headers/private/kernel/arch/m68k src/system/kernel/arch/m68k src/system/kernel/platform/atari_m68k Message-ID: <200808020036.m720aZms023392@sheep.berlios.de> Author: mmu_man Date: 2008-08-02 02:36:33 +0200 (Sat, 02 Aug 2008) New Revision: 26725 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26725&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp Log: Use a bool to check if an irq was acknowledged by the MFP, else we don't call the handler. Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h 2008-08-02 00:34:40 UTC (rev 26724) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h 2008-08-02 00:36:33 UTC (rev 26725) @@ -44,7 +44,7 @@ virtual void EnableIOInterrupt(int irq) = 0; virtual void DisableIOInterrupt(int irq) = 0; - virtual void AcknowledgeIOInterrupt(int irq) = 0; + virtual bool AcknowledgeIOInterrupt(int irq) = 0; virtual void SetHardwareRTC(uint32 seconds) = 0; virtual uint32 GetHardwareRTC() = 0; Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp 2008-08-02 00:34:40 UTC (rev 26724) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_int.cpp 2008-08-02 00:36:33 UTC (rev 26725) @@ -272,9 +272,10 @@ default: // vectors >= 64 are user defined vectors, used for IRQ if (vector >= 64) { - M68KPlatform::Default()->AcknowledgeIOInterrupt(vector); - ret = int_io_interrupt_handler(vector, true); - break; + if (M68KPlatform::Default()->AcknowledgeIOInterrupt(vector)) { + ret = int_io_interrupt_handler(vector, true); + break; + } } dprintf("unhandled exception type 0x%x\n", vector); print_iframe(iframe); Modified: haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp =================================================================== --- haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-02 00:34:40 UTC (rev 26724) +++ haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-02 00:36:33 UTC (rev 26725) @@ -47,7 +47,7 @@ void EnableIOInterrupt(int irq); void DisableIOInterrupt(int irq); - void AcknowledgeIOInterrupt(int irq); + bool AcknowledgeIOInterrupt(int irq); private: uint32 fBase; @@ -70,7 +70,7 @@ virtual void EnableIOInterrupt(int irq); virtual void DisableIOInterrupt(int irq); - virtual void AcknowledgeIOInterrupt(int irq); + virtual bool AcknowledgeIOInterrupt(int irq); virtual void SetHardwareRTC(uint32 seconds); virtual uint32 GetHardwareRTC(); @@ -148,7 +148,7 @@ } -void +bool M68KAtari::MFP::AcknowledgeIOInterrupt(int irq) { uint8 bit = 1 << (irq % 8); @@ -158,7 +158,9 @@ if (val & bit) { val &= ~bit; outb(reg, val); + return true; } + return false; } @@ -303,13 +305,14 @@ } -void +bool M68KAtari::AcknowledgeIOInterrupt(int irq) { MFP *mfp = MFPForIrq(irq); if (mfp) - mfp->AcknowledgeIOInterrupt(irq - mfp->Vector()); + return mfp->AcknowledgeIOInterrupt(irq - mfp->Vector()); + return false; } void From mmu_man at mail.berlios.de Sat Aug 2 02:39:34 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 2 Aug 2008 02:39:34 +0200 Subject: [Haiku-commits] r26726 - in haiku/trunk/src/system: boot/platform/atari_m68k kernel/arch/m68k Message-ID: <200808020039.m720dYmf023537@sheep.berlios.de> Author: mmu_man Date: 2008-08-02 02:39:31 +0200 (Sat, 02 Aug 2008) New Revision: 26726 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26726&view=rev Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_vm.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp Log: - fix early_map - iospace should now be initialized correctly, at least the kernel goes much further. Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-02 00:36:33 UTC (rev 26725) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-02 00:39:31 UTC (rev 26726) @@ -513,6 +513,7 @@ TRACE(("gdt at virtual address %p\n", (void *)gKernelArgs.arch_args.vir_gdt)); } +#endif // save the memory we've physically allocated gKernelArgs.physical_allocated_range[0].size = sNextPhysicalAddress - gKernelArgs.physical_allocated_range[0].start; @@ -547,7 +548,6 @@ } } #endif -#endif } Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_vm.cpp 2008-08-02 00:36:33 UTC (rev 26725) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm.cpp 2008-08-02 00:39:31 UTC (rev 26726) @@ -90,6 +90,7 @@ vm_free_unused_boot_loader_range(0, 0xffffffff - B_PAGE_SIZE + 1); #endif +#warning M68K: unset TT0 now return B_OK; } Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-02 00:36:33 UTC (rev 26725) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-02 00:39:31 UTC (rev 26726) @@ -65,13 +65,10 @@ # define TRACE(x) ; #endif -//XXX: that's platform specific! -// 14 MB of iospace -#define IOSPACE_SIZE (14*1024*1024) -// 4 MB chunks, to optimize for 4 MB pages -// XXX: no such thing on 68k (060 ?) -// 256K -#define IOSPACE_CHUNK_SIZE (256*1024) +// 4 MB of iospace +#define IOSPACE_SIZE (4*1024*1024) +// 256K = 2^6*4K +#define IOSPACE_CHUNK_SIZE (NUM_PAGEENT_PER_TBL*B_PAGE_SIZE) static page_table_entry *iospace_pgtables = NULL; @@ -199,6 +196,7 @@ } +#warning M68K: allocate all kernel pgdirs at boot and remove this (also dont remove them anymore from unmap) static void _update_all_pgdirs(int index, page_root_entry e) { @@ -1066,12 +1064,13 @@ panic("map_iospace_chunk: passed invalid va 0x%lx\n", va); pt = &iospace_pgtables[(va - sIOSpaceBase) / B_PAGE_SIZE]; - for (i = 0; i < 1024; i++, pa += B_PAGE_SIZE) { + for (i = 0; i < NUM_PAGEENT_PER_TBL; i++, pa += B_PAGE_SIZE) { init_page_table_entry(&pt[i]); pt[i].addr = TA_TO_PTEA(pa); pt[i].supervisor = 1; pt[i].write_protect = 0; pt[i].type = DT_PAGE; + //XXX: not cachable ? // 040 or 060 only #ifdef MMU_HAS_GLOBAL_PAGES pt[i].global = 1; @@ -1223,7 +1222,9 @@ // allocate some space to hold physical page mapping info //XXX: check page count -#warning M68K: XXXXXXXXXXXX pt + pd? pd = memalign ? + // we already have all page directories allocated by the bootloader, + // we only need page tables + iospace_pgtables = (page_table_entry *)vm_allocate_early(args, B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * NUM_PAGEENT_PER_TBL * NUM_PAGETBL_PER_PAGE)), ~0L, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); @@ -1237,28 +1238,38 @@ return error; // initialize our data structures - memset(iospace_pgtables, 0, B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * 1024))); + memset(iospace_pgtables, 0, B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * NUM_PAGEENT_PER_TBL * NUM_PAGETBL_PER_PAGE))); TRACE(("mapping iospace_pgtables\n")); -#if 0 // put the array of pgtables directly into the kernel pagedir - // these will be wired and kept mapped into virtual space to be easy to get to + // these will be wired and kept mapped into virtual space to be + // easy to get to. + // note the bootloader allocates all page directories for us + // as a contiguous block. + // we also still have transparent translation enabled, va==pa. { -#warning M68K: XXXXXXXXXXXX addr_t phys_pgtable; addr_t virt_pgtable; + page_root_entry *pr = sKernelVirtualPageRoot; + page_directory_entry *pd; page_directory_entry *e; + int index; int i; virt_pgtable = (addr_t)iospace_pgtables; - for (i = 0; i < (IOSPACE_SIZE / (B_PAGE_SIZE * 1024)); i++, virt_pgtable += B_PAGE_SIZE) { + + for (i = 0; i < (IOSPACE_SIZE / (B_PAGE_SIZE * NUM_PAGEENT_PER_TBL)); + i++, virt_pgtable += SIZ_PAGETBL) { + // early_query handles non-page-aligned addresses early_query(virt_pgtable, &phys_pgtable); - e = &page_hole_pgdir[(sIOSpaceBase / (B_PAGE_SIZE * 1024)) + i]; - put_pgtable_in_pgdir(e, phys_pgtable, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + index = VADDR_TO_PRENT(sIOSpaceBase) + i / NUM_DIRENT_PER_TBL; + pd = (page_directory_entry *)PRE_TO_TA(pr[index]); + e = &pd[VADDR_TO_PRENT(sIOSpaceBase) + i % NUM_DIRENT_PER_TBL]; + put_pgtable_in_pgdir(e, phys_pgtable, + B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); } } -#endif TRACE(("vm_translation_map_init: done\n")); @@ -1387,6 +1398,8 @@ } +// almost directly taken from boot mmu code +// x86: // XXX horrible back door to map a page quickly regardless of translation map object, etc. // used only during VM setup. // uses a 'page hole' set up in the stage 2 bootloader. The page hole is created by pointing one of @@ -1397,32 +1410,66 @@ m68k_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa, uint8 attributes, addr_t (*get_free_page)(kernel_args *)) { - int index; - + page_root_entry *pr = (page_root_entry *)sKernelPhysicalPageRoot; + page_directory_entry *pd; + page_table_entry *pt; + addr_t tbl; + uint32 index; + uint32 i; TRACE(("early_tmap: entry pa 0x%lx va 0x%lx\n", pa, va)); + + // everything much simpler here because pa = va + // thanks to transparent translation which hasn't been disabled yet - // check to see if a page table exists for this range + index = VADDR_TO_PRENT(va); + if (pr[index].type != DT_ROOT) { + unsigned aindex = index & ~(NUM_DIRTBL_PER_PAGE-1); /* aligned */ + //TRACE(("missing page root entry %d ai %d\n", index, aindex)); + tbl = get_free_page(args) * B_PAGE_SIZE; + if (!tbl) + return ENOMEM; + TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", tbl)); + // zero-out + memset((void *)tbl, 0, B_PAGE_SIZE); + // for each pgdir on the allocated page: + for (i = 0; i < NUM_DIRTBL_PER_PAGE; i++) { + put_pgdir_in_pgroot(&pr[aindex + i], tbl, attributes); + //TRACE(("inserting tbl @ %p as %08x pr[%d] %08x\n", tbl, TA_TO_PREA(tbl), aindex + i, *(uint32 *)apr)); + // clear the table + //TRACE(("clearing table[%d]\n", i)); + pd = (page_directory_entry *)tbl; + for (int32 j = 0; j < NUM_DIRENT_PER_TBL; j++) + *(page_directory_entry_scalar *)(&pd[j]) = DFL_DIRENT_VAL; + tbl += SIZ_DIRTBL; + } + } + pd = (page_directory_entry *)PRE_TO_TA(pr[index]); + index = VADDR_TO_PDENT(va); - if (page_hole_pgdir[index].type == DT_PAGE) { - addr_t pgtable; - page_directory_entry *e; - // we need to allocate a pgtable - pgtable = get_free_page(args); - // pgtable is in pages, convert to physical address - pgtable *= B_PAGE_SIZE; - - TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", pgtable)); - - // put it in the pgdir - e = &page_hole_pgdir[index]; - put_pgtable_in_pgdir(e, pgtable, attributes); - - // zero it out in it's new mapping - memset((unsigned int *)((unsigned int)page_hole + (va / B_PAGE_SIZE / 1024) * B_PAGE_SIZE), 0, B_PAGE_SIZE); + if (pd[index].type != DT_DIR) { + unsigned aindex = index & ~(NUM_PAGETBL_PER_PAGE-1); /* aligned */ + //TRACE(("missing page dir entry %d ai %d\n", index, aindex)); + tbl = get_free_page(args) * B_PAGE_SIZE; + if (!tbl) + return ENOMEM; + TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", tbl)); + // zero-out + memset((void *)tbl, 0, B_PAGE_SIZE); + // for each pgdir on the allocated page: + for (i = 0; i < NUM_PAGETBL_PER_PAGE; i++) { + put_pgtable_in_pgdir(&pd[aindex + i], tbl, attributes); + // clear the table + //TRACE(("clearing table[%d]\n", i)); + pt = (page_table_entry *)tbl; + for (int32 j = 0; j < NUM_PAGEENT_PER_TBL; j++) + *(page_table_entry_scalar *)(&pt[j]) = DFL_PAGEENT_VAL; + tbl += SIZ_PAGETBL; + } } + pt = (page_table_entry *)PDE_TO_TA(pd[index]); - // now, fill in the pentry - put_page_table_entry_in_pgtable(page_hole + va / B_PAGE_SIZE, pa, attributes, + index = VADDR_TO_PTENT(va); + put_page_table_entry_in_pgtable(&pt[index], pa, attributes, IS_KERNEL_ADDRESS(va)); arch_cpu_invalidate_TLB_range(va, va); From sbenedetto at mail.berlios.de Sat Aug 2 13:30:56 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 2 Aug 2008 13:30:56 +0200 Subject: [Haiku-commits] r26727 - in haiku/trunk: headers/private/kernel/posix headers/private/system/posix src/system/kernel/posix src/system/libroot/posix/sys Message-ID: <200808021130.m72BUuFm025671@sheep.berlios.de> Author: sbenedetto Date: 2008-08-02 13:30:55 +0200 (Sat, 02 Aug 2008) New Revision: 26727 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26727&view=rev Added: haiku/trunk/headers/private/system/posix/xsi_semaphore_defs.h Modified: haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp haiku/trunk/src/system/libroot/posix/sys/xsi_sem.cpp Log: - Fixed warnings - Fixed deadlock in xsi_sem_undo - RecordUndo - Fixed issue in xsi_sem_undo: if the semaphore set does not exist anymore, ignore the request but do remove the process from the sUndoList, which wasn't previously done. - free() in ClearUndos was called with interrupts disabled - when a semaphore set ends to exist, remove all it's sem_undo request as it's ID will be reused in the future. Modified: haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h =================================================================== --- haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h 2008-08-02 00:39:31 UTC (rev 26726) +++ haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h 2008-08-02 11:30:55 UTC (rev 26727) @@ -11,17 +11,9 @@ #include #include +#include -// TODO: move into a system/posix/xsi_semaphore_defs.h file to be shared with -// xsi_sem.cpp in libroot! -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; -}; - - __BEGIN_DECLS extern void xsi_ipc_init(); Added: haiku/trunk/headers/private/system/posix/xsi_semaphore_defs.h =================================================================== --- haiku/trunk/headers/private/system/posix/xsi_semaphore_defs.h 2008-08-02 00:39:31 UTC (rev 26726) +++ haiku/trunk/headers/private/system/posix/xsi_semaphore_defs.h 2008-08-02 11:30:55 UTC (rev 26727) @@ -0,0 +1,18 @@ +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com. + * Distributed under the terms of the MIT License. + */ +#ifndef SYSTEM_XSI_SEM_H +#define SYSTEM_XSI_SEM_H + +/* + * Shared union used by the semctl option argument. + * The user should declare it explicitly + */ +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; +}; + +#endif Modified: haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-02 00:39:31 UTC (rev 26726) +++ haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-02 11:30:55 UTC (rev 26727) @@ -133,7 +133,7 @@ int RecordUndo(int semaphoreSetID, short semaphoreNumber, short value); // Implemented after sUndoListLock is declared - int RemoveUndo(int semaphoreSetID, short semaphoreNumber, short value); + void RemoveUndo(int semaphoreSetID, short semaphoreNumber, short value); void Revert(short value) { @@ -256,6 +256,10 @@ ~XsiSemaphoreSet() { + // Clear all sem_undo left, as our ID will be reused + // by another set. + for (uint32 i = 0; i < fNumberOfSemaphores; i++) + fSemaphores[i].ClearUndos(fID, i); UnsetID(); delete []fSemaphores; } @@ -493,16 +497,20 @@ // the global undo list, plus decrementing the related // team xsi_sem_undo_requests field. // This happens only on semctl SETVAL and SETALL. + TRACE(("XsiSemaphore::ClearUndos: semaphoreSetID = %d, " + "semaphoreNumber = %d\n", semaphoreSetID, semaphoreNumber)); MutexLocker _(sUndoListLock); DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); if (current->semaphore_set_id == semaphoreSetID && current->semaphore_number == semaphoreNumber) { - InterruptsSpinLocker _(team_spinlock); + InterruptsSpinLocker lock(team_spinlock); if (current->team) current->team->xsi_sem_undo_requests--; iterator.Remove(); + // Restore interrupts before calling free + lock.Unlock(); free(current); } } @@ -526,7 +534,8 @@ // Update its undo value TRACE(("XsiSemaphore::RecordUndo: found record. Team = %d, " "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", - team->id, semaphoreSetID, semaphoreNumber, current->undo_value)); + (int)team->id, semaphoreSetID, semaphoreNumber, + current->undo_value)); int newValue = current->undo_value + value; if (newValue > USHRT_MAX || newValue < -USHRT_MAX) { TRACE_ERROR(("XsiSemaphore::RecordUndo: newValue %d out of range\n", @@ -559,13 +568,14 @@ sUndoList.Add(request); TRACE(("XsiSemaphore::RecordUndo: new record added. Team = %d, " "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", - team->id, semaphoreSetID, semaphoreNumber, request->undo_value)); + (int)team->id, semaphoreSetID, semaphoreNumber, + request->undo_value)); } return B_OK; } -int +void XsiSemaphore::RemoveUndo(int semaphoreSetID, short semaphoreNumber, short value) { // This can be called only when RecordUndo fails. @@ -643,6 +653,9 @@ if (numberOfUndos <= 0) return; + // We must hold the set mutex before the sem_undo + // one in order to avoid deadlock with RecordUndo + MutexLocker lock(sXsiSemaphoreSetLock); MutexLocker _(sUndoListLock); DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); // Look for all sem_undo request from this team @@ -651,21 +664,21 @@ if (current->team->id == teamID) { // Check whether the semaphore set still exist int semaphoreSetID = current->semaphore_set_id; - MutexLocker _(sXsiSemaphoreSetLock); XsiSemaphoreSet *semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreSetID); - if (semaphoreSet == NULL) { + if (semaphoreSet != NULL) { + // Revert the changes done by this process + XsiSemaphore *semaphore + = semaphoreSet->Semaphore(current->semaphore_number); + TRACE(("xsi_do_undo: TeamID = %d, SemaphoreSetID = %d, " + "SemaphoreNumber = %d, undo value = %d\n", (int)teamID, + semaphoreSetID, current->semaphore_number, + current->undo_value)); + semaphore->Revert(current->undo_value); + } else TRACE(("xsi_do_undo: semaphore set %d does not exist " "anymore. Ignore record.\n", semaphoreSetID)); - continue; - } - // Revert the changes done by this process - XsiSemaphore *semaphore - = semaphoreSet->Semaphore(current->semaphore_number); - TRACE(("xsi_do_undo: TeamID = %d, SemaphoreSetID = %d, " - "SemaphoreNumber = %d, undo value = %d\n", teamID, - semaphoreSetID, current->semaphore_number, current->undo_value)); - semaphore->Revert(current->undo_value); + // Remove and free the sem_undo structure from sUndoList iterator.Remove(); free(current); @@ -976,7 +989,7 @@ status_t _user_xsi_semop(int semaphoreID, struct sembuf *ops, size_t numOps) { - TRACE(("xsi_semop: semaphoreID = %d, ops = %p, numOps = %d\n", + TRACE(("xsi_semop: semaphoreID = %d, ops = %p, numOps = %ld\n", semaphoreID, ops, numOps)); MutexLocker lock(sXsiSemaphoreSetLock); XsiSemaphoreSet *semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreID); @@ -1021,14 +1034,13 @@ while (notDone) { XsiSemaphore *semaphore = NULL; short numberOfSemaphores = semaphoreSet->NumberOfSemaphores(); - // TODO: Perhaps lock the set itself? bool goToSleep = false; uint32 i = 0; for (; i < numOps; i++) { short semaphoreNumber = operations[i].sem_num; if (semaphoreNumber >= numberOfSemaphores) { - TRACE_ERROR(("xsi_semop: %d invalid semaphore number\n", i)); + TRACE_ERROR(("xsi_semop: %ld invalid semaphore number\n", i)); result = EINVAL; break; } @@ -1100,12 +1112,10 @@ // We acquired the semaphore, now records the sem_undo // requests XsiSemaphore *semaphore = NULL; - short numberOfSemaphores = semaphoreSet->NumberOfSemaphores(); uint32 i = 0; for (; i < numOps; i++) { short semaphoreNumber = operations[i].sem_num; semaphore = semaphoreSet->Semaphore(semaphoreNumber); - unsigned short value = semaphore->Value(); short operation = operations[i].sem_op; if (operations[i].sem_flg & SEM_UNDO) if (semaphore->RecordUndo(semaphoreSet->ID(), @@ -1129,7 +1139,8 @@ result = ENOSPC; } } - // TODO: Also set last PID for this semaphore set + // We did it. Set the pid. + semaphore->SetPid(getpid()); } } return result; Modified: haiku/trunk/src/system/libroot/posix/sys/xsi_sem.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/xsi_sem.cpp 2008-08-02 00:39:31 UTC (rev 26726) +++ haiku/trunk/src/system/libroot/posix/sys/xsi_sem.cpp 2008-08-02 11:30:55 UTC (rev 26727) @@ -15,22 +15,10 @@ #include -//#include +#include #include #include -// TODO: this should be removed when the above commented header exists -#if 1 -/* - * For the semctl option argument, the user - * should declare explicitly the following union - */ -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; -}; -#endif int semget(key_t key, int numSems, int semFlags) From axeld at mail.berlios.de Sat Aug 2 16:06:41 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 16:06:41 +0200 Subject: [Haiku-commits] r26728 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808021406.m72E6fkO019467@sheep.berlios.de> Author: axeld Date: 2008-08-02 16:06:38 +0200 (Sat, 02 Aug 2008) New Revision: 26728 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26728&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/BlockAllocator.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Index.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Utility.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Utility.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * Coding style cleanups, no functional changes. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-02 11:30:55 UTC (rev 26727) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2008-08-02 14:06:38 UTC (rev 26728) @@ -10,13 +10,14 @@ // TODO: clean this up, find a better separation between Inode and this class -// TODO: even after Create(), the attribute cannot be stat() for until the first write +// TODO: even after Create(), the attribute cannot be stat() for until the +// first write -extern void fill_stat_buffer(Inode *inode, struct stat &stat); +extern void fill_stat_buffer(Inode* inode, struct stat& stat); -Attribute::Attribute(Inode *inode) +Attribute::Attribute(Inode* inode) : fNodeGetter(inode->GetVolume()), fInode(inode), @@ -27,7 +28,7 @@ } -Attribute::Attribute(Inode *inode, attr_cookie *cookie) +Attribute::Attribute(Inode* inode, attr_cookie* cookie) : fNodeGetter(inode->GetVolume()), fInode(inode), @@ -53,7 +54,7 @@ status_t -Attribute::CheckAccess(const char *name, int openMode) +Attribute::CheckAccess(const char* name, int openMode) { // Opening the name attribute using this function is not allowed, // also using the reserved indices name, last_modified, and size @@ -73,7 +74,7 @@ status_t -Attribute::Get(const char *name) +Attribute::Get(const char* name) { Put(); @@ -82,7 +83,7 @@ // try to find it in the small data region if (recursive_lock_lock(&fInode->SmallDataLock()) == B_OK) { fNodeGetter.SetToNode(fInode); - fSmall = fInode->FindSmallData(fNodeGetter.Node(), (const char *)name); + fSmall = fInode->FindSmallData(fNodeGetter.Node(), (const char*)name); if (fSmall != NULL) return B_OK; @@ -112,14 +113,14 @@ status_t -Attribute::Create(const char *name, type_code type, int openMode, - attr_cookie **_cookie) +Attribute::Create(const char* name, type_code type, int openMode, + attr_cookie** _cookie) { status_t status = CheckAccess(name, openMode); if (status < B_OK) return status; - attr_cookie *cookie = new(std::nothrow) attr_cookie; + attr_cookie* cookie = new(std::nothrow) attr_cookie; if (cookie == NULL) RETURN_ERROR(B_NO_MEMORY); @@ -142,7 +143,7 @@ status_t -Attribute::Open(const char *name, int openMode, attr_cookie **_cookie) +Attribute::Open(const char* name, int openMode, attr_cookie** _cookie) { status_t status = CheckAccess(name, openMode); if (status < B_OK) @@ -152,7 +153,7 @@ if (status < B_OK) return status; - attr_cookie *cookie = new(std::nothrow) attr_cookie; + attr_cookie* cookie = new(std::nothrow) attr_cookie; if (cookie == NULL) RETURN_ERROR(B_NO_MEMORY); @@ -171,7 +172,7 @@ status_t -Attribute::Stat(struct stat &stat) +Attribute::Stat(struct stat& stat) { if (fSmall == NULL && fAttribute == NULL) return B_NO_INIT; @@ -192,7 +193,7 @@ status_t -Attribute::Read(attr_cookie *cookie, off_t pos, uint8 *buffer, size_t *_length) +Attribute::Read(attr_cookie* cookie, off_t pos, uint8* buffer, size_t* _length) { if (fSmall == NULL && fAttribute == NULL) return B_NO_INIT; @@ -203,8 +204,8 @@ status_t -Attribute::Write(Transaction &transaction, attr_cookie *cookie, - off_t pos, const uint8 *buffer, size_t *_length) +Attribute::Write(Transaction& transaction, attr_cookie* cookie, off_t pos, + const uint8* buffer, size_t* _length) { if (!cookie->create && fSmall == NULL && fAttribute == NULL) return B_NO_INIT; Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.h 2008-08-02 11:30:55 UTC (rev 26727) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.h 2008-08-02 14:06:38 UTC (rev 26728) @@ -1,6 +1,5 @@ -/* Attribute - connection between pure inode and kernel_interface attributes - * - * Copyright 2004, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef ATTRIBUTE_H @@ -19,35 +18,38 @@ class Attribute { - public: - Attribute(Inode *inode); - Attribute(Inode *inode, attr_cookie *cookie); - ~Attribute(); +public: + Attribute(Inode* inode); + Attribute(Inode* inode, attr_cookie* cookie); + ~Attribute(); - status_t InitCheck(); - status_t CheckAccess(const char *name, int openMode); + status_t InitCheck(); + status_t CheckAccess(const char* name, int openMode); - status_t Get(const char *name); - void Put(); + status_t Get(const char* name); + void Put(); - status_t Create(const char *name, type_code type, int openMode, - attr_cookie **_cookie); - status_t Open(const char *name, int openMode, attr_cookie **_cookie); + status_t Create(const char* name, type_code type, + int openMode, attr_cookie** _cookie); + status_t Open(const char* name, int openMode, + attr_cookie** _cookie); - status_t Stat(struct stat &stat); + status_t Stat(struct stat& stat); - status_t Read(attr_cookie *cookie, off_t pos, uint8 *buffer, size_t *_length); - status_t Write(Transaction &transaction, attr_cookie *cookie, - off_t pos, const uint8 *buffer, size_t *_length); + status_t Read(attr_cookie* cookie, off_t pos, uint8* buffer, + size_t* _length); + status_t Write(Transaction& transaction, attr_cookie* cookie, + off_t pos, const uint8* buffer, + size_t* _length); - private: - status_t _Truncate(); +private: + status_t _Truncate(); - NodeGetter fNodeGetter; - Inode *fInode; - small_data *fSmall; - Inode *fAttribute; - const char *fName; + NodeGetter fNodeGetter; + Inode* fInode; + small_data* fSmall; + Inode* fAttribute; + const char* fName; }; -#endif /* ATTRIBUTE_H */ +#endif // ATTRIBUTE_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-02 11:30:55 UTC (rev 26727) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-02 14:06:38 UTC (rev 26728) @@ -17,32 +17,32 @@ #ifdef DEBUG class NodeChecker { - public: - NodeChecker(const bplustree_node *node, int32 nodeSize, const char *text) - : - fNode(node), - fSize(nodeSize), - fText(text) - { - Check("integrity check failed on construction."); - } +public: + NodeChecker(const bplustree_node* node, int32 nodeSize, const char* text) + : + fNode(node), + fSize(nodeSize), + fText(text) + { + Check("integrity check failed on construction."); + } - ~NodeChecker() - { - Check("integrity check failed on destruction."); - } + ~NodeChecker() + { + Check("integrity check failed on destruction."); + } - void - Check(const char *message) - { - if (fNode->CheckIntegrity(fSize) < B_OK) - dprintf("%s: %s\n", fText, message); - } + void + Check(const char* message) + { + if (fNode->CheckIntegrity(fSize) < B_OK) + dprintf("%s: %s\n", fText, message); + } - private: - const bplustree_node *fNode; - int32 fSize; - const char *fText; +private: + const bplustree_node* fNode; + int32 fSize; + const char* fText; }; #endif @@ -60,13 +60,13 @@ // is hard-coded to 1024 bytes, that's not an issue now. void -CachedNode::UnsetUnchanged(Transaction &transaction) +CachedNode::UnsetUnchanged(Transaction& transaction) { if (fTree == NULL || fTree->fStream == NULL) return; if (fNode != NULL) { - void *cache = fTree->fStream->GetVolume()->BlockCache(); + void* cache = fTree->fStream->GetVolume()->BlockCache(); block_cache_set_dirty(cache, fBlockNumber, false, transaction.ID()); block_cache_put(cache, fBlockNumber); @@ -82,13 +82,14 @@ return; if (fNode != NULL) { - block_cache_put(fTree->fStream->GetVolume()->BlockCache(), fBlockNumber); + block_cache_put(fTree->fStream->GetVolume()->BlockCache(), + fBlockNumber); fNode = NULL; } } -const bplustree_node * +const bplustree_node* CachedNode::SetTo(off_t offset, bool check) { if (fTree == NULL || fTree->fStream == NULL) { @@ -118,8 +119,8 @@ } -bplustree_node * -CachedNode::SetToWritable(Transaction &transaction, off_t offset, bool check) +bplustree_node* +CachedNode::SetToWritable(Transaction& transaction, off_t offset, bool check) { if (fTree == NULL || fTree->fStream == NULL) { REPORT_ERROR(B_BAD_VALUE); @@ -148,8 +149,8 @@ } -bplustree_node * -CachedNode::MakeWritable(Transaction &transaction) +bplustree_node* +CachedNode::MakeWritable(Transaction& transaction) { if (fNode == NULL) return NULL; @@ -162,14 +163,14 @@ } -bplustree_header * -CachedNode::MakeWritableHeader(Transaction &transaction) +bplustree_header* +CachedNode::MakeWritableHeader(Transaction& transaction) { - return (bplustree_header *)MakeWritable(transaction); + return (bplustree_header*)MakeWritable(transaction); } -const bplustree_header * +const bplustree_header* CachedNode::SetToHeader() { if (fTree == NULL || fTree->fStream == NULL) { @@ -180,12 +181,12 @@ Unset(); InternalSetTo(NULL, 0LL); - return (bplustree_header *)fNode; + return (bplustree_header*)fNode; } -bplustree_header * -CachedNode::SetToWritableHeader(Transaction &transaction) +bplustree_header* +CachedNode::SetToWritableHeader(Transaction& transaction) { if (fTree == NULL || fTree->fStream == NULL) { REPORT_ERROR(B_BAD_VALUE); @@ -195,12 +196,12 @@ Unset(); InternalSetTo(&transaction, 0LL); - return (bplustree_header *)fNode; + return (bplustree_header*)fNode; } -bplustree_node * -CachedNode::InternalSetTo(Transaction *transaction, off_t offset) +bplustree_node* +CachedNode::InternalSetTo(Transaction* transaction, off_t offset) { fNode = NULL; fOffset = offset; @@ -209,25 +210,26 @@ block_run run; if (offset < fTree->fStream->Size() && fTree->fStream->FindBlockRun(offset, run, fileOffset) == B_OK) { - Volume *volume = fTree->fStream->GetVolume(); + Volume* volume = fTree->fStream->GetVolume(); int32 blockOffset = (offset - fileOffset) / volume->BlockSize(); fBlockNumber = volume->ToBlock(run) + blockOffset; - uint8 *block; + uint8* block; if (transaction != NULL) { - block = (uint8 *)block_cache_get_writable(volume->BlockCache(), + block = (uint8*)block_cache_get_writable(volume->BlockCache(), fBlockNumber, transaction->ID()); fWritable = true; } else { - block = (uint8 *)block_cache_get(volume->BlockCache(), fBlockNumber); + block = (uint8*)block_cache_get(volume->BlockCache(), fBlockNumber); fWritable = false; } if (block) { - // the node is somewhere in that block... (confusing offset calculation) - fNode = (bplustree_node *)(block + offset - - (fileOffset + (blockOffset << volume->BlockShift()))); + // The node is somewhere in that block... + // (confusing offset calculation) + fNode = (bplustree_node*)(block + offset + - (fileOffset + (blockOffset << volume->BlockShift()))); } else REPORT_ERROR(B_IO_ERROR); } @@ -236,7 +238,7 @@ status_t -CachedNode::Free(Transaction &transaction, off_t offset) +CachedNode::Free(Transaction& transaction, off_t offset) { if (fTree == NULL || fTree->fStream == NULL || offset == BPLUSTREE_NULL) RETURN_ERROR(B_BAD_VALUE); @@ -246,7 +248,8 @@ // function is called, perhaps it should be done when the directory // inode is closed or based on some calculation or whatever... - bplustree_header *header = fTree->fCachedHeader.MakeWritableHeader(transaction); + bplustree_header* header + = fTree->fCachedHeader.MakeWritableHeader(transaction); if (header == NULL) return B_IO_ERROR; @@ -276,15 +279,15 @@ status_t -CachedNode::Allocate(Transaction &transaction, bplustree_node **_node, - off_t *_offset) +CachedNode::Allocate(Transaction& transaction, bplustree_node** _node, + off_t* _offset) { if (fTree == NULL || fTree->fHeader == NULL || fTree->fStream == NULL) RETURN_ERROR(B_BAD_VALUE); Unset(); - bplustree_header *header; + bplustree_header* header; status_t status; // if there are any free nodes, recycle them @@ -303,7 +306,7 @@ } // allocate space for a new node - Inode *stream = fTree->fStream; + Inode* stream = fTree->fStream; if ((status = stream->Append(transaction, fTree->fNodeSize)) < B_OK) return status; @@ -335,7 +338,7 @@ // #pragma mark - -BPlusTree::BPlusTree(Transaction &transaction, Inode *stream, int32 nodeSize) +BPlusTree::BPlusTree(Transaction& transaction, Inode* stream, int32 nodeSize) : fStream(NULL), fHeader(NULL), @@ -346,7 +349,7 @@ } -BPlusTree::BPlusTree(Inode *stream) +BPlusTree::BPlusTree(Inode* stream) : fStream(NULL), fHeader(NULL), @@ -388,13 +391,13 @@ /*! Create a new B+Tree on the specified stream */ status_t -BPlusTree::SetTo(Transaction &transaction, Inode *stream, int32 nodeSize) +BPlusTree::SetTo(Transaction& transaction, Inode* stream, int32 nodeSize) { // initializes in-memory B+Tree fStream = stream; - bplustree_header *header = fCachedHeader.SetToWritableHeader(transaction); + bplustree_header* header = fCachedHeader.SetToWritableHeader(transaction); if (header == NULL) { // allocate space for new header + node! fStatus = stream->SetFileSize(transaction, nodeSize * 2); @@ -419,7 +422,8 @@ header->max_number_of_levels = HOST_ENDIAN_TO_BFS_INT32(1); header->data_type = HOST_ENDIAN_TO_BFS_INT32(ModeToKeyType(stream->Mode())); header->root_node_pointer = HOST_ENDIAN_TO_BFS_INT64(nodeSize); - header->free_node_pointer = HOST_ENDIAN_TO_BFS_INT64((uint64)BPLUSTREE_NULL); + header->free_node_pointer + = HOST_ENDIAN_TO_BFS_INT64((uint64)BPLUSTREE_NULL); header->maximum_size = HOST_ENDIAN_TO_BFS_INT64(nodeSize * 2); // initialize b+tree root node @@ -435,7 +439,7 @@ status_t -BPlusTree::SetTo(Inode *stream) +BPlusTree::SetTo(Inode* stream) { if (stream == NULL) RETURN_ERROR(fStatus = B_BAD_VALUE); @@ -463,7 +467,7 @@ || !fHeader->IsValidLink(fHeader->FreeNode())) { #ifdef DEBUG dump_bplustree_header(fHeader); - dump_block((const char *)fHeader, 128); + dump_block((const char*)fHeader, 128); #endif RETURN_ERROR(fStatus = B_BAD_DATA); } @@ -537,7 +541,7 @@ BPlusTree::ModeToKeyType(mode_t mode) { switch (mode & (S_STR_INDEX | S_INT_INDEX | S_UINT_INDEX | S_LONG_LONG_INDEX - | S_ULONG_LONG_INDEX | S_FLOAT_INDEX | S_DOUBLE_INDEX)) { + | S_ULONG_LONG_INDEX | S_FLOAT_INDEX | S_DOUBLE_INDEX)) { case S_INT_INDEX: return BPLUSTREE_INT32_TYPE; case S_UINT_INDEX: @@ -578,7 +582,7 @@ void -BPlusTree::_AddIterator(TreeIterator *iterator) +BPlusTree::_AddIterator(TreeIterator* iterator) { MutexLocker _(fIteratorLock); fIterators.Add(iterator); @@ -586,7 +590,7 @@ void -BPlusTree::_RemoveIterator(TreeIterator *iterator) +BPlusTree::_RemoveIterator(TreeIterator* iterator) { MutexLocker _(fIteratorLock); fIterators.Remove(iterator); @@ -594,7 +598,7 @@ int32 -BPlusTree::_CompareKeys(const void *key1, int keyLength1, const void *key2, +BPlusTree::_CompareKeys(const void* key1, int keyLength1, const void* key2, int keyLength2) { type_code type = 0; @@ -626,8 +630,8 @@ status_t -BPlusTree::_FindKey(const bplustree_node *node, const uint8 *key, - uint16 keyLength, uint16 *_index, off_t *_next) +BPlusTree::_FindKey(const bplustree_node* node, const uint8* key, + uint16 keyLength, uint16* _index, off_t* _next) { #ifdef DEBUG NodeChecker checker(node, fNodeSize, "find"); @@ -641,7 +645,7 @@ return B_ENTRY_NOT_FOUND; } - off_t *values = node->Values(); + off_t* values = node->Values(); int16 saveIndex = -1; // binary search in the key array @@ -649,9 +653,9 @@ uint16 i = (first + last) >> 1; uint16 searchLength; - uint8 *searchKey = node->KeyAt(i, &searchLength); + uint8* searchKey = node->KeyAt(i, &searchLength); if (searchKey + searchLength + sizeof(off_t) + sizeof(uint16) - > (uint8 *)node + fNodeSize + > (uint8*)node + fNodeSize || searchLength > BPLUSTREE_MAX_KEY_LENGTH) { fStream->GetVolume()->Panic(); RETURN_ERROR(B_BAD_DATA); @@ -684,13 +688,12 @@ } -/*! - Prepares the stack to contain all nodes that were passed while +/*! Prepares the stack to contain all nodes that were passed while following the key, from the root node to the leaf node that could or should contain that key. */ status_t -BPlusTree::_SeekDown(Stack &stack, const uint8 *key, +BPlusTree::_SeekDown(Stack& stack, const uint8* key, uint16 keyLength) { // set the root node to begin with @@ -698,7 +701,7 @@ nodeAndKey.nodeOffset = fHeader->RootNode(); CachedNode cached(this); - const bplustree_node *node; + const bplustree_node* node; while ((node = cached.SetTo(nodeAndKey.nodeOffset)) != NULL) { // if we are already on leaf level, we're done if (node->OverflowLink() == BPLUSTREE_NULL) { @@ -733,16 +736,15 @@ } -/*! - This will find a free duplicate fragment in the given bplustree_node. +/*! This will find a free duplicate fragment in the given bplustree_node. The CachedNode will be set to the writable fragment on success. */ status_t -BPlusTree::_FindFreeDuplicateFragment(Transaction &transaction, - const bplustree_node *node, CachedNode &cached, - off_t *_offset, bplustree_node **_fragment, uint32 *_index) +BPlusTree::_FindFreeDuplicateFragment(Transaction& transaction, + const bplustree_node* node, CachedNode& cached, + off_t* _offset, bplustree_node** _fragment, uint32* _index) { - off_t *values = node->Values(); + off_t* values = node->Values(); for (int32 i = 0; i < node->NumKeys(); i++) { off_t value = BFS_ENDIAN_TO_HOST_INT64(values[i]); @@ -750,7 +752,7 @@ if (bplustree_node::LinkType(value) != BPLUSTREE_DUPLICATE_FRAGMENT) continue; - const bplustree_node *fragment = cached.SetTo( + const bplustree_node* fragment = cached.SetTo( bplustree_node::FragmentOffset(value), false); if (fragment == NULL) { FATAL(("Could not get duplicate fragment at %Ld\n", value)); @@ -760,7 +762,7 @@ // see if there is some space left for us uint32 num = bplustree_node::MaxFragments(fNodeSize); for (uint32 j = 0; j < num; j++) { - duplicate_array *array = fragment->FragmentAt(j); + duplicate_array* array = fragment->FragmentAt(j); if (array->count == 0) { // found an unused fragment @@ -779,11 +781,11 @@ status_t -BPlusTree::_InsertDuplicate(Transaction &transaction, CachedNode &cached, - const bplustree_node *node, uint16 index, off_t value) +BPlusTree::_InsertDuplicate(Transaction& transaction, CachedNode& cached, + const bplustree_node* node, uint16 index, off_t value) { CachedNode cachedDuplicate(this); - off_t *values = node->Values(); + off_t* values = node->Values(); off_t oldValue = BFS_ENDIAN_TO_HOST_INT64(values[index]); status_t status; off_t offset; @@ -792,29 +794,32 @@ // If it's a duplicate fragment, try to insert it into that, or if it // doesn't fit anymore, create a new duplicate node - if (bplustree_node::LinkType(oldValue) == BPLUSTREE_DUPLICATE_FRAGMENT) { - bplustree_node *duplicate = cachedDuplicate.SetToWritable(transaction, + if (bplustree_node::LinkType(oldValue) + == BPLUSTREE_DUPLICATE_FRAGMENT) { + bplustree_node* duplicate + = cachedDuplicate.SetToWritable(transaction, bplustree_node::FragmentOffset(oldValue), false); if (duplicate == NULL) return B_IO_ERROR; - duplicate_array *array = duplicate->FragmentAt( + duplicate_array* array = duplicate->FragmentAt( bplustree_node::FragmentIndex(oldValue)); if (array->count > NUM_FRAGMENT_VALUES || array->count < 1) { - FATAL(("insertDuplicate: Invalid array[%d] size in fragment %Ld == %Ld!\n", + FATAL(("insertDuplicate: Invalid array[%d] size in fragment " + "%Ld == %Ld!\n", (int)bplustree_node::FragmentIndex(oldValue), - bplustree_node::FragmentOffset(oldValue), - array->count)); + bplustree_node::FragmentOffset(oldValue), array->count)); return B_BAD_DATA; } if (array->count < NUM_FRAGMENT_VALUES) { array->Insert(value); } else { - // test if the fragment will be empty if we remove this key's values + // Test if the fragment will be empty if we remove this key's + // values if (duplicate->FragmentsUsed(fNodeSize) < 2) { - // the node will be empty without our values, so let us + // The node will be empty without our values, so let us // reuse it as a duplicate node offset = bplustree_node::FragmentOffset(oldValue); @@ -826,19 +831,20 @@ array = duplicate->DuplicateArray(); array->Insert(value); } else { - // create a new duplicate node + // Create a new duplicate node cachedDuplicate.UnsetUnchanged(transaction); - // the old duplicate has not been touched, so we can reuse it + // The old duplicate has not been touched, so we can + // reuse it - bplustree_node *newDuplicate; + bplustree_node* newDuplicate; status = cachedDuplicate.Allocate(transaction, &newDuplicate, &offset); if (status < B_OK) RETURN_ERROR(status); - // copy the array from the fragment node to the duplicate node - // and free the old entry (by zero'ing all values) + // Copy the array from the fragment node to the duplicate + // node and free the old entry (by zero'ing all values) newDuplicate->overflow_link = HOST_ENDIAN_TO_BFS_INT64( array->count); memcpy(&newDuplicate->all_key_count, &array->values[0], @@ -849,12 +855,13 @@ array->Insert(value); } - // update the main pointer to link to a duplicate node + // Update the main pointer to link to a duplicate node if (cached.MakeWritable(transaction) == NULL) return B_IO_ERROR; - values[index] = HOST_ENDIAN_TO_BFS_INT64(bplustree_node::MakeLink( - BPLUSTREE_DUPLICATE_NODE, offset)); + values[index] + = HOST_ENDIAN_TO_BFS_INT64(bplustree_node::MakeLink( + BPLUSTREE_DUPLICATE_NODE, offset)); } return B_OK; @@ -863,8 +870,8 @@ // Put the value into a dedicated duplicate node // search for free space in the duplicate nodes of that key - duplicate_array *array; - const bplustree_node *duplicate; + duplicate_array* array; + const bplustree_node* duplicate; off_t duplicateOffset; do { duplicateOffset = bplustree_node::FragmentOffset(oldValue); @@ -874,14 +881,15 @@ array = duplicate->DuplicateArray(); if (array->count > NUM_DUPLICATE_VALUES || array->count < 0) { - FATAL(("removeDuplicate: Invalid array size in duplicate %Ld == %Ld!\n", - duplicateOffset, array->count)); + FATAL(("removeDuplicate: Invalid array size in duplicate %Ld " + "== %Ld!\n", duplicateOffset, array->count)); return B_BAD_DATA; } } while (array->count >= NUM_DUPLICATE_VALUES && (oldValue = duplicate->RightLink()) != BPLUSTREE_NULL); - bplustree_node *writableDuplicate = cachedDuplicate.MakeWritable(transaction); + bplustree_node* writableDuplicate + = cachedDuplicate.MakeWritable(transaction); if (writableDuplicate == NULL) return B_IO_ERROR; @@ -891,8 +899,9 @@ } else { // no space left - add a new duplicate node - bplustree_node *newDuplicate; - status = cachedDuplicate.Allocate(transaction, &newDuplicate, &offset); + bplustree_node* newDuplicate; + status = cachedDuplicate.Allocate(transaction, &newDuplicate, + &offset); if (status < B_OK) RETURN_ERROR(status); @@ -911,7 +920,7 @@ // to insert the duplicate value into uint32 fragmentIndex = 0; - bplustree_node *fragment; + bplustree_node* fragment; if (_FindFreeDuplicateFragment(transaction, node, cachedDuplicate, &offset, &fragment, &fragmentIndex) != B_OK) { // allocate a new duplicate fragment node @@ -922,7 +931,7 @@ memset(fragment, 0, fNodeSize); } - duplicate_array *array = fragment->FragmentAt(fragmentIndex); + duplicate_array* array = fragment->FragmentAt(fragmentIndex); array->Insert(oldValue); array->Insert(value); @@ -937,23 +946,23 @@ void -BPlusTree::_InsertKey(bplustree_node *node, uint16 index, uint8 *key, +BPlusTree::_InsertKey(bplustree_node* node, uint16 index, uint8* key, uint16 keyLength, off_t value) { // should never happen, but who knows? if (index > node->NumKeys()) return; - off_t *values = node->Values(); - uint16 *keyLengths = node->KeyLengths(); - uint8 *keys = node->Keys(); + off_t* values = node->Values(); + uint16* keyLengths = node->KeyLengths(); + uint8* keys = node->Keys(); node->all_key_count = HOST_ENDIAN_TO_BFS_INT16(node->NumKeys() + 1); node->all_key_length = HOST_ENDIAN_TO_BFS_INT16(node->AllKeyLength() + keyLength); - off_t *newValues = node->Values(); - uint16 *newKeyLengths = node->KeyLengths(); + off_t* newValues = node->Values(); + uint16* newKeyLengths = node->KeyLengths(); // move values and copy new value into them memmove(newValues + index + 1, values + index, @@ -984,23 +993,22 @@ } -/*! - Splits the \a node into two halves - the other half will be put into \a other. - It also takes care to create a new overflow link if the node to split is an - index node. +/*! Splits the \a node into two halves - the other half will be put into + \a other. It also takes care to create a new overflow link if the node + to split is an index node. */ status_t -BPlusTree::_SplitNode(bplustree_node *node, off_t nodeOffset, - bplustree_node *other, off_t otherOffset, uint16 *_keyIndex, uint8 *key, - uint16 *_keyLength, off_t *_value) +BPlusTree::_SplitNode(bplustree_node* node, off_t nodeOffset, + bplustree_node* other, off_t otherOffset, uint16* _keyIndex, uint8* key, + uint16* _keyLength, off_t* _value) { if (*_keyIndex > node->NumKeys() + 1) return B_BAD_VALUE; - uint16 *inKeyLengths = node->KeyLengths(); - off_t *inKeyValues = node->Values(); - uint8 *inKeys = node->Keys(); - uint8 *outKeys = other->Keys(); + uint16* inKeyLengths = node->KeyLengths(); + off_t* inKeyValues = node->Values(); + uint8* inKeys = node->Keys(); + uint8* outKeys = other->Keys(); int32 keyIndex = *_keyIndex; // can become less than zero! if (keyIndex > node->NumKeys()) { @@ -1059,8 +1067,8 @@ + bytesAfter); other->all_key_count = HOST_ENDIAN_TO_BFS_INT16(out); - uint16 *outKeyLengths = other->KeyLengths(); - off_t *outKeyValues = other->Values(); + uint16* outKeyLengths = other->KeyLengths(); + off_t* outKeyValues = other->Values(); int32 keys = out > keyIndex ? keyIndex : out; if (bytesBefore) { @@ -1082,7 +1090,8 @@ keys = out - keyIndex - 1; for (int32 i = 0;i < keys;i++) { outKeyLengths[keyIndex + i + 1] = HOST_ENDIAN_TO_BFS_INT16( - BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[keyIndex + i]) + bytes); + BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[keyIndex + i]) + + bytes); } memcpy(outKeyValues + keyIndex + 1, inKeyValues + keyIndex, keys * sizeof(off_t)); @@ -1097,7 +1106,7 @@ // these variables are for the key that will be returned // to the parent node - uint8 *newKey = NULL; + uint8* newKey = NULL; uint16 newLength; bool newAllocated = false; @@ -1115,14 +1124,14 @@ } else { // If a key is dropped (is not the new key), we have to copy // it, because it would be lost if not. - uint8 *droppedKey = node->KeyAt(in, &newLength); + uint8* droppedKey = node->KeyAt(in, &newLength); if (droppedKey + newLength + sizeof(off_t) + sizeof(uint16) - > (uint8 *)node + fNodeSize + > (uint8*)node + fNodeSize || newLength > BPLUSTREE_MAX_KEY_LENGTH) { fStream->GetVolume()->Panic(); RETURN_ERROR(B_BAD_DATA); } - newKey = (uint8 *)malloc(newLength); + newKey = (uint8*)malloc(newLength); if (newKey == NULL) return B_NO_MEMORY; @@ -1249,7 +1258,7 @@ You need to have the inode write locked. */ status_t -BPlusTree::Insert(Transaction &transaction, const uint8 *key, uint16 keyLength, +BPlusTree::Insert(Transaction& transaction, const uint8* key, uint16 keyLength, off_t value) { if (keyLength < BPLUSTREE_MIN_KEY_LENGTH @@ -1272,7 +1281,7 @@ keyBuffer[keyLength] = 0; node_and_key nodeAndKey; - const bplustree_node *node; + const bplustree_node* node; CachedNode cached(this); while (stack.Pop(&nodeAndKey) @@ -1299,7 +1308,7 @@ } } - bplustree_node *writableNode = cached.MakeWritable(transaction); + bplustree_node* writableNode = cached.MakeWritable(transaction); if (writableNode == NULL) return B_IO_ERROR; @@ -1322,7 +1331,7 @@ // it now off_t newRoot = BPLUSTREE_NULL; if (nodeAndKey.nodeOffset == fHeader->RootNode()) { - bplustree_node *root; + bplustree_node* root; status_t status = cachedNewRoot.Allocate(transaction, &root, &newRoot); if (status < B_OK) { @@ -1337,7 +1346,7 @@ } // reserve space for the other node - bplustree_node *other; + bplustree_node* other; off_t otherOffset; status_t status = cachedOther.Allocate(transaction, &other, &otherOffset); @@ -1371,14 +1380,14 @@ // create a new root if necessary if (newRoot != BPLUSTREE_NULL) { - bplustree_node *root = cachedNewRoot.Node(); + bplustree_node* root = cachedNewRoot.Node(); _InsertKey(root, 0, keyBuffer, keyLength, writableNode->LeftLink()); root->overflow_link = HOST_ENDIAN_TO_BFS_INT64( nodeAndKey.nodeOffset); - bplustree_header *header + bplustree_header* header = fCachedHeader.MakeWritableHeader(transaction); if (header == NULL) return B_IO_ERROR; @@ -1400,29 +1409,30 @@ It's part of the private tree interface. */ status_t -BPlusTree::_RemoveDuplicate(Transaction &transaction, - const bplustree_node *node, CachedNode &cached, uint16 index, +BPlusTree::_RemoveDuplicate(Transaction& transaction, + const bplustree_node* node, CachedNode& cached, uint16 index, off_t value) { - off_t *values = node->Values(); + off_t* values = node->Values(); off_t oldValue = BFS_ENDIAN_TO_HOST_INT64(values[index]); CachedNode cachedDuplicate(this); off_t duplicateOffset = bplustree_node::FragmentOffset(oldValue); - bplustree_node *duplicate = cachedDuplicate.SetToWritable(transaction, + bplustree_node* duplicate = cachedDuplicate.SetToWritable(transaction, duplicateOffset, false); if (duplicate == NULL) return B_IO_ERROR; // if it's a duplicate fragment, remove the entry from there if (bplustree_node::LinkType(oldValue) == BPLUSTREE_DUPLICATE_FRAGMENT) { - duplicate_array *array = duplicate->FragmentAt( [... truncated: 5053 lines follow ...] From axeld at mail.berlios.de Sat Aug 2 16:52:19 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 16:52:19 +0200 Subject: [Haiku-commits] r26729 - haiku/trunk/src/system/kernel Message-ID: <200808021452.m72EqJQS024301@sheep.berlios.de> Author: axeld Date: 2008-08-02 16:52:18 +0200 (Sat, 02 Aug 2008) New Revision: 26729 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26729&view=rev Modified: haiku/trunk/src/system/kernel/main.cpp Log: Minor cleanup. Modified: haiku/trunk/src/system/kernel/main.cpp =================================================================== --- haiku/trunk/src/system/kernel/main.cpp 2008-08-02 14:06:38 UTC (rev 26728) +++ haiku/trunk/src/system/kernel/main.cpp 2008-08-02 14:52:18 UTC (rev 26729) @@ -9,6 +9,9 @@ /*! This is main - initializes the kernel and launches the Bootscript */ +#include + +#include #include #include @@ -23,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -49,8 +51,6 @@ #include #include -#include - #include "vm/VMAnonymousCache.h" @@ -69,18 +69,8 @@ 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 +extern "C" int _start(kernel_args *bootKernelArgs, int currentCPU) { if (bootKernelArgs->kernel_args_size != sizeof(kernel_args) @@ -110,8 +100,6 @@ // 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); @@ -214,7 +202,8 @@ // 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); + thread_id thread = spawn_kernel_thread(&main2, "main2", + B_NORMAL_PRIORITY, NULL); TRACE("resuming main2 thread...\n"); resume_thread(thread); } else { @@ -244,6 +233,7 @@ return 0; } + static int32 main2(void *unused) { From axeld at mail.berlios.de Sat Aug 2 16:55:55 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 16:55:55 +0200 Subject: [Haiku-commits] r26730 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/debug src/system/kernel/device_manager src/system/kernel/fs src/system/kernel/posix Message-ID: <200808021455.m72EttmN024597@sheep.berlios.de> Author: axeld Date: 2008-08-02 16:55:53 +0200 (Sat, 02 Aug 2008) New Revision: 26730 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26730&view=rev Modified: haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/condition_variable.cpp haiku/trunk/src/system/kernel/debug/user_debugger.cpp haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp haiku/trunk/src/system/kernel/fs/vfs.cpp haiku/trunk/src/system/kernel/lock.cpp haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp haiku/trunk/src/system/kernel/sem.cpp haiku/trunk/src/system/kernel/signal.cpp haiku/trunk/src/system/kernel/smp.c haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/kernel/usergroup.cpp Log: * Renamed thread_spinlock and team_spinlock to gThreadSpinlock and gTeamSpinlock. * Renamed the static global variables in smp.c to match our style guide. * Minor other cleanup. * Removed superfluous white space. Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-08-02 14:55:53 UTC (rev 26730) @@ -19,15 +19,15 @@ #include -extern spinlock thread_spinlock; -#define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock) -#define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock) +extern spinlock gThreadSpinlock; +#define GRAB_THREAD_LOCK() acquire_spinlock(&gThreadSpinlock) +#define RELEASE_THREAD_LOCK() release_spinlock(&gThreadSpinlock) -extern spinlock team_spinlock; +extern spinlock gTeamSpinlock; // NOTE: TEAM lock can be held over a THREAD lock acquisition, // but not the other way (to avoid deadlock) -#define GRAB_TEAM_LOCK() acquire_spinlock(&team_spinlock) -#define RELEASE_TEAM_LOCK() release_spinlock(&team_spinlock) +#define GRAB_TEAM_LOCK() acquire_spinlock(&gTeamSpinlock) +#define RELEASE_TEAM_LOCK() release_spinlock(&gTeamSpinlock) enum additional_thread_state { THREAD_STATE_FREE_ON_RESCHED = 7, // free the thread structure upon reschedule Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -132,7 +132,7 @@ conditionLocker.Unlock(); - SpinLocker threadLocker(thread_spinlock); + SpinLocker threadLocker(gThreadSpinlock); status_t error; if ((flags & (B_RELATIVE_TIMEOUT | B_ABSOLUTE_TIMEOUT)) != 0) @@ -215,7 +215,7 @@ ASSERT(fObject != NULL); InterruptsLocker _; - SpinLocker threadLocker(threadsLocked ? NULL : &thread_spinlock); + SpinLocker threadLocker(threadsLocked ? NULL : &gThreadSpinlock); SpinLocker locker(sConditionVariablesLock); #if KDEBUG @@ -286,7 +286,7 @@ ConditionVariable::_Notify(bool all, bool threadsLocked) { InterruptsLocker _; - SpinLocker threadLocker(threadsLocked ? NULL : &thread_spinlock); + SpinLocker threadLocker(threadsLocked ? NULL : &gThreadSpinlock); SpinLocker locker(sConditionVariablesLock); if (!fEntries.IsEmpty()) Modified: haiku/trunk/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/debug/user_debugger.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -150,7 +150,7 @@ static void update_threads_breakpoints_flag() { - InterruptsSpinLocker _(team_spinlock); + InterruptsSpinLocker _(gTeamSpinlock); struct team* team = thread_get_current_thread()->team; struct thread* thread = team->thread_list; @@ -538,7 +538,7 @@ thread->id)); arch_set_debug_cpu_state( &commandMessage.set_cpu_state.cpu_state); - + break; } @@ -562,7 +562,7 @@ case B_DEBUGGED_THREAD_DEBUGGER_CHANGED: { // Check, if the debugger really changed, i.e. is different - // than the one we know. + // than the one we know. team_debug_info teamDebugInfo; get_team_debug_info(teamDebugInfo); @@ -850,7 +850,7 @@ InterruptsLocker interruptsLocker; - SpinLocker threadLocker(thread_spinlock); + SpinLocker threadLocker(gThreadSpinlock); struct thread *thread = thread_get_thread_struct_locked(threadID); if (!thread) @@ -860,7 +860,7 @@ threadLocker.Unlock(); - SpinLocker teamLocker(team_spinlock); + SpinLocker teamLocker(gTeamSpinlock); update_thread_breakpoints_flag(); update_thread_debugger_installed_flag(); } @@ -1611,7 +1611,7 @@ break; } - + case B_DEBUG_MESSAGE_CLEAR_BREAKPOINT: { // get the parameters @@ -1758,7 +1758,7 @@ // get the masks uint64 ignore = 0; uint64 ignoreOnce = 0; - + cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); @@ -1888,7 +1888,7 @@ } else { // We probably got a SIGKILL. If so, we will terminate when // reading the next message fails. - } + } break; } Modified: haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -158,7 +158,7 @@ fFinishedOperationCondition.NotifyAll(); if (fWaiting) { - SpinLocker _2(thread_spinlock); + SpinLocker _2(gThreadSpinlock); thread_interrupt(thread_get_thread_struct_locked(fSchedulerThread), false); } Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -1503,7 +1503,7 @@ team_id lastTeamID; cpu_status state = disable_interrupts(); - SpinLocker teamsLock(team_spinlock); + SpinLocker teamsLock(gTeamSpinlock); lastTeamID = peek_next_thread_id(); if (nextTeamID < lastTeamID) { Modified: haiku/trunk/src/system/kernel/lock.cpp =================================================================== --- haiku/trunk/src/system/kernel/lock.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/lock.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -246,7 +246,7 @@ ? (char*)lock->name : NULL; // unblock all waiters - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); #ifdef KDEBUG if (lock->waiters != NULL && thread_get_current_thread_id() @@ -283,7 +283,7 @@ #if KDEBUG_RW_LOCK_DEBUG return rw_lock_write_lock(lock); #else - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->writer_count == 0) { lock->reader_count++; @@ -305,7 +305,7 @@ #if KDEBUG_RW_LOCK_DEBUG return rw_lock_write_unlock(lock); #else - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->holder == thread_get_current_thread_id()) { if (--lock->owner_count > 0) @@ -335,7 +335,7 @@ status_t rw_lock_write_lock(rw_lock* lock) { - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); if (lock->reader_count == 0 && lock->writer_count == 0) { lock->writer_count++; @@ -362,7 +362,7 @@ status_t rw_lock_write_unlock(rw_lock* lock) { - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); if (thread_get_current_thread_id() != lock->holder) { panic("rw_lock_write_unlock(): lock %p not write-locked by this thread", @@ -454,7 +454,7 @@ ? (char*)lock->name : NULL; // unblock all waiters - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); #ifdef KDEBUG if (lock->waiters != NULL && thread_get_current_thread_id() @@ -485,7 +485,7 @@ status_t mutex_switch_lock(mutex* from, mutex* to) { - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); #if !defined(KDEBUG) if (atomic_add(&from->count, 1) < -1) @@ -507,7 +507,7 @@ #endif // lock only, if !threadsLocked - InterruptsSpinLocker locker(thread_spinlock, false, !threadsLocked); + InterruptsSpinLocker locker(gThreadSpinlock, false, !threadsLocked); // Might have been released after we decremented the count, but before // we acquired the spinlock. @@ -556,7 +556,7 @@ _mutex_unlock(mutex* lock, bool threadsLocked) { // lock only, if !threadsLocked - InterruptsSpinLocker locker(thread_spinlock, false, !threadsLocked); + InterruptsSpinLocker locker(gThreadSpinlock, false, !threadsLocked); #ifdef KDEBUG if (thread_get_current_thread_id() != lock->holder) { @@ -600,7 +600,7 @@ _mutex_trylock(mutex* lock) { #ifdef KDEBUG - InterruptsSpinLocker _(thread_spinlock); + InterruptsSpinLocker _(gThreadSpinlock); if (lock->holder <= 0) { lock->holder = thread_get_current_thread_id(); Modified: haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -84,7 +84,7 @@ { // For some reason the semaphore is getting destroyed. // Wake up any remaing awaiting threads - InterruptsSpinLocker _(thread_spinlock); + InterruptsSpinLocker _(gThreadSpinlock); while (queued_thread *entry = fWaitingToIncreaseQueue.RemoveHead()) { entry->queued = false; thread_unblock_locked(entry->thread, EIDRM); @@ -184,7 +184,7 @@ thread_prepare_to_block(thread, B_CAN_INTERRUPT, THREAD_BLOCK_TYPE_OTHER, (void*)"xsi semaphore"); - InterruptsSpinLocker _(thread_spinlock); + InterruptsSpinLocker _(gThreadSpinlock); status_t result = thread_block_locked(thread); if (queueEntry.queued) { @@ -204,7 +204,7 @@ void WakeUpThread(bool waitingForZero) { - InterruptsSpinLocker _(thread_spinlock); + InterruptsSpinLocker _(gThreadSpinlock); if (waitingForZero) { // Wake up all threads waiting on zero while (queued_thread *entry = fWaitingToBeZeroQueue.RemoveHead()) { @@ -240,7 +240,7 @@ XsiSemaphoreSet(int numberOfSemaphores, int flags) : fInitOK(false), fLastSemctlTime((time_t)real_time_clock()), - fLastSemopTime(0), + fLastSemopTime(0), fNumberOfSemaphores(numberOfSemaphores), fSemaphores(0) { @@ -495,7 +495,7 @@ // Clear all undo_value (Posix semadj equivalent), // which result in removing the sem_undo record from // the global undo list, plus decrementing the related - // team xsi_sem_undo_requests field. + // team xsi_sem_undo_requests field. // This happens only on semctl SETVAL and SETALL. TRACE(("XsiSemaphore::ClearUndos: semaphoreSetID = %d, " "semaphoreNumber = %d\n", semaphoreSetID, semaphoreNumber)); @@ -505,7 +505,7 @@ struct sem_undo *current = iterator.Next(); if (current->semaphore_set_id == semaphoreSetID && current->semaphore_number == semaphoreNumber) { - InterruptsSpinLocker lock(team_spinlock); + InterruptsSpinLocker lock(gTeamSpinlock); if (current->team) current->team->xsi_sem_undo_requests--; iterator.Remove(); @@ -560,7 +560,7 @@ request->semaphore_number = semaphoreNumber; request->undo_value = value; // Add the request to the global sem_undo list - InterruptsSpinLocker _(team_spinlock); + InterruptsSpinLocker _(gTeamSpinlock); if ((int)(team->xsi_sem_undo_requests + 1) < USHRT_MAX) team->xsi_sem_undo_requests++; else @@ -592,7 +592,7 @@ // sem_undo request made previously by the same // process if (current->undo_value == 0) { - InterruptsSpinLocker _(team_spinlock); + InterruptsSpinLocker _(gTeamSpinlock); if (current->team) current->team->xsi_sem_undo_requests--; iterator.Remove(); @@ -674,7 +674,7 @@ "SemaphoreNumber = %d, undo value = %d\n", (int)teamID, semaphoreSetID, current->semaphore_number, current->undo_value)); - semaphore->Revert(current->undo_value); + semaphore->Revert(current->undo_value); } else TRACE(("xsi_do_undo: semaphore set %d does not exist " "anymore. Ignore record.\n", semaphoreSetID)); @@ -756,7 +756,7 @@ if (create) { // Create a new sempahore set for this key - if (numberOfSemaphores < 0 + if (numberOfSemaphores < 0 || numberOfSemaphores >= MAX_XSI_SEMS_PER_TEAM) { TRACE_ERROR(("xsi_semget: numberOfSemaphores out of range\n")); return EINVAL; @@ -1058,7 +1058,7 @@ break; } } else if (operation == 0) { - if (value == 0) + if (value == 0) continue; else if (operations[i].sem_flg & IPC_NOWAIT) { result = EAGAIN; Modified: haiku/trunk/src/system/kernel/sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -918,7 +918,7 @@ bool unblockedAny = false; - SpinLocker threadLocker(thread_spinlock); + SpinLocker threadLocker(gThreadSpinlock); while (count > 0) { queued_thread* entry = sSems[slot].queue.Head(); @@ -1058,7 +1058,7 @@ team = team_get_current_team_id(); /* prevents sSems[].owner == -1 >= means owned by a port */ if (team < 0 || !team_is_valid(team)) - return B_BAD_TEAM_ID; + return B_BAD_TEAM_ID; slot = *_cookie; if (slot >= sMaxSems) Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/signal.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -229,7 +229,7 @@ void update_current_thread_signals_flag() { - InterruptsSpinLocker locker(thread_spinlock); + InterruptsSpinLocker locker(gThreadSpinlock); update_thread_signals_flag(thread_get_current_thread()); } @@ -343,7 +343,7 @@ // notify threads waiting for team state changes if (thread == thread->team->main_thread) { - InterruptsSpinLocker locker(team_spinlock); + InterruptsSpinLocker locker(gTeamSpinlock); team_set_job_control_state(thread->team, JOB_CONTROL_STATE_CONTINUED, signal, false); @@ -366,13 +366,13 @@ // notify threads waiting for team state changes if (thread == thread->team->main_thread) { - InterruptsSpinLocker locker(team_spinlock); + InterruptsSpinLocker locker(gTeamSpinlock); team_set_job_control_state(thread->team, JOB_CONTROL_STATE_STOPPED, signal, false); // send a SIGCHLD to the parent (if it does have // SA_NOCLDSTOP defined) - SpinLocker _(thread_spinlock); + SpinLocker _(gThreadSpinlock); struct thread* parentThread = thread->team->parent->main_thread; struct sigaction& parentHandler Modified: haiku/trunk/src/system/kernel/smp.c =================================================================== --- haiku/trunk/src/system/kernel/smp.c 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/smp.c 2008-08-02 14:55:53 UTC (rev 26730) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -59,15 +59,15 @@ static spinlock boot_cpu_spin[SMP_MAX_CPUS] = { }; -static struct smp_msg *free_msgs = NULL; -static volatile int free_msg_count = 0; -static spinlock free_msg_spinlock = B_SPINLOCK_INITIALIZER; +static struct smp_msg *sFreeMessages = NULL; +static volatile int sFreeMessageCount = 0; +static spinlock sFreeMessageSpinlock = B_SPINLOCK_INITIALIZER; -static struct smp_msg *smp_msgs[SMP_MAX_CPUS] = { NULL, }; -static spinlock cpu_msg_spinlock[SMP_MAX_CPUS]; +static struct smp_msg *sCPUMessages[SMP_MAX_CPUS] = { NULL, }; +static spinlock sCPUMessageSpinlock[SMP_MAX_CPUS]; -static struct smp_msg *smp_broadcast_msgs = NULL; -static spinlock broadcast_msg_spinlock = B_SPINLOCK_INITIALIZER; +static struct smp_msg *sBroadcastMessages = NULL; +static spinlock sBroadcastMessageSpinlock = B_SPINLOCK_INITIALIZER; static bool sICIEnabled = false; static int32 sNumCPUs = 1; @@ -89,7 +89,7 @@ push_lock_caller(void *caller, spinlock *lock) { sLastCaller[sLastIndex].caller = caller; - sLastCaller[sLastIndex].lock = lock; + sLastCaller[sLastIndex].lock = lock; if (++sLastIndex >= NUM_LAST_CALLERS) sLastIndex = 0; @@ -139,7 +139,7 @@ panic("acquire_spinlock: attempt to acquire lock %p with interrupts enabled\n", lock); oldValue = atomic_set((int32 *)lock, 1); if (oldValue != 0) { - panic("acquire_spinlock: attempt to acquire lock %p twice on non-SMP system (last caller: %p, value %ld)\n", + panic("acquire_spinlock: attempt to acquire lock %p twice on non-SMP system (last caller: %p, value %ld)\n", lock, find_lock_caller(lock), oldValue); } @@ -147,8 +147,8 @@ #endif } } - + static void acquire_spinlock_nocheck(spinlock *lock) { @@ -226,24 +226,24 @@ TRACE(("find_free_message: entry\n")); retry: - while (free_msg_count <= 0) + while (sFreeMessageCount <= 0) PAUSE(); state = disable_interrupts(); - acquire_spinlock(&free_msg_spinlock); + acquire_spinlock(&sFreeMessageSpinlock); - if (free_msg_count <= 0) { + if (sFreeMessageCount <= 0) { // someone grabbed one while we were getting the lock, // go back to waiting for it - release_spinlock(&free_msg_spinlock); + release_spinlock(&sFreeMessageSpinlock); restore_interrupts(state); goto retry; } - *msg = free_msgs; - free_msgs = (*msg)->next; - free_msg_count--; + *msg = sFreeMessages; + sFreeMessages = (*msg)->next; + sFreeMessageCount--; - release_spinlock(&free_msg_spinlock); + release_spinlock(&sFreeMessageSpinlock); TRACE(("find_free_message: returning msg %p\n", *msg)); @@ -256,11 +256,11 @@ { TRACE(("return_free_message: returning msg %p\n", msg)); - acquire_spinlock_nocheck(&free_msg_spinlock); - msg->next = free_msgs; - free_msgs = msg; - free_msg_count++; - release_spinlock(&free_msg_spinlock); + acquire_spinlock_nocheck(&sFreeMessageSpinlock); + msg->next = sFreeMessages; + sFreeMessages = msg; + sFreeMessageCount++; + release_spinlock(&sFreeMessageSpinlock); } @@ -272,20 +272,20 @@ if (!sICIEnabled) return NULL; - acquire_spinlock_nocheck(&cpu_msg_spinlock[currentCPU]); - msg = smp_msgs[currentCPU]; + acquire_spinlock_nocheck(&sCPUMessageSpinlock[currentCPU]); + msg = sCPUMessages[currentCPU]; if (msg != NULL) { - smp_msgs[currentCPU] = msg->next; - release_spinlock(&cpu_msg_spinlock[currentCPU]); + sCPUMessages[currentCPU] = msg->next; + release_spinlock(&sCPUMessageSpinlock[currentCPU]); TRACE((" cpu %d: found msg %p in cpu mailbox\n", currentCPU, msg)); *source_mailbox = MAILBOX_LOCAL; } else { // try getting one from the broadcast mailbox - release_spinlock(&cpu_msg_spinlock[currentCPU]); - acquire_spinlock_nocheck(&broadcast_msg_spinlock); + release_spinlock(&sCPUMessageSpinlock[currentCPU]); + acquire_spinlock_nocheck(&sBroadcastMessageSpinlock); - msg = smp_broadcast_msgs; + msg = sBroadcastMessages; while (msg != NULL) { if (CHECK_BIT(msg->proc_bitmap, currentCPU) != 0) { // we have handled this one already @@ -298,7 +298,7 @@ *source_mailbox = MAILBOX_BCAST; break; } - release_spinlock(&broadcast_msg_spinlock); + release_spinlock(&sBroadcastMessageSpinlock); TRACE((" cpu %d: found msg %p in broadcast mailbox\n", currentCPU, msg)); } return msg; @@ -320,12 +320,12 @@ // clean up the message from one of the mailboxes switch (source_mailbox) { case MAILBOX_BCAST: - mbox = &smp_broadcast_msgs; - spinlock = &broadcast_msg_spinlock; + mbox = &sBroadcastMessages; + spinlock = &sBroadcastMessageSpinlock; break; case MAILBOX_LOCAL: - mbox = &smp_msgs[currentCPU]; - spinlock = &cpu_msg_spinlock[currentCPU]; + mbox = &sCPUMessages[currentCPU]; + spinlock = &sCPUMessageSpinlock[currentCPU]; break; } @@ -462,8 +462,8 @@ if (bufferSize < sizeof(spinlock_contention_info)) return B_BAD_VALUE; - info.thread_spinlock_counter = get_spinlock_counter(&thread_spinlock); - info.team_spinlock_counter = get_spinlock_counter(&team_spinlock); + info.thread_spinlock_counter = get_spinlock_counter(&gThreadSpinlock); + info.team_spinlock_counter = get_spinlock_counter(&gTeamSpinlock); if (!IS_USER_ADDRESS(buffer) || user_memcpy(buffer, &info, sizeof(info)) != B_OK) { @@ -529,10 +529,10 @@ msg->done = false; // stick it in the appropriate cpu's mailbox - acquire_spinlock_nocheck(&cpu_msg_spinlock[targetCPU]); - msg->next = smp_msgs[targetCPU]; - smp_msgs[targetCPU] = msg; - release_spinlock(&cpu_msg_spinlock[targetCPU]); + acquire_spinlock_nocheck(&sCPUMessageSpinlock[targetCPU]); + msg->next = sCPUMessages[targetCPU]; + sCPUMessages[targetCPU] = msg; + release_spinlock(&sCPUMessageSpinlock[targetCPU]); arch_smp_send_ici(targetCPU); @@ -586,10 +586,10 @@ currentCPU, msg)); // stick it in the appropriate cpu's mailbox - acquire_spinlock_nocheck(&broadcast_msg_spinlock); - msg->next = smp_broadcast_msgs; - smp_broadcast_msgs = msg; - release_spinlock(&broadcast_msg_spinlock); + acquire_spinlock_nocheck(&sBroadcastMessageSpinlock); + msg->next = sBroadcastMessages; + sBroadcastMessages = msg; + release_spinlock(&sBroadcastMessageSpinlock); arch_smp_send_broadcast_ici(); @@ -671,8 +671,8 @@ TRACE(("smp_init: entry\n")); if (args->num_cpus > 1) { - free_msgs = NULL; - free_msg_count = 0; + sFreeMessages = NULL; + sFreeMessageCount = 0; for (i = 0; i < MSG_POOL_SIZE; i++) { msg = (struct smp_msg *)malloc(sizeof(struct smp_msg)); if (msg == NULL) { @@ -680,9 +680,9 @@ return B_ERROR; } memset(msg, 0, sizeof(struct smp_msg)); - msg->next = free_msgs; - free_msgs = msg; - free_msg_count++; + msg->next = sFreeMessages; + sFreeMessages = msg; + sFreeMessageCount++; } sNumCPUs = args->num_cpus; } Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-08-02 14:52:18 UTC (rev 26729) +++ haiku/trunk/src/system/kernel/team.cpp 2008-08-02 14:55:53 UTC (rev 26730) @@ -91,7 +91,7 @@ static int32 sMaxTeams = 2048; static int32 sUsedTeams = 1; -spinlock team_spinlock = B_SPINLOCK_INITIALIZER; +spinlock gTeamSpinlock = B_SPINLOCK_INITIALIZER; // #pragma mark - Tracing @@ -101,73 +101,73 @@ namespace TeamTracing { class TeamForked : public AbstractTraceEntry { - public: - TeamForked(thread_id forkedThread) - : - fForkedThread(forkedThread) - { - Initialized(); - } +public: + TeamForked(thread_id forkedThread) + : + fForkedThread(forkedThread) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("team forked, new thread %ld", fForkedThread); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("team forked, new thread %ld", fForkedThread); + } - private: - thread_id fForkedThread; +private: + thread_id fForkedThread; }; class ExecTeam : public AbstractTraceEntry { - public: - ExecTeam(const char* path, int32 argCount, const char* const* args, - int32 envCount, const char* const* env) - : - fArgCount(argCount), - fArgs(NULL) - { - fPath = alloc_tracing_buffer_strcpy(path, B_PATH_NAME_LENGTH, - false); +public: + ExecTeam(const char* path, int32 argCount, const char* const* args, + int32 envCount, const char* const* env) + : + fArgCount(argCount), + fArgs(NULL) + { + fPath = alloc_tracing_buffer_strcpy(path, B_PATH_NAME_LENGTH, + false); - // determine the buffer size we need for the args - size_t argBufferSize = 0; - for (int32 i = 0; i < argCount; i++) - argBufferSize += strlen(args[i]) + 1; + // determine the buffer size we need for the args + size_t argBufferSize = 0; + for (int32 i = 0; i < argCount; i++) + argBufferSize += strlen(args[i]) + 1; - // allocate a buffer - fArgs = (char*)alloc_tracing_buffer(argBufferSize); - if (fArgs) { - char* buffer = fArgs; - for (int32 i = 0; i < argCount; i++) { - size_t argSize = strlen(args[i]) + 1; - memcpy(buffer, args[i], argSize); - buffer += argSize; - } + // allocate a buffer + fArgs = (char*)alloc_tracing_buffer(argBufferSize); + if (fArgs) { + char* buffer = fArgs; + for (int32 i = 0; i < argCount; i++) { + size_t argSize = strlen(args[i]) + 1; + memcpy(buffer, args[i], argSize); + buffer += argSize; } + } - // ignore env for the time being - (void)envCount; - (void)env; + // ignore env for the time being + (void)envCount; + (void)env; - Initialized(); - } + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("team exec, \"%p\", args:", fPath); + virtual void AddDump(TraceOutput& out) + { + out.Print("team exec, \"%p\", args:", fPath); - char* args = fArgs; - for (int32 i = 0; !out.IsFull() && i < fArgCount; i++) { - out.Print(" \"%s\"", args); - args += strlen(args) + 1; - } + char* args = fArgs; + for (int32 i = 0; !out.IsFull() && i < fArgCount; i++) { + out.Print(" \"%s\"", args); + args += strlen(args) + 1; } + } - private: - char* fPath; - int32 fArgCount; - char* fArgs; +private: + char* fPath; + int32 fArgCount; + char* fArgs; }; @@ -190,91 +190,91 @@ class SetJobControlState : public AbstractTraceEntry { - public: - SetJobControlState(team_id team, job_control_state newState, int signal) - : - fTeam(team), - fNewState(newState), - fSignal(signal) - { - Initialized(); - } +public: + SetJobControlState(team_id team, job_control_state newState, int signal) + : + fTeam(team), + fNewState(newState), + fSignal(signal) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("team set job control state, team %ld, " - "new state: %s, signal: %d", - fTeam, job_control_state_name(fNewState), fSignal); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("team set job control state, team %ld, " + "new state: %s, signal: %d", + fTeam, job_control_state_name(fNewState), fSignal); + } - private: - team_id fTeam; - job_control_state fNewState; - int fSignal; +private: + team_id fTeam; + job_control_state fNewState; + int fSignal; }; class WaitForChild : public AbstractTraceEntry { - public: - WaitForChild(pid_t child, uint32 flags) - : - fChild(child), - fFlags(flags) - { - Initialized(); - } +public: + WaitForChild(pid_t child, uint32 flags) + : + fChild(child), + fFlags(flags) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - out.Print("team wait for child, child: %ld, " - "flags: 0x%lx", fChild, fFlags); - } + virtual void AddDump(TraceOutput& out) + { + out.Print("team wait for child, child: %ld, " + "flags: 0x%lx", fChild, fFlags); + } - private: - pid_t fChild; - uint32 fFlags; +private: + pid_t fChild; + uint32 fFlags; }; class WaitForChildDone : public AbstractTraceEntry { - public: - WaitForChildDone(const job_control_entry& entry) - : - fState(entry.state), - fTeam(entry.thread), - fStatus(entry.status), - fReason(entry.reason), - fSignal(entry.signal) - { - Initialized(); - } +public: + WaitForChildDone(const job_control_entry& entry) + : + fState(entry.state), + fTeam(entry.thread), + fStatus(entry.status), + fReason(entry.reason), + fSignal(entry.signal) + { + Initialized(); + } - WaitForChildDone(status_t error) - : - fTeam(error) - { - Initialized(); - } + WaitForChildDone(status_t error) + : + fTeam(error) + { + Initialized(); + } - virtual void AddDump(TraceOutput& out) - { - if (fTeam >= 0) { - out.Print("team wait for child done, team: %ld, " - "state: %s, status: 0x%lx, reason: 0x%x, signal: %d\n", - fTeam, job_control_state_name(fState), fStatus, fReason, - fSignal); - } else { - out.Print("team wait for child failed, error: " - "0x%lx, ", fTeam); - } + virtual void AddDump(TraceOutput& out) + { + if (fTeam >= 0) { + out.Print("team wait for child done, team: %ld, " + "state: %s, status: 0x%lx, reason: 0x%x, signal: %d\n", + fTeam, job_control_state_name(fState), fStatus, fReason, + fSignal); + } else { + out.Print("team wait for child failed, error: " + "0x%lx, ", fTeam); } + } - private: - job_control_state fState; - team_id fTeam; - status_t fStatus; - uint16 fReason; - uint16 fSignal; +private: + job_control_state fState; + team_id fTeam; + status_t fStatus; + uint16 fReason; + uint16 fSignal; }; } // namespace TeamTracing @@ -1639,7 +1639,7 @@ job_control_entry::~job_control_entry() { if (has_group_ref) { - InterruptsSpinLocker locker(team_spinlock); + InterruptsSpinLocker locker(gTeamSpinlock); release_process_group_ref(group_id); } } @@ -1706,7 +1706,7 @@ bool ignoreFoundEntriesChecked = false; while (true) { - InterruptsSpinLocker locker(team_spinlock); + InterruptsSpinLocker locker(gTeamSpinlock); // check whether any condition holds job_control_entry* entry = get_job_control_entry(team, child, flags); @@ -1820,7 +1820,7 @@ // If SIGCHLD is blocked, we shall clear pending SIGCHLDs, if no other child // status is available. if (is_signal_blocked(SIGCHLD)) { - InterruptsSpinLocker locker(team_spinlock); + InterruptsSpinLocker locker(gTeamSpinlock); if (get_job_control_entry(team, child, flags) == NULL) atomic_and(&thread->sig_pending, ~SIGNAL_TO_MASK(SIGCHLD)); @@ -1905,7 +1905,7 @@ static bool process_group_has_stopped_processes(process_group* group) { - SpinLocker _(thread_spinlock); + SpinLocker _(gThreadSpinlock); struct team* team = group->teams; while (team != NULL) { @@ -2101,7 +2101,7 @@ { struct team* team = thread_get_current_thread()->team; - InterruptsSpinLocker _(team_spinlock); + InterruptsSpinLocker _(gTeamSpinlock); [... truncated: 220 lines follow ...] From axeld at mail.berlios.de Sat Aug 2 17:03:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 17:03:03 +0200 Subject: [Haiku-commits] r26731 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm src/system/libroot/os Message-ID: <200808021503.m72F33ZT025606@sheep.berlios.de> Author: axeld Date: 2008-08-02 17:03:03 +0200 (Sat, 02 Aug 2008) New Revision: 26731 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26731&view=rev Modified: haiku/trunk/headers/private/kernel/kernel.h haiku/trunk/src/system/kernel/heap.cpp haiku/trunk/src/system/kernel/lock.cpp haiku/trunk/src/system/kernel/main.cpp haiku/trunk/src/system/kernel/sem.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/libroot/os/driver_settings.c Log: * Renamed kernel_startup to gKernelStartup. Modified: haiku/trunk/headers/private/kernel/kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel.h 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/headers/private/kernel/kernel.h 2008-08-02 15:03:03 UTC (rev 26731) @@ -47,7 +47,7 @@ #define CLEAR_BIT(a, b) ((a) & (~(1 << (b)))) /* during kernel startup, interrupts are disabled (among other things) */ -extern bool kernel_startup; +extern bool gKernelStartup; #ifdef __cplusplus Modified: haiku/trunk/src/system/kernel/heap.cpp =================================================================== --- haiku/trunk/src/system/kernel/heap.cpp 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/kernel/heap.cpp 2008-08-02 15:03:03 UTC (rev 26731) @@ -260,7 +260,7 @@ } // namespace KernelHeapTracing -# define T(x) if (!kernel_startup) new(std::nothrow) KernelHeapTracing::x; +# define T(x) if (!gKernelStartup) new(std::nothrow) KernelHeapTracing::x; #else # define T(x) ; #endif @@ -1211,8 +1211,8 @@ heap_leak_check_info *info = (heap_leak_check_info *)((addr_t)address + bin->element_size - sizeof(heap_leak_check_info)); info->size = size - sizeof(heap_leak_check_info); - info->thread = (kernel_startup ? 0 : thread_get_current_thread_id()); - info->team = (kernel_startup ? 0 : team_get_current_team_id()); + info->thread = (gKernelStartup ? 0 : thread_get_current_thread_id()); + info->team = (gKernelStartup ? 0 : team_get_current_team_id()); info->caller = get_caller(); #endif return address; @@ -1231,8 +1231,8 @@ + (firstPage->index + pageCount) * heap->page_size - sizeof(heap_leak_check_info)); info->size = size - sizeof(heap_leak_check_info); - info->thread = (kernel_startup ? 0 : thread_get_current_thread_id()); - info->team = (kernel_startup ? 0 : team_get_current_team_id()); + info->thread = (gKernelStartup ? 0 : thread_get_current_thread_id()); + info->team = (gKernelStartup ? 0 : team_get_current_team_id()); info->caller = get_caller(); #endif return (void *)(firstPage->area->base + firstPage->index * heap->page_size); @@ -1759,12 +1759,12 @@ void * memalign(size_t alignment, size_t size) { - if (!kernel_startup && !are_interrupts_enabled()) { + if (!gKernelStartup && !are_interrupts_enabled()) { panic("memalign(): called with interrupts disabled\n"); return NULL; } - if (!kernel_startup && size > HEAP_AREA_USE_THRESHOLD) { + if (!gKernelStartup && size > HEAP_AREA_USE_THRESHOLD) { // don't even attempt such a huge allocation - use areas instead size_t areaSize = size + sizeof(area_allocation_info); if (alignment != 0) @@ -1875,7 +1875,7 @@ void free(void *address) { - if (!kernel_startup && !are_interrupts_enabled()) { + if (!gKernelStartup && !are_interrupts_enabled()) { panic("free(): called with interrupts disabled\n"); return; } @@ -1917,7 +1917,7 @@ void * realloc(void *address, size_t newSize) { - if (!kernel_startup && !are_interrupts_enabled()) { + if (!gKernelStartup && !are_interrupts_enabled()) { panic("realloc(): called with interrupts disabled\n"); return NULL; } Modified: haiku/trunk/src/system/kernel/lock.cpp =================================================================== --- haiku/trunk/src/system/kernel/lock.cpp 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/kernel/lock.cpp 2008-08-02 15:03:03 UTC (rev 26731) @@ -92,7 +92,7 @@ { thread_id thread = thread_get_current_thread_id(); - if (!kernel_startup && !are_interrupts_enabled()) { + if (!gKernelStartup && !are_interrupts_enabled()) { panic("recursive_lock_lock: called with interrupts disabled for lock " "%p (\"%s\")\n", lock, lock->lock.name); } @@ -114,7 +114,7 @@ { thread_id thread = thread_get_current_thread_id(); - if (!kernel_startup && !are_interrupts_enabled()) + if (!gKernelStartup && !are_interrupts_enabled()) panic("recursive_lock_lock: called with interrupts disabled for lock " "%p (\"%s\")\n", lock, lock->lock.name); @@ -500,7 +500,7 @@ _mutex_lock(mutex* lock, bool threadsLocked) { #ifdef KDEBUG - if (!kernel_startup && !threadsLocked && !are_interrupts_enabled()) { + if (!gKernelStartup && !threadsLocked && !are_interrupts_enabled()) { panic("_mutex_lock(): called with interrupts disabled for lock %p", lock); } Modified: haiku/trunk/src/system/kernel/main.cpp =================================================================== --- haiku/trunk/src/system/kernel/main.cpp 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/kernel/main.cpp 2008-08-02 15:03:03 UTC (rev 26731) @@ -61,7 +61,7 @@ # define TRACE(x...) ; #endif -bool kernel_startup = true; +bool gKernelStartup = true; static kernel_args sKernelArgs; static uint32 sCpuRendezvous; @@ -191,7 +191,7 @@ // exit the kernel startup phase (mutexes, etc work from now on out) TRACE("exiting kernel startup\n"); - kernel_startup = false; + gKernelStartup = false; smp_cpu_rendezvous(&sCpuRendezvous2, 0); // release the AP cpus to go enter the scheduler Modified: haiku/trunk/src/system/kernel/sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 15:03:03 UTC (rev 26731) @@ -711,7 +711,7 @@ int state; status_t status = B_OK; - if (kernel_startup) + if (gKernelStartup) return B_OK; if (sSemsActive == false) return B_NO_MORE_SEMS; @@ -869,7 +869,7 @@ { int32 slot = id % sMaxSems; - if (kernel_startup) + if (gKernelStartup) return B_OK; if (sSemsActive == false) return B_NO_MORE_SEMS; Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-02 15:03:03 UTC (rev 26731) @@ -1744,7 +1744,7 @@ vm_translation_map *map = &addressSpace->translation_map; off_t offset = 0; - if (!kernel_startup) + if (!gKernelStartup) panic("ALREADY_WIRED flag used outside kernel startup\n"); cache->Lock(); @@ -2918,16 +2918,16 @@ address = ROUNDOWN(address, B_PAGE_SIZE); - kernel_startup = true; + gKernelStartup = true; // vm_get_physical_page() needs to lock... if (vm_get_physical_page(address, ©Address, PHYSICAL_PAGE_NO_WAIT) != B_OK) { kprintf("getting the hardware page failed."); - kernel_startup = false; + gKernelStartup = false; return 0; } - kernel_startup = false; + gKernelStartup = false; address += offset; copyAddress += offset; } else @@ -3015,9 +3015,9 @@ if (physical) { copyAddress = ROUNDOWN(copyAddress, B_PAGE_SIZE); - kernel_startup = true; + gKernelStartup = true; vm_put_physical_page(copyAddress); - kernel_startup = false; + gKernelStartup = false; } return 0; } Modified: haiku/trunk/src/system/libroot/os/driver_settings.c =================================================================== --- haiku/trunk/src/system/libroot/os/driver_settings.c 2008-08-02 14:55:53 UTC (rev 26730) +++ haiku/trunk/src/system/libroot/os/driver_settings.c 2008-08-02 15:03:03 UTC (rev 26731) @@ -321,7 +321,7 @@ * sizeof(struct driver_parameter)); if (newArray == NULL) return B_NO_MEMORY; - + memcpy(&newArray[*_count], ¶meter, sizeof(struct driver_parameter)); newParameter = &newArray[*_count]; @@ -688,7 +688,7 @@ { settings_handle *handle; int file = -1; - + if (driverName == NULL) return NULL; @@ -715,7 +715,7 @@ } // we are allowed to call the driver settings pretty early in the boot process - if (kernel_startup) { + if (gKernelStartup) { mutex_unlock(&sLock); return NULL; } From axeld at mail.berlios.de Sat Aug 2 17:04:47 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 17:04:47 +0200 Subject: [Haiku-commits] r26732 - haiku/trunk/src/system/kernel Message-ID: <200808021504.m72F4l78025774@sheep.berlios.de> Author: axeld Date: 2008-08-02 17:04:47 +0200 (Sat, 02 Aug 2008) New Revision: 26732 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26732&view=rev Modified: haiku/trunk/src/system/kernel/sem.cpp Log: * Renamed sem_spinlock to sSemsSpinlock. Modified: haiku/trunk/src/system/kernel/sem.cpp =================================================================== --- haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 15:03:03 UTC (rev 26731) +++ haiku/trunk/src/system/kernel/sem.cpp 2008-08-02 15:04:47 UTC (rev 26732) @@ -107,9 +107,9 @@ static struct sem_entry *sFreeSemsHead = NULL; static struct sem_entry *sFreeSemsTail = NULL; -static spinlock sem_spinlock = B_SPINLOCK_INITIALIZER; -#define GRAB_SEM_LIST_LOCK() acquire_spinlock(&sem_spinlock) -#define RELEASE_SEM_LIST_LOCK() release_spinlock(&sem_spinlock) +static spinlock sSemsSpinlock = B_SPINLOCK_INITIALIZER; +#define GRAB_SEM_LIST_LOCK() acquire_spinlock(&sSemsSpinlock) +#define RELEASE_SEM_LIST_LOCK() release_spinlock(&sSemsSpinlock) #define GRAB_SEM_LOCK(s) acquire_spinlock(&(s).lock) #define RELEASE_SEM_LOCK(s) release_spinlock(&(s).lock) From ingo_weinhold at gmx.de Sat Aug 2 17:14:57 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 02 Aug 2008 17:14:57 +0200 Subject: [Haiku-commits] r26715 - haiku/trunk/src/add-ons/kernel/file_systems/bfs In-Reply-To: <50649257518-BeMail@zon> References: <50649257518-BeMail@zon> Message-ID: <20080802171457.515.1@knochen-vm.localdomain> On 2008-08-01 at 23:10:47 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2008-08-01 at 14:28:30 [+0200], axeld at BerliOS < > > axeld at mail.berlios.de> > > wrote: > > > - locker.Lock(); > > > + // TODO: we actually need to call WriteLockInTransaction() > > > here, but we > > > + // cannot do this with the current locking model (ie. file > > > cache > > > functions > > > + // are not to be called with the inode lock held). > > > + // But this cannot work anyway, since we hold the lock when > > > calling > > > + // file_cache_set_size(), too... (possible deadlock) > > > + rw_lock_write_lock(&fLock); > > I don't think the VFS/VM locking is to blame here. At least I can't > > see how > > to change it to avoid this problem. What could help is a different > > locking/transaction model in the BFS implementation. Changes in a > > transaction > > could be invisible to others until committed. I.e. in this case the > > file's > > size would be changed, but a reader could still access the file at > > the same > > While this might help, I don't really see how we can make this a > requirement for file system implementations. Furthermore, the file > cache itself needs to be transaction aware as well in the future, and > this wouldn't really simplify the matter. > The only actual problem is the page writer, of course, as this one > doesn't go through the file system to write a page, but its cache > directly. Therefore, it locks the cache first, and the file system must > still be able to perform additional locking to prevent changes to the > disk structure. Actually the page writer doesn't have the cache lock when it enters the file system. It has marked pages busy though, and the file cache waits for busy pages. So the outcome would be pretty much the same (i.e. a deadlock), if the file_cache_write() were entered with the inode write lock held. > If BFS could lock the cache when doing changes to the inode, maybe we > can get around the requirement of any additional locking in the I/O > functions. Holding the cache lock would then be very similar to holding > the read lock - it prevents changes unless you have already write > locked the inode. This would also mean that we provide VMCache methods > that require the caller to lock the cache. > Does this sound like a possible solution? I don't see how that would work. Since the cache is not locked while doing I/O (and I don't think doing that would be a good idea), locking the cache while changing the inode will have no further effect. What could work is to add FS hooks to read lock/unlock the node. The page writer could then acquire the node lock before marking the page busy. Entering the file cache would thus require the read lock to be held and the io() hook wouldn't do any locking anymore. bfs_write() could thus also keep the write lock during the whole time, although that has the obvious disadvantage that it totally kills parallelism. The page writer wouldn't be able to write back any page from a file that is written to. Since the file cache might need pages for writing to the file, this could lead to a deadlock situation. > > time and would see the file with the old size. Another writer could > > also > > write in parallel, unless it would cause the file to be resized as > > well. I > > don't know how well the BFS structures allow to implement it this way > > though. > > We would need to change the block cache to be able to use a different > visibility models, but BFS would need to remember the last transaction > for read access as well. > When I wrote the block cache and designed its API, I stayed away from > this, as this would require a lot of changes in BFS in the read path. I > wanted to review that stuff once the file cache supported transactions > as well. > I think it would be best if the block and file caches would support > different models to be chosen by the file system. I'm not convinced that different models will be necessary. A single model that works for all file systems would be best IMHO. Anyway, back to the current situation: Unless I miss something the only real problem ATM is that bfs_write() doesn't hold the write lock when the transaction is rolled back. This can be easily remedied by re-locking the Inode in Inode::WriteAt() after the file_cache_write(). This will at least prevent readers from accessing inconsistent blocks. Though they might read the not-yet-overwritten garbage at the end of the file during the time the node is not write locked. But that can only be avoided by killing all parallelism in that situation, or by changing our transaction support so that changes done in the transaction won't be visible to others until the transaction is committed. CU, Ingo From axeld at mail.berlios.de Sat Aug 2 17:50:51 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 17:50:51 +0200 Subject: [Haiku-commits] r26733 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200808021550.m72Fop1W029706@sheep.berlios.de> Author: axeld Date: 2008-08-02 17:50:50 +0200 (Sat, 02 Aug 2008) New Revision: 26733 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26733&view=rev Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c Log: * Removed the feature_string from the cpu_ent structure. * Dumping the features as string is now a one time thing, that only happens when DUMP_FEATURE_STRING is defined to 1. Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-02 15:04:47 UTC (rev 26732) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-02 15:50:50 UTC (rev 26733) @@ -228,7 +228,6 @@ int stepping; int model; int extended_model; - char feature_string[256]; // local TSS for this cpu struct tss tss; Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-08-02 15:04:47 UTC (rev 26732) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-08-02 15:50:50 UTC (rev 26733) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -26,6 +26,9 @@ #include "interrupts.h" +#define DUMP_FEATURE_STRING 1 + + /* cpu vendor info */ struct cpu_vendor_info { const char *vendor; @@ -212,7 +215,7 @@ /* set up the double fault tss */ /* TODO: Axel - fix SMP support */ struct tss *tss = &gCPU[cpuNum].arch.double_fault_tss; - + memset(tss, 0, sizeof(struct tss)); tss->sp0 = (uint32)sDoubleFaultStack + sizeof(sDoubleFaultStack); tss->ss0 = KERNEL_DATA_SEG; @@ -235,105 +238,110 @@ } +#if DUMP_FEATURE_STRING static void -make_feature_string(cpu_ent *cpu, char *str, size_t strlen) +dump_feature_string(int currentCPU, cpu_ent *cpu) { - str[0] = 0; + char features[256]; + features[0] = 0; if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_FPU) - strlcat(str, "fpu ", strlen); + strlcat(features, "fpu ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_VME) - strlcat(str, "vme ", strlen); + strlcat(features, "vme ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_DE) - strlcat(str, "de ", strlen); + strlcat(features, "de ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PSE) - strlcat(str, "pse ", strlen); + strlcat(features, "pse ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_TSC) - strlcat(str, "tsc ", strlen); + strlcat(features, "tsc ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_MSR) - strlcat(str, "msr ", strlen); + strlcat(features, "msr ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PAE) - strlcat(str, "pae ", strlen); + strlcat(features, "pae ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_MCE) - strlcat(str, "mce ", strlen); + strlcat(features, "mce ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_CX8) - strlcat(str, "cx8 ", strlen); + strlcat(features, "cx8 ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_APIC) - strlcat(str, "apic ", strlen); + strlcat(features, "apic ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_SEP) - strlcat(str, "sep ", strlen); + strlcat(features, "sep ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_MTRR) - strlcat(str, "mtrr ", strlen); + strlcat(features, "mtrr ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PGE) - strlcat(str, "pge ", strlen); + strlcat(features, "pge ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_MCA) - strlcat(str, "mca ", strlen); + strlcat(features, "mca ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_CMOV) - strlcat(str, "cmov ", strlen); + strlcat(features, "cmov ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PAT) - strlcat(str, "pat ", strlen); + strlcat(features, "pat ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PSE36) - strlcat(str, "pse36 ", strlen); + strlcat(features, "pse36 ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PSN) - strlcat(str, "psn ", strlen); + strlcat(features, "psn ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_CLFSH) - strlcat(str, "clfsh ", strlen); + strlcat(features, "clfsh ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_DS) - strlcat(str, "ds ", strlen); + strlcat(features, "ds ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_ACPI) - strlcat(str, "acpi ", strlen); + strlcat(features, "acpi ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_MMX) - strlcat(str, "mmx ", strlen); + strlcat(features, "mmx ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_FXSR) - strlcat(str, "fxsr ", strlen); + strlcat(features, "fxsr ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_SSE) - strlcat(str, "sse ", strlen); + strlcat(features, "sse ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_SSE2) - strlcat(str, "sse2 ", strlen); + strlcat(features, "sse2 ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_SS) - strlcat(str, "ss ", strlen); + strlcat(features, "ss ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_HTT) - strlcat(str, "htt ", strlen); + strlcat(features, "htt ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_TM) - strlcat(str, "tm ", strlen); + strlcat(features, "tm ", sizeof(features)); if (cpu->arch.feature[FEATURE_COMMON] & IA32_FEATURE_PBE) - strlcat(str, "pbe ", strlen); + strlcat(features, "pbe ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_SSE3) - strlcat(str, "sse3 ", strlen); + strlcat(features, "sse3 ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_MONITOR) - strlcat(str, "monitor ", strlen); + strlcat(features, "monitor ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_DSCPL) - strlcat(str, "dscpl ", strlen); + strlcat(features, "dscpl ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_EST) - strlcat(str, "est ", strlen); + strlcat(features, "est ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_TM2) - strlcat(str, "tm2 ", strlen); + strlcat(features, "tm2 ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT] & IA32_FEATURE_EXT_CNXTID) - strlcat(str, "cnxtid ", strlen); + strlcat(features, "cnxtid ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_SYSCALL) - strlcat(str, "syscall ", strlen); + strlcat(features, "syscall ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_NX) - strlcat(str, "nx ", strlen); + strlcat(features, "nx ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_MMXEXT) - strlcat(str, "mmxext ", strlen); + strlcat(features, "mmxext ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_FFXSR) - strlcat(str, "ffxsr ", strlen); + strlcat(features, "ffxsr ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_LONG) - strlcat(str, "long ", strlen); + strlcat(features, "long ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_3DNOWEXT) - strlcat(str, "3dnowext ", strlen); + strlcat(features, "3dnowext ", sizeof(features)); if (cpu->arch.feature[FEATURE_EXT_AMD] & IA32_FEATURE_AMD_EXT_3DNOW) - strlcat(str, "3dnow ", strlen); + strlcat(features, "3dnow ", sizeof(features)); + + dprintf("CPU %d: features: %s\n", currentCPU, features); } +#endif // DUMP_FEATURE_STRING static int -detect_cpu(int curr_cpu) +detect_cpu(int currentCPU) { + cpu_ent *cpu = get_cpu_struct(); + char vendorString[17]; cpuid_info cpuid; - char vendor_str[17]; int i; - cpu_ent *cpu = get_cpu_struct(); // clear out the cpu info data cpu->arch.vendor = VENDOR_UNKNOWN; @@ -347,8 +355,8 @@ get_current_cpuid(&cpuid, 0); // build the vendor string - memset(vendor_str, 0, sizeof(vendor_str)); - memcpy(vendor_str, cpuid.eax_0.vendor_id, sizeof(cpuid.eax_0.vendor_id)); + memset(vendorString, 0, sizeof(vendorString)); + memcpy(vendorString, cpuid.eax_0.vendor_id, sizeof(cpuid.eax_0.vendor_id)); // get the family, model, stepping get_current_cpuid(&cpuid, 1); @@ -360,19 +368,19 @@ cpu->arch.stepping = cpuid.eax_1.stepping; dprintf("CPU %d: type %d family %d extended_family %d model %d " "extended_model %d stepping %d, string '%s'\n", - curr_cpu, cpu->arch.type, cpu->arch.family, + currentCPU, cpu->arch.type, cpu->arch.family, cpu->arch.extended_family, cpu->arch.model, - cpu->arch.extended_model, cpu->arch.stepping, vendor_str); + cpu->arch.extended_model, cpu->arch.stepping, vendorString); // figure out what vendor we have here for (i = 0; i < VENDOR_NUM; i++) { - if (vendor_info[i].ident_string[0] && !strcmp(vendor_str, vendor_info[i].ident_string[0])) { + if (vendor_info[i].ident_string[0] && !strcmp(vendorString, vendor_info[i].ident_string[0])) { cpu->arch.vendor = i; cpu->arch.vendor_name = vendor_info[i].vendor; break; } - if (vendor_info[i].ident_string[1] && !strcmp(vendor_str, vendor_info[i].ident_string[1])) { + if (vendor_info[i].ident_string[1] && !strcmp(vendorString, vendor_info[i].ident_string[1])) { cpu->arch.vendor = i; cpu->arch.vendor_name = vendor_info[i].vendor; break; @@ -399,13 +407,13 @@ for (i = 0; cpu->arch.model_name[i] == ' '; i++) ; if (i > 0) { - memmove(cpu->arch.model_name, - &cpu->arch.model_name[i], + memmove(cpu->arch.model_name, + &cpu->arch.model_name[i], strlen(&cpu->arch.model_name[i]) + 1); } - dprintf("CPU %d: vendor '%s' model name '%s'\n", - curr_cpu, cpu->arch.vendor_name, cpu->arch.model_name); + dprintf("CPU %d: vendor '%s' model name '%s'\n", + currentCPU, cpu->arch.vendor_name, cpu->arch.model_name); } else { strcpy(cpu->arch.model_name, "unknown"); } @@ -419,8 +427,9 @@ cpu->arch.feature[FEATURE_EXT_AMD] = cpuid.regs.edx; // edx } - make_feature_string(cpu, cpu->arch.feature_string, sizeof(cpu->arch.feature_string)); - dprintf("CPU %d: features: %s\n", curr_cpu, cpu->arch.feature_string); +#if DUMP_FEATURE_STRING + dump_feature_string(currentCPU, cpu); +#endif return 0; } @@ -439,7 +448,7 @@ } #endif - return (cpu->arch.feature[type] & feature) ? TRUE : FALSE; + return (cpu->arch.feature[type] & feature) != 0; } @@ -447,7 +456,7 @@ status_t -arch_cpu_preboot_init_percpu(kernel_args *args, int curr_cpu) +arch_cpu_preboot_init_percpu(kernel_args *args, int cpu) { x86_write_cr0(x86_read_cr0() & ~(CR0_FPU_EMULATION | CR0_MONITOR_FPU)); gX86SwapFPUFunc = i386_fnsave_swap; @@ -456,15 +465,15 @@ } -status_t -arch_cpu_init_percpu(kernel_args *args, int curr_cpu) +status_t +arch_cpu_init_percpu(kernel_args *args, int cpu) { - detect_cpu(curr_cpu); + detect_cpu(cpu); // load the TSS for this cpu // note the main cpu gets initialized in arch_cpu_init_post_vm() - if (curr_cpu != 0) - load_tss(curr_cpu); + if (cpu != 0) + load_tss(cpu); return 0; } @@ -629,7 +638,7 @@ if (size > 0) { to[--size] = '\0'; - // copy + // copy for ( ; size; size--, fromLength++, to++, from++) { if ((*to = *from) == '\0') break; From axeld at mail.berlios.de Sat Aug 2 18:23:22 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 18:23:22 +0200 Subject: [Haiku-commits] r26734 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200808021623.m72GNMpW032437@sheep.berlios.de> Author: axeld Date: 2008-08-02 18:23:22 +0200 (Sat, 02 Aug 2008) New Revision: 26734 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26734&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c Log: * Minor cleanup. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2008-08-02 15:50:50 UTC (rev 26733) +++ haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2008-08-02 16:23:22 UTC (rev 26734) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -47,10 +47,10 @@ static void call_ctors(void) -{ +{ void (**f)(void); - for (f = &__ctor_list; f < &__ctor_end; f++) { + for (f = &__ctor_list; f < &__ctor_end; f++) { (**f)(); } } @@ -74,14 +74,16 @@ // something goes wrong when we pass &gKernelArgs directly // to the assembler inline below - might be a bug in GCC // or I don't see something important... - addr_t stackTop = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; + addr_t stackTop + = gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size; smp_init_other_cpus(); serial_cleanup(); mmu_init_for_kernel(); smp_boot_other_cpus(); - dprintf("kernel entry at %lx\n", gKernelArgs.kernel_image.elf_header.e_entry); + dprintf("kernel entry at %lx\n", + gKernelArgs.kernel_image.elf_header.e_entry); asm("movl %0, %%eax; " // move stack out of way "movl %%eax, %%esp; " @@ -127,7 +129,8 @@ // wait a bit to give the user the opportunity to press a key spin(750000); - // reading the keyboard doesn't seem to work in graphics mode (maybe a bochs problem) + // reading the keyboard doesn't seem to work in graphics mode + // (maybe a bochs problem) sBootOptions = check_for_boot_keys(); //if (sBootOptions & BOOT_OPTION_DEBUG_OUTPUT) serial_enable(); From axeld at mail.berlios.de Sat Aug 2 18:25:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 2 Aug 2008 18:25:16 +0200 Subject: [Haiku-commits] r26735 - haiku/trunk/src/system/kernel/debug Message-ID: <200808021625.m72GPGo8032543@sheep.berlios.de> Author: axeld Date: 2008-08-02 18:25:16 +0200 (Sat, 02 Aug 2008) New Revision: 26735 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26735&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.cpp Log: * thread_preboot_init_percpu() sets the current thread pointer with a mostly empty thread structure. This causes the thread::team pointer to be NULL during the early boot process, but our kernel debugger didn't like that. Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-08-02 16:23:22 UTC (rev 26734) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-08-02 16:25:16 UTC (rev 26735) @@ -657,7 +657,8 @@ set_debug_variable("_thread", (uint64)(addr_t)thread); set_debug_variable("_threadID", thread->id); set_debug_variable("_team", (uint64)(addr_t)thread->team); - set_debug_variable("_teamID", thread->team->id); + if (thread->team != NULL) + set_debug_variable("_teamID", thread->team->id); set_debug_variable("_cpu", sDebuggerOnCPU); kprintf("Thread %ld \"%s\" running on CPU %ld\n", thread->id, From bonefish at mail.berlios.de Sat Aug 2 19:41:12 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 2 Aug 2008 19:41:12 +0200 Subject: [Haiku-commits] r26736 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808021741.m72HfCSM030259@sheep.berlios.de> Author: bonefish Date: 2008-08-02 19:41:03 +0200 (Sat, 02 Aug 2008) New Revision: 26736 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26736&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp Log: * Fixed recently introduced write lock leak, when something failed before file_cache_write() or nothing had to be written. * Fixed race condition. While neither transaction nor read lock are held, the file size can change. * Add the inode to the transaction whenever possible, i.e. on error before file_cache_write() and after it as well. This should prevent readers from seeing inconsistent blocks when the transaction has to be rolled back. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-02 16:25:16 UTC (rev 26735) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-02 17:41:03 UTC (rev 26736) @@ -1412,33 +1412,34 @@ // TODO: support INODE_LOGGED! size_t length = *_length; - bool changeSize = false; + bool changeSize = pos + length > Size(); // set/check boundaries for pos/length if (pos < 0) return B_BAD_VALUE; - if (pos + length > Size()) - changeSize = true; - locker.Unlock(); // the transaction doesn't have to be started already if (changeSize && !transaction.IsStarted()) transaction.Start(fVolume, BlockNumber()); - // TODO: we actually need to call WriteLockInTransaction() here, but we - // cannot do this with the current locking model (ie. file cache functions - // are not to be called with the inode lock held). - // But this cannot work anyway, since we hold the lock when calling - // file_cache_set_size(), too... (possible deadlock) - rw_lock_write_lock(&fLock); + WriteLocker writeLocker(fLock); + // Work around possible race condition: Someone might have shrunken the file + // while we had no lock. + if (!transaction.IsStarted() && pos + length > Size()) { + writeLocker.Unlock(); + transaction.Start(fVolume, BlockNumber()); + writeLocker.Lock(); + } + if (pos + length > Size()) { // let's grow the data stream to the size needed status_t status = SetFileSize(transaction, pos + length); if (status < B_OK) { *_length = 0; + WriteLockInTransaction(transaction); RETURN_ERROR(status); } // TODO: In theory we would need to update the file size @@ -1449,18 +1450,25 @@ // go into this transaction (we cannot wait until the file // is closed) status = WriteBack(transaction); - if (status < B_OK) + if (status < B_OK) { + WriteLockInTransaction(transaction); return status; + } } + writeLocker.Unlock(); + // If we don't want to write anything, we can now return (we may // just have changed the file size using the position parameter) if (length == 0) return B_OK; - rw_lock_write_unlock(&fLock); + status_t status = file_cache_write(FileCache(), NULL, pos, buffer, _length); - return file_cache_write(FileCache(), NULL, pos, buffer, _length); + if (transaction.IsStarted()) + WriteLockInTransaction(transaction); + + return status; } From stippi at mail.berlios.de Sat Aug 2 20:43:26 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Aug 2008 20:43:26 +0200 Subject: [Haiku-commits] r26737 - in haiku/trunk: data/artwork/icons src/add-ons/tracker src/add-ons/tracker/text_search Message-ID: <200808021843.m72IhQ8U005063@sheep.berlios.de> Author: stippi Date: 2008-08-02 20:43:22 +0200 (Sat, 02 Aug 2008) New Revision: 26737 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26737&view=rev Added: haiku/trunk/data/artwork/icons/App_TextSearch haiku/trunk/src/add-ons/tracker/text_search/ haiku/trunk/src/add-ons/tracker/text_search/GlobalDefs.h haiku/trunk/src/add-ons/tracker/text_search/GrepApp.cpp haiku/trunk/src/add-ons/tracker/text_search/GrepApp.h haiku/trunk/src/add-ons/tracker/text_search/GrepListView.cpp haiku/trunk/src/add-ons/tracker/text_search/GrepListView.h haiku/trunk/src/add-ons/tracker/text_search/GrepWindow.cpp haiku/trunk/src/add-ons/tracker/text_search/GrepWindow.h haiku/trunk/src/add-ons/tracker/text_search/Grepper.cpp haiku/trunk/src/add-ons/tracker/text_search/Grepper.h haiku/trunk/src/add-ons/tracker/text_search/Jamfile haiku/trunk/src/add-ons/tracker/text_search/Model.cpp haiku/trunk/src/add-ons/tracker/text_search/Model.h haiku/trunk/src/add-ons/tracker/text_search/TextSearch.cpp haiku/trunk/src/add-ons/tracker/text_search/TextSearch.rdef haiku/trunk/src/add-ons/tracker/text_search/Translation.h Modified: haiku/trunk/src/add-ons/tracker/Jamfile Log: * Imported Tracker Grep 5.1 source code * Renamed it to TextSearch * Cleaned up the code to match our coding style (already was almost compliant and the code is very clean and well designed, a pleasure to work with!) * Fixed memory leaks and potential memory leaks in error codepaths * Checked the success of most allocations (GrepWindow is missing) and implemented error code paths * Simplified the code in a few places * Fixed bugs in code that iterated over the selected list items and assumed it found a top level item already while it may not have Added: haiku/trunk/data/artwork/icons/App_TextSearch =================================================================== (Binary files differ) Property changes on: haiku/trunk/data/artwork/icons/App_TextSearch ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: haiku/trunk/src/add-ons/tracker/Jamfile =================================================================== --- haiku/trunk/src/add-ons/tracker/Jamfile 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/Jamfile 2008-08-02 18:43:22 UTC (rev 26737) @@ -3,4 +3,5 @@ SubInclude HAIKU_TOP src add-ons tracker zipomatic ; SubInclude HAIKU_TOP src add-ons tracker filetype ; SubInclude HAIKU_TOP src add-ons tracker mark_as ; +SubInclude HAIKU_TOP src add-ons tracker text_search ; Added: haiku/trunk/src/add-ons/tracker/text_search/GlobalDefs.h =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GlobalDefs.h 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GlobalDefs.h 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2008 Stephan A?mus + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef GLOBAL_DEFS_H +#define GLOBAL_DEFS_H + +#define APP_SIGNATURE "application/x-vnd.mahlzeit.trackergrep" +#define APP_NAME "TextSearch" + +#endif // GLOBAL_DEFS_H Added: haiku/trunk/src/add-ons/tracker/text_search/GrepApp.cpp =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GrepApp.cpp 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GrepApp.cpp 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,133 @@ +/* + * Copyright (c) 1998-2007 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 "GrepApp.h" + +#include + +#include + +#include "GlobalDefs.h" +#include "GrepWindow.h" +#include "Model.h" + + +GrepApp::GrepApp() + : BApplication(APP_SIGNATURE), + fGotArgvOnStartup(false), + fGotRefsOnStartup(false), + fQuitter(NULL) +{ +} + + +GrepApp::~GrepApp() +{ + delete fQuitter; +} + + +void +GrepApp::ArgvReceived(int32 argc, char** argv) +{ + fGotArgvOnStartup = true; + + BMessage message(B_REFS_RECEIVED); + int32 refCount = 0; + + for (int32 i = 1; i < argc; i++) { + BEntry entry(argv[i]); + entry_ref ref; + entry.GetRef(&ref); + + if (entry.Exists()) { + message.AddRef("refs", &ref); + refCount += 1; + } else + printf("%s: File not found: %s\n", argv[0], argv[i]); + } + + if (refCount > 0) + RefsReceived(&message); +} + + +void +GrepApp::RefsReceived(BMessage* message) +{ + if (IsLaunching()) + fGotRefsOnStartup = true; + + new GrepWindow(message); +} + + +void +GrepApp::ReadyToRun() +{ + if (!fGotArgvOnStartup && !fGotRefsOnStartup) + _NewUnfocusedGrepWindow(); + + // TODO: stippi: I don't understand what this is supposed to do: + if (fGotArgvOnStartup && !fGotRefsOnStartup) + PostMessage(B_QUIT_REQUESTED); +} + + +void +GrepApp::MessageReceived(BMessage* message) +{ + switch (message->what) { + case B_SILENT_RELAUNCH: + _NewUnfocusedGrepWindow(); + break; + + case MSG_TRY_QUIT: + _TryQuit(); + break; + + default: + BApplication::MessageReceived(message); + break; + } +} + + +void +GrepApp::_TryQuit() +{ + if (CountWindows() == 0) + PostMessage(B_QUIT_REQUESTED); + + if (CountWindows() == 1 && fQuitter == NULL) { + fQuitter = new BMessageRunner(be_app_messenger, + new BMessage(MSG_TRY_QUIT), 200000, -1); + } +} + + +void +GrepApp::_NewUnfocusedGrepWindow() +{ + BMessage emptyMessage; + new GrepWindow(&emptyMessage); +} Added: haiku/trunk/src/add-ons/tracker/text_search/GrepApp.h =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GrepApp.h 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GrepApp.h 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1998-2007 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 + +#ifndef GREP_APP_H +#define GREP_APP_H + +class GrepApp : public BApplication { +public: + GrepApp(); + virtual ~GrepApp(); + + virtual void ArgvReceived(int32 argc, char** argv); + virtual void RefsReceived(BMessage* message); + virtual void MessageReceived(BMessage* message); + virtual void ReadyToRun(); + +private: + void _TryQuit(); + void _NewUnfocusedGrepWindow(); + + bool fGotArgvOnStartup; + bool fGotRefsOnStartup; + + BMessageRunner* fQuitter; +}; + +#endif // GREP_APP_H Added: haiku/trunk/src/add-ons/tracker/text_search/GrepListView.cpp =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GrepListView.cpp 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GrepListView.cpp 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,42 @@ +/* + * Copyright (c) 1998-2007 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 "GrepListView.h" + +#include + +ResultItem::ResultItem(const entry_ref& ref) + : BStringItem("", 0, false), + ref(ref) +{ + BEntry entry(&ref); + BPath path(&entry); + SetText(path.Path()); +} + + +GrepListView::GrepListView() + : BOutlineListView(BRect(0, 0, 40, 80), "SearchResults", + B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, + B_WILL_DRAW | B_NAVIGABLE) +{ +} Added: haiku/trunk/src/add-ons/tracker/text_search/GrepListView.h =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GrepListView.h 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GrepListView.h 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1998-2007 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 GREP_LIST_VIEW_H +#define GREP_LIST_VIEW_H + +#include +#include +#include + + +class ResultItem : public BStringItem { +public: + ResultItem(const entry_ref& ref); + + entry_ref ref; +}; + + +class GrepListView : public BOutlineListView { +public: + GrepListView(); +}; + +#endif // GREP_LIST_VIEW_H Added: haiku/trunk/src/add-ons/tracker/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/GrepWindow.cpp 2008-08-02 17:41:03 UTC (rev 26736) +++ haiku/trunk/src/add-ons/tracker/text_search/GrepWindow.cpp 2008-08-02 18:43:22 UTC (rev 26737) @@ -0,0 +1,1596 @@ +/* + * Copyright (c) 1998-2007 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 "GrepWindow.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "GlobalDefs.h" +#include "Grepper.h" +#include "Translation.h" + +using std::nothrow; + + +GrepWindow::GrepWindow(BMessage* message) + : BWindow(BRect(0, 0, 1, 1), NULL, B_DOCUMENT_WINDOW, 0), + fSearchText(NULL), + fSearchResults(NULL), + fMenuBar(NULL), + fFileMenu(NULL), + fNew(NULL), + fOpen(NULL), + fClose(NULL), + fAbout(NULL), + fQuit(NULL), + fActionMenu(NULL), + fSelectAll(NULL), + fSearch(NULL), + fTrimSelection(NULL), + fCopyText(NULL), + fSelectInTracker(NULL), + fOpenSelection(NULL), + fPreferencesMenu(NULL), + fRecurseLinks(NULL), + fRecurseDirs(NULL), + fSkipDotDirs(NULL), + fCaseSensitive(NULL), + fEscapeText(NULL), + fTextOnly(NULL), + fInvokePe(NULL), + fShowLinesMenuitem(NULL), + fHistoryMenu(NULL), + fEncodingMenu(NULL), + fUTF8(NULL), + fShiftJIS(NULL), + fEUC(NULL), + fJIS(NULL), + + fShowLinesCheckbox(NULL), + fButton(NULL), + + fGrepper(NULL), + fOldPattern(""), + + fModel(new (nothrow) Model()), + + fFilePanel(NULL) +{ + if (fModel == NULL) + return; + + entry_ref directory; + _InitRefsReceived(&directory, message); + + fModel->fDirectory = directory; + fModel->fSelectedFiles = *message; + fModel->fTarget = this; + + _SetWindowTitle(); + _CreateMenus(); + _CreateViews(); + _LayoutViews(); + _LoadPrefs(); + _TileIfMultipleWindows(); + + Show(); +} + + +GrepWindow::~GrepWindow() +{ + if (fModel->fState == STATE_SEARCH) { + fGrepper->Cancel(); + } + + delete fModel; +} + + +void GrepWindow::FrameResized(float width, float height) +{ + BWindow::FrameResized(width, height); + fModel->fFrame = Frame(); + _SavePrefs(); +} + + +void GrepWindow::FrameMoved(BPoint origin) +{ + BWindow::FrameMoved(origin); + fModel->fFrame = Frame(); + _SavePrefs(); +} + + +void GrepWindow::MenusBeginning() +{ + fModel->FillHistoryMenu(fHistoryMenu); + BWindow::MenusBeginning(); +} + + +void GrepWindow::MenusEnded() +{ + for (int32 t = fHistoryMenu->CountItems(); t > 0; --t) + delete fHistoryMenu->RemoveItem(t - 1); + + BWindow::MenusEnded(); +} + + +void GrepWindow::MessageReceived(BMessage *message) +{ + switch (message->what) { + case B_ABOUT_REQUESTED: + _OnAboutRequested(); + break; + + case MSG_NEW_WINDOW: + _OnNewWindow(); + break; + + case B_SIMPLE_DATA: + _OnFileDrop(message); + break; + + case MSG_OPEN_PANEL: + _OnOpenPanel(); + break; + + case MSG_REFS_RECEIVED: + _OnRefsReceived(message); + break; + + case B_CANCEL: + _OnOpenPanelCancel(); + break; + + case MSG_RECURSE_LINKS: + _OnRecurseLinks(); + break; + + case MSG_RECURSE_DIRS: + _OnRecurseDirs(); + break; + + case MSG_SKIP_DOT_DIRS: + _OnSkipDotDirs(); + break; + + case MSG_CASE_SENSITIVE: + _OnCaseSensitive(); + break; + + case MSG_ESCAPE_TEXT: + _OnEscapeText(); + break; + + case MSG_TEXT_ONLY: + _OnTextOnly(); + break; + + case MSG_INVOKE_PE: + _OnInvokePe(); + break; + + case MSG_SEARCH_TEXT: + _OnSearchText(); + break; + + case MSG_SELECT_HISTORY: + _OnHistoryItem(message); + break; + + case MSG_START_CANCEL: + _OnStartCancel(); + break; + + case MSG_SEARCH_FINISHED: + _OnSearchFinished(); + break; + + case MSG_REPORT_FILE_NAME: + _OnReportFileName(message); + break; + + case MSG_REPORT_RESULT: + _OnReportResult(message); + break; + + case MSG_REPORT_ERROR: + _OnReportError(message); + break; + + case MSG_SELECT_ALL: + _OnSelectAll(message); + break; + + case MSG_TRIM_SELECTION: + _OnTrimSelection(); + break; + + case MSG_COPY_TEXT: + _OnCopyText(); + break; + + case MSG_SELECT_IN_TRACKER: + _OnSelectInTracker(); + break; + + case MSG_MENU_SHOW_LINES: + _OnMenuShowLines(); + break; + + case MSG_CHECKBOX_SHOW_LINES: + _OnCheckboxShowLines(); + break; + + case MSG_OPEN_SELECTION: + // fall through + case MSG_INVOKE_ITEM: + _OnInvokeItem(); + break; + + case MSG_QUIT_NOW: + _OnQuitNow(); + break; + + case 'utf8': + fModel->fEncoding = 0; + break; + + case B_SJIS_CONVERSION: + fModel->fEncoding = B_SJIS_CONVERSION; + break; + + case B_EUC_CONVERSION: + fModel->fEncoding = B_EUC_CONVERSION; + break; + + case B_JIS_CONVERSION: + fModel->fEncoding = B_JIS_CONVERSION; + break; + + default: + BWindow::MessageReceived(message); + break; + } +} + + +void +GrepWindow::Quit() +{ + _SavePrefs(); + + // TODO: stippi: Looks like this could be done + // by maintaining a counter in GrepApp with the number of open + // grep windows... and just quit when it goes zero + if (be_app->Lock()) { + be_app->PostMessage(MSG_TRY_QUIT); + be_app->Unlock(); + BWindow::Quit(); + } +} + + +// #pragma mark - + + +void +GrepWindow::_InitRefsReceived(entry_ref* directory, BMessage* message) +{ + // HACK-HACK-HACK: + // If the user selected a single folder and invoked TextSearch on it, + // but recurse directories is switched off, TextSearch would do nothing. + // In that special case, we'd like it to recurse into that folder (but + // not go any deeper after that). + + type_code code; + int32 count; + message->GetInfo("refs", &code, &count); + + if (count == 0) { + if (message->FindRef("dir_ref", 0, directory) == B_OK) + message->MakeEmpty(); + } + + if (count == 1) { + entry_ref ref; + if (message->FindRef("refs", 0, &ref) == B_OK) { + BEntry entry(&ref, true); + if (entry.IsDirectory()) { + // ok, special case, we use this folder as base directory + // and pretend nothing had been selected: + *directory = ref; + message->MakeEmpty(); + } + } + } +} + + +void +GrepWindow::_SetWindowTitle() +{ + BEntry entry(&fModel->fDirectory, true); + BString title; + if (entry.InitCheck() == B_OK) { + BPath path; + if (entry.GetPath(&path) == B_OK) + title << APP_NAME << ": " << path.Path(); + } + + if (!title.Length()) + title = APP_NAME; + + SetTitle(title.String()); +} + + +void +GrepWindow::_CreateMenus() +{ + fMenuBar = new BMenuBar(BRect(0,0,1,1), "menubar"); + + fFileMenu = new BMenu(_T("File")); + fActionMenu = new BMenu(_T("Actions")); + fPreferencesMenu = new BMenu(_T("Preferences")); + fHistoryMenu = new BMenu(_T("History")); + fEncodingMenu = new BMenu(_T("Encoding")); + + fNew = new BMenuItem( + _T("New Window"), new BMessage(MSG_NEW_WINDOW), 'N'); + + fOpen = new BMenuItem( + _T("Set Which Files to Search"), new BMessage(MSG_OPEN_PANEL), 'F'); + + fClose = new BMenuItem( + _T("Close"), new BMessage(B_QUIT_REQUESTED), 'W'); + + fAbout = new BMenuItem( + _T("About"), new BMessage(B_ABOUT_REQUESTED)); + + fQuit = new BMenuItem( + _T("Quit"), new BMessage(MSG_QUIT_NOW), 'Q'); + + fSearch = new BMenuItem( + _T("Search"), new BMessage(MSG_START_CANCEL), 'S'); + + fSelectAll = new BMenuItem( + _T("Select All"), new BMessage(MSG_SELECT_ALL), 'A'); + + fTrimSelection = new BMenuItem( + _T("Trim to Selection"), new BMessage(MSG_TRIM_SELECTION), 'T'); + + fOpenSelection = new BMenuItem( + _T("Open Selection"), new BMessage(MSG_OPEN_SELECTION), 'O'); + + fSelectInTracker = new BMenuItem( + _T("Show Files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K'); + + fCopyText = new BMenuItem( + _T("Copy Text to Clipboard"), new BMessage(MSG_COPY_TEXT), 'B'); + + fRecurseLinks = new BMenuItem( + _T("Follow symbolic links"), new BMessage(MSG_RECURSE_LINKS)); + + fRecurseDirs = new BMenuItem( + _T("Look in sub-directories"), new BMessage(MSG_RECURSE_DIRS)); + + fSkipDotDirs = new BMenuItem( + _T("Skip sub-directories starting with a dot"), new BMessage(MSG_SKIP_DOT_DIRS)); + + fCaseSensitive = new BMenuItem( + _T("Case sensitive"), new BMessage(MSG_CASE_SENSITIVE)); + + fEscapeText = new BMenuItem( + _T("Escape search text"), new BMessage(MSG_ESCAPE_TEXT)); + + fTextOnly = new BMenuItem( + _T("Text files only"), new BMessage(MSG_TEXT_ONLY)); + + fInvokePe = new BMenuItem( + _T("Open files in Pe"), new BMessage(MSG_INVOKE_PE)); + + fShowLinesMenuitem = new BMenuItem( + _T("Show Lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L'); + fShowLinesMenuitem->SetMarked(true); + + fUTF8 = new BMenuItem("UTF8", new BMessage('utf8')); + fShiftJIS = new BMenuItem("ShiftJIS", new BMessage(B_SJIS_CONVERSION)); + fEUC = new BMenuItem("EUC", new BMessage(B_EUC_CONVERSION)); + fJIS = new BMenuItem("JIS", new BMessage(B_JIS_CONVERSION)); + + fFileMenu->AddItem(fNew); + fFileMenu->AddSeparatorItem(); + fFileMenu->AddItem(fOpen); + fFileMenu->AddItem(fClose); + fFileMenu->AddSeparatorItem(); + fFileMenu->AddItem(fAbout); + fFileMenu->AddSeparatorItem(); + fFileMenu->AddItem(fQuit); + + fActionMenu->AddItem(fSearch); + fActionMenu->AddSeparatorItem(); + fActionMenu->AddItem(fSelectAll); + fActionMenu->AddItem(fTrimSelection); + fActionMenu->AddSeparatorItem(); + fActionMenu->AddItem(fOpenSelection); + fActionMenu->AddItem(fSelectInTracker); + fActionMenu->AddItem(fCopyText); + + fPreferencesMenu->AddItem(fRecurseLinks); + fPreferencesMenu->AddItem(fRecurseDirs); + fPreferencesMenu->AddItem(fSkipDotDirs); + fPreferencesMenu->AddItem(fCaseSensitive); + fPreferencesMenu->AddItem(fEscapeText); + fPreferencesMenu->AddItem(fTextOnly); + fPreferencesMenu->AddItem(fInvokePe); + fPreferencesMenu->AddSeparatorItem(); + fPreferencesMenu->AddItem(fShowLinesMenuitem); + + fEncodingMenu->AddItem(fUTF8); + fEncodingMenu->AddItem(fShiftJIS); + fEncodingMenu->AddItem(fEUC); + fEncodingMenu->AddItem(fJIS); + +// fEncodingMenu->SetLabelFromMarked(true); + // Do we really want this ? + fEncodingMenu->SetRadioMode(true); + fEncodingMenu->ItemAt(0)->SetMarked(true); + + fMenuBar->AddItem(fFileMenu); + fMenuBar->AddItem(fActionMenu); + fMenuBar->AddItem(fPreferencesMenu); + fMenuBar->AddItem(fHistoryMenu); + fMenuBar->AddItem(fEncodingMenu); + + AddChild(fMenuBar); + SetKeyMenuBar(fMenuBar); + + fSearch->SetEnabled(false); +} + + +void +GrepWindow::_CreateViews() +{ + // The search pattern entry field does not send a message when + // is pressed, because the "Search/Cancel" button already + // does this and we don't want to send the same message twice. + + fSearchText = new BTextControl( + BRect(0, 0, 0, 1), "SearchText", NULL, NULL, NULL, + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, + B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE); + + fSearchText->TextView()->SetMaxBytes(1000); + fSearchText->ResizeToPreferred(); + // because it doesn't have a label + + fSearchText->SetModificationMessage(new BMessage(MSG_SEARCH_TEXT)); + + fButton = new BButton( + BRect(0, 1, 80, 1), "Button", _T("Search"), + new BMessage(MSG_START_CANCEL), B_FOLLOW_RIGHT); + + fButton->MakeDefault(true); + fButton->ResizeToPreferred(); + fButton->SetEnabled(false); + + fShowLinesCheckbox = new BCheckBox( + BRect(0, 0, 1, 1), "ShowLines", _T("Show Lines"), + new BMessage(MSG_CHECKBOX_SHOW_LINES), B_FOLLOW_LEFT); + + fShowLinesCheckbox->SetValue(B_CONTROL_ON); + fShowLinesCheckbox->ResizeToPreferred(); + + fSearchResults = new GrepListView(); + + fSearchResults->SetInvocationMessage(new BMessage(MSG_INVOKE_ITEM)); + fSearchResults->ResizeToPreferred(); +} + + +void +GrepWindow::_LayoutViews() +{ + float menubarWidth, menubarHeight = 20; + fMenuBar->GetPreferredSize(&menubarWidth, &menubarHeight); + + BBox *background = new BBox( + BRect(0, menubarHeight + 1, 2, menubarHeight + 2), B_EMPTY_STRING, + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, + B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, + B_PLAIN_BORDER); + + BScrollView *scroller = new BScrollView( + "ScrollSearchResults", fSearchResults, B_FOLLOW_ALL_SIDES, + B_FULL_UPDATE_ON_RESIZE, true, true, B_NO_BORDER); + + scroller->ResizeToPreferred(); + + float width = 8 + fShowLinesCheckbox->Frame().Width() + + 8 + fButton->Frame().Width() + 8; + + float height = 8 + fSearchText->Frame().Height() + 8 + + fButton->Frame().Height() + 8 + scroller->Frame().Height(); + + float backgroundHeight = 8 + fSearchText->Frame().Height() + + 8 + fButton->Frame().Height() + 8; + + ResizeTo(width, height); + + AddChild(background); + background->ResizeTo(width, backgroundHeight); + background->AddChild(fSearchText); + background->AddChild(fShowLinesCheckbox); + background->AddChild(fButton); + + fSearchText->MoveTo(8, 8); + fSearchText->ResizeBy(width - 16, 0); + fSearchText->MakeFocus(true); + + fShowLinesCheckbox->MoveTo( + 8, 8 + fSearchText->Frame().Height() + 8 + + (fButton->Frame().Height() - fShowLinesCheckbox->Frame().Height())/2); + + fButton->MoveTo( + width - fButton->Frame().Width() - 8, + 8 + fSearchText->Frame().Height() + 8); + + AddChild(scroller); + scroller->MoveTo(0, menubarHeight + 1 + backgroundHeight + 1); + scroller->ResizeTo(width + 1, height - backgroundHeight - menubarHeight - 1); + + BRect screenRect = BScreen(this).Frame(); + + MoveTo( + (screenRect.Width() - width) / 2, + (screenRect.Height() - height) / 2); + + SetSizeLimits(width, 10000, height, 10000); +} + + +void +GrepWindow::_TileIfMultipleWindows() +{ + if (be_app->Lock()) { + int32 windowCount = be_app->CountWindows(); + be_app->Unlock(); + + if (windowCount > 1) + MoveBy(20,20); + } + + BScreen screen(this); + BRect screenFrame = screen.Frame(); + BRect windowFrame = Frame(); + + if (windowFrame.left > screenFrame.right + || windowFrame.top > screenFrame.bottom + || windowFrame.right < screenFrame.left + || windowFrame.bottom < screenFrame.top) + MoveTo(50,50); +} + + +// #pragma mark - + + +void +GrepWindow::_LoadPrefs() +{ + Lock(); + + fModel->LoadPrefs(); + + fRecurseDirs->SetMarked(fModel->fRecurseDirs); + fRecurseLinks->SetMarked(fModel->fRecurseLinks); + fSkipDotDirs->SetMarked(fModel->fSkipDotDirs); + fCaseSensitive->SetMarked(fModel->fCaseSensitive); + fEscapeText->SetMarked(fModel->fEscapeText); + fTextOnly->SetMarked(fModel->fTextOnly); + fInvokePe->SetMarked(fModel->fInvokePe); + + fShowLinesCheckbox->SetValue( + fModel->fShowContents ? B_CONTROL_ON : B_CONTROL_OFF); + fShowLinesMenuitem->SetMarked( + fModel->fShowContents ? true : false); + + switch (fModel->fEncoding) { + case 0: + fUTF8->SetMarked(true); + break; + case B_SJIS_CONVERSION: + fShiftJIS->SetMarked(true); + break; + case B_EUC_CONVERSION: + fEUC->SetMarked(true); + break; + case B_JIS_CONVERSION: + fJIS->SetMarked(true); + break; + default: + printf("Woops. Bad fModel->fEncoding value.\n"); + break; + } + + MoveTo(fModel->fFrame.left, fModel->fFrame.top); + ResizeTo(fModel->fFrame.Width(), fModel->fFrame.Height()); + + Unlock(); +} + + +void +GrepWindow::_SavePrefs() +{ + fModel->SavePrefs(); +} + [... truncated: 2379 lines follow ...] From stippi at mail.berlios.de Sat Aug 2 20:51:21 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Aug 2008 20:51:21 +0200 Subject: [Haiku-commits] r26738 - in haiku/trunk/src: add-ons/tracker apps apps/text_search Message-ID: <200808021851.m72IpL59005935@sheep.berlios.de> Author: stippi Date: 2008-08-02 20:51:20 +0200 (Sat, 02 Aug 2008) New Revision: 26738 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26738&view=rev Added: haiku/trunk/src/apps/text_search/ Removed: haiku/trunk/src/add-ons/tracker/text_search/ Modified: haiku/trunk/src/add-ons/tracker/Jamfile haiku/trunk/src/apps/Jamfile haiku/trunk/src/apps/text_search/Jamfile Log: Moved TextSearch to apps folder, since it's actually a regular app. Modified: haiku/trunk/src/add-ons/tracker/Jamfile =================================================================== --- haiku/trunk/src/add-ons/tracker/Jamfile 2008-08-02 18:43:22 UTC (rev 26737) +++ haiku/trunk/src/add-ons/tracker/Jamfile 2008-08-02 18:51:20 UTC (rev 26738) @@ -3,5 +3,4 @@ SubInclude HAIKU_TOP src add-ons tracker zipomatic ; SubInclude HAIKU_TOP src add-ons tracker filetype ; SubInclude HAIKU_TOP src add-ons tracker mark_as ; -SubInclude HAIKU_TOP src add-ons tracker text_search ; Modified: haiku/trunk/src/apps/Jamfile =================================================================== --- haiku/trunk/src/apps/Jamfile 2008-08-02 18:43:22 UTC (rev 26737) +++ haiku/trunk/src/apps/Jamfile 2008-08-02 18:51:20 UTC (rev 26738) @@ -41,6 +41,7 @@ SubInclude HAIKU_TOP src apps stylededit ; SubInclude HAIKU_TOP src apps sudoku ; SubInclude HAIKU_TOP src apps terminal ; +SubInclude HAIKU_TOP src apps text_search ; SubInclude HAIKU_TOP src apps tracker ; SubInclude HAIKU_TOP src apps tv ; SubInclude HAIKU_TOP src apps webwatch ; Copied: haiku/trunk/src/apps/text_search (from rev 26737, haiku/trunk/src/add-ons/tracker/text_search) Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/add-ons/tracker/text_search/Jamfile 2008-08-02 18:43:22 UTC (rev 26737) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-02 18:51:20 UTC (rev 26738) @@ -1,11 +1,8 @@ -SubDir HAIKU_TOP src add-ons tracker text_search ; +SubDir HAIKU_TOP src text text_search ; SetSubDirSupportedPlatformsBeOSCompatible ; -# TODO: does not seem to work: -AddResources FileType-F : FileType.rdef ; - -Application TextSearch-G : +Application TextSearch : GrepApp.cpp GrepListView.cpp Grepper.cpp From stippi at mail.berlios.de Sat Aug 2 20:54:14 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 2 Aug 2008 20:54:14 +0200 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam Message-ID: <200808021854.m72IsE2B006168@sheep.berlios.de> Author: stippi Date: 2008-08-02 20:54:13 +0200 (Sat, 02 Aug 2008) New Revision: 26739 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26739&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add TextSearch to the image (apps folder but not Haiku menu), create link in Tracker add-ons folder with short cut (like done for Backgrounds). Untested. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-08-02 18:51:20 UTC (rev 26738) +++ haiku/trunk/build/jam/HaikuImage 2008-08-02 18:54:13 UTC (rev 26739) @@ -56,7 +56,8 @@ BEOS_APPS = AboutSystem ActivityMonitor CodyCam DeskCalc DiskProbe DriveSetup CDPlayer Expander Icon-O-Matic Installer LaunchBox Magnify Mail MediaPlayer MidiPlayer NetworkStatus PackageInstaller People PowerStatus - ProcessController ShowImage SoundRecorder StyledEdit Terminal TV Workspaces + ProcessController ShowImage SoundRecorder StyledEdit Terminal TextSearch TV + Workspaces ; BEOS_PREFERENCES = Appearance Backgrounds DataTranslations E-mail FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen @@ -397,6 +398,8 @@ AddFilesToHaikuImage beos system add-ons Tracker : FileType-F ZipOMatic-Z ; AddSymlinkToHaikuImage beos system add-ons Tracker : /boot/beos/preferences/Backgrounds : Background-B ; +AddSymlinkToHaikuImage beos system add-ons Tracker + : /boot/beos/apps/TextSearch : TextSearch-G ; AddFilesToHaikuImage beos system add-ons input_server devices : keyboard mouse wacom ; AddFilesToHaikuImage beos system add-ons input_server filters : screen_saver ; From superstippi at gmx.de Sat Aug 2 21:05:39 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 02 Aug 2008 21:05:39 +0200 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <200808021854.m72IsE2B006168@sheep.berlios.de> References: <200808021854.m72IsE2B006168@sheep.berlios.de> Message-ID: <20080802190539.297340@gmx.net> > Log: > Add TextSearch to the image (apps folder but not Haiku menu), create link > in Tracker add-ons folder with short cut (like done for Backgrounds). > Untested. BTW, I am happy to report that all of this was done in Haiku - the coding, testing, icon creation and svn action. I have run Firefox multiple times to check and write email & listened to music. Uptime is 8 hours 22 minutes. The revision is 26880, which doesn't yet have any of the BFS and I/O scheduler changes. The only problems I encountered were that * BWindow::Activate() seems to be supposed to also unminimize windows. (Opening a file in Pe that is already open but minimized does not auto-show as on BeOS.) * The shortcut to toggle between header and source in Pe (Alt-Tab) does not work. * The Terminal gets confused about the input line length when it is resized while outputting. That's actually all. :-) Great job, everyone!! Best regards, -Stephan From bonefish at mail.berlios.de Sat Aug 2 22:11:20 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 2 Aug 2008 22:11:20 +0200 Subject: [Haiku-commits] r26740 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200808022011.m72KBKog016349@sheep.berlios.de> Author: bonefish Date: 2008-08-02 22:11:11 +0200 (Sat, 02 Aug 2008) New Revision: 26740 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26740&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp Log: Small semantical change of map_max_pages_need(): If given a 0 start address, it is supposed to consider the worst case address range of the given size. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-08-02 18:54:13 UTC (rev 26739) +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp 2008-08-02 20:11:11 UTC (rev 26740) @@ -328,6 +328,12 @@ static size_t map_max_pages_need(vm_translation_map */*map*/, addr_t start, addr_t end) { + // If start == 0, the actual base address is not yet known to the caller and + // we shall assume the worst case. + if (start == 0) { + start = 1023 * B_PAGE_SIZE; + end += 1023 * B_PAGE_SIZE; + } return VADDR_TO_PDENT(end) + 1 - VADDR_TO_PDENT(start); } From bonefish at mail.berlios.de Sat Aug 2 22:24:46 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 2 Aug 2008 22:24:46 +0200 Subject: [Haiku-commits] r26741 - haiku/trunk/src/system/kernel/vm Message-ID: <200808022024.m72KOkxl017407@sheep.berlios.de> Author: bonefish Date: 2008-08-02 22:24:41 +0200 (Sat, 02 Aug 2008) New Revision: 26741 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26741&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: vm_create_anonymous_area(): * Moved reservation of memory for the "locked" cases upfront. Particularly if the would-be area is a kernel area, we don't want the address space to be write locked while doing that, since that would block the low memory handler. * For full lock areas the pages are reserved upfront, too. The reasoning is similar. Reserve the pages needed by the translation map backend for mapping the area pages there too. * Moved the cache locking/unlocking out of the individual cases. All want to have the cache locked the whole time, now. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-02 20:11:11 UTC (rev 26740) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-02 20:24:41 UTC (rev 26741) @@ -1581,6 +1581,8 @@ TRACE(("create_anonymous_area %s: size 0x%lx\n", name, size)); + size = PAGE_ALIGN(size); + if (size == 0) return B_BAD_VALUE; if (!arch_vm_supports_protection(protection)) @@ -1611,37 +1613,82 @@ return B_BAD_VALUE; } + bool doReserveMemory = false; switch (wiring) { case B_NO_LOCK: + break; case B_FULL_LOCK: case B_LAZY_LOCK: case B_CONTIGUOUS: + doReserveMemory = true; + break; case B_ALREADY_WIRED: break; case B_LOMEM: //case B_SLOWMEM: dprintf("B_LOMEM/SLOWMEM is not yet supported!\n"); wiring = B_FULL_LOCK; + doReserveMemory = true; break; default: return B_BAD_VALUE; } + // For full lock or contiguous areas we're also going to map the pages and + // thus need to reserve pages for the mapping backend upfront. + addr_t reservedMapPages = 0; + if (wiring == B_FULL_LOCK || wiring == B_CONTIGUOUS) { + AddressSpaceWriteLocker locker; + status_t status = locker.SetTo(team); + if (status != B_OK) + return status; + + vm_translation_map *map = &locker.AddressSpace()->translation_map; + reservedMapPages = map->ops->map_max_pages_need(map, 0, size - 1); + } + + // Reserve memory before acquiring the address space lock. This reduces the + // chances of failure, since while holding the write lock to the address + // space (if it is the kernel address space that is), the low memory handler + // won't be able to free anything for us. + addr_t reservedMemory = 0; + if (doReserveMemory) { + if (vm_try_reserve_memory(size, 1000000) != B_OK) + return B_NO_MEMORY; + reservedMemory = size; + // TODO: We don't reserve the memory for the pages for the page + // directories/tables. We actually need to do since we currently don't + // reclaim them (and probably can't reclaim all of them anyway). Thus + // there are actually less physical pages than there should be, which + // can get the VM into trouble in low memory situations. + } + + // For full lock areas reserve the pages before locking the address + // space. E.g. block caches can't release their memory while we hold the + // address space lock. + page_num_t reservedPages = reservedMapPages; + if (wiring == B_FULL_LOCK) + reservedPages += size / B_PAGE_SIZE; + if (reservedPages > 0) + vm_page_reserve_pages(reservedPages); + AddressSpaceWriteLocker locker; + vm_address_space *addressSpace; status_t status = locker.SetTo(team); if (status != B_OK) - return status; + goto err0; - vm_address_space *addressSpace = locker.AddressSpace(); - size = PAGE_ALIGN(size); + addressSpace = locker.AddressSpace(); if (wiring == B_CONTIGUOUS) { // we try to allocate the page run here upfront as this may easily // fail for obvious reasons page = vm_page_allocate_page_run(PAGE_STATE_CLEAR, physicalBase, size / B_PAGE_SIZE); - if (page == NULL) - return B_NO_MEMORY; + if (page == NULL) { + status = B_NO_MEMORY; + goto err0; + } } // create an anonymous cache @@ -1656,6 +1703,9 @@ cache->temporary = 1; cache->virtual_end = size; + cache->committed_size = reservedMemory; + // TODO: This should be done via a method. + reservedMemory = 0; switch (wiring) { case B_LAZY_LOCK: @@ -1680,8 +1730,6 @@ goto err1; } - cache->Unlock(); - locker.DegradeToReadLock(); switch (wiring) { @@ -1692,13 +1740,7 @@ case B_FULL_LOCK: { - vm_translation_map *map = &addressSpace->translation_map; - size_t reservePages = map->ops->map_max_pages_need(map, - area->base, area->base + (area->size - 1)); - vm_page_reserve_pages(reservePages); - // Allocate and map all pages for this area - cache->Lock(); off_t offset = 0; for (addr_t address = area->base; address < area->base + (area->size - 1); @@ -1713,26 +1755,19 @@ # endif continue; #endif - vm_page *page = vm_page_allocate_page(PAGE_STATE_CLEAR, false); + vm_page *page = vm_page_allocate_page(PAGE_STATE_CLEAR, true); cache->InsertPage(page, offset); vm_map_page(area, page, address, protection); + + // Periodically unreserve pages we've already allocated, so that + // we don't unnecessarily increase the pressure on the VM. + if (offset > 0 && offset % (128 * B_PAGE_SIZE) == 0) { + page_num_t toUnreserve = 128; + vm_page_unreserve_pages(toUnreserve); + reservedPages -= toUnreserve; + } } - cache->Unlock(); -// TODO: Allocating pages with the address space write locked is not a good -// idea, particularly if that's the kernel's address space. During that time the -// low memory handler will block (e.g. the block cache will try to delete -// areas). The cache backing our area has reserved the memory and thus there -// should be enough pages available (i.e. could be freed by page write/daemon), -// but this is not true for at least two reasons: -// * The pages for page directories/tables are not reserved from the available -// memory (we should do that!) and currently we don't reclaim them (and -// probably can't reclaim all of them anyway). Thus there are actually less -// pages than there should be. -// * ATM we write pages back using virtual addresses. The lower I/O layers will -// try to lock the memory, which will block, since that requires to read-lock -// the address space. - vm_page_unreserve_pages(reservePages); break; } @@ -1747,7 +1782,6 @@ if (!gKernelStartup) panic("ALREADY_WIRED flag used outside kernel startup\n"); - cache->Lock(); map->ops->lock(map); for (addr_t virtualAddress = area->base; virtualAddress < area->base @@ -1774,7 +1808,6 @@ } map->ops->unlock(map); - cache->Unlock(); break; } @@ -1785,12 +1818,8 @@ vm_translation_map *map = &addressSpace->translation_map; addr_t physicalAddress = page->physical_page_number * B_PAGE_SIZE; addr_t virtualAddress = area->base; - size_t reservePages = map->ops->map_max_pages_need(map, - virtualAddress, virtualAddress + (area->size - 1)); off_t offset = 0; - vm_page_reserve_pages(reservePages); - cache->Lock(); map->ops->lock(map); for (virtualAddress = area->base; virtualAddress < area->base @@ -1812,8 +1841,6 @@ } map->ops->unlock(map); - cache->Unlock(); - vm_page_unreserve_pages(reservePages); break; } @@ -1821,6 +1848,11 @@ break; } + cache->Unlock(); + + if (reservedPages > 0) + vm_page_unreserve_pages(reservedPages); + TRACE(("vm_create_anonymous_area: done\n")); area->cache_type = CACHE_TYPE_RAM; @@ -1840,6 +1872,12 @@ } } +err0: + if (reservedPages > 0) + vm_page_unreserve_pages(reservedPages); + if (reservedMemory > 0) + vm_unreserve_memory(reservedMemory); + return status; } From bonefish at mail.berlios.de Sat Aug 2 22:52:08 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 2 Aug 2008 22:52:08 +0200 Subject: [Haiku-commits] r26742 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808022052.m72Kq8Mm020561@sheep.berlios.de> Author: bonefish Date: 2008-08-02 22:51:59 +0200 (Sat, 02 Aug 2008) New Revision: 26742 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26742&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp haiku/trunk/src/system/kernel/device_manager/io_requests.h Log: IORequests leaked their IOBuffers. Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-02 20:24:41 UTC (rev 26741) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-02 20:51:59 UTC (rev 26742) @@ -66,6 +66,13 @@ void +IOBuffer::Delete() +{ + free(this); +} + + +void IOBuffer::SetVecs(size_t firstVecOffset, const iovec* vecs, uint32 count, size_t length, uint32 flags) { @@ -508,6 +515,7 @@ { mutex_lock(&fLock); DeleteSubRequests(); + fBuffer->Delete(); mutex_destroy(&fLock); } Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-02 20:24:41 UTC (rev 26741) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-02 20:51:59 UTC (rev 26742) @@ -29,6 +29,7 @@ class IOBuffer : public DoublyLinkedListLinkImpl { public: static IOBuffer* Create(size_t count); + void Delete(); bool IsVirtual() const { return !fPhysical; } bool IsPhysical() const { return fPhysical; } @@ -55,6 +56,7 @@ void UnlockMemory(team_id team, bool isWrite); private: + IOBuffer(); ~IOBuffer(); // not implemented void _UnlockMemory(team_id team, size_t count, From oruizdorantes at mail.berlios.de Sat Aug 2 23:15:15 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Sat, 2 Aug 2008 23:15:15 +0200 Subject: [Haiku-commits] r26743 - in haiku/trunk/headers/os/bluetooth: . HCI L2CAP Message-ID: <200808022115.m72LFFtx022291@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-02 23:15:02 +0200 (Sat, 02 Aug 2008) New Revision: 26743 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26743&view=rev Modified: haiku/trunk/headers/os/bluetooth/BluetoothDevice.h haiku/trunk/headers/os/bluetooth/DeviceClass.h haiku/trunk/headers/os/bluetooth/DiscoveryAgent.h haiku/trunk/headers/os/bluetooth/DiscoveryListener.h haiku/trunk/headers/os/bluetooth/HCI/btHCI.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h haiku/trunk/headers/os/bluetooth/LocalDevice.h haiku/trunk/headers/os/bluetooth/RemoteDevice.h haiku/trunk/headers/os/bluetooth/bdaddrUtils.h haiku/trunk/headers/os/bluetooth/bluetooth.h haiku/trunk/headers/os/bluetooth/bluetooth_error.h haiku/trunk/headers/os/bluetooth/bluetooth_util.h Log: A bit more styling on main headers Modified: haiku/trunk/headers/os/bluetooth/BluetoothDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/BluetoothDevice.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/BluetoothDevice.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_DEVICE_H #define _BLUETOOTH_DEVICE_H @@ -42,4 +39,4 @@ using Bluetooth::BluetoothDevice; #endif -#endif +#endif // _BLUETOOTH_DEVICE_H Modified: haiku/trunk/headers/os/bluetooth/DeviceClass.h =================================================================== --- haiku/trunk/headers/os/bluetooth/DeviceClass.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/DeviceClass.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _DEVICE_CLASS_H #define _DEVICE_CLASS_H @@ -14,50 +11,50 @@ class DeviceClass { - public: +public: - DeviceClass(int record) - { - this->record = record; - } + DeviceClass(int record) + { + this->record = record; + } - DeviceClass() - { - this->record = 0; - } + DeviceClass() + { + this->record = 0; + } - int GetServiceClasses() - { - return (record & 0x00FFE000) >> 13; - } + int GetServiceClasses() + { + return (record & 0x00FFE000) >> 13; + } - int GetMajorDeviceClass() - { - return (record & 0x00001F00) >> 8; - } + int GetMajorDeviceClass() + { + return (record & 0x00001F00) >> 8; + } - void GetMajorDeviceClass(BString* str) - { + void GetMajorDeviceClass(BString* str) + { - } + } - int GetMinorDeviceClass() - { - return (record & 0x000000FF) >> 2; - } + int GetMinorDeviceClass() + { + return (record & 0x000000FF) >> 2; + } - void GetMinorDeviceClass(BString* str) - { + void GetMinorDeviceClass(BString* str) + { - } - - private: - int record; + } + +private: + int record; }; } @@ -66,4 +63,4 @@ using Bluetooth::DeviceClass; #endif -#endif +#endif // _DEVICE_CLASS_H Modified: haiku/trunk/headers/os/bluetooth/DiscoveryAgent.h =================================================================== --- haiku/trunk/headers/os/bluetooth/DiscoveryAgent.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/DiscoveryAgent.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _DISCOVERY_AGENT_H #define _DISCOVERY_AGENT_H @@ -30,38 +27,38 @@ class DiscoveryAgent { - public: +public: - static const int GIAC = BT_GIAC; - static const int LIAC = BT_LIAC; + static const int GIAC = BT_GIAC; + static const int LIAC = BT_LIAC; - static const int PREKNOWN = BT_PREKNOWN; - static const int CACHED = BT_CACHED; - static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE; + static const int PREKNOWN = BT_PREKNOWN; + static const int CACHED = BT_CACHED; + static const int NOT_DISCOVERABLE = BT_NOT_DISCOVERABLE; - RemoteDevicesList RetrieveDevices(int option); /* TODO */ - status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */ - status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs); - status_t CancelInquiry(DiscoveryListener* listener); + RemoteDevicesList RetrieveDevices(int option); /* TODO */ + status_t StartInquiry(int accessCode, DiscoveryListener* listener); /* Throwing */ + status_t StartInquiry(uint32 accessCode, DiscoveryListener* listener, bigtime_t secs); + status_t CancelInquiry(DiscoveryListener* listener); - /* - int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, - DiscoveryListener discListener); + /* + int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, + DiscoveryListener discListener); - bool cancelServiceSearch(int transID); - BString selectService(UUID uuid, int security, boolean master); - */ + bool cancelServiceSearch(int transID); + BString selectService(UUID uuid, int security, boolean master); + */ - private: - DiscoveryAgent(LocalDevice* ld); - ~DiscoveryAgent(); - void SetLocalDeviceOwner(LocalDevice* ld); +private: + DiscoveryAgent(LocalDevice* ld); + ~DiscoveryAgent(); + void SetLocalDeviceOwner(LocalDevice* ld); - DiscoveryListener* fLastUsedListener; - LocalDevice* fLocalDevice; - BMessenger* fMessenger; + DiscoveryListener* fLastUsedListener; + LocalDevice* fLocalDevice; + BMessenger* fMessenger; - friend class LocalDevice; + friend class LocalDevice; }; } @@ -70,4 +67,4 @@ using Bluetooth::DiscoveryAgent; #endif -#endif +#endif // _DISCOVERY_AGENT_H Modified: haiku/trunk/headers/os/bluetooth/DiscoveryListener.h =================================================================== --- haiku/trunk/headers/os/bluetooth/DiscoveryListener.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/DiscoveryListener.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _DISCOVERY_LISTENER_H #define _DISCOVERY_LISTENER_H @@ -29,42 +26,42 @@ class DiscoveryListener : public BLooper { - public: +public: - static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED; - static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED; - static const int INQUIRY_ERROR = BT_INQUIRY_ERROR; + static const int INQUIRY_COMPLETED = BT_INQUIRY_COMPLETED; + static const int INQUIRY_TERMINATED = BT_INQUIRY_TERMINATED; + static const int INQUIRY_ERROR = BT_INQUIRY_ERROR; - static const int SERVICE_SEARCH_COMPLETED = 0x01; - static const int SERVICE_SEARCH_TERMINATED = 0x02; - static const int SERVICE_SEARCH_ERROR = 0x03; - static const int SERVICE_SEARCH_NO_RECORDS = 0x04; - static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; + static const int SERVICE_SEARCH_COMPLETED = 0x01; + static const int SERVICE_SEARCH_TERMINATED = 0x02; + static const int SERVICE_SEARCH_ERROR = 0x03; + static const int SERVICE_SEARCH_NO_RECORDS = 0x04; + static const int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; - virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod); - /* - virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord); - virtual void serviceSearchCompleted(int transID, int respCode); - */ - virtual void InquiryCompleted(int discType); + virtual void DeviceDiscovered(RemoteDevice* btDevice, DeviceClass cod); + /* + virtual void servicesDiscovered(int transID, ServiceRecord[] servRecord); + virtual void serviceSearchCompleted(int transID, int respCode); + */ + virtual void InquiryCompleted(int discType); - /* JSR82 non-defined methods */ - virtual void InquiryStarted(status_t status); + /* JSR82 non-defined methods */ + virtual void InquiryStarted(status_t status); - private: +private: - RemoteDevicesList GetRemoteDevicesList(void); + RemoteDevicesList GetRemoteDevicesList(void); - void MessageReceived(BMessage* msg); + void MessageReceived(BMessage* msg); - LocalDevice* fLocalDevice; - RemoteDevicesList fRemoteDevicesList; + LocalDevice* fLocalDevice; + RemoteDevicesList fRemoteDevicesList; - friend class DiscoveryAgent; + friend class DiscoveryAgent; - protected: - DiscoveryListener(); - void SetLocalDeviceOwner(LocalDevice* ld); +protected: + DiscoveryListener(); + void SetLocalDeviceOwner(LocalDevice* ld); }; } @@ -73,4 +70,4 @@ using Bluetooth::DiscoveryListener; #endif -#endif +#endif // _DISCOVERY_LISTENER_H Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_H_ #define _BTHCI_H_ @@ -38,4 +35,4 @@ #define HCI_FEATURES_SIZE 8 /* LMP features */ #define HCI_DEVICE_NAME_SIZE 248 /* unit name size */ -#endif +#endif // _BTHCI_H_ Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_acl.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_ACL_H_ #define _BTHCI_ACL_H_ @@ -36,4 +33,4 @@ #define HCI_ACL_BROADCAST_PICONET 0x2 /* both directions */ /* 11 - reserved for future use */ -#endif +#endif // _BTHCI_ACL_H_ Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_command.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_COMMAND_H_ #define _BTHCI_COMMAND_H_ @@ -337,4 +334,4 @@ /* Vendor specific commands */ #define OGF_VENDOR_CMD 0x3F -#endif +#endif // _BTHCI_COMMAND_H_ Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_event.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_EVENT_H_ #define _BTHCI_EVENT_H_ @@ -318,15 +315,13 @@ #define HCI_EVENT_REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION 0x3D - - /* HAIKU Internal Events, not produced by the transport devices but * by some entity of the Haiku Bluetooth Stack. * The MSB 0xE is chosen for this purpose */ -#define HCI_HAIKU_EVENT_SERVER_QUITTING 0xE0 +#define HCI_HAIKU_EVENT_SERVER_QUITTING 0xE0 #define HCI_HAIKU_EVENT_DEVICE_REMOVED 0xE1 -#endif +#endif // _BTHCI_EVENT_H_ Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_module.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_MODULE_H_ #define _BTHCI_MODULE_H_ @@ -35,4 +32,4 @@ } bt_hci_module_info ; -#endif +#endif // _BTHCI_MODULE_H_ Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BTHCI_TRANSPORT_H_ #define _BTHCI_TRANSPORT_H_ @@ -99,4 +96,4 @@ at moment refer to ioctl GET_NOTIFICATION_PORT)*/ #define BT_USERLAND_PORT_NAME "BT kernel-user Land" -#endif +#endif // _BTHCI_TRANSPORT_H_ Modified: haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h =================================================================== --- haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/L2CAP/btL2CAP.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,8 +1,6 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ #ifndef _BTL2CAP_H_ @@ -18,4 +16,4 @@ }; -#endif \ No newline at end of file +#endif // _BTL2CAP_H_ \ No newline at end of file Modified: haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h =================================================================== --- haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/LinkKeyUtils.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _LINKKEY_UTILS_H #define _LINKKEY_UTILS_H @@ -17,51 +14,47 @@ class LinkKeyUtils { public: - static bool Compare(linkkey_t* lk1, linkkey_t* lk2) - { - return (memcmp(lk1, lk2, sizeof(linkkey_t)) == 0); - } + static bool Compare(linkkey_t* lk1, linkkey_t* lk2) + { + return memcmp(lk1, lk2, sizeof(linkkey_t)) == 0; + } - static linkkey_t NullKey() - { - return (linkkey_t) {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; - } - - static char* ToString(const linkkey_t lk) - { - - // TODO: not safe - static char str[50]; + static linkkey_t NullKey() + { + return (linkkey_t){{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; + } + + static char* ToString(const linkkey_t lk) + { + // TODO: not safe + static char str[50]; - sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" - "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - lk.l[0], lk.l[1], lk.l[2], lk.l[3], - lk.l[4], lk.l[5], lk.l[6], lk.l[7], - lk.l[8], lk.l[9], lk.l[10], lk.l[11], - lk.l[12], lk.l[13], lk.l[14], lk.l[15]); - - return str; - } + sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:" + "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", + lk.l[0], lk.l[1], lk.l[2], lk.l[3], lk.l[4], lk.l[5], + lk.l[6], lk.l[7], lk.l[8], lk.l[9], lk.l[10], lk.l[11], + lk.l[12], lk.l[13], lk.l[14], lk.l[15]); - static linkkey_t FromString(const char *lkstr) - { - if (lkstr != NULL) - { - int l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; - size_t count = sscanf(lkstr, "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X:" - "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X", - &l0, &l1, &l2, &l3, &l4, &l5, &l6, &l7, - &l8, &l9, &l10, &l11, &l12, &l13, &l14, &l15); + return str; + } - if (count == 16) - { - return (linkkey_t) {{l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15}}; - } + static linkkey_t FromString(const char *lkstr) + { + if (lkstr != NULL) { + int l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15; + size_t count = sscanf(lkstr, "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X:" + "%2X:%2X:%2X:%2X:%2X:%2X:%2X:%2X", &l0, &l1, &l2, &l3, + &l4, &l5, &l6, &l7, &l8, &l9, &l10, &l11, &l12, &l13, + &l14, &l15); + + if (count == 16) { + return (linkkey_t){{l0, l1, l2, l3, l4, l5, l6, l7, l8, + l9, l10, l11, l12, l13, l14, l15}}; } + } - return NullKey(); - - } + return NullKey(); + } }; } @@ -70,4 +63,4 @@ using Bluetooth::LinkKeyUtils; #endif -#endif \ No newline at end of file +#endif // _LINKKEY_UTILS_H Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _LOCAL_DEVICE_H #define _LOCAL_DEVICE_H @@ -26,44 +23,44 @@ class LocalDevice : public BluetoothDevice { - public: - /* Possible throwing */ - static LocalDevice* GetLocalDevice(); - static uint32 GetLocalDeviceCount(); +public: + /* Possible throwing */ + static LocalDevice* GetLocalDevice(); + static uint32 GetLocalDeviceCount(); - static LocalDevice* GetLocalDevice(hci_id hid); - static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + static LocalDevice* GetLocalDevice(hci_id hid); + static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); - DiscoveryAgent* GetDiscoveryAgent(); - BString GetFriendlyName(); - DeviceClass GetDeviceClass(); - /* Possible throwing */ - status_t SetDiscoverable(int mode); + DiscoveryAgent* GetDiscoveryAgent(); + BString GetFriendlyName(); + DeviceClass GetDeviceClass(); + /* Possible throwing */ + status_t SetDiscoverable(int mode); - BString GetProperty(const char* property); - void GetProperty(const char* property, uint32* value); + BString GetProperty(const char* property); + void GetProperty(const char* property, uint32* value); - int GetDiscoverable(); - bdaddr_t GetBluetoothAddress(); - /* - ServiceRecord getRecord(Connection notifier); - void updateRecord(ServiceRecord srvRecord); - */ + int GetDiscoverable(); + bdaddr_t GetBluetoothAddress(); + /* + ServiceRecord getRecord(Connection notifier); + void updateRecord(ServiceRecord srvRecord); + */ - private: - LocalDevice(hci_id hid); - virtual ~LocalDevice(); +private: + LocalDevice(hci_id hid); + virtual ~LocalDevice(); - hci_id GetID(void) {return hid;} - static LocalDevice* RequestLocalDeviceID(BMessage* request); + hci_id GetID(void) {return hid;} + static LocalDevice* RequestLocalDeviceID(BMessage* request); - BMessenger* fMessenger; + BMessenger* fMessenger; - hci_id hid; + hci_id hid; - friend class DiscoveryAgent; - friend class RemoteDevice; - friend class PincodeWindow; + friend class DiscoveryAgent; + friend class RemoteDevice; + friend class PincodeWindow; }; } @@ -72,4 +69,4 @@ using Bluetooth::LocalDevice; #endif -#endif +#endif // _LOCAL_DEVICE_H Modified: haiku/trunk/headers/os/bluetooth/RemoteDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,10 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _REMOTE_DEVICE_H #define _REMOTE_DEVICE_H @@ -24,50 +21,50 @@ class RemoteDevice : public BluetoothDevice { - public: - static const int WAIT = B_BT_WAIT; - static const int SUCCEEDED = B_BT_SUCCEEDED; +public: + static const int WAIT = B_BT_WAIT; + static const int SUCCEEDED = B_BT_SUCCEEDED; - virtual ~RemoteDevice(); + virtual ~RemoteDevice(); - bool IsTrustedDevice(); - BString GetFriendlyName(bool alwaysAsk); /* Throwing */ - BString GetFriendlyName(void); /* Throwing */ - bdaddr_t GetBluetoothAddress(); - DeviceClass GetDeviceClass(); + bool IsTrustedDevice(); + BString GetFriendlyName(bool alwaysAsk); /* Throwing */ + BString GetFriendlyName(void); /* Throwing */ + bdaddr_t GetBluetoothAddress(); + DeviceClass GetDeviceClass(); - bool Equals(RemoteDevice* obj); + bool Equals(RemoteDevice* obj); - /*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */ - bool Authenticate(); /* Throwing */ - /* bool Authorize(Connection conn); Throwing */ - /*bool Encrypt(Connection conn, bool on); Throwing */ - bool IsAuthenticated(); /* Throwing */ - /*bool IsAuthorized(Connection conn); Throwing */ - bool IsEncrypted(); /* Throwing */ + /*static RemoteDevice* GetRemoteDevice(Connection conn); Throwing */ + bool Authenticate(); /* Throwing */ + /* bool Authorize(Connection conn); Throwing */ + /*bool Encrypt(Connection conn, bool on); Throwing */ + bool IsAuthenticated(); /* Throwing */ + /*bool IsAuthorized(Connection conn); Throwing */ + bool IsEncrypted(); /* Throwing */ - BString GetProperty(const char* property); /* Throwing */ - void GetProperty(const char* property, uint32* value); /* Throwing */ + BString GetProperty(const char* property); /* Throwing */ + void GetProperty(const char* property, uint32* value); /* Throwing */ - LocalDevice* GetLocalDeviceOwner(); + LocalDevice* GetLocalDeviceOwner(); - RemoteDevice(BString address); - RemoteDevice(bdaddr_t address); + RemoteDevice(BString address); + RemoteDevice(bdaddr_t address); - protected: - /* called by Discovery[Listener|Agent] */ - void SetLocalDeviceOwner(LocalDevice* ld); - friend class DiscoveryListener; +protected: + /* called by Discovery[Listener|Agent] */ + void SetLocalDeviceOwner(LocalDevice* ld); + friend class DiscoveryListener; - private: +private: - LocalDevice* fDiscovererLocalDevice; - BMessenger* fMessenger; + LocalDevice* fDiscovererLocalDevice; + BMessenger* fMessenger; - uint8 fPageRepetitionMode; - uint8 fScanPeriodMode; - uint8 fScanMode; - uint16 fClockOffset; + uint8 fPageRepetitionMode; + uint8 fScanPeriodMode; + uint8 fScanMode; + uint16 fClockOffset; }; @@ -77,4 +74,4 @@ using Bluetooth::RemoteDevice; #endif -#endif +#endif // _REMOTE_DEVICE_H Modified: haiku/trunk/headers/os/bluetooth/bdaddrUtils.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BDADDR_UTILS_H #define _BDADDR_UTILS_H @@ -17,57 +14,57 @@ class bdaddrUtils { - public: - static inline bdaddr_t NullAddress() - { - return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); - } +public: + static inline bdaddr_t NullAddress() + { + return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); + } - static inline bdaddr_t LocalAddress() - { - return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); - } + static inline bdaddr_t LocalAddress() + { + return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); + } - static inline bdaddr_t BroadcastAddress() - { - return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); - } + static inline bdaddr_t BroadcastAddress() + { + return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); + } - static bool Compare(bdaddr_t *ba1, bdaddr_t *ba2) - { - return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); - } + static bool Compare(bdaddr_t *ba1, bdaddr_t *ba2) + { + return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); + } - static char* ToString(const bdaddr_t bdaddr) - { - // TODO: not safe - static char str[18]; + static char* ToString(const bdaddr_t bdaddr) + { + // TODO: not safe + static char str[18]; - sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0], - bdaddr.b[1], bdaddr.b[2], bdaddr.b[3], bdaddr.b[4], - bdaddr.b[5]); - return str; - } + sprintf(str,"%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",bdaddr.b[0], + bdaddr.b[1], bdaddr.b[2], bdaddr.b[3], bdaddr.b[4], + bdaddr.b[5]); + return str; + } - static bdaddr_t FromString(const char * addr) - { - int b0, b1, b2, b3, b4, b5; + static bdaddr_t FromString(const char * addr) + { + int b0, b1, b2, b3, b4, b5; - if (addr != NULL) { - size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X", - &b0, &b1, &b2, &b3, &b4, &b5); + if (addr != NULL) { + size_t count = sscanf(addr, "%2X:%2X:%2X:%2X:%2X:%2X", + &b0, &b1, &b2, &b3, &b4, &b5); - if (count == 6) - return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}}); - } + if (count == 6) + return ((bdaddr_t) {{b0, b1, b2, b3, b4, b5}}); + } - return NullAddress(); - } + return NullAddress(); + } }; @@ -78,4 +75,4 @@ #endif -#endif +#endif // _BDADDR_UTILS_H Modified: haiku/trunk/headers/os/bluetooth/bluetooth.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/bluetooth.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,11 +1,8 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_H #define _BLUETOOTH_H @@ -55,4 +52,4 @@ #define BLUETOOTH_PROTO_MAX 256 -#endif +#endif // _BLUETOOTH_H Modified: haiku/trunk/headers/os/bluetooth/bluetooth_error.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth_error.h 2008-08-02 20:51:59 UTC (rev 26742) +++ haiku/trunk/headers/os/bluetooth/bluetooth_error.h 2008-08-02 21:15:02 UTC (rev 26743) @@ -1,74 +1,71 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * * All rights reserved. Distributed under the terms of the MIT License. - * */ - #ifndef _BLUETOOTH_ERROR_H #define _BLUETOOTH_ERROR_H #include -#define BT_OK B_OK -#define BT_ERROR BT_UNSPECIFIED_ERROR +#define BT_OK B_OK +#define BT_ERROR BT_UNSPECIFIED_ERROR /* Official error code for Bluetooth V2.1 + EDR */ -#define BT_UNKNOWN_COMMAND 0x01 -#define BT_NO_CONNECTION 0x02 -#define BT_HARDWARE_FAILURE 0x03 -#define BT_PAGE_TIMEOUT 0x04 -#define BT_AUTHENTICATION_FAILURE 0x05 -#define BT_PIN_OR_KEY_MISSING 0x06 -#define BT_MEMORY_FULL 0x07 -#define BT_CONNECTION_TIMEOUT 0x08 +#define BT_UNKNOWN_COMMAND 0x01 +#define BT_NO_CONNECTION 0x02 +#define BT_HARDWARE_FAILURE 0x03 +#define BT_PAGE_TIMEOUT 0x04 +#define BT_AUTHENTICATION_FAILURE 0x05 +#define BT_PIN_OR_KEY_MISSING 0x06 +#define BT_MEMORY_FULL 0x07 +#define BT_CONNECTION_TIMEOUT 0x08 #define BT_MAX_NUMBER_OF_CONNECTIONS 0x09 #define BT_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a -#define BT_ACL_CONNECTION_EXISTS 0x0b -#define BT_COMMAND_DISALLOWED 0x0c +#define BT_ACL_CONNECTION_EXISTS 0x0b +#define BT_COMMAND_DISALLOWED 0x0c #define BT_REJECTED_LIMITED_RESOURCES 0x0d -#define BT_REJECTED_SECURITY 0x0e -#define BT_REJECTED_PERSONAL 0x0f -#define BT_HOST_TIMEOUT 0x10 -#define BT_UNSUPPORTED_FEATURE 0x11 -#define BT_INVALID_PARAMETERS 0x12 -#define BT_OE_USER_ENDED_CONNECTION 0x13 -#define BT_OE_LOW_RESOURCES 0x14 -#define BT_OE_POWER_OFF 0x15 -#define BT_CONNECTION_TERMINATED 0x16 -#define BT_REPEATED_ATTEMPTS 0x17 -#define BT_PAIRING_NOT_ALLOWED 0x18 -#define BT_UNKNOWN_LMP_PDU 0x19 +#define BT_REJECTED_SECURITY 0x0e +#define BT_REJECTED_PERSONAL 0x0f +#define BT_HOST_TIMEOUT 0x10 +#define BT_UNSUPPORTED_FEATURE 0x11 +#define BT_INVALID_PARAMETERS 0x12 +#define BT_OE_USER_ENDED_CONNECTION 0x13 +#define BT_OE_LOW_RESOURCES 0x14 +#define BT_OE_POWER_OFF 0x15 +#define BT_CONNECTION_TERMINATED 0x16 +#define BT_REPEATED_ATTEMPTS 0x17 +#define BT_PAIRING_NOT_ALLOWED 0x18 +#define BT_UNKNOWN_LMP_PDU 0x19 #define BT_UNSUPPORTED_REMOTE_FEATURE 0x1a -#define BT_SCO_OFFSET_REJECTED 0x1b -#define BT_SCO_INTERVAL_REJECTED 0x1c -#define BT_AIR_MODE_REJECTED 0x1d -#define BT_INVALID_LMP_PARAMETERS 0x1e -#define BT_UNSPECIFIED_ERROR 0x1f +#define BT_SCO_OFFSET_REJECTED 0x1b +#define BT_SCO_INTERVAL_REJECTED 0x1c [... truncated: 72 lines follow ...] From bonefish at mail.berlios.de Sat Aug 2 23:15:20 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 2 Aug 2008 23:15:20 +0200 Subject: [Haiku-commits] r26744 - haiku/trunk/src/apps/text_search Message-ID: <200808022115.m72LFKPF022305@sheep.berlios.de> Author: bonefish Date: 2008-08-02 23:15:17 +0200 (Sat, 02 Aug 2008) New Revision: 26744 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26744&view=rev Modified: haiku/trunk/src/apps/text_search/Jamfile Log: Build fix. Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-02 21:15:02 UTC (rev 26743) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-02 21:15:17 UTC (rev 26744) @@ -1,4 +1,4 @@ -SubDir HAIKU_TOP src text text_search ; +SubDir HAIKU_TOP src apps text_search ; SetSubDirSupportedPlatformsBeOSCompatible ; From superstippi at gmx.de Sat Aug 2 23:24:36 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 02 Aug 2008 23:24:36 +0200 Subject: [Haiku-commits] r26744 - haiku/trunk/src/apps/text_search In-Reply-To: <200808022115.m72LFKPF022305@sheep.berlios.de> References: <200808022115.m72LFKPF022305@sheep.berlios.de> Message-ID: <20080802212436.210890@gmx.net> -------- Original-Nachricht -------- > Datum: Sat, 2 Aug 2008 23:15:20 +0200 > Von: bonefish at mail.berlios.de > An: haiku-commits at lists.berlios.de > Betreff: [Haiku-commits] r26744 - haiku/trunk/src/apps/text_search > Author: bonefish > Date: 2008-08-02 23:15:17 +0200 (Sat, 02 Aug 2008) > New Revision: 26744 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26744&view=rev > > Modified: > haiku/trunk/src/apps/text_search/Jamfile > Log: > Build fix. > > > Modified: haiku/trunk/src/apps/text_search/Jamfile > =================================================================== > --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-02 21:15:02 UTC (rev > 26743) > +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-02 21:15:17 UTC (rev > 26744) > @@ -1,4 +1,4 @@ > -SubDir HAIKU_TOP src text text_search ; > +SubDir HAIKU_TOP src apps text_search ; Pretty weird... I am sure I compiled before checking in. :-| Maybe that's what you get for writing enthusiastic mails about using Haiku all day... ;-) Best regards, -Stephan From umccullough at gmail.com Sun Aug 3 00:27:47 2008 From: umccullough at gmail.com (Urias McCullough) Date: Sat, 2 Aug 2008 15:27:47 -0700 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <20080802190539.297340@gmx.net> References: <200808021854.m72IsE2B006168@sheep.berlios.de> <20080802190539.297340@gmx.net> Message-ID: <1e80d8750808021527g1af431c3t9c1c9dbb7ab67e53@mail.gmail.com> 2008/8/2 Stephan Assmus : > The revision is 26880, which doesn't yet have any of the BFS and I/O scheduler changes. I assume you mean 26680? And the IO scheduler stuff was enabled in 26691 right? I'm trying to figure out what the safest rev to demo Haiku next week will be. I seems that 26691 is stable with the exception of the directory deletion issue (fixed in 26694 IIRC) - so I rolled back to 26688 before the locking changes were made. I'm getting an occasional "Invalid Opcode Exception" when messing around with configure scripts and compiling various libs and whatnot... I haven't found any sort of reproducible scenario, nor have i had a chance to get serial output from the KDLs. Perhaps I should grab 26691 and apply the patch from 26694 directly... From bonefish at mail.berlios.de Sun Aug 3 01:48:34 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 3 Aug 2008 01:48:34 +0200 Subject: [Haiku-commits] r26745 - haiku/trunk/src/system/kernel Message-ID: <200808022348.m72NmYir022135@sheep.berlios.de> Author: bonefish Date: 2008-08-03 01:48:29 +0200 (Sun, 03 Aug 2008) New Revision: 26745 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26745&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: The command line args can easily exceed the maximal tracing buffer allocation size, which caused the Exec traced entry to crash when printed. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-08-02 21:15:17 UTC (rev 26744) +++ haiku/trunk/src/system/kernel/team.cpp 2008-08-02 23:48:29 UTC (rev 26745) @@ -157,11 +157,14 @@ { out.Print("team exec, \"%p\", args:", fPath); - char* args = fArgs; - for (int32 i = 0; !out.IsFull() && i < fArgCount; i++) { - out.Print(" \"%s\"", args); - args += strlen(args) + 1; - } + if (fArgs != NULL) { + char* args = fArgs; + for (int32 i = 0; !out.IsFull() && i < fArgCount; i++) { + out.Print(" \"%s\"", args); + args += strlen(args) + 1; + } + } else + out.Print(" "); } private: From bonefish at mail.berlios.de Sun Aug 3 01:50:20 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 3 Aug 2008 01:50:20 +0200 Subject: [Haiku-commits] r26746 - haiku/trunk/src/system/kernel Message-ID: <200808022350.m72NoK7I022330@sheep.berlios.de> Author: bonefish Date: 2008-08-03 01:50:14 +0200 (Sun, 03 Aug 2008) New Revision: 26746 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26746&view=rev Modified: haiku/trunk/src/system/kernel/thread.cpp Log: Also init kernel_stack_top for the idle threads. It was NULL before, which caused stack traces in those threads to crash. Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-08-02 23:48:29 UTC (rev 26745) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-08-02 23:50:14 UTC (rev 26746) @@ -2007,6 +2007,7 @@ panic("error finding idle kstack area\n"); thread->kernel_stack_base = (addr_t)info.address; + thread->kernel_stack_top = thread->kernel_stack_base + info.size; hash_insert(sThreadHash, thread); insert_thread_into_team(thread->team, thread); From bonefish at mail.berlios.de Sun Aug 3 01:56:32 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 3 Aug 2008 01:56:32 +0200 Subject: [Haiku-commits] r26747 - haiku/trunk/src/system/kernel Message-ID: <200808022356.m72NuWjE022662@sheep.berlios.de> Author: bonefish Date: 2008-08-03 01:56:26 +0200 (Sun, 03 Aug 2008) New Revision: 26747 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26747&view=rev Modified: haiku/trunk/src/system/kernel/elf.cpp Log: Don't allow the kernel team to be passed to elf_debug_lookup_user_symbol_address(). Modified: haiku/trunk/src/system/kernel/elf.cpp =================================================================== --- haiku/trunk/src/system/kernel/elf.cpp 2008-08-02 23:50:14 UTC (rev 26746) +++ haiku/trunk/src/system/kernel/elf.cpp 2008-08-02 23:56:26 UTC (rev 26747) @@ -1310,13 +1310,16 @@ /*! Tries to find a matching user symbol for the given address. - Note that the given team's address must already be in effect. + Note that the given team's address space must already be in effect. */ status_t elf_debug_lookup_user_symbol_address(struct team* team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch) { + if (team == NULL || team == team_get_kernel_team()) + return B_BAD_VALUE; + UserSymbolLookup& lookup = UserSymbolLookup::Default(); status_t error = lookup.Init(team); if (error != B_OK) From mmu_man at mail.berlios.de Sun Aug 3 01:57:04 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 01:57:04 +0200 Subject: [Haiku-commits] r26748 - haiku/trunk/src/apps/text_search Message-ID: <200808022357.m72Nv48s022688@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 01:57:03 +0200 (Sun, 03 Aug 2008) New Revision: 26748 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26748&view=rev Modified: haiku/trunk/src/apps/text_search/Model.cpp haiku/trunk/src/apps/text_search/Model.h Log: Fix gcc4 build. my->beers--; Modified: haiku/trunk/src/apps/text_search/Model.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Model.cpp 2008-08-02 23:56:26 UTC (rev 26747) +++ haiku/trunk/src/apps/text_search/Model.cpp 2008-08-02 23:57:03 UTC (rev 26748) @@ -328,8 +328,8 @@ status_t -Model::_OpenFile(BFile* file, const char* name, uint32 openMode = B_READ_ONLY, - directory_which which = B_USER_SETTINGS_DIRECTORY, BVolume* volume = NULL) +Model::_OpenFile(BFile* file, const char* name, uint32 openMode, + directory_which which, BVolume* volume) { if (file == NULL) return B_BAD_VALUE; Modified: haiku/trunk/src/apps/text_search/Model.h =================================================================== --- haiku/trunk/src/apps/text_search/Model.h 2008-08-02 23:56:26 UTC (rev 26747) +++ haiku/trunk/src/apps/text_search/Model.h 2008-08-02 23:57:03 UTC (rev 26748) @@ -23,6 +23,7 @@ #define MODEL_H #include +#include #include #include #include From mmu_man at mail.berlios.de Sun Aug 3 03:40:58 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 03:40:58 +0200 Subject: [Haiku-commits] r26749 - haiku/trunk/src/system/boot/platform/atari_m68k Message-ID: <200808030140.m731ew1g000205@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 03:40:57 +0200 (Sun, 03 Aug 2008) New Revision: 26749 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26749&view=rev Modified: haiku/trunk/src/system/boot/platform/atari_m68k/video.cpp haiku/trunk/src/system/boot/platform/atari_m68k/video.h Log: Start of boot video mode support. Not finished. Modified: haiku/trunk/src/system/boot/platform/atari_m68k/video.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/video.cpp 2008-08-02 23:57:03 UTC (rev 26748) +++ haiku/trunk/src/system/boot/platform/atari_m68k/video.cpp 2008-08-03 01:40:57 UTC (rev 26749) @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,104 @@ // XXX: use falcon video monitor detection and build possible mode list there... +// which API to use to handle this mode +// cf. http://toshyp.atari.org/004.htm +enum { + MODETYPE_XBIOS_ST, + MODETYPE_XBIOS_TT, + MODETYPE_XBIOS_FALCON, + MODETYPE_CENTSCREEN, + MODETYPE_CRAZYDOTS, + MODETYPE_CT60, + MODETYPE_NATFEAT +}; +class ModeAPI { +public: + ModeAPI(const char *name) { fName = name; }; + ~ModeAPI() {}; + const char *Name() const { return fName; }; + virtual status_t Enumerate() = 0; + virtual status_t Get(struct video_mode *mode) = 0; + virtual status_t Set(const struct video_mode *mode) = 0; +private: + const char *fName; +}; + +struct video_mode { + list_link link; + ModeAPI *ops; + color_space space; + uint16 mode; + uint16 width, height, bits_per_pixel; + uint32 bytes_per_row; +}; + +static struct list sModeList; +static video_mode *sMode, *sDefaultMode; + + +// #pragma mark - Falcon XBIOS API + +class FalconModeAPI : public ModeAPI { +public: + FalconModeAPI() : ModeAPI("Falcon XBIOS") {}; + ~FalconModeAPI() {}; + virtual status_t Enumerate(); + virtual status_t Get(struct video_mode *mode); + virtual status_t Set(const struct video_mode *mode); +}; + + +status_t +FalconModeAPI::Enumerate() +{ + int16 monitor; + monitor = VgetMonitor(); + switch (monitor) { + case 0: + panic("Monochrome ??"); + break; + //case 4 & 5: check for CT60 + case 1: + default: + dprintf("monitor type %d\n", monitor); + break; + } + return ENODEV; +} + + +status_t +FalconModeAPI::Get(struct video_mode *mode) +{ + int16 m = VsetMode(VM_INQUIRE); + int bpp; + int width = 320; + if (m < 0) + return B_ERROR; + bpp = 1 << (m & 0x0007); + if (m & 0x0008) + width *= 2; + bool vga = (m & 0x0010) != 0; + bool pal = (m & 0x0020) != 0; + bool overscan = (m & 0x0040) != 0; + bool st = (m & 0x0080) != 0; + bool interlace = (m & 0x0100) != 0; + return ENODEV; +} + + +status_t +FalconModeAPI::Set(const struct video_mode *mode) +{ + return ENODEV; +} + + +static FalconModeAPI sFalconModeAPI; + + // #pragma mark - @@ -133,6 +231,7 @@ // ToDo: implement me dprintf("current video mode: \n"); dprintf("Vsetmode(-1): 0x%08x\n", VsetMode(VM_INQUIRE)); + sFalconModeAPI.Enumerate(); return B_OK; } Modified: haiku/trunk/src/system/boot/platform/atari_m68k/video.h =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/video.h 2008-08-02 23:57:03 UTC (rev 26748) +++ haiku/trunk/src/system/boot/platform/atari_m68k/video.h 2008-08-03 01:40:57 UTC (rev 26749) @@ -8,7 +8,14 @@ #include +/* 4CCs for custom colorspaces */ +// XXX: move to kernel/app_server header ? +#define ATARI_IBP1 'IBP1' +#define ATARI_IBP2 'IBP2' +#define ATARI_IBP4 'IBP4' +#define ATARI_IBP8 'IBP8' + class Menu; class MenuItem; From bonefish at mail.berlios.de Sun Aug 3 03:48:18 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 3 Aug 2008 03:48:18 +0200 Subject: [Haiku-commits] r26750 - in haiku/trunk: build/config_headers src/system/kernel/fs Message-ID: <200808030148.m731mIEG000581@sheep.berlios.de> Author: bonefish Date: 2008-08-03 03:48:10 +0200 (Sun, 03 Aug 2008) New Revision: 26750 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26750&view=rev Modified: haiku/trunk/build/config_headers/tracing_config.h haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * Added tracing for vfs_{read,write}_pages). * {read,write}_pages() use vfs_{read,write}_pages() now, instead of invoking the FS {read,write}_pages() hooks. Modified: haiku/trunk/build/config_headers/tracing_config.h =================================================================== --- haiku/trunk/build/config_headers/tracing_config.h 2008-08-03 01:40:57 UTC (rev 26749) +++ haiku/trunk/build/config_headers/tracing_config.h 2008-08-03 01:48:10 UTC (rev 26750) @@ -38,6 +38,7 @@ #define TCP_TRACING 0 #define TEAM_TRACING 0 #define USER_MALLOC_TRACING 0 +#define VFS_PAGES_IO_TRACING 0 #define VM_CACHE_TRACING 0 #define WAIT_FOR_OBJECTS_TRACING 0 Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-03 01:40:57 UTC (rev 26749) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-03 01:48:10 UTC (rev 26750) @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -496,6 +497,109 @@ }; +#if VFS_PAGES_IO_TRACING + +namespace VFSPagesIOTracing { + +class PagesIOTraceEntry : public AbstractTraceEntry { +protected: + PagesIOTraceEntry(struct vnode* vnode, void* cookie, off_t pos, + const iovec* vecs, uint32 count, uint32 flags, size_t bytesRequested, + status_t status, size_t bytesTransferred) + : + fVnode(vnode), + fMountID(vnode->mount->id), + fNodeID(vnode->id), + fCookie(cookie), + fPos(pos), + fCount(count), + fFlags(flags), + fBytesRequested(bytesRequested), + fStatus(status), + fBytesTransferred(bytesTransferred) + { + fVecs = (iovec*)alloc_tracing_buffer_memcpy(vecs, sizeof(iovec) * count, + false); + } + + void AddDump(TraceOutput& out, const char* mode) + { + out.Print("vfs pages io %5s: vnode: %p (%ld, %lld), cookie: %p, " + "pos: %lld, size: %lu, vecs: {", mode, fVnode, fMountID, fNodeID, + fCookie, fPos, fBytesRequested); + + if (fVecs != NULL) { + for (uint32 i = 0; i < fCount; i++) { + if (i > 0) + out.Print(", "); + out.Print("(%p, %lu)", fVecs[i].iov_base, fVecs[i].iov_len); + } + } + + out.Print("}, flags: %#lx -> status: %#lx, transferred: %lu", + fFlags, fStatus, fBytesTransferred); + } + +protected: + struct vnode* fVnode; + dev_t fMountID; + ino_t fNodeID; + void* fCookie; + off_t fPos; + iovec* fVecs; + uint32 fCount; + uint32 fFlags; + size_t fBytesRequested; + status_t fStatus; + size_t fBytesTransferred; +}; + + +class ReadPages : public PagesIOTraceEntry { +public: + ReadPages(struct vnode* vnode, void* cookie, off_t pos, + const iovec* vecs, uint32 count, uint32 flags, size_t bytesRequested, + status_t status, size_t bytesTransferred) + : + PagesIOTraceEntry(vnode, cookie, pos, vecs, count, flags, + bytesRequested, status, bytesTransferred) + { + Initialized(); + } + + virtual void AddDump(TraceOutput& out) + { + PagesIOTraceEntry::AddDump(out, "read"); + } +}; + + +class WritePages : public PagesIOTraceEntry { +public: + WritePages(struct vnode* vnode, void* cookie, off_t pos, + const iovec* vecs, uint32 count, uint32 flags, size_t bytesRequested, + status_t status, size_t bytesTransferred) + : + PagesIOTraceEntry(vnode, cookie, pos, vecs, count, flags, + bytesRequested, status, bytesTransferred) + { + Initialized(); + } + + virtual void AddDump(TraceOutput& out) + { + PagesIOTraceEntry::AddDump(out, "write"); + } +}; + +} // namespace VFSPagesIOTracing + +# define TPIO(x) new(std::nothrow) VFSPagesIOTracing::x; +#else +# define TPIO(x) ; +#endif // VFS_PAGES_IO_TRACING + + static int mount_compare(void *_m, const void *_key) { @@ -3321,8 +3425,8 @@ if (descriptor == NULL) return B_FILE_ERROR; - status_t status = FS_CALL(vnode, read_pages, descriptor->cookie, pos, vecs, - count, _numBytes); + status_t status = vfs_read_pages(vnode, descriptor->cookie, pos, vecs, + count, 0, _numBytes); put_fd(descriptor); return status; @@ -3340,8 +3444,8 @@ if (descriptor == NULL) return B_FILE_ERROR; - status_t status = FS_CALL(vnode, write_pages, descriptor->cookie, pos, vecs, - count, _numBytes); + status_t status = vfs_write_pages(vnode, descriptor->cookie, pos, vecs, + count, 0, _numBytes); put_fd(descriptor); return status; @@ -3923,6 +4027,10 @@ FUNCTION(("vfs_read_pages: vnode %p, vecs %p, pos %Ld\n", vnode, vecs, pos)); +#if VFS_PAGES_IO_TRACING + size_t bytesRequested = *_numBytes; +#endif + IORequest request; status_t status = request.Init(pos, vecs, count, *_numBytes, false, flags); if (status == B_OK) { @@ -3932,6 +4040,9 @@ *_numBytes = request.TransferredBytes(); } + TPIO(ReadPages(vnode, cookie, pos, vecs, count, flags, bytesRequested, + status, *_numBytes)); + return status; } @@ -3943,6 +4054,10 @@ FUNCTION(("vfs_write_pages: vnode %p, vecs %p, pos %Ld\n", vnode, vecs, pos)); +#if VFS_PAGES_IO_TRACING + size_t bytesRequested = *_numBytes; +#endif + IORequest request; status_t status = request.Init(pos, vecs, count, *_numBytes, true, flags); if (status == B_OK) { @@ -3952,6 +4067,9 @@ *_numBytes = request.TransferredBytes(); } + TPIO(WritePages(vnode, cookie, pos, vecs, count, flags, bytesRequested, + status, *_numBytes)); + return status; } From bonefish at mail.berlios.de Sun Aug 3 03:55:31 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sun, 3 Aug 2008 03:55:31 +0200 Subject: [Haiku-commits] r26751 - haiku/trunk/src/system/kernel/fs Message-ID: <200808030155.m731tVPD003819@sheep.berlios.de> Author: bonefish Date: 2008-08-03 03:55:25 +0200 (Sun, 03 Aug 2008) New Revision: 26751 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26751&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp Log: * Use vfs_vnode_io() to schedule subrequests instead of calling the FS's io() hook directly (it might not even have one). * Fixed incorrect check in synchronous_io() which would cause requests with more than one vec to finish early. Fixes bug #2558. Modified: haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-03 01:48:10 UTC (rev 26750) +++ haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-03 01:55:25 UTC (rev 26751) @@ -210,7 +210,7 @@ if (error == B_OK) { TRACE_RIO("[%ld] scheduling subrequest: %p\n", find_thread(NULL), subRequest); - error = FS_CALL(cookie->vnode, io, cookie->descriptor->cookie, + error = vfs_vnode_io(cookie->vnode, cookie->descriptor->cookie, subRequest); } else { // Once scheduling a subrequest failed, we cancel all subsequent @@ -335,7 +335,7 @@ offset += transferred; length -= transferred; - if (transferred != length) + if (transferred != vecLength) break; } From ingo_weinhold at gmx.de Sun Aug 3 04:24:56 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sun, 03 Aug 2008 04:24:56 +0200 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <1e80d8750808021527g1af431c3t9c1c9dbb7ab67e53@mail.gmail.com> References: <200808021854.m72IsE2B006168@sheep.berlios.de> <20080802190539.297340@gmx.net> <1e80d8750808021527g1af431c3t9c1c9dbb7ab67e53@mail.gmail.com> Message-ID: <20080803042456.373.1@knochen-vm.localdomain> On 2008-08-03 at 00:27:47 [+0200], Urias McCullough wrote: > 2008/8/2 Stephan Assmus : > > The revision is 26880, which doesn't yet have any of the BFS and I/O > > scheduler changes. > > I assume you mean 26680? And the IO scheduler stuff was enabled in 26691 > right? > > I'm trying to figure out what the safest rev to demo Haiku next week > will be. I seems that 26691 is stable with the exception of the > directory deletion issue (fixed in 26694 IIRC) - so I rolled back to > 26688 before the locking changes were made. > > I'm getting an occasional "Invalid Opcode Exception" when messing > around with configure scripts and compiling various libs and > whatnot... I haven't found any sort of reproducible scenario, nor have > i had a chance to get serial output from the KDLs. > > Perhaps I should grab 26691 and apply the patch from 26694 directly... Since there are more major changes to come in critical subsystems (particularly I/O and VM) which will almost inevitably be accompanied by some more bugs, maybe it's time to start tagging revisions that are generally perceived as relatively stable, and perhaps even maintain them for a short time as branches. That would be handy for people who want to demo Haiku or who want to get serious work done without running into every latest bug. CU, Ingo From umccullough at gmail.com Sun Aug 3 04:57:29 2008 From: umccullough at gmail.com (Urias McCullough) Date: Sat, 2 Aug 2008 19:57:29 -0700 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <20080803042456.373.1@knochen-vm.localdomain> References: <200808021854.m72IsE2B006168@sheep.berlios.de> <20080802190539.297340@gmx.net> <1e80d8750808021527g1af431c3t9c1c9dbb7ab67e53@mail.gmail.com> <20080803042456.373.1@knochen-vm.localdomain> Message-ID: <1e80d8750808021957l61c01b6eoc35360a9746b973c@mail.gmail.com> 2008/8/2 Ingo Weinhold : >> I'm trying to figure out what the safest rev to demo Haiku next week >> will be. I seems that 26691 is stable with the exception of the >> directory deletion issue (fixed in 26694 IIRC) - so I rolled back to >> 26688 before the locking changes were made. > > Since there are more major changes to come in critical subsystems > (particularly I/O and VM) which will almost inevitably be accompanied by > some more bugs, maybe it's time to start tagging revisions that are > generally perceived as relatively stable, and perhaps even maintain them > for a short time as branches. That would be handy for people who want to > demo Haiku or who want to get serious work done without running into every > latest bug. If it's the right time to do this, then I'm totally for it :) FWIW, in the last week or so I have been able to use haiku for compiling and testing various libs and software (tuxpaint!) for well over 24 hours at a time (leaving it running as I crawl off to bed)... including full download of sources from SVN and compiling Haiku to a separate partition (which then booted once I fixed my grub problems). It was definitely quite stable at that time... and it's pretty darn close still at the moment. From stippi at mail.berlios.de Sun Aug 3 12:45:53 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Aug 2008 12:45:53 +0200 Subject: [Haiku-commits] r26752 - haiku/trunk/src/apps/text_search Message-ID: <200808031045.m73AjrEA020249@sheep.berlios.de> Author: stippi Date: 2008-08-03 12:45:51 +0200 (Sun, 03 Aug 2008) New Revision: 26752 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26752&view=rev Added: haiku/trunk/src/apps/text_search/FileIterator.cpp haiku/trunk/src/apps/text_search/FileIterator.h Modified: haiku/trunk/src/apps/text_search/GlobalDefs.h haiku/trunk/src/apps/text_search/GrepWindow.cpp haiku/trunk/src/apps/text_search/Grepper.cpp haiku/trunk/src/apps/text_search/Grepper.h haiku/trunk/src/apps/text_search/Jamfile haiku/trunk/src/apps/text_search/Model.h Log: Refactored a new class FileIterator from Grepper that will make adding node monitoring easier. Also, FileIterator will be split to make the code cleaner with regards to folder or selection mode. Added: haiku/trunk/src/apps/text_search/FileIterator.cpp =================================================================== --- haiku/trunk/src/apps/text_search/FileIterator.cpp 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/FileIterator.cpp 2008-08-03 10:45:51 UTC (rev 26752) @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 "FileIterator.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include "Model.h" + +using std::nothrow; + +// TODO: stippi: Check if this is a the best place to maintain a global +// list of files and folders for node monitoring. It should probably monitor +// every file that was grepped, as well as every visited (sub) folder. +// For the moment I don't know the life cycle of the FileIterator object. + + +FileIterator::FileIterator(Model* model) + : fDirectories(10), + fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), + fCurrentRef(0), + fModel(model) +{ + if (!fCurrentDir || !fDirectories.AddItem(fCurrentDir)) { + // init error + delete fCurrentDir; + fCurrentDir = NULL; + } +} + + +FileIterator::~FileIterator() +{ + for (int32 i = fDirectories.CountItems() - 1; i >= 0; i--) + delete (BDirectory*)fDirectories.ItemAt(i); +} + + +bool +FileIterator::IsValid() const +{ + return fCurrentDir != NULL; +} + + +bool +FileIterator::GetNextName(char* buffer) +{ + BEntry entry; + struct stat fileStat; + + while (true) { + // Traverse the directory to get a new BEntry. + // _GetNextEntry returns false if there are no + // more entries, and we exit the loop. + + if (!_GetNextEntry(entry)) + return false; + + // If the entry is a subdir, then add it to the + // list of directories and continue the loop. + // If the entry is a file and we can grep it + // (i.e. it is a text file), then we're done + // here. Otherwise, continue with the next entry. + + if (entry.GetStat(&fileStat) == B_OK) { + if (S_ISDIR(fileStat.st_mode)) { + // subdir + _ExamineSubdir(entry); + } else { + // file or a (non-traversed) symbolic link + if (_ExamineFile(entry, buffer)) + return true; + } + } + } +} + + +// #pragma mark - private + + +bool +FileIterator::_GetNextEntry(BEntry& entry) +{ + if (fDirectories.CountItems() == 1) + return _GetTopEntry(entry); + else + return _GetSubEntry(entry); +} + + +bool +FileIterator::_GetTopEntry(BEntry& entry) +{ + // If the user selected one or more files, we must look + // at the "refs" inside the message that was passed into + // our add-on's process_refs(). If the user didn't select + // any files, we will simply read all the entries from the + // current working directory. + + entry_ref fileRef; + + if (fModel->fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) { + entry.SetTo(&fileRef, fModel->fRecurseLinks); + ++fCurrentRef; + return true; + } else if (fCurrentRef > 0) { + // when we get here, we have processed + // all the refs from the message + return false; + } else if (fCurrentDir != NULL) { + // examine the whole directory + return fCurrentDir->GetNextEntry(&entry, + fModel->fRecurseLinks) == B_OK; + } + + return false; +} + + +bool +FileIterator::_GetSubEntry(BEntry& entry) +{ + if (!fCurrentDir) + return false; + + if (fCurrentDir->GetNextEntry(&entry, fModel->fRecurseLinks) == B_OK) + return true; + + // If we get here, there are no more entries in + // this subdir, so return to the parent directory. + + fDirectories.RemoveItem(fCurrentDir); + delete fCurrentDir; + fCurrentDir = (BDirectory*)fDirectories.LastItem(); + + return _GetNextEntry(entry); +} + + +void +FileIterator::_ExamineSubdir(BEntry& entry) +{ + if (!fModel->fRecurseDirs) + return; + + if (fModel->fSkipDotDirs) { + char nameBuf[B_FILE_NAME_LENGTH]; + if (entry.GetName(nameBuf) == B_OK) { + if (*nameBuf == '.') + return; + } + } + + BDirectory* dir = new (nothrow) BDirectory(&entry); + if (dir == NULL || dir->InitCheck() != B_OK + || !fDirectories.AddItem(dir)) { + // clean up + delete dir; + return; + } + + fCurrentDir = dir; +} + + +bool +FileIterator::_ExamineFile(BEntry& entry, char* buffer) +{ + BPath path; + if (entry.GetPath(&path) != B_OK) + return false; + + strcpy(buffer, path.Path()); + + if (!fModel->fTextOnly) + return true; + + BNode node(&entry); + BNodeInfo nodeInfo(&node); + char mimeTypeString[B_MIME_TYPE_LENGTH]; + + if (nodeInfo.GetType(mimeTypeString) == B_OK) { + BMimeType mimeType(mimeTypeString); + BMimeType superType; + + if (mimeType.GetSupertype(&superType) == B_OK) { + if (strcmp("text", superType.Type()) == 0 + || strcmp("message", superType.Type()) == 0) { + return true; + } + } + } + + return false; +} + Added: haiku/trunk/src/apps/text_search/FileIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-03 10:45:51 UTC (rev 26752) @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 FILE_ITERATOR_H +#define FILE_ITERATOR_H + +#include + +class BEntry; +class BDirectory; +class Model; + +// TODO: split into Folder and MessageFileIterator (_GetTopEntry) + +// Provides an interface to retrieve the next file that should be grepped +// for the search string. +class FileIterator { +public: + FileIterator(Model* model); + virtual ~FileIterator(); + + virtual bool IsValid() const; + + // Returns the full path name of the next file. + virtual bool GetNextName(char* buffer); + +private: + // Looks for the next entry. + bool _GetNextEntry(BEntry& entry); + + // Looks for the next entry in the top-level dir. + bool _GetTopEntry(BEntry& entry); + + // Looks for the next entry in a subdir. + bool _GetSubEntry(BEntry& entry); + + // Determines whether we can add a subdir. + void _ExamineSubdir(BEntry& entry); + + // Determines whether we can grep a file. + bool _ExamineFile(BEntry& entry, char* buffer); + +private: + // Contains pointers to BDirectory objects. + BList fDirectories; + + // The directory we are currently looking at. + BDirectory* fCurrentDir; + + // The ref number we are currently looking at. + int32 fCurrentRef; + + // The directory or files to grep on. + Model* fModel; +}; + +#endif // FILE_ITERATOR_H Modified: haiku/trunk/src/apps/text_search/GlobalDefs.h =================================================================== --- haiku/trunk/src/apps/text_search/GlobalDefs.h 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/GlobalDefs.h 2008-08-03 10:45:51 UTC (rev 26752) @@ -5,7 +5,15 @@ #ifndef GLOBAL_DEFS_H #define GLOBAL_DEFS_H + #define APP_SIGNATURE "application/x-vnd.mahlzeit.trackergrep" #define APP_NAME "TextSearch" +#define PREFS_FILE "TextSearchSettings" +#define HISTORY_LIMIT 20 + +#define TRACKER_SIGNATURE "application/x-vnd.Be-TRAK" +#define PE_SIGNATURE "application/x-vnd.beunited.pe" + + #endif // GLOBAL_DEFS_H Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-03 10:45:51 UTC (rev 26752) @@ -38,6 +38,7 @@ #include #include +#include "FileIterator.h" #include "GlobalDefs.h" #include "Grepper.h" #include "Translation.h" @@ -112,10 +113,7 @@ GrepWindow::~GrepWindow() { - if (fModel->fState == STATE_SEARCH) { - fGrepper->Cancel(); - } - + delete fGrepper; delete fModel; } @@ -708,8 +706,21 @@ fOldPattern = fSearchText->Text(); - fGrepper = new Grepper(fOldPattern.String(), fModel); - fGrepper->Start(); + FileIterator* iterator = new (nothrow) FileIterator(fModel); + fGrepper = new (nothrow) Grepper(fOldPattern.String(), fModel, + iterator); + if (fGrepper != NULL && fGrepper->IsValid()) + fGrepper->Start(); + else { + // roll back in case of problems + if (fGrepper == NULL) + delete iterator; + delete fGrepper; + fGrepper = NULL; + fModel->fState = STATE_CANCEL; + // TODO: better notification to user + fprintf(stderr, "Out of memory.\n"); + } } else if (fModel->fState == STATE_SEARCH) { fModel->fState = STATE_CANCEL; fGrepper->Cancel(); Modified: haiku/trunk/src/apps/text_search/Grepper.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-03 10:45:51 UTC (rev 26752) @@ -33,6 +33,8 @@ #include #include +#include "FileIterator.h" + using std::nothrow; // TODO: stippi: Check if this is a the best place to maintain a global @@ -88,24 +90,13 @@ } -Grepper::Grepper(const char* pattern, Model* model) - : fDirectories(new (nothrow) BList(10)), - fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), - fCurrentRef(0), - fPattern(NULL), +Grepper::Grepper(const char* pattern, Model* model, FileIterator* iterator) + : fPattern(NULL), fModel(model), + fIterator(iterator), fThreadId(-1), fMustQuit(false) { - if (!fCurrentDir || !fDirectories || !fDirectories->AddItem(fCurrentDir)) { - // init error - delete fCurrentDir; - fCurrentDir = NULL; - delete fDirectories; - fDirectories = NULL; - return; - } - if (fModel->fEncoding) { char *src = strdup_from_utf8(fModel->fEncoding, pattern, strlen(pattern)); @@ -119,26 +110,17 @@ Grepper::~Grepper() { Cancel(); - free(fPattern); - - // If the thread terminated normally, then there is only - // one object in the list: the initial directory. But if - // the user aborted the search, there may be more. - - if (fDirectories) { - for (int32 i = fDirectories->CountItems() - 1; i >= 0; i--) - delete static_cast(fDirectories->ItemAt(i)); - - delete fDirectories; - } + delete fIterator; } bool Grepper::IsValid() const { - return fPattern != NULL && fDirectories != NULL && fCurrentDir != NULL; + if (fIterator == NULL || !fIterator->IsValid()) + return false; + return fPattern != NULL && fModel != NULL; } @@ -192,7 +174,7 @@ sprintf(fileName, "/boot/var/tmp/SearchText%ld", fThreadId); tempFile.SetTo(fileName); - while (!fMustQuit && _GetNextName(fileName)) { + while (!fMustQuit && fIterator->GetNextName(fileName)) { message.MakeEmpty(); message.what = MSG_REPORT_FILE_NAME; message.AddString("filename", fileName); @@ -344,153 +326,3 @@ return result; } - -bool -Grepper::_GetNextName(char* buffer) -{ - BEntry entry; - struct stat fileStat; - - while (true) { - // Traverse the directory to get a new BEntry. - // _GetNextEntry returns false if there are no - // more entries, and we exit the loop. - - if (!_GetNextEntry(entry)) - return false; - - // If the entry is a subdir, then add it to the - // list of directories and continue the loop. - // If the entry is a file and we can grep it - // (i.e. it is a text file), then we're done - // here. Otherwise, continue with the next entry. - - if (entry.GetStat(&fileStat) == B_OK) { - if (S_ISDIR(fileStat.st_mode)) { - // subdir - _ExamineSubdir(entry); - } else { - // file or a (non-traversed) symbolic link - if (_ExamineFile(entry, buffer)) - return true; - } - } - } -} - - -bool -Grepper::_GetNextEntry(BEntry& entry) -{ - if (fDirectories->CountItems() == 1) - return _GetTopEntry(entry); - else - return _GetSubEntry(entry); -} - - -bool -Grepper::_GetTopEntry(BEntry& entry) -{ - // If the user selected one or more files, we must look - // at the "refs" inside the message that was passed into - // our add-on's process_refs(). If the user didn't select - // any files, we will simply read all the entries from the - // current working directory. - - entry_ref fileRef; - - if (fModel->fSelectedFiles.FindRef("refs", - fCurrentRef, &fileRef) == B_OK) { - entry.SetTo(&fileRef, fModel->fRecurseLinks); - ++fCurrentRef; - return true; - } else if (fCurrentRef > 0) { - // when we get here, we have processed - // all the refs from the message - return false; - } else { - // examine the whole directory - return fCurrentDir->GetNextEntry(&entry, - fModel->fRecurseLinks) == B_OK; - } -} - - -bool -Grepper::_GetSubEntry(BEntry& entry) -{ - if (!fCurrentDir) - return false; - - if (fCurrentDir->GetNextEntry(&entry, fModel->fRecurseLinks) == B_OK) - return true; - - // If we get here, there are no more entries in - // this subdir, so return to the parent directory. - - fDirectories->RemoveItem(fCurrentDir); - delete fCurrentDir; - fCurrentDir = (BDirectory*)fDirectories->LastItem(); - - return _GetNextEntry(entry); -} - - -void -Grepper::_ExamineSubdir(BEntry& entry) -{ - if (!fModel->fRecurseDirs) - return; - - if (fModel->fSkipDotDirs) { - char nameBuf[B_FILE_NAME_LENGTH]; - if (entry.GetName(nameBuf) == B_OK) { - if (*nameBuf == '.') - return; - } - } - - BDirectory* dir = new (nothrow) BDirectory(&entry); - if (dir == NULL || dir->InitCheck() != B_OK - || !fDirectories->AddItem(dir)) { - // clean up - delete dir; - return; - } - - fCurrentDir = dir; -} - - -bool -Grepper::_ExamineFile(BEntry& entry, char* buffer) -{ - BPath path; - if (entry.GetPath(&path) != B_OK) - return false; - - strcpy(buffer, path.Path()); - - if (!fModel->fTextOnly) - return true; - - BNode node(&entry); - BNodeInfo nodeInfo(&node); - char mimeTypeString[B_MIME_TYPE_LENGTH]; - - if (nodeInfo.GetType(mimeTypeString) == B_OK) { - BMimeType mimeType(mimeTypeString); - BMimeType superType; - - if (mimeType.GetSupertype(&superType) == B_OK) { - if (strcmp("text", superType.Type()) == 0 - || strcmp("message", superType.Type()) == 0) { - return true; - } - } - } - - return false; -} - Modified: haiku/trunk/src/apps/text_search/Grepper.h =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.h 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/Grepper.h 2008-08-03 10:45:51 UTC (rev 26752) @@ -24,10 +24,13 @@ #include "Model.h" +class FileIterator; + // Executes "grep" in a background thread. class Grepper { public: - Grepper(const char* pattern, Model* model); + Grepper(const char* pattern, Model* model, + FileIterator* iterator); virtual ~Grepper(); bool IsValid() const; @@ -49,44 +52,19 @@ // to prevent the shell from misinterpreting them. bool _EscapeSpecialChars(char* buffer, ssize_t bufferSize); - - // Returns the full path name of the next file. - bool _GetNextName(char* buffer); - - // Looks for the next entry. - bool _GetNextEntry(BEntry& entry); - - // Looks for the next entry in the top-level dir. - bool _GetTopEntry(BEntry& entry); - - // Looks for the next entry in a subdir. - bool _GetSubEntry(BEntry& entry); - - // Determines whether we can add a subdir. - void _ExamineSubdir(BEntry& entry); - - // Determines whether we can grep a file. - bool _ExamineFile(BEntry& entry, char* buffer); - -private: - // Contains pointers to BDirectory objects. - BList* fDirectories; - - // The directory we are currently looking at. - BDirectory* fCurrentDir; - - // The ref number we are currently looking at. - int32 fCurrentRef; - + private: // The (escaped) search pattern. char* fPattern; // The directory or files to grep on. Model* fModel; + // The supplier of files to grep + FileIterator* fIterator; + // Our thread's ID. thread_id fThreadId; - + // Whether our thread must quit. volatile bool fMustQuit; }; Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-03 10:45:51 UTC (rev 26752) @@ -3,6 +3,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; Application TextSearch : + FileIterator.cpp GrepApp.cpp GrepListView.cpp Grepper.cpp Modified: haiku/trunk/src/apps/text_search/Model.h =================================================================== --- haiku/trunk/src/apps/text_search/Model.h 2008-08-03 01:55:25 UTC (rev 26751) +++ haiku/trunk/src/apps/text_search/Model.h 2008-08-03 10:45:51 UTC (rev 26752) @@ -32,14 +32,9 @@ #include #include +#include "GlobalDefs.h" -#define PREFS_FILE "TrackerGrepSettings" -#define HISTORY_LIMIT 20 -#define TRACKER_SIGNATURE "application/x-vnd.Be-TRAK" -#define PE_SIGNATURE "application/x-vnd.beunited.pe" - - enum { MSG_START_CANCEL = 1000, MSG_RECURSE_LINKS, @@ -89,6 +84,7 @@ void AddToHistory(const char* text); void FillHistoryMenu(BMenu* menu); +public: // The directory we were invoked from. entry_ref fDirectory; From axeld at pinc-software.de Sun Aug 3 13:16:38 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 13:16:38 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26736_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/file=5Fsystems/bfs?= In-Reply-To: <200808021741.m72HfCSM030259@sheep.berlios.de> Message-ID: <2804278185-BeMail@zon> bonefish at mail.berlios.de wrote: > Log: > * Fixed recently introduced write lock leak, when something failed > before file_cache_write() or nothing had to be written. > * Fixed race condition. While neither transaction nor read lock are > held, the file size can change. > * Add the inode to the transaction whenever possible, i.e. on error > before file_cache_write() and after it as well. This should prevent > readers from seeing inconsistent blocks when the transaction has to > be > rolled back. Thanks! Bye, Axel. From mmu_man at mail.berlios.de Sun Aug 3 14:09:25 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 14:09:25 +0200 Subject: [Haiku-commits] r26753 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200808031209.m73C9Pdn031011@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 14:09:23 +0200 (Sun, 03 Aug 2008) New Revision: 26753 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26753&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp Log: Handle new semantics on map_max_pages_need. Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-03 10:45:51 UTC (rev 26752) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-03 12:09:23 UTC (rev 26753) @@ -227,7 +227,7 @@ addr_t pa; int32 index; status_t err = B_ERROR; // no pagetable here - TRACE(("%s(%p,)", __FUNCTION__, va)); + TRACE(("%s(%p,)\n", __FUNCTION__, va)); index = VADDR_TO_PRENT(va); TRACE(("%s: pr[%d].type %d\n", __FUNCTION__, index, pr[index].type)); @@ -485,7 +485,15 @@ map_max_pages_need(vm_translation_map */*map*/, addr_t start, addr_t end) { size_t need; - size_t pgdirs = VADDR_TO_PRENT(end) + 1 - VADDR_TO_PRENT(start); + size_t pgdirs; + // If start == 0, the actual base address is not yet known to the caller + // and we shall assume the worst case. + if (start == 0) { +#warning M68K: FIXME? + start = (1023) * B_PAGE_SIZE; + end += start; + } + pgdirs = VADDR_TO_PRENT(end) + 1 - VADDR_TO_PRENT(start); // how much for page directories need = (pgdirs + NUM_DIRTBL_PER_PAGE - 1) / NUM_DIRTBL_PER_PAGE; // and page tables themselves @@ -1236,7 +1244,7 @@ &sIOSpaceBase, IOSPACE_SIZE, IOSPACE_CHUNK_SIZE); if (error != B_OK) return error; - + TRACE(("iospace at %p\n", sIOSpaceBase)); // initialize our data structures memset(iospace_pgtables, 0, B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * NUM_PAGEENT_PER_TBL * NUM_PAGETBL_PER_PAGE))); From axeld at pinc-software.de Sun Aug 3 14:12:43 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 14:12:43 +0200 CEST Subject: [Haiku-commits] r26752 - haiku/trunk/src/apps/text_search In-Reply-To: <200808031045.m73AjrEA020249@sheep.berlios.de> Message-ID: <6169721036-BeMail@zon> stippi at BerliOS wrote: > Log: > Refactored a new class FileIterator from Grepper that will make > adding > node monitoring easier. Also, FileIterator will be split to make the > code > cleaner with regards to folder or selection mode. How about integrating it into the find panel functionality in Tracker? That would be much more beneficial for everyone, I guess. Bye, Axel. From axeld at mail.berlios.de Sun Aug 3 14:51:40 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 14:51:40 +0200 Subject: [Haiku-commits] r26754 - haiku/trunk/headers/posix/sys Message-ID: <200808031251.m73CpeId002671@sheep.berlios.de> Author: axeld Date: 2008-08-03 14:51:40 +0200 (Sun, 03 Aug 2008) New Revision: 26754 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26754&view=rev Modified: haiku/trunk/headers/posix/sys/stat.h Log: * Patch by Andreas F?\195?\164rber: remove undefined S_ISTXT from ALLPERMS. * This fixes bug #2560. Modified: haiku/trunk/headers/posix/sys/stat.h =================================================================== --- haiku/trunk/headers/posix/sys/stat.h 2008-08-03 12:09:23 UTC (rev 26753) +++ haiku/trunk/headers/posix/sys/stat.h 2008-08-03 12:51:40 UTC (rev 26754) @@ -93,7 +93,7 @@ #define S_IEXEC S_IXUSR #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) -#define ALLPERMS (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO) +#define ALLPERMS (S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO) #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* default file mode, everyone can read/write */ From axeld at pinc-software.de Sun Aug 3 15:00:14 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 15:00:14 +0200 CEST Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <20080803042456.373.1@knochen-vm.localdomain> Message-ID: <9020427257-BeMail@zon> Ingo Weinhold wrote: > Since there are more major changes to come in critical subsystems > (particularly I/O and VM) which will almost inevitably be accompanied > by > some more bugs, maybe it's time to start tagging revisions that are > generally perceived as relatively stable, and perhaps even maintain > them > for a short time as branches. That would be handy for people who want > to > demo Haiku or who want to get serious work done without running into > every > latest bug. Hm, that sounds very much like an alpha release to me ;-) I would actually like to stay away from that for now, though, as what we need to find bugs is exposure; actively maintaining more than a single branch also means more overhead. Remembering (via mailss or tagging) more or less stable releases for demo purposes would be okay, but I wouldn't maintain them in a branch yet. Time to restart the distribution planning, anyway. Bye, Axel. From stippi at mail.berlios.de Sun Aug 3 15:40:55 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 3 Aug 2008 15:40:55 +0200 Subject: [Haiku-commits] r26755 - in haiku/trunk: headers/libs/agg headers/private/app src/kits/interface src/preferences/appearance src/preferences/fonts src/servers/app src/servers/app/drawing/Painter src/servers/app/drawing/Painter/drawing_modes src/tests/servers/app Message-ID: <200808031340.m73Det8h006835@sheep.berlios.de> Author: stippi Date: 2008-08-03 15:40:41 +0200 (Sun, 03 Aug 2008) New Revision: 26755 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26755&view=rev Added: haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.cpp haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.h haiku/trunk/src/servers/app/drawing/Painter/GlobalSubpixelSettings.cpp haiku/trunk/src/servers/app/drawing/Painter/GlobalSubpixelSettings.h haiku/trunk/src/servers/app/drawing/Painter/agg_rasterizer_scanline_aa_subpix.h haiku/trunk/src/servers/app/drawing/Painter/agg_scanline_p_subpix.h haiku/trunk/src/servers/app/drawing/Painter/agg_scanline_p_subpix_avrg_filtering.h haiku/trunk/src/servers/app/drawing/Painter/agg_scanline_u_subpix_avrg_filtering.h Removed: haiku/trunk/src/preferences/fonts/AdvancedSettingsView.cpp haiku/trunk/src/preferences/fonts/AdvancedSettingsView.h Modified: haiku/trunk/headers/libs/agg/agg_renderer_base.h haiku/trunk/headers/private/app/ServerProtocol.h haiku/trunk/src/kits/interface/Font.cpp haiku/trunk/src/kits/interface/InterfaceDefs.cpp haiku/trunk/src/preferences/appearance/APRView.cpp haiku/trunk/src/preferences/appearance/APRView.h haiku/trunk/src/preferences/appearance/APRWindow.cpp haiku/trunk/src/preferences/appearance/APRWindow.h haiku/trunk/src/preferences/appearance/Jamfile haiku/trunk/src/preferences/fonts/FontView.h haiku/trunk/src/preferences/fonts/Jamfile haiku/trunk/src/preferences/fonts/MainWindow.cpp haiku/trunk/src/preferences/fonts/MainWindow.h haiku/trunk/src/servers/app/DesktopSettings.cpp haiku/trunk/src/servers/app/DesktopSettings.h haiku/trunk/src/servers/app/DesktopSettingsPrivate.h haiku/trunk/src/servers/app/FontCacheEntry.cpp haiku/trunk/src/servers/app/FontCacheEntry.h haiku/trunk/src/servers/app/FontEngine.cpp haiku/trunk/src/servers/app/FontEngine.h haiku/trunk/src/servers/app/ProfileMessageSupport.cpp haiku/trunk/src/servers/app/ServerApp.cpp haiku/trunk/src/servers/app/agg_scanline_storage_subpix.h haiku/trunk/src/servers/app/agg_scanline_u_subpix.h haiku/trunk/src/servers/app/drawing/Painter/AGGTextRenderer.cpp haiku/trunk/src/servers/app/drawing/Painter/AGGTextRenderer.h haiku/trunk/src/servers/app/drawing/Painter/Jamfile haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.h haiku/trunk/src/servers/app/drawing/Painter/agg_renderer_region.h haiku/trunk/src/servers/app/drawing/Painter/agg_renderer_scanline_subpix.h haiku/trunk/src/servers/app/drawing/Painter/defines.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAddSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaCCSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaCOSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaCOSolidSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaPCSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaPOSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeAlphaPOSolidSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeBlendSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeCopySUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeCopySolidSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeCopyTextSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeEraseSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeInvertSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeMaxSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeMinSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeOverSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeOverSolidSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeSelectSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/DrawingModeSubtractSUBPIX.h haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/PixelFormat.cpp haiku/trunk/src/servers/app/drawing/Painter/drawing_modes/PixelFormat.h haiku/trunk/src/tests/servers/app/Jamfile Log: Patch by Andrej Spielmann (GSoC): * Simplified the subpixel related methods for the AGG "pixel format" template interface, the ones for the solid cover simply pass through the existing methods, so only one subpixel blending function is left which does the actual work (this removes a lot of the previously added code) * Implemented a new rasterizer based on the original AGG rasterizer which implements subpixel anti-aliasing for any generic AGG vector pipelines. It is now optionally used in Painter and AGGTextRenderer (for vector fonts, ie rotated, sheared or big enough fonts) depending on the global subpixel setting. * Put all subpixel variables into the new GlobalSubpixelSettings.h|cpp * Simplified DesktopSettings related classes a bit and renamed previous FontSubpixelAntialiasing to just SubpixelAntialiasing. * The private libbe functions for subpixel related settings moved from Font.cpp to InterfaceDefs.cpp where other such functions live. They are not related to fonts only anymore. * Removed the subpixel related settings again from the Fonts preflet and added them to the Appearance preflet instead. All of the above implements subpixel anti-aliasing on a global scale, which to my knowledge no other OS is doing at the moment. Any vector rendering can optionally use subpixel anti-aliasing in Haiku now. The bitmap cached fonts are still affected by the Freetype complile time #define to enable the patented subpixel rasterization (three times wide glyphs). Vector fonts and shapes are not affected though at the moment. Modified: haiku/trunk/headers/libs/agg/agg_renderer_base.h =================================================================== --- haiku/trunk/headers/libs/agg/agg_renderer_base.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/headers/libs/agg/agg_renderer_base.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -206,22 +206,7 @@ m_ren->blend_hline(x1, y, x2 - x1 + 1, c, cover); } - //-------------------------------------------------------------------- - void blend_hline_subpix(int x1, int y, int x2, - const color_type& c, cover_type cover) - { - if(x1 > x2) { int t = x2; x2 = x1; x1 = t; } - if(y > ymax()) return; - if(y < ymin()) return; - if(x1 > xmax()) return; - if(x2 < xmin()) return; - if(x1 < xmin()) x1 = xmin(); - if(x2 > xmax()) x2 = xmax(); - - m_ren->blend_hline_subpix(x1, y, x2 - x1 + 1, c, cover); - } - //-------------------------------------------------------------------- void blend_vline(int x, int y1, int y2, const color_type& c, cover_type cover) @@ -309,7 +294,7 @@ { len -= 3 * (xmin() - x); if(len <= 0) return; - covers += 3*(xmin() - x); + covers += 3 * (xmin() - x); x = xmin(); } if(x + len / 3 > xmax()) Modified: haiku/trunk/headers/private/app/ServerProtocol.h =================================================================== --- haiku/trunk/headers/private/app/ServerProtocol.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/headers/private/app/ServerProtocol.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -189,10 +189,15 @@ AS_GET_SHOW_ALL_DRAGGERS, AS_SET_SHOW_ALL_DRAGGERS, - AS_SET_FONT_SUBPIXEL_ANTIALIASING, - AS_GET_FONT_SUBPIXEL_ANTIALIASING, + // Subpixel antialiasing & hinting + AS_SET_SUBPIXEL_ANTIALIASING, + AS_GET_SUBPIXEL_ANTIALIASING, AS_SET_HINTING, AS_GET_HINTING, + AS_SET_SUBPIXEL_AVERAGE_WEIGHT, + AS_GET_SUBPIXEL_AVERAGE_WEIGHT, + AS_SET_SUBPIXEL_ORDERING, + AS_GET_SUBPIXEL_ORDERING, // Graphics calls AS_SET_HIGH_COLOR, Modified: haiku/trunk/src/kits/interface/Font.cpp =================================================================== --- haiku/trunk/src/kits/interface/Font.cpp 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/kits/interface/Font.cpp 2008-08-03 13:40:41 UTC (rev 26755) @@ -406,59 +406,6 @@ } -void -_set_font_subpixel_antialiasing_(bool subpix) -{ - BPrivate::AppServerLink link; - - link.StartMessage(AS_SET_FONT_SUBPIXEL_ANTIALIASING); - link.Attach(subpix); - link.Flush(); -} - - -status_t -_get_font_subpixel_antialiasing_(bool* subpix) -{ - BPrivate::AppServerLink link; - - link.StartMessage(AS_GET_FONT_SUBPIXEL_ANTIALIASING); - int32 status = B_ERROR; - if (link.FlushWithReply(status) != B_OK - || status < B_OK) - return status; - link.Read(subpix); - return B_OK; -} - - -void -_set_hinting_(bool hinting) -{ - BPrivate::AppServerLink link; - - link.StartMessage(AS_SET_HINTING); - link.Attach(hinting); - link.Flush(); -} - - -status_t -_get_hinting_(bool* hinting) -{ - - BPrivate::AppServerLink link; - - link.StartMessage(AS_GET_HINTING); - int32 status = B_ERROR; - if (link.FlushWithReply(status) != B_OK - || status < B_OK) - return status; - link.Read(hinting); - return B_OK; -} - - /*! \brief Returns the number of installed font families \return The number of installed font families Modified: haiku/trunk/src/kits/interface/InterfaceDefs.cpp =================================================================== --- haiku/trunk/src/kits/interface/InterfaceDefs.cpp 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/kits/interface/InterfaceDefs.cpp 2008-08-03 13:40:41 UTC (rev 26755) @@ -195,6 +195,107 @@ } // namespace BPrivate +void +set_subpixel_antialiasing(bool subpix) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_SET_SUBPIXEL_ANTIALIASING); + link.Attach(subpix); + link.Flush(); +} + + +status_t +get_subpixel_antialiasing(bool* subpix) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_GET_SUBPIXEL_ANTIALIASING); + int32 status = B_ERROR; + if (link.FlushWithReply(status) != B_OK || status < B_OK) + return status; + link.Read(subpix); + return B_OK; +} + + +void +set_hinting(bool hinting) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_SET_HINTING); + link.Attach(hinting); + link.Flush(); +} + + +status_t +get_hinting(bool* hinting) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_GET_HINTING); + int32 status = B_ERROR; + if (link.FlushWithReply(status) != B_OK || status < B_OK) + return status; + link.Read(hinting); + return B_OK; +} + + +void +set_average_weight(uint8 averageWeight) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_SET_SUBPIXEL_AVERAGE_WEIGHT); + link.Attach(averageWeight); + link.Flush(); +} + + +status_t +get_average_weight(uint8* averageWeight) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_GET_SUBPIXEL_AVERAGE_WEIGHT); + int32 status = B_ERROR; + if (link.FlushWithReply(status) != B_OK || status < B_OK) + return status; + link.Read(averageWeight); + return B_OK; +} + + +void +set_is_subpixel_ordering_regular(bool subpixelOrdering) +{ + BPrivate::AppServerLink link; + + link.StartMessage(AS_SET_SUBPIXEL_ORDERING); + link.Attach(subpixelOrdering); + link.Flush(); +} + + +status_t +get_is_subpixel_ordering_regular(bool* subpixelOrdering) +{ + + BPrivate::AppServerLink link; + + link.StartMessage(AS_GET_SUBPIXEL_ORDERING); + int32 status = B_ERROR; + if (link.FlushWithReply(status) != B_OK || status < B_OK) + return status; + link.Read(subpixelOrdering); + return B_OK; +} + + const color_map * system_colors() { @@ -965,6 +1066,7 @@ return B_OK; } + } // namespace BPrivate // These methods were marked with "Danger, will Robinson!" in Modified: haiku/trunk/src/preferences/appearance/APRView.cpp =================================================================== --- haiku/trunk/src/preferences/appearance/APRView.cpp 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/APRView.cpp 2008-08-03 13:40:41 UTC (rev 26755) @@ -18,6 +18,7 @@ #include #include "APRView.h" +#include "APRWindow.h" #include "defs.h" #include "ColorWell.h" #include "ColorWhichItem.h" @@ -152,26 +153,7 @@ fPicker = new BColorControl(BPoint(fScrollView->Frame().left,fScrollView->Frame().bottom+kBorderSpace),B_CELLS_32x8,5.0,"fPicker", new BMessage(UPDATE_COLOR)); - AddChild(fPicker); - - fDefaults = new BButton(BRect(0,0,1,1),"DefaultsButton","Defaults", - new BMessage(DEFAULT_SETTINGS), - B_FOLLOW_LEFT |B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); - fDefaults->ResizeToPreferred(); - fDefaults->SetEnabled(false); - fDefaults->MoveTo(fPicker->Frame().left,fPicker->Frame().bottom+kBorderSpace); - AddChild(fDefaults); - - - BRect cvrect(fDefaults->Frame()); - cvrect.OffsetBy(cvrect.Width() + kItemSpace,0); - - fRevert = new BButton(cvrect,"RevertButton","Revert", - new BMessage(REVERT_SETTINGS), - B_FOLLOW_LEFT |B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); - fRevert->ResizeToPreferred(); - fRevert->SetEnabled(false); - AddChild(fRevert); + AddChild(fPicker); } APRView::~APRView(void) @@ -184,21 +166,15 @@ { fPicker->SetTarget(this); fAttrList->SetTarget(this); - fDefaults->SetTarget(this); - fRevert->SetTarget(this); fColorWell->SetTarget(this); fPicker->SetValue(fCurrentSet.StringToColor(fAttrString.String())); if (fDecorMenu) fDecorMenu->SetTargetForItems(BMessenger(this)); - - Window()->ResizeTo(MAX(fPicker->Frame().right,fPicker->Frame().right) + 10, - fDefaults->Frame().bottom + 10); + LoadSettings(); fAttrList->Select(0); - - fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); } void @@ -235,11 +211,9 @@ // Update current fAttribute in the settings fCurrentSet.SetColor(fAttribute, col); - UpdateCurrentColor(); - - fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); - fRevert->SetEnabled(true); - + UpdateCurrentColor(); + + Window()->PostMessage(kMsgUpdate); break; } case ATTRIBUTE_CHOSEN: { @@ -254,7 +228,7 @@ fAttrString=whichitem->Text(); UpdateControlsFromAttr(whichitem->Text()); - fDefaults->SetEnabled(fCurrentSet.IsDefaultable()); + Window()->PostMessage(kMsgUpdate); break; } case REVERT_SETTINGS: { @@ -262,13 +236,11 @@ UpdateControlsFromAttr(fAttrString.String()); UpdateAllColors(); - fRevert->SetEnabled(false); - + Window()->PostMessage(kMsgUpdate); break; } case DEFAULT_SETTINGS: { fCurrentSet = ColorSet::DefaultColorSet(); - fDefaults->SetEnabled(false); UpdateControlsFromAttr(fAttrString.String()); UpdateAllColors(); @@ -281,6 +253,7 @@ BPrivate::set_decorator(fDecorMenu->IndexOf(item)); #endif } + Window()->PostMessage(kMsgUpdate); break; } default: @@ -302,6 +275,11 @@ fPrevSet = fCurrentSet; } +bool APRView::IsDefaultable(void) +{ + return fCurrentSet.IsDefaultable(); +} + void APRView::UpdateAllColors(void) { for (uint32 i = 0; i < sColorCount; i++) Modified: haiku/trunk/src/preferences/appearance/APRView.h =================================================================== --- haiku/trunk/src/preferences/appearance/APRView.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/APRView.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -40,6 +40,7 @@ void MessageReceived(BMessage *msg); void LoadSettings(void); + bool IsDefaultable(void); protected: @@ -49,9 +50,6 @@ BColorControl *fPicker; - BButton *fRevert; - BButton *fDefaults; - BListView *fAttrList; color_which fAttribute; Modified: haiku/trunk/src/preferences/appearance/APRWindow.cpp =================================================================== --- haiku/trunk/src/preferences/appearance/APRWindow.cpp 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/APRWindow.cpp 2008-08-03 13:40:41 UTC (rev 26755) @@ -6,19 +6,101 @@ * DarkWyrm (darkwyrm at earthlink.net) */ +#include #include +#include #include "APRWindow.h" #include "APRView.h" #include "defs.h" +static const uint32 kMsgSetDefaults = 'dflt'; +static const uint32 kMsgRevert = 'rvrt'; + APRWindow::APRWindow(BRect frame) - : BWindow(frame, "Appearance", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, - B_ALL_WORKSPACES ) + : BWindow(frame, "Appearance", B_TITLED_WINDOW, B_NOT_ZOOMABLE, + B_ALL_WORKSPACES) { - APRView *colorview = new APRView(Bounds(),"Colors",B_FOLLOW_ALL, B_WILL_DRAW); - AddChild(colorview); + BRect rect = Bounds(); + BView* view = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW); + view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AddChild(view); + + rect.left = 10; + rect.top = rect.bottom - 10; + fDefaultsButton = new BButton(rect, "defaults", "Defaults", + new BMessage(kMsgSetDefaults), B_FOLLOW_LEFT + | B_FOLLOW_BOTTOM, B_WILL_DRAW); + fDefaultsButton->ResizeToPreferred(); + fDefaultsButton->SetEnabled(false); + float buttonHeight = fDefaultsButton->Bounds().Height(); + fDefaultsButton->MoveBy(0, -buttonHeight); + view->AddChild(fDefaultsButton); + + rect = fDefaultsButton->Frame(); + rect.OffsetBy(fDefaultsButton->Bounds().Width() + 10, 0); + + fRevertButton = new BButton(rect, "revert", "Revert", + new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); + fRevertButton->ResizeToPreferred(); + fRevertButton->SetEnabled(false); + view->AddChild(fRevertButton); + + rect = Bounds(); + rect.top += 5; + rect.bottom -= 20 + buttonHeight; + rect.left += 5; + BTabView *tabView = new BTabView(rect, "tabview", B_WIDTH_FROM_LABEL); + + rect = tabView->ContainerView()->Bounds().InsetByCopy(5, 8); + + fAntialiasingSettings = new AntialiasingSettingsView(rect, "Antialiasing"); + fColorsView = new APRView(rect,"Colors",B_FOLLOW_ALL, B_WILL_DRAW); + + tabView->AddTab(fColorsView); + tabView->AddTab(fAntialiasingSettings); + + view->AddChild(tabView); + fColorsView->ResizeToPreferred(); + fAntialiasingSettings -> ResizeToPreferred(); + + fDefaultsButton -> SetEnabled(fColorsView -> IsDefaultable() + || fAntialiasingSettings -> IsDefaultable()); + fDefaultsButton -> SetTarget(this); + fRevertButton -> SetTarget(this); } + +void +APRWindow::MessageReceived(BMessage *message) +{ + switch (message->what) { + case kMsgUpdate: + fDefaultsButton->SetEnabled(fColorsView->IsDefaultable() + || fAntialiasingSettings->IsDefaultable()); + fRevertButton->SetEnabled(true); + break; + case kMsgSetDefaults: + fColorsView -> MessageReceived(new BMessage(DEFAULT_SETTINGS)); + fAntialiasingSettings->SetDefaults(); + fDefaultsButton->SetEnabled(false); + fRevertButton->SetEnabled(true); + break; + + case kMsgRevert: + fColorsView -> MessageReceived(new BMessage(REVERT_SETTINGS)); + fAntialiasingSettings->Revert(); + fDefaultsButton->SetEnabled(fColorsView->IsDefaultable() + || fAntialiasingSettings->IsDefaultable()); + fRevertButton->SetEnabled(false); + break; + + default: + BWindow::MessageReceived(message); + break; + } +} + + bool APRWindow::QuitRequested(void) { Modified: haiku/trunk/src/preferences/appearance/APRWindow.h =================================================================== --- haiku/trunk/src/preferences/appearance/APRWindow.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/APRWindow.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -9,14 +9,30 @@ #define APR_WINDOW_H #include +#include #include #include +#include +#include "APRView.h" +#include "AntialiasingSettingsView.h" + class APRWindow : public BWindow { public: APRWindow(BRect frame); bool QuitRequested(void); + void MessageReceived(BMessage *message); + +private: + APRView* fColorsView; + BButton* fDefaultsButton; + BButton* fRevertButton; + + AntialiasingSettingsView* fAntialiasingSettings; + }; +static const int32 kMsgUpdate = 'updt'; + #endif Added: haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.cpp 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.cpp 2008-08-03 13:40:41 UTC (rev 26755) @@ -0,0 +1,345 @@ +/* + * Copyright 2008, Andrej Spielmann, + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "AntialiasingSettingsView.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "APRWindow.h" + + +#define INSTANT_UPDATE + // if defined, the changes will take place immediately and not only on exit +//#define DISABLE_HINTING_CONTROL + // if defined, the hinting menu is disabled (hinting not properly + // implemented) + +static const int32 kMsgSetAntialiasing = 'anti'; +static const int32 kMsgSetHinting = 'hint'; +static const int32 kMsgSetAverageWeight = 'avrg'; +static const char* kSubpixelLabel = "Subpixel antialiasing"; +static const char* kGrayscaleLabel = "Grayscale antialiasing"; +static const char* kNoHintingLabel = "Off"; +static const char* kFullHintingLabel = "On"; + +extern void set_subpixel_antialiasing(bool subpix); +extern status_t get_subpixel_antialiasing(bool* subpix); +extern void set_hinting(bool hinting); +extern status_t get_hinting(bool* hinting); +extern void set_average_weight(unsigned char averageWeight); +extern status_t get_average_weight(unsigned char* averageWeight); + + +// #pragma mark - + + +AntialiasingSettingsView::AntialiasingSettingsView(BRect _rect, const char* name) + : BView(_rect, name, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW) +{ + if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK) + fCurrentSubpixelAntialiasing = false; + fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; + + if (get_hinting(&fCurrentHinting) != B_OK) + fCurrentHinting = true; + fSavedHinting = fCurrentHinting; + + if (get_average_weight(&fCurrentAverageWeight) != B_OK) + fCurrentAverageWeight = 100; + fSavedAverageWeight = fCurrentAverageWeight; + + fDivider = StringWidth("Strength of colours in sbpx AA:") + 5; + + fAntialiasingMenu = new BPopUpMenu("Antialiasing menu"); + fHintingMenu = new BPopUpMenu("Hinting menu"); + + // antialiasing menu + BRect rect(Bounds()); + fAntialiasingMenuField = new BMenuField(rect, "antialiasing", + "Antialiasing type:", fAntialiasingMenu, false); + fAntialiasingMenuField->SetDivider(fDivider); + fAntialiasingMenuField->SetAlignment(B_ALIGN_RIGHT); + fAntialiasingMenuField->ResizeToPreferred(); + AddChild(fAntialiasingMenuField); + _BuildAntialiasingMenu(); + + //Average weight in subpixel filtering + float shift = fAntialiasingMenuField->Bounds().Height()+5; + rect.top +=shift; + rect.bottom += shift; + fAverageWeightControl = new BTextControl(rect, "averageWeightControl", + "Strength of colours in sbpx AA:", NULL, + new BMessage(kMsgSetAverageWeight), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); + fAverageWeightControl -> SetDivider(fDivider); + fAverageWeightControl -> TextView() -> SetMaxBytes(3); + fAverageWeightControl -> ResizeToPreferred(); + AddChild(fAverageWeightControl); + for (int i = 0; i < 256; i++) { + if (i < '0' || i > '9') { + fAverageWeightControl->TextView()->DisallowChar(i); + fAverageWeightControl->TextView()->DisallowChar(i); + } + } + fAverageWeightControl -> SetEnabled(false); + + // hinting menu + shift = fAverageWeightControl->Bounds().Height()+5; + rect.top += shift; + rect.bottom += shift; + fHintingMenuField = new BMenuField(rect, "hinting", + "Character hinting:", fHintingMenu, false); + fHintingMenuField->SetDivider(fDivider); + fHintingMenuField->SetAlignment(B_ALIGN_RIGHT); + fHintingMenuField->ResizeToPreferred(); + AddChild(fHintingMenuField); + _BuildHintingMenu(); + +#ifdef DISABLE_HINTING_CONTROL + fHintingMenuField->SetEnabled(false); +#endif + + _SetCurrentAntialiasing(); + _SetCurrentHinting(); + _SetCurrentAverageWeight(); +} + + +AntialiasingSettingsView::~AntialiasingSettingsView() +{ +#ifndef INSTANT_UPDATE + set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); + set_hinting(fCurrentHinting); + set_average_weight(fCurrentAverageWeight); +#endif +} + + +void +AntialiasingSettingsView::GetPreferredSize(float *_width, float *_height) +{ + // don't change the width if it is large enough + if (_width) { + *_width = (StringWidth(kSubpixelLabel) > StringWidth(kGrayscaleLabel) ? + StringWidth(kSubpixelLabel) : StringWidth(kGrayscaleLabel)) + + fDivider + 30; + if (*_width < Bounds().Width()) + *_width = Bounds().Width(); + } + + *_height = fHintingMenuField->Frame().bottom; +} + + +void +AntialiasingSettingsView::SetDivider(float divider) +{ + fAntialiasingMenuField -> SetDivider(divider); + fHintingMenuField -> SetDivider(divider); + fAverageWeightControl -> SetDivider(divider); + fDivider = divider; +} + + +void +AntialiasingSettingsView::RelayoutIfNeeded() +{ + float width, height; + GetPreferredSize(&width, &height); + + if (width > Bounds().Width() || height > Bounds().Height()) { + ResizeTo(width, height); + } +} + + +void +AntialiasingSettingsView::AttachedToWindow() +{ + if (Parent() != NULL) + SetViewColor(Parent()->ViewColor()); + else + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fAntialiasingMenu -> SetTargetForItems(this); + fHintingMenu -> SetTargetForItems(this); + fAverageWeightControl -> SetTarget(this); +} + + +void +AntialiasingSettingsView::MessageReceived(BMessage *msg) +{ + switch (msg->what) { + case kMsgSetAntialiasing: + { + bool subpixelAntialiasing; + if (msg->FindBool("antialiasing", &subpixelAntialiasing) != B_OK + || subpixelAntialiasing == fCurrentSubpixelAntialiasing) + break; + fCurrentSubpixelAntialiasing = subpixelAntialiasing; + fAverageWeightControl -> SetEnabled(fCurrentSubpixelAntialiasing); +#ifdef INSTANT_UPDATE + set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); +#endif + Window()->PostMessage(kMsgUpdate); + break; + } + case kMsgSetHinting: + { + bool hinting; + if (msg->FindBool("hinting", &hinting) != B_OK + || hinting == fCurrentHinting) + break; + fCurrentHinting = hinting; +#ifdef INSTANT_UPDATE + set_hinting(fCurrentHinting); +#endif + Window()->PostMessage(kMsgUpdate); + break; + } + case kMsgSetAverageWeight: + { + int subpixelWeight; + unsigned char averageWeight; + if (fAverageWeightControl -> Text() != NULL) { + subpixelWeight = atoi(fAverageWeightControl -> Text()); + if (subpixelWeight > 255) { + subpixelWeight = 255; + BString subpixelWeightString; + subpixelWeightString << subpixelWeight; + fAverageWeightControl -> SetText( + subpixelWeightString.String()); + } + averageWeight = 255 - subpixelWeight; + if (averageWeight == fCurrentAverageWeight) break; + } else break; + fCurrentAverageWeight = averageWeight; +#ifdef INSTANT_UPDATE + set_average_weight(fCurrentAverageWeight); +#endif + Window()->PostMessage(kMsgUpdate); + break; + } + default: + BView::MessageReceived(msg); + } +} + + +void +AntialiasingSettingsView::_BuildAntialiasingMenu() +{ + BMessage* message = new BMessage(kMsgSetAntialiasing); + message->AddBool("antialiasing", false); + + BMenuItem* item = new BMenuItem(kGrayscaleLabel, message); + + fAntialiasingMenu->AddItem(item); + + BMessage* message2 = new BMessage(kMsgSetAntialiasing); + message2->AddBool("antialiasing", true); + + BMenuItem* item2 = new BMenuItem(kSubpixelLabel, message2); + + fAntialiasingMenu->AddItem(item2); +} + + +void +AntialiasingSettingsView::_BuildHintingMenu() +{ + BMessage* message = new BMessage(kMsgSetHinting); + message->AddBool("hinting", false); + + BMenuItem* item = new BMenuItem(kNoHintingLabel, message); + + fHintingMenu->AddItem(item); + + BMessage* message2 = new BMessage(kMsgSetHinting); + message2->AddBool("hinting", true); + + BMenuItem* item2 = new BMenuItem(kFullHintingLabel, message2); + + fHintingMenu->AddItem(item2); +} + + +void +AntialiasingSettingsView::_SetCurrentAntialiasing() +{ + BMenuItem *item = fAntialiasingMenu->FindItem( + fCurrentSubpixelAntialiasing ? kSubpixelLabel : kGrayscaleLabel); + if (item != NULL) + item->SetMarked(true); + if (fCurrentSubpixelAntialiasing) fAverageWeightControl -> SetEnabled(true); +} + + +void +AntialiasingSettingsView::_SetCurrentHinting() +{ + BMenuItem *item = fHintingMenu->FindItem( + fCurrentHinting ? kFullHintingLabel : kNoHintingLabel); + if (item != NULL) + item->SetMarked(true); +} + + +void +AntialiasingSettingsView::_SetCurrentAverageWeight() +{ + BString subpixelWeightString; + subpixelWeightString << (255 - fCurrentAverageWeight); + fAverageWeightControl -> SetText(subpixelWeightString.String()); +} + + +void +AntialiasingSettingsView::SetDefaults() +{ +} + + +bool +AntialiasingSettingsView::IsDefaultable() +{ + return false; +} + + +bool +AntialiasingSettingsView::IsRevertable() +{ + return (fCurrentSubpixelAntialiasing != fSavedSubpixelAntialiasing) + || (fCurrentHinting != fSavedHinting) + || (fCurrentAverageWeight != fSavedAverageWeight); +} + + +void +AntialiasingSettingsView::Revert() +{ + if (!IsRevertable()) + return; + + fCurrentSubpixelAntialiasing = fSavedSubpixelAntialiasing; + fCurrentHinting = fSavedHinting; + fCurrentAverageWeight = fSavedAverageWeight; +#ifdef INSTANT_UPDATE + set_subpixel_antialiasing(fCurrentSubpixelAntialiasing); + set_hinting(fCurrentHinting); + set_average_weight(fCurrentAverageWeight); +#endif + _SetCurrentAntialiasing(); + _SetCurrentHinting(); + _SetCurrentAverageWeight(); +} Added: haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.h =================================================================== --- haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/AntialiasingSettingsView.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -0,0 +1,59 @@ +/* + * Copyright 2008, Andrej Spielmann, + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef ANTIALIASING_SETTINGS_VIEW_H +#define ANTIALIASING_SETTINGS_VIEW_H + + +#include + +class BBox; +class BMenuField; +class BPopUpMenu; +class BTextControl; + + +class AntialiasingSettingsView : public BView { +public: + AntialiasingSettingsView(BRect rect, + const char* name); + virtual ~AntialiasingSettingsView(); + + virtual void GetPreferredSize(float *_width, float *_height); + virtual void RelayoutIfNeeded(); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage *msg); + + void SetDivider(float divider); + + void SetDefaults(); + void Revert(); + bool IsDefaultable(); + bool IsRevertable(); + +private: + void _BuildAntialiasingMenu(); + void _SetCurrentAntialiasing(); + void _BuildHintingMenu(); + void _SetCurrentHinting(); + void _SetCurrentAverageWeight(); + +protected: + float fDivider; + + BMenuField* fAntialiasingMenuField; + BPopUpMenu* fAntialiasingMenu; + BMenuField* fHintingMenuField; + BPopUpMenu* fHintingMenu; + BTextControl* fAverageWeightControl; + + bool fSavedSubpixelAntialiasing; + bool fCurrentSubpixelAntialiasing; + bool fSavedHinting; + bool fCurrentHinting; + unsigned char fSavedAverageWeight; + unsigned char fCurrentAverageWeight; +}; + +#endif // ANTIALIASING_SETTINGS_VIEW_H Modified: haiku/trunk/src/preferences/appearance/Jamfile =================================================================== --- haiku/trunk/src/preferences/appearance/Jamfile 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/appearance/Jamfile 2008-08-03 13:40:41 UTC (rev 26755) @@ -5,6 +5,7 @@ Preference Appearance : APRMain.cpp + AntialiasingSettingsView.cpp APRView.cpp APRWindow.cpp ColorSet.cpp Deleted: haiku/trunk/src/preferences/fonts/AdvancedSettingsView.cpp Deleted: haiku/trunk/src/preferences/fonts/AdvancedSettingsView.h Modified: haiku/trunk/src/preferences/fonts/FontView.h =================================================================== --- haiku/trunk/src/preferences/fonts/FontView.h 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/fonts/FontView.h 2008-08-03 13:40:41 UTC (rev 26755) @@ -12,7 +12,6 @@ #include "FontSelectionView.h" -#include "AdvancedSettingsView.h" class FontView : public BView { Modified: haiku/trunk/src/preferences/fonts/Jamfile =================================================================== --- haiku/trunk/src/preferences/fonts/Jamfile 2008-08-03 12:51:40 UTC (rev 26754) +++ haiku/trunk/src/preferences/fonts/Jamfile 2008-08-03 13:40:41 UTC (rev 26755) @@ -5,7 +5,6 @@ Preference Fonts : FontSelectionView.cpp - AdvancedSettingsView.cpp FontsSettings.cpp FontView.cpp main.cpp Modified: haiku/trunk/src/preferences/fonts/MainWindow.cpp =================================================================== [... truncated: 6431 lines follow ...] From superstippi at gmx.de Sun Aug 3 16:45:44 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 03 Aug 2008 16:45:44 +0200 Subject: [Haiku-commits] r26752 - haiku/trunk/src/apps/text_search In-Reply-To: <6169721036-BeMail@zon> References: <6169721036-BeMail@zon> Message-ID: <20080803144544.214420@gmx.net> -------- Original-Nachricht -------- > Datum: Sun, 03 Aug 2008 14:12:43 +0200 CEST > Von: "Axel D?rfler" > An: "SVN commits to the Haiku sourcerepository=?utf-8?q?" > Betreff: Re: [Haiku-commits] r26752 - haiku/trunk/src/apps/text_search > stippi at BerliOS wrote: > > Log: > > Refactored a new class FileIterator from Grepper that will make > > adding > > node monitoring easier. Also, FileIterator will be split to make the > > code > > cleaner with regards to folder or selection mode. > > How about integrating it into the find panel functionality in Tracker? > That would be much more beneficial for everyone, I guess. Yeah, perhaps I can do that. First I wanted to add the node monitoring feature, though, since I believe this is really useful and gives a cool effect during a demo. Best regards, -Stephan From axeld at mail.berlios.de Sun Aug 3 17:42:33 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 17:42:33 +0200 Subject: [Haiku-commits] r26756 - haiku/trunk/src/servers/app Message-ID: <200808031542.m73FgXic027118@sheep.berlios.de> Author: axeld Date: 2008-08-03 17:42:32 +0200 (Sun, 03 Aug 2008) New Revision: 26756 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26756&view=rev Modified: haiku/trunk/src/servers/app/Decorator.cpp haiku/trunk/src/servers/app/Decorator.h Log: * Coding style cleanup. Modified: haiku/trunk/src/servers/app/Decorator.cpp =================================================================== --- haiku/trunk/src/servers/app/Decorator.cpp 2008-08-03 13:40:41 UTC (rev 26755) +++ haiku/trunk/src/servers/app/Decorator.cpp 2008-08-03 15:42:32 UTC (rev 26756) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -7,28 +7,29 @@ * Stephan A?mus */ -/** Base class for window decorators */ +/*! Base class for window decorators */ #include "Decorator.h" -#include "DrawingEngine.h" +#include + #include -#include +#include "DrawingEngine.h" -/*! - \brief Constructor +/*! \brief Constructor + + Does general initialization of internal data members and creates a colorset + object. + \param rect Size of client area \param wlook style of window look. See Window.h \param wfeel style of window feel. See Window.h \param wflags various window flags. See Window.h - - Does general initialization of internal data members and creates a colorset - object. */ -Decorator::Decorator(DesktopSettings& settings, BRect rect, - window_look look, uint32 flags) +Decorator::Decorator(DesktopSettings& settings, BRect rect, window_look look, + uint32 flags) : fDrawingEngine(NULL), fDrawState(), @@ -63,8 +64,7 @@ } -/*! - \brief Assigns a display driver to the decorator +/*! \brief Assigns a display driver to the decorator \param driver A valid DrawingEngine object */ void @@ -73,24 +73,23 @@ fDrawingEngine = engine; // lots of subclasses will depend on the driver for text support, so call // _DoLayout() after we have it - if (fDrawingEngine) { + if (fDrawingEngine) _DoLayout(); - } } -/*! - \brief Sets the decorator's window flags - \param flags New value for the flags +/*! \brief Sets the decorator's window flags While this call will not update the screen, it will affect how future updates work and immediately affects input handling. + + \param flags New value for the flags */ void Decorator::SetFlags(uint32 flags, BRegion* updateRegion) { - // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE are in sync - // (it's only a semantical simplification, not a necessity) + // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE + // are in sync (it's only a semantical simplification, not a necessity) if ((flags & (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) == (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) flags |= B_NOT_RESIZABLE; @@ -101,8 +100,7 @@ } -/* - \brief Sets the decorator's font +/*! \brief Sets the decorator's font \param font The new font object to copy from */ void @@ -113,8 +111,7 @@ } -/*! - \brief Sets the decorator's window look +/*! \brief Sets the decorator's window look \param look New value for the look */ void @@ -125,57 +122,56 @@ } -/*! - \brief Sets the close button's value. - \param is_down Whether the button is down or not +/*! \brief Sets the close button's value. Note that this does not update the button's look - it just updates the internal button value + + \param is_down Whether the button is down or not */ void -Decorator::SetClose(bool is_down) +Decorator::SetClose(bool pressed) { - if (is_down != fClosePressed) { - fClosePressed = is_down; + if (pressed != fClosePressed) { + fClosePressed = pressed; DrawClose(); } } -/*! - \brief Sets the minimize button's value. - \param is_down Whether the button is down or not +/*! \brief Sets the minimize button's value. Note that this does not update the button's look - it just updates the internal button value + + \param is_down Whether the button is down or not */ void -Decorator::SetMinimize(bool is_down) +Decorator::SetMinimize(bool pressed) { - if (is_down != fMinimizePressed) { - fMinimizePressed = is_down; + if (pressed != fMinimizePressed) { + fMinimizePressed = pressed; DrawMinimize(); } } -/*! - \brief Sets the zoom button's value. - \param is_down Whether the button is down or not +/*! \brief Sets the zoom button's value. Note that this does not update the button's look - it just updates the internal button value + + \param is_down Whether the button is down or not */ void -Decorator::SetZoom(bool is_down) +Decorator::SetZoom(bool pressed) { - if (is_down != fZoomPressed) { - fZoomPressed = is_down; + if (pressed != fZoomPressed) { + fZoomPressed = pressed; DrawZoom(); } } -/*! - \brief Updates the value of the decorator title +/*! \brief Updates the value of the decorator title \param string New title value */ void @@ -187,8 +183,7 @@ } -/*! - \brief Returns the decorator's window look +/*! \brief Returns the decorator's window look \return the decorator's window look */ window_look @@ -198,8 +193,7 @@ } -/*! - \brief Returns the decorator's window flags +/*! \brief Returns the decorator's window flags \return the decorator's window flags */ uint32 @@ -209,8 +203,7 @@ } -/*! - \brief Returns the decorator's title +/*! \brief Returns the decorator's title \return the decorator's title */ const char* @@ -220,8 +213,7 @@ } -/*! - \brief Returns the decorator's border rectangle +/*! \brief Returns the decorator's border rectangle \return the decorator's border rectangle */ BRect @@ -231,8 +223,7 @@ } -/*! - \brief Returns the decorator's tab rectangle +/*! \brief Returns the decorator's tab rectangle \return the decorator's tab rectangle */ BRect @@ -241,8 +232,8 @@ return fTabRect; } -/*! - \brief Returns the value of the close button + +/*! \brief Returns the value of the close button \return true if down, false if up */ bool @@ -251,8 +242,8 @@ return fClosePressed; } -/*! - \brief Returns the value of the minimize button + +/*! \brief Returns the value of the minimize button \return true if down, false if up */ bool @@ -261,8 +252,8 @@ return fMinimizePressed; } -/*! - \brief Returns the value of the zoom button + +/*! \brief Returns the value of the zoom button \return true if down, false if up */ bool @@ -271,59 +262,61 @@ return fZoomPressed; } -// GetSizeLimits + void -Decorator::GetSizeLimits(int32* minWidth, int32* minHeight, - int32* maxWidth, int32* maxHeight) const +Decorator::GetSizeLimits(int32* minWidth, int32* minHeight, int32* maxWidth, + int32* maxHeight) const { } -/*! - \brief Changes the focus value of the decorator - \param is_active True if active, false if not + +/*! \brief Changes the focus value of the decorator While this call will not update the screen, it will affect how future updates work. + + \param active True if active, false if not */ void -Decorator::SetFocus(bool is_active) +Decorator::SetFocus(bool active) { - fIsFocused = is_active; + fIsFocused = active; _SetFocus(); // TODO: maybe it would be cleaner to handle the redraw here. } -//------------------------------------------------------------------------- -// Virtual Methods -//------------------------------------------------------------------------- -/*! - \brief Returns the "footprint" of the entire window, including decorator - \param region Region to be changed to represent the window's screen footprint - +// #pragma mark - virtual methods + + +/*! \brief Returns the "footprint" of the entire window, including decorator + This function is required by all subclasses. + + \param region Region to be changed to represent the window's screen + footprint */ void Decorator::GetFootprint(BRegion *region) { } -/*! - \brief Performs hit-testing for the decorator - \return The type of area clicked - Clicked is called whenever it has been determined that the window has received a - mouse click. The default version returns DEC_NONE. A subclass may use any or all - of them. - +/*! \brief Performs hit-testing for the decorator + + Clicked is called whenever it has been determined that the window has + received a mouse click. The default version returns DEC_NONE. A subclass + may use any or all of them. + Click type : Action taken by the server - + - \c DEC_NONE : Do nothing - \c DEC_ZOOM : Handles the zoom button (setting states, etc) - \c DEC_CLOSE : Handles the close button (setting states, etc) - \c DEC_MINIMIZE : Handles the minimize button (setting states, etc) - \c DEC_TAB : Currently unused - - \c DEC_DRAG : Moves the window to the front and prepares to move the window + - \c DEC_DRAG : Moves the window to the front and prepares to move the + window - \c DEC_MOVETOBACK : Moves the window to the back of the stack - \c DEC_MOVETOFRONT : Moves the window to the front of the stack - \c DEC_SLIDETAB : Initiates tab-sliding @@ -339,22 +332,24 @@ - \c DEC_RESIZE_RB This function is required by all subclasses. - + + \return The type of area clicked */ click_type -Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) +Decorator::Clicked(BPoint point, int32 buttons, int32 modifiers) { return DEC_NONE; } -/*! - \brief Moves the decorator frame and all default rectangles + +/*! \brief Moves the decorator frame and all default rectangles + + If a subclass implements this method, be sure to call Decorator::MoveBy + to ensure that internal members are also updated. All members of the + Decorator class are automatically moved in this method + \param x X Offset \param y y Offset - - If a subclass implements this method, be sure to call Decorator::MoveBy - to ensure that internal members are also updated. All members of the Decorator - class are automatically moved in this method */ void Decorator::MoveBy(float x, float y) @@ -362,36 +357,38 @@ MoveBy(BPoint(x, y)); } -/*! - \brief Moves the decorator frame and all default rectangles - \param pt Point containing the offsets + +/*! \brief Moves the decorator frame and all default rectangles If a subclass implements this method, be sure to call Decorator::MoveBy - to ensure that internal members are also updated. All members of the Decorator - class are automatically moved in this method + to ensure that internal members are also updated. All members of the + Decorator class are automatically moved in this method + + \param offset BPoint containing the offsets */ void -Decorator::MoveBy(BPoint pt) +Decorator::MoveBy(BPoint offset) { - fZoomRect.OffsetBy(pt); - fCloseRect.OffsetBy(pt); - fMinimizeRect.OffsetBy(pt); - fMinimizeRect.OffsetBy(pt); - fTabRect.OffsetBy(pt); - fFrame.OffsetBy(pt); - fResizeRect.OffsetBy(pt); - fBorderRect.OffsetBy(pt); + fZoomRect.OffsetBy(offset); + fCloseRect.OffsetBy(offset); + fMinimizeRect.OffsetBy(offset); + fMinimizeRect.OffsetBy(offset); + fTabRect.OffsetBy(offset); + fFrame.OffsetBy(offset); + fResizeRect.OffsetBy(offset); + fBorderRect.OffsetBy(offset); } -/*! - \brief Resizes the decorator frame - \param dx x offset - \param dy y offset + +/*! \brief Resizes the decorator frame - This is a required function for subclasses to implement - the default does nothing. - Note that window resize flags should be followed and fFrame should be resized - accordingly. It would also be a wise idea to ensure that the window's rectangles - are not inverted. + This is a required function for subclasses to implement - the default does + nothing. Note that window resize flags should be followed and fFrame should + be resized accordingly. It would also be a wise idea to ensure that the + window's rectangles are not inverted. + + \param x x offset + \param y y offset */ void Decorator::ResizeBy(float x, float y, BRegion* dirty) @@ -414,19 +411,20 @@ } -/*! - \brief Updates the decorator's look in the area r - \param r The area to update. - +/*! \brief Updates the decorator's look in the area \a rect + The default version updates all areas which intersect the frame and tab. + + \param rect The area to update. */ void -Decorator::Draw(BRect r) +Decorator::Draw(BRect rect) { - _DrawFrame(r & fFrame); - _DrawTab(r & fTabRect); + _DrawFrame(rect & fFrame); + _DrawTab(rect & fTabRect); } + //! Forces a complete decorator update void Decorator::Draw() @@ -435,6 +433,7 @@ _DrawTab(fTabRect); } + //! Draws the close button void Decorator::DrawClose() @@ -442,6 +441,7 @@ _DrawClose(fCloseRect); } + //! draws the frame void Decorator::DrawFrame() @@ -449,13 +449,15 @@ _DrawFrame(fFrame); } + //! draws the minimize button void -Decorator::DrawMinimize(void) +Decorator::DrawMinimize() { _DrawTab(fMinimizeRect); } + //! draws the tab, title, and buttons void Decorator::DrawTab() @@ -467,16 +469,18 @@ _DrawClose(fCloseRect); } -// draws the title + +//! draws the title void Decorator::DrawTitle() { _DrawTitle(fTabRect); } + //! draws the zoom button void -Decorator::DrawZoom(void) +Decorator::DrawZoom() { _DrawZoom(fZoomRect); } @@ -491,89 +495,89 @@ } -/*! - \brief Provides the number of characters that will fit in the given width - \param width Maximum number of pixels the title can be - \return the number of characters that will fit in the given width -*/ - //! Function for calculating layout for the decorator void Decorator::_DoLayout() { } -/*! - \brief Actually draws the frame - \param r Area of the frame to update + +/*! \brief Actually draws the frame + \param rect Area of the frame to update */ void -Decorator::_DrawFrame(BRect r) +Decorator::_DrawFrame(BRect rect) { } -/*! - \brief Actually draws the tab - \param r Area of the tab to update + +/*! \brief Actually draws the tab - This function is called when the tab itself needs drawn. Other items, like the - window title or buttons, should not be drawn here. + This function is called when the tab itself needs drawn. Other items, + like the window title or buttons, should not be drawn here. + + \param rect Area of the tab to update */ void -Decorator::_DrawTab(BRect r) +Decorator::_DrawTab(BRect rect) { } -/*! - \brief Actually draws the close button - \param r Area of the button to update - - Unless a subclass has a particularly large button, it is probably unnecessary - to check the update rectangle. + +/*! \brief Actually draws the close button + + Unless a subclass has a particularly large button, it is probably + unnecessary to check the update rectangle. + + \param rect Area of the button to update */ void -Decorator::_DrawClose(BRect r) +Decorator::_DrawClose(BRect rect) { } -/*! - \brief Actually draws the title - \param r area of the title to update - - The main tasks for this function are to ensure that the decorator draws the title - only in its own area and drawing the title itself. Using B_OP_COPY for drawing - the title is recommended because of the marked performance hit of the other - drawing modes, but it is not a requirement. + +/*! \brief Actually draws the title + + The main tasks for this function are to ensure that the decorator draws + the title only in its own area and drawing the title itself. + Using B_OP_COPY for drawing the title is recommended because of the marked + performance hit of the other drawing modes, but it is not a requirement. + + \param rect area of the title to update */ void -Decorator::_DrawTitle(BRect r) +Decorator::_DrawTitle(BRect rect) { } -/*! - \brief Actually draws the zoom button - \param r Area of the button to update + +/*! \brief Actually draws the zoom button - Unless a subclass has a particularly large button, it is probably unnecessary - to check the update rectangle. + Unless a subclass has a particularly large button, it is probably + unnecessary to check the update rectangle. + + \param rect Area of the button to update */ void -Decorator::_DrawZoom(BRect r) +Decorator::_DrawZoom(BRect rect) { } /*! \brief Actually draws the minimize button - \param r Area of the button to update - Unless a subclass has a particularly large button, it is probably unnecessary - to check the update rectangle. + Unless a subclass has a particularly large button, it is probably + unnecessary to check the update rectangle. + + \param rect Area of the button to update */ void -Decorator::_DrawMinimize(BRect r) +Decorator::_DrawMinimize(BRect rect) { } + //! Hook function called when the decorator changes focus void Decorator::_SetFocus() Modified: haiku/trunk/src/servers/app/Decorator.h =================================================================== --- haiku/trunk/src/servers/app/Decorator.h 2008-08-03 13:40:41 UTC (rev 26755) +++ haiku/trunk/src/servers/app/Decorator.h 2008-08-03 15:42:32 UTC (rev 26756) @@ -1,13 +1,13 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: * DarkWyrm * Stephan A?mus */ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ +#ifndef DECORATOR_H +#define DECORATOR_H #include @@ -23,7 +23,7 @@ class BRegion; -typedef enum { +enum click_type { DEC_NONE = 0, DEC_ZOOM, DEC_CLOSE, @@ -42,125 +42,122 @@ CLICK_RESIZE_RT, CLICK_RESIZE_LB, CLICK_RESIZE_RB -} click_type; +}; class Decorator { - public: - Decorator(DesktopSettings& settings, BRect rect, - window_look look, uint32 flags); - virtual ~Decorator(); +public: + Decorator(DesktopSettings& settings, BRect rect, + window_look look, uint32 flags); + virtual ~Decorator(); - void SetDrawingEngine(DrawingEngine *driver); - inline DrawingEngine* GetDrawingEngine() const - { return fDrawingEngine; } - void SetFont(ServerFont *font); + void SetDrawingEngine(DrawingEngine *driver); + inline DrawingEngine* GetDrawingEngine() const + { return fDrawingEngine; } + void SetFont(ServerFont *font); - virtual void SetLook(DesktopSettings& settings, - window_look look, BRegion* updateRegion = NULL); - virtual void SetFlags(uint32 flags, BRegion* updateRegion = NULL); + virtual void SetLook(DesktopSettings& settings, window_look look, + BRegion* updateRegion = NULL); + virtual void SetFlags(uint32 flags, + BRegion* updateRegion = NULL); - void SetClose(bool pressed); - void SetMinimize(bool pressed); - void SetZoom(bool pressed); + void SetClose(bool pressed); + void SetMinimize(bool pressed); + void SetZoom(bool pressed); - virtual void SetTitle(const char* string, BRegion* updateRegion = NULL); + virtual void SetTitle(const char* string, + BRegion* updateRegion = NULL); - window_look Look() const; - uint32 Flags() const; + window_look Look() const; + uint32 Flags() const; - const char* Title() const; + const char* Title() const; - // we need to know its border(frame). WinBorder's fFrame rect - // must expand to include Decorator borders. Otherwise we can't - // draw the border. We also add TabRect because I feel we'll need it - BRect BorderRect() const; - BRect TabRect() const; + BRect BorderRect() const; + BRect TabRect() const; - bool GetClose(); - bool GetMinimize(); - bool GetZoom(); + bool GetClose(); + bool GetMinimize(); + bool GetZoom(); - virtual void GetSizeLimits(int32* minWidth, int32* minHeight, - int32* maxWidth, int32* maxHeight) const; + virtual void GetSizeLimits(int32* minWidth, int32* minHeight, + int32* maxWidth, int32* maxHeight) const; - void SetFocus(bool focussed); - bool IsFocus() - { return fIsFocused; }; + void SetFocus(bool focussed); + bool IsFocus() + { return fIsFocused; }; - virtual void GetFootprint(BRegion *region); + virtual void GetFootprint(BRegion *region); - virtual click_type Clicked(BPoint pt, int32 buttons, - int32 modifiers); + virtual click_type Clicked(BPoint where, int32 buttons, + int32 modifiers); - void MoveBy(float x, float y); - virtual void MoveBy(BPoint pt); - void ResizeBy(float x, float y, BRegion* dirty); - virtual void ResizeBy(BPoint pt, BRegion* dirty) = 0; + void MoveBy(float x, float y); + virtual void MoveBy(BPoint offset); + void ResizeBy(float x, float y, BRegion* dirty); + virtual void ResizeBy(BPoint offset, BRegion* dirty) = 0; - /*! \return true if tab location updated, false if out of bounds or unsupported */ - virtual bool SetTabLocation(float location, BRegion* updateRegion = NULL) - { (void)updateRegion; return false; } - virtual float TabLocation() const - { return 0.0; } + /*! \return true if tab location updated, false if out of bounds + or unsupported + */ + virtual bool SetTabLocation(float location, + BRegion* /*updateRegion*/ = NULL) + { return false; } + virtual float TabLocation() const + { return 0.0; } - virtual bool SetSettings(const BMessage& settings, - BRegion* updateRegion = NULL); - virtual bool GetSettings(BMessage* settings) const; + virtual bool SetSettings(const BMessage& settings, + BRegion* updateRegion = NULL); + virtual bool GetSettings(BMessage* settings) const; - virtual void Draw(BRect r); - virtual void Draw(); - virtual void DrawClose(); - virtual void DrawFrame(); - virtual void DrawMinimize(); - virtual void DrawTab(); - virtual void DrawTitle(); - virtual void DrawZoom(); + virtual void Draw(BRect rect); + virtual void Draw(); + virtual void DrawClose(); + virtual void DrawFrame(); + virtual void DrawMinimize(); + virtual void DrawTab(); + virtual void DrawTitle(); + virtual void DrawZoom(); - rgb_color UIColor(color_which which); + rgb_color UIColor(color_which which); - protected: - int32 _TitleWidth() const - { return fTitle.CountChars(); } +protected: + int32 _TitleWidth() const + { return fTitle.CountChars(); } - virtual void _DoLayout(); + virtual void _DoLayout(); - virtual void _DrawFrame(BRect r); - virtual void _DrawTab(BRect r); + virtual void _DrawFrame(BRect rect); + virtual void _DrawTab(BRect rect); - virtual void _DrawClose(BRect r); - virtual void _DrawTitle(BRect r); - virtual void _DrawZoom(BRect r); - virtual void _DrawMinimize(BRect r); + virtual void _DrawClose(BRect rect); + virtual void _DrawTitle(BRect rect); + virtual void _DrawZoom(BRect rect); + virtual void _DrawMinimize(BRect rect); - virtual void _SetFocus(); + virtual void _SetFocus(); - DrawingEngine* fDrawingEngine; - DrawState fDrawState; + DrawingEngine* fDrawingEngine; + DrawState fDrawState; - window_look fLook; - uint32 fFlags; + window_look fLook; + uint32 fFlags; - BRect fZoomRect; - BRect fCloseRect; - BRect fMinimizeRect; - BRect fTabRect; - BRect fFrame; - BRect fResizeRect; - BRect fBorderRect; + BRect fZoomRect; + BRect fCloseRect; + BRect fMinimizeRect; + BRect fTabRect; + BRect fFrame; + BRect fResizeRect; + BRect fBorderRect; - private: - bool fClosePressed : 1; - bool fZoomPressed : 1; - bool fMinimizePressed : 1; +private: + bool fClosePressed : 1; + bool fZoomPressed : 1; + bool fMinimizePressed : 1; - bool fIsFocused : 1; + bool fIsFocused : 1; - BString fTitle; + BString fTitle; }; -// add-on stuff -//typedef float get_version(void); -//typedef Decorator* create_decorator(DesktopSettings& desktopSettings, BRect rect, -// window_look look, uint32 flags); - -#endif /* _DECORATOR_H_ */ +#endif // DECORATOR_H From axeld at mail.berlios.de Sun Aug 3 17:49:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 17:49:02 +0200 Subject: [Haiku-commits] r26757 - in haiku/trunk/src: kits/interface servers/app Message-ID: <200808031549.m73Fn2mV027471@sheep.berlios.de> Author: axeld Date: 2008-08-03 17:49:02 +0200 (Sun, 03 Aug 2008) New Revision: 26757 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26757&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp haiku/trunk/src/servers/app/Desktop.cpp Log: * BWindow::Activate() now also unminimizes a window if necessary. * Removed superfluous white space. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2008-08-03 15:42:32 UTC (rev 26756) +++ haiku/trunk/src/kits/interface/Window.cpp 2008-08-03 15:49:02 UTC (rev 26757) @@ -109,7 +109,7 @@ { "Feel", { B_GET_PROPERTY, B_SET_PROPERTY }, - { B_DIRECT_SPECIFIER }, NULL, 0, { B_INT32_TYPE } + { B_DIRECT_SPECIFIER }, NULL, 0, { B_INT32_TYPE } }, { @@ -161,7 +161,7 @@ { B_DIRECT_SPECIFIER }, NULL, 0, { B_BOOL_TYPE } }, - {} + {} }; static value_info sWindowValueInfo[] = { @@ -184,12 +184,12 @@ "ResizeBy", 'WDRB', B_COMMAND_KIND, "Resize by the offsets in the BPoint data" }, - + {} }; -void +void _set_menu_sem_(BWindow *window, sem_id sem) { if (window != NULL) @@ -345,7 +345,7 @@ BMessage msg; int32 i = 0; - while (data->FindMessage("_views", i++, &msg) == B_OK) { + while (data->FindMessage("_views", i++, &msg) == B_OK) { BArchivable *obj = instantiate_object(&msg); BView *child = dynamic_cast(obj); if (child) @@ -419,10 +419,10 @@ BArchivable * BWindow::Instantiate(BMessage *data) { - if (!validate_instantiation(data , "BWindow")) - return NULL; + if (!validate_instantiation(data , "BWindow")) + return NULL; - return new BWindow(data); + return new BWindow(data); } @@ -454,7 +454,7 @@ ret = data->AddFloat("_zoom", fMaxZoomHeight); } - if (fMinWidth != 0.0 || fMinHeight != 0.0 + if (fMinWidth != 0.0 || fMinHeight != 0.0 || fMaxWidth != 32768.0 || fMaxHeight != 32768.0) { if (ret == B_OK) ret = data->AddFloat("_sizel", fMinWidth); @@ -503,8 +503,8 @@ return; } - while (!IsHidden()) { - Hide(); + while (!IsHidden()) { + Hide(); } if (fFlags & B_QUIT_ON_WINDOW_CLOSE) @@ -656,7 +656,7 @@ if (Lock()) { if (fInTransaction) fLink->Flush(); - fInTransaction = false; + fInTransaction = false; Unlock(); } } @@ -679,7 +679,7 @@ } -void +void BWindow::MessageReceived(BMessage *msg) { if (!msg->HasSpecifiers()) { @@ -699,7 +699,7 @@ if (msg->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK) return BLooper::MessageReceived(msg); - + BPropertyInfo propertyInfo(sWindowPropInfo); switch (propertyInfo.FindMatch(msg, index, &specifier, what, prop)) { case 0: @@ -828,11 +828,11 @@ replyMsg.AddString("message", "Didn't understand the specifier(s)"); } msg->SendReply(&replyMsg); -} +} -void -BWindow::DispatchMessage(BMessage *msg, BHandler *target) +void +BWindow::DispatchMessage(BMessage *msg, BHandler *target) { if (!msg) return; @@ -880,7 +880,7 @@ width = nextWidth; int32 nextHeight; - if (pendingMessage->FindInt32("height", &nextHeight) == B_OK) + if (pendingMessage->FindInt32("height", &nextHeight) == B_OK) height = nextHeight; MessageQueue()->RemoveMessage(pendingMessage); @@ -964,7 +964,7 @@ fTopView->_Activate(active); // we notify the input server if we are gaining or losing focus - // from a view which has the B_INPUT_METHOD_AWARE on a window + // from a view which has the B_INPUT_METHOD_AWARE on a window // (de)activation bool inputMethodAware = false; if (fFocus) @@ -1055,7 +1055,7 @@ case B_MOUSE_DOWN: { BView *view = dynamic_cast(target); - + // Close an eventually opened menu // unless the target is the menu itself BMenu *menu = dynamic_cast(fFocus); @@ -1063,9 +1063,9 @@ if (menu != NULL && menu != view && privMenu.State() != MENU_STATE_CLOSED) { privMenu.QuitTracking(); - return; + return; } - + if (view != NULL) { BPoint where; msg->FindPoint("be:view_where", &where); @@ -1190,19 +1190,19 @@ fLink->Read(&width); fLink->Read(&height); if (origin != fFrame.LeftTop()) { - // TODO: remove code duplicatation with + // TODO: remove code duplicatation with // B_WINDOW_MOVED case... //printf("window position was not up to date\n"); fFrame.OffsetTo(origin); FrameMoved(origin); } if (width != fFrame.Width() || height != fFrame.Height()) { - // TODO: remove code duplicatation with + // TODO: remove code duplicatation with // B_WINDOW_RESIZED case... //printf("window size was not up to date\n"); fFrame.right = fFrame.left + width; fFrame.bottom = fFrame.top + height; - + _AdoptResize(); FrameResized(width, height); } @@ -1315,7 +1315,7 @@ } default: - BLooper::DispatchMessage(msg, target); + BLooper::DispatchMessage(msg, target); break; } } @@ -1370,7 +1370,7 @@ void -BWindow::SetSizeLimits(float minWidth, float maxWidth, +BWindow::SetSizeLimits(float minWidth, float maxWidth, float minHeight, float maxHeight) { if (minWidth > maxWidth || minHeight > maxHeight) @@ -1406,7 +1406,7 @@ void -BWindow::GetSizeLimits(float *minWidth, float *maxWidth, +BWindow::GetSizeLimits(float *minWidth, float *maxWidth, float *minHeight, float *maxHeight) { // TODO: What about locking?!? @@ -1534,7 +1534,7 @@ float borderWidth = 5.0; float tabHeight = 26.0; - // 1) the rectangle defined by SetZoomLimits(), + // 1) the rectangle defined by SetZoomLimits(), float zoomedWidth = fMaxZoomWidth; float zoomedHeight = fMaxZoomHeight; @@ -1730,7 +1730,7 @@ // arrived at the server Sync(); - // Since we're blocking the event loop, we need to retrieve + // Since we're blocking the event loop, we need to retrieve // all messages that are pending on the port. _DequeueAll(); @@ -1796,6 +1796,9 @@ return; if (!IsHidden()) { + fMinimized = false; + // activating a window will also unminimize it + fLink->StartMessage(AS_ACTIVATE_WINDOW); fLink->Attach(active); fLink->Flush(); @@ -1871,7 +1874,7 @@ } -bool +bool BWindow::IsMinimized() const { // Hiding takes precendence over minimization!!! @@ -2222,7 +2225,7 @@ } -void +void BWindow::MoveBy(float dx, float dy) { if ((dx == 0.0 && dy == 0.0) || !Lock()) @@ -2357,7 +2360,7 @@ bool BWindow::IsHidden() const { - return fShowLevel <= 0; + return fShowLevel <= 0; } @@ -2450,7 +2453,7 @@ // #pragma mark - Private Methods -void +void BWindow::_InitData(BRect frame, const char* title, window_look look, window_feel feel, uint32 flags, uint32 workspace, int32 bitmapToken) { @@ -2553,7 +2556,7 @@ { BPrivate::AppServerLink lockLink; - // we're talking to the server application using our own + // we're talking to the server application using our own // communication channel (fLink) - we better make sure no one // interferes by locking that channel (which AppServerLink does // implicetly) @@ -2612,7 +2615,7 @@ if (title == NULL) title = ""; - // we will change BWindow's thread name to "w>window title" + // we will change BWindow's thread name to "w>window title" char threadName[B_OS_NAME_LENGTH]; strcpy(threadName, "w>"); @@ -2786,7 +2789,7 @@ case B_BORDERED_WINDOW_LOOK: return B_BORDERED_WINDOW; - + default: return B_UNTYPED_WINDOW; } @@ -2861,7 +2864,7 @@ // set fTopView's owner, add it to window's eligible handler list // and also set its next handler to be this window. - STRACE(("Calling setowner fTopView = %p this = %p.\n", + STRACE(("Calling setowner fTopView = %p this = %p.\n", fTopView, this)); fTopView->_SetOwner(this); @@ -2981,7 +2984,7 @@ return fLastMouseMovedView; break; - default: + default: break; } @@ -3070,7 +3073,7 @@ if (gDefaultTokens.GetToken(cookie.focus_token, B_HANDLER_TOKEN, (void**)&handler) != B_OK || handler->Looper() != this) dispatchToFocus = false; - + if (dispatchToFocus && cookie.index > 0) { // should this message still be dispatched by the focus view? bool feedFocus; @@ -3212,7 +3215,7 @@ int32 token; if (message->FindInt32("_view_token", &token) == B_OK) viewUnderMouse = _FindView(token); - + fLastMouseMovedView = viewUnderMouse; } } @@ -3323,7 +3326,7 @@ return true; } } - + // Handle shortcuts if ((modifiers & B_COMMAND_KEY) != 0) { // Command+q has been pressed, so, we will quit Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2008-08-03 15:42:32 UTC (rev 26756) +++ haiku/trunk/src/servers/app/Desktop.cpp 2008-08-03 15:49:02 UTC (rev 26757) @@ -1535,6 +1535,13 @@ SetWindowWorkspaces(window, workspaces); } + if (window->IsMinimized()) { + // Unlike WindowAction(), this is called from the application itself, + // so we will just unminimize the window here. + ShowWindow(window); + window->SetMinimized(false); + } + if (window == FrontWindow()) { // see if there is a normal B_AVOID_FRONT window still in front of us Window* avoidsFront = window->NextWindow(fCurrentWorkspace); @@ -2389,12 +2396,13 @@ return; } - if (action == B_BRING_TO_FRONT - && !window->IsMinimized()) { + if (action == B_BRING_TO_FRONT && !window->IsMinimized()) { // the window is visible, we just need to make it the front window ActivateWindow(window); - } else + } else { + // if not, ask the window if it wants to be unminimized serverWindow->NotifyMinimize(action == B_MINIMIZE_WINDOW); + } UnlockAllWindows(); } From axeld at pinc-software.de Sun Aug 3 17:49:40 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 17:49:40 +0200 CEST Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <20080802190539.297340@gmx.net> Message-ID: <19186189756-BeMail@zon> "Stephan Assmus" wrote: > The only problems I encountered were that > * BWindow::Activate() seems to be supposed to also unminimize > windows. (Opening a file in Pe that > is already open but minimized does not auto-show as on BeOS.) Fixed in r26757; I noticed this once, too, but forgot about it again :- ) Bye, Axel. From mmu_man at mail.berlios.de Sun Aug 3 17:57:06 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 17:57:06 +0200 Subject: [Haiku-commits] r26758 - in haiku/trunk: headers/private/kernel/arch/m68k src/system/kernel/arch/m68k src/system/kernel/platform/atari_m68k Message-ID: <200808031557.m73Fv6qZ027921@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 17:57:03 +0200 (Sun, 03 Aug 2008) New Revision: 26758 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26758&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp Log: Implemented keyboard input for KDL. Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h 2008-08-03 15:49:02 UTC (rev 26757) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_platform.h 2008-08-03 15:57:03 UTC (rev 26758) @@ -39,6 +39,8 @@ struct real_time_data *data) = 0; virtual status_t InitTimer(struct kernel_args *kernelArgs) = 0; + virtual char BlueScreenGetChar() = 0; + virtual char SerialDebugGetChar() = 0; virtual void SerialDebugPutChar(char c) = 0; Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp 2008-08-03 15:49:02 UTC (rev 26757) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_debug_console.cpp 2008-08-03 15:57:03 UTC (rev 26758) @@ -34,7 +34,7 @@ char arch_debug_blue_screen_getchar(void) { - return 0; + return M68KPlatform::Default()->BlueScreenGetChar(); } Modified: haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp =================================================================== --- haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-03 15:49:02 UTC (rev 26757) +++ haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-03 15:57:03 UTC (rev 26758) @@ -9,11 +9,14 @@ #include #include +#include //#include #include #include #include +#include "debugger_keymaps.h" + #define MFP0_BASE 0xFFFFFA00 #define MFP1_BASE 0xFFFFFA80 @@ -24,10 +27,41 @@ // ?? #define SCC_C1_VECTOR_BASE (0x1BC/4) -#define inb(a) (*(volatile uint8 *)(a)) -#define outb(a, v) (*(volatile uint8 *)(a) = v) +#define IKBD_BASE 0xFFFFFC00 +#define IKBD_CTRL 0 +#define IKBD_DATA 2 +#define IKBD_STATUS_READ_BUFFER_FULL 0x01 +// keyboard scancodes, very much like PC ones +// see +// http://www.classiccmp.org/dunfield/atw800/h/atw800k.jpg +// ST Mag Nr 57 page 55 +enum keycodes { + LEFT_SHIFT = 42, + RIGHT_SHIFT = 54, + LEFT_CONTROL = 29, + + LEFT_ALT = 56, + + CURSOR_LEFT = 75, + CURSOR_RIGHT = 77, + CURSOR_UP = 72, + CURSOR_DOWN = 80, + CURSOR_HOME = 71, + CURSOR_END = 79, // not on real atari keyboard + PAGE_UP = 73, // not on real atari keyboard XXX remap Help ? + PAGE_DOWN = 81, // not on real atari keyboard XXX remap Undo ? + + DELETE = 83, + F12 = 88, // but it's shifted + +}; + +#define in8(a) (*(volatile uint8 *)(a)) +#define out8(a, v) (*(volatile uint8 *)(a) = v) + + namespace BPrivate { //class MfpPIC; @@ -65,6 +99,8 @@ struct real_time_data *data); virtual status_t InitTimer(struct kernel_args *kernelArgs); + virtual char BlueScreenGetChar(); + virtual char SerialDebugGetChar(); virtual void SerialDebugPutChar(char c); @@ -126,10 +162,10 @@ uint8 bit = 1 << (irq % 8); // I*B[0] is vector+0, I*A[0] is vector+8 uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB)); - uint8 val = inb(reg); + uint8 val = in8(reg); if (val & bit == 0) { val |= bit; - outb(reg, val); + out8(reg, val); } } @@ -140,10 +176,10 @@ uint8 bit = 1 << (irq % 8); // I*B[0] is vector+0, I*A[0] is vector+8 uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB)); - uint8 val = inb(reg); + uint8 val = in8(reg); if (val & bit) { val &= ~bit; - outb(reg, val); + out8(reg, val); } } @@ -154,10 +190,10 @@ uint8 bit = 1 << (irq % 8); // I*B[0] is vector+0, I*A[0] is vector+8 uint32 reg = Base() + ((irq > 8) ? (MFP_ISRA) : (MFP_ISRB)); - uint8 val = inb(reg); + uint8 val = in8(reg); if (val & bit) { val &= ~bit; - outb(reg, val); + out8(reg, val); return true; } return false; @@ -206,6 +242,8 @@ #warning M68K: add real serial debug output someday + //out8(IKBD_BASE+IKBD_DATA, 0x11); + return B_OK; } @@ -256,11 +294,144 @@ char +M68KAtari::BlueScreenGetChar() +{ + /* polling the keyboard, similar to code in keyboard + * driver, but without using an interrupt + * taken almost straight from x86 code + * XXX: maybe use the keymap from the _AKP cookie instead ? + */ + static bool shiftPressed = false; + static bool controlPressed = false; + static bool altPressed = false; + static uint8 special = 0; + static uint8 special2 = 0; + uint8 key = 0; + + if (special & 0x80) { + special &= ~0x80; + return '['; + } + if (special != 0) { + key = special; + special = 0; + return key; + } + if (special2 != 0) { + key = special2; + special2 = 0; + return key; + } + + while (true) { + uint8 status = in8(IKBD_BASE+IKBD_CTRL); + + if ((status & IKBD_STATUS_READ_BUFFER_FULL) == 0) { + // no data in keyboard buffer + spin(200); + continue; + } + + spin(200); + key = in8(IKBD_BASE+IKBD_DATA); + /* + kprintf("key: %02x, %sshift %scontrol %salt\n", + key, + shiftPressed?"":"!", + controlPressed?"":"!", + altPressed?"":"!"); + */ + + if (key & 0x80) { + // key up + switch (key & ~0x80) { + case LEFT_SHIFT: + case RIGHT_SHIFT: + shiftPressed = false; + break; + case LEFT_CONTROL: + controlPressed = false; + break; + case LEFT_ALT: + altPressed = false; + break; + } + } else { + // key down + switch (key) { + case LEFT_SHIFT: + case RIGHT_SHIFT: + shiftPressed = true; + break; + + case LEFT_CONTROL: + controlPressed = true; + break; + + case LEFT_ALT: + altPressed = true; + break; + + // start escape sequence for cursor movement + case CURSOR_UP: + special = 0x80 | 'A'; + return '\x1b'; + case CURSOR_DOWN: + special = 0x80 | 'B'; + return '\x1b'; + case CURSOR_RIGHT: + special = 0x80 | 'C'; + return '\x1b'; + case CURSOR_LEFT: + special = 0x80 | 'D'; + return '\x1b'; + case CURSOR_HOME: + special = 0x80 | 'H'; + return '\x1b'; + case CURSOR_END: + special = 0x80 | 'F'; + return '\x1b'; + case PAGE_UP: + special = 0x80 | '5'; + special2 = '~'; + return '\x1b'; + case PAGE_DOWN: + special = 0x80 | '6'; + special2 = '~'; + return '\x1b'; + + + case DELETE: + if (controlPressed && altPressed) + arch_cpu_shutdown(true); + + special = 0x80 | '3'; + special2 = '~'; + return '\x1b'; + + default: + if (controlPressed) { + char c = kShiftedKeymap[key]; + if (c >= 'A' && c <= 'Z') + return 0x1f & c; + } + + if (altPressed) + return kAltedKeymap[key]; + + return shiftPressed + ? kShiftedKeymap[key] : kUnshiftedKeymap[key]; + } + } + } +} + + +char M68KAtari::SerialDebugGetChar() { - panic("WRITEME"); + //WRITEME return 0; -// return (char)key; } From axeld at mail.berlios.de Sun Aug 3 18:04:20 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 18:04:20 +0200 Subject: [Haiku-commits] r26759 - haiku/trunk/src/apps/deskbar Message-ID: <200808031604.m73G4KZY028415@sheep.berlios.de> Author: axeld Date: 2008-08-03 18:04:20 +0200 (Sun, 03 Aug 2008) New Revision: 26759 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26759&view=rev Modified: haiku/trunk/src/apps/deskbar/WindowMenuItem.cpp Log: * Coding style cleanup. Modified: haiku/trunk/src/apps/deskbar/WindowMenuItem.cpp =================================================================== --- haiku/trunk/src/apps/deskbar/WindowMenuItem.cpp 2008-08-03 15:57:03 UTC (rev 26758) +++ haiku/trunk/src/apps/deskbar/WindowMenuItem.cpp 2008-08-03 16:04:20 UTC (rev 26759) @@ -32,18 +32,20 @@ All rights reserved. */ -#include +#include "WindowMenuItem.h" + #include + #include +#include #include "BarApp.h" #include "BarMenuBar.h" #include "ExpandoMenuBar.h" +#include "icons.h" #include "ResourceSet.h" #include "TeamMenu.h" #include "WindowMenu.h" -#include "WindowMenuItem.h" -#include "icons.h" const float kHPad = 10.0f; @@ -52,9 +54,9 @@ const BRect kIconRect(1.0f, 1.0f, 13.0f, 14.0f); -TWindowMenuItem::TWindowMenuItem(const char *title, int32 id, - bool mini, bool currentWorkspace, bool dragging) - : BMenuItem(title, NULL), +TWindowMenuItem::TWindowMenuItem(const char *title, int32 id, bool mini, + bool currentWorkspace, bool dragging) + : BMenuItem(title, NULL), fID(id), fMini(mini), fCurrentWorkSpace(currentWorkspace), @@ -71,14 +73,15 @@ void TWindowMenuItem::Initialize(const char *title) { - if (fMini) + if (fMini) { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowHiddenSwitchIcon); - else + } else { fBitmap = fCurrentWorkSpace ? AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownIcon) : AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_WindowShownSwitchIcon); + } BFont font(be_plain_font); fTitleWidth = ceilf(font.StringWidth(title)); @@ -90,8 +93,8 @@ void -TWindowMenuItem::SetTo(const char *title, int32 id, - bool mini, bool currentWorkspace, bool dragging) +TWindowMenuItem::SetTo(const char *title, int32 id, bool mini, + bool currentWorkspace, bool dragging) { fModified = fCurrentWorkSpace != currentWorkspace || fMini != mini; @@ -121,9 +124,9 @@ if (fExpanded && Menu()) { BPoint contLoc = ContentLocation() + BPoint(kHPad, kVPad); contLoc.x += kIconRect.Width() + kLabelOffset; - + be_plain_font->TruncateString(&truncatedTitle, B_TRUNCATE_MIDDLE, - Frame().Width() - contLoc.x - 3.0f); + Frame().Width() - contLoc.x - 3.0f); } if (strcmp(Label(), truncatedTitle.String()) != 0) @@ -141,22 +144,26 @@ void TWindowMenuItem::GetContentSize(float *width, float *height) { - if (!fExpanded) { - *width = kHPad + fTitleWidth + kHPad; - if (fID >= 0) - *width += fBitmap->Bounds().Width() + kLabelOffset; - } else - *width = Frame().Width()/* - kHPad*/; + if (width != NULL) { + if (!fExpanded) { + *width = kHPad + fTitleWidth + kHPad; + if (fID >= 0) + *width += fBitmap->Bounds().Width() + kLabelOffset; + } else + *width = Frame().Width()/* - kHPad*/; + } // Note: when the item is in "expanded mode", ie embedded into // the Deskbar itself, then a truncated label is used in SetLabel() // The code here is ignorant of this fact, but it doesn't seem to // hurt anything. - *height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f; - float labelHeight = fTitleAscent + fTitleDescent; - *height = (labelHeight > *height) ? labelHeight : *height; - *height += kVPad * 2; + if (height != NULL) { + *height = (fID >= 0) ? fBitmap->Bounds().Height() : 0.0f; + float labelHeight = fTitleAscent + fTitleDescent; + *height = (labelHeight > *height) ? labelHeight : *height; + *height += kVPad * 2; + } } @@ -172,23 +179,26 @@ // if not selected or being tracked on, fill with gray TBarView *barview = (static_cast(be_app))->BarView(); - if (!IsSelected() && !menu->IsRedrawAfterSticky() || barview->Dragging() || !IsEnabled()) { + if (!IsSelected() && !menu->IsRedrawAfterSticky() + || barview->Dragging() || !IsEnabled()) { menu->SetHighColor(menuColor); menu->FillRect(frame); if (fExpanded) { - rgb_color shadow = tint_color(menuColor, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0f); + rgb_color shadow = tint_color(menuColor, + (B_NO_TINT + B_DARKEN_1_TINT) / 2.0f); menu->SetHighColor(shadow); frame.right = frame.left + kHPad / 2; menu->FillRect(frame); - } + } } if (IsEnabled() && IsSelected() && !menu->IsRedrawAfterSticky()) { // fill - menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT)); + menu->SetHighColor(tint_color(menuColor, + B_HIGHLIGHT_BACKGROUND_TINT)); menu->FillRect(frame); - } else + } else menu->SetLowColor(menuColor); DrawContent(); @@ -212,7 +222,7 @@ if (fID >= 0) { menu->SetDrawingMode(B_OP_OVER); - + float width = fBitmap->Bounds().Width(); if (width > 16) @@ -228,7 +238,8 @@ menu->SetDrawingMode(B_OP_COPY); } - contLoc.y = frame.top + ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f; + contLoc.y = frame.top + + ((frame.Height() - fTitleAscent - fTitleDescent) / 2) + 1.0f; menu->PopState(); menu->MovePenTo(contLoc); @@ -240,12 +251,12 @@ status_t -TWindowMenuItem::Invoke(BMessage *) +TWindowMenuItem::Invoke(BMessage* /*message*/) { if (!fDragging) { if (fID >= 0) { - int32 action = (modifiers() & B_CONTROL_KEY) - ? B_MINIMIZE_WINDOW :B_BRING_TO_FRONT; + int32 action = (modifiers() & B_CONTROL_KEY) != 0 + ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT; bool doZoom = false; BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f); @@ -257,8 +268,8 @@ if (item->Menu()->Window() != NULL) { zoomRect = item->Menu()->ConvertToScreen(item->Frame()); - doZoom = fMini && (action == B_BRING_TO_FRONT) || - !fMini && (action == B_MINIMIZE_WINDOW); + doZoom = fMini && action == B_BRING_TO_FRONT + || !fMini && action == B_MINIMIZE_WINDOW; } do_window_action(fID, action, zoomRect, doZoom); From teammaui at web.de Sun Aug 3 18:17:53 2008 From: teammaui at web.de (=?utf-8?Q?Ralf_Sch=C3=BClke?=) Date: Sun, 03 Aug 2008 18:17:53 +0200 Subject: [Haiku-commits] r26755 - in haiku/trunk: headers/libs/agg headers/private/app src/kits/interface src/preferences/appearance src/preferences/fonts src/servers/app src/servers/app/drawing/Painter src/servers/app/drawing/Painter/drawing_modes src/tests/servers/app In-Reply-To: <200808031340.m73Det8h006835@sheep.berlios.de> References: <200808031340.m73Det8h006835@sheep.berlios.de> Message-ID: On Sun, 03 Aug 2008 15:40:55 +0200, stippi at BerliOS wrote: > All of the above implements subpixel anti-aliasing on a global scale, > which > to my knowledge no other OS is doing at the moment. Any vector rendering > can optionally use subpixel anti-aliasing in Haiku now. Thats verry nice, thanks. +1 for haiku os Ralf -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From axeld at mail.berlios.de Sun Aug 3 18:19:25 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 18:19:25 +0200 Subject: [Haiku-commits] r26760 - haiku/trunk/src/servers/app Message-ID: <200808031619.m73GJPtd029405@sheep.berlios.de> Author: axeld Date: 2008-08-03 18:19:25 +0200 (Sun, 03 Aug 2008) New Revision: 26760 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26760&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp Log: * Since ShowWindow() could call ActivateWindow() again as well, we should better call Window::SetMinimized() before calling it from there. * And since ShowWindow() calls _SendFakeMouseMoved(), we also better don't call it with the window lock held, or otherwise we would potentially cause a deadlock. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2008-08-03 16:04:20 UTC (rev 26759) +++ haiku/trunk/src/servers/app/Desktop.cpp 2008-08-03 16:19:25 UTC (rev 26760) @@ -1538,8 +1538,13 @@ if (window->IsMinimized()) { // Unlike WindowAction(), this is called from the application itself, // so we will just unminimize the window here. + window->SetMinimized(false); + UnlockAllWindows(); + ShowWindow(window); - window->SetMinimized(false); + + if (!LockAllWindows()) + return; } if (window == FrontWindow()) { From axeld at mail.berlios.de Sun Aug 3 18:30:37 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 18:30:37 +0200 Subject: [Haiku-commits] r26761 - in haiku/trunk/headers: posix/sys private/fs_shell Message-ID: <200808031630.m73GUbkA030652@sheep.berlios.de> Author: axeld Date: 2008-08-03 18:30:30 +0200 (Sun, 03 Aug 2008) New Revision: 26761 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26761&view=rev Modified: haiku/trunk/headers/posix/sys/stat.h haiku/trunk/headers/private/fs_shell/fssh_stat.h Log: * As pointed out by Andreas, the previous patch wasn't really correct; ALLPERMS should really contain all permission bits. * It now uses S_ISVTX instead of S_ISTXT - this is how it works in Linux as well, while FreeBSD uses S_ISTXT there (but S_ISTXT and S_ISVTX have the same value there, too). * Also fixed the fs_shell this time. Modified: haiku/trunk/headers/posix/sys/stat.h =================================================================== --- haiku/trunk/headers/posix/sys/stat.h 2008-08-03 16:19:25 UTC (rev 26760) +++ haiku/trunk/headers/posix/sys/stat.h 2008-08-03 16:30:30 UTC (rev 26761) @@ -72,7 +72,7 @@ #define S_ISUID 04000 /* set user id on execution */ #define S_ISGID 02000 /* set group id on execution */ -#define S_ISVTX 01000 /* save swapped text even after use */ +#define S_ISVTX 01000 /* save swapped text even after use (sticky bit) */ #define S_IRWXU 00700 /* read, write, execute: owner */ #define S_IRUSR 00400 /* read permission: owner */ @@ -93,7 +93,7 @@ #define S_IEXEC S_IXUSR #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) -#define ALLPERMS (S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO) +#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* default file mode, everyone can read/write */ Modified: haiku/trunk/headers/private/fs_shell/fssh_stat.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_stat.h 2008-08-03 16:19:25 UTC (rev 26760) +++ haiku/trunk/headers/private/fs_shell/fssh_stat.h 2008-08-03 16:30:30 UTC (rev 26761) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku Inc. All Rights Reserved. + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _FSSH_SYS_STAT_H_ @@ -72,7 +72,7 @@ #define FSSH_S_ISUID 04000 /* set user id on execution */ #define FSSH_S_ISGID 02000 /* set group id on execution */ -#define FSSH_S_ISVTX 01000 /* save swapped text even after use */ +#define FSSH_S_ISVTX 01000 /* save swapped text even after use (sticky bit) */ #define FSSH_S_IRWXU 00700 /* read, write, execute: owner */ #define FSSH_S_IRUSR 00400 /* read permission: owner */ @@ -88,7 +88,7 @@ #define FSSH_S_IXOTH 00001 /* execute permission: other */ #define FSSH_ACCESSPERMS (FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) -#define FSSH_ALLPERMS (FSSH_S_ISUID | FSSH_S_ISGID | FSSH_S_ISTXT \ +#define FSSH_ALLPERMS (FSSH_S_ISUID | FSSH_S_ISGID | FSSH_S_ISVTX \ | FSSH_S_IRWXU | FSSH_S_IRWXG | FSSH_S_IRWXO) #define FSSH_DEFFILEMODE (FSSH_S_IRUSR | FSSH_S_IWUSR | FSSH_S_IRGRP \ | FSSH_S_IWGRP | FSSH_S_IROTH | FSSH_S_IWOTH) From superstippi at gmx.de Sun Aug 3 19:14:25 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 03 Aug 2008 19:14:25 +0200 Subject: [Haiku-commits] r26748 - haiku/trunk/src/apps/text_search In-Reply-To: <200808022357.m72Nv48s022688@sheep.berlios.de> References: <200808022357.m72Nv48s022688@sheep.berlios.de> Message-ID: <20080803171425.266680@gmx.net> Hi mmu_man, > Log: > Fix gcc4 build. my->beers--; thanks, didn't spot that one! Best regards, -Stephan From axeld at mail.berlios.de Sun Aug 3 20:00:21 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 3 Aug 2008 20:00:21 +0200 Subject: [Haiku-commits] r26762 - haiku/trunk/src/add-ons/accelerants/common Message-ID: <200808031800.m73I0LMC027333@sheep.berlios.de> Author: axeld Date: 2008-08-03 20:00:20 +0200 (Sun, 03 Aug 2008) New Revision: 26762 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26762&view=rev Modified: haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp Log: * Removed the extraneous 640x480 modes as pointed out by Gerald. * Disabled "timing.sync != 3" check that potentially ignores modes that we might want to have. We could also add the mode by resolution in that case, and ignore the timing info completely. There should be an open bug about this, but I couldn't find it. * Minor cleanup. Modified: haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2008-08-03 16:30:30 UTC (rev 26761) +++ haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2008-08-03 18:00:20 UTC (rev 26762) @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -16,7 +16,8 @@ #define POSITIVE_SYNC \ (B_POSITIVE_HSYNC | B_POSITIVE_VSYNC) #define MODE_FLAGS \ - (B_8_BIT_DAC | B_HARDWARE_CURSOR | B_PARALLEL_ACCESS | B_DPMS | B_SUPPORTS_OVERLAYS) + (B_8_BIT_DAC | B_HARDWARE_CURSOR | B_PARALLEL_ACCESS | B_DPMS \ + | B_SUPPORTS_OVERLAYS) // TODO: move this list into the app_server static const display_mode kBaseModeList[] = { @@ -25,8 +26,6 @@ {{25175, 640, 656, 752, 800, 400, 412, 414, 449, B_POSITIVE_VSYNC}, B_CMAP8, 640, 400, 0, 0, MODE_FLAGS}, /* 640x400 - www.epanorama.net/documents/pc/vga_timing.html) */ {{25175, 640, 656, 752, 800, 480, 490, 492, 525, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(640X480X8.Z1) */ - {{27500, 640, 672, 768, 864, 480, 488, 494, 530, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* 640X480X60Hz */ - {{30500, 640, 672, 768, 864, 480, 517, 523, 588, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* SVGA_640X480X60HzNI */ {{31500, 640, 664, 704, 832, 480, 489, 492, 520, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 70-72Hz_(640X480X8.Z1) */ {{31500, 640, 656, 720, 840, 480, 481, 484, 500, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 75Hz_(640X480X8.Z1) */ {{36000, 640, 696, 752, 832, 480, 481, 484, 509, 0}, B_CMAP8, 640, 480, 0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 85Hz_(640X480X8.Z1) */ @@ -214,16 +213,18 @@ } for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { - if (info->detailed_monitor[i].monitor_desc_type != EDID1_IS_DETAILED_TIMING) + if (info->detailed_monitor[i].monitor_desc_type + != EDID1_IS_DETAILED_TIMING) continue; // TODO: handle flags correctly! - const edid1_detailed_timing& timing = info->detailed_monitor[i].data.detailed_timing; + const edid1_detailed_timing& timing + = info->detailed_monitor[i].data.detailed_timing; display_mode mode; - - if (timing.pixel_clock <= 0 || timing.sync != 3) + + if (timing.pixel_clock <= 0/* || timing.sync != 3*/) continue; - + mode.timing.pixel_clock = timing.pixel_clock * 10; mode.timing.h_display = timing.h_active; mode.timing.h_sync_start = timing.h_active + timing.h_sync_off; @@ -248,10 +249,10 @@ mode.h_display_start = 0; mode.v_display_start = 0; mode.flags = MODE_FLAGS; - + _AddMode(&mode); } - + // TODO: add other modes from the base list that satisfy the display's // requirements! @@ -329,7 +330,7 @@ // caller. Note that refresh rates computed from mode parameters is // not exact; thus, the tolerance of 1.2% was obtained by testing the // various established modes that can be selected by the EDID info. - + if (mode.timing.h_display == width && mode.timing.v_display == height && fabs(get_refresh_rate(mode) - refresh) < refresh * 0.012) { _AddMode(&mode); From modeenf at mail.berlios.de Sun Aug 3 20:20:07 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Sun, 3 Aug 2008 20:20:07 +0200 Subject: [Haiku-commits] r26763 - haiku/trunk/headers/os/device Message-ID: <200808031820.m73IK7q1028762@sheep.berlios.de> Author: modeenf Date: 2008-08-03 20:20:05 +0200 (Sun, 03 Aug 2008) New Revision: 26763 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26763&view=rev Modified: haiku/trunk/headers/os/device/Joystick.h Log: Some small updates to joystick.h Modified: haiku/trunk/headers/os/device/Joystick.h =================================================================== --- haiku/trunk/headers/os/device/Joystick.h 2008-08-03 18:00:20 UTC (rev 26762) +++ haiku/trunk/headers/os/device/Joystick.h 2008-08-03 18:20:05 UTC (rev 26763) @@ -16,12 +16,25 @@ #include #include +#define DEBUG + class BList; class BString; struct entry_ref; struct _extended_joystick; class _BJoystickTweaker; +typedef struct _joystick_info { + char module_name[64]; + char controller_name[64]; + int16 num_axes; + int16 num_buttons; + int16 num_hats; + uint32 num_sticks; + bool calibration_enable; + bigtime_t max_latency; +} joystick_info; + /* -----------------------------------------------------------------------*/ class BJoystick { @@ -89,8 +102,9 @@ private: friend class _BJoystickTweaker; +//friend class JoyCalib; //Added from Zeta - struct _joystick_info; +// struct _joystick_info; void ScanDevices( bool use_disabled = false); @@ -109,10 +123,17 @@ BList * _fDevices; _joystick_info * m_info; char * m_dev_name; +#if !_PR3_COMPATIBLE_ //if statment added from Zeta virtual status_t _Reserved_Joystick_4(void *, ...); virtual status_t _Reserved_Joystick_5(void *, ...); virtual status_t _Reserved_Joystick_6(void *, ...); uint32 _reserved_Joystick_[10]; +#endif + +#ifdef DEBUG +public: + static FILE *sLogFile; +#endif }; #endif From modeenf at mail.berlios.de Sun Aug 3 20:22:24 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Sun, 3 Aug 2008 20:22:24 +0200 Subject: [Haiku-commits] r26764 - haiku/trunk/src/kits/device Message-ID: <200808031822.m73IMOdn029131@sheep.berlios.de> Author: modeenf Date: 2008-08-03 20:22:21 +0200 (Sun, 03 Aug 2008) New Revision: 26764 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26764&view=rev Modified: haiku/trunk/src/kits/device/Jamfile haiku/trunk/src/kits/device/Joystick.cpp Log: Read's the joystick description file Modified: haiku/trunk/src/kits/device/Jamfile =================================================================== --- haiku/trunk/src/kits/device/Jamfile 2008-08-03 18:20:05 UTC (rev 26763) +++ haiku/trunk/src/kits/device/Jamfile 2008-08-03 18:22:21 UTC (rev 26764) @@ -2,6 +2,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders device ; + # for usb_raw.h that defines the ioctl protocol used by the USB classes UseHeaders [ FDirName $(HAIKU_TOP) src add-ons kernel drivers bus usb ] : true ; @@ -10,6 +12,7 @@ D2A.cpp DigitalPort.cpp Joystick.cpp + JoystickTweaker.cpp SerialPort.cpp USBConfiguration.cpp USBDevice.cpp Modified: haiku/trunk/src/kits/device/Joystick.cpp =================================================================== --- haiku/trunk/src/kits/device/Joystick.cpp 2008-08-03 18:20:05 UTC (rev 26763) +++ haiku/trunk/src/kits/device/Joystick.cpp 2008-08-03 18:22:21 UTC (rev 26764) @@ -3,10 +3,14 @@ * All rights reserved. * Distributed under the terms of the MIT License. */ + +/* +joystick preference app + JoyCalib::JoyCalib(BRect, BJoystick &, BWindow *): +__8JoyCalibG5BRectR9BJoystickP7BWindow: +*/ -#include #include -#include #include #include @@ -17,112 +21,74 @@ #include #include -#define DEVICEPATH "/dev/joystick/" +#include "Joystick.h" -typedef struct _joystick_info { - char module_name[64]; - char device_name[64]; - int16 num_axes; - int16 num_buttons; - int16 num_hats; - uint16 num_sticks; -} joystick_info; +#ifdef DEBUG + inline void LOG(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \ + fputs(buf, BJoystick::sLogFile); fflush(BJoystick::sLogFile); } + #define LOG_ERR(text...) LOG(text) +FILE *BJoystick::sLogFile = NULL; +#else + #define LOG(text...) + #define LOG_ERR(text...) fprintf(stderr, text) +#endif -//Scans a directory and adds the entries it founds as strings to the given list -static status_t -scan_directory(const char* rootPath, BList *list, BEntry *rootEntry = NULL) -{ - BDirectory root; +#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__) - if (rootEntry != NULL) - root.SetTo( rootEntry); - else if (rootPath != NULL) - root.SetTo(rootPath); - else - return B_ERROR; - - BEntry entry; - - ASSERT(list != NULL); - while ((root.GetNextEntry(&entry)) > B_ERROR ) { - if (entry.IsDirectory()) { - scan_directory(rootPath, list, &entry); - } else { - BPath path; - entry.GetPath(&path); - BString str(path.Path()); - str.RemoveFirst(rootPath); - list->AddItem(strdup(str.String())); - } - } - return B_OK; -} +#include "JoystickTweaker.h" -class _BJoystickTweaker { - -public: - _BJoystickTweaker(); - _BJoystickTweaker(BJoystick &stick); -virtual ~_BJoystickTweaker(); - -protected: -private: - status_t scan_including_disabled(); - status_t save_config(const entry_ref * ref = NULL); - status_t get_info(); - BJoystick* fJoystick; -}; -//-------------------------------------------------------------------// - - BJoystick::BJoystick() : _mBeBoxMode(false) , _fDevices(new BList) -{ - ScanDevices(); + , m_info(new _joystick_info()) +{ +#ifdef DEBUG + sLogFile = fopen("/var/log/libdevice.log", "a"); +#endif + //ScanDevices(); } BJoystick::~BJoystick() -{ +{ if (ffd >= 0) close(ffd); - for (int32 count = _fDevices->CountItems() - 1; count >= 0; count--) + for (int32 count = _fDevices->CountItems() - 1; count >= 0; count--) { free(_fDevices->RemoveItem(count)); + } delete _fDevices; + delete m_info; } status_t BJoystick::Open(const char *portName) { + CALLED(); return Open(portName, true); } status_t -BJoystick::Open(const char *portName, - bool enter_enhanced) +BJoystick::Open(const char *portName, bool enter_enhanced) { + CALLED(); char buf[64]; - //We don't want to use enhanced mode but _mBeBoxMode sugest if we use - //BeBoxMode if(!enter_enhanced) _mBeBoxMode = !enter_enhanced; if (portName == NULL) - return B_BAD_VALUE; // Heheee, we won't crash + return B_BAD_VALUE; if (portName[0] != '/') snprintf(buf, 64, DEVICEPATH"/%s", portName); else - // A name like "/dev/joystick/usb/0" was passed snprintf(buf, 64, "%s", portName); - if (ffd >= 0) //If this port is already open, close it + if (ffd >= 0) close(ffd); // TODO: BeOS don't use O_EXCL, and this seems to lead to some issues. I @@ -141,13 +107,22 @@ } // TODO: I wonder why the return type is a status_t, // since we (as BeOS does) return the descriptor number for the device... - return (ffd >= 0) ? ffd : errno; + + //Read the Joystick Description file for this port/joystick + _BJoystickTweaker jt(*this); + jt.get_info(m_info, portName); + + if (ffd >= 0) { + return ffd; + } else + return errno; } void BJoystick::Close(void) { + CALLED(); if (ffd >= 0) close(ffd); ffd = -1; @@ -157,26 +132,27 @@ void BJoystick::ScanDevices(bool use_disabled) { - // First, we empty the list - for (int32 count = _fDevices->CountItems() - 1; count >= 0; count--) - free(_fDevices->RemoveItem(count)); - - // Add devices to the list - scan_directory(DEVICEPATH, _fDevices); + CALLED(); + if (use_disabled) { + _BJoystickTweaker temp(*this); + temp.scan_including_disabled(); + } } int32 BJoystick::CountDevices() { + CALLED(); int32 count = 0; // Refresh devices list - ScanDevices(); + ScanDevices(true); if (_fDevices != NULL) count = _fDevices->CountItems(); + LOG("Count = %d\n", count); return count; } @@ -184,37 +160,27 @@ status_t BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize) { - status_t result = B_ERROR; - const char *dev = NULL; + CALLED(); + status_t result = B_ERROR; + BString *temp = new BString(); if (_fDevices != NULL) - dev = static_cast(_fDevices->ItemAt(n)); + temp = static_cast(_fDevices->ItemAt(n)); - if (dev != NULL && name != NULL) { - strncpy(name, dev, bufSize); + if (temp != NULL && name != NULL) { + strncpy(name, temp->String(), bufSize); name[bufSize - 1] = '\0'; result = B_OK; } + + LOG("Device Name = %s\n", name); return result; } -status_t -BJoystick::Update(void) -{ - return B_ERROR; -} - - -status_t -BJoystick::SetMaxLatency(bigtime_t max_latency) -{ - return B_ERROR; -} - - bool BJoystick::EnterEnhancedMode(const entry_ref *ref) { + CALLED(); _mBeBoxMode = false; return !_mBeBoxMode; } @@ -222,171 +188,169 @@ int32 BJoystick::CountSticks() -{ - return 0; +{ + CALLED(); + return m_info->num_sticks; } int32 BJoystick::CountAxes() { - return 0; + CALLED(); + return m_info->num_axes; } int32 BJoystick::CountHats() { - return 0; + CALLED(); + return m_info->num_hats; } int32 BJoystick::CountButtons() { - return 0; + CALLED(); + return m_info->num_buttons; } - status_t -BJoystick::GetAxisValues(int16 *out_values, - int32 for_stick) +BJoystick::GetControllerModule(BString *out_name) { - return B_ERROR; + CALLED(); + if (m_info != NULL && ffd >= 0) { + out_name->SetTo(m_info->module_name); + return B_OK; + } else + return B_ERROR; + } status_t -BJoystick::GetHatValues(uint8 *out_hats, - int32 for_stick) +BJoystick::GetControllerName(BString *out_name) { - return B_ERROR; + CALLED(); + if (m_info != NULL && ffd >= 0) { + out_name->SetTo(m_info->controller_name); + return B_OK; + } else + return B_ERROR; } -uint32 -BJoystick::ButtonValues(int32 for_stick) +bool +BJoystick::IsCalibrationEnabled() { - return 0; + CALLED(); + return m_info->calibration_enable; } status_t -BJoystick::GetAxisNameAt(int32 index, - BString *out_name) +BJoystick::EnableCalibration(bool calibrates) { - return B_ERROR; + CALLED(); + return m_info->calibration_enable = calibrates; } status_t -BJoystick::GetHatNameAt(int32 index, - BString *out_name) +BJoystick::SetMaxLatency(bigtime_t max_latency) { - return B_ERROR; + CALLED(); + m_info->max_latency = max_latency; + return B_OK; } +//--------- not done ------------------- status_t -BJoystick::GetButtonNameAt(int32 index, - BString *out_name) +BJoystick::GetAxisNameAt(int32 index, BString *out_name) { + CALLED(); return B_ERROR; } status_t -BJoystick::GetControllerModule(BString *out_name) +BJoystick::GetHatNameAt(int32 index, BString *out_name) { + CALLED(); return B_ERROR; } status_t -BJoystick::GetControllerName(BString *out_name) +BJoystick::GetButtonNameAt(int32 index, BString *out_name) { + CALLED(); return B_ERROR; } -bool -BJoystick::IsCalibrationEnabled() -{ - return false; -} - - status_t -BJoystick::EnableCalibration(bool calibrates) +BJoystick::GetAxisValues(int16 *out_values, int32 for_stick) { - return false; -} - - -void -BJoystick::Calibrate(struct _extended_joystick *reading) -{ -} - - -status_t -BJoystick::gather_enhanced_info(const entry_ref *ref) -{ + CALLED(); return B_ERROR; } status_t -BJoystick::save_config(const entry_ref *ref) +BJoystick::GetHatValues(uint8 *out_hats, int32 for_stick) { + CALLED(); return B_ERROR; } -/* These functions are here to maintain Binary Compatibility */ -void BJoystick::_ReservedJoystick1() {} -void BJoystick::_ReservedJoystick2() {} -void BJoystick::_ReservedJoystick3() {} -status_t BJoystick::_Reserved_Joystick_4(void *, ...) {return B_ERROR;} -status_t BJoystick::_Reserved_Joystick_5(void *, ...) {return B_ERROR;} -status_t BJoystick::_Reserved_Joystick_6(void *, ...) {return B_ERROR;} - - -//-------------------------------------------------------------------// - - -_BJoystickTweaker::_BJoystickTweaker() +uint32 +BJoystick::ButtonValues(int32 for_stick) { + CALLED(); + return 0; } -_BJoystickTweaker::_BJoystickTweaker(BJoystick &stick) +status_t +BJoystick::Update(void) { - fJoystick = &stick; + CALLED(); + return B_ERROR; } -_BJoystickTweaker::~_BJoystickTweaker() +void +BJoystick::Calibrate(struct _extended_joystick *reading) { + CALLED(); } status_t -_BJoystickTweaker::save_config(const entry_ref *ref) +BJoystick::gather_enhanced_info(const entry_ref *ref) { + CALLED(); return B_ERROR; } status_t -_BJoystickTweaker::scan_including_disabled() +BJoystick::save_config(const entry_ref *ref) { + CALLED(); return B_ERROR; } -status_t -_BJoystickTweaker::get_info() -{ - return B_ERROR; -} +/* These functions are here to maintain Binary Compatibility */ +void BJoystick::_ReservedJoystick1() {CALLED();} +void BJoystick::_ReservedJoystick2() {CALLED();} +void BJoystick::_ReservedJoystick3() {CALLED();} +status_t BJoystick::_Reserved_Joystick_4(void *, ...) {CALLED();return B_ERROR;} +status_t BJoystick::_Reserved_Joystick_5(void *, ...) {CALLED();return B_ERROR;} +status_t BJoystick::_Reserved_Joystick_6(void *, ...) {CALLED();return B_ERROR;} From modeenf at mail.berlios.de Sun Aug 3 20:25:10 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Sun, 3 Aug 2008 20:25:10 +0200 Subject: [Haiku-commits] r26765 - haiku/trunk/src/kits/device Message-ID: <200808031825.m73IPAxm029514@sheep.berlios.de> Author: modeenf Date: 2008-08-03 20:25:08 +0200 (Sun, 03 Aug 2008) New Revision: 26765 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26765&view=rev Added: haiku/trunk/src/kits/device/JoystickTweaker.cpp Log: Forgot a file Added: haiku/trunk/src/kits/device/JoystickTweaker.cpp =================================================================== --- haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-03 18:22:21 UTC (rev 26764) +++ haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-03 18:25:08 UTC (rev 26765) @@ -0,0 +1,202 @@ +/* + * Copyright 2008, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fredrik Modeen + * + */ +#include "JoystickTweaker.h" +#include "Joystick.h" + +#include + +#include +#include + +#define STRINGLENGTHCPY 64 + +#include + +#ifdef DEBUG + inline void LOG(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \ + fputs(buf, _BJoystickTweaker::sLogFile); fflush(_BJoystickTweaker::sLogFile); } + #define LOG_ERR(text...) LOG(text) +FILE *_BJoystickTweaker::sLogFile = NULL; +#else + #define LOG(text...) + #define LOG_ERR(text...) fprintf(stderr, text) +#endif + +#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__) + +_BJoystickTweaker::_BJoystickTweaker() +{ + CALLED(); +#ifdef DEBUG + sLogFile = fopen("/var/log/libdevice.log", "a"); +#endif +} + + +_BJoystickTweaker::_BJoystickTweaker(BJoystick &stick) +{ + CALLED(); +#ifdef DEBUG + sLogFile = fopen("/var/log/libdevice.log", "a"); +#endif + + fJoystick = &stick; +} + + +_BJoystickTweaker::~_BJoystickTweaker() +{ +} + + +status_t +_BJoystickTweaker::save_config(const entry_ref *ref) +{ + CALLED(); + return B_ERROR; +} + + +status_t +_BJoystickTweaker::scan_including_disabled(const char* rootPath, BList *list, + BEntry *rootEntry = NULL) +{ + BDirectory root; + + if (rootEntry != NULL) + root.SetTo( rootEntry); + else if (rootPath != NULL) + root.SetTo(rootPath); + else + return B_ERROR; + + BEntry entry; + + ASSERT(list != NULL); + while ((root.GetNextEntry(&entry)) > B_ERROR ) { + if (entry.IsDirectory()) { + scan_including_disabled(rootPath, list, &entry); + } else { + BPath path; + entry.GetPath(&path); + + BString *str = new BString(path.Path()); + str->RemoveFirst(rootPath); + list->AddItem(str); + } + } + return B_OK; +} + + +void +_BJoystickTweaker::scan_including_disabled() +{ + CALLED(); + // First, we empty the list + for (int32 count = fJoystick->_fDevices->CountItems() - 1; count >= 0; count--) + free(fJoystick->_fDevices->RemoveItem(count)); + + scan_including_disabled(DEVICEPATH, fJoystick->_fDevices); +} + + +status_t +_BJoystickTweaker::get_info() +{ + CALLED(); + return B_ERROR; +} + + +status_t +_BJoystickTweaker::get_info(_joystick_info* info, + const char * ref) +{ + CALLED(); + status_t err = B_ERROR; + BString str(JOYSTICKPATH); + str.Append(ref); + + FILE *file = fopen(str.String(), "r"); + if (file != NULL) { + char line [STRINGLENGTHCPY]; /* or other suitable maximum line size */ + while (fgets ( line, sizeof line, file ) != NULL ) { /* read a line */ + int len = strlen(line); + if (len > 0 && line[len-1] == '\n') // if there's a newline + line[len-1] = '\0'; // truncate the string + BuildFromJoystickDesc(line, info); + } + fclose(file); + } + + err = B_OK; + return err; +} + + +void +_BJoystickTweaker::BuildFromJoystickDesc(char *string, _joystick_info* info) +{ + BString str(string); + str.RemoveAll("\""); + + if (str.IFindFirst("module") != -1) { + str.RemoveFirst("module = "); + strncpy(info->module_name, str.String(), STRINGLENGTHCPY); + } else if (str.IFindFirst("gadget") != -1) { + str.RemoveFirst("gadget = "); + strncpy(info->controller_name, str.String(), STRINGLENGTHCPY); + } else if (str.IFindFirst("num_axes") != -1) { + str.RemoveFirst("num_axes = "); + //strncpy(info->num_axes, str.String(), STRINGLENGTHCPY); + info->num_axes = atoi(str.String()); + //LOG("%s\n", str.String()); + } else if (str.IFindFirst("num_hats") != -1) { + str.RemoveFirst("num_hats = "); + info->num_hats = atoi(str.String()); + //strncpy(info->num_hats, str.String(), STRINGLENGTHCPY); + //LOG("%s\n", str.String()); + } else if (str.IFindFirst("num_buttons") != -1) { + str.RemoveFirst("num_buttons = "); + info->num_buttons = atoi(str.String()); + //strncpy(info->num_buttons, str.String(), STRINGLENGTHCPY); + //LOG("%s\n", str.String()); + } else if (str.IFindFirst("num_sticks") != -1) { + str.RemoveFirst("num_sticks = "); + info->num_sticks = atoi(str.String()); + //strncpy(info->num_sticks, str.String(), STRINGLENGTHCPY); + //LOG("%s\n", str.String()); + } else { + // LOG("Path = %s\n", str->String()); + } +} + + +status_t +_BJoystickTweaker::SendIOCT(uint32 op) +{ + status_t err = B_ERROR; + switch (op) { + case B_JOYSTICK_SET_DEVICE_MODULE: + break; + + case B_JOYSTICK_GET_DEVICE_MODULE: + break; + + case B_JOYSTICK_GET_SPEED_COMPENSATION: + case B_JOYSTICK_SET_SPEED_COMPENSATION: + case B_JOYSTICK_GET_MAX_LATENCY: + case B_JOYSTICK_SET_MAX_LATENCY: + case B_JOYSTICK_SET_RAW_MODE: + default: + break; + } + return err; +} From modeenf at mail.berlios.de Sun Aug 3 20:26:05 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Sun, 3 Aug 2008 20:26:05 +0200 Subject: [Haiku-commits] r26766 - haiku/trunk/headers/private Message-ID: <200808031826.m73IQ5GB029645@sheep.berlios.de> Author: modeenf Date: 2008-08-03 20:26:03 +0200 (Sun, 03 Aug 2008) New Revision: 26766 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26766&view=rev Added: haiku/trunk/headers/private/device/ Log: moved _JoystickTweaker (.h) to this place From modeenf at mail.berlios.de Sun Aug 3 20:29:24 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Sun, 3 Aug 2008 20:29:24 +0200 Subject: [Haiku-commits] r26767 - haiku/trunk/headers/private/device Message-ID: <200808031829.m73ITOQn029973@sheep.berlios.de> Author: modeenf Date: 2008-08-03 20:29:21 +0200 (Sun, 03 Aug 2008) New Revision: 26767 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26767&view=rev Added: haiku/trunk/headers/private/device/JoystickTweaker.h haiku/trunk/headers/private/device/joystick_driver.h Log: and now the files Added: haiku/trunk/headers/private/device/JoystickTweaker.h =================================================================== --- haiku/trunk/headers/private/device/JoystickTweaker.h 2008-08-03 18:26:03 UTC (rev 26766) +++ haiku/trunk/headers/private/device/JoystickTweaker.h 2008-08-03 18:29:21 UTC (rev 26767) @@ -0,0 +1,54 @@ +/* + * Copyright 2008, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fredrik Modeen + * + */ + +#include "joystick_driver.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#define DEBUG + +#define DEVICEPATH "/dev/joystick/" +#define JOYSTICKPATH "/boot/home/config/settings/joysticks/" + +class BJoystick; + +struct _joystick_info; + +class _BJoystickTweaker { + +public: + _BJoystickTweaker(); + _BJoystickTweaker(BJoystick &stick); +virtual ~_BJoystickTweaker(); + status_t SendIOCT(uint32 op); + void scan_including_disabled(); + status_t get_info(_joystick_info* info, const char * ref); +protected: +private: + void BuildFromJoystickDesc(char *string, _joystick_info* info); + status_t scan_including_disabled(const char* rootPath, BList *list, BEntry *rootEntry = NULL); + status_t save_config(const entry_ref * ref = NULL); + status_t get_info(); + BJoystick* fJoystick; +#ifdef DEBUG +public: + static FILE *sLogFile; +#endif +}; Added: haiku/trunk/headers/private/device/joystick_driver.h =================================================================== --- haiku/trunk/headers/private/device/joystick_driver.h 2008-08-03 18:26:03 UTC (rev 26766) +++ haiku/trunk/headers/private/device/joystick_driver.h 2008-08-03 18:29:21 UTC (rev 26767) @@ -0,0 +1,120 @@ +/* ++++++++++ + FILE: joystick_driver.h + REVS: $Revision: 1.1 $ + NAME: herold + DATE: Tue Jun 4 14:57:25 PDT 1996 ++++++ */ + +/* + Copyright 1999, Be Incorporated. All Rights Reserved. + This file may be used under the terms of the Be Sample Code License. +*/ + +#ifndef _JOYSTICK_DRIVER_H +#define _JOYSTICK_DRIVER_H + +#include +#include +#include + +typedef struct _joystick { + bigtime_t timestamp; + uint32 horizontal; + uint32 vertical; + bool button1; + bool button2; +} joystick; + +/* maximum number of axes on one controller (pads count as 2 axes each) */ +#define MAX_AXES 12 +/* maximum number of hats on one controller -- PADS SHOULD BE RETURNED AS AXES! */ +#define MAX_HATS 8 +/* maximum number of buttons on one controller */ +#define MAX_BUTTONS 32 +/* maximum number of controllers on one port */ +#define MAX_STICKS 4 + +typedef struct _extended_joystick { + bigtime_t timestamp; /* system_time when it was read */ + uint32 buttons; /* lsb to msb, 1 == on */ + int16 axes[MAX_AXES]; /* -32768 to 32767, X, Y, Z, U, V, W */ + uint8 hats[MAX_HATS]; /* 0 through 8 (1 == N, 3 == E, 5 == S, 7 == W) */ +} extended_joystick; + +#define MAX_CONFIG_SIZE 100 + +enum { /* flags for joystick module info */ + js_flag_force_feedback = 0x1, + js_flag_force_feedback_directional = 0x2 +}; + +typedef struct _joystick_module_info { + char module_name[64]; + char device_name[64]; + int16 num_axes; + int16 num_buttons; + int16 num_hats; + uint16 _reserved[7]; + uint32 flags; + uint16 num_sticks; + int16 config_size; + char device_config[MAX_CONFIG_SIZE]; /* device specific */ +} joystick_module_info; + +/* Note that joystick_module is something used by the game port driver */ +/* to talk to digital joysticks; if you're writing a sound card driver */ +/* and want to add support for a /dev/joystick device, use the generic_gameport */ +/* module. */ + +typedef struct _joystick_module { + module_info minfo; + /** "configure" might change the "info" if it auto-detects a device */ + int (*configure)(int port, joystick_module_info * info, size_t size, void ** out_cookie); + /** "read" actual data from device into "data" */ + int (*read)(void * cookie, int port, extended_joystick * data, size_t size); + /** "crumble" the cookie (deallocate) when done */ + int (*crumble)(void * cookie, int port); + /** "force" tells the joystick to exert force on the same axes as input for the specified duration */ + int (*force)(void * cookie, int port, bigtime_t duration, extended_joystick * force, size_t size); + int _reserved_; +} joystick_module; + +/** Doing force feedback means writing an extended_joystick to the device with force values. + The "timestamp" should be the duration of the feedback. Successive writes will be queued + by the device module. */ +enum { /* Joystick driver ioctl() opcodes */ + B_JOYSTICK_GET_SPEED_COMPENSATION = B_JOYSTICK_DRIVER_BASE, + /* arg -> ptr to int32 */ + B_JOYSTICK_SET_SPEED_COMPENSATION, /* arg -> ptr to int32 */ + B_JOYSTICK_GET_MAX_LATENCY, /* arg -> ptr to long long */ + B_JOYSTICK_SET_MAX_LATENCY, /* arg -> ptr to long long */ + B_JOYSTICK_SET_DEVICE_MODULE, /* arg -> ptr to joystick_module; also enters enhanced mode */ + B_JOYSTICK_GET_DEVICE_MODULE, /* arg -> ptr to joystick_module */ + B_JOYSTICK_SET_RAW_MODE /* arg -> ptr to bool (true or false) */ +}; + +/* Speed compensation is not generally necessary, because the joystick */ +/* driver is measuring using real time, not just # cycles. "0" means the */ +/* default, center value. + typically returns higher values; - returns lower */ +/* A typical range might be from -10 to +10, but it varies by driver */ + +/* Lower latency will make for more overhead in reading the joystick */ +/* ideally, you set this value to just short of how long it takes you */ +/* to calculate and render a frame. 30 fps -> latency 33000 */ + + +typedef struct _generic_gameport_module { + module_info minfo; + status_t (*create_device)(int port, void ** out_storage); + status_t (*delete_device)(void * storage); + status_t (*open_hook)(void * storage, uint32 flags, void ** out_cookie); + status_t (*close_hook)(void * cookie); + status_t (*free_hook)(void * cookie); + status_t (*control_hook)(void * cookie, uint32 op, void * data, size_t len); + status_t (*read_hook)(void * cookie, off_t pos, void * data, size_t * len); + status_t (*write_hook)(void * cookie, off_t pos, const void * data, size_t * len); + int _reserved_; +} generic_gameport_module; + + +#endif From rossi at webpositive.org Sun Aug 3 20:56:49 2008 From: rossi at webpositive.org (Marcus Jacob) Date: Sun, 03 Aug 2008 20:56:49 +0200 Subject: [Haiku-commits] r26762 - haiku/trunk/src/add-ons/accelerants/common References: <200808031800.m73I0LMC027333@sheep.berlios.de> Message-ID: <00045392c902a953_mailit@relay.webpositive.org> Hi Axel, cool! This change fixed my issue, now the 1920x1200 resolution works without disabling the EDID info in the intel_extreme accelerant. Thanks, Rossi >Author: axeld >Date: 2008-08-03 20:00:20 +0200 (Sun, 03 Aug 2008) >New Revision: 26762 >ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26762&view=rev > >Modified: > haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp >Log: >* Removed the extraneous 640x480 modes as pointed out by Gerald. >* Disabled "timing.sync != 3" check that potentially ignores modes that we >might > want to have. We could also add the mode by resolution in that case, and > ignore the timing info completely. There should be an open bug about this, > but I couldn't find it. >* Minor cleanup. > > >Modified: haiku/trunk/src/add-ons/accelerants/common/ create_display_modes.cpp >=================================================================== >--- haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2008- >08-03 16:30:30 UTC (rev 26761) >+++ haiku/trunk/src/add-ons/accelerants/common/create_display_modes.cpp 2008- >08-03 18:00:20 UTC (rev 26762) >@@ -1,5 +1,5 @@ > /* >- * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. All rights >reserved. >+ * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. > * Distributed under the terms of the MIT License. > */ > >@@ -16,7 +16,8 @@ > #define POSITIVE_SYNC \ > (B_POSITIVE_HSYNC | B_POSITIVE_VSYNC) > #define MODE_FLAGS \ >- (B_8_BIT_DAC | B_HARDWARE_CURSOR | B_PARALLEL_ACCESS | B_DPMS | >B_SUPPORTS_OVERLAYS) >+ (B_8_BIT_DAC | B_HARDWARE_CURSOR | B_PARALLEL_ACCESS | B_DPMS \ >+ | B_SUPPORTS_OVERLAYS) > > // TODO: move this list into the app_server > static const display_mode kBaseModeList[] = { >@@ -25,8 +26,6 @@ > {{25175, 640, 656, 752, 800, 400, 412, 414, 449, B_POSITIVE_VSYNC}, >B_CMAP8, 640, 400, 0, 0, MODE_FLAGS}, /* 640x400 - www.epanorama.net/ >documents/pc/vga_timing.html) */ > > {{25175, 640, 656, 752, 800, 480, 490, 492, 525, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 60Hz_(640X480X8.Z1) */ >- {{27500, 640, 672, 768, 864, 480, 488, 494, 530, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* 640X480X60Hz */ >- {{30500, 640, 672, 768, 864, 480, 517, 523, 588, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* SVGA_640X480X60HzNI */ > {{31500, 640, 664, 704, 832, 480, 489, 492, 520, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 70-72Hz_(640X480X8.Z1) */ > {{31500, 640, 656, 720, 840, 480, 481, 484, 500, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 75Hz_(640X480X8.Z1) */ > {{36000, 640, 696, 752, 832, 480, 481, 484, 509, 0}, B_CMAP8, 640, 480, >0, 0, MODE_FLAGS}, /* Vesa_Monitor_ at 85Hz_(640X480X8.Z1) */ >@@ -214,16 +213,18 @@ > } > > for (uint32 i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i) { >- if (info->detailed_monitor[i].monitor_desc_type != >EDID1_IS_DETAILED_TIMING) >+ if (info->detailed_monitor[i].monitor_desc_type >+ != EDID1_IS_DETAILED_TIMING) > continue; > > // TODO: handle flags correctly! >- const edid1_detailed_timing& timing = info-> >detailed_monitor[i].data.detailed_timing; >+ const edid1_detailed_timing& timing >+ = info->detailed_monitor[i].data.detailed_timing; > display_mode mode; >- >- if (timing.pixel_clock <= 0 || timing.sync != 3) >+ >+ if (timing.pixel_clock <= 0/* || timing.sync != 3*/) > continue; >- >+ > mode.timing.pixel_clock = timing.pixel_clock * 10; > mode.timing.h_display = timing.h_active; > mode.timing.h_sync_start = timing.h_active + timing.h_sync_off; >@@ -248,10 +249,10 @@ > mode.h_display_start = 0; > mode.v_display_start = 0; > mode.flags = MODE_FLAGS; >- >+ > _AddMode(&mode); > } >- >+ > // TODO: add other modes from the base list that satisfy the display's > // requirements! > >@@ -329,7 +330,7 @@ > // caller. Note that refresh rates computed from mode parameters is > // not exact; thus, the tolerance of 1.2% was obtained by testing >the > // various established modes that can be selected by the EDID info. >- >+ > if (mode.timing.h_display == width && mode.timing.v_display == height > && fabs(get_refresh_rate(mode) - refresh) < refresh * 0.012) { > _AddMode(&mode); > >_______________________________________________ >Haiku-commits mailing list >Haiku-commits at lists.berlios.de >https://lists.berlios.de/mailman/listinfo/haiku-commits From mmu_man at mail.berlios.de Sun Aug 3 21:18:57 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 21:18:57 +0200 Subject: [Haiku-commits] r26768 - haiku/trunk/src/system/boot/platform/atari_m68k Message-ID: <200808031918.m73JIvNU002795@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 21:18:56 +0200 (Sun, 03 Aug 2008) New Revision: 26768 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26768&view=rev Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp Log: Just go for 256MB for transparent translation at boot, 32MB is not enough anyway yet, the kernel wants 16MB just for the heap. Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-03 18:29:21 UTC (rev 26767) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-03 19:18:56 UTC (rev 26768) @@ -591,8 +591,8 @@ gKernelArgs.num_physical_allocated_ranges = 1; // remember the start of the allocated physical pages - // enable transparent translation of the first 32 MB - gMMUOps->set_tt(0, ATARI_CHIPRAM_BASE, 0x02000000, 0); + // enable transparent translation of the first 256 MB + gMMUOps->set_tt(0, ATARI_CHIPRAM_BASE, 0x10000000, 0); // enable transparent translation of the 16MB ST shadow range for I/O gMMUOps->set_tt(1, ATARI_SHADOW_BASE, 0x01000000, 0); From mmu_man at mail.berlios.de Sun Aug 3 21:44:00 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 21:44:00 +0200 Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device Message-ID: <200808031944.m73Ji0JP004609@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 21:43:59 +0200 (Sun, 03 Aug 2008) New Revision: 26769 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26769&view=rev Modified: haiku/trunk/src/kits/device/JoystickTweaker.cpp Log: gcc4 fix. my->beers--; Modified: haiku/trunk/src/kits/device/JoystickTweaker.cpp =================================================================== --- haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-03 19:18:56 UTC (rev 26768) +++ haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-03 19:43:59 UTC (rev 26769) @@ -65,7 +65,7 @@ status_t _BJoystickTweaker::scan_including_disabled(const char* rootPath, BList *list, - BEntry *rootEntry = NULL) + BEntry *rootEntry) { BDirectory root; From mmu_man at mail.berlios.de Sun Aug 3 21:53:10 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 3 Aug 2008 21:53:10 +0200 Subject: [Haiku-commits] r26770 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200808031953.m73JrAXO005139@sheep.berlios.de> Author: mmu_man Date: 2008-08-03 21:53:09 +0200 (Sun, 03 Aug 2008) New Revision: 26770 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26770&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp Log: - fix page dir index - fix comment - mode debug output - don't lookup unmapped pages in early_query Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-03 19:43:59 UTC (rev 26769) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2008-08-03 19:53:09 UTC (rev 26770) @@ -214,9 +214,8 @@ // this is used before the vm is fully up, it uses the -// transparent translation of the first 32MB +// transparent translation of the first 256MB // a set up by the bootloader. -// (XXX: why just 32MB ? TT0 should just map 2G) static status_t early_query(addr_t va, addr_t *_physicalAddress) { @@ -254,7 +253,7 @@ index = 0; // single descriptor } - if (pt /*&& pt[index].type == DT_PAGE*/) { + if (pt && pt[index].type == DT_PAGE) { *_physicalAddress = PTE_TO_PA(pt[index]); // we should only be passed page va, but just in case. *_physicalAddress += va % B_PAGE_SIZE; @@ -1273,7 +1272,7 @@ early_query(virt_pgtable, &phys_pgtable); index = VADDR_TO_PRENT(sIOSpaceBase) + i / NUM_DIRENT_PER_TBL; pd = (page_directory_entry *)PRE_TO_TA(pr[index]); - e = &pd[VADDR_TO_PRENT(sIOSpaceBase) + i % NUM_DIRENT_PER_TBL]; + e = &pd[(VADDR_TO_PDENT(sIOSpaceBase) + i) % NUM_DIRENT_PER_TBL]; put_pgtable_in_pgdir(e, phys_pgtable, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); } @@ -1432,11 +1431,11 @@ index = VADDR_TO_PRENT(va); if (pr[index].type != DT_ROOT) { unsigned aindex = index & ~(NUM_DIRTBL_PER_PAGE-1); /* aligned */ - //TRACE(("missing page root entry %d ai %d\n", index, aindex)); + TRACE(("missing page root entry %d ai %d\n", index, aindex)); tbl = get_free_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; - TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", tbl)); + TRACE(("early_map: asked for free page for pgdir. 0x%lx\n", tbl)); // zero-out memset((void *)tbl, 0, B_PAGE_SIZE); // for each pgdir on the allocated page: @@ -1456,7 +1455,7 @@ index = VADDR_TO_PDENT(va); if (pd[index].type != DT_DIR) { unsigned aindex = index & ~(NUM_PAGETBL_PER_PAGE-1); /* aligned */ - //TRACE(("missing page dir entry %d ai %d\n", index, aindex)); + TRACE(("missing page dir entry %d ai %d\n", index, aindex)); tbl = get_free_page(args) * B_PAGE_SIZE; if (!tbl) return ENOMEM; From emitrax at gmail.com Sun Aug 3 22:28:37 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sun, 3 Aug 2008 20:28:37 +0000 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <9020427257-BeMail@zon> References: <20080803042456.373.1@knochen-vm.localdomain> <9020427257-BeMail@zon> Message-ID: 2008/8/3 Axel D?rfler : > Ingo Weinhold wrote: >> Since there are more major changes to come in critical subsystems >> (particularly I/O and VM) which will almost inevitably be accompanied >> by >> some more bugs, maybe it's time to start tagging revisions that are >> generally perceived as relatively stable, and perhaps even maintain >> them >> for a short time as branches. That would be handy for people who want >> to >> demo Haiku or who want to get serious work done without running into >> every >> latest bug. > > Hm, that sounds very much like an alpha release to me ;-) So does to me, and I'm actually wondering what features are still missing before R1. Because new features always brings more bugs, and that only keep postponing the release. So is there a list of feature missing (not bugs :) )? Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From axeld at pinc-software.de Sun Aug 3 23:14:18 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 23:14:18 +0200 CEST Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device In-Reply-To: <200808031944.m73Ji0JP004609@sheep.berlios.de> Message-ID: <38664865007-BeMail@zon> mmu_man at mail.berlios.de wrote: > Log: > gcc4 fix. my->beers--; Infinity - 1 = Infinity :-) Bye, Axel. From revol at free.fr Sun Aug 3 23:31:49 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 03 Aug 2008 23:31:49 +0200 CEST Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device In-Reply-To: <38664865007-BeMail@zon> Message-ID: <19868805571-BeMail@laptop> > mmu_man at mail.berlios.de wrote: > > Log: > > gcc4 fix. my->beers--; > > Infinity - 1 = Infinity :-) #define Infinity 0 Fran?ois. From axeld at pinc-software.de Sun Aug 3 23:42:34 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 23:42:34 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26762_-_haiku/trunk/src/add-ons/accele?= =?utf-8?q?rants/common?= In-Reply-To: <00045392c902a953_mailit@relay.webpositive.org> Message-ID: <40360321517-BeMail@zon> Marcus Jacob wrote: > cool! This change fixed my issue, now the 1920x1200 resolution works > without > disabling the EDID info in the intel_extreme accelerant. Thanks for the feedback! Bye, Axel. From axeld at pinc-software.de Sun Aug 3 23:53:50 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 03 Aug 2008 23:53:50 +0200 CEST Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device In-Reply-To: <19868805571-BeMail@laptop> Message-ID: <41036761715-BeMail@zon> "Fran?ois Revol" wrote: > > mmu_man at mail.berlios.de wrote: > > > Log: > > > gcc4 fix. my->beers--; > > Infinity - 1 = Infinity :-) > #define Infinity 0 struct fran?ois { uint32 beers; [...] }; Bye, Axel. From revol at free.fr Mon Aug 4 00:05:06 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 04 Aug 2008 00:05:06 +0200 CEST Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device In-Reply-To: <41036761715-BeMail@zon> Message-ID: <1406730986-BeMail@laptop> > "Fran?ois Revol" wrote: > > > mmu_man at mail.berlios.de wrote: > > > > Log: > > > > gcc4 fix. my->beers--; > > > Infinity - 1 = Infinity :-) > > #define Infinity 0 > > struct fran?ois { > uint32 beers; > [...] > }; typedef signed long uint32; >:-) Fran?ois. From ingo_weinhold at gmx.de Mon Aug 4 01:15:24 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 04 Aug 2008 01:15:24 +0200 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <9020427257-BeMail@zon> References: <9020427257-BeMail@zon> Message-ID: <20080804011524.714.4@knochen-vm.localdomain> On 2008-08-03 at 15:00:14 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > Since there are more major changes to come in critical subsystems > > (particularly I/O and VM) which will almost inevitably be accompanied > > by > > some more bugs, maybe it's time to start tagging revisions that are > > generally perceived as relatively stable, and perhaps even maintain > > them > > for a short time as branches. That would be handy for people who want > > to > > demo Haiku or who want to get serious work done without running into > > every > > latest bug. > > Hm, that sounds very much like an alpha release to me ;-) It ain't a release unless it's released. :-) And I really wasn't thinking of branches that are maintained for months, but rather short lived ones that are terminated after a few weeks at the latest. That would also be a bit of practice for the eventual alpha branch. :-) > I would actually like to stay away from that for now, though, as what > we need to find bugs is exposure; Yep, I agree with the need for exposure, but I also see people using Haiku for "productive" things like porting stuff. Using the latest BFS change that will potentially eat hours of porting work might not that desirable in such a case. > actively maintaining more than a > single branch also means more overhead. Since that doesn't really require any development skills, none of the currently active developers would need to do anything, if someone else wanted to do that. > Remembering (via mailss or > tagging) more or less stable releases for demo purposes would be okay, > but I wouldn't maintain them in a branch yet. Well, I'm fine with tags for the time being. A reasonable naming scheme would help, plus a file that lists the most important problems of each tagged version. > Time to restart the distribution planning, anyway. Yep. CU, Ingo From umccullough at gmail.com Mon Aug 4 01:19:05 2008 From: umccullough at gmail.com (Urias McCullough) Date: Sun, 3 Aug 2008 23:19:05 +0000 Subject: [Haiku-commits] r26762 - haiku/trunk/src/add-ons/accelerants/common In-Reply-To: <00045392c902a953_mailit@relay.webpositive.org> References: <200808031800.m73I0LMC027333@sheep.berlios.de> <00045392c902a953_mailit@relay.webpositive.org> Message-ID: <1e80d8750808031619u4601f699ufba39fda58586958@mail.gmail.com> 2008/8/3 Marcus Jacob : > Hi Axel, > > cool! This change fixed my issue, now the 1920x1200 resolution works without > disabling the EDID info in the intel_extreme accelerant. Darn, I don't have my Haiku test box attached to my 1920x1200 screen any more (maybe a week from now). However, it does seem like all of a sudden the bootscreen doesn't show on this Dell 19" LCD (native res is 1280x1024). The screen reports that it's the wrong mode, and suggests 1280x1024 at 60hz. When I boot into my r26688 version, it works fine... so I'm assuming this change maybe "broke" that? This is on my dell optiplex gx270 with intel_extreme i865G. Huh, and I just noticed at some point listdev output got broken - everything reports as an "Unclassified device". Pretty sure that's a new problem. Anyhow, I apologize for my lack of time to submit proper issues to Trac - I'm sort of in my last hours of setup before I take these machines to LW tomorrow. I'll bring a serial cable with me in case I have a chance to debug while I'm there :) From kokitomare at gmail.com Mon Aug 4 01:27:52 2008 From: kokitomare at gmail.com (Jorge Mare) Date: Sun, 3 Aug 2008 16:27:52 -0700 Subject: [Haiku-commits] r26739 - haiku/trunk/build/jam In-Reply-To: <20080804011524.714.4@knochen-vm.localdomain> References: <9020427257-BeMail@zon> <20080804011524.714.4@knochen-vm.localdomain> Message-ID: On Sun, Aug 3, 2008 at 4:15 PM, Ingo Weinhold wrote: > > On 2008-08-03 at 15:00:14 [+0200], Axel D?rfler > wrote: >> Ingo Weinhold wrote: >> > Since there are more major changes to come in critical subsystems >> > (particularly I/O and VM) which will almost inevitably be accompanied >> > by >> > some more bugs, maybe it's time to start tagging revisions that are >> > generally perceived as relatively stable, and perhaps even maintain >> > them >> > for a short time as branches. That would be handy for people who want >> > to >> > demo Haiku or who want to get serious work done without running into >> > every >> > latest bug. >> >> Hm, that sounds very much like an alpha release to me ;-) > > It ain't a release unless it's released. :-) And I really wasn't thinking > of branches that are maintained for months, but rather short lived ones > that are terminated after a few weeks at the latest. That would also be a > bit of practice for the eventual alpha branch. :-) > >> I would actually like to stay away from that for now, though, as what >> we need to find bugs is exposure; > > Yep, I agree with the need for exposure, but I also see people using Haiku > for "productive" things like porting stuff. Using the latest BFS change > that will potentially eat hours of porting work might not that desirable in > such a case. > >> actively maintaining more than a >> single branch also means more overhead. > > Since that doesn't really require any development skills, none of the > currently active developers would need to do anything, if someone else > wanted to do that. > >> Remembering (via mailss or >> tagging) more or less stable releases for demo purposes would be okay, >> but I wouldn't maintain them in a branch yet. > > Well, I'm fine with tags for the time being. A reasonable naming scheme > would help, plus a file that lists the most important problems of each > tagged version. Be it branches or tags, the ability to identify "stable" revs would definitely be welcome by those of us who are demoing Haiku at conferences/etc. Jorge (on the same boat as Urias) From umccullough at gmail.com Mon Aug 4 01:27:57 2008 From: umccullough at gmail.com (Urias McCullough) Date: Sun, 3 Aug 2008 23:27:57 +0000 Subject: [Haiku-commits] r26762 - haiku/trunk/src/add-ons/accelerants/common In-Reply-To: <1e80d8750808031619u4601f699ufba39fda58586958@mail.gmail.com> References: <200808031800.m73I0LMC027333@sheep.berlios.de> <00045392c902a953_mailit@relay.webpositive.org> <1e80d8750808031619u4601f699ufba39fda58586958@mail.gmail.com> Message-ID: <1e80d8750808031627k4a14bbb4q71af77e14e5e266f@mail.gmail.com> 2008/8/3 Urias McCullough : > Huh, and I just noticed at some point listdev output got broken - > everything reports as an "Unclassified device". Pretty sure that's a > new problem. Nope, I guess that's been broken (probably since the new device_manager changes)... I even see the example I posted in ticket #2404 shows the issue. Not sure why I didn't notice that then. From mmu_man at mail.berlios.de Mon Aug 4 03:30:36 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Mon, 4 Aug 2008 03:30:36 +0200 Subject: [Haiku-commits] r26771 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200808040130.m741UaWp021431@sheep.berlios.de> Author: mmu_man Date: 2008-08-04 03:30:33 +0200 (Mon, 04 Aug 2008) New Revision: 26771 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26771&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp Log: - fix arch_debug_get_caller() - implemented arch_debug_get_stack_trace(), should allow building with TRACING enabled. Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2008-08-03 19:53:09 UTC (rev 26770) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2008-08-04 01:30:33 UTC (rev 26771) @@ -57,8 +57,7 @@ get_current_stack_frame() { stack_frame *frame; -#warning M68K: a6 or a7 ? - asm volatile("move.l %%a6,%0" : "=r"(frame)); + asm volatile("move.l %%fp,%0" : "=r"(frame)); return frame; } @@ -277,10 +276,69 @@ arch_debug_get_caller(void) { // TODO: implement me - return (void *)&arch_debug_get_caller; + //return __builtin_frame_address(1); + struct stack_frame *frame; + //frame = __builtin_frame_address(0); + frame = get_current_stack_frame(); + return (void *)frame->previous->return_address; } +int32 +arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, + int32 skipFrames, bool userOnly) +{ + struct iframe_stack *frameStack; + addr_t framePointer; + int32 count = 0; + int32 i, num = 0, last = 0; + + // always skip our own frame + skipFrames++; + + struct thread* thread = thread_get_current_thread(); + framePointer = (addr_t)get_current_stack_frame(); + + // We don't have a thread pointer early in the boot process + if (thread != NULL) + frameStack = &thread->arch_info.iframes; + else + frameStack = &gBootFrameStack; + + while (framePointer != 0 && count < maxCount) { + // see if the frame pointer matches the iframe + struct iframe *frame = NULL; + for (i = 0; i < frameStack->index; i++) { + if (framePointer == (((addr_t)frameStack->frames[i] - 8) & ~0xf)) { + // it's an iframe + frame = frameStack->frames[i]; + break; + } + } + + addr_t ip; + addr_t nextFrame; + + if (frame) { + ip = frame->cpu.pc; + nextFrame = frame->a[6]; + } else { + if (get_next_frame(framePointer, &nextFrame, &ip) != B_OK) + break; + } + + if (skipFrames <= 0 && (!userOnly || IS_USER_ADDRESS(framePointer))) + returnAddresses[count++] = ip; + else + skipFrames--; + + framePointer = nextFrame; + } + + return count; +} + + status_t arch_debug_init(kernel_args *args) { From bonefish at mail.berlios.de Mon Aug 4 04:43:50 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 04:43:50 +0200 Subject: [Haiku-commits] r26772 - haiku/trunk/src/system/kernel/fs Message-ID: <200808040243.m742hoHg032642@sheep.berlios.de> Author: bonefish Date: 2008-08-04 04:43:48 +0200 (Mon, 04 Aug 2008) New Revision: 26772 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26772&view=rev Modified: haiku/trunk/src/system/kernel/fs/fd.cpp Log: Fixed build with tracing enabled. Modified: haiku/trunk/src/system/kernel/fs/fd.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/fd.cpp 2008-08-04 01:30:33 UTC (rev 26771) +++ haiku/trunk/src/system/kernel/fs/fd.cpp 2008-08-04 02:43:48 UTC (rev 26772) @@ -498,8 +498,8 @@ status_t select_fd(int32 fd, struct select_info* info, bool kernel) { - TRACE(("select_fd(fd = %d, info = %p (%p), 0x%x)\n", fd, info, - info->sync, info.selected_events)); + TRACE(("select_fd(fd = %ld, info = %p (%p), 0x%x)\n", fd, info, + info->sync, info->selected_events)); FDGetter fdGetter; // define before the context locker, so it will be destroyed after it @@ -577,8 +577,8 @@ status_t deselect_fd(int32 fd, struct select_info* info, bool kernel) { - TRACE(("deselect_fd(fd = %d, info = %p (%p), 0x%x)\n", fd, info, - info->sync, info.selected_events)); + TRACE(("deselect_fd(fd = %ld, info = %p (%p), 0x%x)\n", fd, info, + info->sync, info->selected_events)); if (info->selected_events == 0) return B_OK; From bonefish at mail.berlios.de Mon Aug 4 04:45:07 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 04:45:07 +0200 Subject: [Haiku-commits] r26773 - haiku/trunk/src/system/kernel Message-ID: <200808040245.m742j7aT032744@sheep.berlios.de> Author: bonefish Date: 2008-08-04 04:45:06 +0200 (Mon, 04 Aug 2008) New Revision: 26773 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26773&view=rev Modified: haiku/trunk/src/system/kernel/condition_variable.cpp Log: More informative panic(). Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2008-08-04 02:43:48 UTC (rev 26772) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2008-08-04 02:45:06 UTC (rev 26773) @@ -113,8 +113,8 @@ ConditionVariableEntry::Wait(uint32 flags, bigtime_t timeout) { if (!are_interrupts_enabled()) { - panic("wait_for_condition_variable_entry() called with interrupts " - "disabled"); + panic("ConditionVariableEntry::Wait() called with interrupts " + "disabled, entry: %p, variable: %p", this, fVariable); return B_ERROR; } From bonefish at mail.berlios.de Mon Aug 4 04:46:09 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 04:46:09 +0200 Subject: [Haiku-commits] r26774 - haiku/trunk/src/system/kernel/vm Message-ID: <200808040246.m742k9OX032765@sheep.berlios.de> Author: bonefish Date: 2008-08-04 04:46:07 +0200 (Mon, 04 Aug 2008) New Revision: 26774 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26774&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: vm_page_fault(): Only put the address space, if we actually got one. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-04 02:45:06 UTC (rev 26773) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-04 02:46:07 UTC (rev 26774) @@ -4149,7 +4149,8 @@ } } - vm_put_address_space(addressSpace); + if (addressSpace != NULL) + vm_put_address_space(addressSpace); return B_HANDLED_INTERRUPT; } From bonefish at mail.berlios.de Mon Aug 4 04:51:41 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 04:51:41 +0200 Subject: [Haiku-commits] r26775 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200808040251.m742pfYJ000348@sheep.berlios.de> Author: bonefish Date: 2008-08-04 04:51:38 +0200 (Mon, 04 Aug 2008) New Revision: 26775 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26775&view=rev Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: * Introduced x86_get_double_fault_stack(), which returns the address and size of the double fault stack. * is_kernel_stack_address() does now also check whether the given address is on the double fault stack. This fixes stack traces on double faults, which were broken (i.e. went only to the double fault iframe) since we started checking whether the addresses are on the kernel stack at all. Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-04 02:46:07 UTC (rev 26774) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-04 02:51:38 UTC (rev 26775) @@ -268,6 +268,7 @@ void x86_set_mtrr(uint32 index, uint64 base, uint64 length, uint8 type); status_t x86_get_mtrr(uint32 index, uint64 *_base, uint64 *_length, uint8 *_type); bool x86_check_feature(uint32 feature, enum x86_feature_type type); +void* x86_get_double_fault_stack(int32 cpu, size_t* _size); #define read_cr3(value) \ Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-08-04 02:46:07 UTC (rev 26774) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2008-08-04 02:51:38 UTC (rev 26775) @@ -452,6 +452,14 @@ } +void* +x86_get_double_fault_stack(int32 cpu, size_t* _size) +{ + *_size = sizeof(sDoubleFaultStack); + return sDoubleFaultStack; +} + + // #pragma mark - Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-08-04 02:46:07 UTC (rev 26774) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-08-04 02:51:38 UTC (rev 26775) @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -208,7 +209,15 @@ *_thread = thread; } +static bool +is_double_fault_stack_address(int32 cpu, addr_t address) +{ + size_t size; + addr_t bottom = (addr_t)x86_get_double_fault_stack(cpu, &size); + return address >= bottom && address < bottom + size; +} + static bool is_kernel_stack_address(struct thread* thread, addr_t address) { @@ -218,7 +227,9 @@ return IS_KERNEL_ADDRESS(address); return address >= thread->kernel_stack_base - && address < thread->kernel_stack_top; + && address < thread->kernel_stack_top + || thread->cpu != NULL + && is_double_fault_stack_address(thread->cpu->cpu_num, address); } From bonefish at mail.berlios.de Mon Aug 4 04:57:04 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 04:57:04 +0200 Subject: [Haiku-commits] r26776 - haiku/trunk/src/system/kernel/fs Message-ID: <200808040257.m742v4Hi001392@sheep.berlios.de> Author: bonefish Date: 2008-08-04 04:57:03 +0200 (Mon, 04 Aug 2008) New Revision: 26776 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26776&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp Log: do_iterative_fd_io(): * When do_iterative_fd_io_iterate() fails, we must not invoke the supplied finished hook explicitly, since it is invoked indirectly by request->SetStatusAndNotify() anyway. Should fix #2557. * We must detach the descriptor putter as soon as we have adjusted the request's finished callback, since that will put the descriptor. Modified: haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-04 02:51:38 UTC (rev 26775) +++ haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-04 02:57:03 UTC (rev 26776) @@ -440,6 +440,9 @@ request->SetFinishedCallback(&do_iterative_fd_io_finish, iterationCookie); request->SetIterationCallback(&do_iterative_fd_io_iterate, iterationCookie); + descriptorPutter.Detach(); + // From now on the descriptor is put by our finish callback. + bool partialTransfer = false; status_t error = do_iterative_fd_io_iterate(iterationCookie, request, &partialTransfer); @@ -449,13 +452,9 @@ request->TransferredBytes()); } - finished(cookie, request, error, request->IsPartialTransfer(), - request->TransferredBytes()); request->SetStatusAndNotify(error); return error; } - descriptorPutter.Detach(); - return B_OK; } From bonefish at mail.berlios.de Mon Aug 4 05:02:26 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:02:26 +0200 Subject: [Haiku-commits] r26777 - haiku/trunk/src/system/kernel/debug Message-ID: <200808040302.m7432QT0001670@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:02:25 +0200 (Mon, 04 Aug 2008) New Revision: 26777 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26777&view=rev Modified: haiku/trunk/src/system/kernel/debug/debug.cpp Log: Fixed warning. Modified: haiku/trunk/src/system/kernel/debug/debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/debug/debug.cpp 2008-08-04 02:57:03 UTC (rev 26776) +++ haiku/trunk/src/system/kernel/debug/debug.cpp 2008-08-04 03:02:25 UTC (rev 26777) @@ -757,7 +757,7 @@ bool newLine = false; char line[256]; size_t linePos = 0; - for (int32 i = start; i < end; i++) { + for (uint32 i = start; i < end; i++) { char c = sSyslogBuffer->buffer[i % sSyslogBuffer->size]; if (c == '\0' || (uint8)c == 0xcc) continue; From bonefish at mail.berlios.de Mon Aug 4 05:03:35 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:03:35 +0200 Subject: [Haiku-commits] r26778 - haiku/trunk/headers/private/fs_shell Message-ID: <200808040303.m7433Ze0001756@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:03:31 +0200 (Mon, 04 Aug 2008) New Revision: 26778 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26778&view=rev Added: haiku/trunk/headers/private/fs_shell/fssh_auto_deleter.h Log: Copied AutoDeleter.h for use in the FS shell. Copied: haiku/trunk/headers/private/fs_shell/fssh_auto_deleter.h (from rev 26755, haiku/trunk/headers/private/shared/AutoDeleter.h) =================================================================== --- haiku/trunk/headers/private/shared/AutoDeleter.h 2008-08-03 13:40:41 UTC (rev 26755) +++ haiku/trunk/headers/private/fs_shell/fssh_auto_deleter.h 2008-08-04 03:03:31 UTC (rev 26778) @@ -0,0 +1,220 @@ +/* + * Copyright 2001-2007, Ingo Weinhold, bonefish at users.sf.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _AUTO_DELETER_H +#define _AUTO_DELETER_H + +/*! Scope-based automatic deletion of objects/arrays. + ObjectDeleter - deletes an object + ArrayDeleter - deletes an array + MemoryDeleter - free()s malloc()ed memory + CObjectDeleter - calls an arbitrary specified destructor function +*/ + +#include + +namespace FSShell { + +// AutoDeleter + +template +class AutoDeleter { +public: + inline AutoDeleter() + : fObject(NULL) + { + } + + inline AutoDeleter(C *object) + : fObject(object) + { + } + + inline ~AutoDeleter() + { + fDelete(fObject); + } + + inline void SetTo(C *object) + { + if (object != fObject) { + fDelete(fObject); + fObject = object; + } + } + + inline void Unset() + { + SetTo(NULL); + } + + inline void Delete() + { + SetTo(NULL); + } + + inline C *Get() const + { + return fObject; + } + + inline C *Detach() + { + C *object = fObject; + fObject = NULL; + return object; + } + +protected: + C *fObject; + DeleteFunc fDelete; +}; + + +// ObjectDeleter + +template +struct ObjectDelete +{ + inline void operator()(C *object) + { + delete object; + } +}; + +template +struct ObjectDeleter : AutoDeleter > +{ + ObjectDeleter() : AutoDeleter >() {} + ObjectDeleter(C *object) : AutoDeleter >(object) {} +}; + + +// ArrayDeleter + +template +struct ArrayDelete +{ + inline void operator()(C *array) + { + delete[] array; + } +}; + +template +struct ArrayDeleter : AutoDeleter > +{ + ArrayDeleter() : AutoDeleter >() {} + ArrayDeleter(C *array) : AutoDeleter >(array) {} +}; + + +// MemoryDeleter + +struct MemoryDelete +{ + inline void operator()(void *memory) + { + free(memory); + } +}; + +struct MemoryDeleter : AutoDeleter +{ + MemoryDeleter() : AutoDeleter() {} + MemoryDeleter(void *memory) : AutoDeleter(memory) {} +}; + + +// CObjectDeleter + +template +struct CObjectDelete +{ + inline void operator()(Type *object) + { + if (fDestructor != NULL && object != NULL) + fDestructor(object); + } + + template + inline void operator=(Destructor destructor) + { + fDestructor = destructor; + } + +private: + DestructorReturnType (*fDestructor)(Type*); +}; + +template +struct CObjectDeleter + : AutoDeleter > +{ + typedef AutoDeleter > Base; + + template + CObjectDeleter(Destructor destructor) : Base() + { + Base::fDelete = destructor; + } + + template + CObjectDeleter(Type *object, Destructor destructor) : Base(object) + { + Base::fDelete = destructor; + } +}; + + +// MethodDeleter + +template +struct MethodDelete +{ + inline void operator()(Type *object) + { + if (fDestructor && object != NULL) + (object->*fDestructor)(); + } + + template + inline void operator=(Destructor destructor) + { + fDestructor = destructor; + } + +private: + DestructorReturnType (Type::*fDestructor)(); +}; + + +template +struct MethodDeleter + : AutoDeleter > +{ + typedef AutoDeleter > Base; + + template + MethodDeleter(Destructor destructor) : Base() + { + Base::fDelete = destructor; + } + + template + MethodDeleter(Type *object, Destructor destructor) : Base(object) + { + Base::fDelete = destructor; + } +}; + +} // namespace FSShell + +using FSShell::ObjectDeleter; +using FSShell::ArrayDeleter; +using FSShell::MemoryDeleter; +using FSShell::CObjectDeleter; +using FSShell::MethodDeleter; + +#endif // _AUTO_DELETER_H From bonefish at mail.berlios.de Mon Aug 4 05:15:54 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:15:54 +0200 Subject: [Haiku-commits] r26779 - in haiku/trunk: headers/os/drivers headers/private/fs_shell src/system/kernel/cache src/system/kernel/vm src/tools/fs_shell Message-ID: <200808040315.m743FsVh007751@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:15:50 +0200 (Mon, 04 Aug 2008) New Revision: 26779 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26779&view=rev Modified: haiku/trunk/headers/os/drivers/fs_cache.h haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/tools/fs_shell/file_cache.cpp Log: Added functions file_cache_{disable,enable}(). They allow to disable actual caching in the file cache, i.e. all reads and writes go directly to the underlying device. The implementation is not quite complete, since the VM can still add pages to the cache when the file is mmap()ed, which can lead to inconsistencies. Modified: haiku/trunk/headers/os/drivers/fs_cache.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_cache.h 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/headers/os/drivers/fs_cache.h 2008-08-04 03:15:50 UTC (rev 26779) @@ -73,6 +73,8 @@ /* file cache */ extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size); extern void file_cache_delete(void *_cacheRef); +extern void file_cache_enable(void *_cacheRef); +extern status_t file_cache_disable(void *_cacheRef); extern status_t file_cache_set_size(void *_cacheRef, off_t size); extern status_t file_cache_sync(void *_cache); Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-04 03:15:50 UTC (rev 26779) @@ -828,6 +828,8 @@ /* file cache */ #define file_cache_create fssh_file_cache_create #define file_cache_delete fssh_file_cache_delete +#define file_cache_enable fssh_file_cache_enable +#define file_cache_disable fssh_file_cache_disable #define file_cache_set_size fssh_file_cache_set_size #define file_cache_sync fssh_file_cache_sync Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2008-08-04 03:15:50 UTC (rev 26779) @@ -88,6 +88,8 @@ extern void * fssh_file_cache_create(fssh_mount_id mountID, fssh_vnode_id vnodeID, fssh_off_t size); extern void fssh_file_cache_delete(void *_cacheRef); +extern void fssh_file_cache_enable(void *_cacheRef); +extern fssh_status_t fssh_file_cache_disable(void *_cacheRef); extern fssh_status_t fssh_file_cache_set_size(void *_cacheRef, fssh_off_t size); extern fssh_status_t fssh_file_cache_sync(void *_cache); Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-08-04 03:15:50 UTC (rev 26779) @@ -49,6 +49,7 @@ // significant 31 bits, and make this uint32 (one bit for // write vs. read) int32 last_access_index; + uint16 disabled_count; bool last_access_was_write; }; @@ -58,6 +59,7 @@ static struct cache_module_info *sCacheModule; +static const uint8 kZeroBuffer[4096] = {}; // #pragma mark - @@ -885,6 +887,7 @@ memset(ref->last_access, 0, sizeof(ref->last_access)); ref->last_access_index = 0; + ref->disabled_count = 0; // TODO: delay vm_cache creation until data is // requested/written for the first time? Listing lots of @@ -930,7 +933,53 @@ } +extern "C" void +file_cache_enable(void *_cacheRef) +{ + file_cache_ref *ref = (file_cache_ref*)_cacheRef; + + AutoLocker _(ref->cache); + + if (ref->disabled_count == 0) { + panic("Unbalanced file_cache_enable()!"); + return; + } + + ref->disabled_count--; +} + + extern "C" status_t +file_cache_disable(void *_cacheRef) +{ + // TODO: This function only removes all pages from the cache and prevents + // that the file cache functions add any new ones until re-enabled. The + // VM (on page fault) can still add pages, if the file is mmap()ed. We + // should mark the cache to prevent shared mappings of the file and fix + // the page fault code to deal correctly with private mappings (i.e. only + // insert pages in consumer caches). + + file_cache_ref *ref = (file_cache_ref*)_cacheRef; + + AutoLocker _(ref->cache); + + // If already disabled, there's nothing to do for us. + if (ref->disabled_count > 0) { + ref->disabled_count++; + return B_OK; + } + + // The file cache is not yet disabled. We need to evict all cached pages. + status_t error = ref->cache->FlushAndRemoveAllPages(); + if (error != B_OK) + return error; + + ref->disabled_count++; + return B_OK; +} + + +extern "C" status_t file_cache_set_size(void *_cacheRef, off_t newSize) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; @@ -974,6 +1023,14 @@ TRACE(("file_cache_read(ref = %p, offset = %Ld, buffer = %p, size = %lu)\n", ref, offset, buffer, *_size)); + if (ref->disabled_count > 0) { + // Caching is disabled -- read directly from the file. + iovec vec; + vec.iov_base = buffer; + vec.iov_len = *_size; + return vfs_read_pages(ref->vnode, cookie, offset, &vec, 1, 0, _size); + } + return cache_io(ref, cookie, offset, (addr_t)buffer, _size, false); } @@ -984,6 +1041,41 @@ { file_cache_ref *ref = (file_cache_ref *)_cacheRef; + if (ref->disabled_count > 0) { + // Caching is disabled -- write directly to the file. + + if (buffer != NULL) { + iovec vec; + vec.iov_base = (void*)buffer; + vec.iov_len = *_size; + return vfs_write_pages(ref->vnode, cookie, offset, &vec, 1, 0, + _size); + } + + // NULL buffer -- use a dummy buffer to write zeroes + // TODO: This is not particularly efficient! + iovec vec; + vec.iov_base = (void*)kZeroBuffer; + vec.iov_len = sizeof(kZeroBuffer); + size_t size = *_size; + while (size > 0) { + size_t toWrite = min_c(size, vec.iov_len); + size_t written = toWrite; + status_t error = vfs_write_pages(ref->vnode, cookie, offset, &vec, + 1, 0, &written); + if (error != B_OK) + return error; + if (written == 0) + break; + + offset += written; + size -= written; + } + + *_size -= size; + return B_OK; + } + status_t status = cache_io(ref, cookie, offset, (addr_t)const_cast(buffer), _size, true); Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-04 03:15:50 UTC (rev 26779) @@ -793,6 +793,51 @@ status_t +VMCache::FlushAndRemoveAllPages() +{ + while (page_count > 0) { + // write back modified pages + status_t error = WriteModified(); + if (error != B_OK) + return error; + + // remove pages + for (VMCachePagesTree::Iterator it = pages.GetIterator(); + vm_page* page = it.Next();) { + if (page->state == PAGE_STATE_BUSY) { + // wait for page to become unbusy + ConditionVariableEntry entry; + entry.Add(page); + Unlock(); + entry.Wait(); + Lock(); + + // restart from the start of the list + it = pages.GetIterator(); + continue; + } + + // skip modified pages -- they will be written back in the next + // iteration + if (page->state == PAGE_STATE_MODIFIED) + continue; + + // We can't remove mapped pages. + if (page->wired_count > 0 || !page->mappings.IsEmpty()) + return B_BUSY; + + RemovePage(page); + vm_page_free(this, page); + // Note: When iterating through a IteratableSplayTree + // removing the current node is safe. + } + } + + return B_OK; +} + + +status_t VMCache::Commit(off_t size) { committed_size = size; Modified: haiku/trunk/src/tools/fs_shell/file_cache.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_cache.cpp 2008-08-04 03:03:31 UTC (rev 26778) +++ haiku/trunk/src/tools/fs_shell/file_cache.cpp 2008-08-04 03:15:50 UTC (rev 26779) @@ -281,7 +281,22 @@ } +void +fssh_file_cache_enable(void *_cacheRef) +{ + fssh_panic("fssh_file_cache_enable() called"); +} + + fssh_status_t +fssh_file_cache_disable(void *_cacheRef) +{ + fssh_panic("fssh_file_cache_disable() called"); + return FSSH_B_ERROR; +} + + +fssh_status_t fssh_file_cache_set_size(void *_cacheRef, fssh_off_t size) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; From bonefish at mail.berlios.de Mon Aug 4 05:18:11 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:18:11 +0200 Subject: [Haiku-commits] r26780 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808040318.m743IBu3008136@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:18:10 +0200 (Mon, 04 Aug 2008) New Revision: 26780 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26780&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/system_dependencies.h Log: * Added support for O_NOCACHE/O_DIRECT. * bfs_open() was leaking the already allocated cookie in several error conditions. 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-08-04 03:15:50 UTC (rev 26779) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2008-08-04 03:18:10 UTC (rev 26780) @@ -70,6 +70,11 @@ bool partialTransfer, size_t bytesTransferred) { Inode* inode = (Inode*)cookie; +#ifndef BFS_SHELL +ktrace_printf("bfs iterative_io_finished_hook(): inode: %p, request: %p, " +"status: %#lx, partial: %d, transferred: %lu", inode, request, status, +partialTransfer, bytesTransferred); +#endif rw_lock_read_unlock(&inode->Lock()); return B_OK; @@ -450,6 +455,9 @@ if (inode->FileCache() == NULL) RETURN_ERROR(B_BAD_VALUE); +#ifndef BFS_SHELL +ktrace_printf("bfs_io(): inode: %p, request: %p", inode, request); +#endif // We lock the node here and will unlock it in the "finished" hook. rw_lock_read_lock(&inode->Lock()); @@ -1123,6 +1131,7 @@ file_cookie* cookie = new(std::nothrow) file_cookie; if (cookie == NULL) RETURN_ERROR(B_NO_MEMORY); + ObjectDeleter cookieDeleter(cookie); // initialize the cookie cookie->open_mode = openMode; @@ -1130,6 +1139,15 @@ cookie->last_size = inode->Size(); cookie->last_notification = system_time(); + // Disable the file cache, if requested? + CObjectDeleter fileCacheEnabler(file_cache_enable); + if ((openMode & O_NOCACHE) != 0 && inode->FileCache() != NULL) { + status = file_cache_disable(inode->FileCache()); + if (status != B_OK) + return status; + fileCacheEnabler.SetTo(inode->FileCache()); + } + // Should we truncate the file? if ((openMode & O_TRUNC) != 0) { if ((openMode & O_RWMASK) == O_RDONLY) @@ -1143,18 +1161,18 @@ inode->WriteLockInTransaction(transaction); status_t status = inode->SetFileSize(transaction, 0); - if (status >= B_OK) - status = inode->WriteBack(transaction); + if (status < B_OK) + return status; - if (status < B_OK) { - // bfs_free_cookie() is only called if this function is successful - delete cookie; + status = inode->WriteBack(transaction); + if (status < B_OK) return status; - } transaction.Done(); } + fileCacheEnabler.Detach(); + cookieDeleter.Detach(); *_cookie = cookie; return B_OK; } @@ -1306,6 +1324,9 @@ volume->Allocator().StopChecking(NULL); } + if ((cookie->open_mode & O_NOCACHE) != 0 && inode->FileCache() != NULL) + file_cache_enable(inode->FileCache()); + delete cookie; return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/system_dependencies.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/system_dependencies.h 2008-08-04 03:15:50 UTC (rev 26779) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/system_dependencies.h 2008-08-04 03:18:10 UTC (rev 26780) @@ -11,9 +11,11 @@ #include #include "fssh_api_wrapper.h" +#include "fssh_auto_deleter.h" #else // !BFS_SHELL +#include #include #include #include From bonefish at mail.berlios.de Mon Aug 4 05:19:11 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:19:11 +0200 Subject: [Haiku-commits] r26781 - haiku/trunk/headers/private/kernel Message-ID: <200808040319.m743JBqF008172@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:19:10 +0200 (Mon, 04 Aug 2008) New Revision: 26781 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26781&view=rev Modified: haiku/trunk/headers/private/kernel/vm_types.h Log: Should have been part of r26779. Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2008-08-04 03:18:10 UTC (rev 26780) +++ haiku/trunk/headers/private/kernel/vm_types.h 2008-08-04 03:19:10 UTC (rev 26781) @@ -209,6 +209,8 @@ status_t SetMinimalCommitment(off_t commitment); status_t Resize(off_t newSize); + status_t FlushAndRemoveAllPages(); + // for debugging only mutex* GetLock() { return &fLock; } From bonefish at mail.berlios.de Mon Aug 4 05:19:55 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:19:55 +0200 Subject: [Haiku-commits] r26782 - haiku/trunk/src/system/kernel/vm Message-ID: <200808040319.m743JtKp008203@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:19:54 +0200 (Mon, 04 Aug 2008) New Revision: 26782 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26782&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp Log: Use kprintf() instead of dprintf() in debugger commands. Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-04 03:19:10 UTC (rev 26781) +++ haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-04 03:19:54 UTC (rev 26782) @@ -39,22 +39,22 @@ { vm_area *area; - dprintf("dump of address space at %p:\n", aspace); - dprintf("id: 0x%lx\n", aspace->id); - dprintf("ref_count: %ld\n", aspace->ref_count); - dprintf("fault_count: %ld\n", aspace->fault_count); - dprintf("translation_map: %p\n", &aspace->translation_map); - dprintf("base: 0x%lx\n", aspace->base); - dprintf("size: 0x%lx\n", aspace->size); - dprintf("change_count: 0x%lx\n", aspace->change_count); - dprintf("area_hint: %p\n", aspace->area_hint); - dprintf("area_list:\n"); + kprintf("dump of address space at %p:\n", aspace); + kprintf("id: 0x%lx\n", aspace->id); + kprintf("ref_count: %ld\n", aspace->ref_count); + kprintf("fault_count: %ld\n", aspace->fault_count); + kprintf("translation_map: %p\n", &aspace->translation_map); + kprintf("base: 0x%lx\n", aspace->base); + kprintf("size: 0x%lx\n", aspace->size); + kprintf("change_count: 0x%lx\n", aspace->change_count); + kprintf("area_hint: %p\n", aspace->area_hint); + kprintf("area_list:\n"); for (area = aspace->areas; area != NULL; area = area->address_space_next) { - dprintf(" area 0x%lx: ", area->id); - dprintf("base_addr = 0x%lx ", area->base); - dprintf("size = 0x%lx ", area->size); - dprintf("name = '%s' ", area->name); - dprintf("protection = 0x%lx\n", area->protection); + kprintf(" area 0x%lx: ", area->id); + kprintf("base_addr = 0x%lx ", area->base); + kprintf("size = 0x%lx ", area->size); + kprintf("name = '%s' ", area->name); + kprintf("protection = 0x%lx\n", area->protection); } } @@ -65,7 +65,7 @@ vm_address_space *aspace; if (argc < 2) { - dprintf("aspace: not enough arguments\n"); + kprintf("aspace: not enough arguments\n"); return 0; } @@ -76,7 +76,7 @@ aspace = (vm_address_space *)hash_lookup(sAddressSpaceTable, &id); if (aspace == NULL) { - dprintf("invalid aspace id\n"); + kprintf("invalid aspace id\n"); } else { _dump_aspace(aspace); } @@ -92,7 +92,7 @@ vm_address_space *space; struct hash_iterator iter; - dprintf(" address id base size area count " + kprintf(" address id base size area count " " area size\n"); hash_open(sAddressSpaceTable, &iter); @@ -108,7 +108,7 @@ areaSize += area->size; } } - dprintf("%p %6ld %#010lx %#10lx %10ld %10lld\n", + kprintf("%p %6ld %#010lx %#10lx %10ld %10lld\n", space, space->id, space->base, space->size, areaCount, areaSize); } hash_close(sAddressSpaceTable, &iter, false); From bonefish at mail.berlios.de Mon Aug 4 05:28:52 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 05:28:52 +0200 Subject: [Haiku-commits] r26783 - in haiku/trunk/src/system/kernel: . vm Message-ID: <200808040328.m743Sq5K008579@sheep.berlios.de> Author: bonefish Date: 2008-08-04 05:28:46 +0200 (Mon, 04 Aug 2008) New Revision: 26783 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26783&view=rev Modified: haiku/trunk/src/system/kernel/main.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h Log: Patch by Zhao Shuai with changes by myself: * Keep track of the stack space actually allocated for the cache and let Write() fail when we've already allocated as much as reserved. * Added second phase of swap initialization (swap_init_post_modules()) which reads the virtual memory driver settings and creates/resizes a swap file. ATM truncate() is used to resize the swap file, but that is a bit slow. We should probably introduce a VFS function to use BFS's fast method. This should make swap support work somewhat, but since swap space is never freed ATM this would be a relatively short pleasure. Still disabled by default. Modified: haiku/trunk/src/system/kernel/main.cpp =================================================================== --- haiku/trunk/src/system/kernel/main.cpp 2008-08-04 03:19:54 UTC (rev 26782) +++ haiku/trunk/src/system/kernel/main.cpp 2008-08-04 03:28:46 UTC (rev 26783) @@ -273,6 +273,11 @@ boot_splash_set_stage(BOOT_SPLASH_STAGE_4_MOUNT_BOOT_FS); vfs_mount_boot_file_system(&sKernelArgs); +#if ENABLE_SWAP_SUPPORT + TRACE("swap_init_post_modules\n"); + swap_init_post_modules(); +#endif + // CPU specific modules may now be available boot_splash_set_stage(BOOT_SPLASH_STAGE_5_INIT_CPU_MODULES); cpu_init_post_modules(&sKernelArgs); Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 03:19:54 UTC (rev 26782) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 03:28:46 UTC (rev 26783) @@ -10,7 +10,11 @@ #include "VMAnonymousCache.h" +#include +#include #include +#include +#include #include #include @@ -18,9 +22,11 @@ #include #include #include +#include #include #include #include +#include #if ENABLE_SWAP_SUPPORT @@ -152,6 +158,7 @@ fPrecommittedPages = min_c(numPrecommittedPages, 255); fGuardedSize = numGuardPages * B_PAGE_SIZE; fCommittedSwapSize = 0; + fAllocatedSwapSize = 0; return B_OK; } @@ -223,6 +230,9 @@ VMAnonymousCache::Write(off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { + if (fAllocatedSwapSize + count * PAGE_SIZE > fCommittedSwapSize) + return B_ERROR; + offset >>= PAGE_SHIFT; uint32 n = count; for (uint32 i = 0; i < count; i += n) { @@ -234,6 +244,8 @@ if (pageIndex == SWAP_PAGE_NONE) panic("can't allocate swap space\n"); + fAllocatedSwapSize += n * PAGE_SIZE; + for (uint32 j = 0; j < n; j++) _SwapBlockBuild(offset + i + j, pageIndex + j); @@ -244,7 +256,6 @@ } off_t pos = (pageIndex - swapFile->first_page) * PAGE_SIZE; - status_t status = vfs_write_pages(swapFile->vnode, NULL, pos, vecs + i, n, 0, _numBytes); if (status != B_OK) @@ -728,5 +739,40 @@ sAvailSwapSpace = 0; } +void +swap_init_post_modules() +{ + off_t size = 0; + + void *settings = load_driver_settings("virtual_memory"); + if (settings != NULL) { + if (!get_driver_boolean_parameter(settings, "vm", false, false)) + return; + + const char *string = get_driver_parameter(settings, "swap_size", NULL, + NULL); + size = string ? atoll(string) : 0; + + unload_driver_settings(settings); + } else + size = vm_page_num_pages() * B_PAGE_SIZE * 2; + + if (size < B_PAGE_SIZE) + return; + + int fd = open("/var/swap", O_RDWR | O_CREAT | O_NOCACHE, S_IRUSR | S_IWUSR); + if (fd < 0) { + dprintf("Can't open/create /var/swap: %s\n", strerror(errno)); + return; + } + close(fd); + + if (truncate("/var/swap", size) < 0) { + dprintf("Failed to resize /var/swap to %lld bytes: %s\n", size, + strerror(errno)); + } + + swap_file_add("/var/swap"); +} + #endif // ENABLE_SWAP_SUPPORT - Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2008-08-04 03:19:54 UTC (rev 26782) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2008-08-04 03:28:46 UTC (rev 26783) @@ -48,10 +48,14 @@ uint8 fPrecommittedPages; int32 fGuardedSize; off_t fCommittedSwapSize; + off_t fAllocatedSwapSize; }; -extern "C" void swap_init(void); +extern "C" { + void swap_init(void); + void swap_init_post_modules(); +} #endif // ENABLE_SWAP_SUPPORT From modeenf at mail.berlios.de Mon Aug 4 07:45:57 2008 From: modeenf at mail.berlios.de (modeenf at mail.berlios.de) Date: Mon, 4 Aug 2008 07:45:57 +0200 Subject: [Haiku-commits] r26784 - haiku/trunk/src/kits/device Message-ID: <200808040545.m745jvVa006493@sheep.berlios.de> Author: modeenf Date: 2008-08-04 07:45:52 +0200 (Mon, 04 Aug 2008) New Revision: 26784 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26784&view=rev Modified: haiku/trunk/src/kits/device/Joystick.cpp haiku/trunk/src/kits/device/JoystickTweaker.cpp Log: comment fix and fixed some return error from BeBook Modified: haiku/trunk/src/kits/device/Joystick.cpp =================================================================== --- haiku/trunk/src/kits/device/Joystick.cpp 2008-08-04 03:28:46 UTC (rev 26783) +++ haiku/trunk/src/kits/device/Joystick.cpp 2008-08-04 05:45:52 UTC (rev 26784) @@ -21,6 +21,8 @@ #include #include +#include + #include "Joystick.h" #ifdef DEBUG @@ -112,6 +114,10 @@ _BJoystickTweaker jt(*this); jt.get_info(m_info, portName); + LOG("ioctl - %d\n", m_info->num_buttons); + ioctl(ffd, B_JOYSTICK_SET_DEVICE_MODULE, m_info); + ioctl(ffd, B_JOYSTICK_GET_DEVICE_MODULE, m_info); + LOG("ioctl - %d\n", m_info->num_buttons); if (ffd >= 0) { return ffd; } else @@ -161,19 +167,21 @@ BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize) { CALLED(); - status_t result = B_ERROR; BString *temp = new BString(); - if (_fDevices != NULL) + if (_fDevices != NULL && _fDevices->CountItems() > n) temp = static_cast(_fDevices->ItemAt(n)); + else + return B_BAD_INDEX; if (temp != NULL && name != NULL) { + if(temp->Length() > bufSize) + return B_NAME_TOO_LONG; strncpy(name, temp->String(), bufSize); name[bufSize - 1] = '\0'; - result = B_OK; + LOG("Device Name = %s\n", name); + return B_OK; } - - LOG("Device Name = %s\n", name); - return result; + return B_ERROR; } @@ -254,7 +262,11 @@ BJoystick::EnableCalibration(bool calibrates) { CALLED(); - return m_info->calibration_enable = calibrates; + if(ffd >= 0) { + m_info->calibration_enable = calibrates; + return B_OK; + } else + return B_NO_INIT; } @@ -263,6 +275,7 @@ { CALLED(); m_info->max_latency = max_latency; + //else B_ERROR (when?) return B_OK; } @@ -272,7 +285,7 @@ BJoystick::GetAxisNameAt(int32 index, BString *out_name) { CALLED(); - return B_ERROR; + return B_BAD_INDEX; } @@ -280,7 +293,7 @@ BJoystick::GetHatNameAt(int32 index, BString *out_name) { CALLED(); - return B_ERROR; + return B_BAD_INDEX; } @@ -288,7 +301,7 @@ BJoystick::GetButtonNameAt(int32 index, BString *out_name) { CALLED(); - return B_ERROR; + return B_BAD_INDEX; } @@ -296,7 +309,7 @@ BJoystick::GetAxisValues(int16 *out_values, int32 for_stick) { CALLED(); - return B_ERROR; + return B_BAD_VALUE; } @@ -304,7 +317,7 @@ BJoystick::GetHatValues(uint8 *out_hats, int32 for_stick) { CALLED(); - return B_ERROR; + return B_BAD_VALUE; } @@ -320,7 +333,10 @@ BJoystick::Update(void) { CALLED(); - return B_ERROR; + if(ffd >= 0) { + return B_OK; + } else + return B_ERROR; } Modified: haiku/trunk/src/kits/device/JoystickTweaker.cpp =================================================================== --- haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-04 03:28:46 UTC (rev 26783) +++ haiku/trunk/src/kits/device/JoystickTweaker.cpp 2008-08-04 05:45:52 UTC (rev 26784) @@ -126,11 +126,11 @@ FILE *file = fopen(str.String(), "r"); if (file != NULL) { - char line [STRINGLENGTHCPY]; /* or other suitable maximum line size */ - while (fgets ( line, sizeof line, file ) != NULL ) { /* read a line */ + char line [STRINGLENGTHCPY]; + while (fgets ( line, sizeof line, file ) != NULL ) { int len = strlen(line); - if (len > 0 && line[len-1] == '\n') // if there's a newline - line[len-1] = '\0'; // truncate the string + if (len > 0 && line[len-1] == '\n') + line[len-1] = '\0'; BuildFromJoystickDesc(line, info); } fclose(file); @@ -155,23 +155,19 @@ strncpy(info->controller_name, str.String(), STRINGLENGTHCPY); } else if (str.IFindFirst("num_axes") != -1) { str.RemoveFirst("num_axes = "); - //strncpy(info->num_axes, str.String(), STRINGLENGTHCPY); - info->num_axes = atoi(str.String()); + //info->num_axes = atoi(str.String()); //LOG("%s\n", str.String()); } else if (str.IFindFirst("num_hats") != -1) { str.RemoveFirst("num_hats = "); - info->num_hats = atoi(str.String()); - //strncpy(info->num_hats, str.String(), STRINGLENGTHCPY); + //info->num_hats = atoi(str.String()); //LOG("%s\n", str.String()); } else if (str.IFindFirst("num_buttons") != -1) { str.RemoveFirst("num_buttons = "); - info->num_buttons = atoi(str.String()); - //strncpy(info->num_buttons, str.String(), STRINGLENGTHCPY); + //info->num_buttons = atoi(str.String()); //LOG("%s\n", str.String()); } else if (str.IFindFirst("num_sticks") != -1) { str.RemoveFirst("num_sticks = "); - info->num_sticks = atoi(str.String()); - //strncpy(info->num_sticks, str.String(), STRINGLENGTHCPY); + //info->num_sticks = atoi(str.String()); //LOG("%s\n", str.String()); } else { // LOG("Path = %s\n", str->String()); From axeld at pinc-software.de Mon Aug 4 08:51:43 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 04 Aug 2008 08:51:43 +0200 CEST Subject: [Haiku-commits] r26769 - haiku/trunk/src/kits/device In-Reply-To: <1406730986-BeMail@laptop> Message-ID: <628571492-BeMail@zon> "Fran?ois Revol" wrote: > > > #define Infinity 0 > typedef signed long uint32; I think you have a strange perception of reality :-) Bye, Axel. From axeld at pinc-software.de Mon Aug 4 09:06:50 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 04 Aug 2008 09:06:50 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26779_-_in_haiku/trunk=3A_headers/os/d?= =?utf-8?q?rivers_headers/private/fs=5Fshell_src/system/kernel/cache_src/s?= =?utf-8?q?ystem/kernel/vm_src/tools/fs=5Fshell?= In-Reply-To: <200808040315.m743FsVh007751@sheep.berlios.de> Message-ID: <1535190808-BeMail@zon> bonefish at mail.berlios.de wrote: > +extern "C" status_t > file_cache_set_size(void *_cacheRef, off_t newSize) > { > file_cache_ref *ref = (file_cache_ref *)_cacheRef; > @@ -974,6 +1023,14 @@ > TRACE(("file_cache_read(ref = %p, offset = %Ld, buffer = %p, size = > %lu)\n", > ref, offset, buffer, *_size)); > > + if (ref->disabled_count > 0) { > + // Caching is disabled -- read directly from the file. [...] > + } > + > return cache_io(ref, cookie, offset, (addr_t)buffer, _size, false); > } > > @@ -984,6 +1041,41 @@ > { > file_cache_ref *ref = (file_cache_ref *)_cacheRef; > > + if (ref->disabled_count > 0) { > + // Caching is disabled -- write directly to the file. [...] > + } > + > status_t status = cache_io(ref, cookie, offset, > (addr_t)const_cast(buffer), _size, true); There is already the bypass cache logic in cache_io() which is thought to handle this case; even though this is more direct, we should either move that case from cache_io() then, or move this into cache_io() and let it use the read_from_file()/write_to_file() functions. At the very least, allocating the zero buffer via malloc() could be removed from write_to_file() :-) Bye, Axel. From axeld at mail.berlios.de Mon Aug 4 10:28:18 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 10:28:18 +0200 Subject: [Haiku-commits] r26785 - in haiku/trunk: headers/os/drivers headers/private/fs_shell src/system/kernel/cache src/tools/fs_shell Message-ID: <200808040828.m748SIkJ014852@sheep.berlios.de> Author: axeld Date: 2008-08-04 10:28:17 +0200 (Mon, 04 Aug 2008) New Revision: 26785 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26785&view=rev Modified: haiku/trunk/headers/os/drivers/fs_cache.h haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h haiku/trunk/src/system/kernel/cache/file_cache.cpp haiku/trunk/src/system/kernel/cache/file_map.cpp haiku/trunk/src/tools/fs_shell/file_cache.cpp haiku/trunk/src/tools/fs_shell/file_map.cpp Log: * Added file_cache_is_enabled() function. * Added file_map_set_mode() function that you can use to keep a whole file cached. This is needed for the swap file support: FILE_MAP_CACHE_ALL will not only precache all file_io_vecs when called, but it will also cause all file_map_translate() calls to fail that would require further caching (ie. if the file size had changed). * Updated the fs_shell file map code to the latest one (with several bug fixes). Modified: haiku/trunk/headers/os/drivers/fs_cache.h =================================================================== --- haiku/trunk/headers/os/drivers/fs_cache.h 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/headers/os/drivers/fs_cache.h 2008-08-04 08:28:17 UTC (rev 26785) @@ -19,6 +19,12 @@ TRANSACTION_IDLE = 0x08 }; +/* file map modes */ +enum { + FILE_MAP_CACHE_ON_DEMAND = 0x01, /* default mode */ + FILE_MAP_CACHE_ALL = 0x02 +}; + typedef void (*transaction_notification_hook)(int32 id, int32 event, void *data); @@ -74,6 +80,7 @@ extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size); extern void file_cache_delete(void *_cacheRef); extern void file_cache_enable(void *_cacheRef); +extern bool file_cache_is_enabled(void *_cacheRef); extern status_t file_cache_disable(void *_cacheRef); extern status_t file_cache_set_size(void *_cacheRef, off_t size); extern status_t file_cache_sync(void *_cache); @@ -88,6 +95,7 @@ extern void file_map_delete(void *_map); extern void file_map_set_size(void *_map, off_t size); extern void file_map_invalidate(void *_map, off_t offset, off_t size); +extern status_t file_map_set_mode(void *_map, uint32 mode); extern status_t file_map_translate(void *_map, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count); Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2008-08-04 08:28:17 UTC (rev 26785) @@ -794,6 +794,9 @@ #define TRANSACTION_ENDED FSSH_TRANSACTION_ENDED #define TRANSACTION_IDLE FSSH_TRANSACTION_IDLE +#define FILE_MAP_CACHE_ON_DEMAND FSSH_FILE_MAP_CACHE_ON_DEMAND +#define FILE_MAP_CACHE_ALL FSSH_FILE_MAP_CACHE_ALL + #define transaction_notification_hook fssh_transaction_notification_hook /* transactions */ Modified: haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/headers/private/fs_shell/fssh_fs_cache.h 2008-08-04 08:28:17 UTC (rev 26785) @@ -18,6 +18,12 @@ FSSH_TRANSACTION_IDLE = 0x08 }; +/* file map modes */ +enum { + FSSH_FILE_MAP_CACHE_ON_DEMAND = 0x01, /* default mode */ + FSSH_FILE_MAP_CACHE_ALL = 0x02 +}; + typedef void (*fssh_transaction_notification_hook)(int32_t id, int32_t event, void *data); @@ -90,6 +96,7 @@ extern void fssh_file_cache_delete(void *_cacheRef); extern void fssh_file_cache_enable(void *_cacheRef); extern fssh_status_t fssh_file_cache_disable(void *_cacheRef); +extern bool fssh_file_cache_is_enabled(void *_cacheRef); extern fssh_status_t fssh_file_cache_set_size(void *_cacheRef, fssh_off_t size); extern fssh_status_t fssh_file_cache_sync(void *_cache); @@ -108,6 +115,7 @@ extern void fssh_file_map_set_size(void *_map, fssh_off_t size); extern void fssh_file_map_invalidate(void *_map, fssh_off_t offset, fssh_off_t size); +extern fssh_status_t fssh_file_map_set_mode(void *_map, uint32_t mode); extern fssh_status_t fssh_file_map_translate(void *_map, fssh_off_t offset, fssh_size_t size, struct fssh_file_io_vec *vecs, fssh_size_t *_count); Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2008-08-04 08:28:17 UTC (rev 26785) @@ -979,6 +979,16 @@ } +extern "C" bool +file_cache_is_enabled(void *_cacheRef) +{ + file_cache_ref *ref = (file_cache_ref*)_cacheRef; + AutoLocker _(ref->cache); + + return ref->disabled_count == 0; +} + + extern "C" status_t file_cache_set_size(void *_cacheRef, off_t newSize) { Modified: haiku/trunk/src/system/kernel/cache/file_map.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_map.cpp 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/src/system/kernel/cache/file_map.cpp 2008-08-04 08:28:17 UTC (rev 26785) @@ -71,11 +71,14 @@ struct vnode* Vnode() const { return fVnode; } off_t Size() const { return fSize; } + status_t SetMode(uint32 mode); + private: file_extent* _FindExtent(off_t offset, uint32* _index); status_t _MakeSpace(size_t count); status_t _Add(file_io_vec* vecs, size_t vecCount, off_t& lastOffset); + status_t _Cache(off_t offset, off_t size); void _InvalidateAfter(off_t offset); void _Free(); @@ -87,6 +90,7 @@ size_t fCount; struct vnode* fVnode; off_t fSize; + bool fCacheAll; }; #ifdef DEBUG_FILE_MAP @@ -98,11 +102,13 @@ FileMap::FileMap(struct vnode* vnode, off_t size) + : + fCount(0), + fVnode(vnode), + fSize(size), + fCacheAll(false) { mutex_init(&fLock, "file map"); - fCount = 0; - fVnode = vnode; - fSize = size; #ifdef DEBUG_FILE_MAP MutexLocker _(sLock); @@ -320,12 +326,68 @@ status_t +FileMap::_Cache(off_t offset, off_t size) +{ + file_extent* lastExtent = NULL; + if (fCount > 0) + lastExtent = ExtentAt(fCount - 1); + + off_t mapEnd = 0; + if (lastExtent != NULL) + mapEnd = lastExtent->offset + lastExtent->disk.length; + + off_t end = offset + size; + + if (fCacheAll && mapEnd < end) + return B_ERROR; + + status_t status = B_OK; + file_io_vec vecs[8]; + const size_t kMaxVecs = 8; + + while (status == B_OK && mapEnd < end) { + // We don't have the requested extents yet, retrieve them + size_t vecCount = kMaxVecs; + status = vfs_get_file_map(Vnode(), mapEnd, ~0UL, vecs, &vecCount); + if (status == B_OK || status == B_BUFFER_OVERFLOW) + status = _Add(vecs, vecCount, mapEnd); + } + + return status; +} + + +status_t +FileMap::SetMode(uint32 mode) +{ + if (mode != FILE_MAP_CACHE_ALL && mode != FILE_MAP_CACHE_ON_DEMAND) + return B_BAD_VALUE; + + MutexLocker _(fLock); + + if (mode == FILE_MAP_CACHE_ALL && fCacheAll + || mode == FILE_MAP_CACHE_ON_DEMAND && !fCacheAll) + return B_OK; + + if (mode == FILE_MAP_CACHE_ALL) { + status_t status = _Cache(0, fSize); + if (status != B_OK) + return status; + + fCacheAll = true; + } else + fCacheAll = false; + + return B_OK; +} + + +status_t FileMap::Translate(off_t offset, size_t size, file_io_vec* vecs, size_t* _count) { MutexLocker _(fLock); size_t maxVecs = *_count; - status_t status = B_OK; if (offset >= Size()) { *_count = 0; @@ -337,24 +399,7 @@ // First, we need to make sure that we have already cached all file // extents needed for this request. - file_extent* lastExtent = NULL; - if (fCount > 0) - lastExtent = ExtentAt(fCount - 1); - - off_t mapOffset = 0; - if (lastExtent != NULL) - mapOffset = lastExtent->offset + lastExtent->disk.length; - - off_t end = offset + size; - - while (status == B_OK && mapOffset < end) { - // We don't have the requested extents yet, retrieve them - size_t vecCount = maxVecs; - status = vfs_get_file_map(Vnode(), mapOffset, ~0UL, vecs, &vecCount); - if (status == B_OK || status == B_BUFFER_OVERFLOW) - status = _Add(vecs, vecCount, mapOffset); - } - + status_t status = _Cache(offset, size); if (status != B_OK) return status; @@ -570,6 +615,17 @@ extern "C" status_t +file_map_set_mode(void* _map, uint32 mode) +{ + FileMap* map = (FileMap*)_map; + if (map == NULL) + return B_BAD_VALUE; + + return map->SetMode(mode); +} + + +extern "C" status_t file_map_translate(void* _map, off_t offset, size_t size, file_io_vec* vecs, size_t* _count) { Modified: haiku/trunk/src/tools/fs_shell/file_cache.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_cache.cpp 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/src/tools/fs_shell/file_cache.cpp 2008-08-04 08:28:17 UTC (rev 26785) @@ -296,6 +296,13 @@ } +bool +fssh_file_cache_is_enabled(void *_cacheRef) +{ + return true; +} + + fssh_status_t fssh_file_cache_set_size(void *_cacheRef, fssh_off_t size) { Modified: haiku/trunk/src/tools/fs_shell/file_map.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_map.cpp 2008-08-04 05:45:52 UTC (rev 26784) +++ haiku/trunk/src/tools/fs_shell/file_map.cpp 2008-08-04 08:28:17 UTC (rev 26785) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -8,6 +8,7 @@ #include #include +#include #include "fssh_kernel_export.h" #include "vfs.h" @@ -33,103 +34,201 @@ fssh_file_io_vec disk; }; -struct file_map { - file_map(fssh_off_t size); - ~file_map(); +struct file_extent_array { + file_extent* array; + fssh_size_t max_count; +}; - file_extent *operator[](uint32_t index); - file_extent *ExtentAt(uint32_t index); - fssh_status_t Add(fssh_file_io_vec *vecs, fssh_size_t vecCount, - fssh_off_t &lastOffset); - void Free(); +class FileMap { +public: + FileMap(void* vnode, fssh_off_t size); + ~FileMap(); + void Invalidate(fssh_off_t offset, fssh_off_t size); + void SetSize(fssh_off_t size); + + fssh_status_t Translate(fssh_off_t offset, fssh_size_t size, + fssh_file_io_vec* vecs, fssh_size_t* _count); + + file_extent* ExtentAt(uint32_t index); + + fssh_size_t Count() const { return fCount; } + void* Vnode() const { return fVnode; } + fssh_off_t Size() const { return fSize; } + + fssh_status_t SetMode(uint32_t mode); + +private: + file_extent* _FindExtent(fssh_off_t offset, uint32_t* _index); + fssh_status_t _MakeSpace(fssh_size_t count); + fssh_status_t _Add(fssh_file_io_vec* vecs, fssh_size_t vecCount, + fssh_off_t& lastOffset); + fssh_status_t _Cache(fssh_off_t offset, fssh_off_t size); + void _InvalidateAfter(fssh_off_t offset); + void _Free(); + union { - file_extent direct[CACHED_FILE_EXTENTS]; - file_extent *array; + file_extent fDirect[CACHED_FILE_EXTENTS]; + file_extent_array fIndirect; }; - fssh_size_t count; - void *vnode; - fssh_off_t size; + fssh_mutex fLock; + fssh_size_t fCount; + void* fVnode; + fssh_off_t fSize; + bool fCacheAll; }; -file_map::file_map(fssh_off_t _size) +FileMap::FileMap(void* vnode, fssh_off_t size) + : + fCount(0), + fVnode(vnode), + fSize(size), + fCacheAll(false) { - array = NULL; - count = 0; - size = _size; + fssh_mutex_init(&fLock, "file map"); } -file_map::~file_map() +FileMap::~FileMap() { - Free(); + _Free(); + fssh_mutex_destroy(&fLock); } -file_extent * -file_map::operator[](uint32_t index) +file_extent* +FileMap::ExtentAt(uint32_t index) { - return ExtentAt(index); + if (index >= fCount) + return NULL; + + if (fCount > CACHED_FILE_EXTENTS) + return &fIndirect.array[index]; + + return &fDirect[index]; } -file_extent * -file_map::ExtentAt(uint32_t index) +file_extent* +FileMap::_FindExtent(fssh_off_t offset, uint32_t *_index) { - if (index >= count) - return NULL; + int32_t left = 0; + int32_t right = fCount - 1; - if (count > CACHED_FILE_EXTENTS) - return &array[index]; + while (left <= right) { + int32_t index = (left + right) / 2; + file_extent* extent = ExtentAt(index); - return &direct[index]; + if (extent->offset > offset) { + // search in left part + right = index - 1; + } else if (extent->offset + extent->disk.length <= offset) { + // search in right part + left = index + 1; + } else { + // found extent + if (_index) + *_index = index; + + return extent; + } + } + + return NULL; } fssh_status_t -file_map::Add(fssh_file_io_vec *vecs, fssh_size_t vecCount, - fssh_off_t &lastOffset) +FileMap::_MakeSpace(fssh_size_t count) { - TRACE(("file_map::Add(vecCount = %u)\n", vecCount)); - - fssh_off_t offset = 0; - - if (vecCount <= CACHED_FILE_EXTENTS && count == 0) { + if (count <= CACHED_FILE_EXTENTS) { // just use the reserved area in the file_cache_ref structure + if (fCount > CACHED_FILE_EXTENTS) { + // the new size is smaller than the minimal array size + file_extent *array = fIndirect.array; + memcpy(fDirect, array, sizeof(file_extent) * count); + free(array); + } } else { - // TODO: once we can invalidate only parts of the file map, - // we might need to copy the previously cached file extends - // from the direct range - file_extent *newMap = (file_extent *)realloc(array, - (count + vecCount) * sizeof(file_extent)); - if (newMap == NULL) - return FSSH_B_NO_MEMORY; + // resize array if needed + file_extent* oldArray = NULL; + fssh_size_t maxCount = CACHED_FILE_EXTENTS; + if (fCount > CACHED_FILE_EXTENTS) { + oldArray = fIndirect.array; + maxCount = fIndirect.max_count; + } - array = newMap; + if (count > maxCount) { + // allocate new array + while (maxCount < count) { + if (maxCount < 32768) + maxCount <<= 1; + else + maxCount += 32768; + } - if (count != 0) { - file_extent *extent = ExtentAt(count - 1); - offset = extent->offset + extent->disk.length; + file_extent* newArray = (file_extent *)realloc(oldArray, + maxCount * sizeof(file_extent)); + if (newArray == NULL) + return FSSH_B_NO_MEMORY; + + if (fCount > 0 && fCount <= CACHED_FILE_EXTENTS) + memcpy(newArray, fDirect, sizeof(file_extent) * fCount); + + fIndirect.array = newArray; + fIndirect.max_count = maxCount; } } - int32_t start = count; - count += vecCount; + fCount = count; + return FSSH_B_OK; +} + +fssh_status_t +FileMap::_Add(fssh_file_io_vec* vecs, fssh_size_t vecCount, + fssh_off_t& lastOffset) +{ + TRACE(("FileMap@%p::Add(vecCount = %ld)\n", this, vecCount)); + + uint32_t start = fCount; + fssh_off_t offset = 0; + + fssh_status_t status = _MakeSpace(fCount + vecCount); + if (status != FSSH_B_OK) + return status; + + file_extent* lastExtent = NULL; + if (start != 0) { + lastExtent = ExtentAt(start - 1); + offset = lastExtent->offset + lastExtent->disk.length; + } + for (uint32_t i = 0; i < vecCount; i++) { - file_extent *extent = ExtentAt(start + i); + if (lastExtent != NULL) { + if (lastExtent->disk.offset + lastExtent->disk.length + == vecs[i].offset) { + lastExtent->disk.length += vecs[i].length; + offset += vecs[i].length; + start--; + _MakeSpace(fCount - 1); + continue; + } + } + file_extent* extent = ExtentAt(start + i); extent->offset = offset; extent->disk = vecs[i]; offset += extent->disk.length; + lastExtent = extent; } #ifdef TRACE_FILE_MAP - for (uint32_t i = 0; i < count; i++) { - file_extent *extent = ExtentAt(i); - fssh_dprintf("[%u] extend offset %Ld, disk offset %Ld, length %Ld\n", + for (uint32 i = 0; i < fCount; i++) { + file_extent* extent = ExtentAt(i); + dprintf("[%ld] extent offset %Ld, disk offset %Ld, length %Ld\n", i, extent->offset, extent->disk.offset, extent->disk.length); } #endif @@ -140,172 +239,154 @@ void -file_map::Free() +FileMap::_InvalidateAfter(fssh_off_t offset) { - if (count > CACHED_FILE_EXTENTS) - free(array); + uint32_t index; + file_extent* extent = _FindExtent(offset, &index); + if (extent != NULL) { + _MakeSpace(index + 1); - array = NULL; - count = 0; + if (extent->offset + extent->disk.length > offset) { + extent->disk.length = offset - extent->offset; + if (extent->disk.length == 0) + _MakeSpace(index); + } + } } -// #pragma mark - - - -static file_extent * -find_file_extent(file_map &map, fssh_off_t offset, uint32_t *_index) +/*! Invalidates or removes the specified part of the file map. +*/ +void +FileMap::Invalidate(fssh_off_t offset, fssh_off_t size) { - // TODO: do binary search + MutexLocker _(fLock); - for (uint32_t index = 0; index < map.count; index++) { - file_extent *extent = map[index]; - - if (extent->offset <= offset - && extent->offset + extent->disk.length > offset) { - if (_index) - *_index = index; - return extent; - } + // TODO: honour size, we currently always remove everything after "offset" + if (offset == 0) { + _Free(); + return; } - return NULL; + _InvalidateAfter(offset); } -} // namespace FSShell +void +FileMap::SetSize(fssh_off_t size) +{ + MutexLocker _(fLock); + if (size < fSize) + _InvalidateAfter(size); -// #pragma mark - public FS API + fSize = size; +} -extern "C" void * -fssh_file_map_create(fssh_mount_id mountID, fssh_vnode_id vnodeID, - fssh_off_t size) +void +FileMap::_Free() { - TRACE(("file_map_create(mountID = %d, vnodeID = %Ld)\n", mountID, vnodeID)); + if (fCount > CACHED_FILE_EXTENTS) + free(fIndirect.array); - file_map *map = new file_map(size); - if (map == NULL) - return NULL; - - // Get the vnode for the object - // (note, this does not grab a reference to the node) - if (vfs_lookup_vnode(mountID, vnodeID, &map->vnode) != FSSH_B_OK) { - delete map; - return NULL; - } - - return map; + fCount = 0; } -extern "C" void -fssh_file_map_delete(void *_map) +fssh_status_t +FileMap::_Cache(fssh_off_t offset, fssh_off_t size) { - file_map *map = (file_map *)_map; - if (map == NULL) - return; + file_extent* lastExtent = NULL; + if (fCount > 0) + lastExtent = ExtentAt(fCount - 1); - TRACE(("file_map_delete(map = %p)\n", map)); - delete map; -} + fssh_off_t mapEnd = 0; + if (lastExtent != NULL) + mapEnd = lastExtent->offset + lastExtent->disk.length; + fssh_off_t end = offset + size; -extern "C" void -fssh_file_map_set_size(void *_map, fssh_off_t size) -{ - if (_map == NULL) - return; + if (fCacheAll && mapEnd < end) + return FSSH_B_ERROR; - // TODO: honour offset/size parameters - file_map *map = (file_map *)_map; - //if (size < map->size) - map->Free(); - map->size = size; + fssh_status_t status = FSSH_B_OK; + fssh_file_io_vec vecs[8]; + const fssh_size_t kMaxVecs = 8; + + while (status == FSSH_B_OK && mapEnd < end) { + // We don't have the requested extents yet, retrieve them + size_t vecCount = kMaxVecs; + status = vfs_get_file_map(Vnode(), mapEnd, ~0UL, vecs, &vecCount); + if (status == FSSH_B_OK || status == FSSH_B_BUFFER_OVERFLOW) + status = _Add(vecs, vecCount, mapEnd); + } + + return status; } -extern "C" void -fssh_file_map_invalidate(void *_map, fssh_off_t offset, fssh_off_t size) +fssh_status_t +FileMap::SetMode(uint32_t mode) { - if (_map == NULL) - return; + if (mode != FSSH_FILE_MAP_CACHE_ALL + && mode != FSSH_FILE_MAP_CACHE_ON_DEMAND) + return FSSH_B_BAD_VALUE; - // TODO: honour offset/size parameters - file_map *map = (file_map *)_map; - map->Free(); + MutexLocker _(fLock); + + if (mode == FSSH_FILE_MAP_CACHE_ALL && fCacheAll + || mode == FSSH_FILE_MAP_CACHE_ON_DEMAND && !fCacheAll) + return FSSH_B_OK; + + if (mode == FSSH_FILE_MAP_CACHE_ALL) { + fssh_status_t status = _Cache(0, fSize); + if (status != FSSH_B_OK) + return status; + + fCacheAll = true; + } else + fCacheAll = false; + + return FSSH_B_OK; } -extern "C" fssh_status_t -fssh_file_map_translate(void *_map, fssh_off_t offset, fssh_size_t size, - fssh_file_io_vec *vecs, fssh_size_t *_count) +fssh_status_t +FileMap::Translate(fssh_off_t offset, fssh_size_t size, fssh_file_io_vec* vecs, + fssh_size_t* _count) { - if (_map == NULL) - return FSSH_B_BAD_VALUE; + MutexLocker _(fLock); - file_map &map = *(file_map *)_map; fssh_size_t maxVecs = *_count; - fssh_status_t status = FSSH_B_OK; - if (offset >= map.size) { + if (offset >= Size()) { *_count = 0; return FSSH_B_OK; } - if (offset + size > map.size) - size = map.size - offset; + if (offset + size > fSize) + size = fSize - offset; - if (map.count == 0) { - // we don't yet have the map of this file, so let's grab it - // (ordered by offset, so that we can do a binary search on them) - fssh_size_t vecCount = maxVecs; - fssh_off_t mapOffset = 0; + // First, we need to make sure that we have already cached all file + // extents needed for this request. - while (true) { - status = vfs_get_file_map(map.vnode, mapOffset, ~0UL, vecs, - &vecCount); - if (status < FSSH_B_OK && status != FSSH_B_BUFFER_OVERFLOW) - return status; - - fssh_status_t addStatus = map.Add(vecs, vecCount, mapOffset); - if (addStatus != FSSH_B_OK) { - // only clobber the status in case of failure - status = addStatus; - } - - if (status != FSSH_B_BUFFER_OVERFLOW) - break; - - // when we are here, the map has been stored in the array, and - // the array size was still too small to cover the whole file - vecCount = maxVecs; - } - } - - if (status != FSSH_B_OK) { - // We must invalidate the (part of the) map we already - // have, as we cannot know if it's complete or not - map.Free(); + fssh_status_t status = _Cache(offset, size); + if (status != FSSH_B_OK) return status; - } - // We now have cached the map of this file, we now need to - // translate it for the requested access. + // We now have cached the map of this file as far as we need it, now + // we need to translate it for the requested access. uint32_t index; - file_extent *fileExtent = find_file_extent(map, offset, &index); - if (fileExtent == NULL) { - // access outside file bounds? But that's not our problem - *_count = 0; - return FSSH_B_OK; - } + file_extent* fileExtent = _FindExtent(offset, &index); offset -= fileExtent->offset; vecs[0].offset = fileExtent->disk.offset + offset; vecs[0].length = fileExtent->disk.length - offset; - if (vecs[0].length >= size || index >= map.count - 1) { + if (vecs[0].length >= size) { + if (vecs[0].length > size) + vecs[0].length = size; *_count = 1; return FSSH_B_OK; } @@ -313,25 +394,111 @@ // copy the rest of the vecs size -= vecs[0].length; + uint32_t vecIndex = 1; - for (index = 1; index < map.count;) { + while (true) { fileExtent++; - vecs[index] = fileExtent->disk; - index++; + vecs[vecIndex++] = fileExtent->disk; - if (size <= fileExtent->disk.length) + if (size <= fileExtent->disk.length) { + if (size < fileExtent->disk.length) + vecs[vecIndex - 1].length = size; break; + } - if (index >= maxVecs) { - *_count = index; + if (vecIndex >= maxVecs) { + *_count = vecIndex; return FSSH_B_BUFFER_OVERFLOW; } size -= fileExtent->disk.length; } - *_count = index; + *_count = vecIndex; return FSSH_B_OK; } + +} // namespace FSShell + + +// #pragma mark - public FS API + + +extern "C" void* +fssh_file_map_create(fssh_mount_id mountID, fssh_vnode_id vnodeID, + fssh_off_t size) +{ + TRACE(("file_map_create(mountID = %ld, vnodeID = %Ld, size = %Ld)\n", + mountID, vnodeID, size)); + + // Get the vnode for the object + // (note, this does not grab a reference to the node) + void* vnode; + if (vfs_lookup_vnode(mountID, vnodeID, &vnode) != FSSH_B_OK) + return NULL; + + return new(std::nothrow) FileMap(vnode, size); +} + + +extern "C" void +fssh_file_map_delete(void* _map) +{ + FileMap* map = (FileMap*)_map; + if (map == NULL) + return; + + TRACE(("file_map_delete(map = %p)\n", map)); + delete map; +} + + +extern "C" void +fssh_file_map_set_size(void* _map, fssh_off_t size) +{ + FileMap* map = (FileMap*)_map; + if (map == NULL) + return; + + map->SetSize(size); +} + + +extern "C" void +fssh_file_map_invalidate(void* _map, fssh_off_t offset, fssh_off_t size) +{ + FileMap* map = (FileMap*)_map; + if (map == NULL) + return; + + map->Invalidate(offset, size); +} + + +extern "C" fssh_status_t +fssh_file_map_set_mode(void* _map, uint32_t mode) +{ + FileMap* map = (FileMap*)_map; + if (map == NULL) + return FSSH_B_BAD_VALUE; + + return map->SetMode(mode); +} + + +extern "C" fssh_status_t +fssh_file_map_translate(void* _map, fssh_off_t offset, fssh_size_t size, + fssh_file_io_vec* vecs, fssh_size_t* _count) +{ + TRACE(("file_map_translate(map %p, offset %Ld, size %ld)\n", + _map, offset, size)); + + FileMap* map = (FileMap*)_map; + if (map == NULL) + return FSSH_B_BAD_VALUE; + + return map->Translate(offset, size, vecs, _count); +} + From stippi at mail.berlios.de Mon Aug 4 13:30:31 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 13:30:31 +0200 Subject: [Haiku-commits] r26786 - haiku/trunk/src/apps/text_search Message-ID: <200808041130.m74BUVqm004714@sheep.berlios.de> Author: stippi Date: 2008-08-04 13:30:21 +0200 (Mon, 04 Aug 2008) New Revision: 26786 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26786&view=rev Added: haiku/trunk/src/apps/text_search/FolderIterator.cpp haiku/trunk/src/apps/text_search/FolderIterator.h Modified: haiku/trunk/src/apps/text_search/FileIterator.cpp haiku/trunk/src/apps/text_search/FileIterator.h haiku/trunk/src/apps/text_search/GrepWindow.cpp haiku/trunk/src/apps/text_search/Grepper.cpp haiku/trunk/src/apps/text_search/Grepper.h haiku/trunk/src/apps/text_search/Jamfile haiku/trunk/src/apps/text_search/Model.cpp haiku/trunk/src/apps/text_search/Model.h Log: Refactoring * FileIterator is now a mostly abstract interface * FolderIterator is the currently only implementation (there could be MessageIterator for an even better separation, which would read the top level search folders from the BMessage with the selected poses, but it would mostly use the same code for traversing the subfolders anyways so I left that for the time being.) * The Grepper and FolderIterator now copy the current settings from the Model at instantiation. Since they run in a separate thread and the Model may actually be changed from the Window thread, I think this is just a cleaner and more safe solution. * Cleanup here and there. Modified: haiku/trunk/src/apps/text_search/FileIterator.cpp =================================================================== --- haiku/trunk/src/apps/text_search/FileIterator.cpp 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/FileIterator.cpp 2008-08-04 11:30:21 UTC (rev 26786) @@ -23,200 +23,49 @@ #include "FileIterator.h" -#include -#include -#include #include -#include +#include #include #include -#include "Model.h" -using std::nothrow; - -// TODO: stippi: Check if this is a the best place to maintain a global -// list of files and folders for node monitoring. It should probably monitor -// every file that was grepped, as well as every visited (sub) folder. -// For the moment I don't know the life cycle of the FileIterator object. - - -FileIterator::FileIterator(Model* model) - : fDirectories(10), - fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), - fCurrentRef(0), - fModel(model) +FileIterator::FileIterator() { - if (!fCurrentDir || !fDirectories.AddItem(fCurrentDir)) { - // init error - delete fCurrentDir; - fCurrentDir = NULL; - } } FileIterator::~FileIterator() { - for (int32 i = fDirectories.CountItems() - 1; i >= 0; i--) - delete (BDirectory*)fDirectories.ItemAt(i); } bool -FileIterator::IsValid() const +FileIterator::_ExamineFile(BEntry& entry, char* buffer, bool textFilesOnly) { - return fCurrentDir != NULL; -} - - -bool -FileIterator::GetNextName(char* buffer) -{ - BEntry entry; - struct stat fileStat; - - while (true) { - // Traverse the directory to get a new BEntry. - // _GetNextEntry returns false if there are no - // more entries, and we exit the loop. - - if (!_GetNextEntry(entry)) - return false; - - // If the entry is a subdir, then add it to the - // list of directories and continue the loop. - // If the entry is a file and we can grep it - // (i.e. it is a text file), then we're done - // here. Otherwise, continue with the next entry. - - if (entry.GetStat(&fileStat) == B_OK) { - if (S_ISDIR(fileStat.st_mode)) { - // subdir - _ExamineSubdir(entry); - } else { - // file or a (non-traversed) symbolic link - if (_ExamineFile(entry, buffer)) - return true; - } - } - } -} - - -// #pragma mark - private - - -bool -FileIterator::_GetNextEntry(BEntry& entry) -{ - if (fDirectories.CountItems() == 1) - return _GetTopEntry(entry); - else - return _GetSubEntry(entry); -} - - -bool -FileIterator::_GetTopEntry(BEntry& entry) -{ - // If the user selected one or more files, we must look - // at the "refs" inside the message that was passed into - // our add-on's process_refs(). If the user didn't select - // any files, we will simply read all the entries from the - // current working directory. - - entry_ref fileRef; - - if (fModel->fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) { - entry.SetTo(&fileRef, fModel->fRecurseLinks); - ++fCurrentRef; - return true; - } else if (fCurrentRef > 0) { - // when we get here, we have processed - // all the refs from the message - return false; - } else if (fCurrentDir != NULL) { - // examine the whole directory - return fCurrentDir->GetNextEntry(&entry, - fModel->fRecurseLinks) == B_OK; - } - - return false; -} - - -bool -FileIterator::_GetSubEntry(BEntry& entry) -{ - if (!fCurrentDir) - return false; - - if (fCurrentDir->GetNextEntry(&entry, fModel->fRecurseLinks) == B_OK) - return true; - - // If we get here, there are no more entries in - // this subdir, so return to the parent directory. - - fDirectories.RemoveItem(fCurrentDir); - delete fCurrentDir; - fCurrentDir = (BDirectory*)fDirectories.LastItem(); - - return _GetNextEntry(entry); -} - - -void -FileIterator::_ExamineSubdir(BEntry& entry) -{ - if (!fModel->fRecurseDirs) - return; - - if (fModel->fSkipDotDirs) { - char nameBuf[B_FILE_NAME_LENGTH]; - if (entry.GetName(nameBuf) == B_OK) { - if (*nameBuf == '.') - return; - } - } - - BDirectory* dir = new (nothrow) BDirectory(&entry); - if (dir == NULL || dir->InitCheck() != B_OK - || !fDirectories.AddItem(dir)) { - // clean up - delete dir; - return; - } - - fCurrentDir = dir; -} - - -bool -FileIterator::_ExamineFile(BEntry& entry, char* buffer) -{ BPath path; if (entry.GetPath(&path) != B_OK) return false; strcpy(buffer, path.Path()); - if (!fModel->fTextOnly) + if (!textFilesOnly) return true; BNode node(&entry); BNodeInfo nodeInfo(&node); char mimeTypeString[B_MIME_TYPE_LENGTH]; - if (nodeInfo.GetType(mimeTypeString) == B_OK) { - BMimeType mimeType(mimeTypeString); - BMimeType superType; + if (nodeInfo.GetType(mimeTypeString) != B_OK) + return false; - if (mimeType.GetSupertype(&superType) == B_OK) { - if (strcmp("text", superType.Type()) == 0 - || strcmp("message", superType.Type()) == 0) { - return true; - } + BMimeType mimeType(mimeTypeString); + BMimeType superType; + + if (mimeType.GetSupertype(&superType) == B_OK) { + if (strcmp("text", superType.Type()) == 0 + || strcmp("message", superType.Type()) == 0) { + return true; } } Modified: haiku/trunk/src/apps/text_search/FileIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-04 11:30:21 UTC (rev 26786) @@ -23,54 +23,24 @@ #ifndef FILE_ITERATOR_H #define FILE_ITERATOR_H -#include - class BEntry; -class BDirectory; -class Model; -// TODO: split into Folder and MessageFileIterator (_GetTopEntry) - // Provides an interface to retrieve the next file that should be grepped // for the search string. class FileIterator { public: - FileIterator(Model* model); + FileIterator(); virtual ~FileIterator(); - virtual bool IsValid() const; + virtual bool IsValid() const = 0; // Returns the full path name of the next file. - virtual bool GetNextName(char* buffer); + virtual bool GetNextName(char* buffer) = 0; -private: - // Looks for the next entry. - bool _GetNextEntry(BEntry& entry); - - // Looks for the next entry in the top-level dir. - bool _GetTopEntry(BEntry& entry); - - // Looks for the next entry in a subdir. - bool _GetSubEntry(BEntry& entry); - - // Determines whether we can add a subdir. - void _ExamineSubdir(BEntry& entry); - +protected: // Determines whether we can grep a file. - bool _ExamineFile(BEntry& entry, char* buffer); - -private: - // Contains pointers to BDirectory objects. - BList fDirectories; - - // The directory we are currently looking at. - BDirectory* fCurrentDir; - - // The ref number we are currently looking at. - int32 fCurrentRef; - - // The directory or files to grep on. - Model* fModel; + bool _ExamineFile(BEntry& entry, char* buffer, + bool textFilesOnly); }; #endif // FILE_ITERATOR_H Added: haiku/trunk/src/apps/text_search/FolderIterator.cpp =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.cpp 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/FolderIterator.cpp 2008-08-04 11:30:21 UTC (rev 26786) @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 "FolderIterator.h" + +#include +#include +#include +#include + +#include + +#include "Model.h" + +using std::nothrow; + +// TODO: stippi: Check if this is a the best place to maintain a global +// list of files and folders for node monitoring. It should probably monitor +// every file that was grepped, as well as every visited (sub) folder. +// For the moment I don't know the life cycle of the FolderIterator object. + + +FolderIterator::FolderIterator(const Model* model) + : FileIterator(), + fDirectories(10), + fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), + fCurrentRef(0), + + fSelectedFiles(model->fSelectedFiles), + + fRecurseDirs(model->fRecurseDirs), + fRecurseLinks(model->fRecurseLinks), + fSkipDotDirs(model->fSkipDotDirs), + fTextOnly(model->fTextOnly) +{ + if (!fCurrentDir || !fDirectories.AddItem(fCurrentDir)) { + // init error + delete fCurrentDir; + fCurrentDir = NULL; + } +} + + +FolderIterator::~FolderIterator() +{ + for (int32 i = fDirectories.CountItems() - 1; i >= 0; i--) + delete (BDirectory*)fDirectories.ItemAt(i); +} + + +bool +FolderIterator::IsValid() const +{ + return fCurrentDir != NULL; +} + + +bool +FolderIterator::GetNextName(char* buffer) +{ + BEntry entry; + struct stat fileStat; + + while (true) { + // Traverse the directory to get a new BEntry. + // _GetNextEntry returns false if there are no + // more entries, and we exit the loop. + + if (!_GetNextEntry(entry)) + return false; + + // If the entry is a subdir, then add it to the + // list of directories and continue the loop. + // If the entry is a file and we can grep it + // (i.e. it is a text file), then we're done + // here. Otherwise, continue with the next entry. + + if (entry.GetStat(&fileStat) == B_OK) { + if (S_ISDIR(fileStat.st_mode)) { + // subdir + _ExamineSubdir(entry); + } else { + // file or a (non-traversed) symbolic link + if (_ExamineFile(entry, buffer, fTextOnly)) + return true; + } + } + } +} + + +// #pragma mark - private + + +bool +FolderIterator::_GetNextEntry(BEntry& entry) +{ + if (fDirectories.CountItems() == 1) + return _GetTopEntry(entry); + else + return _GetSubEntry(entry); +} + + +bool +FolderIterator::_GetTopEntry(BEntry& entry) +{ + // If the user selected one or more files, we must look + // at the "refs" inside the message that was passed into + // our add-on's process_refs(). If the user didn't select + // any files, we will simply read all the entries from the + // current working directory. + + entry_ref fileRef; + + if (fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) { + entry.SetTo(&fileRef, fRecurseLinks); + ++fCurrentRef; + return true; + } else if (fCurrentRef > 0) { + // when we get here, we have processed + // all the refs from the message + return false; + } else if (fCurrentDir != NULL) { + // examine the whole directory + return fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK; + } + + return false; +} + + +bool +FolderIterator::_GetSubEntry(BEntry& entry) +{ + if (!fCurrentDir) + return false; + + if (fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK) + return true; + + // If we get here, there are no more entries in + // this subdir, so return to the parent directory. + + fDirectories.RemoveItem(fCurrentDir); + delete fCurrentDir; + fCurrentDir = (BDirectory*)fDirectories.LastItem(); + + return _GetNextEntry(entry); +} + + +void +FolderIterator::_ExamineSubdir(BEntry& entry) +{ + if (!fRecurseDirs) + return; + + if (fSkipDotDirs) { + char nameBuf[B_FILE_NAME_LENGTH]; + if (entry.GetName(nameBuf) == B_OK) { + if (*nameBuf == '.') + return; + } + } + + BDirectory* dir = new (nothrow) BDirectory(&entry); + if (dir == NULL || dir->InitCheck() != B_OK || !fDirectories.AddItem(dir)) { + // clean up + delete dir; + return; + } + + fCurrentDir = dir; +} Added: haiku/trunk/src/apps/text_search/FolderIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.h 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/FolderIterator.h 2008-08-04 11:30:21 UTC (rev 26786) @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 FOLDER_ITERATOR_H +#define FOLDER_ITERATOR_H + +#include +#include + +#include "FileIterator.h" + +class BEntry; +class BDirectory; +class Model; + +// TODO: split into Folder and MessageFileIterator (_GetTopEntry) +// This code either has an original folder to start iterating from, +// or it uses the refs in the message that contains the selected poses +// from the Tracker window that invoked us. But I think if folders are +// among those poses, it will then use the same code for examining sub +// folders. + +// Provides an interface to retrieve the next file that should be grepped +// for the search string. +class FolderIterator : public FileIterator { +public: + FolderIterator(const Model* model); + virtual ~FolderIterator(); + + virtual bool IsValid() const; + + // Returns the full path name of the next file. + virtual bool GetNextName(char* buffer); + +private: + // Looks for the next entry. + bool _GetNextEntry(BEntry& entry); + + // Looks for the next entry in the top-level dir. + bool _GetTopEntry(BEntry& entry); + + // Looks for the next entry in a subdir. + bool _GetSubEntry(BEntry& entry); + + // Determines whether we can add a subdir. + void _ExamineSubdir(BEntry& entry); + +private: + // Contains pointers to BDirectory objects. + BList fDirectories; + + // The directory we are currently looking at. + BDirectory* fCurrentDir; + + // The ref number we are currently looking at. + int32 fCurrentRef; + + // The current settings + BMessage fSelectedFiles; + + bool fRecurseDirs : 1; + bool fRecurseLinks : 1; + bool fSkipDotDirs : 1; + bool fTextOnly : 1; +}; + +#endif // FOLDER_ITERATOR_H Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 11:30:21 UTC (rev 26786) @@ -38,7 +38,7 @@ #include #include -#include "FileIterator.h" +#include "FolderIterator.h" #include "GlobalDefs.h" #include "Grepper.h" #include "Translation.h" @@ -98,7 +98,6 @@ fModel->fDirectory = directory; fModel->fSelectedFiles = *message; - fModel->fTarget = this; _SetWindowTitle(); _CreateMenus(); @@ -706,9 +705,9 @@ fOldPattern = fSearchText->Text(); - FileIterator* iterator = new (nothrow) FileIterator(fModel); + FileIterator* iterator = new (nothrow) FolderIterator(fModel); fGrepper = new (nothrow) Grepper(fOldPattern.String(), fModel, - iterator); + this, iterator); if (fGrepper != NULL && fGrepper->IsValid()) fGrepper->Start(); else { Modified: haiku/trunk/src/apps/text_search/Grepper.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-04 11:30:21 UTC (rev 26786) @@ -34,6 +34,7 @@ #include #include "FileIterator.h" +#include "Model.h" using std::nothrow; @@ -90,16 +91,20 @@ } -Grepper::Grepper(const char* pattern, Model* model, FileIterator* iterator) +Grepper::Grepper(const char* pattern, const Model* model, + const BHandler* target, FileIterator* iterator) : fPattern(NULL), - fModel(model), + fTarget(target), + fEscapeText(model->fEscapeText), + fCaseSensitive(model->fCaseSensitive), + fEncoding(model->fEncoding), + fIterator(iterator), fThreadId(-1), fMustQuit(false) { - if (fModel->fEncoding) { - char *src = strdup_from_utf8(fModel->fEncoding, pattern, - strlen(pattern)); + if (fEncoding > 0) { + char* src = strdup_from_utf8(fEncoding, pattern, strlen(pattern)); _SetPattern(src); free(src); } else @@ -120,7 +125,7 @@ { if (fIterator == NULL || !fIterator->IsValid()) return false; - return fPattern != NULL && fModel != NULL; + return fPattern != NULL; } @@ -178,7 +183,7 @@ message.MakeEmpty(); message.what = MSG_REPORT_FILE_NAME; message.AddString("filename", fileName); - fModel->fTarget->PostMessage(&message); + fTarget.SendMessage(&message); message.MakeEmpty(); message.what = MSG_REPORT_RESULT; @@ -196,13 +201,12 @@ message.MakeEmpty(); message.what = MSG_REPORT_ERROR; message.AddString("error", tempString); - fModel->fTarget->PostMessage(&message); + fTarget.SendMessage(&message); continue; } sprintf(command, "grep -hn %s %s \"%s\" > \"%s\"", - fModel->fCaseSensitive ? "" : "-i", fPattern, fileName, - tempFile.Path()); + fCaseSensitive ? "" : "-i", fPattern, fileName, tempFile.Path()); int res = system(command); @@ -211,9 +215,9 @@ if (results != NULL) { while (fgets(tempString, B_PATH_NAME_LENGTH, results) != 0) { - if (fModel->fEncoding) { - char *tempdup = strdup_to_utf8(fModel->fEncoding, - tempString, strlen(tempString)); + if (fEncoding > 0) { + char* tempdup = strdup_to_utf8(fEncoding, tempString, + strlen(tempString)); message.AddString("text", tempdup); free(tempdup); } else @@ -221,7 +225,7 @@ } if (message.HasString("text")) - fModel->fTarget->PostMessage(&message); + fTarget.SendMessage(&message); fclose(results); continue; @@ -233,7 +237,7 @@ message.MakeEmpty(); message.what = MSG_REPORT_ERROR; message.AddString("error", tempString); - fModel->fTarget->PostMessage(&message); + fTarget.SendMessage(&message); } // We wait with removing the temporary file until after the @@ -244,7 +248,7 @@ message.MakeEmpty(); message.what = MSG_SEARCH_FINISHED; - fModel->fTarget->PostMessage(&message); + fTarget.SendMessage(&message); return 0; } @@ -256,7 +260,7 @@ if (src == NULL) return; - if (!fModel->fEscapeText) { + if (!fEscapeText) { fPattern = strdup(src); return; } Modified: haiku/trunk/src/apps/text_search/Grepper.h =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.h 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/Grepper.h 2008-08-04 11:30:21 UTC (rev 26786) @@ -22,14 +22,16 @@ #ifndef GREPPER_H #define GREPPER_H -#include "Model.h" +#include class FileIterator; +class Model; // Executes "grep" in a background thread. class Grepper { public: - Grepper(const char* pattern, Model* model, + Grepper(const char* pattern, const Model* model, + const BHandler* target, FileIterator* iterator); virtual ~Grepper(); @@ -56,8 +58,11 @@ // The (escaped) search pattern. char* fPattern; - // The directory or files to grep on. - Model* fModel; + // The settings from the model. + BMessenger fTarget; + bool fEscapeText : 1; + bool fCaseSensitive : 1; + uint32 fEncoding; // The supplier of files to grep FileIterator* fIterator; Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 11:30:21 UTC (rev 26786) @@ -4,6 +4,7 @@ Application TextSearch : FileIterator.cpp + FolderIterator.cpp GrepApp.cpp GrepListView.cpp Grepper.cpp Modified: haiku/trunk/src/apps/text_search/Model.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Model.cpp 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/Model.cpp 2008-08-04 11:30:21 UTC (rev 26786) @@ -53,7 +53,6 @@ fFrame(100, 100, 500, 400), - fTarget(NULL), fState(STATE_IDLE), fFilePanelPath(""), Modified: haiku/trunk/src/apps/text_search/Model.h =================================================================== --- haiku/trunk/src/apps/text_search/Model.h 2008-08-04 08:28:17 UTC (rev 26785) +++ haiku/trunk/src/apps/text_search/Model.h 2008-08-04 11:30:21 UTC (rev 26786) @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -118,9 +117,6 @@ // The dimensions of the window. BRect fFrame; - // The looper that will receive notifications. - BLooper* fTarget; - // What are we doing. state_t fState; From stippi at mail.berlios.de Mon Aug 4 14:53:56 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 14:53:56 +0200 Subject: [Haiku-commits] r26787 - haiku/trunk/src/apps/text_search Message-ID: <200808041253.m74CruQp028460@sheep.berlios.de> Author: stippi Date: 2008-08-04 14:53:55 +0200 (Mon, 04 Aug 2008) New Revision: 26787 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26787&view=rev Modified: haiku/trunk/src/apps/text_search/Model.cpp haiku/trunk/src/apps/text_search/Model.h Log: * Refactoring, added const specifiers to helper methods that don't modify the object. * Improved check that enforces search pattern history limit to also handle the case when the limit is changed in the source. Modified: haiku/trunk/src/apps/text_search/Model.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Model.cpp 2008-08-04 11:30:21 UTC (rev 26786) +++ haiku/trunk/src/apps/text_search/Model.cpp 2008-08-04 12:53:55 UTC (rev 26787) @@ -60,8 +60,7 @@ fEncoding(0) { BPath path; - status_t status = find_directory(B_USER_DIRECTORY, &path); - if (status == B_OK) + if (find_directory(B_USER_DIRECTORY, &path) == B_OK) fFilePanelPath = path.Path(); else fFilePanelPath = "/boot/home"; @@ -72,9 +71,7 @@ Model::LoadPrefs() { BFile file; - status_t status = _OpenFile(&file, PREFS_FILE, B_READ_ONLY, - B_USER_SETTINGS_DIRECTORY, NULL); - + status_t status = _OpenFile(&file, PREFS_FILE); if (status != B_OK) return status; @@ -139,9 +136,8 @@ Model::SavePrefs() { BFile file; - status_t status = _OpenFile(&file, PREFS_FILE, - B_CREATE_FILE | B_WRITE_ONLY, B_USER_SETTINGS_DIRECTORY, NULL); - + status_t status = _OpenFile(&file, PREFS_FILE, + B_CREATE_FILE | B_WRITE_ONLY); if (status != B_OK) return status; @@ -193,30 +189,31 @@ void Model::AddToHistory(const char* text) { - BList* items = _LoadHistory(); - if (items == NULL) + BList items; + if (!_LoadHistory(items)) return; BString* string = new (nothrow) BString(text); - if (string == NULL || !items->AddItem(string)) { + if (string == NULL || !items.AddItem(string)) { delete string; + _FreeHistory(items); return; } - int32 count = items->CountItems() - 1; + int32 count = items.CountItems() - 1; // don't check last item, since that's the one we just added for (int32 t = 0; t < count; ++t) { // If the same text is already in the list, // then remove it first. Case-sensitive. - BString* string = static_cast(items->ItemAt(t)); + BString* string = static_cast(items.ItemAt(t)); if (*string == text) { - delete static_cast(items->RemoveItem(t)); + delete static_cast(items.RemoveItem(t)); break; } } - if (items->CountItems() == HISTORY_LIMIT) - delete static_cast(items->RemoveItem(0L)); + while (items.CountItems() >= HISTORY_LIMIT) + delete static_cast(items.RemoveItem(0L)); _SaveHistory(items); _FreeHistory(items); @@ -224,14 +221,14 @@ void -Model::FillHistoryMenu(BMenu* menu) +Model::FillHistoryMenu(BMenu* menu) const { - BList* items = _LoadHistory(); - if (items == NULL) + BList items; + if (!_LoadHistory(items)) return; - for (int32 t = items->CountItems() - 1; t >= 0; --t) { - BString* item = static_cast(items->ItemAt(t)); + for (int32 t = items.CountItems() - 1; t >= 0; --t) { + BString* item = static_cast(items.ItemAtFast(t)); BMessage* message = new BMessage(MSG_SELECT_HISTORY); message->AddString("text", item->String()); menu->AddItem(new BMenuItem(item->String(), message)); @@ -244,46 +241,40 @@ // #pragma mark - private -BList* -Model::_LoadHistory() +bool +Model::_LoadHistory(BList& items) const { - BList* items = new (nothrow) BList(); - if (items == NULL) - return NULL; - BFile file; - status_t status = _OpenFile(&file, PREFS_FILE, B_READ_ONLY, - B_USER_SETTINGS_DIRECTORY, NULL); - + status_t status = _OpenFile(&file, PREFS_FILE); if (status != B_OK) - return items; + return false; status = file.Lock(); if (status != B_OK) - return items; + return false; BMessage message; status = message.Unflatten(&file); if (status != B_OK) - return items; + return false; file.Unlock(); BString string; for (int32 x = 0; message.FindString("string", x, &string) == B_OK; x++) { BString* copy = new (nothrow) BString(string); - if (copy == NULL || !items->AddItem(copy)) { + if (copy == NULL || !items.AddItem(copy)) { delete copy; break; } } - return items; + return true; } status_t -Model::_SaveHistory(BList* items) +Model::_SaveHistory(const BList& items) const { BFile file; status_t status = _OpenFile(&file, PREFS_FILE, @@ -298,10 +289,9 @@ return status; BMessage message; - for (int32 x = 0; ; x++) { - BString* string = static_cast(items->ItemAt(x)); - if (string == NULL) - break; + int32 count = items.CountItems(); + for (int32 i = 0; i < count; i++) { + BString* string = static_cast(items.ItemAtFast(i)); if (message.AddString("string", string->String()) != B_OK) break; @@ -317,18 +307,16 @@ void -Model::_FreeHistory(BList* items) +Model::_FreeHistory(const BList& items) const { - for (int32 t = items->CountItems() - 1; t >= 0; --t) - delete static_cast((items->RemoveItem(t))); - - delete items; + for (int32 t = items.CountItems() - 1; t >= 0; --t) + delete static_cast((items.ItemAtFast(t))); } status_t Model::_OpenFile(BFile* file, const char* name, uint32 openMode, - directory_which which, BVolume* volume) + directory_which which, BVolume* volume) const { if (file == NULL) return B_BAD_VALUE; Modified: haiku/trunk/src/apps/text_search/Model.h =================================================================== --- haiku/trunk/src/apps/text_search/Model.h 2008-08-04 11:30:21 UTC (rev 26786) +++ haiku/trunk/src/apps/text_search/Model.h 2008-08-04 12:53:55 UTC (rev 26787) @@ -81,7 +81,7 @@ status_t SavePrefs(); void AddToHistory(const char* text); - void FillHistoryMenu(BMenu* menu); + void FillHistoryMenu(BMenu* menu) const; public: // The directory we were invoked from. @@ -127,14 +127,14 @@ uint32 fEncoding; private: - BList* _LoadHistory(); - status_t _SaveHistory(BList* items); - void _FreeHistory(BList* items); + bool _LoadHistory(BList& items) const; + status_t _SaveHistory(const BList& items) const; + void _FreeHistory(const BList& items) const; status_t _OpenFile(BFile* file, const char* name, uint32 openMode = B_READ_ONLY, directory_which which = B_USER_SETTINGS_DIRECTORY, - BVolume* volume = NULL); + BVolume* volume = NULL) const; }; #endif // MODEL_H From stippi at mail.berlios.de Mon Aug 4 15:04:46 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 15:04:46 +0200 Subject: [Haiku-commits] r26788 - in haiku/trunk: headers/private/storage src/kits/storage Message-ID: <200808041304.m74D4kio029045@sheep.berlios.de> Author: stippi Date: 2008-08-04 15:04:45 +0200 (Mon, 04 Aug 2008) New Revision: 26788 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26788&view=rev Modified: haiku/trunk/headers/private/storage/PathMonitor.h haiku/trunk/src/kits/storage/PathMonitor.cpp Log: * Use new header layout in PathMonitor.h * Honor 80 char/line limit in PathMonitor.cpp Modified: haiku/trunk/headers/private/storage/PathMonitor.h =================================================================== --- haiku/trunk/headers/private/storage/PathMonitor.h 2008-08-04 12:53:55 UTC (rev 26787) +++ haiku/trunk/headers/private/storage/PathMonitor.h 2008-08-04 13:04:45 UTC (rev 26788) @@ -18,17 +18,19 @@ namespace BPrivate { class BPathMonitor { - public: - static status_t StartWatching(const char* path, uint32 flags, BMessenger target); +public: + static status_t StartWatching(const char* path, uint32 flags, + BMessenger target); - static status_t StopWatching(const char* path, BMessenger target); - static status_t StopWatching(BMessenger target); + static status_t StopWatching(const char* path, + BMessenger target); + static status_t StopWatching(BMessenger target); - private: - BPathMonitor(); - ~BPathMonitor(); +private: + BPathMonitor(); + ~BPathMonitor(); - static status_t _InitIfNeeded(); + static status_t _InitIfNeeded(); }; } // namespace BPrivate Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 12:53:55 UTC (rev 26787) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 13:04:45 UTC (rev 26788) @@ -189,7 +189,8 @@ fStatus = _AddDirectory(nodeRef); - // TODO: work-around for existing files (should not watch the directory in this case) + // TODO: work-around for existing files (should not watch the directory in + // this case) BEntry entry(path); if (entry.Exists() && !entry.IsDirectory()) _AddFile(entry); @@ -223,7 +224,8 @@ printf("WATCHING DIRECTORIES:\n"); DirectorySet::iterator i = fDirectories.begin(); for (; i != fDirectories.end(); i++) { - printf(" %ld:%Ld (%s)\n", i->node.device, i->node.node, i->contained ? "contained" : "-"); + printf(" %ld:%Ld (%s)\n", i->node.device, i->node.node, i->contained + ? "contained" : "-"); } printf("WATCHING FILES:\n"); @@ -539,7 +541,8 @@ bool -PathHandler::_HasDirectory(const node_ref& nodeRef, bool* _contained /* = NULL */) const +PathHandler::_HasDirectory(const node_ref& nodeRef, + bool* _contained /* = NULL */) const { watched_directory directory; directory.node = nodeRef; From axeld at mail.berlios.de Mon Aug 4 15:09:41 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 15:09:41 +0200 Subject: [Haiku-commits] r26789 - haiku/trunk/src/system/kernel Message-ID: <200808041309.m74D9fXs029266@sheep.berlios.de> Author: axeld Date: 2008-08-04 15:09:40 +0200 (Mon, 04 Aug 2008) New Revision: 26789 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26789&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: * We're now using an anonymous condition variable for the team's dead children instead of publishing it. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-08-04 13:04:45 UTC (rev 26788) +++ haiku/trunk/src/system/kernel/team.cpp 2008-08-04 13:09:40 UTC (rev 26789) @@ -769,7 +769,7 @@ return NULL; // publish dead/stopped/continued children condition vars - team->dead_children->condition_variable.Publish(team->dead_children, + team->dead_children->condition_variable.Init(team->dead_children, "team children"); // keep all allocated structures @@ -786,8 +786,6 @@ static void delete_team_struct(struct team *team) { - team->dead_children->condition_variable.Unpublish(); - while (death_entry* threadDeathEntry = (death_entry*)list_remove_head_item( &team->dead_threads)) { free(threadDeathEntry); @@ -1756,7 +1754,7 @@ ConditionVariableEntry deadWaitEntry; if (status == B_WOULD_BLOCK && (flags & WNOHANG) == 0) - deadWaitEntry.Add(team->dead_children); + team->dead_children->condition_variable.Add(&deadWaitEntry); locker.Unlock(); From axeld at mail.berlios.de Mon Aug 4 15:26:14 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 15:26:14 +0200 Subject: [Haiku-commits] r26790 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200808041326.m74DQEfV030665@sheep.berlios.de> Author: axeld Date: 2008-08-04 15:26:13 +0200 (Mon, 04 Aug 2008) New Revision: 26790 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26790&view=rev Modified: haiku/trunk/headers/private/kernel/kmodule.h haiku/trunk/src/system/kernel/main.cpp haiku/trunk/src/system/kernel/module.cpp Log: * Shuffled initializers around: the team, ELF, and module initializers come now a lot earlier. * That makes it now possible to use modules pretty early in the kernel (like before timer_init(), or int_init_post_vm()). Modified: haiku/trunk/headers/private/kernel/kmodule.h =================================================================== --- haiku/trunk/headers/private/kernel/kmodule.h 2008-08-04 13:09:40 UTC (rev 26789) +++ haiku/trunk/headers/private/kernel/kmodule.h 2008-08-04 13:26:13 UTC (rev 26790) @@ -30,6 +30,7 @@ extern status_t load_module(const char *path, module_info ***_modules); extern status_t module_init(struct kernel_args *args); +extern status_t module_init_post_threads(void); #ifdef __cplusplus } Modified: haiku/trunk/src/system/kernel/main.cpp =================================================================== --- haiku/trunk/src/system/kernel/main.cpp 2008-08-04 13:09:40 UTC (rev 26789) +++ haiku/trunk/src/system/kernel/main.cpp 2008-08-04 13:26:13 UTC (rev 26790) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2002-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -129,6 +129,12 @@ boot_item_init(); driver_settings_init(&sKernelArgs); debug_init_post_vm(&sKernelArgs); + TRACE("init teams\n"); + team_init(&sKernelArgs); + TRACE("init ELF loader\n"); + elf_init(&sKernelArgs); + TRACE("init modules\n"); + module_init(&sKernelArgs); int_init_post_vm(&sKernelArgs); cpu_init_post_vm(&sKernelArgs); commpage_init(); @@ -154,8 +160,6 @@ smp_init_post_generic_syscalls(); TRACE("init cbuf\n"); cbuf_init(); - TRACE("init teams\n"); - team_init(&sKernelArgs); TRACE("init threads\n"); thread_init(&sKernelArgs); TRACE("init ports\n"); @@ -163,15 +167,13 @@ TRACE("init kernel daemons\n"); kernel_daemon_init(); arch_platform_init_post_thread(&sKernelArgs); - TRACE("init posix semaphores\n"); + TRACE("init POSIX semaphores\n"); realtime_sem_init(); xsi_ipc_init(); TRACE("init VM threads\n"); vm_init_post_thread(&sKernelArgs); low_resource_manager_init_post_thread(); - TRACE("init ELF loader\n"); - elf_init(&sKernelArgs); TRACE("init scheduler\n"); scheduler_init(); TRACE("init notification services\n"); @@ -245,7 +247,7 @@ TRACE("Init modules\n"); boot_splash_set_stage(BOOT_SPLASH_STAGE_1_INIT_MODULES); - module_init(&sKernelArgs); + module_init_post_threads(); // init userland debugging TRACE("Init Userland debugging\n"); Modified: haiku/trunk/src/system/kernel/module.cpp =================================================================== --- haiku/trunk/src/system/kernel/module.cpp 2008-08-04 13:09:40 UTC (rev 26789) +++ haiku/trunk/src/system/kernel/module.cpp 2008-08-04 13:26:13 UTC (rev 26790) @@ -1815,10 +1815,6 @@ new(&sModuleNotificationService) ModuleNotificationService(); - register_kernel_daemon(&ModuleNotificationService::HandleNotifications, - NULL, 10); - // once every second - sDisableUserAddOns = get_safemode_boolean(B_SAFEMODE_DISABLE_USER_ADD_ONS, false); @@ -1829,6 +1825,17 @@ } +status_t +module_init_post_threads(void) +{ + return register_kernel_daemon( + &ModuleNotificationService::HandleNotifications, NULL, 10); + // once every second + + return B_OK; +} + + // #pragma mark - Exported Kernel API (public part) From HOST.HAIKU at gmx.de Mon Aug 4 15:32:49 2008 From: HOST.HAIKU at gmx.de (Julun) Date: Mon, 04 Aug 2008 15:32:49 +0200 Subject: [Haiku-commits] r26787 - haiku/trunk/src/apps/text_search In-Reply-To: <200808041253.m74CruQp028460@sheep.berlios.de> References: <200808041253.m74CruQp028460@sheep.berlios.de> Message-ID: <48970501.50006@gmx.de> Hi, just curious, are there any guidelines, preferences on how out-parameters are handled, as pointers or references? I recently changed some code as well to _LoadHistory(...) format, but i was considering changing it back like _OpenFile(...) as it's more obvious that the values might get modified by the function call. It would be nice if we could add that if we can agree on something. Regards, Karsten > @@ -72,9 +71,7 @@ > Model::LoadPrefs() > { > BFile file; > - status_t status = _OpenFile(&file, PREFS_FILE, B_READ_ONLY, > - B_USER_SETTINGS_DIRECTORY, NULL); > - > + status_t status = _OpenFile(&file, PREFS_FILE); > if (status != B_OK) > return status; > > > @@ -193,30 +189,31 @@ > void > Model::AddToHistory(const char* text) > { > - BList* items = _LoadHistory(); > - if (items == NULL) > + BList items; > + if (!_LoadHistory(items)) > return; > > > -BList* > -Model::_LoadHistory() > +bool > +Model::_LoadHistory(BList& items) const > { > status_t > Model::_OpenFile(BFile* file, const char* name, uint32 openMode, > - directory_which which, BVolume* volume) > + directory_which which, BVolume* volume) const > { > - BList* _LoadHistory(); > - status_t _SaveHistory(BList* items); > - void _FreeHistory(BList* items); > + bool _LoadHistory(BList& items) const; > + status_t _SaveHistory(const BList& items) const; > + void _FreeHistory(const BList& items) const; > status_t _OpenFile(BFile* file, const char* name, > uint32 openMode = B_READ_ONLY, > directory_which which > = B_USER_SETTINGS_DIRECTORY, > - BVolume* volume = NULL); > + BVolume* volume = NULL) const; > }; > > #endif // MODEL_H > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > > From axeld at pinc-software.de Mon Aug 4 15:54:54 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 04 Aug 2008 15:54:54 +0200 CEST Subject: [Haiku-commits] r26787 - haiku/trunk/src/apps/text_search In-Reply-To: <48970501.50006@gmx.de> Message-ID: <26019730900-BeMail@zon> Julun wrote: > just curious, are there any guidelines, preferences on how > out-parameters are handled, as pointers or references? I recently > changed some code as well to _LoadHistory(...) format, but i was > considering changing it back like _OpenFile(...) as it's more obvious > that the values might get modified by the function call. > > It would be nice if we could add that if we can agree on something. I prefer by reference when the object must not be NULL, by pointer if it is allowed to be NULL. While it's more obvious that the values are changed (unless you already have a pointer type), I find that advantage usually negligible, as it depends on what you're used to, anyway. Bye, Axel. From bonefish at mail.berlios.de Mon Aug 4 16:23:08 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 16:23:08 +0200 Subject: [Haiku-commits] r26791 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200808041423.m74EN8Fs002372@sheep.berlios.de> Author: bonefish Date: 2008-08-04 16:23:06 +0200 (Mon, 04 Aug 2008) New Revision: 26791 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26791&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test2.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: Test program to reproduce bug #2562. Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-04 13:26:13 UTC (rev 26790) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-04 14:23:06 UTC (rev 26791) @@ -32,6 +32,10 @@ : signal_in_allocator_test.cpp ; +SimpleTest signal_in_allocator_test2 + : signal_in_allocator_test2.cpp +; + SimpleTest signal_test : signal_test.cpp ; Copied: haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test2.cpp (from rev 26755, 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-08-03 13:40:41 UTC (rev 26755) +++ haiku/trunk/src/tests/system/libroot/posix/signal_in_allocator_test2.cpp 2008-08-04 14:23:06 UTC (rev 26791) @@ -0,0 +1,80 @@ +/* + * 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) +{ + sHandledSignals++; +} + + +static void +allocator_thread(int level) +{ + if (level > 100000) + return; + + free(malloc(rand() % 10000)); + + allocator_thread(level + 1); +} + + +int +main() +{ + // Test program to reproduce bug #2562. Is finished quickly and must be run + // in a loop to reproduce the bug. + + // 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); + + allocator_thread(0); + + kill_thread(signalThread); + snooze(1000); + + printf("test successful, handled %lld signals\n", sHandledSignals); + + return 0; +} From stippi at mail.berlios.de Mon Aug 4 16:25:26 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 16:25:26 +0200 Subject: [Haiku-commits] r26792 - haiku/trunk/src/kits/storage Message-ID: <200808041425.m74EPQNk002498@sheep.berlios.de> Author: stippi Date: 2008-08-04 16:25:26 +0200 (Mon, 04 Aug 2008) New Revision: 26792 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26792&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: Don't choke in BPathMonitor::StopWatch(...) if the client never called StartWatching() before and the BPathMonitor stuff is therefor not initialized. Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 14:23:06 UTC (rev 26791) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 14:25:26 UTC (rev 26792) @@ -815,6 +815,9 @@ /*static*/ status_t BPathMonitor::StopWatching(const char* path, BMessenger target) { + if (sLocker == NULL) + return B_NO_INIT; + BAutolock _(sLocker); WatcherMap::iterator iterator = sWatchers.find(target); @@ -845,6 +848,9 @@ /*static*/ status_t BPathMonitor::StopWatching(BMessenger target) { + if (sLocker == NULL) + return B_NO_INIT; + BAutolock _(sLocker); WatcherMap::iterator iterator = sWatchers.find(target); From axeld at mail.berlios.de Mon Aug 4 16:50:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 16:50:32 +0200 Subject: [Haiku-commits] r26793 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808041450.m74EoW67004395@sheep.berlios.de> Author: axeld Date: 2008-08-04 16:50:32 +0200 (Mon, 04 Aug 2008) New Revision: 26793 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26793&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp Log: * Added KDL command "bfs_block_runs" which shows the blocks runs in an array. * The "bfs" KDL command now also accepts ',' as group/start delimiter in a block_run. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2008-08-04 14:25:26 UTC (rev 26792) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2008-08-04 14:50:32 UTC (rev 26793) @@ -321,7 +321,7 @@ // convert block_runs/offsets for (int i = 2; i < argc; i++) { char* arg = argv[i]; - if (strchr(arg, '.') != NULL) { + if (strchr(arg, '.') != NULL || strchr(arg, ',') != NULL) { // block_run to offset block_run run; run.allocation_group = HOST_ENDIAN_TO_BFS_INT32( @@ -358,6 +358,28 @@ static int +dump_block_run_array(int argc, char** argv) +{ + if (argc < 2 || !strcmp(argv[1], "--help")) { + kprintf("usage: %s [number-of-runs]\n", argv[0]); + return 0; + } + + block_run* runs = (block_run*)parse_expression(argv[1]); + uint32 count = 16; + if (argc > 2) + count = parse_expression(argv[2]); + + for (uint32 i = 0; i < count; i++) { + dprintf("[%3lu] ", i); + dump_block_run("", runs[i]); + } + + return 0; +} + + +static int dump_bplustree_node(int argc, char** argv) { if (argc < 2 || argc > 4 || !strcmp(argv[1], "--help")) { @@ -421,6 +443,8 @@ add_debugger_command("bfs_btree_node", dump_bplustree_node, "dump a BFS B+tree node"); add_debugger_command("bfs", dump_volume, "dump a BFS volume"); + add_debugger_command("bfs_block_runs", dump_block_run_array, + "dump a block run array"); } From axeld at mail.berlios.de Mon Aug 4 16:54:22 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 16:54:22 +0200 Subject: [Haiku-commits] r26794 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808041454.m74EsM8C004592@sheep.berlios.de> Author: axeld Date: 2008-08-04 16:54:22 +0200 (Mon, 04 Aug 2008) New Revision: 26794 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26794&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp Log: * For regular files, BFS will now preallocate much more than the previous 64 KB, which are now only used for directories and for files smaller than 1 MB. * For files between 1 MB and 32 MB 512 KB are used as preallocation size, everything beyond that will get a 1/16 of their file size, ie. 4 MB with a file size of 64 MB, 64 MB with a file size of 1 GB. * This should help a lot with fragmentation of large files when they are written synchronously. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-04 14:50:32 UTC (rev 26793) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Inode.cpp 2008-08-04 14:54:22 UTC (rev 26794) @@ -1568,7 +1568,7 @@ // blocks we need to allocate may be different from the one we request // from the block allocator - // Should we preallocate some blocks (currently, always 64k)? + // Should we preallocate some blocks? // Attributes, attribute directories, and long symlinks usually won't get // that big, and should stay close to the inode - preallocating could be // counterproductive. @@ -1576,8 +1576,24 @@ // well. if (!IsAttribute() && !IsAttributeDirectory() && !IsSymLink() && blocksRequested < (65536 >> fVolume->BlockShift()) - && fVolume->FreeBlocks() > 128) - blocksRequested = 65536 >> fVolume->BlockShift(); + && fVolume->FreeBlocks() > 128) { + // preallocate 64 KB at minimum + if (IsFile()) { + // request preallocated blocks depending on the file size + if (size < 1 * 1024 * 1024) { + // preallocate 64 KB for file sizes < 1 MB + blocksRequested = 65536 >> fVolume->BlockShift(); + } else if (size < 32 * 1024 * 1024) { + // preallocate 512 KB for file sizes between 1 MB and 32 MB + blocksRequested = (512 * 1024) >> fVolume->BlockShift(); + } else { + // preallocate 1/16 of the file size (ie. 4 MB for 64 MB, + // 64 MB for 1 GB) + blocksRequested = size >> (fVolume->BlockShift() + 4); + } + } else + blocksRequested = 65536 >> fVolume->BlockShift(); + } while (blocksNeeded > 0) { // the requested blocks do not need to be returned with a From stippi at mail.berlios.de Mon Aug 4 17:16:31 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 17:16:31 +0200 Subject: [Haiku-commits] r26795 - haiku/trunk/src/apps/text_search Message-ID: <200808041516.m74FGVQV006573@sheep.berlios.de> Author: stippi Date: 2008-08-04 17:16:30 +0200 (Mon, 04 Aug 2008) New Revision: 26795 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26795&view=rev Modified: haiku/trunk/src/apps/text_search/FileIterator.h haiku/trunk/src/apps/text_search/FolderIterator.cpp haiku/trunk/src/apps/text_search/FolderIterator.h haiku/trunk/src/apps/text_search/GrepWindow.cpp haiku/trunk/src/apps/text_search/GrepWindow.h haiku/trunk/src/apps/text_search/Jamfile Log: Intermediate commit, because I want to rename FolderIterator but it has changes. * Beginnings of node monitoring support. Currently disabled, but detects new, changed and removed files. Folders untested yet. There may also be a problem with the toplevel folders when a pose selection message is used. That's untested too as of yet. * Removed some superfluous whitespace. * Small refactoring in FolderIterator to access some stuff from the outside as well. Modified: haiku/trunk/src/apps/text_search/FileIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/FileIterator.h 2008-08-04 15:16:30 UTC (rev 26795) @@ -36,7 +36,10 @@ // Returns the full path name of the next file. virtual bool GetNextName(char* buffer) = 0; - + + // Tells the Grepper whether the targets wants to know about negative hits. + virtual bool NotifyNegatives() const = 0; + protected: // Determines whether we can grep a file. bool _ExamineFile(BEntry& entry, char* buffer, Modified: haiku/trunk/src/apps/text_search/FolderIterator.cpp =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.cpp 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/FolderIterator.cpp 2008-08-04 15:16:30 UTC (rev 26795) @@ -109,21 +109,15 @@ } -// #pragma mark - private - - bool -FolderIterator::_GetNextEntry(BEntry& entry) +FolderIterator::NotifyNegatives() const { - if (fDirectories.CountItems() == 1) - return _GetTopEntry(entry); - else - return _GetSubEntry(entry); + return false; } bool -FolderIterator::_GetTopEntry(BEntry& entry) +FolderIterator::GetTopEntry(BEntry& entry) { // If the user selected one or more files, we must look // at the "refs" inside the message that was passed into @@ -151,6 +145,37 @@ bool +FolderIterator::FollowSubdir(BEntry& entry) const +{ + if (!fRecurseDirs) + return false; + + if (fSkipDotDirs) { + char nameBuf[B_FILE_NAME_LENGTH]; + if (entry.GetName(nameBuf) == B_OK) { + if (*nameBuf == '.') + return false; + } + } + + return true; +} + + +// #pragma mark - private + + +bool +FolderIterator::_GetNextEntry(BEntry& entry) +{ + if (fDirectories.CountItems() == 1) + return GetTopEntry(entry); + else + return _GetSubEntry(entry); +} + + +bool FolderIterator::_GetSubEntry(BEntry& entry) { if (!fCurrentDir) @@ -173,17 +198,9 @@ void FolderIterator::_ExamineSubdir(BEntry& entry) { - if (!fRecurseDirs) + if (!FollowSubdir(entry)) return; - if (fSkipDotDirs) { - char nameBuf[B_FILE_NAME_LENGTH]; - if (entry.GetName(nameBuf) == B_OK) { - if (*nameBuf == '.') - return; - } - } - BDirectory* dir = new (nothrow) BDirectory(&entry); if (dir == NULL || dir->InitCheck() != B_OK || !fDirectories.AddItem(dir)) { // clean up Modified: haiku/trunk/src/apps/text_search/FolderIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.h 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/FolderIterator.h 2008-08-04 15:16:30 UTC (rev 26795) @@ -47,17 +47,19 @@ virtual ~FolderIterator(); virtual bool IsValid() const; - - // Returns the full path name of the next file. virtual bool GetNextName(char* buffer); + virtual bool NotifyNegatives() const; + // Looks for the next entry in the top-level dir. + bool GetTopEntry(BEntry& entry); + + // Should this subfolder be followed? + bool FollowSubdir(BEntry& entry) const; + private: // Looks for the next entry. bool _GetNextEntry(BEntry& entry); - // Looks for the next entry in the top-level dir. - bool _GetTopEntry(BEntry& entry); - // Looks for the next entry in a subdir. bool _GetSubEntry(BEntry& entry); Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 15:16:30 UTC (rev 26795) @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -155,133 +156,137 @@ case B_ABOUT_REQUESTED: _OnAboutRequested(); break; - + case MSG_NEW_WINDOW: _OnNewWindow(); break; - + case B_SIMPLE_DATA: _OnFileDrop(message); break; - + case MSG_OPEN_PANEL: _OnOpenPanel(); break; - + case MSG_REFS_RECEIVED: _OnRefsReceived(message); break; - + case B_CANCEL: _OnOpenPanelCancel(); break; - + case MSG_RECURSE_LINKS: _OnRecurseLinks(); break; - + case MSG_RECURSE_DIRS: _OnRecurseDirs(); break; - + case MSG_SKIP_DOT_DIRS: _OnSkipDotDirs(); break; - + case MSG_CASE_SENSITIVE: _OnCaseSensitive(); break; - + case MSG_ESCAPE_TEXT: _OnEscapeText(); break; - + case MSG_TEXT_ONLY: _OnTextOnly(); break; - + case MSG_INVOKE_PE: _OnInvokePe(); break; - + case MSG_SEARCH_TEXT: _OnSearchText(); break; - + case MSG_SELECT_HISTORY: _OnHistoryItem(message); break; - + case MSG_START_CANCEL: _OnStartCancel(); break; - + case MSG_SEARCH_FINISHED: _OnSearchFinished(); break; - + + case B_PATH_MONITOR: + _OnNodeMonitorEvent(message); + break; + case MSG_REPORT_FILE_NAME: _OnReportFileName(message); break; - + case MSG_REPORT_RESULT: _OnReportResult(message); break; - + case MSG_REPORT_ERROR: _OnReportError(message); break; - + case MSG_SELECT_ALL: _OnSelectAll(message); break; - + case MSG_TRIM_SELECTION: _OnTrimSelection(); break; - + case MSG_COPY_TEXT: _OnCopyText(); break; - + case MSG_SELECT_IN_TRACKER: _OnSelectInTracker(); break; - + case MSG_MENU_SHOW_LINES: _OnMenuShowLines(); break; - + case MSG_CHECKBOX_SHOW_LINES: _OnCheckboxShowLines(); break; - + case MSG_OPEN_SELECTION: // fall through case MSG_INVOKE_ITEM: _OnInvokeItem(); break; - + case MSG_QUIT_NOW: _OnQuitNow(); break; - + case 'utf8': fModel->fEncoding = 0; break; - + case B_SJIS_CONVERSION: fModel->fEncoding = B_SJIS_CONVERSION; break; - + case B_EUC_CONVERSION: fModel->fEncoding = B_EUC_CONVERSION; break; - + case B_JIS_CONVERSION: fModel->fEncoding = B_JIS_CONVERSION; break; - + default: BWindow::MessageReceived(message); break; @@ -292,6 +297,7 @@ void GrepWindow::Quit() { + _StopNodeMonitoring(); _SavePrefs(); // TODO: stippi: Looks like this could be done @@ -663,12 +669,57 @@ } +void +GrepWindow::_StartNodeMonitoring() +{ + BMessenger messenger(this); + uint32 fileFlags = B_WATCH_NAME | B_WATCH_STAT; + uint32 dirFlags = B_WATCH_DIRECTORY | B_WATCH_NAME; + + // watch the top level folder + BPath path(&fModel->fDirectory); + if (path.InitCheck() == B_OK) { +printf("start monitoring root folder: %s\n", path.Path()); + BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags, messenger); + } + + FolderIterator iterator(fModel); + + BEntry entry; + while (iterator.GetTopEntry(entry)) { + path.SetTo(&entry); + if (entry.IsDirectory()) { + // subfolder + if (iterator.FollowSubdir(entry)) { +printf("start monitoring folder: %s\n", path.Path()); + BPrivate::BPathMonitor::StartWatching(path.Path(), + dirFlags | B_WATCH_RECURSIVELY, messenger); + } + } else { + // regular file +printf("start monitoring file: %s\n", path.Path()); + BPrivate::BPathMonitor::StartWatching(path.Path(), fileFlags, + messenger); + } + } +} + + +void +GrepWindow::_StopNodeMonitoring() +{ + BPrivate::BPathMonitor::StopWatching(BMessenger(this)); +} + + // #pragma mark - events void GrepWindow::_OnStartCancel() { + _StopNodeMonitoring(); + if (fModel->fState == STATE_IDLE) { fModel->fState = STATE_SEARCH; @@ -714,8 +765,11 @@ // roll back in case of problems if (fGrepper == NULL) delete iterator; - delete fGrepper; - fGrepper = NULL; + else { + // Grepper owns iterator + delete fGrepper; + fGrepper = NULL; + } fModel->fState = STATE_CANCEL; // TODO: better notification to user fprintf(stderr, "Out of memory.\n"); @@ -732,6 +786,8 @@ { fModel->fState = STATE_IDLE; +// _StartNodeMonitoring(); + delete fGrepper; fGrepper = NULL; @@ -740,11 +796,11 @@ fPreferencesMenu->SetEnabled(true); fHistoryMenu->SetEnabled(true); fEncodingMenu->SetEnabled(true); - + fButton->SetLabel(_T("Search")); fButton->SetEnabled(true); fSearch->SetEnabled(true); - + fSearchText->SetEnabled(true); fSearchText->MakeFocus(true); fSearchText->SetText(fOldPattern.String()); @@ -754,6 +810,39 @@ void +GrepWindow::_OnNodeMonitorEvent(BMessage* message) +{ + int32 opCode; + if (message->FindInt32("opcode", &opCode) != B_OK) + return; + + switch (opCode) { + case B_ENTRY_CREATED: +printf("B_ENTRY_CREATED\n"); + break; + case B_ENTRY_REMOVED: +printf("B_ENTRY_REMOVED\n"); + break; + case B_ENTRY_MOVED: +printf("B_ENTRY_MOVED\n"); + break; + case B_STAT_CHANGED: +printf("B_STAT_CHANGED\n"); + break; + case B_ATTR_CHANGED: +printf("B_ATTR_CHANGED\n"); + break; + + default: +printf("unkown opcode\n"); + break; + } + + message->PrintToStream(); +} + + +void GrepWindow::_OnReportFileName(BMessage* message) { fSearchText->SetText(message->FindString("filename")); Modified: haiku/trunk/src/apps/text_search/GrepWindow.h =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-04 15:16:30 UTC (rev 26795) @@ -53,9 +53,13 @@ void _LoadPrefs(); void _SavePrefs(); - + + void _StartNodeMonitoring(); + void _StopNodeMonitoring(); + void _OnStartCancel(); void _OnSearchFinished(); + void _OnNodeMonitorEvent(BMessage* message); void _OnReportFileName(BMessage* message); void _OnReportResult(BMessage* message); void _OnReportError(BMessage* message); @@ -129,8 +133,8 @@ Grepper* fGrepper; BString fOldPattern; - Model* fModel; + bigtime_t fLastNodeMonitorEvent; BFilePanel* fFilePanel; }; Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 14:54:22 UTC (rev 26794) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 15:16:30 UTC (rev 26795) @@ -2,6 +2,8 @@ SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders storage ; + Application TextSearch : FileIterator.cpp FolderIterator.cpp From axeld at pinc-software.de Mon Aug 4 17:31:37 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 04 Aug 2008 17:31:37 +0200 CEST Subject: [Haiku-commits] r26795 - haiku/trunk/src/apps/text_search In-Reply-To: <200808041516.m74FGVQV006573@sheep.berlios.de> Message-ID: <31822667753-BeMail@zon> stippi at BerliOS wrote: > Log: > Intermediate commit, because I want to rename FolderIterator but it > has changes. You can just follow the instructions in the error message: svn mv --force FolderIterator.cpp StippisIterator.cpp Bye, Axel. From axeld at mail.berlios.de Mon Aug 4 18:04:58 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 18:04:58 +0200 Subject: [Haiku-commits] r26796 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808041604.m74G4wQH013138@sheep.berlios.de> Author: axeld Date: 2008-08-04 18:04:57 +0200 (Mon, 04 Aug 2008) New Revision: 26796 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26796&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: * We must call file_cache_disable() with O_NOCACHE also in bfs_create(). 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-08-04 15:16:30 UTC (rev 26795) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2008-08-04 16:04:57 UTC (rev 26796) @@ -810,10 +810,17 @@ Transaction transaction(volume, directory->BlockNumber()); + Inode* inode; bool created; status_t status = Inode::Create(transaction, directory, name, - S_FILE | (mode & S_IUMSK), openMode, 0, &created, _vnodeID); + S_FILE | (mode & S_IUMSK), openMode, 0, &created, _vnodeID, &inode); + // Disable the file cache, if requested? + if (status == B_OK && (openMode & O_NOCACHE) != 0 + && inode->FileCache() != NULL) { + status = file_cache_disable(inode->FileCache()); + } + if (status >= B_OK) { transaction.Done(); From axeld at mail.berlios.de Mon Aug 4 18:10:26 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 18:10:26 +0200 Subject: [Haiku-commits] r26797 - haiku/trunk/src/system/kernel/vm Message-ID: <200808041610.m74GAQCm013482@sheep.berlios.de> Author: axeld Date: 2008-08-04 18:10:25 +0200 (Mon, 04 Aug 2008) New Revision: 26797 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26797&view=rev Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp Log: * Now uses _kern_write_stat() directly in order to resize the swap file without filling it with zeros (ie. make use of B_STAT_SIZE_INSECURE). * Added TODO that closing the file descriptor in swap_init_post_modules() (that should probably renamed to swap_init_post_boot_device()) is not really a good idea. Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 16:04:57 UTC (rev 26796) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 16:10:25 UTC (rev 26797) @@ -16,17 +16,21 @@ #include #include +#include +#include + #include +#include +#include #include -#include #include +#include +#include +#include #include #include #include #include -#include -#include -#include #if ENABLE_SWAP_SUPPORT @@ -765,13 +769,19 @@ dprintf("Can't open/create /var/swap: %s\n", strerror(errno)); return; } - close(fd); - if (truncate("/var/swap", size) < 0) { + struct stat stat; + stat.st_size = size; + if (_kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), + B_STAT_SIZE | B_STAT_SIZE_INSECURE) != B_OK) { dprintf("Failed to resize /var/swap to %lld bytes: %s\n", size, strerror(errno)); } + close(fd); + // TODO: if we don't keep the file open, O_NOCACHE is going to be + // removed - we must not do this while we're using the swap file + swap_file_add("/var/swap"); } From axeld at mail.berlios.de Mon Aug 4 18:36:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 18:36:03 +0200 Subject: [Haiku-commits] r26798 - haiku/trunk/src/add-ons/kernel/generic/scsi_periph Message-ID: <200808041636.m74Ga3Tu022920@sheep.berlios.de> Author: axeld Date: 2008-08-04 18:36:02 +0200 (Mon, 04 Aug 2008) New Revision: 26798 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26798&view=rev Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.c Log: * Fixed a bug in scsi_periph that prevents accessing block number 0x100000. * The blocks beyond that would be potentially read in smaller chunks than anticipated, too. Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.c 2008-08-04 16:10:25 UTC (rev 26797) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.c 2008-08-04 16:36:02 UTC (rev 26798) @@ -82,7 +82,8 @@ // don't allow transfer cross the 24 bit address limit // (I'm not sure whether this is allowed, but this way we // are sure to not ask for trouble) - num_blocks = min(num_blocks, 0x100000 - pos); + if (pos < 0x100000) + num_blocks = min(num_blocks, 0x100000 - pos); } num_bytes = num_blocks * block_size; @@ -226,7 +227,7 @@ request->flags = 0; - if (cmd->flags & B_RAW_DEVICE_DATA_IN) + if (cmd->flags & B_RAW_DEVICE_DATA_IN) request->flags |= SCSI_DIR_IN; else if (cmd->data_length) request->flags |= SCSI_DIR_OUT; From ingo_weinhold at gmx.de Mon Aug 4 19:09:21 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 04 Aug 2008 19:09:21 +0200 Subject: [Haiku-commits] r26797 - haiku/trunk/src/system/kernel/vm In-Reply-To: <200808041610.m74GAQCm013482@sheep.berlios.de> References: <200808041610.m74GAQCm013482@sheep.berlios.de> Message-ID: <20080804190921.412.1@knochen-vm.localdomain> On 2008-08-04 at 18:10:26 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-04 18:10:25 +0200 (Mon, 04 Aug 2008) > New Revision: 26797 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26797&view=rev > > Modified: > haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp > Log: > * Now uses _kern_write_stat() directly in order to resize the swap file > without filling it with zeros (ie. make use of B_STAT_SIZE_INSECURE). > * Added TODO that closing the file descriptor in swap_init_post_modules() > (that should probably renamed to swap_init_post_boot_device()) is not > really > a good idea. > > > Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 > 16:04:57 UTC (rev 26796) > +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-04 > 16:10:25 UTC (rev 26797) > @@ -16,17 +16,21 @@ > #include > #include > > +#include > +#include > + > #include > +#include > +#include > #include > -#include > #include > +#include > +#include > +#include > #include > #include > #include > #include > -#include > -#include > -#include > > > #if ENABLE_SWAP_SUPPORT > @@ -765,13 +769,19 @@ > dprintf("Can't open/create /var/swap: %s\n", strerror(errno)); > return; > } > - close(fd); > > - if (truncate("/var/swap", size) < 0) { > + struct stat stat; > + stat.st_size = size; > + if (_kern_write_stat(fd, NULL, false, &stat, sizeof(struct stat), > + B_STAT_SIZE | B_STAT_SIZE_INSECURE) != B_OK) { > dprintf("Failed to resize /var/swap to %lld bytes: %s\n", size, > strerror(errno)); > } > > + close(fd); > + // TODO: if we don't keep the file open, O_NOCACHE is going to be > + // removed - we must not do this while we're using the swap file > + > swap_file_add("/var/swap"); > } I guess closing it is fine. What is not quite OK is that swap_file_add() doesn't open it (and keep it open). A few things are actually a bit odd: The FS interface {read,write}_pages() hooks get a cookie although only when called through the file cache this cookie is non-NULL -- lower layers (devfs/device) get (and expect) the cookie on the other hand, since the FS usually has the device open. O_NOCACHE is an open flag although it affects the vnode independently of the particular FD. CU, Ingo From oruizdorantes at mail.berlios.de Mon Aug 4 19:14:13 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Mon, 4 Aug 2008 19:14:13 +0200 Subject: [Haiku-commits] r26799 - in haiku/trunk: headers/os/bluetooth/HCI src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200808041714.m74HEDVF002013@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-04 19:14:06 +0200 (Mon, 04 Aug 2008) New Revision: 26799 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26799&view=rev Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_sco.h Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c Log: - First steps for SCO connections - Some styling (Mika Lindqvist) Added: haiku/trunk/headers/os/bluetooth/HCI/btHCI_sco.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_sco.h 2008-08-04 16:36:02 UTC (rev 26798) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_sco.h 2008-08-04 17:14:06 UTC (rev 26799) @@ -0,0 +1,17 @@ +/* + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef _BTHCI_SCO_H_ +#define _BTHCI_SCO_H_ + +#include + +#define HCI_SCO_HDR_SIZE 3 + +struct hci_sco_header { + uint16 handle; + uint8 slen; +} __attribute__((packed)); + +#endif // _BTHCI_SCO_H_ Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-08-04 16:36:02 UTC (rev 26798) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-08-04 17:14:06 UTC (rev 26799) @@ -1,8 +1,7 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com * All rights reserved. Distributed under the terms of the MIT License. - * */ #include @@ -14,6 +13,7 @@ #include #include #include +#include #define BT_DEBUG_THIS_MODULE #include @@ -22,38 +22,38 @@ void* nb_get_whole_buffer(net_buffer* nbuf) { - void* conPointer; - status_t err; + void* conPointer; + status_t err; #if 0 - /* the job could be already done */ - // !!! it could be trash from other upper protocols... - if (nbuf->COOKIEFIELD != NULL) - return (void*)nbuf->COOKIEFIELD; + /* the job could be already done */ + // !!! it could be trash from other upper protocols... + if (nbuf->COOKIEFIELD != NULL) + return (void*)nbuf->COOKIEFIELD; #endif err = nb->direct_access(nbuf, 0, nbuf->size, &conPointer); - + if (err != B_OK) { - panic("I expected to be contiguous:("); - #if 0 - /* pity, we are gonna need a realocation */ - nbuf->COOKIEFIELD = (uint32) malloc(nbuf->size); - if (nbuf->COOKIEFIELD == NULL) - goto fail; - - err = nb->write(nbuf, 0, (void*) nbuf->COOKIEFIELD, nbuf->size); - if (err != B_OK) - goto free; + panic("I expected to be contiguous:("); + #if 0 + /* pity, we are gonna need a realocation */ + nbuf->COOKIEFIELD = (uint32) malloc(nbuf->size); + if (nbuf->COOKIEFIELD == NULL) + goto fail; + + err = nb->write(nbuf, 0, (void*) nbuf->COOKIEFIELD, nbuf->size); + if (err != B_OK) + goto free; + + conPointer = (void*)nbuf->COOKIEFIELD; + #endif + } - conPointer = (void*)nbuf->COOKIEFIELD; - #endif - } - - return conPointer; + return conPointer; #if 0 free: - free((void*) nbuf->COOKIEFIELD); + free((void*) nbuf->COOKIEFIELD); fail: - return NULL; + return NULL; #endif } @@ -63,48 +63,57 @@ { if (nbuf == NULL) return; -#if 0 - /* Free possible allocated */ - if (nbuf->COOKIEFIELD != NULL) - free((void*)nbuf->COOKIEFIELD); +#if 0 + /* Free possible allocated */ + if (nbuf->COOKIEFIELD != NULL) + free((void*)nbuf->COOKIEFIELD); #endif // TODO check for survivers... if (nb != NULL) - nb->free(nbuf); - -} + nb->free(nbuf); + +} -/* Check from the completition if the queue is empty */ +// Extract the expected size of the packet +// TODO: This might be inefficient as at the moment of the creation of the net_buffer +// this information is known and it could be stored in any of the net_buffer fields +// but I still dont know how many of those am i gonna have free.... size_t get_expected_size(net_buffer* nbuf) { - - if (nbuf == NULL) - panic("Analizing NULL packet"); - - switch (nbuf->protocol) { + + if (nbuf == NULL) + panic("Analizing NULL packet"); + + switch (nbuf->protocol) { + + case BT_COMMAND: { + struct hci_command_header* header = nb_get_whole_buffer(nbuf); + return header->clen + sizeof(struct hci_command_header); + } + + case BT_EVENT: { + struct hci_event_header* header = nb_get_whole_buffer(nbuf); + return header->elen + sizeof(struct hci_event_header); + } - case BT_ACL: { - struct hci_acl_header* header = nb_get_whole_buffer(nbuf); - return header->alen + sizeof(struct hci_acl_header); - } + case BT_ACL: { + struct hci_acl_header* header = nb_get_whole_buffer(nbuf); + return header->alen + sizeof(struct hci_acl_header); + } - case BT_COMMAND: { - struct hci_command_header* header = nb_get_whole_buffer(nbuf); - return header->clen + sizeof(struct hci_command_header); - } - - case BT_EVENT: { - struct hci_event_header* header = nb_get_whole_buffer(nbuf); - return header->elen + sizeof(struct hci_event_header); - } - default: - panic("h2geneirc:no protocol specifiel for get expected size"); - break; - } - - return B_ERROR; + case BT_SCO: { + struct hci_sco_header* header = nb_get_whole_buffer(nbuf); + return header->slen + sizeof(struct hci_sco_header); + } + + default: + panic(BLUETOOTH_DEVICE_DEVFS_NAME "no protocol specified for " __FUNCTION__); + break; + } + + return B_ERROR; } #if 0 @@ -114,37 +123,37 @@ inline void init_room(struct list* l) { - list_init(l); + list_init(l); } void* alloc_room(struct list* l, size_t size) { - - void* item = list_get_first_item(l); - - if (item == NULL) - item = (void*) malloc(size); - - return item; - + + void* item = list_get_first_item(l); + + if (item == NULL) + item = (void*) malloc(size); + + return item; + } inline void reuse_room(struct list* l, void* room) { - list_add_item(l, room); + list_add_item(l, room); } void purge_room(struct list* l) { - void* item; - - while ((item = list_remove_head_item(l)) != NULL) { + void* item; + + while ((item = list_remove_head_item(l)) != NULL) { free(item); - } + } } From axeld at mail.berlios.de Mon Aug 4 19:56:13 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 4 Aug 2008 19:56:13 +0200 Subject: [Haiku-commits] r26800 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808041756.m74HuDm6014757@sheep.berlios.de> Author: axeld Date: 2008-08-04 19:56:13 +0200 (Mon, 04 Aug 2008) New Revision: 26800 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26800&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h Log: * Build fix when built with DEBUG defined. * Forgot to remove the "bfs_block_runs" debugger command on module unload. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-04 17:14:06 UTC (rev 26799) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2008-08-04 17:56:13 UTC (rev 26800) @@ -456,8 +456,8 @@ // is header valid? if (fHeader->MaximumSize() != stream->Size()) { - FATAL(("B+tree header size %Ld doesn't fit file size %Ld!\n", - fHeader->MaximumSize(), stream->Size())); + dprintf("B+tree header size %Ld doesn't fit file size %Ld!\n", + fHeader->MaximumSize(), stream->Size()); // we can't change the header since we don't have a transaction //fHeader->maximum_size = HOST_ENDIAN_TO_BFS_INT64(stream->Size()); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2008-08-04 17:14:06 UTC (rev 26799) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.cpp 2008-08-04 17:56:13 UTC (rev 26800) @@ -365,7 +365,7 @@ return 0; } - block_run* runs = (block_run*)parse_expression(argv[1]); + const block_run* runs = (const block_run*)parse_expression(argv[1]); uint32 count = 16; if (argc > 2) count = parse_expression(argv[2]); @@ -427,6 +427,7 @@ remove_debugger_command("bfs_btree_header", dump_bplustree_header); remove_debugger_command("bfs_btree_node", dump_bplustree_node); remove_debugger_command("bfs", dump_volume); + remove_debugger_command("bfs_block_runs", dump_block_run_array); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h 2008-08-04 17:14:06 UTC (rev 26799) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Debug.h 2008-08-04 17:56:13 UTC (rev 26800) @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, 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 DEBUG_H @@ -67,7 +67,7 @@ #define REPORT_ERROR(status) \ __out("bfs: %s:%d: %s\n", __FUNCTION__, __LINE__, strerror(status)); #define RETURN_ERROR(err) { status_t _status = err; if (_status < B_OK) REPORT_ERROR(_status); return _status;} -// #define FATAL(x) { __out("bfs: "); __out x; sync(); panic("BFS!\n"); } +// #define FATAL(x) { panic x; } #define FATAL(x) { __out("bfs: "); __out x; } #define INFORM(x) { __out("bfs: "); __out x; } #define FUNCTION() ; @@ -88,9 +88,9 @@ struct disk_super_block; class Inode; class Volume; - + // some structure dump functions - extern void dump_block_run(const char *prefix, block_run &run); + extern void dump_block_run(const char *prefix, const block_run &run); extern void dump_super_block(const disk_super_block *superBlock); extern void dump_data_stream(const data_stream *stream); extern void dump_inode(const bfs_inode *inode); From oruizdorantes at mail.berlios.de Mon Aug 4 19:58:14 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Mon, 4 Aug 2008 19:58:14 +0200 Subject: [Haiku-commits] r26801 - in haiku/trunk: headers/os/bluetooth src/kits/bluetooth Message-ID: <200808041758.m74HwE0S014938@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-04 19:58:09 +0200 (Mon, 04 Aug 2008) New Revision: 26801 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26801&view=rev Modified: haiku/trunk/headers/os/bluetooth/RemoteDevice.h haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp Log: Use const reference as input parameter as suggested by julun Modified: haiku/trunk/headers/os/bluetooth/RemoteDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-04 17:56:13 UTC (rev 26800) +++ haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-04 17:58:09 UTC (rev 26801) @@ -48,7 +48,7 @@ LocalDevice* GetLocalDeviceOwner(); - RemoteDevice(BString address); + RemoteDevice(const BString& address); RemoteDevice(bdaddr_t address); protected: Modified: haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp =================================================================== --- haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp 2008-08-04 17:56:13 UTC (rev 26800) +++ haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp 2008-08-04 17:58:09 UTC (rev 26801) @@ -30,7 +30,7 @@ bool RemoteDevice::IsTrustedDevice(void) { - return true; + return true; } @@ -38,58 +38,58 @@ RemoteDevice::GetFriendlyName(bool alwaysAsk) { - if (!alwaysAsk) { - // Check if the name is already retrieved - // TODO: Check if It is known from a KnownDevicesList - return BString("Not implemented"); - } - - if (fDiscovererLocalDevice == NULL) - return BString("#NoOwnerError#Not Valid name"); - - if (fMessenger == NULL) - return BString("#ServerNotReady#Not Valid name"); - - void* remoteNameCommand = NULL; + if (!alwaysAsk) { + // Check if the name is already retrieved + // TODO: Check if It is known from a KnownDevicesList + return BString("Not implemented"); + } + + if (fDiscovererLocalDevice == NULL) + return BString("#NoOwnerError#Not Valid name"); + + if (fMessenger == NULL) + return BString("#ServerNotReady#Not Valid name"); + + void* remoteNameCommand = NULL; size_t size; - - /* Issue inquiry command */ - BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); - BMessage reply; - - request.AddInt32("hci_id", fDiscovererLocalDevice->GetID()); - - // Fill the request + + // Issue inquiry command + BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); + BMessage reply; + + request.AddInt32("hci_id", fDiscovererLocalDevice->GetID()); + + // Fill the request remoteNameCommand = buildRemoteNameRequest(fBdaddr, fPageRepetitionMode, fClockOffset, &size); // Fill correctily - + request.AddData("raw command", B_ANY_TYPE, remoteNameCommand, size); request.AddInt16("eventExpected", HCI_EVENT_CMD_STATUS); - request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); - + request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_LINK_CONTROL, OCF_REMOTE_NAME_REQUEST)); + request.AddInt16("eventExpected", HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE); - - - if (fMessenger->SendMessage(&request, &reply) == B_OK) - { - BString name; - int8 status; - - if ((reply.FindInt8("status", &status) == B_OK) && (status == BT_OK)) { - - if ((reply.FindString("friendlyname", &name) == B_OK ) ) { - return name; - } else { - return BString("");// should not happen - } - - } else { - // seems we got a netative event - return BString("#CommandFailed#Not Valid name"); - } - } - - return BString("#NotCompletedRequest#Not Valid name"); + + + if (fMessenger->SendMessage(&request, &reply) == B_OK) + { + BString name; + int8 status; + + if ((reply.FindInt8("status", &status) == B_OK) && (status == BT_OK)) { + + if ((reply.FindString("friendlyname", &name) == B_OK ) ) { + return name; + } else { + return BString(""); // should not happen + } + + } else { + // seems we got a negative event + return BString("#CommandFailed#Not Valid name"); + } + } + + return BString("#NotCompletedRequest#Not Valid name"); } @@ -103,16 +103,16 @@ bdaddr_t RemoteDevice::GetBluetoothAddress() { - return fBdaddr; + return fBdaddr; } bool RemoteDevice::Equals(RemoteDevice* obj) { - bdaddr_t ba = obj->GetBluetoothAddress(); + bdaddr_t ba = obj->GetBluetoothAddress(); - return bdaddrUtils::Compare(&fBdaddr, &ba); + return bdaddrUtils::Compare(&fBdaddr, &ba); } // static RemoteDevice* GetRemoteDevice(Connection conn); @@ -120,7 +120,7 @@ bool RemoteDevice::Authenticate() { - return true; + return true; } @@ -131,7 +131,7 @@ bool RemoteDevice::IsAuthenticated() { - return true; + return true; } @@ -141,7 +141,7 @@ bool RemoteDevice::IsEncrypted() { - return true; + return true; } LocalDevice* @@ -166,7 +166,7 @@ } -RemoteDevice::RemoteDevice(BString address) +RemoteDevice::RemoteDevice(const BString& address) { fBdaddr = bdaddrUtils::FromString((const char *)address.String()); fMessenger = _RetrieveBluetoothMessenger(); @@ -183,7 +183,6 @@ BString RemoteDevice::GetProperty(const char* property) /* Throwing */ { - return NULL; } From oruizdorantes at mail.berlios.de Mon Aug 4 21:10:55 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Mon, 4 Aug 2008 21:10:55 +0200 Subject: [Haiku-commits] r26802 - in haiku/trunk: headers/os/bluetooth src/kits/bluetooth Message-ID: <200808041910.m74JAtLm024887@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-04 21:10:43 +0200 (Mon, 04 Aug 2008) New Revision: 26802 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26802&view=rev Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h haiku/trunk/headers/os/bluetooth/RemoteDevice.h haiku/trunk/src/kits/bluetooth/LocalDevice.cpp haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp Log: - Proper const use - Styling Modified: haiku/trunk/headers/os/bluetooth/LocalDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-08-04 17:58:09 UTC (rev 26801) +++ haiku/trunk/headers/os/bluetooth/LocalDevice.h 2008-08-04 19:10:43 UTC (rev 26802) @@ -28,8 +28,8 @@ static LocalDevice* GetLocalDevice(); static uint32 GetLocalDeviceCount(); - static LocalDevice* GetLocalDevice(hci_id hid); - static LocalDevice* GetLocalDevice(bdaddr_t bdaddr); + static LocalDevice* GetLocalDevice(const hci_id hid); + static LocalDevice* GetLocalDevice(const bdaddr_t bdaddr); DiscoveryAgent* GetDiscoveryAgent(); BString GetFriendlyName(); Modified: haiku/trunk/headers/os/bluetooth/RemoteDevice.h =================================================================== --- haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-04 17:58:09 UTC (rev 26801) +++ haiku/trunk/headers/os/bluetooth/RemoteDevice.h 2008-08-04 19:10:43 UTC (rev 26802) @@ -49,7 +49,7 @@ LocalDevice* GetLocalDeviceOwner(); RemoteDevice(const BString& address); - RemoteDevice(bdaddr_t address); + RemoteDevice(const bdaddr_t address); protected: /* called by Discovery[Listener|Agent] */ Modified: haiku/trunk/src/kits/bluetooth/LocalDevice.cpp =================================================================== --- haiku/trunk/src/kits/bluetooth/LocalDevice.cpp 2008-08-04 17:58:09 UTC (rev 26801) +++ haiku/trunk/src/kits/bluetooth/LocalDevice.cpp 2008-08-04 19:10:43 UTC (rev 26802) @@ -1,11 +1,9 @@ /* * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com * All rights reserved. Distributed under the terms of the MIT License. - * */ - #include #include @@ -29,18 +27,18 @@ LocalDevice* LocalDevice::RequestLocalDeviceID(BMessage* request) { - BMessage reply; - hci_id hid; + BMessage reply; + hci_id hid; LocalDevice* lDevice = NULL; BMessenger* messenger = _RetrieveBluetoothMessenger(); if (messenger == NULL) return NULL; - - if (messenger->SendMessage(request, &reply) == B_OK && - reply.FindInt32("hci_id", &hid) == B_OK ) { - + + if (messenger->SendMessage(request, &reply) == B_OK && + reply.FindInt32("hci_id", &hid) == B_OK ) { + if (hid >= 0) lDevice = new LocalDevice(hid); } @@ -60,22 +58,22 @@ { BMessage request(BT_MSG_ACQUIRE_LOCAL_DEVICE); - return RequestLocalDeviceID(&request); + return RequestLocalDeviceID(&request); } LocalDevice* -LocalDevice::GetLocalDevice(hci_id hid) +LocalDevice::GetLocalDevice(const hci_id hid) { - BMessage request(BT_MSG_ACQUIRE_LOCAL_DEVICE); - request.AddInt32("hci_id", hid); - - return RequestLocalDeviceID(&request); + BMessage request(BT_MSG_ACQUIRE_LOCAL_DEVICE); + request.AddInt32("hci_id", hid); + + return RequestLocalDeviceID(&request); } LocalDevice* -LocalDevice::GetLocalDevice(bdaddr_t bdaddr) +LocalDevice::GetLocalDevice(const bdaddr_t bdaddr) { BMessage request(BT_MSG_ACQUIRE_LOCAL_DEVICE); @@ -143,19 +141,19 @@ status_t LocalDevice::SetDiscoverable(int mode) { - if (fMessenger == NULL) - return B_ERROR; - - BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); - BMessage reply; - - size_t size; + if (fMessenger == NULL) + return B_ERROR; + + BMessage request(BT_MSG_HANDLE_SIMPLE_REQUEST); + BMessage reply; + + size_t size; int8 bt_status = BT_ERROR; - - - request.AddInt32("hci_id", hid); - - + + + request.AddInt32("hci_id", hid); + + void* command = buildWriteScan(mode, &size); if (command == NULL) { @@ -163,17 +161,17 @@ } request.AddData("raw command", B_ANY_TYPE, command, size); - request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); - request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE)); - - if (fMessenger->SendMessage(&request, &reply) == B_OK) { - if (reply.FindInt8("status", &bt_status ) == B_OK ) { + request.AddInt16("eventExpected", HCI_EVENT_CMD_COMPLETE); + request.AddInt16("opcodeExpected", PACK_OPCODE(OGF_CONTROL_BASEBAND, OCF_WRITE_SCAN_ENABLE)); + + if (fMessenger->SendMessage(&request, &reply) == B_OK) { + if (reply.FindInt8("status", &bt_status ) == B_OK ) { return bt_status; } } - + return B_ERROR; } @@ -181,28 +179,28 @@ bdaddr_t LocalDevice::GetBluetoothAddress() { - if (fMessenger == NULL) - return bdaddrUtils::NullAddress(); - - const bdaddr_t* bdaddr; - BMessage request(BT_MSG_GET_ADDRESS); - BMessage reply; - ssize_t size; + if (fMessenger == NULL) + return bdaddrUtils::NullAddress(); - /* ADD ID */ - request.AddInt32("hci_id", hid); - - if (fMessenger->SendMessage(&request, &reply) == B_OK) { - - if (reply.FindData("bdaddr", B_ANY_TYPE, 0, (const void**)&bdaddr, &size) == B_OK ){ + const bdaddr_t* bdaddr; + BMessage request(BT_MSG_GET_ADDRESS); + BMessage reply; + ssize_t size; + + /* ADD ID */ + request.AddInt32("hci_id", hid); + + if (fMessenger->SendMessage(&request, &reply) == B_OK) { + + if (reply.FindData("bdaddr", B_ANY_TYPE, 0, (const void**)&bdaddr, &size) == B_OK ){ - return *bdaddr; - - } else { - return bdaddrUtils::NullAddress(); - } - - } + return *bdaddr; + + } else { + return bdaddrUtils::NullAddress(); + } + + } return bdaddrUtils::NullAddress(); } @@ -212,21 +210,21 @@ LocalDevice::GetFriendlyName() { if (fMessenger == NULL) - return NULL; - - BString friendlyname; - BMessage request(BT_MSG_GET_FRIENDLY_NAME); - BMessage reply; - - /* ADD ID */ - request.AddInt32("hci_id", hid); - - if (fMessenger->SendMessage(&request, &reply) == B_OK && - reply.FindString("friendlyname", &friendlyname) == B_OK ){ - - return friendlyname; - } + return NULL; + + BString friendlyname; + BMessage request(BT_MSG_GET_FRIENDLY_NAME); + BMessage reply; + /* ADD ID */ + request.AddInt32("hci_id", hid); + + if (fMessenger->SendMessage(&request, &reply) == B_OK && + reply.FindString("friendlyname", &friendlyname) == B_OK){ + + return friendlyname; + } + return BString("Unknown"); } Modified: haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp =================================================================== --- haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp 2008-08-04 17:58:09 UTC (rev 26801) +++ haiku/trunk/src/kits/bluetooth/RemoteDevice.cpp 2008-08-04 19:10:43 UTC (rev 26802) @@ -1,11 +1,9 @@ /* * Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com - * + * Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com * All rights reserved. Distributed under the terms of the MIT License. - * */ - #include #include #include @@ -23,7 +21,6 @@ #include "KitSupport.h" - namespace Bluetooth { @@ -154,12 +151,12 @@ void RemoteDevice::SetLocalDeviceOwner(LocalDevice* ld) { - fDiscovererLocalDevice = ld; + fDiscovererLocalDevice = ld; } /* Constructor */ -RemoteDevice::RemoteDevice(bdaddr_t address) +RemoteDevice::RemoteDevice(const bdaddr_t address) { fBdaddr = address; fMessenger = _RetrieveBluetoothMessenger(); From oruizdorantes at mail.berlios.de Mon Aug 4 22:03:29 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Mon, 4 Aug 2008 22:03:29 +0200 Subject: [Haiku-commits] r26803 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200808042003.m74K3TQ8031411@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-04 22:03:23 +0200 (Mon, 04 Aug 2008) New Revision: 26803 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26803&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c Log: Cleaning whitespaces/tabs and styling Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-08-04 19:10:43 UTC (rev 26802) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-08-04 20:03:23 UTC (rev 26803) @@ -306,26 +306,22 @@ new_bt_dev->intr_in_ep = ep; new_bt_dev->max_packet_size_intr_in = ep->descr->max_packet_size; flowf("INT in\n"); - } else - { - ; + } else { flowf("INT out\n"); } break; case USB_ENDPOINT_ATTR_BULK: - if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) - { + if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) { new_bt_dev->bulk_in_ep = ep; new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;; flowf("BULK int\n"); - } else - { + } else { new_bt_dev->bulk_out_ep = ep; new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;; flowf("BULK out\n"); } - break; + break; } } @@ -442,41 +438,39 @@ acquire_sem(bdev->lock); // TX structures for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { - list_init(&bdev->nbuffersTx[i]); - bdev->nbuffersPendingTx[i] = 0; + list_init(&bdev->nbuffersTx[i]); + bdev->nbuffersPendingTx[i] = 0; } - + // RX structures bdev->eventRx = NULL; for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) { bdev->nbufferRx[i] = NULL; } - - + // dumping the USB frames init_room(&bdev->eventRoom); init_room(&bdev->aclRoom); //init_room(new_bt_dev->scoRoom); - - list_init(&bdev->snetBufferRecycleTrash); - + + list_init(&bdev->snetBufferRecycleTrash); + // Allocate set and register the HCI device if (btDevices != NULL) { struct net_device* ndev; // TODO: Fill the transport descriptor err = btDevices->init_device(bdev->name, &ndev); - + if ( err == B_OK ) { hdev = ndev->index; bdev->ndev = ndev; } else hdev = bdev->num; /* XXX: Lets try to go on*/ - } - else { + } else { hdev = bdev->num; /* XXX: Lets try to go on*/ - } + } - bdev->hdev = hdev; + bdev->hdev = hdev; *cookie = bdev; release_sem(bdev->lock); @@ -553,8 +547,7 @@ /* GotoLowPower */ // interesting ..... - } - else { + } else { /* The last client has closed, and the device is no longer connected, so remove it from the list. */ } @@ -604,12 +597,12 @@ (*(size_t**)¶ms)++; #endif - // TODO: Reuse from some TXcompleted queue + // TODO: Reuse from some TXcompleted queue snbuf = snb_create(size); snb_put(snbuf, params, size); err = submit_tx_command(bdev, snbuf); - debugf("device launched %ld\n", err); + debugf("device launched %ld\n", err); break; case BT_UP: @@ -641,7 +634,7 @@ flowf("device launched\n"); break; - case GET_STATICS: + case GET_STATS: memcpy(params, &bdev->stat, sizeof(bt_hci_statistics)); err = B_OK; break; @@ -668,7 +661,7 @@ device_read(void *cookie, off_t pos, void *buf, size_t *count) { debugf("Reading... count = %ld\n", *count); - + *count = 0; return B_OK; } @@ -810,10 +803,8 @@ } acquire_sem(dev_table_sem); - for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) - { - if (bt_usb_devices[j] != NULL && bt_usb_devices[j]->connected) - { + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { + if (bt_usb_devices[j] != NULL && bt_usb_devices[j]->connected) { str = strdup(bt_usb_devices[j]->name); if (str) { publish_names[i++] = str; @@ -842,16 +833,16 @@ static device_hooks hooks = { - device_open, - device_close, - device_free, - device_control, - device_read, + device_open, + device_close, + device_free, + device_control, + device_read, device_write, NULL, NULL, NULL, - NULL + NULL }; Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-08-04 19:10:43 UTC (rev 26802) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-08-04 20:03:23 UTC (rev 26803) @@ -39,100 +39,98 @@ static status_t assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count) -{ - net_buffer* nbuf = NULL; - snet_buffer* snbuf = NULL; - - size_t currentPacketLen = 0; - size_t expectedPacketLen = 0; +{ + net_buffer* nbuf = NULL; + snet_buffer* snbuf = NULL; + + size_t currentPacketLen = 0; + size_t expectedPacketLen = 0; - bdev->stat.bytesRX += count; + bdev->stat.bytesRX += count; if (type == BT_EVENT) snbuf = bdev->eventRx; else - nbuf = bdev->nbufferRx[type]; + nbuf = bdev->nbufferRx[type]; - while (count) { + while (count) { debugf("count %d nb=%p sb=%p type=%d\n",count, nbuf, snbuf, type); - if ( (type != BT_EVENT && nbuf == NULL) || - (type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) { + if ( (type != BT_EVENT && nbuf == NULL) || + (type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) { - /* new buffer incoming */ - switch (type) { - case BT_EVENT: - if (count >= HCI_EVENT_HDR_SIZE) { - - struct hci_event_header* headerPkt = data; - expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen; - snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen); - - } else { - flowf("EVENT frame corrupted\n"); - return -EILSEQ; - } - break; - - case BT_ACL: - if (count >= HCI_ACL_HDR_SIZE) { - int16 index; - struct hci_acl_header* headerPkt = data; + /* new buffer incoming */ + switch (type) { + case BT_EVENT: + if (count >= HCI_EVENT_HDR_SIZE) { + + struct hci_event_header* headerPkt = data; + expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen; + snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen); + + } else { + flowf("EVENT frame corrupted\n"); + return -EILSEQ; + } + break; + + case BT_ACL: + if (count >= HCI_ACL_HDR_SIZE) { + int16 index; + struct hci_acl_header* headerPkt = data; - expectedPacketLen = HCI_ACL_HDR_SIZE + B_LENDIAN_TO_HOST_INT16(headerPkt->alen); - - /* Create the buffer */ - bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen); - // TODO: this allocation can fail!! - nbuf->protocol = type; - debugf("new ACL frame %p\n", nbuf); + expectedPacketLen = HCI_ACL_HDR_SIZE + B_LENDIAN_TO_HOST_INT16(headerPkt->alen); + + /* Create the buffer */ + bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen); + // TODO: this allocation can fail!! + nbuf->protocol = type; + debugf("new ACL frame %p\n", nbuf); debugf("### Incoming ACL: len = %d\n", count); for (index = 0 ; index < count; index++ ) { dprintf("%x:",((uint8*)data)[index]); } flowf("### \n"); - - } else { - flowf("ACL frame corrupted\n"); - return -EILSEQ; - } - break; - - case BT_SCO: - break; - - default: - panic("unkown packet type in assembly"); - break; - } - currentPacketLen = expectedPacketLen; + } else { + flowf("ACL frame corrupted\n"); + return -EILSEQ; + } + break; + + case BT_SCO: - } - else { - /* Continuation */ - if (type != BT_EVENT) - currentPacketLen = get_expected_size(nbuf) - nbuf->size; - else - currentPacketLen = snb_remaining_to_put(snbuf); - } + break; + + default: + panic("unkown packet type in assembly"); + break; + } - currentPacketLen = min(currentPacketLen, count); + currentPacketLen = expectedPacketLen; - if (type == BT_EVENT) - snb_put(snbuf, data, currentPacketLen); + } else { + /* Continuation */ + if (type != BT_EVENT) + currentPacketLen = get_expected_size(nbuf) - nbuf->size; + else + currentPacketLen = snb_remaining_to_put(snbuf); + } + + currentPacketLen = min(currentPacketLen, count); + + if (type == BT_EVENT) + snb_put(snbuf, data, currentPacketLen); else - nb->append(nbuf, data, currentPacketLen); + nb->append(nbuf, data, currentPacketLen); /* Complete frame? */ - if (type == BT_EVENT && snb_completed(snbuf)) { - + if (type == BT_EVENT && snb_completed(snbuf)) { post_packet_up(bdev, type, snbuf); snbuf = bdev->eventRx = NULL; + } - } - if (type != BT_EVENT && (get_expected_size(nbuf) - nbuf->size) == 0 ) { post_packet_up(bdev, type, nbuf); @@ -141,13 +139,13 @@ if (type == BT_ACL) debugf("ACL Packet not filled size=%ld expected=%ld\n", nbuf->size, get_expected_size(nbuf)); }*/ - - /* in case in the pipe there is info about the next buffer ... */ + + /* in case in the pipe there is info about the next buffer ... */ count -= currentPacketLen; data += currentPacketLen; - } - - return B_OK; + } + + return B_OK; } @@ -163,38 +161,36 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len) #endif { - - bt_usb_dev* bdev = cookie; - status_t err; - - /* TODO: or not running anymore */ + bt_usb_dev* bdev = cookie; + status_t err; + + /* TODO: or not running anymore */ if (status == B_CANCELED) return; - if (status != B_OK || actual_len == 0) - goto resubmit; + if (status != B_OK || actual_len == 0) + goto resubmit; - if ( assembly_rx(cookie, BT_EVENT, data, actual_len) == B_OK ) { - bdev->stat.successfulTX++; - } else { - bdev->stat.errorRX++; - } - + if ( assembly_rx(cookie, BT_EVENT, data, actual_len) == B_OK ) { + bdev->stat.successfulTX++; + } else { + bdev->stat.errorRX++; + } + resubmit: - err = usb->queue_interrupt(bdev->intr_in_ep->handle, - data, bdev->max_packet_size_intr_in , - event_complete, bdev); + err = usb->queue_interrupt(bdev->intr_in_ep->handle, + data, bdev->max_packet_size_intr_in , + event_complete, bdev); - if (err != B_OK ) { - reuse_room(&bdev->eventRoom, data); - bdev->stat.rejectedRX++; - debugf("RX event resubmittion failed %s\n",strerror(err)); - } - else { - bdev->stat.acceptedRX++; - } - + if (err != B_OK) { + reuse_room(&bdev->eventRoom, data); + bdev->stat.rejectedRX++; + debugf("RX event resubmittion failed %s\n",strerror(err)); + } else { + bdev->stat.acceptedRX++; + } + } @@ -205,67 +201,64 @@ acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len) #endif { - bt_usb_dev* bdev = cookie; - status_t err; - - /* TODO: or not running anymore? */ + bt_usb_dev* bdev = cookie; + status_t err; + + /* TODO: or not running anymore? */ if (status == B_CANCELED) return; - if (status != B_OK || actual_len == 0) - goto resubmit; + if (status != B_OK || actual_len == 0) + goto resubmit; - if ( assembly_rx(cookie, BT_ACL, data, actual_len) == B_OK ) { - bdev->stat.successfulRX++; - } else { - bdev->stat.errorRX++; - } - + if (assembly_rx(cookie, BT_ACL, data, actual_len) == B_OK) { + bdev->stat.successfulRX++; + } else { + bdev->stat.errorRX++; + } + resubmit: err = usb->queue_bulk(bdev->bulk_in_ep->handle, data, - max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in), - acl_rx_complete, (void*) bdev); + max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in), + acl_rx_complete, (void*) bdev); - if (err != B_OK ) { - reuse_room(&bdev->aclRoom, data); - bdev->stat.rejectedRX++; - debugf("RX acl resubmittion failed %s\n", strerror(err)); - } - else { - bdev->stat.acceptedRX++; - } + if (err != B_OK) { + reuse_room(&bdev->aclRoom, data); + bdev->stat.rejectedRX++; + debugf("RX acl resubmittion failed %s\n", strerror(err)); + } else { + bdev->stat.acceptedRX++; + } } - #if 0 #pragma mark --- RX --- #endif - status_t submit_rx_event(bt_usb_dev* bdev) -{ - status_t status; - size_t size = bdev->max_packet_size_intr_in; - void* buf = alloc_room(&bdev->eventRoom, size); - - if (buf == NULL) - return ENOMEM; +{ + status_t status; + size_t size = bdev->max_packet_size_intr_in; + void* buf = alloc_room(&bdev->eventRoom, size); - status = usb->queue_interrupt(bdev->intr_in_ep->handle, - buf, size , - event_complete, (void*) bdev); - if (status != B_OK ) { - reuse_room(&bdev->eventRoom, buf); // reuse allocated one - bdev->stat.rejectedRX++; - } - else { - bdev->stat.acceptedRX++; - debugf("Accepted RX Event %d\n", bdev->stat.acceptedRX); - } - - return status; + if (buf == NULL) + return ENOMEM; + + status = usb->queue_interrupt(bdev->intr_in_ep->handle, + buf, size , + event_complete, (void*) bdev); + + if (status != B_OK) { + reuse_room(&bdev->eventRoom, buf); // reuse allocated one + bdev->stat.rejectedRX++; + } else { + bdev->stat.acceptedRX++; + debugf("Accepted RX Event %d\n", bdev->stat.acceptedRX); + } + + return status; } @@ -273,34 +266,32 @@ submit_rx_acl(bt_usb_dev* bdev) { - status_t status; - size_t size = max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in); - void* buf = alloc_room(&bdev->aclRoom, size); + status_t status; + size_t size = max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in); + void* buf = alloc_room(&bdev->aclRoom, size); - if (buf == NULL) - return ENOMEM; - - status = usb->queue_bulk(bdev->bulk_in_ep->handle, buf, size , - acl_rx_complete, bdev); + if (buf == NULL) + return ENOMEM; - if (status != B_OK ) { - reuse_room(&bdev->aclRoom, buf); // reuse allocated - bdev->stat.rejectedRX++; - } - else { - bdev->stat.acceptedRX++; - } - - return status; + status = usb->queue_bulk(bdev->bulk_in_ep->handle, buf, size , + acl_rx_complete, bdev); + + if (status != B_OK) { + reuse_room(&bdev->aclRoom, buf); // reuse allocated + bdev->stat.rejectedRX++; + } else { + bdev->stat.acceptedRX++; + } + + return status; } status_t submit_rx_sco(bt_usb_dev* bdev) { - - /* not yet implemented */ - return B_ERROR; + /* not yet implemented */ + return B_ERROR; } @@ -316,28 +307,26 @@ command_complete(void* cookie, status_t status, void* data, size_t actual_len) #endif { - snet_buffer* snbuf = (snet_buffer*) cookie; - bt_usb_dev* bdev = snb_cookie(snbuf); + snet_buffer* snbuf = (snet_buffer*) cookie; + bt_usb_dev* bdev = snb_cookie(snbuf); - debugf("%ld %02x:%02x:%02x:\n", actual_len, ((uint8*)data)[0],((uint8*)data)[1],((uint8*)data)[2]); + debugf("%ld %02x:%02x:%02x:\n", actual_len, ((uint8*)data)[0],((uint8*)data)[1],((uint8*)data)[2]); - if (status != B_OK) { - - bdev->stat.successfulTX++; - bdev->stat.bytesTX += actual_len; - } - else { - bdev->stat.errorTX++; - /* the packet has been lost */ - /* too late to requeue it? */ - } + if (status != B_OK) { + bdev->stat.successfulTX++; + bdev->stat.bytesTX += actual_len; + } else { + bdev->stat.errorTX++; + /* the packet has been lost */ + /* too late to requeue it? */ + } - snb_park(&bdev->snetBufferRecycleTrash, snbuf); + snb_park(&bdev->snetBufferRecycleTrash, snbuf); #ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS - // TODO: check just the empty queues? - schedTxProcessing(bdev); -#endif + // TODO: check just the empty queues? + schedTxProcessing(bdev); +#endif } @@ -347,92 +336,85 @@ #else acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len) #endif - { + net_buffer* nbuf = (net_buffer*) cookie; + bt_usb_dev* bdev = GET_DEVICE(nbuf); - net_buffer* nbuf = (net_buffer*) cookie; - bt_usb_dev* bdev = GET_DEVICE(nbuf); + if (status != B_OK) { - if (status != B_OK) { - - bdev->stat.successfulTX++; - bdev->stat.bytesTX += actual_len; - } - else { - bdev->stat.errorTX++; - /* the packet has been lost */ - /* too late to requeue it? */ - } - - nb_destroy(nbuf); + bdev->stat.successfulTX++; + bdev->stat.bytesTX += actual_len; + } else { + bdev->stat.errorTX++; + /* the packet has been lost */ + /* too late to requeue it? */ + } + + nb_destroy(nbuf); #ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS - schedTxProcessing(bdev); -#endif + schedTxProcessing(bdev); +#endif } - #if 0 #pragma mark --- TX --- #endif status_t submit_tx_command(bt_usb_dev* bdev, snet_buffer* snbuf) -{ - status_t err; - - uint8 bRequestType = bdev->ctrl_req; +{ + status_t err; + + uint8 bRequestType = bdev->ctrl_req; uint8 bRequest = 0; uint16 wIndex = 0; uint16 value = 0; uint16 wLength = B_HOST_TO_LENDIAN_INT16(snb_size(snbuf)); - if (!GET_BIT(bdev->state, RUNNING) ) { + if (!GET_BIT(bdev->state, RUNNING)) { return B_DEV_NOT_READY; } - /* set cookie */ - snb_set_cookie(snbuf, bdev); - + /* set cookie */ + snb_set_cookie(snbuf, bdev); + err = usb->queue_request(bdev->dev, bRequestType, bRequest, - value, wIndex, wLength, - snb_get(snbuf), wLength //??? - ,command_complete, (void*) snbuf); + value, wIndex, wLength, + snb_get(snbuf), wLength //??? + ,command_complete, (void*) snbuf); if (err != B_OK ) { - bdev->stat.rejectedTX++; - } - else { - bdev->stat.acceptedTX++; - } + bdev->stat.rejectedTX++; + } else { + bdev->stat.acceptedTX++; + } - return err; + return err; } status_t submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf) { - status_t err; - - /* set cookie */ - SET_DEVICE(nbuf,bdev->hdev); + status_t err; + + /* set cookie */ + SET_DEVICE(nbuf,bdev->hdev); if (!GET_BIT(bdev->state, RUNNING) ) { return B_DEV_NOT_READY; } - - err = usb->queue_bulk(bdev->bulk_out_ep->handle, - nb_get_whole_buffer(nbuf), nbuf->size, - acl_tx_complete, (void*) nbuf); - + err = usb->queue_bulk(bdev->bulk_out_ep->handle, + nb_get_whole_buffer(nbuf), nbuf->size, + acl_tx_complete, (void*) nbuf); + if (err != B_OK ) { - bdev->stat.rejectedTX++; - } - else { - bdev->stat.acceptedTX++; - } + bdev->stat.rejectedTX++; + } else { + bdev->stat.acceptedTX++; + } - return err; + return err; } @@ -440,11 +422,10 @@ submit_tx_sco(bt_usb_dev* bdev) { - if (!GET_BIT(bdev->state, RUNNING) ) { + if (!GET_BIT(bdev->state, RUNNING)) { return B_DEV_NOT_READY; } - /* not yet implemented */ - return B_ERROR; + /* not yet implemented */ + return B_ERROR; } - Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-08-04 19:10:43 UTC (rev 26802) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/snet_buffer.c 2008-08-04 20:03:23 UTC (rev 26803) @@ -13,63 +13,62 @@ struct snet_buffer { struct list_link link; - uint8* buffer; - + uint8* buffer; + uint16 allocatedSize; - uint16 expectedSize; - uint16 puttingSize; - uint16 pullingSize; + uint16 expectedSize; + uint16 puttingSize; + uint16 pullingSize; - void* cookie; - + void* cookie; + }; snet_buffer* snb_create(uint16 size) { - /* TODO: pointer checking */ + /* TODO: pointer checking */ #ifdef SNB_BUFFER_ATTACHED - /* Allocating these 2 buffers together might prevent memory fragmentation? */ - snet_buffer* snb = (snet_buffer*) malloc(sizeof(snet_buffer) + size); - snb->buffer = ((uint8*)snb) + sizeof(snet_buffer); + /* Allocating these 2 buffers together might prevent memory fragmentation? */ + snet_buffer* snb = (snet_buffer*) malloc(sizeof(snet_buffer) + size); + snb->buffer = ((uint8*)snb) + sizeof(snet_buffer); #else - snet_buffer* snb = malloc(sizeof (snet_buffer)); - snb->buffer = malloc(size); + snet_buffer* snb = malloc(sizeof (snet_buffer)); + snb->buffer = malloc(size); #endif - snb->pullingSize = snb->puttingSize = 0; - snb->expectedSize = snb->allocatedSize = size; + snb->pullingSize = snb->puttingSize = 0; + snb->expectedSize = snb->allocatedSize = size; - return snb; - + return snb; } void snb_put(snet_buffer* snb, void* data, uint16 size) { - /* TODO: check overflow */ - memcpy( &snb->buffer[snb->puttingSize], data, size); - snb->puttingSize+=size; + /* TODO: check overflow */ + memcpy( &snb->buffer[snb->puttingSize], data, size); + snb->puttingSize+=size; } void* snb_pull(snet_buffer* snb, uint16 size) { - /* TODO: check overflow */ - snb->pullingSize+=size; - return &snb->buffer[snb->pullingSize-size]; - + /* TODO: check overflow */ + snb->pullingSize+=size; + return &snb->buffer[snb->pullingSize-size]; + } inline void snb_reset(snet_buffer* snb) { - snb->puttingSize = snb->pullingSize = 0; + snb->puttingSize = snb->pullingSize = 0; } @@ -80,10 +79,10 @@ return; #ifdef SNB_BUFFER_ATTACHED - free(snb); + free(snb); #else - free(snb->buffer); - free(snb); + free(snb->buffer); + free(snb); #endif } @@ -92,90 +91,89 @@ inline void* snb_get(snet_buffer* snb) { - /* TODO: pointer checking */ - return snb->buffer; + /* TODO: pointer checking */ + return snb->buffer; } inline uint16 snb_size(snet_buffer* snb) { - /* TODO: pointer checking */ - return snb->expectedSize; + /* TODO: pointer checking */ + return snb->expectedSize; } inline void* snb_cookie(snet_buffer* snb) { - /* TODO: pointer checking */ - return snb->cookie; + /* TODO: pointer checking */ + return snb->cookie; } inline void snb_set_cookie(snet_buffer* snb, void* cookie) { - /* TODO: pointer checking */ - snb->cookie = cookie; + /* TODO: pointer checking */ + snb->cookie = cookie; } /* Return true if we canot "put" more data in the buffer */ inline bool snb_completed(snet_buffer* snb) { - return (snb->expectedSize == snb->puttingSize); + return (snb->expectedSize == snb->puttingSize); } /* Return true if we cannot pull more more data from the buffer */ inline bool snb_finished(snet_buffer* snb) { - return (snb->expectedSize == snb->pullingSize); + return (snb->expectedSize == snb->pullingSize); } inline uint16 snb_remaining_to_put(snet_buffer* snb) { - return (snb->expectedSize - snb->puttingSize); + return (snb->expectedSize - snb->puttingSize); } inline uint16 snb_remaining_to_pull(snet_buffer* snb) { - return (snb->expectedSize - snb->pullingSize); + return (snb->expectedSize - snb->pullingSize); } /* ISSUE1: Number of packets in the worst case(we always need a bigger buffer than before) increases, never decreases: - + SOL1: Delete the smallest when the queue is bigger than X elements SOL2: ? - + ISSUE2: If the queue is not gonna be used for long time. Memory c ould be freed - + SOL1: Provide purge func. SOL2: ? - + */ static snet_buffer* snb_attempt_reuse(snet_buffer* snb, uint16 size) { - if ( snb == NULL || - ((int16)snb->allocatedSize - (int16)size) < 0 ) { + if ( snb == NULL || + ((int16)snb->allocatedSize - (int16)size) < 0 ) { - /* Impossible or not worth, Creating a new one */ - snb_free(snb); - return snb_create(size); + /* Impossible or not worth, Creating a new one */ + snb_free(snb); + return snb_create(size); - } - else { - snb_reset(snb); - snb->expectedSize = size; - return snb; - } + } else { + snb_reset(snb); + snb->expectedSize = size; + return snb; + } } [... truncated: 10 lines follow ...] From oruizdorantes at mail.berlios.de Mon Aug 4 22:13:07 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Mon, 4 Aug 2008 22:13:07 +0200 Subject: [Haiku-commits] r26804 - haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200808042013.m74KD73o031920@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-04 22:13:03 +0200 (Mon, 04 Aug 2008) New Revision: 26804 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26804&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c Log: Fix gcc4 build (using __FUNCTION__), and more whitespaces cleanups... Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-08-04 20:03:23 UTC (rev 26803) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c 2008-08-04 20:13:03 UTC (rev 26804) @@ -65,7 +65,7 @@ /* Broadcom BCM2035 */ { 0, 0, 0, 0x0a5c, 0x200a }, { 0, 0, 0, 0x0a5c, 0x2009 }, - + /* Devices taken from the linux Driver */ /* AVM BlueFRITZ! USB v2.0 */ { 0, 0, 0, 0x057c , 0x3800 }, @@ -76,15 +76,15 @@ { 0, 0, 0, 0x044e , 0x3002 }, /* Ericsson with non-standard id */ { 0, 0, 0, 0x0bdb , 0x1002 } -}; +}; /* add a device to the list of connected devices */ static bt_usb_dev* spawn_device(const usb_device* usb_dev) { int32 i; - status_t err = B_OK; - bt_usb_dev* new_bt_dev = NULL; + status_t err = B_OK; + bt_usb_dev* new_bt_dev = NULL; flowf("add_device()\n"); @@ -93,7 +93,7 @@ flowf("device table full\n"); goto exit; } - + /* try the allocation */ new_bt_dev = (bt_usb_dev*)malloc(sizeof(bt_usb_dev)); if ( new_bt_dev == NULL ) { @@ -116,18 +116,18 @@ goto bail1; } - /* find a free slot and fill out the name */ - acquire_sem(dev_table_sem); + /* find a free slot and fill out the name */ + acquire_sem(dev_table_sem); for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { if (bt_usb_devices[i] == NULL) { bt_usb_devices[i] = new_bt_dev; sprintf(new_bt_dev->name, "%s/%ld", BLUETOOTH_DEVICE_PATH, i); new_bt_dev->num = i; - debugf("added device %p %ld %s\n", bt_usb_devices[i] ,new_bt_dev->num,new_bt_dev->name); + debugf("added device %p %ld %s\n", bt_usb_devices[i] ,new_bt_dev->num,new_bt_dev->name); break; } } - release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); /* In the case we cannot us */ if (bt_usb_devices[i] != new_bt_dev) { @@ -148,7 +148,7 @@ delete_sem(new_bt_dev->cmd_complete); bail0: free(new_bt_dev); -exit: +exit: return new_bt_dev; } @@ -159,13 +159,13 @@ { if (bdev != NULL) { debugf("(%p)\n", bdev); - + delete_sem(bdev->lock); delete_sem(bdev->cmd_complete); - + // mark it free bt_usb_devices[bdev->num] = NULL; - + free(bdev); dev_count--; } @@ -176,38 +176,38 @@ fetch_device(bt_usb_dev* dev, hci_id hid) { int i; - + debugf("(%p)\n", dev); - + acquire_sem(dev_table_sem); - if (dev != NULL) + if (dev != NULL) for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { /* somehow the device is still around */ if (bt_usb_devices[i] == dev) { release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); - return bt_usb_devices[i]; + return bt_usb_devices[i]; } - } + } else for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) { /* somehow the device is still around */ if (bt_usb_devices[i] != NULL && bt_usb_devices[i]->hdev == hid) { release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); - return bt_usb_devices[i]; + return bt_usb_devices[i]; } - } - + } + release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); - - return NULL; + + return NULL; } #if 0 #pragma mark - #endif -static bt_hci_transport bt_usb_hooks = +static bt_hci_transport bt_usb_hooks = { NULL, NULL, @@ -222,26 +222,26 @@ device_added(const usb_device* dev, void** cookie) { const usb_interface_info* interface; - const usb_device_descriptor* desc; + const usb_device_descriptor* desc; const usb_configuration_info* config; const usb_interface_info* uif; const usb_endpoint_info* ep; - + status_t err = B_ERROR; bt_usb_dev* new_bt_dev = spawn_device(dev); - int e; + int e; debugf("device_added(%p, %p)\n", dev, new_bt_dev); if (new_bt_dev == NULL) { flowf("Couldn't allocate device record.\n"); err = ENOMEM; - goto bail_no_mem; + goto bail_no_mem; } /* we only have 1 configuration number 0 */ config = usb->get_nth_configuration(dev, 0); - //dump_usb_configuration_info(config); + //dump_usb_configuration_info(config); if (config == NULL) { flowf("couldn't get default config.\n"); err = B_ERROR; @@ -249,11 +249,11 @@ } debugf("found %ld alt interfaces.\n", config->interface->alt_count); - + /* set first interface */ interface = &config->interface->alt[0]; err = usb->set_alt_interface(new_bt_dev->dev, interface); - + if (err != B_OK) { debugf("set_alt_interface() returned %ld.\n", err); goto bail; @@ -265,15 +265,15 @@ debugf("set_configuration() returned %ld.\n", err); goto bail; } - + /* Place to find out whats our concrete device and set up some special info to our driver */ /* TODO: if this code increases too much reconsider this implementation*/ desc = usb->get_device_descriptor(dev); - if ( desc->vendor_id == 0x0a5c && (desc->product_id == 0x200a || + if ( desc->vendor_id == 0x0a5c && (desc->product_id == 0x200a || desc->product_id == 0x2009 || desc->product_id == 0x2035 )) { new_bt_dev->driver_info = BT_WILL_NEED_A_RESET | BT_SCO_NOT_WORKING; - } + } /* else if ( desc->vendor_id == YOUR_VENDOR_HERE && desc->product_id == YOUR_PRODUCT_HERE ) { YOUR_SPECIAL_FLAGS_HERE @@ -284,28 +284,28 @@ err = ENODEV; goto bail; } - + // security check if (config->interface->active->descr->interface_number > 0){ debugf("Strange condition happened %d\n", config->interface->active->descr->interface_number); err = B_ERROR; goto bail; } - - debugf("Found %ld interfaces. Expected 3\n", config->interface_count); + + debugf("Found %ld interfaces. Expected 3\n", config->interface_count); /* Find endpoints that we need */ uif = config->interface->active; for (e = 0; e < uif->descr->num_endpoints; e++) { ep = &uif->endpoint[e]; - switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) + switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) { case USB_ENDPOINT_ATTR_INTERRUPT: - if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) + if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) { new_bt_dev->intr_in_ep = ep; new_bt_dev->max_packet_size_intr_in = ep->descr->max_packet_size; - flowf("INT in\n"); + flowf("INT in\n"); } else { flowf("INT out\n"); } @@ -324,7 +324,7 @@ break; } } - + if (!new_bt_dev->bulk_in_ep || !new_bt_dev->bulk_out_ep || !new_bt_dev->intr_in_ep) { flowf("Minimal # endpoints for BT not found\n"); goto bail; @@ -340,13 +340,13 @@ /* set the cookie that will be passed to other USB hook functions (currently device_removed() is the only other) */ - *cookie = new_bt_dev; - debugf("Ok %p\n",bt_usb_devices[0]); + *cookie = new_bt_dev; + debugf("Ok %p\n",bt_usb_devices[0]); return B_OK; -bail: +bail: kill_device(new_bt_dev); -bail_no_mem: +bail_no_mem: *cookie = NULL; return err; @@ -358,16 +358,16 @@ device_removed(void* cookie) { bt_usb_dev* bdev = (bt_usb_dev*) fetch_device(cookie, 0); - + debugf("device_removed(%p)\n", bdev); - if (bdev == NULL) { + if (bdev == NULL) { flowf(" not present in driver??\n"); return B_ERROR; } if (!TEST_AND_CLEAR(&bdev->state, RUNNING) ) { - flowf(" wasnt running??\n"); + flowf(" wasnt running??\n"); } @@ -376,24 +376,24 @@ usb->cancel_queued_transfers(bdev->intr_in_ep->handle); flowf("Cancelling impossible EVENTS\n"); } - + if (bdev->bulk_in_ep!=NULL) { usb->cancel_queued_transfers(bdev->bulk_in_ep->handle); flowf("Cancelling impossible ACL in\n"); } - + if (bdev->bulk_out_ep!=NULL) { usb->cancel_queued_transfers(bdev->bulk_out_ep->handle); flowf("Cancelling impossible ACL out\n"); } - + bdev->connected = false; return B_OK; } -static usb_notify_hooks notify_hooks = +static usb_notify_hooks notify_hooks = { &device_added, &device_removed @@ -411,7 +411,7 @@ bt_usb_dev* bdev = NULL; hci_id hdev; int i; - + flowf("device_open()\n"); acquire_sem(dev_table_sem); @@ -422,21 +422,21 @@ } } release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); - + if (bdev == NULL) { flowf("Device not found in the open list!"); *cookie = NULL; return B_ERROR; - } - + } + // Set RUNNING if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) { flowf("dev already running! - reOpened device!\n"); return B_ERROR; - } + } acquire_sem(bdev->lock); - // TX structures + // TX structures for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { list_init(&bdev->nbuffersTx[i]); bdev->nbuffersPendingTx[i] = 0; @@ -448,7 +448,7 @@ bdev->nbufferRx[i] = NULL; } - // dumping the USB frames + // dumping the USB frames init_room(&bdev->eventRoom); init_room(&bdev->aclRoom); //init_room(new_bt_dev->scoRoom); @@ -489,44 +489,44 @@ int32 i; void* item; bt_usb_dev* bdev = (bt_usb_dev*)cookie; - + if (bdev == NULL) panic("bad cookie"); - + debugf("device_close() called on %ld\n", bdev->hdev ); // Clean queues - + // TX for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) { if (i == BT_COMMAND) while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { - snb_free(item); + snb_free(item); } else while ((item = list_remove_head_item(&bdev->nbuffersTx[i])) != NULL) { - nb_destroy(item); + nb_destroy(item); } - + } // RX for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) { - nb_destroy(bdev->nbufferRx[i]); + nb_destroy(bdev->nbufferRx[i]); } snb_free(bdev->eventRx); - + purge_room(&bdev->eventRoom); purge_room(&bdev->aclRoom); - + /* Device no longer in our Stack*/ if (btDevices != NULL) btDevices->uninit_device(bdev->ndev); // unSet RUNNING - if (TEST_AND_CLEAR(&bdev->state, RUNNING)) { + if (TEST_AND_CLEAR(&bdev->state, RUNNING)) { debugf(" %s not running??\n",bdev->name); return B_ERROR; - } + } return B_OK; } @@ -539,19 +539,19 @@ { status_t err = B_OK; bt_usb_dev* bdev = (bt_usb_dev*)cookie; - + debugf("device_free() called on %s \n",BLUETOOTH_DEVICE_PATH); - + if (--bdev->open_count == 0) { /* GotoLowPower */ // interesting ..... } else { /* The last client has closed, and the device is no longer - connected, so remove it from the list. */ + connected, so remove it from the list. */ } - + kill_device(bdev); return err; @@ -568,10 +568,10 @@ #if BT_DRIVER_SUPPORTS_ACL // ACL int32 i; #endif - + TOUCH(size); debugf("ioctl() opcode %ld size %ld.\n", msg, size); - + if (bdev == NULL) { flowf("Bad cookie\n"); return B_BAD_VALUE; @@ -581,30 +581,30 @@ flowf("Invalid pointer control\n"); return B_BAD_VALUE; } - + acquire_sem(bdev->lock); - + switch (msg) { case ISSUE_BT_COMMAND: -#ifdef BT_IOCTLS_PASS_SIZE +#ifdef BT_IOCTLS_PASS_SIZE if (size == 0) { flowf("Invalid size control\n"); - err = B_BAD_VALUE; + err = B_BAD_VALUE; break; } #else size = (*((size_t*)params)); (*(size_t**)¶ms)++; -#endif - +#endif + // TODO: Reuse from some TXcompleted queue snbuf = snb_create(size); snb_put(snbuf, params, size); - + err = submit_tx_command(bdev, snbuf); debugf("device launched %ld\n", err); break; - + case BT_UP: // EVENTS @@ -614,7 +614,7 @@ flowf("Queuing failed device stops running\n"); break; } - + #if BT_DRIVER_SUPPORTS_ACL // ACL for (i = 0; i < MAX_ACL_IN_WINDOW; i++) { err = submit_rx_acl(bdev); @@ -625,15 +625,15 @@ } } #endif - + SET_BIT(bdev->state, RUNNING); - + #if BT_DRIVER_SUPPORTS_SCO // TODO: SCO / eSCO #endif flowf("device launched\n"); break; - + case GET_STATS: memcpy(params, &bdev->stat, sizeof(bt_hci_statistics)); err = B_OK; @@ -642,15 +642,15 @@ case GET_HCI_ID: *(hci_id*)params = bdev->hdev; err = B_OK; - break; + break; - + default: debugf("Invalid opcode %ld.\n", msg); err = B_DEV_INVALID_IOCTL; break; } - + release_sem(bdev->lock); return err; } @@ -672,7 +672,7 @@ device_write(void *cookie, off_t pos, const void *buf, size_t *count) { flowf("device_write()\n"); - + return B_ERROR; } @@ -686,14 +686,14 @@ { int j; flowf("init_driver()\n"); - + // BT devices MODULE INITS if (get_module(btDevices_name,(module_info**)&btDevices) != B_OK) { debugf("cannot get module \"%s\"\n", btDevices_name); return B_ERROR; } else - debugf("btDevices module at %p\n", btDevices); + debugf("btDevices module at %p\n", btDevices); // HCI MODULE INITS @@ -703,10 +703,10 @@ return err_release2; #endif } else { - debugf("hci module at %p\n", hci); + debugf("hci module at %p\n", hci); } - - // USB MODULE INITS + + // USB MODULE INITS if (get_module(usb_name,(module_info**)&usb) != B_OK) { debugf("cannot get module \"%s\"\n", usb_name); goto err_release1; @@ -718,33 +718,33 @@ debugf("cannot get module \"%s\"\n", NET_BUFFER_MODULE_NAME); #ifndef BT_SURVIVE_WITHOUT_NET_BUFFERS goto err_release; -#endif +#endif } else { debugf("nb module at %p\n", nb); } - + // GENERAL INITS dev_table_sem = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "dev_table_lock"); if (dev_table_sem < 0) { goto err; } - + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { bt_usb_devices[j] = NULL; } - - /* After here device_added and publish devices hooks are called + + /* After here device_added and publish devices hooks are called be carefull USB devs */ usb->register_driver(BLUETOOTH_DEVICE_DEVFS_NAME, supported_devices, 1, NULL); usb->install_notify(BLUETOOTH_DEVICE_DEVFS_NAME, ¬ify_hooks); return B_OK; - -err: // Releasing + +err: // Releasing put_module(NET_BUFFER_MODULE_NAME); -err_release: +err_release: put_module(usb_name); -err_release1: +err_release1: put_module(hci_name); err_release2: put_module(btDevices_name); @@ -757,14 +757,14 @@ uninit_driver(void) { int32 j; - + flowf("uninit_driver()\n"); - + for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { - if (publish_names[j] != NULL) + if (publish_names[j] != NULL) free(publish_names[j]); - + if (bt_usb_devices[j] != NULL) { // if (connected_dev != NULL) { // debugf("Device %p still exists.\n", connected_dev); @@ -773,14 +773,14 @@ kill_device(bt_usb_devices[j]); } } - + usb->uninstall_notify(BLUETOOTH_DEVICE_DEVFS_NAME); - + /* Releasing modules */ put_module(usb_name); put_module(hci_name); // TODO: netbuffers - + delete_sem(dev_table_sem); } @@ -792,7 +792,7 @@ int32 i = 0; char* str; - + flowf("publish_devices()\n"); for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { @@ -801,7 +801,7 @@ publish_names[j] = NULL; } } - + acquire_sem(dev_table_sem); for (j = 0; j < MAX_BT_GENERIC_USB_DEVICES; j++) { if (bt_usb_devices[j] != NULL && bt_usb_devices[j]->connected) { @@ -813,11 +813,11 @@ } } release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE); - + publish_names[i] = NULL; debugf("published %ld devices\n", i); -// TODO: this method might make better memory use +// TODO: this method might make better memory use // dev_names = (char**)malloc(sizeof (char*) * (dev_count+1)); // if (dev_names) { // for (i = 0; i < MAX_NUM_DEVS; i++) { @@ -827,7 +827,7 @@ // debugf("publishing \"%s\"\n", dev_names[i]); // } // } - + return (const char**)publish_names; } @@ -850,6 +850,6 @@ find_device(const char* name) { debugf("find_device(%s)\n", name); - + return &hooks; } Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-08-04 20:03:23 UTC (rev 26803) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c 2008-08-04 20:13:03 UTC (rev 26804) @@ -37,17 +37,17 @@ #endif -static status_t +static status_t assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count) { net_buffer* nbuf = NULL; snet_buffer* snbuf = NULL; - + size_t currentPacketLen = 0; size_t expectedPacketLen = 0; bdev->stat.bytesRX += count; - + if (type == BT_EVENT) snbuf = bdev->eventRx; else @@ -55,7 +55,7 @@ while (count) { - debugf("count %d nb=%p sb=%p type=%d\n",count, nbuf, snbuf, type); + debugf("count %d nb=%p sb=%p type=%d\n",count, nbuf, snbuf, type); if ( (type != BT_EVENT && nbuf == NULL) || (type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) { @@ -64,24 +64,24 @@ switch (type) { case BT_EVENT: if (count >= HCI_EVENT_HDR_SIZE) { - + struct hci_event_header* headerPkt = data; expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen; snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen); - + } else { flowf("EVENT frame corrupted\n"); return -EILSEQ; } break; - + case BT_ACL: if (count >= HCI_ACL_HDR_SIZE) { int16 index; struct hci_acl_header* headerPkt = data; expectedPacketLen = HCI_ACL_HDR_SIZE + B_LENDIAN_TO_HOST_INT16(headerPkt->alen); - + /* Create the buffer */ bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen); // TODO: this allocation can fail!! @@ -98,11 +98,11 @@ return -EILSEQ; } break; - + case BT_SCO: break; - + default: panic("unkown packet type in assembly"); break; @@ -122,7 +122,7 @@ if (type == BT_EVENT) snb_put(snbuf, data, currentPacketLen); - else + else nb->append(nbuf, data, currentPacketLen); /* Complete frame? */ @@ -141,7 +141,7 @@ }*/ /* in case in the pipe there is info about the next buffer ... */ - count -= currentPacketLen; + count -= currentPacketLen; data += currentPacketLen; } @@ -163,7 +163,7 @@ { bt_usb_dev* bdev = cookie; status_t err; - + /* TODO: or not running anymore */ if (status == B_CANCELED) return; @@ -176,11 +176,11 @@ } else { bdev->stat.errorRX++; } - + resubmit: - err = usb->queue_interrupt(bdev->intr_in_ep->handle, - data, bdev->max_packet_size_intr_in , + err = usb->queue_interrupt(bdev->intr_in_ep->handle, + data, bdev->max_packet_size_intr_in , event_complete, bdev); if (err != B_OK) { @@ -219,8 +219,8 @@ resubmit: - err = usb->queue_bulk(bdev->bulk_in_ep->handle, data, - max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in), + err = usb->queue_bulk(bdev->bulk_in_ep->handle, data, + max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in), acl_rx_complete, (void*) bdev); if (err != B_OK) { @@ -246,8 +246,8 @@ if (buf == NULL) return ENOMEM; - status = usb->queue_interrupt(bdev->intr_in_ep->handle, - buf, size , + status = usb->queue_interrupt(bdev->intr_in_ep->handle, + buf, size , event_complete, (void*) bdev); if (status != B_OK) { @@ -290,7 +290,7 @@ status_t submit_rx_sco(bt_usb_dev* bdev) { - /* not yet implemented */ + /* not yet implemented */ return B_ERROR; } @@ -308,7 +308,7 @@ #endif { snet_buffer* snbuf = (snet_buffer*) cookie; - bt_usb_dev* bdev = snb_cookie(snbuf); + bt_usb_dev* bdev = snb_cookie(snbuf); debugf("%ld %02x:%02x:%02x:\n", actual_len, ((uint8*)data)[0],((uint8*)data)[1],((uint8*)data)[2]); @@ -323,7 +323,7 @@ snb_park(&bdev->snetBufferRecycleTrash, snbuf); -#ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS +#ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS // TODO: check just the empty queues? schedTxProcessing(bdev); #endif @@ -338,11 +338,11 @@ #endif { net_buffer* nbuf = (net_buffer*) cookie; - bt_usb_dev* bdev = GET_DEVICE(nbuf); + bt_usb_dev* bdev = GET_DEVICE(nbuf); if (status != B_OK) { - bdev->stat.successfulTX++; + bdev->stat.successfulTX++; bdev->stat.bytesTX += actual_len; } else { bdev->stat.errorTX++; @@ -351,7 +351,7 @@ } nb_destroy(nbuf); -#ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS +#ifdef BT_RESCHEDULING_AFTER_COMPLETITIONS schedTxProcessing(bdev); #endif } @@ -364,10 +364,10 @@ submit_tx_command(bt_usb_dev* bdev, snet_buffer* snbuf) { status_t err; - + uint8 bRequestType = bdev->ctrl_req; - uint8 bRequest = 0; - uint16 wIndex = 0; + uint8 bRequest = 0; + uint16 wIndex = 0; uint16 value = 0; uint16 wLength = B_HOST_TO_LENDIAN_INT16(snb_size(snbuf)); @@ -377,18 +377,18 @@ /* set cookie */ snb_set_cookie(snbuf, bdev); - + err = usb->queue_request(bdev->dev, bRequestType, bRequest, - value, wIndex, wLength, + value, wIndex, wLength, snb_get(snbuf), wLength //??? ,command_complete, (void*) snbuf); - + if (err != B_OK ) { bdev->stat.rejectedTX++; } else { bdev->stat.acceptedTX++; } - + return err; } @@ -396,7 +396,7 @@ submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf) { status_t err; - + /* set cookie */ SET_DEVICE(nbuf,bdev->hdev); @@ -404,7 +404,7 @@ return B_DEV_NOT_READY; } - err = usb->queue_bulk(bdev->bulk_out_ep->handle, + err = usb->queue_bulk(bdev->bulk_out_ep->handle, nb_get_whole_buffer(nbuf), nbuf->size, acl_tx_complete, (void*) nbuf); @@ -426,6 +426,6 @@ return B_DEV_NOT_READY; } - /* not yet implemented */ + /* not yet implemented */ return B_ERROR; } Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-08-04 20:03:23 UTC (rev 26803) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.c 2008-08-04 20:13:03 UTC (rev 26804) @@ -29,7 +29,7 @@ // !!! it could be trash from other upper protocols... if (nbuf->COOKIEFIELD != NULL) return (void*)nbuf->COOKIEFIELD; -#endif +#endif err = nb->direct_access(nbuf, 0, nbuf->size, &conPointer); if (err != B_OK) { @@ -39,17 +39,17 @@ nbuf->COOKIEFIELD = (uint32) malloc(nbuf->size); if (nbuf->COOKIEFIELD == NULL) goto fail; - + err = nb->write(nbuf, 0, (void*) nbuf->COOKIEFIELD, nbuf->size); if (err != B_OK) goto free; - + conPointer = (void*)nbuf->COOKIEFIELD; #endif } return conPointer; -#if 0 +#if 0 free: free((void*) nbuf->COOKIEFIELD); fail: @@ -71,7 +71,7 @@ [... truncated: 85 lines follow ...] From leavengood at gmail.com Mon Aug 4 22:15:38 2008 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 4 Aug 2008 16:15:38 -0400 Subject: [Haiku-commits] r26683 - haiku/trunk/src/tests/servers/app/benchmark In-Reply-To: References: <14524671180-BeMail@zon> <20080730133754.5512.8@stippis2.1217403757.fake> Message-ID: On Wed, Jul 30, 2008 at 2:15 PM, Rene Gollent wrote: > > I might be able to help shed some light here...the main reason > Dano/Zeta's app_server has very heavily optimized region code is > because it was used to handle completely arbitrary window shapes (see > mmu_man's clock application that's clipped to the shape of the clock > including holes and everything for an example of just how arbitrary is > possible). This often required maintaining relatively complex window > regions, especially for curved windows, hence a lot of effort was > invested into that code. Unfortunately I don't remember much about its > implementation apart from it using skiplists. I for one would very much like to have arbitrary window shapes in Haiku eventually. Though I think pushing that out to an R2 feature would be fine. I never knew Dano and Zeta supported that, pretty cool. Though I don't like some of the crazy ways people use that feature in Windows, I do think it is used nicely on the Mac, even if just for rounded edges on some windows. Ryan From stippi at mail.berlios.de Mon Aug 4 23:16:13 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 23:16:13 +0200 Subject: [Haiku-commits] r26805 - haiku/trunk/src/kits/storage Message-ID: <200808042116.m74LGDLc004723@sheep.berlios.de> Author: stippi Date: 2008-08-04 23:16:11 +0200 (Mon, 04 Aug 2008) New Revision: 26805 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26805&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: * Move the LockLooper() call before PathHandler::Quit() into Quit(). * The B_QUIT_REQUESTED message never arrived for me unless I unlock the BLooper again, then it works as expected. * The B_QUIT_REQUESTED handling accessed fOwnsLooper after deleting the object. (Review much welcome - I don't understand the purpose of locking the BLooper at all before trying to use a BMessenger to send it a message.) Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 20:13:03 UTC (rev 26804) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-04 21:16:11 UTC (rev 26805) @@ -212,8 +212,13 @@ void PathHandler::Quit() { + if (!LockLooper()) + return; + BMessenger me(this); me.SendMessage(B_QUIT_REQUESTED); + + UnlockLooper(); } @@ -484,13 +489,16 @@ case B_QUIT_REQUESTED: { BLooper* looper = Looper(); + bool ownsLooper = fOwnsLooper; stop_watching(this); looper->RemoveHandler(this); delete this; - if (fOwnsLooper) + if (ownsLooper) { + looper->Lock(); looper->Quit(); + } return; } @@ -833,8 +841,7 @@ PathHandler* handler = i->second; watcher->handlers.erase(i); - if (handler->LockLooper()) - handler->Quit(); + handler->Quit(); if (watcher->handlers.empty()) { sWatchers.erase(iterator); @@ -863,8 +870,7 @@ PathHandler* handler = i->second; watcher->handlers.erase(i); - if (handler->LockLooper()) - handler->Quit(); + handler->Quit(); } sWatchers.erase(iterator); From bonefish at mail.berlios.de Mon Aug 4 23:45:52 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 23:45:52 +0200 Subject: [Haiku-commits] r26806 - haiku/trunk/headers/private/kernel/arch/x86 Message-ID: <200808042145.m74Ljq8D007016@sheep.berlios.de> Author: bonefish Date: 2008-08-04 23:45:50 +0200 (Mon, 04 Aug 2008) New Revision: 26806 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26806&view=rev Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h Log: Added comment. Modified: haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-04 21:16:11 UTC (rev 26805) +++ haiku/trunk/headers/private/kernel/arch/x86/arch_cpu.h 2008-08-04 21:45:50 UTC (rev 26806) @@ -153,6 +153,9 @@ uint32 eip; uint32 cs; uint32 flags; + + // user_esp and user_ss are only present when the iframe is a userland + // iframe (IFRAME_IS_USER()). A kernel iframe is shorter. uint32 user_esp; uint32 user_ss; }; From bonefish at mail.berlios.de Mon Aug 4 23:47:39 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 23:47:39 +0200 Subject: [Haiku-commits] r26807 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200808042147.m74Lldos007149@sheep.berlios.de> Author: bonefish Date: 2008-08-04 23:47:37 +0200 (Mon, 04 Aug 2008) New Revision: 26807 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26807&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp Log: * Also print whether an iframe is a userland or kernel iframe. * In case of a kernel iframe the iframe is shorter -- fixed the output accordingly. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-08-04 21:45:50 UTC (rev 26806) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp 2008-08-04 21:47:37 UTC (rev 26807) @@ -152,14 +152,16 @@ static void print_iframe(struct iframe *frame) { - kprintf("iframe at %p (end = %p)\n", frame, frame + 1); + bool isUser = IFRAME_IS_USER(frame); + kprintf("%s iframe at %p (end = %p)\n", isUser ? "user" : "kernel", frame, + isUser ? (uint32*)(frame + 1) : &frame->user_esp); kprintf(" eax 0x%-9lx ebx 0x%-9lx ecx 0x%-9lx edx 0x%lx\n", frame->eax, frame->ebx, frame->ecx, frame->edx); kprintf(" esi 0x%-9lx edi 0x%-9lx ebp 0x%-9lx esp 0x%lx\n", frame->esi, frame->edi, frame->ebp, frame->esp); kprintf(" eip 0x%-9lx eflags 0x%-9lx", frame->eip, frame->flags); - if ((frame->error_code & 0x4) != 0) { + if (isUser) { // from user space kprintf("user esp 0x%lx", frame->user_esp); } From bonefish at mail.berlios.de Mon Aug 4 23:49:12 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 23:49:12 +0200 Subject: [Haiku-commits] r26808 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200808042149.m74LnCXr007422@sheep.berlios.de> Author: bonefish Date: 2008-08-04 23:49:11 +0200 (Mon, 04 Aug 2008) New Revision: 26808 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26808&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Log: arch_setup_signal_frame(): panic() if we don't have a user iframe. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-04 21:47:37 UTC (rev 26807) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-04 21:49:11 UTC (rev 26808) @@ -170,7 +170,7 @@ // the one we're switching to is kernel space return i386_translation_map_get_pgdir(&vm_kernel_address_space()->translation_map); } - + return i386_translation_map_get_pgdir(&to->team->address_space->translation_map); } @@ -439,6 +439,11 @@ int signal, int signalMask) { struct iframe *frame = get_current_iframe(); + if (!IFRAME_IS_USER(frame)) { + panic("arch_setup_signal_frame(): No user iframe!"); + return B_BAD_VALUE; + } + uint32 *signalCode; uint32 *userRegs; struct vregs regs; @@ -473,7 +478,7 @@ regs._reserved_2[1] = frame->esi; regs._reserved_2[2] = frame->ebp; i386_fnsave((void *)(®s.xregs)); - + userStack -= (sizeof(struct vregs) + 3) / 4; userRegs = userStack; status = user_memcpy(userRegs, ®s, sizeof(regs)); From stippi at mail.berlios.de Mon Aug 4 23:51:35 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 4 Aug 2008 23:51:35 +0200 Subject: [Haiku-commits] r26809 - haiku/trunk/src/apps/text_search Message-ID: <200808042151.m74LpZ0v007641@sheep.berlios.de> Author: stippi Date: 2008-08-04 23:51:33 +0200 (Mon, 04 Aug 2008) New Revision: 26809 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26809&view=rev Added: haiku/trunk/src/apps/text_search/ChangesIterator.cpp haiku/trunk/src/apps/text_search/ChangesIterator.h haiku/trunk/src/apps/text_search/InitialIterator.cpp haiku/trunk/src/apps/text_search/InitialIterator.h Removed: haiku/trunk/src/apps/text_search/FolderIterator.cpp haiku/trunk/src/apps/text_search/FolderIterator.h Modified: haiku/trunk/src/apps/text_search/GrepListView.cpp haiku/trunk/src/apps/text_search/GrepListView.h haiku/trunk/src/apps/text_search/GrepWindow.cpp haiku/trunk/src/apps/text_search/GrepWindow.h haiku/trunk/src/apps/text_search/Grepper.cpp haiku/trunk/src/apps/text_search/Jamfile haiku/trunk/src/apps/text_search/Model.h Log: Finished implementing and enabled node monitoring on the folders and files of the current search. If new files match the pattern, the appear in the results, or are removed if they don't match anymore. The results also adapt to changes in the files. Basically, I added another iterator that is also used to track changes when node monitor events arrive. Only those changed files are grepped again after a timeout of .5 seconds when no new node monitor events pour in. Added: haiku/trunk/src/apps/text_search/ChangesIterator.cpp =================================================================== --- haiku/trunk/src/apps/text_search/ChangesIterator.cpp 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/ChangesIterator.cpp 2008-08-04 21:51:33 UTC (rev 26809) @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * All rights reserved. Distributed under the terms of the MIT license. + */ + +#include "ChangesIterator.h" + +#include +#include +#include + +#include + +#include "Model.h" + +using std::nothrow; + +ChangesIterator::ChangesIterator(const Model* model) + : FileIterator(), + fPathMap(), + fIteratorIndex(0), + + fRecurseDirs(model->fRecurseDirs), + fRecurseLinks(model->fRecurseLinks), + fSkipDotDirs(model->fSkipDotDirs), + fTextOnly(model->fTextOnly) +{ +} + + +ChangesIterator::~ChangesIterator() +{ +} + + +bool +ChangesIterator::IsValid() const +{ + return fPathMap.InitCheck() == B_OK; +} + + +bool +ChangesIterator::GetNextName(char* buffer) +{ + // TODO: inefficient + PathMap::Iterator iterator = fPathMap.GetIterator(); + int32 index = 0; + while (index < fIteratorIndex && iterator.HasNext()) + iterator.Next(); + + if (iterator.HasNext()) { + const PathMap::Entry& entry = iterator.Next(); + sprintf(buffer, "%s", entry.key.GetString()); + + fIteratorIndex++; + return true; + } + + return false; +} + + +bool +ChangesIterator::NotifyNegatives() const +{ + return true; +} + + +// #pragma mark - + + +void +ChangesIterator::EntryAdded(const char* path) +{ + HashString key(path); + if (fPathMap.ContainsKey(key)) + return; + + fPathMap.Put(key, ENTRY_ADDED); +} + + +void +ChangesIterator::EntryRemoved(const char* path) +{ + HashString key(path); + if (fPathMap.ContainsKey(key)) { + uint32 mode = fPathMap.Get(key); + if (mode == ENTRY_ADDED) + fPathMap.Remove(key); + else if (mode != ENTRY_REMOVED) + fPathMap.Put(key, ENTRY_REMOVED); + } else + fPathMap.Put(key, ENTRY_REMOVED); +} + + +void +ChangesIterator::EntryChanged(const char* path) +{ + HashString key(path); + if (fPathMap.ContainsKey(key) && fPathMap.Get(key) == ENTRY_ADDED) + return; + + fPathMap.Put(key, ENTRY_CHANGED); +} Added: haiku/trunk/src/apps/text_search/ChangesIterator.h =================================================================== --- haiku/trunk/src/apps/text_search/ChangesIterator.h 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/ChangesIterator.h 2008-08-04 21:51:33 UTC (rev 26809) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef CHANGES_ITERATOR_H +#define CHANGES_ITERATOR_H + +#include +#include + +#include "FileIterator.h" + +class BEntry; +class BDirectory; +class Model; + +class ChangesIterator : public FileIterator { +public: + ChangesIterator(const Model* model); + virtual ~ChangesIterator(); + + virtual bool IsValid() const; + virtual bool GetNextName(char* buffer); + virtual bool NotifyNegatives() const; + +public: + void EntryAdded(const char* path); + void EntryRemoved(const char* path); + void EntryChanged(const char* path); + +private: + typedef HashMap PathMap; + enum { + ENTRY_ADDED = 0, + ENTRY_REMOVED, + ENTRY_CHANGED + }; + + PathMap fPathMap; + int32 fIteratorIndex; + + bool fRecurseDirs : 1; + bool fRecurseLinks : 1; + bool fSkipDotDirs : 1; + bool fTextOnly : 1; +}; + +#endif // CHANGES_ITERATOR_H Deleted: haiku/trunk/src/apps/text_search/FolderIterator.cpp Deleted: haiku/trunk/src/apps/text_search/FolderIterator.h Modified: haiku/trunk/src/apps/text_search/GrepListView.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepListView.cpp 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/GrepListView.cpp 2008-08-04 21:51:33 UTC (rev 26809) @@ -40,3 +40,21 @@ B_WILL_DRAW | B_NAVIGABLE) { } + + +ResultItem* +GrepListView::FindItem(const entry_ref& ref, int32* _index) const +{ + int32 count = FullListCountItems(); + for (int32 i = 0; i < count; i++) { + ResultItem* item = dynamic_cast(FullListItemAt(i)); + if (item == NULL) + continue; + if (item->ref == ref) { + *_index = i; + return item; + } + } + *_index = -1; + return NULL; +} Modified: haiku/trunk/src/apps/text_search/GrepListView.h =================================================================== --- haiku/trunk/src/apps/text_search/GrepListView.h 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/GrepListView.h 2008-08-04 21:51:33 UTC (rev 26809) @@ -38,6 +38,9 @@ class GrepListView : public BOutlineListView { public: GrepListView(); + + ResultItem* FindItem(const entry_ref& ref, + int32* _index) const; }; #endif // GREP_LIST_VIEW_H Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-04 21:51:33 UTC (rev 26809) @@ -33,20 +33,24 @@ #include #include #include +#include #include #include #include #include #include -#include "FolderIterator.h" +#include "ChangesIterator.h" #include "GlobalDefs.h" #include "Grepper.h" +#include "InitialIterator.h" #include "Translation.h" using std::nothrow; +static const bigtime_t kChangesPulseInterval = 500000; + GrepWindow::GrepWindow(BMessage* message) : BWindow(BRect(0, 0, 1, 1), NULL, B_DOCUMENT_WINDOW, 0), fSearchText(NULL), @@ -86,8 +90,10 @@ fGrepper(NULL), fOldPattern(""), - fModel(new (nothrow) Model()), + fLastNodeMonitorEvent(system_time()), + fChangesIterator(NULL), + fChangesPulse(NULL), fFilePanel(NULL) { @@ -225,6 +231,10 @@ _OnNodeMonitorEvent(message); break; + case MSG_NODE_MONITOR_PULSE: + _OnNodeMonitorPulse(); + break; + case MSG_REPORT_FILE_NAME: _OnReportFileName(message); break; @@ -672,6 +682,8 @@ void GrepWindow::_StartNodeMonitoring() { + _StopNodeMonitoring(); + BMessenger messenger(this); uint32 fileFlags = B_WATCH_NAME | B_WATCH_STAT; uint32 dirFlags = B_WATCH_DIRECTORY | B_WATCH_NAME; @@ -679,11 +691,11 @@ // watch the top level folder BPath path(&fModel->fDirectory); if (path.InitCheck() == B_OK) { -printf("start monitoring root folder: %s\n", path.Path()); +//printf("start monitoring root folder: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags, messenger); } - FolderIterator iterator(fModel); + InitialIterator iterator(fModel); BEntry entry; while (iterator.GetTopEntry(entry)) { @@ -691,17 +703,23 @@ if (entry.IsDirectory()) { // subfolder if (iterator.FollowSubdir(entry)) { -printf("start monitoring folder: %s\n", path.Path()); +//printf("start monitoring folder: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags | B_WATCH_RECURSIVELY, messenger); } } else { // regular file -printf("start monitoring file: %s\n", path.Path()); +//printf("start monitoring file: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), fileFlags, messenger); } } + + if (fChangesPulse == NULL) { + BMessage message(MSG_NODE_MONITOR_PULSE); + fChangesPulse = new BMessageRunner(BMessenger(this), &message, + kChangesPulseInterval); + } } @@ -709,6 +727,10 @@ GrepWindow::_StopNodeMonitoring() { BPrivate::BPathMonitor::StopWatching(BMessenger(this)); + delete fChangesIterator; + fChangesIterator = NULL; + delete fChangesPulse; + fChangesPulse = NULL; } @@ -721,13 +743,13 @@ _StopNodeMonitoring(); if (fModel->fState == STATE_IDLE) { - fModel->fState = STATE_SEARCH; + fSearchResults->MakeEmpty(); - fSearchResults->MakeEmpty(); - if (fSearchText->TextView()->TextLength() == 0) return; + fModel->fState = STATE_SEARCH; + fModel->AddToHistory(fSearchText->Text()); // From now on, we don't want to be notified when the @@ -756,7 +778,7 @@ fOldPattern = fSearchText->Text(); - FileIterator* iterator = new (nothrow) FolderIterator(fModel); + FileIterator* iterator = new (nothrow) InitialIterator(fModel); fGrepper = new (nothrow) Grepper(fOldPattern.String(), fModel, this, iterator); if (fGrepper != NULL && fGrepper->IsValid()) @@ -770,7 +792,7 @@ delete fGrepper; fGrepper = NULL; } - fModel->fState = STATE_CANCEL; + fModel->fState = STATE_IDLE; // TODO: better notification to user fprintf(stderr, "Out of memory.\n"); } @@ -786,7 +808,7 @@ { fModel->fState = STATE_IDLE; -// _StartNodeMonitoring(); + _StartNodeMonitoring(); delete fGrepper; fGrepper = NULL; @@ -816,39 +838,102 @@ if (message->FindInt32("opcode", &opCode) != B_OK) return; + if (fChangesIterator == NULL) { + fChangesIterator = new (nothrow) ChangesIterator(fModel); + if (fChangesIterator == NULL || !fChangesIterator->IsValid()) { + delete fChangesIterator; + fChangesIterator = NULL; + } + } + switch (opCode) { case B_ENTRY_CREATED: -printf("B_ENTRY_CREATED\n"); - break; case B_ENTRY_REMOVED: -printf("B_ENTRY_REMOVED\n"); + { + const char* name; + BString path; + if (message->FindString("path", &path) == B_OK + && message->FindString("name", &name) == B_OK) { + path << '/' << name; + if (opCode == B_ENTRY_CREATED) + fChangesIterator->EntryAdded(path.String()); + else + fChangesIterator->EntryRemoved(path.String()); + } break; + } case B_ENTRY_MOVED: printf("B_ENTRY_MOVED\n"); +message->PrintToStream(); + // TODO: If the path is now outside the folder hierarchy, it's just + // a "removed" entry. If the move happened within the hierarchy, + // it should be a combined removed/added event. break; case B_STAT_CHANGED: -printf("B_STAT_CHANGED\n"); + { + BString path; + if (message->FindString("path", &path) == B_OK) + fChangesIterator->EntryChanged(path.String()); break; - case B_ATTR_CHANGED: -printf("B_ATTR_CHANGED\n"); - break; + } default: -printf("unkown opcode\n"); break; } - message->PrintToStream(); + fLastNodeMonitorEvent = system_time(); } void +GrepWindow::_OnNodeMonitorPulse() +{ + if (fChangesIterator == NULL) + return; + + if (system_time() - fLastNodeMonitorEvent < kChangesPulseInterval) { + // wait for things to settle down before running the search for changes + return; + } + + if (fModel->fState != STATE_IDLE) { + // An update or search is still in progress. New node monitor messages + // may arrive while an update is still running. They should not arrive + // during a regular search, but we want to be prepared for that anyways + // and check != STATE_IDLE. + return; + } + + fOldPattern = fSearchText->Text(); + + fGrepper = new (nothrow) Grepper(fOldPattern.String(), fModel, + this, fChangesIterator); + if (fGrepper != NULL && fGrepper->IsValid()) { + fGrepper->Start(); + fChangesIterator = NULL; + fModel->fState = STATE_UPDATE; + } else { + // roll back in case of problems + if (fGrepper == NULL) + delete fChangesIterator; + else { + // Grepper owns iterator + delete fGrepper; + fGrepper = NULL; + } + fprintf(stderr, "Out of memory.\n"); + } +} + + +void GrepWindow::_OnReportFileName(BMessage* message) { - fSearchText->SetText(message->FindString("filename")); + if (fModel->fState != STATE_UPDATE) + fSearchText->SetText(message->FindString("filename")); } - + void GrepWindow::_OnReportResult(BMessage* message) { @@ -856,14 +941,36 @@ if (message->FindRef("ref", &ref) != B_OK) return; - BStringItem* item = new ResultItem(ref); - fSearchResults->AddItem(item); - item->SetExpanded(fModel->fShowContents); - type_code type; int32 count; message->GetInfo("text", &type, &count); + BStringItem* item = NULL; + if (fModel->fState == STATE_UPDATE) { + int32 index; + item = fSearchResults->FindItem(ref, &index); + if (item) { + // remove any sub items + while (true) { + BListItem* subItem = fSearchResults->FullListItemAt(index + 1); + if (subItem && subItem->OutlineLevel() > 0) + delete fSearchResults->RemoveItem(index + 1); + else + break; + } + if (count == 0) { + // remove file item itself + delete fSearchResults->RemoveItem(index); + return; + } + } + } + if (item == NULL) { + item = new ResultItem(ref); + fSearchResults->AddItem(item); + item->SetExpanded(fModel->fShowContents); + } + const char* buf; while (message->FindString("text", --count, &buf) == B_OK) { uchar* temp = (uchar*)strdup(buf); @@ -882,8 +989,7 @@ ++ptr; } - fSearchResults->AddUnder( - new BStringItem((const char*)temp), item); + fSearchResults->AddUnder(new BStringItem((const char*)temp), item); free(temp); } Modified: haiku/trunk/src/apps/text_search/GrepWindow.h =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-04 21:51:33 UTC (rev 26809) @@ -28,6 +28,8 @@ #include "Model.h" #include "GrepListView.h" +class BMessageRunner; +class ChangesIterator; class Grepper; class GrepWindow : public BWindow { @@ -60,6 +62,7 @@ void _OnStartCancel(); void _OnSearchFinished(); void _OnNodeMonitorEvent(BMessage* message); + void _OnNodeMonitorPulse(); void _OnReportFileName(BMessage* message); void _OnReportResult(BMessage* message); void _OnReportError(BMessage* message); @@ -135,6 +138,8 @@ BString fOldPattern; Model* fModel; bigtime_t fLastNodeMonitorEvent; + ChangesIterator* fChangesIterator; + BMessageRunner* fChangesPulse; BFilePanel* fFilePanel; }; Modified: haiku/trunk/src/apps/text_search/Grepper.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-04 21:51:33 UTC (rev 26809) @@ -224,7 +224,7 @@ message.AddString("text", tempString); } - if (message.HasString("text")) + if (message.HasString("text") || fIterator->NotifyNegatives()) fTarget.SendMessage(&message); fclose(results); Copied: haiku/trunk/src/apps/text_search/InitialIterator.cpp (from rev 26795, haiku/trunk/src/apps/text_search/FolderIterator.cpp) =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.cpp 2008-08-04 15:16:30 UTC (rev 26795) +++ haiku/trunk/src/apps/text_search/InitialIterator.cpp 2008-08-04 21:51:33 UTC (rev 26809) @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 "InitialIterator.h" + +#include +#include +#include +#include + +#include + +#include "Model.h" + +using std::nothrow; + +// TODO: stippi: Check if this is a the best place to maintain a global +// list of files and folders for node monitoring. It should probably monitor +// every file that was grepped, as well as every visited (sub) folder. +// For the moment I don't know the life cycle of the InitialIterator object. + + +InitialIterator::InitialIterator(const Model* model) + : FileIterator(), + fDirectories(10), + fCurrentDir(new (nothrow) BDirectory(&model->fDirectory)), + fCurrentRef(0), + + fSelectedFiles(model->fSelectedFiles), + + fRecurseDirs(model->fRecurseDirs), + fRecurseLinks(model->fRecurseLinks), + fSkipDotDirs(model->fSkipDotDirs), + fTextOnly(model->fTextOnly) +{ + if (!fCurrentDir || !fDirectories.AddItem(fCurrentDir)) { + // init error + delete fCurrentDir; + fCurrentDir = NULL; + } +} + + +InitialIterator::~InitialIterator() +{ + for (int32 i = fDirectories.CountItems() - 1; i >= 0; i--) + delete (BDirectory*)fDirectories.ItemAt(i); +} + + +bool +InitialIterator::IsValid() const +{ + return fCurrentDir != NULL; +} + + +bool +InitialIterator::GetNextName(char* buffer) +{ + BEntry entry; + struct stat fileStat; + + while (true) { + // Traverse the directory to get a new BEntry. + // _GetNextEntry returns false if there are no + // more entries, and we exit the loop. + + if (!_GetNextEntry(entry)) + return false; + + // If the entry is a subdir, then add it to the + // list of directories and continue the loop. + // If the entry is a file and we can grep it + // (i.e. it is a text file), then we're done + // here. Otherwise, continue with the next entry. + + if (entry.GetStat(&fileStat) == B_OK) { + if (S_ISDIR(fileStat.st_mode)) { + // subdir + _ExamineSubdir(entry); + } else { + // file or a (non-traversed) symbolic link + if (_ExamineFile(entry, buffer, fTextOnly)) + return true; + } + } + } +} + + +bool +InitialIterator::NotifyNegatives() const +{ + return false; +} + + +bool +InitialIterator::GetTopEntry(BEntry& entry) +{ + // If the user selected one or more files, we must look + // at the "refs" inside the message that was passed into + // our add-on's process_refs(). If the user didn't select + // any files, we will simply read all the entries from the + // current working directory. + + entry_ref fileRef; + + if (fSelectedFiles.FindRef("refs", fCurrentRef, &fileRef) == B_OK) { + entry.SetTo(&fileRef, fRecurseLinks); + ++fCurrentRef; + return true; + } else if (fCurrentRef > 0) { + // when we get here, we have processed + // all the refs from the message + return false; + } else if (fCurrentDir != NULL) { + // examine the whole directory + return fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK; + } + + return false; +} + + +bool +InitialIterator::FollowSubdir(BEntry& entry) const +{ + if (!fRecurseDirs) + return false; + + if (fSkipDotDirs) { + char nameBuf[B_FILE_NAME_LENGTH]; + if (entry.GetName(nameBuf) == B_OK) { + if (*nameBuf == '.') + return false; + } + } + + return true; +} + + +// #pragma mark - private + + +bool +InitialIterator::_GetNextEntry(BEntry& entry) +{ + if (fDirectories.CountItems() == 1) + return GetTopEntry(entry); + else + return _GetSubEntry(entry); +} + + +bool +InitialIterator::_GetSubEntry(BEntry& entry) +{ + if (!fCurrentDir) + return false; + + if (fCurrentDir->GetNextEntry(&entry, fRecurseLinks) == B_OK) + return true; + + // If we get here, there are no more entries in + // this subdir, so return to the parent directory. + + fDirectories.RemoveItem(fCurrentDir); + delete fCurrentDir; + fCurrentDir = (BDirectory*)fDirectories.LastItem(); + + return _GetNextEntry(entry); +} + + +void +InitialIterator::_ExamineSubdir(BEntry& entry) +{ + if (!FollowSubdir(entry)) + return; + + BDirectory* dir = new (nothrow) BDirectory(&entry); + if (dir == NULL || dir->InitCheck() != B_OK || !fDirectories.AddItem(dir)) { + // clean up + delete dir; + return; + } + + fCurrentDir = dir; +} Copied: haiku/trunk/src/apps/text_search/InitialIterator.h (from rev 26795, haiku/trunk/src/apps/text_search/FolderIterator.h) =================================================================== --- haiku/trunk/src/apps/text_search/FolderIterator.h 2008-08-04 15:16:30 UTC (rev 26795) +++ haiku/trunk/src/apps/text_search/InitialIterator.h 2008-08-04 21:51:33 UTC (rev 26809) @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2008 Stephan A?mus + * Copyright (c) 1998-2007 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 INITIAL_ITERATOR_H +#define INITIAL_ITERATOR_H + +#include +#include + +#include "FileIterator.h" + +class BEntry; +class BDirectory; +class Model; + +// TODO: split into Folder and MessageFileIterator (_GetTopEntry) +// This code either has an original folder to start iterating from, +// or it uses the refs in the message that contains the selected poses +// from the Tracker window that invoked us. But I think if folders are +// among those poses, it will then use the same code for examining sub +// folders. + +// Provides an interface to retrieve the next file that should be grepped +// for the search string. +class InitialIterator : public FileIterator { +public: + InitialIterator(const Model* model); + virtual ~InitialIterator(); + + virtual bool IsValid() const; + virtual bool GetNextName(char* buffer); + virtual bool NotifyNegatives() const; + + // Looks for the next entry in the top-level dir. + bool GetTopEntry(BEntry& entry); + + // Should this subfolder be followed? + bool FollowSubdir(BEntry& entry) const; + +private: + // Looks for the next entry. + bool _GetNextEntry(BEntry& entry); + + // Looks for the next entry in a subdir. + bool _GetSubEntry(BEntry& entry); + + // Determines whether we can add a subdir. + void _ExamineSubdir(BEntry& entry); + +private: + // Contains pointers to BDirectory objects. + BList fDirectories; + + // The directory we are currently looking at. + BDirectory* fCurrentDir; + + // The ref number we are currently looking at. + int32 fCurrentRef; + + // The current settings + BMessage fSelectedFiles; + + bool fRecurseDirs : 1; + bool fRecurseLinks : 1; + bool fSkipDotDirs : 1; + bool fTextOnly : 1; +}; + +#endif // INITIAL_ITERATOR_H Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-04 21:51:33 UTC (rev 26809) @@ -2,11 +2,13 @@ SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateHeaders shared ; UsePrivateHeaders storage ; Application TextSearch : + ChangesIterator.cpp FileIterator.cpp - FolderIterator.cpp + InitialIterator.cpp GrepApp.cpp GrepListView.cpp Grepper.cpp @@ -14,6 +16,6 @@ Model.cpp TextSearch.cpp - : be tracker textencoding + : be tracker textencoding libshared.a : TextSearch.rdef ; Modified: haiku/trunk/src/apps/text_search/Model.h =================================================================== --- haiku/trunk/src/apps/text_search/Model.h 2008-08-04 21:49:11 UTC (rev 26808) +++ haiku/trunk/src/apps/text_search/Model.h 2008-08-04 21:51:33 UTC (rev 26809) @@ -48,6 +48,7 @@ MSG_SEARCH_TEXT, MSG_INVOKE_ITEM, MSG_SELECT_HISTORY, + MSG_NODE_MONITOR_PULSE, MSG_REPORT_FILE_NAME, MSG_REPORT_RESULT, @@ -70,7 +71,8 @@ enum state_t { STATE_IDLE = 0, STATE_SEARCH, - STATE_CANCEL + STATE_CANCEL, + STATE_UPDATE }; class Model { From bonefish at mail.berlios.de Mon Aug 4 23:53:11 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 4 Aug 2008 23:53:11 +0200 Subject: [Haiku-commits] r26810 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200808042153.m74LrB9C007712@sheep.berlios.de> Author: bonefish Date: 2008-08-04 23:53:10 +0200 (Mon, 04 Aug 2008) New Revision: 26810 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26810&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S Log: We must not do any kernel exit work when we originally didn't come from userland. E.g. preparing a signal handler would terribly go wrong, since we don't have a userland iframe. This fixes bug #2562 and maybe also #2522. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-08-04 21:51:33 UTC (rev 26809) +++ haiku/trunk/src/system/kernel/arch/x86/arch_interrupts.S 2008-08-04 21:53:10 UTC (rev 26810) @@ -299,10 +299,18 @@ movl IFRAME_vector(%ebp), %eax call *gInterruptHandlerTable(, %eax, 4) + // Don't do any kernel exit work, if we actually came from the kernel (but + // were already/still prepared for userland), since the iframe in this case + // will be a kernel iframe and e.g. trying to set up a signal stack will not + // be a very healthy endeavor. + cmp $USER_CODE_SEG, IFRAME_cs(%ebp) + jne 1f + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ , THREAD_flags(%edi) jnz kernel_exit_work +1: cli // disable interrupts @@ -630,14 +638,14 @@ cli movl %esi, %esp addl $VM86_IFRAME_sizeof, %esp - + // save old iframe popl %eax // old kernel stack top popl %edi movl $(VM86_IFRAME_sizeof >> 2), %ecx cld rep movsl - + // adjust kernel_stack_top and tss.esp0 movl %dr3, %edi movl %eax, THREAD_kernel_stack_top(%edi) From superstippi at gmx.de Mon Aug 4 23:59:38 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 04 Aug 2008 23:59:38 +0200 Subject: [Haiku-commits] r26809 - haiku/trunk/src/apps/text_search In-Reply-To: <200808042151.m74LpZ0v007641@sheep.berlios.de> References: <200808042151.m74LpZ0v007641@sheep.berlios.de> Message-ID: <20080804215938.203100@gmx.net> Hi, > Log: > Finished implementing and enabled node monitoring on the folders and files > of the current search. If new files match the pattern, the appear in the > results, or are removed if they don't match anymore. The results also > adapt to changes in the files. > Basically, I added another iterator that is also used to track changes > when node monitor events arrive. Only those changed files are grepped > again after a timeout of .5 seconds when no new node monitor events pour in. Just noticed that it doesn't work yet if the changed files are in subfolders. I need to experiment more with the BPathMonitor yet... :-) Best regards, -Stephan From ingo_weinhold at gmx.de Tue Aug 5 00:28:24 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 05 Aug 2008 00:28:24 +0200 Subject: [Haiku-commits] r26809 - haiku/trunk/src/apps/text_search In-Reply-To: <200808042151.m74LpZ0v007641@sheep.berlios.de> References: <200808042151.m74LpZ0v007641@sheep.berlios.de> Message-ID: <20080805002824.467.1@knochen-vm.localdomain> On 2008-08-04 at 23:51:35 [+0200], stippi at BerliOS wrote: > Author: stippi > Date: 2008-08-04 23:51:33 +0200 (Mon, 04 Aug 2008) > New Revision: 26809 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26809&view=rev > > Added: > haiku/trunk/src/apps/text_search/ChangesIterator.cpp > haiku/trunk/src/apps/text_search/ChangesIterator.h > haiku/trunk/src/apps/text_search/InitialIterator.cpp > haiku/trunk/src/apps/text_search/InitialIterator.h > Removed: > haiku/trunk/src/apps/text_search/FolderIterator.cpp > haiku/trunk/src/apps/text_search/FolderIterator.h > Modified: > haiku/trunk/src/apps/text_search/GrepListView.cpp > haiku/trunk/src/apps/text_search/GrepListView.h > haiku/trunk/src/apps/text_search/GrepWindow.cpp > haiku/trunk/src/apps/text_search/GrepWindow.h > haiku/trunk/src/apps/text_search/Grepper.cpp > haiku/trunk/src/apps/text_search/Jamfile > haiku/trunk/src/apps/text_search/Model.h > Log: > Finished implementing and enabled node monitoring on the folders and files > of the current search. If new files match the pattern, the appear in the > results, or are removed if they don't match anymore. The results also > adapt to changes in the files. > Basically, I added another iterator that is also used to track changes when > node monitor events arrive. Only those changed files are grepped again after > a timeout of .5 seconds when no new node monitor events pour in. BTW, Haiku has interesting new node monitoring constants: B_WATCH_INTERIM_UPDATE and B_STAT_* (cf. ). The former is a flag to specify when starting to watch a node. If not specified the app won't get stat changed notifications until the changed file is closed. The B_STAT_* constants are flags in the notification message indicating what aspect has changed exactly. I'm not sure how well this works in case of unarchiving tools, but at least in theory it should be enough to react on non-interim modification time changes only. CU, Ingo From mmu_man at mail.berlios.de Tue Aug 5 01:18:11 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Tue, 5 Aug 2008 01:18:11 +0200 Subject: [Haiku-commits] r26811 - in haiku/trunk: headers/os/bluetooth/HCI src/add-ons/kernel/drivers/bluetooth/h2/h2generic Message-ID: <200808042318.m74NIBnh003509@sheep.berlios.de> Author: mmu_man Date: 2008-08-05 01:18:03 +0200 (Tue, 05 Aug 2008) New Revision: 26811 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26811&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h Log: - fix warning - fix build (weird ioctl name) Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-04 21:53:10 UTC (rev 26810) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-04 23:18:03 UTC (rev 26811) @@ -81,7 +81,7 @@ enum { ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, - GET_STATICS, + GET_STATS, GET_NOTIFICATION_PORT, GET_HCI_ID, BT_UP Modified: haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h 2008-08-04 21:53:10 UTC (rev 26810) +++ haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h 2008-08-04 23:18:03 UTC (rev 26811) @@ -18,4 +18,4 @@ status_t submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf); status_t submit_tx_sco(bt_usb_dev* bdev); -#endif \ No newline at end of file +#endif From julun at mail.berlios.de Tue Aug 5 01:29:41 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Tue, 5 Aug 2008 01:29:41 +0200 Subject: [Haiku-commits] r26812 - in haiku/trunk: headers/libs/print/libprint src/libs/print/libprint Message-ID: <200808042329.m74NTfeW024203@sheep.berlios.de> Author: julun Date: 2008-08-05 01:29:40 +0200 (Tue, 05 Aug 2008) New Revision: 26812 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26812&view=rev Modified: haiku/trunk/headers/libs/print/libprint/Preview.h haiku/trunk/src/libs/print/libprint/Preview.cpp Log: * cleanup * sync against the preview driver * fixed totally broken multiple pages on single page preview Modified: haiku/trunk/headers/libs/print/libprint/Preview.h =================================================================== --- haiku/trunk/headers/libs/print/libprint/Preview.h 2008-08-04 23:18:03 UTC (rev 26811) +++ haiku/trunk/headers/libs/print/libprint/Preview.h 2008-08-04 23:29:40 UTC (rev 26812) @@ -1,139 +1,164 @@ /* + * Copyright 2002-2008, Haiku. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer + * Hartmut Reh + * julun + */ +#include "BlockingWindow.h" +#include "JobData.h" +#include "PrintJobReader.h" -Preview -Copyright (c) 2002, 2003 OpenBeOS. -Copyright (c) 2005 Haiku. +#include -Author: - Michael Pfeiffer - Hartmut Reh - -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. +class BButton; +class BFile; +class BMessage; +class BPicture; +class BScrollView; +class BStringView; +class BTextControl; -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. -*/ +// #pragma mark - PreviewPage -#include -#include "PrintJobReader.h" -#include "BlockingWindow.h" class PreviewPage { - int32 fPage; - int32 fNumberOfPictures; - BPicture* fPictures; - BPoint* fPoints; - BRect* fRects; - status_t fStatus; - public: - PreviewPage(int32 page, PrintJobPage* pjp); - ~PreviewPage(); - status_t InitCheck() const; - - int32 Page() const { return fPage; } - void Draw(BView* view); + PreviewPage(int32 page, PrintJobPage* pjp); + ~PreviewPage(); + + void Draw(BView* view, const BRect& printRect); + status_t InitCheck() const; + int32 Page() const { return fPage; } + +private: + int32 fPage; + status_t fStatus; + int32 fNumberOfPictures; + + BRect* fRects; + BPoint* fPoints; + BPicture* fPictures; }; + +// #pragma mark - PreviewView + + class PreviewView : public BView { - int32 fPage; - int32 fZoom; - PrintJobReader fReader; - int32 fNumberOfPagesPerPage; - int32 fNumberOfPages; // physical pages - bool fReverse; - BRect fPageRect; - JobData::Orientation fOrientation; - JobData::PageSelection fPageSelection; - PreviewPage* fCachedPage; - - float ZoomFactor() const; - BRect PageRect() const; - BRect PrintableRect() const; - int32 GetPageNumber(int32 index) const; - public: - PreviewView(BFile* jobFile, BRect rect); - ~PreviewView(); - status_t InitCheck() const; - - BRect ViewRect() const; + PreviewView(BFile* jobFile, BRect rect); + virtual ~PreviewView(); - bool IsPageLoaded(int32 page) const; - bool IsPageValid() const; - void LoadPage(int32 page); - void DrawPageFrame(BRect r); - void DrawPage(BRect r); - void Draw(BRect r); - void FrameResized(float width, float height); - - void FixScrollbars(); - - bool ShowsFirstPage() const; - bool ShowsLastPage() const; - int CurrentPage() const { return fPage + 1; } - int NumberOfPages() const; - void ShowNextPage(); - void ShowPrevPage(); - void ShowFirstPage(); - void ShowLastPage(); - void ShowFindPage(int page); - - bool CanZoomIn() const; - bool CanZoomOut() const; - void ZoomIn(); - void ZoomOut(); + virtual void Show(); + virtual void Hide(); + virtual void Draw(BRect r); + virtual void FrameResized(float width, float height); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, + const BMessage* message); + virtual void MouseUp(BPoint point); + virtual void KeyDown(const char* bytes, int32 numBytes); + + void ShowFirstPage(); + void ShowPrevPage(); + void ShowNextPage(); + void ShowLastPage(); + bool ShowsFirstPage() const; + bool ShowsLastPage() const; + void ShowFindPage(int32 page); + + void ZoomIn(); + bool CanZoomIn() const; + void ZoomOut(); + bool CanZoomOut() const; + + void FixScrollbars(); + BRect ViewRect() const; + status_t InitCheck() const; + int32 NumberOfPages() const; + int32 CurrentPage() const { return fPage + 1; } + +private: + BRect _PaperRect() const; + float _ZoomFactor() const; + BRect _PrintableRect() const; + + void _LoadPage(int32 page); + bool _IsPageValid() const; + bool _IsPageLoaded(int32 page) const; + + BRect _ContentRect() const; + void _DrawPageFrame(BRect rect); + void _DrawPage(BRect updateRect); + void _DrawMarginFrame(BRect rect); + + int32 _GetPageNumber(int32 index) const; + +private: + int32 fPage; + int32 fZoom; + PrintJobReader fReader; + bool fReverse; + BRect fPaperRect; + BRect fPrintableRect; + bool fTracking; + bool fInsideView; + BPoint fScrollStart; + int32 fNumberOfPages; + int32 fNumberOfPagesPerPage; + PreviewPage* fCachedPage; + + JobData::Orientation fOrientation; + JobData::PageSelection fPageSelection; }; + +// #pragma mark - PreviewWindow + + class PreviewWindow : public BlockingWindow { - BButton *fFirst; - BButton *fNext; - BButton *fPrev; - BButton *fLast; - BButton *fZoomIn; - BButton *fZoomOut; - BTextControl *fPageNumber; - BStringView *fPageText; - PreviewView *fPreview; - BScrollView *fPreviewScroller; - float fButtonBarHeight; - - enum { - MSG_FIRST_PAGE = 'pwfp', - MSG_NEXT_PAGE = 'pwnp', - MSG_PREV_PAGE = 'pwpp', - MSG_LAST_PAGE = 'pwlp', - MSG_FIND_PAGE = 'pwsp', - MSG_ZOOM_IN = 'pwzi', - MSG_ZOOM_OUT = 'pwzo', - MSG_PRINT_JOB = 'pwpj', - MSG_CANCEL_JOB = 'pwcj', - }; +public: + PreviewWindow(BFile* jobFile, + bool showOkAndCancelButtons = false); - void ResizeToPage(bool allowShrinking = false); - void UpdateControls(); - - typedef BlockingWindow inherited; - -public: - PreviewWindow(BFile* jobFile, bool showOkAndCancelButtons = false); - status_t InitCheck() const { return fPreview->InitCheck(); } - void MessageReceived(BMessage* m); - status_t Go(); + virtual void MessageReceived(BMessage* m); + + status_t Go(); + status_t InitCheck() const { return fPreview->InitCheck(); } + + +private: + void _ResizeToPage(); + void _UpdateControls(); + +private: + BButton* fFirst; + BButton* fNext; + BButton* fPrev; + BButton* fLast; + BButton* fZoomIn; + BButton* fZoomOut; + BTextControl* fPageNumber; + BStringView* fPageText; + PreviewView* fPreview; + BScrollView* fPreviewScroller; + float fButtonBarHeight; + + enum { + MSG_FIRST_PAGE = 'pwfp', + MSG_NEXT_PAGE = 'pwnp', + MSG_PREV_PAGE = 'pwpp', + MSG_LAST_PAGE = 'pwlp', + MSG_FIND_PAGE = 'pwsp', + MSG_ZOOM_IN = 'pwzi', + MSG_ZOOM_OUT = 'pwzo', + MSG_PRINT_JOB = 'pwpj', + MSG_CANCEL_JOB = 'pwcj', + }; }; - Modified: haiku/trunk/src/libs/print/libprint/Preview.cpp =================================================================== --- haiku/trunk/src/libs/print/libprint/Preview.cpp 2008-08-04 23:18:03 UTC (rev 26811) +++ haiku/trunk/src/libs/print/libprint/Preview.cpp 2008-08-04 23:29:40 UTC (rev 26812) @@ -1,619 +1,1000 @@ /* - * Copyright 2002-2007, Haiku. All rights reserved. + * Copyright 2002-2008, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Michael Pfeiffer * Hartmut Reh + * julun */ +#include "Preview.h" + +#include "GraphicsDriver.h" +#include "PrintUtils.h" + + +#include #include + +#include +#include #include +#include +#include #include +#include +#include +#include -#include "GraphicsDriver.h" -#include "Preview.h" -#include "PrintUtils.h" +// #pragma mark - PreviewPage -// Implementation of PreviewPage + PreviewPage::PreviewPage(int32 page, PrintJobPage* pjp) : fPage(page) + , fStatus(B_ERROR) + , fNumberOfPictures(0) + , fRects(NULL) + , fPoints(NULL) , fPictures(NULL) - , fPoints(NULL) - , fRects(NULL) { fNumberOfPictures = pjp->NumberOfPictures(); + + fRects = new BRect[fNumberOfPictures]; + fPoints = new BPoint[fNumberOfPictures]; fPictures = new BPicture[fNumberOfPictures]; - fPoints = new BPoint[fNumberOfPictures]; - fRects = new BRect[fNumberOfPictures]; - status_t rc = B_ERROR; - for (int32 i = 0; i < fNumberOfPictures && - (rc = pjp->NextPicture(fPictures[i], fPoints[i], fRects[i])) == B_OK; i ++); - fStatus = rc; + + for (int32 i = 0; i < fNumberOfPictures; ++i) { + fStatus = pjp->NextPicture(fPictures[i], fPoints[i], fRects[i]); + if (fStatus != B_OK) + break; + } } -PreviewPage::~PreviewPage() { - delete []fPictures; - delete []fPoints; - delete []fRects; + +PreviewPage::~PreviewPage() + { + delete [] fRects; + delete [] fPoints; + delete [] fPictures; } -status_t PreviewPage::InitCheck() const { + +status_t +PreviewPage::InitCheck() const +{ return fStatus; } -void PreviewPage::Draw(BView* view) + +void +PreviewPage::Draw(BView* view, const BRect& printRect) { ASSERT(fStatus == B_OK); - for (int32 i = 0; i < fNumberOfPictures; i ++) - { - view->DrawPicture(&fPictures[i], fPoints[i]); - } + for (int32 i = 0; i < fNumberOfPictures; i++) + view->DrawPicture(&fPictures[i], printRect.LeftTop() + fPoints[i]); } -// Implementation of PreviewView -const float kPreviewTopMargin = 10; -const float kPreviewBottomMargin = 30; -const float kPreviewLeftMargin = 10; -const float kPreviewRightMargin = 30; +// #pragma mark - PreviewView + +namespace { + +const float kPreviewTopMargin = 10.0; +const float kPreviewBottomMargin = 30.0; +const float kPreviewLeftMargin = 10.0; +const float kPreviewRightMargin = 30.0; + + // TODO share constant with JobData -static const char *kJDOrientation = "orientation"; -static const char *kJDNup = "JJJJ_nup"; -static const char *kJDReverse = "JJJJ_reverse"; -static const char* kJDPageSelection = "JJJJ_page_selection"; +const char *kJDOrientation = "orientation"; +const char *kJDNup = "JJJJ_nup"; +const char *kJDReverse = "JJJJ_reverse"; +const char* kJDPageSelection = "JJJJ_page_selection"; -static BRect RotateRect(BRect rect) + +const uint8 ZOOM_IN[] = { 16, 1, 6, 6, 0, 0, 15, 128, 48, 96, 32, 32, 66, 16, + 66, 16, 79, 144, 66, 16, 66, 16, 32, 32, 48, 112, 15, 184, 0, 28, 0, 14, 0, + 6, 0, 0, 15, 128, 63, 224, 127, 240, 127, 240, 255, 248, 255, 248, 255, 248, + 255, 248, 255, 248, 127, 248, 127, 248, 63, 252, 15, 254, 0, 31, 0, 15, 0, 7 }; + + +const uint8 ZOOM_OUT[] = { 16, 1, 6, 6, 0, 0, 15, 128, 48, 96, 32, 32, 64, 16, + 64, 16, 79, 144, 64, 16, 64, 16, 32, 32, 48, 112, 15, 184, 0, 28, 0, 14, 0, + 6, 0, 0, 15, 128, 63, 224, 127, 240, 127, 240, 255, 248, 255, 248, 255, 248, + 255, 248, 255, 248, 127, 248, 127, 248, 63, 252, 15, 254, 0, 31, 0, 15, 0, 7 }; + + +BRect +RotateRect(const BRect& rect) { - BRect rotated(rect.top, rect.left, rect.bottom, rect.right); - return rotated; + return BRect(rect.top, rect.left, rect.bottom, rect.right); } + +BRect +ScaleDown(BRect rect, float factor) +{ + rect.left /= factor; + rect.top /= factor; + rect.right /= factor; + rect.bottom /= factor; + return rect; +} + + +BPoint +CalulateOffset(int32 numberOfPagesPerPage, int32 index, + JobData::Orientation orientation, BRect printableRect) +{ + BPoint offset(0.0, 0.0); + if (numberOfPagesPerPage == 1) + return offset; + + float width = printableRect.Width(); + float height = printableRect.Height(); + + switch (numberOfPagesPerPage) { + case 2: { + if (index == 1) { + if (JobData::kPortrait == orientation) + offset.x = width; + else + offset.y = height; + } + } break; + + case 8: { + if (JobData::kPortrait == orientation) { + offset.x = width * (index / 2); + offset.y = height * (index % 2); + } else { + offset.x = width * (index % 2); + offset.y = height * (index / 2); + } + } break; + + case 32: { + if (JobData::kPortrait == orientation) { + offset.x = width * (index / 4); + offset.y = height * (index % 4); + } else { + offset.x = width * (index % 4); + offset.y = height * (index / 4); + } + } break; + + case 4: { + case 9: + case 16: + case 25: + case 36: + case 49: + case 64: + case 81: + case 100: + case 121: + int32 value = int32(sqrt(double(numberOfPagesPerPage))); + offset.x = width * (index % value); + offset.y = height * (index / value); + } break; + } + return offset; +} + +} + + PreviewView::PreviewView(BFile* jobFile, BRect rect) : BView(rect, "PreviewView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS) , fPage(0) , fZoom(0) , fReader(jobFile) + , fReverse(false) + , fPaperRect(BRect()) + , fPrintableRect(BRect()) + , fTracking(false) + , fInsideView(true) + , fScrollStart(0.0, 0.0) + , fNumberOfPages(1) , fNumberOfPagesPerPage(1) - , fReverse(false) + , fCachedPage(NULL) , fOrientation(JobData::kPortrait) , fPageSelection(JobData::kAllPages) - , fCachedPage(NULL) { int32 value32; - if (fReader.JobSettings()->FindInt32(kJDOrientation, &value32) == B_OK) { + if (fReader.JobSettings()->FindInt32(kJDOrientation, &value32) == B_OK) fOrientation = (JobData::Orientation)value32; - } - if (fReader.JobSettings()->FindInt32(kJDPageSelection, &value32) == B_OK) { + + if (fReader.JobSettings()->FindInt32(kJDPageSelection, &value32) == B_OK) fPageSelection = (JobData::PageSelection)value32; - } + fReader.JobSettings()->FindInt32(kJDNup, &fNumberOfPagesPerPage); fReader.JobSettings()->FindBool(kJDReverse, &fReverse); - fNumberOfPages = (fReader.NumberOfPages() + fNumberOfPagesPerPage - 1) / fNumberOfPagesPerPage; - if (fPageSelection == JobData::kOddNumberedPages) { + fNumberOfPages = (fReader.NumberOfPages() + fNumberOfPagesPerPage - 1) + / fNumberOfPagesPerPage; + + if (fPageSelection == JobData::kOddNumberedPages) fNumberOfPages = (fNumberOfPages + 1) / 2; - } - else if (fPageSelection == JobData::kEvenNumberedPages) { + else if (fPageSelection == JobData::kEvenNumberedPages) fNumberOfPages /= 2; - } - fPageRect = fReader.PaperRect(); + + fPaperRect = fReader.PaperRect(); + fPrintableRect = fReader.PrintableRect(); switch (fNumberOfPagesPerPage) { case 2: case 8: case 32: - case 128: - fPageRect = RotateRect(fPageRect); - break; + case 128: { + fPaperRect = RotateRect(fPaperRect); + fPrintableRect = RotateRect(fPrintableRect); + } break; } } -PreviewView::~PreviewView() { + +PreviewView::~PreviewView() +{ delete fCachedPage; } -// returns 2 ^ fZoom -float PreviewView::ZoomFactor() const { - const int32 b = 4; - int32 zoom; - if (fZoom > 0) { - zoom = (1 << b) << fZoom; - } else { - zoom = (1 << b) >> -fZoom; - } - float factor = zoom / (float)(1 << b); - return factor * fReader.GetScale() / 100.0; -} -BRect PreviewView::PageRect() const { - float f = ZoomFactor(); - BRect r(fPageRect); - return ScaleRect(r, f); +void +PreviewView::Show() +{ + BView::Show(); + be_app->SetCursor(ZOOM_IN); } -BRect PreviewView::PrintableRect() const { - float f = ZoomFactor(); - BRect r = fReader.PrintableRect(); - return ScaleRect(r, f); -} -BRect PreviewView::ViewRect() const { - BRect r(PageRect()); - r.right += kPreviewLeftMargin + kPreviewRightMargin; - r.bottom += kPreviewTopMargin + kPreviewBottomMargin; - return r; +void +PreviewView::Hide() +{ + be_app->SetCursor(B_HAND_CURSOR); + BView::Hide(); } -status_t PreviewView::InitCheck() const { - return fReader.InitCheck(); -} -bool PreviewView::IsPageLoaded(int32 page) const { - return fCachedPage != NULL && fCachedPage->Page() == page; +void +PreviewView::Draw(BRect rect) +{ + if (fReader.InitCheck() == B_OK) { + _DrawPageFrame(rect); + _DrawPage(rect); + _DrawMarginFrame(rect); + } } -bool PreviewView::IsPageValid() const { - return fCachedPage && fCachedPage->InitCheck() == B_OK; -} -void PreviewView::LoadPage(int32 page) { - delete fCachedPage; - fCachedPage = NULL; - PrintJobPage pjp; - if (fReader.GetPage(page, pjp) == B_OK) { - fCachedPage = new PreviewPage(page, &pjp); - } +void +PreviewView::FrameResized(float width, float height) +{ + Invalidate(); + FixScrollbars(); } -void PreviewView::DrawPageFrame(BRect rect) { - const float kShadowIndent = 3; - const float kShadowWidth = 3; - float x, y; - float right, bottom; - rgb_color frameColor = {0, 0, 0, 0}; - rgb_color shadowColor = {90, 90, 90, 0}; - BRect r(PageRect()); - - PushState(); - // draw page border around page - r.InsetBy(-1, -1); - r.OffsetTo(kPreviewLeftMargin-1, kPreviewTopMargin-1); - SetHighColor(frameColor); - StrokeRect(r); - - // draw page shadow - SetHighColor(shadowColor); - x = r.right + 1; - right = x + kShadowWidth; - bottom = r.bottom + 1 + kShadowWidth; - y = r.top + kShadowIndent; - FillRect(BRect(x, y, right, bottom)); +void +PreviewView::MouseDown(BPoint point) +{ + MakeFocus(true); + BMessage *message = Window()->CurrentMessage(); - x = r.left + kShadowIndent; - y = r.bottom + 1; - FillRect(BRect(x, y, r.right, bottom)); - PopState(); + int32 button; + if (message && message->FindInt32("buttons", &button) == B_OK) { + if (button == B_PRIMARY_MOUSE_BUTTON) { + int32 modifier; + if (message->FindInt32("modifiers", &modifier) == B_OK) { + if (modifier & B_SHIFT_KEY) + ZoomOut(); + else + ZoomIn(); + } + } + + if (button == B_SECONDARY_MOUSE_BUTTON) { + fTracking = true; + be_app->SetCursor(B_HAND_CURSOR); + SetMouseEventMask(B_POINTER_EVENTS, + B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY); + fScrollStart = Bounds().LeftTop() + ConvertToScreen(point); + } + } } -int32 PreviewView::GetPageNumber(int32 index) const +void +PreviewView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) { - int page = fPage; - if (fReverse) { - page = fNumberOfPages - fPage - 1; - } + if (fTracking) { + uint32 button; + GetMouse(&point, &button, false); + point = fScrollStart - ConvertToScreen(point); - if (fPageSelection == JobData::kOddNumberedPages) { - page *= 2; // 0, 2, 4, ... - } - else if (fPageSelection == JobData::kEvenNumberedPages) { - page = 2 * page + 1; // 1, 3, 5, ... - } - - return page * fNumberOfPagesPerPage + index; -} + float hMin, hMax; + BScrollBar *hBar = ScrollBar(B_HORIZONTAL); + hBar->GetRange(&hMin, &hMax); -void PreviewView::DrawPage(BRect rect) -{ + float vMin, vMax; + BScrollBar *vBar = ScrollBar(B_VERTICAL); + vBar->GetRange(&vMin, &vMax); - BRect physicalRect = fReader.PaperRect(); - BRect scaledPhysicalRect = physicalRect; - BRect scaledPrintableRect = fReader.PrintableRect(); - - for (int32 index = 0; index < fNumberOfPagesPerPage; index ++) { - int32 pageNumber = GetPageNumber(index); - if (pageNumber < 0) { - // no page at index - continue; + if (point.x < 0.0) point.x = 0.0; + if (point.y < 0.0) point.y = 0.0; + if (point.x > hMax) point.x = hMax; + if (point.y > vMax) point.y = vMax; + + ScrollTo(point); + } else { + switch (transit) { + case B_ENTERED_VIEW: { + fInsideView = true; + be_app->SetCursor(ZOOM_IN); + } break; + + case B_EXITED_VIEW: { + fInsideView = false; + be_app->SetCursor(B_HAND_CURSOR); + } break; + + default: { + if (modifiers() & B_SHIFT_KEY) + be_app->SetCursor(ZOOM_OUT); + else + be_app->SetCursor(ZOOM_IN); + } break; } - if (!IsPageLoaded(pageNumber)) { - LoadPage(pageNumber); - } - if (!IsPageValid()) { - // TODO show feedback - continue; - } - - BPoint scalingXY = GraphicsDriver::getScale(fNumberOfPagesPerPage, physicalRect, 100.0); - float scaling = min_c(scalingXY.x, scalingXY.y); - BPoint offset = GraphicsDriver::getOffset(fNumberOfPagesPerPage, index, fOrientation, &scalingXY, - scaledPhysicalRect, scaledPrintableRect, physicalRect); - - // draw page contents - PushState(); - - // print job coordinates are relative to the printable rect - SetScale(ZoomFactor() * scaling); - - BPoint leftTopMargin(BPoint(kPreviewLeftMargin, kPreviewTopMargin)); - leftTopMargin.x /= ZoomFactor() * scaling; - leftTopMargin.y /= ZoomFactor() * scaling; - offset += leftTopMargin; - SetOrigin(offset); - - // constrain clipping region to printable rectangle - BRect clipRect(fReader.PrintableRect()); - clipRect.OffsetTo(0, 0); - BRegion clip(clipRect); - ConstrainClippingRegion(&clip); - - fCachedPage->Draw(this); - - PopState(); } } -void PreviewView::Draw(BRect rect) { - if (fReader.InitCheck() == B_OK) { - DrawPageFrame(rect); - DrawPage(rect); - } -} -void PreviewView::FrameResized(float width, float height) { - FixScrollbars(); +void +PreviewView::MouseUp(BPoint point) +{ + (void)point; + fTracking = false; + fScrollStart.Set(0.0, 0.0); + if (fInsideView && ((modifiers() & B_SHIFT_KEY) == 0)) + be_app->SetCursor(ZOOM_IN); } -bool PreviewView::ShowsFirstPage() const { - return fPage == 0; -} -bool PreviewView::ShowsLastPage() const { - return fPage == NumberOfPages() - 1; -} +void +PreviewView::KeyDown(const char* bytes, int32 numBytes) +{ + MakeFocus(true); + switch (bytes[0]) { + case '-': { + if (modifiers() & B_CONTROL_KEY) + ZoomOut(); + } break; -int PreviewView::NumberOfPages() const { - return fNumberOfPages; + case '+' : { + if (modifiers() & B_CONTROL_KEY) + ZoomIn(); + } break; + + default: { + BView::KeyDown(bytes, numBytes); + } break; + } } -void PreviewView::ShowNextPage() { - if (!ShowsLastPage()) { - fPage ++; + +void +PreviewView::ShowFirstPage() +{ + if (!ShowsFirstPage()) { + fPage = 0; Invalidate(); } } -void PreviewView::ShowPrevPage() { + +void +PreviewView::ShowPrevPage() +{ if (!ShowsFirstPage()) { - fPage --; + fPage--; Invalidate(); } } - -void PreviewView::ShowFirstPage() { - if (!ShowsFirstPage()) { - fPage = 0; + + +void +PreviewView::ShowNextPage() +{ + if (!ShowsLastPage()) { + fPage++; Invalidate(); } } -void PreviewView::ShowLastPage() { + +void +PreviewView::ShowLastPage() +{ if (!ShowsLastPage()) { - fPage = NumberOfPages()-1; + fPage = NumberOfPages()-1; Invalidate(); } } -void PreviewView::ShowFindPage(int page) { - page --; - + +bool +PreviewView::ShowsFirstPage() const +{ + return fPage == 0; +} + + +bool +PreviewView::ShowsLastPage() const +{ + return fPage == NumberOfPages() - 1; +} + + +void +PreviewView::ShowFindPage(int32 page) +{ + page--; + if (page < 0) { page = 0; } else if (page > (NumberOfPages()-1)) { page = NumberOfPages()-1; } - - fPage = (int32)page; + fPage = page; Invalidate(); } -bool PreviewView::CanZoomIn() const { - return fZoom < 4; -} -bool PreviewView::CanZoomOut() const { - return fZoom > -2; -} - -void PreviewView::ZoomIn() { +void +PreviewView::ZoomIn() +{ if (CanZoomIn()) { - fZoom ++; FixScrollbars(); + fZoom++; + FixScrollbars(); Invalidate(); } } -void PreviewView::ZoomOut() { + +bool +PreviewView::CanZoomIn() const +{ + return fZoom < 4; +} + + +void +PreviewView::ZoomOut() +{ if (CanZoomOut()) { - fZoom --; FixScrollbars(); + fZoom--; + FixScrollbars(); Invalidate(); } } -void PreviewView::FixScrollbars() { - BRect frame = Bounds(); [... truncated: 714 lines follow ...] From oliver.ruiz.dorantes at gmail.com Tue Aug 5 09:32:56 2008 From: oliver.ruiz.dorantes at gmail.com (Oliver Ruiz Dorantes) Date: Tue, 5 Aug 2008 09:32:56 +0200 Subject: [Haiku-commits] r26811 - in haiku/trunk: headers/os/bluetooth/HCI src/add-ons/kernel/drivers/bluetooth/h2/h2generic In-Reply-To: <200808042318.m74NIBnh003509@sheep.berlios.de> References: <200808042318.m74NIBnh003509@sheep.berlios.de> Message-ID: Sorry... Thanks Fran?ois Forgot to commit that header ... 2008/8/5 > Author: mmu_man > Date: 2008-08-05 01:18:03 +0200 (Tue, 05 Aug 2008) > New Revision: 26811 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26811&view=rev > > Modified: > haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h > > haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h > Log: > - fix warning > - fix build (weird ioctl name) > > > Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h > =================================================================== > --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-04 > 21:53:10 UTC (rev 26810) > +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-04 > 23:18:03 UTC (rev 26811) > @@ -81,7 +81,7 @@ > > enum { > ISSUE_BT_COMMAND = B_DEVICE_OP_CODES_END + BT_IOCTLS_OFFSET, > - GET_STATICS, > + GET_STATS, > GET_NOTIFICATION_PORT, > GET_HCI_ID, > BT_UP > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h > =================================================================== > --- > haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h > 2008-08-04 21:53:10 UTC (rev 26810) > +++ > haiku/trunk/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.h > 2008-08-04 23:18:03 UTC (rev 26811) > @@ -18,4 +18,4 @@ > status_t submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf); > status_t submit_tx_sco(bt_usb_dev* bdev); > > -#endif > \ No newline at end of file > +#endif > > _______________________________________________ > 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 jackburton at mail.berlios.de Tue Aug 5 10:33:42 2008 From: jackburton at mail.berlios.de (jackburton at mail.berlios.de) Date: Tue, 5 Aug 2008 10:33:42 +0200 Subject: [Haiku-commits] r26813 - haiku/trunk/src/tools/fs_shell Message-ID: <200808050833.m758Xgc1020973@sheep.berlios.de> Author: jackburton Date: 2008-08-05 10:33:40 +0200 (Tue, 05 Aug 2008) New Revision: 26813 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26813&view=rev Modified: haiku/trunk/src/tools/fs_shell/file_map.cpp Log: gcc4 build fix Modified: haiku/trunk/src/tools/fs_shell/file_map.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/file_map.cpp 2008-08-04 23:29:40 UTC (rev 26812) +++ haiku/trunk/src/tools/fs_shell/file_map.cpp 2008-08-05 08:33:40 UTC (rev 26813) @@ -316,7 +316,7 @@ while (status == FSSH_B_OK && mapEnd < end) { // We don't have the requested extents yet, retrieve them - size_t vecCount = kMaxVecs; + fssh_size_t vecCount = kMaxVecs; status = vfs_get_file_map(Vnode(), mapEnd, ~0UL, vecs, &vecCount); if (status == FSSH_B_OK || status == FSSH_B_BUFFER_OVERFLOW) status = _Add(vecs, vecCount, mapEnd); From sbenedetto at mail.berlios.de Tue Aug 5 11:44:37 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Tue, 5 Aug 2008 11:44:37 +0200 Subject: [Haiku-commits] r26814 - haiku/trunk/src/system/kernel/posix Message-ID: <200808050944.m759ib5f028748@sheep.berlios.de> Author: sbenedetto Date: 2008-08-05 11:44:36 +0200 (Tue, 05 Aug 2008) New Revision: 26814 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26814&view=rev Modified: haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp Log: * Check for wake ups on Revert() * Fix TRACE() output * Check for IPC_CREAT in xsi_semget when IPC does not yet exist * Fix bound checking * Fix setpid call Modified: haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-05 08:33:40 UTC (rev 26813) +++ haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-05 09:44:36 UTC (rev 26814) @@ -138,6 +138,10 @@ void Revert(short value) { fValue -= value; + if (fValue == 0 && fThreadsWaitingToBeZero > 0) + WakeUpThread(true); + else if (fValue > 0 && fThreadsWaitingToIncrease > 0) + WakeUpThread(false); } void SetPid(pid_t pid) @@ -256,6 +260,7 @@ ~XsiSemaphoreSet() { + TRACE(("XsiSemaphoreSet::~XsiSemaphoreSet(): removing semaphore set\n")); // Clear all sem_undo left, as our ID will be reused // by another set. for (uint32 i = 0; i < fNumberOfSemaphores; i++) @@ -670,13 +675,13 @@ // Revert the changes done by this process XsiSemaphore *semaphore = semaphoreSet->Semaphore(current->semaphore_number); - TRACE(("xsi_do_undo: TeamID = %d, SemaphoreSetID = %d, " + TRACE(("xsi_sem_undo: TeamID = %d, SemaphoreSetID = %d, " "SemaphoreNumber = %d, undo value = %d\n", (int)teamID, semaphoreSetID, current->semaphore_number, current->undo_value)); semaphore->Revert(current->undo_value); } else - TRACE(("xsi_do_undo: semaphore set %d does not exist " + TRACE(("xsi_sem_undo: semaphore set %d does not exist " "anymore. Ignore record.\n", semaphoreSetID)); // Remove and free the sem_undo structure from sUndoList @@ -711,6 +716,11 @@ if (ipcKey == NULL) { // The ipc key have probably just been created // by the caller, add it to the system + if (!(flags & IPC_CREAT)) { + TRACE_ERROR(("xsi_semget: key %d does not exist, but the " + "caller did not ask for creation\n",(int)key)); + return ENOENT; + } ipcKey = new(std::nothrow) Ipc(key); if (ipcKey == NULL) { TRACE_ERROR(("xsi_semget: failed to create new Ipc object " @@ -756,8 +766,8 @@ if (create) { // Create a new sempahore set for this key - if (numberOfSemaphores < 0 - || numberOfSemaphores >= MAX_XSI_SEMS_PER_TEAM) { + if (numberOfSemaphores <= 0 + || numberOfSemaphores >= MAX_XSI_SEMS_PER_TEAM) { TRACE_ERROR(("xsi_semget: numberOfSemaphores out of range\n")); return EINVAL; } @@ -1137,9 +1147,16 @@ operations[j].sem_num, operations[j].sem_op); } result = ENOSPC; - } + } } - // We did it. Set the pid. + } + } + + // We did it. Set the pid of all semaphores used + if (result == 0) { + for (uint32 i = 0; i < numOps; i++) { + short semaphoreNumber = operations[i].sem_num; + XsiSemaphore *semaphore = semaphoreSet->Semaphore(semaphoreNumber); semaphore->SetPid(getpid()); } } From axeld at mail.berlios.de Tue Aug 5 15:57:19 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 15:57:19 +0200 Subject: [Haiku-commits] r26815 - haiku/trunk/src/system/libroot/os Message-ID: <200808051357.m75DvJiZ007627@sheep.berlios.de> Author: axeld Date: 2008-08-05 15:57:14 +0200 (Tue, 05 Aug 2008) New Revision: 26815 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26815&view=rev Modified: haiku/trunk/src/system/libroot/os/scheduler.c Log: * Coding style cleanup, pointed out by Andreas. Modified: haiku/trunk/src/system/libroot/os/scheduler.c =================================================================== --- haiku/trunk/src/system/libroot/os/scheduler.c 2008-08-05 09:44:36 UTC (rev 26814) +++ haiku/trunk/src/system/libroot/os/scheduler.c 2008-08-05 13:57:14 UTC (rev 26815) @@ -1,5 +1,5 @@ -/* - * Copyright 2004-2007, Haiku. All rights reserved. +/* + * Copyright 2004-2008, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -14,7 +14,7 @@ static struct { uint32 what; int32 priority; -} gWhatPriorityArray[] = { +} sWhatPriorityArray[] = { // highest priority first {B_MIDI_PROCESSING, 0x78}, {B_AUDIO_RECORDING | B_AUDIO_PLAYBACK, 0x73}, @@ -30,28 +30,31 @@ {(uint32)-1, -1} }; -int32 -suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length) + +int32 +suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, + bigtime_t length) { int i; int32 priority = what == B_DEFAULT_MEDIA_PRIORITY ? 0x0a : 0; // default priority - - for (i = 0; gWhatPriorityArray[i].what != (uint32)-1; i ++) { - if ((what & gWhatPriorityArray[i].what) != 0) { - priority = gWhatPriorityArray[i].priority; + + for (i = 0; sWhatPriorityArray[i].what != (uint32)-1; i ++) { + if ((what & sWhatPriorityArray[i].what) != 0) { + priority = sWhatPriorityArray[i].priority; break; } } - - return priority; + + return priority; } -bigtime_t -estimate_max_scheduling_latency(thread_id th) + +bigtime_t +estimate_max_scheduling_latency(thread_id thread) { - if (th == -1) - th = find_thread(NULL); + if (thread == -1) + thread = find_thread(NULL); return 0; } From bonefish at mail.berlios.de Tue Aug 5 18:52:20 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 5 Aug 2008 18:52:20 +0200 Subject: [Haiku-commits] r26816 - haiku/trunk/src/build/libroot Message-ID: <200808051652.m75GqK60012131@sheep.berlios.de> Author: bonefish Date: 2008-08-05 18:52:11 +0200 (Tue, 05 Aug 2008) New Revision: 26816 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26816&view=rev Modified: haiku/trunk/src/build/libroot/sem.cpp Log: * Increased the maximal number of (pseudo) semaphores. Modified: haiku/trunk/src/build/libroot/sem.cpp =================================================================== --- haiku/trunk/src/build/libroot/sem.cpp 2008-08-05 13:57:14 UTC (rev 26815) +++ haiku/trunk/src/build/libroot/sem.cpp 2008-08-05 16:52:11 UTC (rev 26816) @@ -16,7 +16,7 @@ bool inUse; }; -static const int kSemaphoreCount = 10240; +static const int kSemaphoreCount = 40960; static semaphore sSemaphores[kSemaphoreCount]; @@ -41,11 +41,11 @@ sem.inUse = true; sem.count = count; - + return i; } } - + return B_NO_MORE_SEMS; } @@ -59,7 +59,7 @@ sSemaphores[id].inUse = false; free(sSemaphores[id].name); sSemaphores[id].name = NULL; - + return B_OK; } @@ -89,21 +89,21 @@ if (timeout < 0) timeout = 0; - bool noTimeout = false; + bool noTimeout = false; if (flags & B_RELATIVE_TIMEOUT) { // relative timeout: get the absolute time when to time out - + // special case: on timeout == 0 we return B_WOULD_BLOCK if (timeout == 0) return B_WOULD_BLOCK; - + bigtime_t currentTime = system_time(); if (timeout > B_INFINITE_TIMEOUT || currentTime >= B_INFINITE_TIMEOUT - timeout) { noTimeout = true; } else { timeout += currentTime; } - + } else if (flags & B_ABSOLUTE_TIMEOUT) { // absolute timeout } else { @@ -122,7 +122,7 @@ status_t error = snooze_until(timeout, B_SYSTEM_TIMEBASE); if (error != B_OK) return error; - + return B_TIMED_OUT; } From bonefish at mail.berlios.de Tue Aug 5 18:56:45 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 5 Aug 2008 18:56:45 +0200 Subject: [Haiku-commits] r26817 - haiku/trunk/src/add-ons/kernel/bus_managers/scsi Message-ID: <200808051656.m75GujoB015964@sheep.berlios.de> Author: bonefish Date: 2008-08-05 18:56:25 +0200 (Tue, 05 Aug 2008) New Revision: 26817 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26817&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c Log: Removed whitespace at the end of lines. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c 2008-08-05 16:52:11 UTC (rev 26816) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c 2008-08-05 16:56:25 UTC (rev 26817) @@ -8,16 +8,16 @@ /* DMA buffer handling. - If the peripheral driver hasn't made sure that the data of a request + If the peripheral driver hasn't made sure that the data of a request is DMA safe, we check that and copy data to a buffer if needed. The buffer is enlarged on demand and destroyed after a time-out - by a daemon. Obviously, it's a good idea to avoid all this, therefore + by a daemon. Obviously, it's a good idea to avoid all this, therefore blkman takes care of that for read/write requests. - - To be able to copy data back after the request was finished, we need a + + To be able to copy data back after the request was finished, we need a S/G list to the original data as the copying is done in a different thread/process context (namely the service thread). - + Currently, there is only one buffer per device; in the future, we may support multiple buffers, especially if we want to support more then 4 GB memory, which leads to trouble with 32-bit PCI cards. @@ -34,7 +34,7 @@ /*! Check whether S/G list of request is supported DMA controller */ static bool -is_sg_list_dma_safe(scsi_ccb *request) +is_sg_list_dma_safe(scsi_ccb *request) { scsi_bus_info *bus = request->bus; const physical_entry *sg_list = request->sg_list; @@ -49,7 +49,7 @@ SHOW_FLOW0(1, "S/G-list too long"); return false; } - + // if there are no further restrictions - be happy if (dma_boundary == ~0UL && alignment == 0 && max_sg_block_size == 0) return true; @@ -60,11 +60,11 @@ // calculate space upto next dma boundary crossing and // verify that it isn't crossed - max_len = (dma_boundary + 1) - + max_len = (dma_boundary + 1) - ((addr_t)sg_list->address & dma_boundary); if (max_len < sg_list->size) { - SHOW_FLOW(0, "S/G-entry crosses DMA boundary @0x%x", + SHOW_FLOW(0, "S/G-entry crosses DMA boundary @0x%x", (int)sg_list->address + (int)max_len); return false; } @@ -73,6 +73,7 @@ if (((addr_t)sg_list->address & alignment) != 0) { SHOW_FLOW(0, "S/G-entry has bad alignment @0x%x", (int)sg_list->address); +panic("XXX"); return false; } @@ -115,7 +116,7 @@ for (; size > 0 && num_vecs > 0; ++sg_list, --num_vecs) { addr_t virtualAddress; size_t bytes; - + bytes = min( size, sg_list->size ); if (vm_get_physical_page((addr_t)sg_list->address, &virtualAddress, @@ -131,7 +132,7 @@ buffer_data += bytes; } - + return true; } @@ -176,15 +177,15 @@ scsi_alloc_dma_buffer(dma_buffer *buffer, dma_params *dma_params, uint32 size) { size_t sg_list_size, sg_list_entries; - - // free old buffer first + + // free old buffer first scsi_free_dma_buffer( buffer ); // just in case alignment is redicuously huge size = (size + dma_params->alignment) & ~dma_params->alignment; - + size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); - + // calculate worst case number of S/G entries, i.e. if they are non-continuous; // there is a controller limit and a limit by our own S/G manager to check if (size / B_PAGE_SIZE > dma_params->max_sg_blocks @@ -193,29 +194,29 @@ uchar *dma_buffer_address_unaligned; // alright - a contiguous buffer is required to keep S/G table short - SHOW_INFO(1, "need to setup contiguous DMA buffer of size %d", + SHOW_INFO(1, "need to setup contiguous DMA buffer of size %d", (int)size); // verify that we don't get problems with dma boundary if (boundary != ~0UL) { if (size > boundary + 1) { - SHOW_ERROR(2, "data is longer then maximum DMA transfer len (%d/%d bytes)", + SHOW_ERROR(2, "data is longer then maximum DMA transfer len (%d/%d bytes)", (int)size, (int)boundary + 1); return false; } - // round up to next power of two and allocate a buffer double the - // needed size so we can cut out an area that doesn't cross + // round up to next power of two and allocate a buffer double the + // needed size so we can cut out an area that doesn't cross // dma boundary size = (1 << log2( size )) * 2; } - buffer->area = create_area("DMA buffer", - (void **)&dma_buffer_address_unaligned, + buffer->area = create_area("DMA buffer", + (void **)&dma_buffer_address_unaligned, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK | B_CONTIGUOUS, 0 ); if (buffer->area < 0) { - SHOW_ERROR(2, "Cannot create contignous DMA buffer of %d bytes", + SHOW_ERROR(2, "Cannot create contignous DMA buffer of %d bytes", (int)size); return false; } @@ -234,7 +235,7 @@ // adjust next boundary if outside allocated area if( next_boundary > dma_buffer_address_unaligned + size ) next_boundary = dma_buffer_address_unaligned + size; - + buffer->size = next_boundary - buffer->address; } else { // non-boundary case: use buffer directly @@ -243,25 +244,25 @@ } } else { // we can live with a fragmented buffer - very nice - buffer->area = create_area( "DMA buffer", - (void **)&buffer->address, + buffer->area = create_area( "DMA buffer", + (void **)&buffer->address, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK, 0 ); if (buffer->area < 0) { - SHOW_ERROR(2, "Cannot create DMA buffer of %d bytes", + SHOW_ERROR(2, "Cannot create DMA buffer of %d bytes", (int)size); return false; } - + buffer->size = size; } - // create S/G list + // create S/G list // worst case is one entry per page, and size is page-aligned sg_list_size = buffer->size / B_PAGE_SIZE * sizeof( physical_entry ); // create_area has page-granularity sg_list_size = (sg_list_size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); - + buffer->sg_list_area = create_area("DMA buffer S/G table", (void **)&buffer->sg_list, B_ANY_KERNEL_ADDRESS, sg_list_size, @@ -274,7 +275,7 @@ buffer->area = 0; return false; } - + sg_list_entries = sg_list_size / sizeof( physical_entry ); { @@ -284,12 +285,12 @@ buffer->address, buffer->size }; - - res = get_iovec_memory_map( - &vec, 1, 0, buffer->size, - buffer->sg_list, sg_list_entries, &buffer->sg_count, + + res = get_iovec_memory_map( + &vec, 1, 0, buffer->size, + buffer->sg_list, sg_list_entries, &buffer->sg_count, &mapped_len ); - + if( res != B_OK || mapped_len != buffer->size ) { SHOW_ERROR(0, "Error creating S/G list for DMA buffer (%s; wanted %d, got %d bytes)", strerror(res), (int)mapped_len, (int)buffer->size); @@ -316,17 +317,17 @@ static bool scsi_alloc_dma_buffer_sg_orig(dma_buffer *buffer, int size) { - // free old list first + // free old list first scsi_free_dma_buffer_sg_orig(buffer); size = (size * sizeof(physical_entry) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); - buffer->sg_orig = create_area("S/G to original data", - (void **)&buffer->sg_list_orig, + buffer->sg_orig = create_area("S/G to original data", + (void **)&buffer->sg_list_orig, B_ANY_KERNEL_ADDRESS, size, B_NO_LOCK, 0); if (buffer->sg_orig < 0) { - SHOW_ERROR(2, "Cannot S/G list buffer to original data of %d bytes", + SHOW_ERROR(2, "Cannot S/G list buffer to original data of %d bytes", (int)size); return false; } @@ -369,11 +370,11 @@ SHOW_FLOW0(1, "copy S/G list"); - memcpy(buffer->sg_list_orig, request->sg_list, + memcpy(buffer->sg_list_orig, request->sg_list, request->sg_count * sizeof(physical_entry)); buffer->sg_count_orig = request->sg_count; - return true; + return true; } @@ -386,18 +387,18 @@ { scsi_device_info *device = request->device; dma_buffer *buffer; - + request->buffered = false; // perhaps we have luck and no buffering is needed - if( is_sg_list_dma_safe( request )) + if( is_sg_list_dma_safe( request )) return true; SHOW_FLOW0(1, "Buffer is not DMA safe" ); dump_sg_table(request->sg_list, request->sg_count); - // only one buffer at a time + // only one buffer at a time acquire_sem(device->dma_buffer_owner); // make sure, clean-up daemon doesn't bother us @@ -405,9 +406,9 @@ // there is only one buffer, so no further management buffer = &device->dma_buffer; - - buffer->inuse = true; - + + buffer->inuse = true; + RELEASE_BEN(&device->dma_buffer_lock); // memorize buffer for cleanup @@ -435,7 +436,7 @@ buffer->orig_data = request->data; buffer->orig_sg_list = request->sg_list; buffer->orig_sg_count = request->sg_count; - + request->data = buffer->address; request->sg_list = buffer->sg_list; request->sg_count = buffer->sg_count; @@ -457,7 +458,7 @@ RELEASE_BEN(&device->dma_buffer_lock); release_sem(device->dma_buffer_owner); - return false; + return false; } @@ -469,8 +470,8 @@ { scsi_device_info *device = request->device; dma_buffer *buffer = request->dma_buffer; - - SHOW_FLOW(1, "Buffering finished, %x, %x", + + SHOW_FLOW(1, "Buffering finished, %x, %x", request->subsys_status & SCSI_SUBSYS_STATUS_MASK, (int)(request->flags & SCSI_DIR_MASK)); @@ -478,12 +479,12 @@ if ((request->subsys_status & SCSI_SUBSYS_STATUS_MASK) == SCSI_REQ_CMP && (request->flags & SCSI_DIR_MASK) == SCSI_DIR_IN) scsi_copy_dma_buffer(request, request->data_length - request->data_resid, false); - - // restore request + + // restore request request->data = buffer->orig_data; request->sg_list = buffer->orig_sg_list; request->sg_count = buffer->orig_sg_count; - + // free buffer ACQUIRE_BEN(&device->dma_buffer_lock); From axeld at mail.berlios.de Tue Aug 5 19:13:09 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 19:13:09 +0200 Subject: [Haiku-commits] r26818 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200808051713.m75HD9Ur001106@sheep.berlios.de> Author: axeld Date: 2008-08-05 19:13:06 +0200 (Tue, 05 Aug 2008) New Revision: 26818 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26818&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp Log: * Patch by Andreas: we did not store ebp in vregs::ebp, and we did not store ebx at all. * This fixes bug #2569. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-05 16:56:25 UTC (rev 26817) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-05 17:13:06 UTC (rev 26818) @@ -472,11 +472,12 @@ regs.eax = frame->eax; regs.ecx = frame->ecx; regs.edx = frame->edx; + regs.ebp = frame->ebp; regs.esp = frame->esp; regs._reserved_1 = frame->user_esp; regs._reserved_2[0] = frame->edi; regs._reserved_2[1] = frame->esi; - regs._reserved_2[2] = frame->ebp; + regs._reserved_2[2] = frame->ebx; i386_fnsave((void *)(®s.xregs)); userStack -= (sizeof(struct vregs) + 3) / 4; @@ -565,11 +566,12 @@ frame->eax = regs.eax; frame->ecx = regs.ecx; frame->edx = regs.edx; + frame->ebp = regs.ebp; frame->esp = regs.esp; frame->user_esp = regs._reserved_1; frame->edi = regs._reserved_2[0]; frame->esi = regs._reserved_2[1]; - frame->ebp = regs._reserved_2[2]; + frame->ebx = regs._reserved_2[2]; i386_frstor((void *)(®s.xregs)); From bonefish at mail.berlios.de Tue Aug 5 19:20:22 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 5 Aug 2008 19:20:22 +0200 Subject: [Haiku-commits] r26819 - in haiku/trunk: headers/private/kernel headers/private/system src/system/boot/platform/atari_m68k src/system/boot/platform/bios_ia32 src/system/boot/platform/openfirmware/arch/ppc src/system/kernel src/system/kernel/arch/m68k src/system/kernel/arch/ppc src/system/kernel/arch/x86 src/system/kernel/vm Message-ID: <200808051720.m75HKMsu008736@sheep.berlios.de> Author: bonefish Date: 2008-08-05 19:19:46 +0200 (Tue, 05 Aug 2008) New Revision: 26819 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26819&view=rev Modified: haiku/trunk/headers/private/kernel/kernel.h haiku/trunk/headers/private/system/thread_defs.h haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/cpu.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp haiku/trunk/src/system/kernel/arch/m68k/arch_thread.c haiku/trunk/src/system/kernel/arch/ppc/arch_debug.cpp haiku/trunk/src/system/kernel/arch/ppc/arch_thread.c haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp haiku/trunk/src/system/kernel/team.cpp haiku/trunk/src/system/kernel/thread.cpp haiku/trunk/src/system/kernel/vm/vm.cpp Log: * Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not include the guard pages. Adjusted the kernel and boot loader code accordingly -- the guard pages size is added/not removed respectively. The stack size passed to _kern_spawn_thread() is now the actually usable size, and it is no longer possible to specify a size smaller than or equal to the guard pages size. * vm_create_anonymous_area(): Precommit two pages maximum -- a stack with only one page usable size obviously doesn't need two pages. Modified: haiku/trunk/headers/private/kernel/kernel.h =================================================================== --- haiku/trunk/headers/private/kernel/kernel.h 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/headers/private/kernel/kernel.h 2008-08-05 17:19:46 UTC (rev 26819) @@ -27,12 +27,13 @@ // At least, you then know that the stack overflows in this case :) /** Size of the kernel stack */ -#ifndef DEBUG_KERNEL_STACKS -# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 12 kB +#define KERNEL_STACK_SIZE (B_PAGE_SIZE * 3) // 12 kB + +#ifdef DEBUG_KERNEL_STACKS +# define KERNEL_STACK_GUARD_PAGES 1 #else -# define KERNEL_STACK_SIZE (B_PAGE_SIZE * 4) // 12 kB + one guard page +# define KERNEL_STACK_GUARD_PAGES 0 #endif -#define KERNEL_STACK_GUARD_PAGES 1 /** Size of the environmental variables space for a process */ #define ENV_SIZE (B_PAGE_SIZE * 8) Modified: haiku/trunk/headers/private/system/thread_defs.h =================================================================== --- haiku/trunk/headers/private/system/thread_defs.h 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/headers/private/system/thread_defs.h 2008-08-05 17:19:46 UTC (rev 26819) @@ -14,11 +14,14 @@ #define THREAD_CONTINUED 0x4 /** 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 +#define USER_STACK_GUARD_PAGES 4 // 16 kB +#define USER_MAIN_THREAD_STACK_SIZE (16 * 1024 * 1024 \ + - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB +#define USER_STACK_SIZE (256 * 1024 \ + - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 256 kB +#define MIN_USER_STACK_SIZE (4 * 1024) // 4 KB +#define MAX_USER_STACK_SIZE (16 * 1024 * 1024 \ + - USER_STACK_GUARD_PAGES * B_PAGE_SIZE) // 16 MB struct thread_creation_attributes { Modified: haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/boot/platform/atari_m68k/mmu.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -57,12 +57,12 @@ * 0xdNNNNN video buffer usually there, as per v_bas_ad * (=Logbase() but Physbase() is better) * - * The first 32 MB (2) are identity mapped (0x0 - 0x1000000); paging - * is turned on. The kernel is mapped at 0x80000000, all other stuff - * mapped by the loader (kernel args, modules, driver settings, ...) - * comes after 0x81000000 which means that there is currently only + * The first 32 MB (2) are identity mapped (0x0 - 0x1000000); paging + * is turned on. The kernel is mapped at 0x80000000, all other stuff + * mapped by the loader (kernel args, modules, driver settings, ...) + * comes after 0x81000000 which means that there is currently only * 1 MB reserved for the kernel itself (see kMaxKernelSize). - * + * * (1) no need for user stack, we are already in supervisor mode in the * loader. * (2) maps the whole regular ST space; transparent translation registers @@ -143,9 +143,9 @@ mmu_get_next_page_tables() { #if 0 - TRACE(("mmu_get_next_page_tables, sNextPageTableAddress %p, kPageTableRegionEnd %p\n", + TRACE(("mmu_get_next_page_tables, sNextPageTableAddress %p, kPageTableRegionEnd %p\n", sNextPageTableAddress, kPageTableRegionEnd)); - + addr_t address = sNextPageTableAddress; if (address >= kPageTableRegionEnd) return (uint32 *)get_next_physical_page(); @@ -492,7 +492,7 @@ // seg 0x10 - kernel 4GB data set_segment_descriptor(&virtualGDT[2], 0, 0xffffffff, DT_DATA_WRITEABLE, DPL_KERNEL); - + // seg 0x1b - ring 3 user 4GB code set_segment_descriptor(&virtualGDT[3], 0, 0xffffffff, DT_CODE_READABLE, DPL_USER); @@ -613,10 +613,12 @@ // set virtual addr for interrupt vector table gKernelArgs.arch_args.vir_vbr = gKernelArgs.arch_args.vir_pgroot + VBR_PAGE_OFFSET; - + // map in a kernel stack - gKernelArgs.cpu_kstack[0].start = (addr_t)mmu_allocate(NULL, KERNEL_STACK_SIZE); - gKernelArgs.cpu_kstack[0].size = KERNEL_STACK_SIZE; + gKernelArgs.cpu_kstack[0].start = (addr_t)mmu_allocate(NULL, + KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + gKernelArgs.cpu_kstack[0].size = KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; TRACE(("kernel stack at 0x%lx to 0x%lx\n", gKernelArgs.cpu_kstack[0].start, gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size)); @@ -633,9 +635,9 @@ gKernelArgs.physical_memory_range[1].size = fastram_top - ATARI_FASTRAM_BASE; gKernelArgs.num_physical_memory_ranges++; - + } - + // mark the video area allocated addr_t video_base = *TOSVAR_memtop; video_base &= ~(B_PAGE_SIZE-1); Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -302,7 +302,7 @@ dprintf("extended memory info (from 0xe820):\n"); for (uint32 i = 0; i < count; i++) { dprintf(" base 0x%08Lx, len 0x%08Lx, type %lu (%s)\n", - block[i].base_addr, block[i].length, + block[i].base_addr, block[i].length, block[i].type, e820_memory_type(block[i].type)); } #endif @@ -606,8 +606,9 @@ // map in a kernel stack gKernelArgs.cpu_kstack[0].start = (addr_t)mmu_allocate(NULL, - KERNEL_STACK_SIZE); - gKernelArgs.cpu_kstack[0].size = KERNEL_STACK_SIZE; + KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + gKernelArgs.cpu_kstack[0].size = KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; TRACE(("kernel stack at 0x%lx to 0x%lx\n", gKernelArgs.cpu_kstack[0].start, gKernelArgs.cpu_kstack[0].start + gKernelArgs.cpu_kstack[0].size)); Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -396,8 +396,10 @@ for (uint32 i = 1; i < gKernelArgs.num_cpus; i++) { // create a final stack the trampoline code will put the ap processor on - gKernelArgs.cpu_kstack[i].start = (addr_t)mmu_allocate(NULL, KERNEL_STACK_SIZE); - gKernelArgs.cpu_kstack[i].size = KERNEL_STACK_SIZE; + gKernelArgs.cpu_kstack[i].start = (addr_t)mmu_allocate(NULL, + KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + gKernelArgs.cpu_kstack[i].size = KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; } } @@ -438,14 +440,18 @@ // set this stack up finalStack = (uint32 *)gKernelArgs.cpu_kstack[i].start; - memset(finalStack, 0, KERNEL_STACK_SIZE); - tempStack = (finalStack + KERNEL_STACK_SIZE / sizeof(uint32)) - 1; + memset((uint8*)finalStack + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE, 0, + KERNEL_STACK_SIZE); + tempStack = (finalStack + + (KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE) + / sizeof(uint32)) - 1; *tempStack = (uint32)&smp_cpu_ready; // set the trampoline stack up tempStack = (uint32 *)(trampolineStack + B_PAGE_SIZE - 4); // final location of the stack - *tempStack = ((uint32)finalStack) + KERNEL_STACK_SIZE - sizeof(uint32); + *tempStack = ((uint32)finalStack) + KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE - sizeof(uint32); tempStack--; // page dir *tempStack = gKernelArgs.arch_args.phys_pgdir; Modified: haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/cpu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/cpu.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/boot/platform/openfirmware/arch/ppc/cpu.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -76,7 +76,7 @@ gKernelArgs.arch_args.cpu_frequency = clockFrequency; gKernelArgs.arch_args.bus_frequency = busFrequency; gKernelArgs.arch_args.time_base_frequency = timeBaseFrequency; - + TRACE((" CPU clock frequency: %ld\n", clockFrequency)); TRACE((" bus clock frequency: %ld\n", busFrequency)); TRACE((" time base frequency: %ld\n", timeBaseFrequency)); @@ -84,7 +84,7 @@ cpuCount++; } - + if (cpuCount == 0) { printf("boot_arch_cpu_init(): Found no CPUs!\n"); return B_ERROR; @@ -95,7 +95,8 @@ // allocate the kernel stacks (the memory stuff is already initialized // at this point) addr_t stack = (addr_t)arch_mmu_allocate((void*)0x80000000, - cpuCount * KERNEL_STACK_SIZE, B_READ_AREA | B_WRITE_AREA, false); + cpuCount * (KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE), + B_READ_AREA | B_WRITE_AREA, false); if (!stack) { printf("boot_arch_cpu_init(): Failed to allocate kernel stack(s)!\n"); return B_NO_MEMORY; @@ -103,8 +104,9 @@ for (int i = 0; i < cpuCount; i++) { gKernelArgs.cpu_kstack[i].start = stack; - gKernelArgs.cpu_kstack[i].size = KERNEL_STACK_SIZE; - stack += KERNEL_STACK_SIZE; + gKernelArgs.cpu_kstack[i].size = KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; + stack += KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; } return B_OK; Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_debug.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -180,7 +180,7 @@ kprintf(" kernel stack: %p to %p\n", (void *)thread->kernel_stack_base, - (void *)(thread->kernel_stack_base + KERNEL_STACK_SIZE)); + (void *)(thread->kernel_stack_top)); if (thread->user_stack_base != 0) { kprintf(" user stack: %p to %p\n", (void *)thread->user_stack_base, Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_thread.c =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_thread.c 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_thread.c 2008-08-05 17:19:46 UTC (rev 26819) @@ -110,7 +110,7 @@ // the one we're switching to is kernel space return m68k_translation_map_get_pgdir(&vm_kernel_address_space()->translation_map); } - + return m68k_translation_map_get_pgdir(&to->team->address_space->translation_map); } @@ -150,15 +150,15 @@ void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; - addr_t *kstackTop = kstack + KERNEL_STACK_SIZE / sizeof(addr_t); + addr_t *kstackTop = (addr_t *)t->kernel_stack_base; // clear the kernel stack #ifdef DEBUG_KERNEL_STACKS # ifdef STACK_GROWS_DOWNWARDS memset((void *)((addr_t)kstack + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE), 0, - KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + KERNEL_STACK_SIZE); # else - memset(kstack, 0, KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + memset(kstack, 0, KERNEL_STACK_SIZE); # endif #else memset(kstack, 0, KERNEL_STACK_SIZE); Modified: haiku/trunk/src/system/kernel/arch/ppc/arch_debug.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/ppc/arch_debug.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/arch/ppc/arch_debug.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -179,7 +179,7 @@ kprintf(" kernel stack: %p to %p\n", (void *)thread->kernel_stack_base, - (void *)(thread->kernel_stack_base + KERNEL_STACK_SIZE)); + (void *)(thread->kernel_stack_top)); if (thread->user_stack_base != 0) { kprintf(" user stack: %p to %p\n", (void *)thread->user_stack_base, Modified: haiku/trunk/src/system/kernel/arch/ppc/arch_thread.c =================================================================== --- haiku/trunk/src/system/kernel/arch/ppc/arch_thread.c 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/arch/ppc/arch_thread.c 2008-08-05 17:19:46 UTC (rev 26819) @@ -122,15 +122,15 @@ void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; - addr_t *kstackTop = kstack + KERNEL_STACK_SIZE / sizeof(addr_t); + addr_t *kstackTop = (addr_t *)t->kernel_stack_top; // clear the kernel stack #ifdef DEBUG_KERNEL_STACKS # ifdef STACK_GROWS_DOWNWARDS memset((void *)((addr_t)kstack + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE), 0, - KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + KERNEL_STACK_SIZE); # else - memset(kstack, 0, KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + memset(kstack, 0, KERNEL_STACK_SIZE); # endif #else memset(kstack, 0, KERNEL_STACK_SIZE); @@ -180,9 +180,9 @@ arch_thread_context_switch(struct thread *t_from, struct thread *t_to) { // set the new kernel stack in the EAR register. - // this is used in the exception handler code to decide what kernel stack to - // switch to if the exception had happened when the processor was in user mode - asm("mtear %0" :: "g"(t_to->kernel_stack_base + KERNEL_STACK_SIZE - 8)); + // this is used in the exception handler code to decide what kernel stack to + // switch to if the exception had happened when the processor was in user mode + asm("mtear %0" :: "g"(t_to->kernel_stack_top - 8)); // switch the asids if we need to if (t_to->team->address_space != NULL) { Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -261,9 +261,9 @@ #ifdef DEBUG_KERNEL_STACKS # ifdef STACK_GROWS_DOWNWARDS memset((void *)((addr_t)kstack + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE), 0, - KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + KERNEL_STACK_SIZE); # else - memset(kstack, 0, KERNEL_STACK_SIZE - KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE); + memset(kstack, 0, KERNEL_STACK_SIZE); # endif #else memset(kstack, 0, KERNEL_STACK_SIZE); Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/team.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -985,10 +985,12 @@ // ToDo: ENV_SIZE is a) limited, and b) not used after libroot copied it to the heap // ToDo: we could reserve the whole USER_STACK_REGION upfront... - sizeLeft = PAGE_ALIGN(USER_MAIN_THREAD_STACK_SIZE + TLS_SIZE + sizeLeft = PAGE_ALIGN(USER_MAIN_THREAD_STACK_SIZE + + USER_STACK_GUARD_PAGES * B_PAGE_SIZE + TLS_SIZE + sizeof(struct user_space_program_args) + teamArgs->flat_args_size); t->user_stack_base = USER_STACK_REGION + USER_STACK_REGION_SIZE - sizeLeft; - t->user_stack_size = USER_MAIN_THREAD_STACK_SIZE; + t->user_stack_size = USER_MAIN_THREAD_STACK_SIZE + + USER_STACK_GUARD_PAGES * B_PAGE_SIZE; // the exact location at the end of the user stack area sprintf(ustack_name, "%s_main_stack", team->name); Modified: haiku/trunk/src/system/kernel/thread.cpp =================================================================== --- haiku/trunk/src/system/kernel/thread.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/thread.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -391,7 +391,8 @@ 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, + KERNEL_STACK_SIZE + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE, + B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_KERNEL_STACK_AREA); if (thread->kernel_stack_area < 0) { @@ -405,7 +406,8 @@ return status; } - thread->kernel_stack_top = thread->kernel_stack_base + KERNEL_STACK_SIZE; + thread->kernel_stack_top = thread->kernel_stack_base + KERNEL_STACK_SIZE + + KERNEL_STACK_GUARD_PAGES * B_PAGE_SIZE; state = disable_interrupts(); GRAB_THREAD_LOCK(); @@ -499,6 +501,7 @@ thread->user_stack_size = USER_STACK_SIZE; else thread->user_stack_size = PAGE_ALIGN(attributes.stack_size); + thread->user_stack_size += USER_STACK_GUARD_PAGES * B_PAGE_SIZE; snprintf(stack_name, B_OS_NAME_LENGTH, "%s_%ld_stack", attributes.name, thread->id); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-05 17:13:06 UTC (rev 26818) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-05 17:19:46 UTC (rev 26819) @@ -1576,6 +1576,7 @@ vm_cache *cache; vm_page *page = NULL; bool isStack = (protection & B_STACK_AREA) != 0; + page_num_t guardPages; bool canOvercommit = false; addr_t physicalBase = 0; @@ -1693,10 +1694,10 @@ // create an anonymous cache // if it's a stack, make sure that two pages are available at least - status = VMCacheFactory::CreateAnonymousCache(cache, - canOvercommit, isStack ? 2 : 0, - isStack ? ((protection & B_USER_PROTECTION) != 0 ? - USER_STACK_GUARD_PAGES : KERNEL_STACK_GUARD_PAGES) : 0, + guardPages = isStack ? ((protection & B_USER_PROTECTION) != 0 + ? USER_STACK_GUARD_PAGES : KERNEL_STACK_GUARD_PAGES) : 0; + status = VMCacheFactory::CreateAnonymousCache(cache, canOvercommit, + isStack ? (min_c(2, size / B_PAGE_SIZE - guardPages)) : 0, guardPages, wiring == B_NO_LOCK); if (status != B_OK) goto err1; From anevilyak at gmail.com Tue Aug 5 19:47:37 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Tue, 5 Aug 2008 12:47:37 -0500 Subject: [Haiku-commits] r26819 - in haiku/trunk: headers/private/kernel headers/private/system src/system/boot/platform/atari_m68k src/system/boot/platform/bios_ia32 src/system/boot/platform/openfirmware/arch/ppc src/system/kernel src/system/kernel/arch/ Message-ID: On Tue, Aug 5, 2008 at 12:20 PM, wrote: > Author: bonefish > Date: 2008-08-05 19:19:46 +0200 (Tue, 05 Aug 2008) > New Revision: 26819 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26819&view=rev Does this by any chance fix ticket 2559? Regards, Rene From axeld at mail.berlios.de Tue Aug 5 19:54:15 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 19:54:15 +0200 Subject: [Haiku-commits] r26820 - in haiku/trunk: headers/posix src/system/libroot/posix Message-ID: <200808051754.m75HsFgd023544@sheep.berlios.de> Author: axeld Date: 2008-08-05 19:54:14 +0200 (Tue, 05 Aug 2008) New Revision: 26820 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26820&view=rev Added: haiku/trunk/headers/posix/sched.h haiku/trunk/src/system/libroot/posix/scheduler.cpp Modified: haiku/trunk/src/system/libroot/posix/Jamfile Log: * Patch by Andreas that adds sched.h, and sched_yield() to Haiku. * This closes ticket #2568. Added: haiku/trunk/headers/posix/sched.h =================================================================== --- haiku/trunk/headers/posix/sched.h 2008-08-05 17:19:46 UTC (rev 26819) +++ haiku/trunk/headers/posix/sched.h 2008-08-05 17:54:14 UTC (rev 26820) @@ -0,0 +1,18 @@ +/* + * Copyright 2008, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef _SCHED_H_ +#define _SCHED_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int sched_yield(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SCHED_H_ */ Modified: haiku/trunk/src/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/Jamfile 2008-08-05 17:19:46 UTC (rev 26819) +++ haiku/trunk/src/system/libroot/posix/Jamfile 2008-08-05 17:54:14 UTC (rev 26820) @@ -21,6 +21,7 @@ inttypes.c poll.c $(PWD_BACKEND) + scheduler.cpp semaphore.cpp syslog.cpp termios.c Added: haiku/trunk/src/system/libroot/posix/scheduler.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/scheduler.cpp 2008-08-05 17:19:46 UTC (rev 26819) +++ haiku/trunk/src/system/libroot/posix/scheduler.cpp 2008-08-05 17:54:14 UTC (rev 26820) @@ -0,0 +1,17 @@ +/* + * Copyright 2008, Andreas F?rber, andreas.faerber at web.de + * Distributed under the terms of the MIT license. + */ + +#include + +#include + + +int +sched_yield(void) +{ + _kern_thread_yield(); + return 0; +} + From julun at mail.berlios.de Tue Aug 5 22:39:12 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Tue, 5 Aug 2008 22:39:12 +0200 Subject: [Haiku-commits] r26821 - in haiku/trunk/src: add-ons/print/drivers/preview libs/print/libprint Message-ID: <200808052039.m75KdC71004732@sheep.berlios.de> Author: julun Date: 2008-08-05 22:39:11 +0200 (Tue, 05 Aug 2008) New Revision: 26821 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26821&view=rev Removed: haiku/trunk/src/add-ons/print/drivers/preview/Preview.cpp haiku/trunk/src/add-ons/print/drivers/preview/Preview.h Modified: haiku/trunk/src/add-ons/print/drivers/preview/Jamfile haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.cpp haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.h haiku/trunk/src/libs/print/libprint/Preview.cpp Log: * make use of libprint inbuild Preview class Modified: haiku/trunk/src/add-ons/print/drivers/preview/Jamfile =================================================================== --- haiku/trunk/src/add-ons/print/drivers/preview/Jamfile 2008-08-05 17:54:14 UTC (rev 26820) +++ haiku/trunk/src/add-ons/print/drivers/preview/Jamfile 2008-08-05 20:39:11 UTC (rev 26821) @@ -10,10 +10,9 @@ PageSetupWindow.cpp JobSetupWindow.cpp Driver.cpp - Preview.cpp PrinterDriver.cpp PreviewDriver.cpp - : be libprint.a + : be libprint.a $(TARGET_LIBSTDC++) ; Package haiku-printingkit-cvs : Deleted: haiku/trunk/src/add-ons/print/drivers/preview/Preview.cpp Deleted: haiku/trunk/src/add-ons/print/drivers/preview/Preview.h Modified: haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.cpp =================================================================== --- haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.cpp 2008-08-05 17:54:14 UTC (rev 26820) +++ haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.cpp 2008-08-05 20:39:11 UTC (rev 26821) @@ -7,6 +7,7 @@ */ #include "PreviewDriver.h" +#include "Preview.h" #define PREVIEW_DRIVER_DEBUG 0 Modified: haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.h =================================================================== --- haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.h 2008-08-05 17:54:14 UTC (rev 26820) +++ haiku/trunk/src/add-ons/print/drivers/preview/PreviewDriver.h 2008-08-05 20:39:11 UTC (rev 26821) @@ -6,9 +6,9 @@ * Michael Pfeiffer */ -#include "Preview.h" #include "PrinterDriver.h" + class PreviewDriver : public PrinterDriver { public: PreviewDriver(BNode* spoolDir); Modified: haiku/trunk/src/libs/print/libprint/Preview.cpp =================================================================== --- haiku/trunk/src/libs/print/libprint/Preview.cpp 2008-08-05 17:54:14 UTC (rev 26820) +++ haiku/trunk/src/libs/print/libprint/Preview.cpp 2008-08-05 20:39:11 UTC (rev 26821) @@ -212,15 +212,20 @@ if (fReader.JobSettings()->FindInt32(kJDPageSelection, &value32) == B_OK) fPageSelection = (JobData::PageSelection)value32; - fReader.JobSettings()->FindInt32(kJDNup, &fNumberOfPagesPerPage); - fReader.JobSettings()->FindBool(kJDReverse, &fReverse); + bool value; + if (fReader.JobSettings()->FindBool(kJDReverse, &value) == B_OK) + fReverse = value; + + if (fReader.JobSettings()->FindInt32(kJDNup, &value32) == B_OK) + fNumberOfPagesPerPage = value32; + fNumberOfPages = (fReader.NumberOfPages() + fNumberOfPagesPerPage - 1) / fNumberOfPagesPerPage; if (fPageSelection == JobData::kOddNumberedPages) fNumberOfPages = (fNumberOfPages + 1) / 2; else if (fPageSelection == JobData::kEvenNumberedPages) - fNumberOfPages /= 2; + fNumberOfPages /= 2; fPaperRect = fReader.PaperRect(); fPrintableRect = fReader.PrintableRect(); @@ -685,7 +690,7 @@ int32 pageNumber = _GetPageNumber(index); if (pageNumber < 0) continue; - + if (!_IsPageLoaded(pageNumber)) _LoadPage(pageNumber); @@ -700,7 +705,7 @@ BRegion clip(clipRect); ConstrainClippingRegion(&clip); - + SetScale(_ZoomFactor() * scaling); fCachedPage->Draw(this, printRect.OffsetByCopy(offset)); @@ -765,7 +770,7 @@ page *= 2; // 0, 2, 4, ... else if (fPageSelection == JobData::kEvenNumberedPages) page = 2 * page + 1; // 1, 3, 5, ... - + return page * fNumberOfPagesPerPage + index; } @@ -847,7 +852,7 @@ // cancel printing if user closes the preview window SetUserQuitResult(B_ERROR); - + BButton *printJob = new BButton(BRect(), "printJob", "Print", new BMessage(MSG_PRINT_JOB), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); AddChild(printJob); From julun at mail.berlios.de Tue Aug 5 22:40:49 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Tue, 5 Aug 2008 22:40:49 +0200 Subject: [Haiku-commits] r26822 - haiku/trunk/src/kits/interface Message-ID: <200808052040.m75KenpN004980@sheep.berlios.de> Author: julun Date: 2008-08-05 22:40:49 +0200 (Tue, 05 Aug 2008) New Revision: 26822 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26822&view=rev Modified: haiku/trunk/src/kits/interface/PrintJob.cpp Log: * replace some whitespaces * return error in case we could not get all values from JobConfig Modified: haiku/trunk/src/kits/interface/PrintJob.cpp =================================================================== --- haiku/trunk/src/kits/interface/PrintJob.cpp 2008-08-05 20:39:11 UTC (rev 26821) +++ haiku/trunk/src/kits/interface/PrintJob.cpp 2008-08-05 20:40:49 UTC (rev 26822) @@ -197,7 +197,8 @@ delete fSetupMessage; fSetupMessage = messenger.Result(); - _HandlePrintSetup(fSetupMessage); + if (!_HandlePrintSetup(fSetupMessage)) + return B_ERROR; return B_OK; } @@ -289,7 +290,7 @@ fSpoolFile->Write(&fSpoolFileHeader, sizeof(print_file_header)); // set file attributes - app_info appInfo; + app_info appInfo; be_app->GetAppInfo(&appInfo); const char* printerName = ""; fSetupMessage->FindString(PSRV_FIELD_CURRENT_PRINTER, &printerName); @@ -465,14 +466,14 @@ int32 BPrintJob::FirstPage() { - return fFirstPage; + return fFirstPage; } int32 BPrintJob::LastPage() { - return fLastPage; + return fLastPage; } From julun at mail.berlios.de Tue Aug 5 22:41:32 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Tue, 5 Aug 2008 22:41:32 +0200 Subject: [Haiku-commits] r26823 - haiku/trunk/src/apps/stylededit Message-ID: <200808052041.m75KfWkm005050@sheep.berlios.de> Author: julun Date: 2008-08-05 22:41:31 +0200 (Tue, 05 Aug 2008) New Revision: 26823 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26823&view=rev Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp Log: * whitespace cleanup Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2008-08-05 20:40:49 UTC (rev 26822) +++ haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2008-08-05 20:41:31 UTC (rev 26823) @@ -105,8 +105,8 @@ viewFrame.top = fMenuBar->Bounds().Height() + 1; viewFrame.right -= B_V_SCROLL_BAR_WIDTH; viewFrame.left = 0; - viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT; - + viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT; + BRect textBounds = viewFrame; textBounds.OffsetTo(B_ORIGIN); textBounds.InsetBy(TEXT_INSET, TEXT_INSET); @@ -129,21 +129,21 @@ BMenuItem* menuItem; menu->AddItem(menuItem = new BMenuItem("New", new BMessage(MENU_NEW), 'N')); menuItem->SetTarget(be_app); - + menu->AddItem(menuItem = new BMenuItem(fRecentMenu = new BMenu("Open" B_UTF8_ELLIPSIS), new BMessage(MENU_OPEN))); menuItem->SetShortcut('O', 0); menuItem->SetTarget(be_app); menu->AddSeparatorItem(); - menu->AddItem(fSaveItem = new BMenuItem("Save", new BMessage(MENU_SAVE), 'S')); - fSaveItem->SetEnabled(false); + menu->AddItem(fSaveItem = new BMenuItem("Save", new BMessage(MENU_SAVE), 'S')); + fSaveItem->SetEnabled(false); menu->AddItem(menuItem = new BMenuItem("Save As" B_UTF8_ELLIPSIS, new BMessage(MENU_SAVEAS))); menuItem->SetShortcut('S',B_SHIFT_KEY); menuItem->SetEnabled(true); menu->AddItem(fRevertItem = new BMenuItem("Revert to Saved" B_UTF8_ELLIPSIS, - new BMessage(MENU_REVERT))); + new BMessage(MENU_REVERT))); fRevertItem->SetEnabled(false); menu->AddItem(menuItem = new BMenuItem("Close", new BMessage(MENU_CLOSE), 'W')); @@ -173,7 +173,7 @@ menu->AddItem(menuItem = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); menuItem->SetTarget(fTextView); menu->AddItem(fClearItem = new BMenuItem("Clear", new BMessage(MENU_CLEAR))); - fClearItem->SetEnabled(false); + fClearItem->SetEnabled(false); fClearItem->SetTarget(fTextView); menu->AddSeparatorItem(); @@ -203,7 +203,7 @@ for (uint32 i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++) { BMessage* fontMessage = new BMessage(FONT_SIZE); fontMessage->AddFloat("size", fontSizes[i]); - + char label[64]; snprintf(label, sizeof(label), "%ld", fontSizes[i]); fFontSizeMenu->AddItem(menuItem = new BMenuItem(label, fontMessage)); @@ -211,14 +211,14 @@ if (fontSizes[i] == (int32)be_plain_font->Size()) menuItem->SetMarked(true); } - + // "Color"-subMenu fFontColorMenu = new BMenu("Color"); fFontColorMenu->SetRadioMode(true); fFontMenu->AddItem(fFontColorMenu); - + fFontColorMenu->AddItem(fBlackItem = new BMenuItem("Black", new BMessage(FONT_COLOR))); - fBlackItem->SetMarked(true); + fBlackItem->SetMarked(true); fFontColorMenu->AddItem(fRedItem = new ColorMenuItem("Red", RED, new BMessage(FONT_COLOR))); fFontColorMenu->AddItem(fGreenItem = new ColorMenuItem("Green", GREEN, new BMessage(FONT_COLOR))); fFontColorMenu->AddItem(fBlueItem = new ColorMenuItem("Blue", BLUE, new BMessage(FONT_COLOR))); @@ -269,10 +269,10 @@ // "Align"-subMenu: subMenu = new BMenu("Align"); - subMenu->SetRadioMode(true); + subMenu->SetRadioMode(true); subMenu->AddItem(fAlignLeft = new BMenuItem("Left", new BMessage(ALIGN_LEFT))); - menuItem->SetMarked(true); + menuItem->SetMarked(true); subMenu->AddItem(fAlignCenter = new BMenuItem("Center", new BMessage(ALIGN_CENTER))); subMenu->AddItem(fAlignRight = new BMenuItem("Right", new BMessage(ALIGN_RIGHT))); @@ -350,7 +350,7 @@ fTextView->Undo(be_clipboard); break; - case B_CUT: + case B_CUT: fTextView->Cut(be_clipboard); break; case B_COPY: @@ -359,7 +359,7 @@ case B_PASTE: fTextView->Paste(be_clipboard); break; - case MENU_CLEAR: + case MENU_CLEAR: fTextView->Clear(); break; case MENU_FIND: @@ -416,7 +416,7 @@ { message->FindBool("casesens", &fCaseSens); message->FindString("FindText",&fStringToFind); - message->FindString("ReplaceText",&fReplaceString); + message->FindString("ReplaceText",&fReplaceString); bool allWindows; message->FindBool("allwindows", &allWindows); @@ -426,9 +426,9 @@ if (allWindows) SearchAllWindows(fStringToFind, fReplaceString, fCaseSens); - else + else ReplaceAll(fStringToFind, fReplaceString, fCaseSens); - break; + break; } // Font menu @@ -541,12 +541,12 @@ // we cleaned! fClean = true; fUndoCleans = false; - } else if (fClean) { + } else if (fClean) { // if we were clean // then a redo will make us clean again fRedoCleans = true; fClean = false; - } + } // set mode fCanUndo = false; fCanRedo = true; @@ -576,7 +576,7 @@ } if (fClean) { fRevertItem->SetEnabled(false); - fSaveItem->SetEnabled(fSaveMessage == NULL); + fSaveItem->SetEnabled(fSaveMessage == NULL); } else { fRevertItem->SetEnabled(fSaveMessage != NULL); fSaveItem->SetEnabled(true); @@ -605,7 +605,7 @@ BMessage documents; be_roster->GetRecentDocuments(&documents, 9, NULL, APP_SIGNATURE); - // delete old items.. + // delete old items.. // shatty: it would be preferable to keep the old // menu around instead of continuously thrashing // the menu, but unfortunately there does not @@ -642,7 +642,7 @@ if (oldSizeItem != NULL) oldSizeItem->SetMarked(false); - // find the current font, color, size + // find the current font, color, size BFont font; uint32 sameProperties; rgb_color color = BLACK; @@ -677,7 +677,7 @@ fYellowItem->SetMarked(true); } } - } + } } if (sameProperties & B_FONT_SIZE) { @@ -725,7 +725,7 @@ void StyledEditWindow::Quit() { - styled_edit_app->CloseDocument(); + styled_edit_app->CloseDocument(); BWindow::Quit(); } @@ -881,7 +881,7 @@ } } - fSavePanel->SetSaveText(Title()); + fSavePanel->SetSaveText(Title()); if (message != NULL) fSavePanel->SetMessage(message); @@ -992,20 +992,20 @@ status = entry.SetTo(&dir, name); if (status == B_OK) status = entry.GetRef(&ref); - if (status != B_OK || !entry.Exists()) { - BAlert *vanishedAlert; + if (status != B_OK || !entry.Exists()) { + BAlert *vanishedAlert; BString alertText; alertText.SetTo("Cannot revert, file not found: \""); alertText << name; alertText << "\"."; - vanishedAlert = new BAlert("vanishedAlert", alertText.String(), "Bummer", 0, 0, + vanishedAlert = new BAlert("vanishedAlert", alertText.String(), "Bummer", 0, 0, B_WIDTH_AS_USUAL, B_EVEN_SPACING, B_STOP_ALERT); vanishedAlert->SetShortcut(0, B_ESCAPE); vanishedAlert->Go(); return; } - int32 buttonIndex = 0; + int32 buttonIndex = 0; BAlert* revertAlert; BString alertText; alertText.SetTo("Revert to the last version of \""); @@ -1036,7 +1036,7 @@ fCanRedo = false; // clear clean modes - fSaveItem->SetEnabled(false); + fSaveItem->SetEnabled(false); fRevertItem->SetEnabled(false); fUndoCleans = false; fRedoCleans = false; @@ -1071,7 +1071,7 @@ result = PageSetup(documentName); if (result != B_OK) return; - } + } BPrintJob printJob(documentName); printJob.SetSettings(new BMessage(*fPrintSettings)); @@ -1080,10 +1080,10 @@ return; // information from printJob - BRect printableRect = printJob.PrintableRect(); + BRect printableRect = printJob.PrintableRect(); int32 firstPage = printJob.FirstPage(); int32 lastPage = printJob.LastPage(); - + // lines eventually to be used to compute pages to print int32 firstLine = 0; int32 lastLine = fTextView->CountLines(); @@ -1115,7 +1115,7 @@ lastLine = currentLine - 1; } - + printJob.BeginJob(); if (fTextView->CountLines() > 0 && fTextView->TextLength() > 0) { int32 printLine = firstLine; @@ -1138,21 +1138,21 @@ printJob.SpoolPage(); } } - + printJob.CommitJob(); } bool StyledEditWindow::Search(BString string, bool caseSensitive, bool wrap, bool backsearch) -{ +{ int32 start; int32 finish; - start = B_ERROR; + start = B_ERROR; - int32 length = string.Length(); + int32 length = string.Length(); if (length == 0) return false; @@ -1195,11 +1195,11 @@ return true; } - return false; + return false; } -void +void StyledEditWindow::FindSelection() { int32 selectionStart, selectionFinish; @@ -1252,9 +1252,9 @@ fTextView->SetText(viewText.String()); - if (viewText.Length() < textStart) + if (viewText.Length() < textStart) textStart = viewText.Length(); - if (viewText.Length() < textFinish) + if (viewText.Length() < textFinish) textFinish = viewText.Length(); fTextView->Select(textStart,textFinish); @@ -1297,7 +1297,7 @@ fTextView->GetFontAndColor(&font, &sameProperties); font.SetSize(fontSize); fTextView->SetFontAndColor(&font, B_FONT_SIZE); - + _UpdateCleanUndoRedoSaveRevert(); } @@ -1350,10 +1350,10 @@ { fClean = false; fUndoCleans = false; - fRedoCleans = false; + fRedoCleans = false; fRevertItem->SetEnabled(fSaveMessage != NULL); fSaveItem->SetEnabled(true); - fUndoItem->SetLabel("Can't Undo"); + fUndoItem->SetLabel("Can't Undo"); fUndoItem->SetEnabled(false); fCanUndo = false; fCanRedo = false; From julun at mail.berlios.de Tue Aug 5 22:42:34 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Tue, 5 Aug 2008 22:42:34 +0200 Subject: [Haiku-commits] r26824 - haiku/trunk/src/apps/stylededit Message-ID: <200808052042.m75KgYIJ005128@sheep.berlios.de> Author: julun Date: 2008-08-05 22:42:34 +0200 (Tue, 05 Aug 2008) New Revision: 26824 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26824&view=rev Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp Log: * fix of by one error, makes printing of ranges work properly Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2008-08-05 20:41:31 UTC (rev 26823) +++ haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2008-08-05 20:42:34 UTC (rev 26824) @@ -1101,7 +1101,7 @@ currentLine++; } if (pagesInDocument == lastPage) - lastLine = currentLine; + lastLine = currentLine - 1; if (currentHeight >= printableRect.Height()) { pagesInDocument++; From axeld at mail.berlios.de Tue Aug 5 23:00:03 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 23:00:03 +0200 Subject: [Haiku-commits] r26825 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808052100.m75L03SL006727@sheep.berlios.de> Author: axeld Date: 2008-08-05 23:00:02 +0200 (Tue, 05 Aug 2008) New Revision: 26825 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26825&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.h Log: * Added a DMAResource::Init() method that gets a device node - for now, it will reuse the block_io attributes in the node to build the dma_restrictions. * DMAResource::Init() now dumps the dma_resources (should be done with the TRACE() macro later). * Turned off IOScheduler debug output. Modified: haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp 2008-08-05 20:42:34 UTC (rev 26824) +++ haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp 2008-08-05 21:00:02 UTC (rev 26825) @@ -20,7 +20,7 @@ #include -#define TRACE_IO_SCHEDULER +//#define TRACE_IO_SCHEDULER #ifdef TRACE_IO_SCHEDULER # define TRACE(x...) dprintf(x) #else Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-05 20:42:34 UTC (rev 26824) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-05 21:00:02 UTC (rev 26825) @@ -6,6 +6,8 @@ #include "dma_resources.h" +#include + #include #include @@ -20,6 +22,8 @@ #endif +extern device_manager_info gDeviceManagerModule; + const size_t kMaxBounceBufferSize = 4 * B_PAGE_SIZE; @@ -95,6 +99,40 @@ status_t +DMAResource::Init(device_node* node, size_t blockSize) +{ + dma_restrictions restrictions; + memset(&restrictions, 0, sizeof(dma_restrictions)); + + // TODO: add DMA attributes instead of reusing block_io's + + uint32 value; + if (gDeviceManagerModule.get_attr_uint32(node, + B_BLOCK_DEVICE_DMA_ALIGNMENT, &value, true) == B_OK) + restrictions.alignment = value + 1; + + if (gDeviceManagerModule.get_attr_uint32(node, + B_BLOCK_DEVICE_DMA_BOUNDARY, &value, true) == B_OK) + restrictions.boundary = value + 1; + + if (gDeviceManagerModule.get_attr_uint32(node, + B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &value, true) == B_OK) + restrictions.max_segment_size = value; + + if (gDeviceManagerModule.get_attr_uint32(node, + B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &value, true) == B_OK) + restrictions.max_transfer_size = value * blockSize; + + uint32 bufferCount; + if (gDeviceManagerModule.get_attr_uint32(node, + B_BLOCK_DEVICE_MAX_SG_BLOCKS, &bufferCount, true) != B_OK) + bufferCount = 16; + + return Init(restrictions, blockSize, bufferCount); +} + + +status_t DMAResource::Init(const dma_restrictions& restrictions, size_t blockSize, uint32 bufferCount) { @@ -123,6 +161,13 @@ fBounceBufferSize); } + dprintf("DMAResource@%p: low/high %lx/%lx, max segment count %lu, align %lu, " + "boundary %lu, max transfer %lu, max segment size %lu\n", this, + fRestrictions.low_address, fRestrictions.high_address, + fRestrictions.max_segment_count, fRestrictions.alignment, + fRestrictions.boundary, fRestrictions.max_transfer_size, + fRestrictions.max_segment_size); + fScratchVecs = (iovec*)malloc( sizeof(iovec) * fRestrictions.max_segment_count); if (fScratchVecs == NULL) @@ -150,9 +195,10 @@ area_id area = -1; if (size != 0) { - if (fRestrictions.alignment > B_PAGE_SIZE - || fRestrictions.boundary > B_PAGE_SIZE) - panic("not yet implemented"); + if (fRestrictions.alignment > B_PAGE_SIZE) + dprintf("dma buffer restrictions not yet implemented: alignment %lu\n", fRestrictions.alignment); + if (fRestrictions.boundary > B_PAGE_SIZE) + dprintf("dma buffer restrictions not yet implemented: boundary %lu\n", fRestrictions.boundary); size = ROUNDUP(size, B_PAGE_SIZE); Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-05 20:42:34 UTC (rev 26824) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-05 21:00:02 UTC (rev 26825) @@ -12,6 +12,7 @@ #include +struct device_node; struct IOOperation; struct IORequest; @@ -69,6 +70,7 @@ status_t Init(const dma_restrictions& restrictions, size_t blockSize, uint32 bufferCount); + status_t Init(device_node* node, size_t blockSize); status_t CreateBuffer(DMABuffer** _buffer) { return CreateBuffer(0, _buffer); } From mauricek at mail.berlios.de Tue Aug 5 23:09:01 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Tue, 5 Aug 2008 23:09:01 +0200 Subject: [Haiku-commits] r26826 - haiku/trunk/src/add-ons/media/plugins/raw_decoder Message-ID: <200808052109.m75L911p007697@sheep.berlios.de> Author: mauricek Date: 2008-08-05 23:09:01 +0200 (Tue, 05 Aug 2008) New Revision: 26826 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26826&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp Log: whitespace cleanup Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp 2008-08-05 21:00:02 UTC (rev 26825) +++ haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp 2008-08-05 21:09:01 UTC (rev 26826) @@ -67,9 +67,9 @@ if (ioEncodedFormat->type != B_MEDIA_RAW_AUDIO && ioEncodedFormat->type != B_MEDIA_RAW_VIDEO) return B_ERROR; - + fInputFormat = *ioEncodedFormat; - + if (ioEncodedFormat->type == B_MEDIA_RAW_VIDEO) { fInputSampleSize = ioEncodedFormat->u.raw_video.display.line_count * ioEncodedFormat->u.raw_video.display.bytes_per_row; fInputFrameSize = fInputSampleSize; @@ -80,10 +80,10 @@ // since ioEncodedFormat is later passed to the application by BMediaTrack::EncodedFormat() // we need to remove non public format specifications - + // remove non format bits, like channel order ioEncodedFormat->u.raw_audio.format &= B_AUDIO_FORMAT_MASK; - + switch (ioEncodedFormat->u.raw_audio.format) { case B_AUDIO_FORMAT_UINT8: case B_AUDIO_FORMAT_INT8: @@ -91,20 +91,20 @@ case B_AUDIO_FORMAT_INT32: case B_AUDIO_FORMAT_FLOAT32: break; // ok to pass through - + case B_AUDIO_FORMAT_INT24: ioEncodedFormat->u.raw_audio.format = B_AUDIO_FORMAT_INT32; break; - + case B_AUDIO_FORMAT_FLOAT64: ioEncodedFormat->u.raw_audio.format = B_AUDIO_FORMAT_FLOAT32; break; - + default: TRACE("RawDecoder::Setup: unknown input format\n"); return B_ERROR; } - + // since we can translate to a different buffer size, // suggest something nicer than delivered by the // file reader (perhaps we should even report wildcard?) @@ -142,7 +142,7 @@ RawDecoder::NegotiateAudioOutputFormat(media_format *ioDecodedFormat) { char s[1024]; - + string_for_format(*ioDecodedFormat, s, sizeof(s)); TRACE("RawDecoder::NegotiateAudioOutputFormat enter: %s\n", s); @@ -158,7 +158,7 @@ case media_raw_audio_format::B_AUDIO_INT: ioDecodedFormat->u.raw_audio.valid_bits = fInputFormat.u.raw_audio.valid_bits; break; // we can produce this on request - + default: switch (fInputFormat.u.raw_audio.format & B_AUDIO_FORMAT_MASK) { case media_raw_audio_format::B_AUDIO_SHORT: @@ -167,13 +167,13 @@ ioDecodedFormat->u.raw_audio.format = fInputFormat.u.raw_audio.format & B_AUDIO_FORMAT_MASK; ioDecodedFormat->u.raw_audio.valid_bits = 0; break; - + case media_raw_audio_format::B_AUDIO_INT: case B_AUDIO_FORMAT_INT24: ioDecodedFormat->u.raw_audio.format = media_raw_audio_format::B_AUDIO_INT; ioDecodedFormat->u.raw_audio.valid_bits = fInputFormat.u.raw_audio.valid_bits; break; - + case media_raw_audio_format::B_AUDIO_FLOAT: case B_AUDIO_FORMAT_FLOAT64: default: @@ -191,13 +191,13 @@ fOutputSampleSize = (ioDecodedFormat->u.raw_audio.format & B_AUDIO_FORMAT_SIZE_MASK); fOutputFrameSize = fOutputSampleSize * ioDecodedFormat->u.raw_audio.channel_count; - + if (ioDecodedFormat->u.raw_audio.byte_order == 0) ioDecodedFormat->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; - + ioDecodedFormat->u.raw_audio.channel_mask = 0; ioDecodedFormat->u.raw_audio.matrix_mask = 0; - + if (ioDecodedFormat->u.raw_audio.buffer_size < 128 || ioDecodedFormat->u.raw_audio.buffer_size > 65536) { ioDecodedFormat->u.raw_audio.buffer_size = AudioBufferSize( ioDecodedFormat->u.raw_audio.channel_count, @@ -207,9 +207,9 @@ // round down to exact multiple of output frame size ioDecodedFormat->u.raw_audio.buffer_size = (ioDecodedFormat->u.raw_audio.buffer_size / fOutputFrameSize) * fOutputFrameSize; } - + fOutputBufferFrameCount = ioDecodedFormat->u.raw_audio.buffer_size / fOutputFrameSize; - + // setup input swapping function if (fInputFormat.u.raw_audio.byte_order == B_MEDIA_HOST_ENDIAN) { fSwapInput = 0; @@ -288,7 +288,7 @@ break; } break; - + case B_AUDIO_FORMAT_INT8: switch (ioDecodedFormat->u.raw_audio.format) { case B_AUDIO_FORMAT_UINT8: @@ -431,14 +431,14 @@ debugger("RawDecoder::NegotiateAudioOutputFormat unknown input format\n"); break; } - + fChunkBuffer = 0; fChunkSize = 0; fStartTime = 0; string_for_format(*ioDecodedFormat, s, sizeof(s)); TRACE("RawDecoder::NegotiateAudioOutputFormat leave: %s\n", s); - + if (ioDecodedFormat->type == 0) debugger("RawDecoder::NegotiateAudioOutputFormat ioDecodedFormat->type == 0"); /* @@ -499,7 +499,7 @@ } // XXX should change channel order here for // B_AUDIO_FORMAT_CHANNEL_ORDER_WAVE and B_AUDIO_FORMAT_CHANNEL_ORDER_AIFF - + if (fSwapOutput) fSwapOutput(buffer, *frameCount * fInputFormat.u.raw_audio.channel_count); return *frameCount ? B_OK : B_ERROR; From mauricek at mail.berlios.de Tue Aug 5 23:09:13 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Tue, 5 Aug 2008 23:09:13 +0200 Subject: [Haiku-commits] r26827 - haiku/trunk/src/add-ons/media/plugins/raw_decoder Message-ID: <200808052109.m75L9DcN007721@sheep.berlios.de> Author: mauricek Date: 2008-08-05 23:09:12 +0200 (Tue, 05 Aug 2008) New Revision: 26827 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26827&view=rev Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp Log: * In case we do not have any frames to convert we'll need to break, otherwise we end up in an endless loop. This only happened when the remaining raw data provided did not contain enough content. In this particular case there were only 2 bytes remaining though the decoder needed 4 bytes to handle at least 1 frame. Seems like the audio file only provided data for one channel in the end, which did not lead to a B_LAST_BUFFER_ERROR yet as it has been read properly. * This fixes bug 1708 and most probably 1275 as well (someone check and close please) Didn't we just have a discussion about Media handling killing the system :P Modified: haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp =================================================================== --- haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp 2008-08-05 21:09:01 UTC (rev 26826) +++ haiku/trunk/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp 2008-08-05 21:09:12 UTC (rev 26827) @@ -489,6 +489,9 @@ continue; } int32 frames = min_c(fOutputBufferFrameCount - *frameCount, fChunkSize / fInputFrameSize); + if (frames == 0) + break; + int32 samples = frames * fInputFormat.u.raw_audio.channel_count; fConvert(output_buffer, fChunkBuffer, samples); fChunkBuffer = (const char *)fChunkBuffer + frames * fInputFrameSize; From axeld at mail.berlios.de Tue Aug 5 23:11:54 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 23:11:54 +0200 Subject: [Haiku-commits] r26828 - in haiku/trunk: build/jam headers/os/drivers/bus headers/private/drivers src/add-ons/kernel/bus_managers/ata src/add-ons/kernel/bus_managers/scsi src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/add-ons/kernel/generic/scsi_periph Message-ID: <200808052111.m75LBsJY008040@sheep.berlios.de> Author: axeld Date: 2008-08-05 23:11:51 +0200 (Tue, 05 Aug 2008) New Revision: 26828 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26828&view=rev Added: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.cpp Removed: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/error_handling.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/handle.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/io.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.c Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/headers/os/drivers/bus/SCSI.h haiku/trunk/headers/private/drivers/scsi_periph.h haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/Jamfile haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h Log: * First baby steps in letting our drivers use the new I/O request/scheduler architecture: for now, we do this on the lowest layer only, therefore all requests are handled synchronously (ie. in the scheduler's thread). * Instead of using the block_io module, scsi_disk (and scsi_cd) are now exporting a device on their own, and use an I/O scheduler with an appropriate DMA resource. * There are still lots of TODOs, and it can easily panic - don't update if you intend to demo Haiku. * scsi_periph now only has an io() function that get an io_operation, instead of the previous read/write functions, moved preferred CCB size from those functions into the device registration. * Changed all scsi_periph files to C++. * scsi_cd ported, too, but untested. * Removed block_io from image - it will be removed completely soon. * Temporarily commented an ASSERT() in the ATA bus manager (in case you use it); it's sometimes triggered by the code now, and I haven't yet looked into the issue -- doesn't seem to harm, at least. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/build/jam/HaikuImage 2008-08-05 21:11:51 UTC (rev 26828) @@ -160,7 +160,7 @@ AddFilesToHaikuImage beos system add-ons kernel file_systems : $(BEOS_ADD_ONS_FILE_SYSTEMS) ; AddFilesToHaikuImage beos system add-ons kernel generic - : block_io dpc ide_adapter locked_pool mpu401 scsi_periph ; + : dpc ide_adapter locked_pool mpu401 scsi_periph ; AddFilesToHaikuImage beos system add-ons kernel partitioning_systems : intel session ; AddFilesToHaikuImage beos system add-ons kernel interrupt_controllers @@ -372,7 +372,7 @@ AddBootModuleSymlinksToHaikuImage pci $(X86_ONLY)isa config_manager ide scsi usb $(PPC_ONLY)openpic - block_io ide_adapter locked_pool scsi_periph + ide_adapter locked_pool scsi_periph ahci generic_ide_pci it8211 legacy_sata silicon_image_3112 $(X86_ONLY)ide_isa uhci ohci ehci scsi_cd scsi_disk usb_disk Modified: haiku/trunk/headers/os/drivers/bus/SCSI.h =================================================================== --- haiku/trunk/headers/os/drivers/bus/SCSI.h 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/headers/os/drivers/bus/SCSI.h 2008-08-05 21:11:51 UTC (rev 26828) @@ -134,6 +134,7 @@ uint16 sg_count; // number of S/G entries uint32 data_length; // length of data int32 data_resid; // data transfer residual length: 2's comp + void *io_operation; uchar sense[SCSI_MAX_SENSE_SIZE]; // autosense data uchar sense_resid; // autosense resid length: 2's comp Modified: haiku/trunk/headers/private/drivers/scsi_periph.h =================================================================== --- haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-05 21:11:51 UTC (rev 26828) @@ -7,8 +7,7 @@ #ifndef _SCSI_PERIPH_H #define _SCSI_PERIPH_H -/* - Use this module to minimize work required to write a SCSI +/*! Use this module to minimize work required to write a SCSI peripheral driver. It takes care of: @@ -64,21 +63,21 @@ // cookie issued by driver per file handle typedef struct periph_handle_info *periph_handle_cookie; +typedef struct IOOperation io_operation; // callbacks to be provided by peripheral driver typedef struct scsi_periph_callbacks { // *** block devices *** // informs of new size of medium // (set to NULL if not a block device) - void (*set_capacity)( periph_device_cookie periph_device, uint64 capacity, - uint32 block_size ); + void (*set_capacity)(periph_device_cookie cookie, uint64 capacity, + uint32 blockSize); // *** removable devices // called when media got changed (can be NULL if medium is not changable) // (you don't need to call periph->media_changed, but it's doesn't if you do) // ccb - request at your disposal - void (*media_changed)( periph_device_cookie periph_device, - scsi_ccb *request ); + void (*media_changed)(periph_device_cookie cookie, scsi_ccb *request); } scsi_periph_callbacks; @@ -87,73 +86,61 @@ module_info info; // *** init/cleanup *** - status_t (*register_device)( - periph_device_cookie periph_device, - scsi_periph_callbacks *callbacks, - scsi_device scsi_device, - scsi_device_interface *scsi, - device_node *node, - bool removable, - scsi_periph_device *driver ); - status_t (*unregister_device)( scsi_periph_device driver ); + // preferred_ccb_size - preferred command size; if zero, the shortest is used + status_t (*register_device)(periph_device_cookie cookie, + scsi_periph_callbacks *callbacks, scsi_device scsiDevice, + scsi_device_interface *scsi, device_node *node, bool removable, + int preferredCcbSize, scsi_periph_device *driver); + status_t (*unregister_device)(scsi_periph_device driver); // *** basic command execution *** // exec command, retrying on problems - status_t (*safe_exec)( - scsi_periph_device periph_device, - scsi_ccb *request ); + status_t (*safe_exec)(scsi_periph_device periphCookie, scsi_ccb *request); // exec simple command - status_t (*simple_exec)( scsi_periph_device device, - void *cdb, uchar cdb_len, void *data, size_t data_len, - int ccb_flags ); + status_t (*simple_exec)(scsi_periph_device device, void *cdb, + uint8 cdbLength, void *data, size_t dataLength, int ccbFlags); // *** file handling *** // to be called when a new file is opened - status_t (*handle_open)( scsi_periph_device device, - periph_handle_cookie periph_handle, scsi_periph_handle *res_handle ); + status_t (*handle_open)(scsi_periph_device device, + periph_handle_cookie periph_handle, scsi_periph_handle *_handle); // to be called when a file is closed - status_t (*handle_close)( scsi_periph_handle handle ); + status_t (*handle_close)(scsi_periph_handle handle); // to be called when a file is freed - status_t (*handle_free)( scsi_periph_handle handle ); + status_t (*handle_free)(scsi_periph_handle handle); // *** default implementation for block devices *** - // block read - // preferred_ccb_size - preferred command size; if zero, the shortest is used - status_t (*read)( scsi_periph_handle handle, const phys_vecs *vecs, - off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred, - int preferred_ccb_size ); - // block write - // (see block_read) - status_t (*write)( scsi_periph_handle handle, const phys_vecs *vecs, - off_t pos, size_t num_blocks, uint32 block_size, size_t *bytes_transferred, - int preferred_ccb_size ); + status_t (*io)(scsi_periph_device device, io_operation *operation, + size_t *_bytesTransferred); + // block ioctls - status_t (*ioctl)( scsi_periph_handle handle, int op, void *buf, size_t len ); + status_t (*ioctl)(scsi_periph_handle handle, int op, void *buffer, + size_t length); // check medium capacity (calls set_capacity callback on success) // request - ccb for this device; is used to talk to device - status_t (*check_capacity)( scsi_periph_device device, scsi_ccb *request ); + status_t (*check_capacity)(scsi_periph_device device, scsi_ccb *request); // *** removable media *** // to be called when a medium change is detected to block subsequent commands - void (*media_changed)( scsi_periph_device device ); + void (*media_changed)(scsi_periph_device device); // convert result of *request to err_res - err_res (*check_error)( scsi_periph_device device, scsi_ccb *request ); + err_res (*check_error)(scsi_periph_device device, scsi_ccb *request); // send start or stop command to device - // with_LoEj = true - include loading/ejecting, - // false - only do allow/deny - err_res (*send_start_stop)( scsi_periph_device device, scsi_ccb *request, - bool start, bool with_LoEj ); + // withLoadEject = true - include loading/ejecting, + // false - only do allow/deny + err_res (*send_start_stop)(scsi_periph_device device, scsi_ccb *request, + bool start, bool withLoadEject); // checks media status and waits for device to become ready // returns: B_OK, B_DEV_MEDIA_CHANGE_REQUESTED, B_NO_MEMORY or // pending error reported by handle_get_error - status_t (*get_media_status)( scsi_periph_handle handle ); + status_t (*get_media_status)(scsi_periph_handle handle); // compose device name consisting of prefix and path/target/LUN // (result must be freed by caller) char *(*compose_device_name)(device_node *device_node, const char *prefix); // fill data with icon (for B_GET_ICON ioctl) - status_t (*get_icon)( icon_type type, device_icon *data ); + status_t (*get_icon)(icon_type type, device_icon *data); // synchronizes (flush) the device cache err_res(*synchronize_cache)(scsi_periph_device device, scsi_ccb *request); @@ -162,4 +149,3 @@ #define SCSI_PERIPH_MODULE_NAME "generic/scsi_periph/v1" #endif /* _SCSI_PERIPH_H */ - Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c 2008-08-05 21:11:51 UTC (rev 26828) @@ -14,7 +14,7 @@ } -/* Start the request, but don't clear sense to allow +/* Start the request, but don't clear sense to allow * retrieving the previous sense data. */ void ata_request_start(ata_request **_request, struct ide_device_info *device, struct scsi_ccb *ccb) @@ -31,7 +31,7 @@ device->bus->state = ata_state_busy; device->bus->active_device = device; - + request = device->requestFree; device->requestActive = request; device->requestFree = NULL; @@ -77,7 +77,7 @@ void ata_request_set_status(ata_request *request, uint8 status) { - ASSERT(status != SCSI_REQ_CMP); +// ASSERT(status != SCSI_REQ_CMP); if (request && request->ccb) request->ccb->subsys_status = status; } @@ -106,10 +106,10 @@ request, ccb->subsys_status, request->senseKey); // when the request completed and has set sense - // data, report this to the scsci stack by setting + // data, report this to the scsi stack by setting // CHECK CONDITION status if (ccb->subsys_status == SCSI_REQ_CMP && request->senseKey != 0) { - + TRACE("ata_request_finish - setting check condition\n"); request->ccb->subsys_status = SCSI_REQ_CMP_ERR; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c 2008-08-05 21:11:51 UTC (rev 26828) @@ -8,7 +8,7 @@ CCB manager - As allocation of ccb can be on the paging path we must use a + As allocation of ccb can be on the paging path we must use a locked pool. */ @@ -19,7 +19,7 @@ // ccb are relatively large, so don't make it too small to not waste memory #define CCB_CHUNK_SIZE 16*1024 -// maximum number of CCBs - probably, we want to make that editable +// maximum number of CCBs - probably, we want to make that editable // it must be at least 1 for normal use and 1 for stand-by autosense request #define CCB_NUM_MAX 128 @@ -40,6 +40,7 @@ // reset some very important fields // TODO: should we better omit that to find bugs easier? ccb->sg_list = NULL; + ccb->io_operation = NULL; ccb->sort = -1; SHOW_FLOW(3, "path=%d", ccb->path_id); Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/Jamfile 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/Jamfile 2008-08-05 21:11:51 UTC (rev 26828) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel drivers disk scsi scsi_disk ; UsePrivateHeaders drivers kernel ; +SubDirHdrs $(HAIKU_TOP) src system kernel device_manager ; KernelAddon scsi_disk : scsi_disk.cpp Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-05 21:11:51 UTC (rev 26828) @@ -29,13 +29,12 @@ #endif -static scsi_periph_interface *sSCSIPeripheral; -static device_manager_info *sDeviceManager; -static block_io_for_driver_interface *sBlockIO; +static scsi_periph_interface* sSCSIPeripheral; +static device_manager_info* sDeviceManager; static status_t -update_capacity(das_device_info *device) +update_capacity(das_driver_info *device) { TRACE("update_capacity()\n"); @@ -53,20 +52,20 @@ static status_t -get_geometry(das_handle_info *handle, device_geometry *geometry) +get_geometry(das_handle* handle, device_geometry* geometry) { - das_device_info *device = handle->device; + das_driver_info* info = handle->info; - status_t status = update_capacity(device); + status_t status = update_capacity(info); if (status < B_OK) return status; - geometry->bytes_per_sector = device->block_size; + geometry->bytes_per_sector = info->block_size; geometry->sectors_per_track = 1; - geometry->cylinder_count = device->capacity; + geometry->cylinder_count = info->capacity; geometry->head_count = 1; geometry->device_type = B_DISK; - geometry->removable = device->removable; + geometry->removable = info->removable; // TBD: for all but CD-ROMs, read mode sense - medium type // (bit 7 of block device specific parameter for Optical Memory Block Device) @@ -86,7 +85,7 @@ static status_t -load_eject(das_device_info *device, bool load) +load_eject(das_driver_info *device, bool load) { TRACE("load_eject()\n"); @@ -104,7 +103,7 @@ static status_t -synchronize_cache(das_device_info *device) +synchronize_cache(das_driver_info *device) { TRACE("synchronize_cache()\n"); @@ -135,36 +134,65 @@ } -// #pragma mark - block_io API +static status_t +do_io(void* cookie, IOOperation* operation) +{ + das_driver_info* info = (das_driver_info*)cookie; + // TODO: this can go away as soon as we pushed the IOOperation to the upper + // layers - we can then set scsi_periph::io() as callback for the scheduler + size_t bytesTransferred; + status_t status = sSCSIPeripheral->io(info->scsi_periph_device, operation, + &bytesTransferred); -static void -das_set_device(das_device_info *info, block_io_device device) + info->io_scheduler->OperationCompleted(operation, status, bytesTransferred); + return status; +} + + +// #pragma mark - device module API + + +static status_t +das_init_device(void* _info, void** _cookie) { - info->block_io_device = device; + das_driver_info* info = (das_driver_info*)_info; // and get (initial) capacity scsi_ccb *request = info->scsi->alloc_ccb(info->scsi_device); if (request == NULL) - return; + return B_NO_MEMORY; sSCSIPeripheral->check_capacity(info->scsi_periph_device, request); info->scsi->free_ccb(request); + + *_cookie = info; + return B_OK; } +static void +das_uninit_device(void* _cookie) +{ + das_driver_info* info = (das_driver_info*)_cookie; + + delete info->io_scheduler; + delete info->dma_resource; +} + + static status_t -das_open(das_device_info *device, das_handle_info **_cookie) +das_open(void* _info, const char* path, int openMode, void** _cookie) { - TRACE("open()\n"); + das_driver_info* info = (das_driver_info*)_info; - das_handle_info *handle = (das_handle_info *)malloc(sizeof(*handle)); + das_handle* handle = (das_handle*)malloc(sizeof(das_handle)); if (handle == NULL) return B_NO_MEMORY; - handle->device = device; + handle->info = info; - status_t status = sSCSIPeripheral->handle_open(device->scsi_periph_device, + status_t status = sSCSIPeripheral->handle_open(info->scsi_periph_device, (periph_handle_cookie)handle, &handle->scsi_periph_handle); if (status < B_OK) { free(handle); @@ -177,8 +205,9 @@ static status_t -das_close(das_handle_info *handle) +das_close(void* cookie) { + das_handle* handle = (das_handle*)cookie; TRACE("close()\n"); sSCSIPeripheral->handle_close(handle->scsi_periph_handle); @@ -187,8 +216,9 @@ static status_t -das_free(das_handle_info *handle) +das_free(void* cookie) { + das_handle* handle = (das_handle*)cookie; TRACE("free()\n"); sSCSIPeripheral->handle_free(handle->scsi_periph_handle); @@ -198,38 +228,80 @@ static status_t -das_read(das_handle_info *handle, const phys_vecs *vecs, off_t pos, - size_t num_blocks, uint32 block_size, size_t *bytes_transferred) +das_read(void* cookie, off_t pos, void* buffer, size_t* _length) { - return sSCSIPeripheral->read(handle->scsi_periph_handle, vecs, pos, - num_blocks, block_size, bytes_transferred, 10); + das_handle* handle = (das_handle*)cookie; + size_t length = *_length; + + IORequest request; + status_t status = request.Init(pos, buffer, length, false, 0); + if (status != B_OK) + return status; + + status = handle->info->io_scheduler->ScheduleRequest(&request); + if (status != B_OK) + return status; + + status = request.Wait(0, 0); + if (status == B_OK) + *_length = length; + else + dprintf("das_read(): request.Wait() returned: %s\n", strerror(status)); + + return status; } static status_t -das_write(das_handle_info *handle, const phys_vecs *vecs, off_t pos, - size_t num_blocks, uint32 block_size, size_t *bytes_transferred) +das_write(void* cookie, off_t pos, const void* buffer, size_t* _length) { - return sSCSIPeripheral->write(handle->scsi_periph_handle, vecs, pos, - num_blocks, block_size, bytes_transferred, 10); + das_handle* handle = (das_handle*)cookie; + size_t length = *_length; + + IORequest request; + status_t status = request.Init(pos, (void*)buffer, length, true, 0); + if (status != B_OK) + return status; + + status = handle->info->io_scheduler->ScheduleRequest(&request); + if (status != B_OK) + return status; + + status = request.Wait(0, 0); + if (status == B_OK) + *_length = length; + else + dprintf("das_write(): request.Wait() returned: %s\n", strerror(status)); + + return status; } static status_t -das_ioctl(das_handle_info *handle, int op, void *buffer, size_t length) +das_io(void *cookie, io_request *request) { - das_device_info *device = handle->device; + das_handle* handle = (das_handle*)cookie; + return handle->info->io_scheduler->ScheduleRequest(request); +} + + +static status_t +das_ioctl(void* cookie, uint32 op, void* buffer, size_t length) +{ + das_handle* handle = (das_handle*)cookie; + das_driver_info* info = handle->info; + TRACE("ioctl(op = %d)\n", op); switch (op) { case B_GET_DEVICE_SIZE: { - status_t status = update_capacity(device); + status_t status = update_capacity(info); if (status != B_OK) return status; - size_t size = device->capacity * device->block_size; + size_t size = info->capacity * info->block_size; return user_memcpy(buffer, &size, sizeof(size_t)); } @@ -242,23 +314,23 @@ status_t status = get_geometry(handle, &geometry); if (status != B_OK) return status; - + return user_memcpy(buffer, &geometry, sizeof(device_geometry)); } case B_GET_ICON: - return sSCSIPeripheral->get_icon(device->removable + return sSCSIPeripheral->get_icon(info->removable ? icon_type_floppy : icon_type_disk, (device_icon *)buffer); case B_EJECT_DEVICE: case B_SCSI_EJECT: - return load_eject(device, false); + return load_eject(info, false); case B_LOAD_MEDIA: - return load_eject(device, true); + return load_eject(info, true); case B_FLUSH_DRIVE_CACHE: - return synchronize_cache(device); + return synchronize_cache(info); default: return sSCSIPeripheral->ioctl(handle->scsi_periph_handle, op, @@ -271,7 +343,7 @@ static void -das_set_capacity(das_device_info *device, uint64 capacity, uint32 blockSize) +das_set_capacity(das_driver_info* info, uint64 capacity, uint32 blockSize) { TRACE("das_set_capacity(device = %p, capacity = %Ld, blockSize = %ld)\n", device, capacity, blockSize); @@ -282,19 +354,40 @@ if ((1UL << blockShift) != blockSize) blockShift = 0; - device->capacity = capacity; - device->block_size = blockSize; + info->capacity = capacity; - sBlockIO->set_media_params(device->block_io_device, blockSize, - blockShift, capacity); + if (info->block_size != blockSize) { + if (info->block_size != 0) { + dprintf("old %ld, new %ld\n", info->block_size, blockSize); + panic("updating DMAResource not yet implemented..."); + } + + // TODO: we need to replace the DMAResource in our IOScheduler + status_t status = info->dma_resource->Init(info->node, blockSize); + if (status != B_OK) + panic("initializing DMAResource failed: %s", strerror(status)); + + info->io_scheduler = new(std::nothrow) IOScheduler(info->dma_resource); + if (info->io_scheduler == NULL) + panic("allocating IOScheduler failed."); + + // TODO: use whole device name here + status = info->io_scheduler->Init("scsi"); + if (status != B_OK) + panic("initializing IOScheduler failed: %s", strerror(status)); + + info->io_scheduler->SetCallback(do_io, info); + } + + info->block_size = blockSize; } static void -das_media_changed(das_device_info *device, scsi_ccb *request) +das_media_changed(das_driver_info *device, scsi_ccb *request) { // do a capacity check - // TBD: is this a good idea (e.g. if this is an empty CD)? + // TODO: is this a good idea (e.g. if this is an empty CD)? sSCSIPeripheral->check_capacity(device->scsi_periph_device, request); } @@ -363,53 +456,54 @@ {"removable", B_UINT8_TYPE, {ui8: deviceInquiry->removable_medium}}, // impose own max block restriction {B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, {ui32: maxBlocks}}, - // in general, any disk can be a BIOS drive (even ZIP-disks) - {B_BLOCK_DEVICE_IS_BIOS_DRIVE, B_UINT8_TYPE, {ui8: 1}}, { NULL } }; - return sDeviceManager->register_node(node, SCSI_DISK_MODULE_NAME, attrs, - NULL, NULL); + return sDeviceManager->register_node(node, SCSI_DISK_DRIVER_MODULE_NAME, + attrs, NULL, NULL); } static status_t das_init_driver(device_node *node, void **cookie) { - das_device_info *device; - status_t status; - uint8 removable; - TRACE("das_init_driver"); - status = sDeviceManager->get_attr_uint8(node, "removable", + uint8 removable; + status_t status = sDeviceManager->get_attr_uint8(node, "removable", &removable, false); if (status != B_OK) return status; - device = (das_device_info *)malloc(sizeof(*device)); - if (device == NULL) + das_driver_info* info = (das_driver_info*)malloc(sizeof(das_driver_info)); + if (info == NULL) return B_NO_MEMORY; - memset(device, 0, sizeof(*device)); + memset(info, 0, sizeof(*info)); - device->node = node; - device->removable = removable; + info->dma_resource = new(std::nothrow) DMAResource; + if (info->dma_resource == NULL) { + free(info); + return B_NO_MEMORY; + } - device_node *parent = sDeviceManager->get_parent_node(node); - sDeviceManager->get_driver(parent, (driver_module_info **)&device->scsi, - (void **)&device->scsi_device); + info->node = node; + info->removable = removable; + + device_node* parent = sDeviceManager->get_parent_node(node); + sDeviceManager->get_driver(parent, (driver_module_info **)&info->scsi, + (void **)&info->scsi_device); sDeviceManager->put_node(parent); - status = sSCSIPeripheral->register_device((periph_device_cookie)device, - &callbacks, device->scsi_device, device->scsi, device->node, - device->removable, &device->scsi_periph_device); + status = sSCSIPeripheral->register_device((periph_device_cookie)info, + &callbacks, info->scsi_device, info->scsi, info->node, + info->removable, 10, &info->scsi_periph_device); if (status != B_OK) { - free(device); + free(info); return status; } - *cookie = device; + *cookie = info; return B_OK; } @@ -417,26 +511,26 @@ static void das_uninit_driver(void *_cookie) { - das_device_info *device = (das_device_info *)_cookie; + das_driver_info* info = (das_driver_info*)_cookie; - sSCSIPeripheral->unregister_device(device->scsi_periph_device); - free(device); + sSCSIPeripheral->unregister_device(info->scsi_periph_device); + free(info); } static status_t -das_register_child_devices(void *_cookie) +das_register_child_devices(void* _cookie) { - das_device_info *device = (das_device_info *)_cookie; + das_driver_info* info = (das_driver_info*)_cookie; status_t status; - char *name; - name = sSCSIPeripheral->compose_device_name(device->node, "disk/scsi"); + char* name = sSCSIPeripheral->compose_device_name(info->node, + "disk/scsi"); if (name == NULL) return B_ERROR; - status = sDeviceManager->publish_device(device->node, name, - B_BLOCK_IO_DEVICE_MODULE_NAME); + status = sDeviceManager->publish_device(info->node, name, + SCSI_DISK_DEVICE_MODULE_NAME); free(name); return status; @@ -444,43 +538,52 @@ module_dependency module_dependencies[] = { - {SCSI_PERIPH_MODULE_NAME, (module_info **)&sSCSIPeripheral}, - {B_BLOCK_IO_FOR_DRIVER_MODULE_NAME, (module_info **)&sBlockIO}, - {B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&sDeviceManager}, + {SCSI_PERIPH_MODULE_NAME, (module_info**)&sSCSIPeripheral}, + {B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&sDeviceManager}, {} }; -block_device_interface sSCSIDiskModule = { +struct device_module_info sSCSIDiskDevice = { { - { - SCSI_DISK_MODULE_NAME, - 0, - NULL - }, - - das_supports_device, - das_register_device, - das_init_driver, - das_uninit_driver, - das_register_child_devices, - NULL, // rescan - NULL, // removed + SCSI_DISK_DEVICE_MODULE_NAME, + 0, + NULL }, - (void (*)(block_device_cookie *, block_io_device)) &das_set_device, - (status_t (*)(block_device_cookie *, block_device_handle_cookie **))&das_open, - (status_t (*)(block_device_handle_cookie *)) &das_close, - (status_t (*)(block_device_handle_cookie *)) &das_free, + das_init_device, + das_uninit_device, + NULL, //das_remove, - (status_t (*)(block_device_handle_cookie *, const phys_vecs *, - off_t, size_t, uint32, size_t *)) &das_read, - (status_t (*)(block_device_handle_cookie *, const phys_vecs *, - off_t, size_t, uint32, size_t *)) &das_write, + das_open, + das_close, + das_free, + das_read, + das_write, + das_io, + das_ioctl, - (status_t (*)(block_device_handle_cookie *, int, void *, size_t))&das_ioctl, + NULL, // select + NULL, // deselect }; -module_info *modules[] = { - (module_info *)&sSCSIDiskModule, +struct driver_module_info sSCSIDiskDriver = { + { + SCSI_DISK_DRIVER_MODULE_NAME, + 0, + NULL + }, + + das_supports_device, + das_register_device, + das_init_driver, + das_uninit_driver, + das_register_child_devices, + NULL, // rescan + NULL, // removed +}; + +module_info* modules[] = { + (module_info*)&sSCSIDiskDriver, + (module_info*)&sSCSIDiskDevice, NULL }; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h 2008-08-05 21:11:51 UTC (rev 26828) @@ -12,27 +12,32 @@ #include #include +#include "dma_resources.h" +#include "io_requests.h" +#include "IOScheduler.h" -#define SCSI_DISK_MODULE_NAME "drivers/disk/scsi/scsi_dsk/driver_v1" +#define SCSI_DISK_DRIVER_MODULE_NAME "drivers/disk/scsi/scsi_disk/driver_v1" +#define SCSI_DISK_DEVICE_MODULE_NAME "drivers/disk/scsi/scsi_disk/device_v1" -// must start as block_device_cookie -typedef struct das_device_info { - device_node *node; - ::scsi_periph_device scsi_periph_device; - ::scsi_device scsi_device; - scsi_device_interface *scsi; - ::block_io_device block_io_device; - uint64 capacity; - uint32 block_size; +struct das_driver_info { + device_node* node; + ::scsi_periph_device scsi_periph_device; + ::scsi_device scsi_device; + scsi_device_interface* scsi; + IOScheduler* io_scheduler; + DMAResource* dma_resource; - bool removable; // true, if device is removable -} das_device_info; + uint64 capacity; + uint32 block_size; -typedef struct das_handle_info { - ::scsi_periph_handle scsi_periph_handle; - das_device_info *device; -} das_handle_info; + bool removable; +}; +struct das_handle { + ::scsi_periph_handle scsi_periph_handle; + das_driver_info* info; +}; + #endif /* _SCSI_DISK_H */ Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile 2008-08-05 21:09:12 UTC (rev 26827) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile 2008-08-05 21:11:51 UTC (rev 26828) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel generic scsi_periph ; UsePrivateHeaders drivers kernel ; +SubDirHdrs $(HAIKU_TOP) src system kernel device_manager ; # disable debug output, if debugging is disabled if $(DEBUG) = 0 { @@ -8,13 +9,13 @@ } KernelAddon scsi_periph : - block.c - device_icons.c - device.c - error_handling.c - handle.c - io.c - removable.c - scsi_periph.c - sync.c + block.cpp + device_icons.cpp + device.cpp + error_handling.cpp + handle.cpp + io.cpp + removable.cpp + scsi_periph.cpp + sync.cpp ; Deleted: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.c Copied: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp (from rev 26819, haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.c) =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.c 2008-08-05 17:19:46 UTC (rev 26819) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/block.cpp 2008-08-05 21:11:51 UTC (rev 26828) @@ -0,0 +1,89 @@ +/* + * Copyright 2004-2008, Haiku, Inc. All RightsReserved. + * Copyright 2002-2003, Thomas Kurschel. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ + +//! Handling of block device (currently, only a capacity check is provided) + + +#include "scsi_periph_int.h" +#include + + +status_t +periph_check_capacity(scsi_periph_device_info *device, scsi_ccb *request) +{ + scsi_res_read_capacity capacityResult; + scsi_cmd_read_capacity *cmd = (scsi_cmd_read_capacity *)request->cdb; + uint64 capacity; + uint32 blockSize; + status_t res; + + SHOW_FLOW(3, "%p, %p", device, request); + + // driver doesn't support capacity callback - seems to be no block + // device driver, so ignore + if (device->callbacks->set_capacity == NULL) + return B_OK; + + request->flags = SCSI_DIR_IN; + + request->data = (uint8*)&capacityResult; + request->data_length = sizeof(capacityResult); + request->cdb_length = sizeof(scsi_cmd_read_capacity); + request->timeout = device->std_timeout; + request->sort = -1; + request->sg_list = NULL; + + memset(cmd, 0, sizeof(*cmd)); + cmd->opcode = SCSI_OP_READ_CAPACITY; + // we don't set PMI (partial medium indicator) as we want the whole capacity; + // in this case, all other parameters must be zero + + res = periph_safe_exec(device, request); + + if (res == B_DEV_MEDIA_CHANGED) { + // in this case, the error handler has already called check_capacity + // recursively, so we ignore our (invalid) result + SHOW_FLOW0( 3, "ignore result because medium change" ); + return B_DEV_MEDIA_CHANGED; + } + + ACQUIRE_BEN(&device->mutex); + + if (res == B_OK && request->data_resid == 0) { + capacity = B_BENDIAN_TO_HOST_INT32(capacityResult.lba); + + // the command returns the index of the _last_ block, + // i.e. the size is one larger + ++capacity; + + blockSize = B_BENDIAN_TO_HOST_INT32(capacityResult.block_size); + } else { + capacity = 0; + blockSize = 0; + } + + SHOW_FLOW(3, "capacity = %Ld, block_size = %ld", capacity, blockSize); + + device->block_size = blockSize; + + device->callbacks->set_capacity(device->periph_device, + capacity, blockSize); + +/* device->byte2blk_shift = log2( device->block_size ); + if( device->byte2blk_shift < 0 ) { + // this may be too restrictive... + device->capacity = -1; + return ERR_DEV_GENERAL; + }*/ + + RELEASE_BEN(&device->mutex); + + SHOW_FLOW(3, "done (%s)", strerror(res)); + + return res; +} + Deleted: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.c Copied: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.cpp (from rev 26819, haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device.c) =================================================================== [... truncated: 1093 lines follow ...] From axeld at mail.berlios.de Tue Aug 5 23:15:28 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 5 Aug 2008 23:15:28 +0200 Subject: [Haiku-commits] r26829 - haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd Message-ID: <200808052115.m75LFSp2008625@sheep.berlios.de> Author: axeld Date: 2008-08-05 23:15:28 +0200 (Tue, 05 Aug 2008) New Revision: 26829 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26829&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/Jamfile haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h Log: * Ported scsi_cd, too, still untested. * This should have been part of r26828, although it did not break the build :-) Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/Jamfile 2008-08-05 21:11:51 UTC (rev 26828) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/Jamfile 2008-08-05 21:15:28 UTC (rev 26829) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src add-ons kernel drivers disk scsi scsi_cd ; UsePrivateHeaders drivers kernel ; +SubDirHdrs $(HAIKU_TOP) src system kernel device_manager ; KernelAddon scsi_cd : scsi_cd.cpp Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-05 21:11:51 UTC (rev 26828) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-05 21:15:28 UTC (rev 26829) @@ -7,8 +7,8 @@ /*! Peripheral driver to handle CD-ROM drives. To be more precisely, it supports CD-ROM and WORM drives (well - - I've never _seen_ a WORM driver). - + I've never _seen_ a WORM driver). + Much work is done by scsi_periph and block_io. */ @@ -29,49 +29,48 @@ static scsi_periph_interface *sSCSIPeripheral; static device_manager_info *sDeviceManager; -static block_io_for_driver_interface *sBlockIO; #define SCSI_CD_STD_TIMEOUT 10 static status_t -update_capacity(cd_device_info *device) +update_capacity(cd_driver_info *info) { TRACE("update_capacity()\n"); - scsi_ccb *ccb = device->scsi->alloc_ccb(device->scsi_device); + scsi_ccb *ccb = info->scsi->alloc_ccb(info->scsi_device); if (ccb == NULL) return B_NO_MEMORY; status_t status = sSCSIPeripheral->check_capacity( - device->scsi_periph_device, ccb); + info->scsi_periph_device, ccb); - device->scsi->free_ccb(ccb); + info->scsi->free_ccb(ccb); return status; } static status_t -get_geometry(cd_handle_info *handle, device_geometry *geometry) +get_geometry(cd_handle *handle, device_geometry *geometry) { - cd_device_info *device = handle->device; + cd_driver_info *info = handle->info; - status_t status = update_capacity(device); + status_t status = update_capacity(info); // it seems that Be expects B_GET_GEOMETRY to always succeed unless // the medium has been changed; e.g. if we report B_DEV_NO_MEDIA, the - // device is ignored by the CDPlayer and CDBurner + // info is ignored by the CDPlayer and CDBurner if (status == B_DEV_MEDIA_CHANGED) return B_DEV_MEDIA_CHANGED; - geometry->bytes_per_sector = device->block_size; + geometry->bytes_per_sector = info->block_size; geometry->sectors_per_track = 1; - geometry->cylinder_count = device->capacity; + geometry->cylinder_count = info->capacity; geometry->head_count = 1; - geometry->device_type = device->device_type; - geometry->removable = device->removable; + geometry->device_type = info->device_type; + geometry->removable = info->removable; // TBD: for all but CD-ROMs, read mode sense - medium type // (bit 7 of block device specific parameter for Optical Memory Block Device) @@ -79,7 +78,7 @@ // (same for write-once block devices) // (same for optical memory block devices) geometry->read_only = true; - geometry->write_once = device->device_type == scsi_dev_WORM; + geometry->write_once = info->device_type == scsi_dev_WORM; TRACE("scsi_disk: get_geometry(): %ld, %ld, %ld, %ld, %d, %d, %d, %d\n", geometry->bytes_per_sector, geometry->sectors_per_track, @@ -91,7 +90,7 @@ static status_t -get_toc(cd_device_info *device, scsi_toc *toc) +get_toc(cd_driver_info *info, scsi_toc *toc) { scsi_ccb *ccb; status_t res; @@ -101,11 +100,11 @@ TRACE("get_toc()\n"); - ccb = device->scsi->alloc_ccb(device->scsi_device); + ccb = info->scsi->alloc_ccb(info->scsi_device); if (ccb == NULL) return B_NO_MEMORY; - // first read number of tracks only + // first read number of tracks only ccb->flags = SCSI_DIR_IN; cmd = (scsi_cmd_read_toc *)ccb->cdb; @@ -126,16 +125,16 @@ ccb->sg_list = NULL; ccb->data_length = sizeof(toc->toc_data); - res = sSCSIPeripheral->safe_exec(device->scsi_periph_device, ccb); + res = sSCSIPeripheral->safe_exec(info->scsi_periph_device, ccb); if (res != B_OK) goto err; // then read all track infos - // (little hint: number of tracks is last - first + 1; - // but scsi_toc_toc has already one track, so we get + // (little hint: number of tracks is last - first + 1; + // but scsi_toc_toc has already one track, so we get // last - first extra tracks; finally, we want the lead-out as // well, so we add an extra track) - dataLength = (short_response->last - short_response->first + 1) + dataLength = (short_response->last - short_response->first + 1) * sizeof(scsi_toc_track) + sizeof(scsi_toc_toc); dataLength = min_c(dataLength, sizeof(toc->toc_data)); @@ -144,35 +143,35 @@ cmd->allocation_length = B_HOST_TO_BENDIAN_INT16(dataLength); - res = sSCSIPeripheral->safe_exec(device->scsi_periph_device, ccb); + res = sSCSIPeripheral->safe_exec(info->scsi_periph_device, ccb); err: - device->scsi->free_ccb(ccb); + info->scsi->free_ccb(ccb); return res; } static status_t -load_eject(cd_device_info *device, bool load) +load_eject(cd_driver_info *info, bool load) { TRACE("load_eject()\n"); - scsi_ccb *ccb = device->scsi->alloc_ccb(device->scsi_device); + scsi_ccb *ccb = info->scsi->alloc_ccb(info->scsi_device); if (ccb == NULL) return B_NO_MEMORY; err_res result = sSCSIPeripheral->send_start_stop( - device->scsi_periph_device, ccb, load, true); + info->scsi_periph_device, ccb, load, true); - device->scsi->free_ccb(ccb); + info->scsi->free_ccb(ccb); return result.error_code; } static status_t -get_position(cd_device_info *device, scsi_position *position) +get_position(cd_driver_info *info, scsi_position *position) { scsi_cmd_read_subchannel cmd; @@ -186,13 +185,13 @@ cmd.track = 0; cmd.allocation_length = B_HOST_TO_BENDIAN_INT16(sizeof(scsi_position)); - return sSCSIPeripheral->simple_exec(device->scsi_periph_device, + return sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), position, sizeof(*position), SCSI_DIR_IN); } static status_t -get_set_volume(cd_device_info *device, scsi_volume *volume, bool set) +get_set_volume(cd_driver_info *info, scsi_volume *volume, bool set) { scsi_cmd_mode_sense_6 cmd; scsi_mode_param_header_6 header; @@ -212,7 +211,7 @@ memset(&header, -2, sizeof(header)); - res = sSCSIPeripheral->simple_exec(device->scsi_periph_device, &cmd, + res = sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), &header, sizeof(header), SCSI_DIR_IN); if (res != B_OK) return res; @@ -235,14 +234,14 @@ cmd.allocation_length = len; - res = sSCSIPeripheral->simple_exec(device->scsi_periph_device, &cmd, + res = sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), buffer, len, SCSI_DIR_IN); if (res != B_OK) { free(buffer); return res; } - TRACE(" mode_data_len=%d, block_desc_len=%d", + TRACE(" mode_data_len=%d, block_desc_len=%d", ((scsi_mode_param_header_6 *)buffer)->mode_data_length, ((scsi_mode_param_header_6 *)buffer)->block_desc_length); @@ -295,7 +294,7 @@ cmd.param_list_length = sizeof(header) + header.block_desc_length + sizeof(*page); - res = sSCSIPeripheral->simple_exec(device->scsi_periph_device, + res = sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), buffer, len, SCSI_DIR_OUT); } @@ -306,7 +305,7 @@ /*! Play audio cd; time is in MSF */ static status_t -play_msf(cd_device_info *device, const scsi_play_position *position) +play_msf(cd_driver_info *info, const scsi_play_position *position) { scsi_cmd_play_msf cmd; @@ -324,14 +323,14 @@ cmd.end_second = position->end_s; cmd.end_frame = position->end_f; - return sSCSIPeripheral->simple_exec(device->scsi_periph_device, + return sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), NULL, 0, 0); } /*! Play audio cd; time is in track/index */ static status_t -play_track_index(cd_device_info *device, const scsi_play_track *buf) +play_track_index(cd_driver_info *info, const scsi_play_track *buf) { scsi_toc generic_toc; scsi_toc_toc *toc; @@ -343,7 +342,7 @@ // the corresponding command PLAY AUDIO TRACK/INDEX is deprecated, // so we have to simulate it by converting track to time via TOC - res = get_toc(device, &generic_toc); + res = get_toc(info, &generic_toc); if (res != B_OK) return res; @@ -357,7 +356,7 @@ if (end_track > toc->last_track) end_track = toc->last_track + 1; - + if (end_track < toc->last_track + 1) ++end_track; @@ -375,12 +374,12 @@ position.end_s = toc->tracks[end_track].start.time.second; position.end_f = toc->tracks[end_track].start.time.frame; - return play_msf(device, &position); + return play_msf(info, &position); } static status_t -stop_audio(cd_device_info *device) +stop_audio(cd_driver_info *info) { scsi_cmd_stop_play cmd; @@ -389,13 +388,13 @@ memset( &cmd, 0, sizeof( cmd )); cmd.opcode = SCSI_OP_STOP_PLAY; - return sSCSIPeripheral->simple_exec(device->scsi_periph_device, + return sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), NULL, 0, 0); } static status_t -pause_resume(cd_device_info *device, bool resume) +pause_resume(cd_driver_info *info, bool resume) { scsi_cmd_pause_resume cmd; @@ -405,13 +404,13 @@ cmd.opcode = SCSI_OP_PAUSE_RESUME; cmd.resume = resume; - return sSCSIPeripheral->simple_exec(device->scsi_periph_device, + return sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), NULL, 0, 0); } static status_t -scan(cd_device_info *device, const scsi_scan *buf) +scan(cd_driver_info *info, const scsi_scan *buf) { scsi_cmd_scan cmd; scsi_position curPos; @@ -419,11 +418,11 @@ TRACE("scan(direction =% d)\n", buf->direction); - status_t res = get_position(device, &curPos); + status_t res = get_position(info, &curPos); if (res != B_OK) return res; - cdPos = (scsi_cd_current_position *)((char *)&curPos + cdPos = (scsi_cd_current_position *)((char *)&curPos + sizeof(scsi_subchannel_data_header)); if (buf->direction == 0) { @@ -437,7 +436,7 @@ playPos.end_s = 59; playPos.end_f = 24; - return play_msf(device, &playPos); + return play_msf(info, &playPos); } memset(&cmd, 0, sizeof(cmd)); @@ -450,32 +449,32 @@ /* tmp = (uint8 *)&cmd; dprintf("%d %d %d %d %d %d %d %d %d %d %d %d\n", - tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], + tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], tmp[5], tmp[6], tmp[7], tmp[8], tmp[9], tmp[10], tmp[11]); */ - return sSCSIPeripheral->simple_exec(device->scsi_periph_device, + return sSCSIPeripheral->simple_exec(info->scsi_periph_device, &cmd, sizeof(cmd), NULL, 0, 0); } static status_t -read_cd(cd_device_info *device, const scsi_read_cd *readCD) +read_cd(cd_driver_info *info, const scsi_read_cd *readCD) { scsi_cmd_read_cd *cmd; - uint32 lba, length; + uint32 lba, length; scsi_ccb *ccb; status_t res; // we use safe_exec instead of simple_exec as we want to set // the sorting order manually (only makes much sense if you grab // multiple tracks at once, but we are prepared) - ccb = device->scsi->alloc_ccb(device->scsi_device); + ccb = info->scsi->alloc_ccb(info->scsi_device); if (ccb == NULL) return B_NO_MEMORY; - cmd = (scsi_cmd_read_cd *)ccb->cdb; + cmd = (scsi_cmd_read_cd *)ccb->cdb; memset(cmd, 0, sizeof(*cmd)); cmd->opcode = SCSI_OP_READ_CD; cmd->sector_type = 1; @@ -509,9 +508,9 @@ ccb->sg_list = NULL; ccb->data_length = readCD->buffer_length; - res = sSCSIPeripheral->safe_exec(device->scsi_periph_device, ccb); + res = sSCSIPeripheral->safe_exec(info->scsi_periph_device, ccb); - device->scsi->free_ccb(ccb); + info->scsi->free_ccb(ccb); return res; } @@ -526,56 +525,85 @@ if (x == (1UL << y)) break; } - + return y; } -// #pragma mark - block_io API +static status_t +do_io(void* cookie, IOOperation* operation) +{ + cd_driver_info* info = (cd_driver_info*)cookie; + // TODO: this can go away as soon as we pushed the IOOperation to the upper + // layers - we can then set scsi_periph::io() as callback for the scheduler + size_t bytesTransferred; + status_t status = sSCSIPeripheral->io(info->scsi_periph_device, operation, + &bytesTransferred); + info->io_scheduler->OperationCompleted(operation, status, bytesTransferred); + return status; +} + + +// #pragma mark - device module API + + +static status_t +cd_init_device(void* _info, void** _cookie) +{ + cd_driver_info* info = (cd_driver_info*)_info; + + // and get (initial) capacity + scsi_ccb *request = info->scsi->alloc_ccb(info->scsi_device); + if (request == NULL) + return B_NO_MEMORY; + + sSCSIPeripheral->check_capacity(info->scsi_periph_device, request); + info->scsi->free_ccb(request); + + *_cookie = info; + return B_OK; +} + + static void -cd_set_device(cd_device_info *info, block_io_device device) +cd_uninit_device(void* _cookie) { - info->block_io_device = device; + cd_driver_info* info = (cd_driver_info*)_cookie; + + delete info->io_scheduler; + delete info->dma_resource; } static status_t -cd_open(cd_device_info *device, cd_handle_info **_cookie) +cd_open(void* _info, const char* path, int openMode, void** _cookie) { - TRACE("open()\n"); + cd_driver_info* info = (cd_driver_info*)_info; - cd_handle_info *handle = (cd_handle_info *)malloc(sizeof(*handle)); + cd_handle* handle = (cd_handle*)malloc(sizeof(cd_handle)); if (handle == NULL) return B_NO_MEMORY; - handle->device = device; + handle->info = info; - status_t status = sSCSIPeripheral->handle_open(device->scsi_periph_device, + status_t status = sSCSIPeripheral->handle_open(info->scsi_periph_device, (periph_handle_cookie)handle, &handle->scsi_periph_handle); if (status < B_OK) { free(handle); return status; } - if (device->block_size == 0 || device->capacity == 0) { - scsi_ccb *request = device->scsi->alloc_ccb(device->scsi_device); - if (request != NULL) { - // don't care if no test was possible - sSCSIPeripheral->check_capacity(device->scsi_periph_device, request); - device->scsi->free_ccb(request); - } - } - *_cookie = handle; return B_OK; } static status_t -cd_close(cd_handle_info *handle) +cd_close(void* cookie) { + cd_handle* handle = (cd_handle*)cookie; TRACE("close()\n"); sSCSIPeripheral->handle_close(handle->scsi_periph_handle); @@ -584,8 +612,9 @@ static status_t -cd_free(cd_handle_info *handle) +cd_free(void* cookie) { + cd_handle* handle = (cd_handle*)cookie; TRACE("free()\n"); sSCSIPeripheral->handle_free(handle->scsi_periph_handle); @@ -595,38 +624,80 @@ static status_t -cd_read(cd_handle_info *handle, const phys_vecs *vecs, off_t pos, - size_t num_blocks, uint32 block_size, size_t *bytes_transferred) +cd_read(void* cookie, off_t pos, void* buffer, size_t* _length) { - return sSCSIPeripheral->read(handle->scsi_periph_handle, vecs, pos, - num_blocks, block_size, bytes_transferred, 10); + cd_handle* handle = (cd_handle*)cookie; + size_t length = *_length; + + IORequest request; + status_t status = request.Init(pos, buffer, length, false, 0); + if (status != B_OK) + return status; + + status = handle->info->io_scheduler->ScheduleRequest(&request); + if (status != B_OK) + return status; + + status = request.Wait(0, 0); + if (status == B_OK) + *_length = length; + else + dprintf("cd_read(): request.Wait() returned: %s\n", strerror(status)); + + return status; } static status_t -cd_write(cd_handle_info *handle, const phys_vecs *vecs, off_t pos, - size_t num_blocks, uint32 block_size, size_t *bytes_transferred) +cd_write(void* cookie, off_t pos, const void* buffer, size_t* _length) { - return sSCSIPeripheral->write(handle->scsi_periph_handle, vecs, pos, - num_blocks, block_size, bytes_transferred, 10); + cd_handle* handle = (cd_handle*)cookie; + size_t length = *_length; + + IORequest request; + status_t status = request.Init(pos, (void*)buffer, length, true, 0); + if (status != B_OK) + return status; + + status = handle->info->io_scheduler->ScheduleRequest(&request); + if (status != B_OK) + return status; + + status = request.Wait(0, 0); + if (status == B_OK) + *_length = length; + else + dprintf("cd_write(): request.Wait() returned: %s\n", strerror(status)); + + return status; } static status_t -cd_ioctl(cd_handle_info *handle, int op, void *buffer, size_t length) +cd_io(void *cookie, io_request *request) { - cd_device_info *device = handle->device; + cd_handle* handle = (cd_handle*)cookie; + return handle->info->io_scheduler->ScheduleRequest(request); +} + + +static status_t +cd_ioctl(void* cookie, uint32 op, void* buffer, size_t length) +{ + cd_handle* handle = (cd_handle*)cookie; + cd_driver_info *info = handle->info; + TRACE("ioctl(op = %d)\n", op); switch (op) { case B_GET_DEVICE_SIZE: { - status_t status = update_capacity(device); + status_t status = update_capacity(info); if (status != B_OK) return status; - size_t size = device->capacity * device->block_size; + size_t size = info->capacity * info->block_size; return user_memcpy(buffer, &size, sizeof(size_t)); } @@ -639,7 +710,7 @@ status_t status = get_geometry(handle, &geometry); if (status != B_OK) return status; - + return user_memcpy(buffer, &geometry, sizeof(device_geometry)); } @@ -649,22 +720,22 @@ case B_SCSI_GET_TOC: // TODO: we pass a user buffer here! - return get_toc(device, (scsi_toc *)buffer); + return get_toc(info, (scsi_toc *)buffer); case B_EJECT_DEVICE: case B_SCSI_EJECT: - return load_eject(device, false); + return load_eject(info, false); case B_LOAD_MEDIA: - return load_eject(device, true); + return load_eject(info, true); case B_SCSI_GET_POSITION: { if (buffer == NULL) return B_BAD_VALUE; - + scsi_position position; - status_t status = get_position(device, &position); + status_t status = get_position(info, &position); if (status != B_OK) return status; @@ -673,10 +744,10 @@ case B_SCSI_GET_VOLUME: // TODO: we pass a user buffer here! - return get_set_volume(device, (scsi_volume *)buffer, false); + return get_set_volume(info, (scsi_volume *)buffer, false); case B_SCSI_SET_VOLUME: // TODO: we pass a user buffer here! - return get_set_volume(device, (scsi_volume *)buffer, true); + return get_set_volume(info, (scsi_volume *)buffer, true); case B_SCSI_PLAY_TRACK: { @@ -684,7 +755,7 @@ if (user_memcpy(&track, buffer, sizeof(scsi_play_track)) != B_OK) return B_BAD_ADDRESS; - return play_track_index(device, &track); + return play_track_index(info, &track); } case B_SCSI_PLAY_POSITION: { @@ -693,27 +764,27 @@ != B_OK) return B_BAD_ADDRESS; - return play_msf(device, &position); + return play_msf(info, &position); } case B_SCSI_STOP_AUDIO: - return stop_audio(device); + return stop_audio(info); case B_SCSI_PAUSE_AUDIO: - return pause_resume(device, false); + return pause_resume(info, false); case B_SCSI_RESUME_AUDIO: - return pause_resume(device, true); + return pause_resume(info, true); case B_SCSI_SCAN: { scsi_scan scanBuffer; if (user_memcpy(&scanBuffer, buffer, sizeof(scsi_scan)) != B_OK) return B_BAD_ADDRESS; - - return scan(device, &scanBuffer); + + return scan(info, &scanBuffer); } case B_SCSI_READ_CD: // TODO: we pass a user buffer here! - return read_cd(device, (scsi_read_cd *)buffer); + return read_cd(info, (scsi_read_cd *)buffer); default: return sSCSIPeripheral->ioctl(handle->scsi_periph_handle, op, @@ -726,10 +797,10 @@ static void -cd_set_capacity(cd_device_info *device, uint64 capacity, uint32 blockSize) +cd_set_capacity(cd_driver_info *info, uint64 capacity, uint32 blockSize) { - TRACE("das_set_capacity(device = %p, capacity = %Ld, blockSize = %ld)\n", - device, capacity, blockSize); + TRACE("cd_set_capacity(info = %p, capacity = %Ld, blockSize = %ld)\n", + info, capacity, blockSize); // get log2, if possible uint32 blockShift = log2(blockSize); @@ -737,20 +808,41 @@ if ((1UL << blockShift) != blockSize) blockShift = 0; - device->capacity = capacity; - device->block_size = blockSize; + info->capacity = capacity; - sBlockIO->set_media_params(device->block_io_device, blockSize, - blockShift, capacity); + if (info->block_size != blockSize) { + if (info->block_size != 0) { + dprintf("old %ld, new %ld\n", info->block_size, blockSize); + panic("updating DMAResource not yet implemented..."); + } + + // TODO: we need to replace the DMAResource in our IOScheduler + status_t status = info->dma_resource->Init(info->node, blockSize); + if (status != B_OK) + panic("initializing DMAResource failed: %s", strerror(status)); + + info->io_scheduler = new(std::nothrow) IOScheduler(info->dma_resource); + if (info->io_scheduler == NULL) + panic("allocating IOScheduler failed."); + + // TODO: use whole device name here + status = info->io_scheduler->Init("scsi"); + if (status != B_OK) + panic("initializing IOScheduler failed: %s", strerror(status)); + + info->io_scheduler->SetCallback(do_io, info); + } + + info->block_size = blockSize; } static void -cd_media_changed(cd_device_info *device, scsi_ccb *request) +cd_media_changed(cd_driver_info *info, scsi_ccb *request) { // do a capacity check // TBD: is this a good idea (e.g. if this is an empty CD)? - sSCSIPeripheral->check_capacity(device->scsi_periph_device, request); + sSCSIPeripheral->check_capacity(info->scsi_periph_device, request); } @@ -822,15 +914,15 @@ { NULL } }; - return sDeviceManager->register_node(node, SCSI_CD_MODULE_NAME, attrs, - NULL, NULL); + return sDeviceManager->register_node(node, SCSI_CD_DRIVER_MODULE_NAME, + attrs, NULL, NULL); } static status_t cd_init_driver(device_node *node, void **cookie) { - cd_device_info *device; + cd_driver_info *info; status_t status; uint8 removable; @@ -841,36 +933,36 @@ if (status != B_OK) return status; - device = (cd_device_info *)malloc(sizeof(*device)); - if (device == NULL) + info = (cd_driver_info *)malloc(sizeof(*info)); + if (info == NULL) return B_NO_MEMORY; - memset(device, 0, sizeof(*device)); + memset(info, 0, sizeof(*info)); - device->node = node; - device->removable = removable; + info->node = node; + info->removable = removable; // set capacity to zero, so it get checked on first opened handle - device->capacity = 0; - device->block_size = 0; + info->capacity = 0; + info->block_size = 0; - sDeviceManager->get_attr_uint8(node, SCSI_DEVICE_TYPE_ITEM, - &device->device_type, true); + sDeviceManager->get_attr_uint8(node, SCSI_DEVICE_TYPE_ITEM, + &info->device_type, true); device_node *parent = sDeviceManager->get_parent_node(node); - sDeviceManager->get_driver(parent, (driver_module_info **)&device->scsi, - (void **)&device->scsi_device); + sDeviceManager->get_driver(parent, (driver_module_info **)&info->scsi, + (void **)&info->scsi_device); sDeviceManager->put_node(parent); - status = sSCSIPeripheral->register_device((periph_device_cookie)device, - &callbacks, device->scsi_device, device->scsi, device->node, - device->removable, &device->scsi_periph_device); + status = sSCSIPeripheral->register_device((periph_device_cookie)info, + &callbacks, info->scsi_device, info->scsi, info->node, + info->removable, 10, &info->scsi_periph_device); if (status != B_OK) { - free(device); + free(info); return status; } - *cookie = device; + *cookie = info; return B_OK; } @@ -878,26 +970,26 @@ static void cd_uninit_driver(void *_cookie) { - cd_device_info *device = (cd_device_info *)_cookie; + cd_driver_info *info = (cd_driver_info *)_cookie; - sSCSIPeripheral->unregister_device(device->scsi_periph_device); - free(device); + sSCSIPeripheral->unregister_device(info->scsi_periph_device); + free(info); } static status_t cd_register_child_devices(void *_cookie) { - cd_device_info *device = (cd_device_info *)_cookie; + cd_driver_info *info = (cd_driver_info *)_cookie; status_t status; char *name; - name = sSCSIPeripheral->compose_device_name(device->node, "disk/scsi"); + name = sSCSIPeripheral->compose_device_name(info->node, "disk/scsi"); if (name == NULL) return B_ERROR; - status = sDeviceManager->publish_device(device->node, name, - B_BLOCK_IO_DEVICE_MODULE_NAME); + status = sDeviceManager->publish_device(info->node, name, + SCSI_CD_DEVICE_MODULE_NAME); free(name); return status; @@ -905,43 +997,52 @@ module_dependency module_dependencies[] = { - {SCSI_PERIPH_MODULE_NAME, (module_info **)&sSCSIPeripheral}, - {B_BLOCK_IO_FOR_DRIVER_MODULE_NAME, (module_info **)&sBlockIO}, - {B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&sDeviceManager}, + {SCSI_PERIPH_MODULE_NAME, (module_info**)&sSCSIPeripheral}, + {B_DEVICE_MANAGER_MODULE_NAME, (module_info**)&sDeviceManager}, {} }; -block_device_interface sSCSICDModule = { +struct device_module_info sSCSICDDevice = { { - { - SCSI_CD_MODULE_NAME, - 0, - NULL - }, - - cd_supports_device, - cd_register_device, - cd_init_driver, - cd_uninit_driver, - cd_register_child_devices, - NULL, // rescan - NULL, // removed + SCSI_CD_DEVICE_MODULE_NAME, + 0, + NULL }, - (void (*)(block_device_cookie *, block_io_device)) &cd_set_device, - (status_t (*)(block_device_cookie *, block_device_handle_cookie **))&cd_open, - (status_t (*)(block_device_handle_cookie *)) &cd_close, - (status_t (*)(block_device_handle_cookie *)) &cd_free, + cd_init_device, + cd_uninit_device, + NULL, // remove, - (status_t (*)(block_device_handle_cookie *, const phys_vecs *, - off_t, size_t, uint32, size_t *)) &cd_read, - (status_t (*)(block_device_handle_cookie *, const phys_vecs *, - off_t, size_t, uint32, size_t *)) &cd_write, + cd_open, + cd_close, + cd_free, + cd_read, + cd_write, + cd_io, + cd_ioctl, - (status_t (*)(block_device_handle_cookie *, int, void *, size_t))&cd_ioctl, + NULL, // select + NULL, // deselect }; -module_info *modules[] = { - (module_info *)&sSCSICDModule, +struct driver_module_info sSCSICDDriver = { + { + SCSI_CD_DRIVER_MODULE_NAME, + 0, + NULL + }, + + cd_supports_device, + cd_register_device, + cd_init_driver, + cd_uninit_driver, + cd_register_child_devices, + NULL, // rescan + NULL, // removed +}; + +module_info* modules[] = { + (module_info*)&sSCSICDDriver, + (module_info*)&sSCSICDDevice, NULL }; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h 2008-08-05 21:11:51 UTC (rev 26828) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h 2008-08-05 21:15:28 UTC (rev 26829) @@ -12,28 +12,33 @@ #include #include +#include "dma_resources.h" +#include "io_requests.h" +#include "IOScheduler.h" -#define SCSI_CD_MODULE_NAME "drivers/disk/scsi/scsi_cd/driver_v1" +#define SCSI_CD_DRIVER_MODULE_NAME "drivers/disk/scsi/scsi_cd/driver_v1" +#define SCSI_CD_DEVICE_MODULE_NAME "drivers/disk/scsi/scsi_cd/device_v1" -// must start as block_device_cookie -typedef struct cd_device_info { - device_node *node; - ::scsi_periph_device scsi_periph_device; - ::scsi_device scsi_device; - scsi_device_interface *scsi; - ::block_io_device block_io_device; - uint64 capacity; - uint32 block_size; +struct cd_driver_info { + device_node* node; + ::scsi_periph_device scsi_periph_device; + ::scsi_device scsi_device; + scsi_device_interface* scsi; + IOScheduler* io_scheduler; + DMAResource* dma_resource; - bool removable; - uint8 device_type; -} cd_device_info; - -typedef struct cd_handle_info { - ::scsi_periph_handle scsi_periph_handle; - cd_device_info *device; -} cd_handle_info; + uint64 capacity; + uint32 block_size; [... truncated: 12 lines follow ...] From korli at mail.berlios.de Wed Aug 6 00:06:22 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 6 Aug 2008 00:06:22 +0200 Subject: [Haiku-commits] r26830 - haiku/trunk/src/system/libroot/posix/stdlib Message-ID: <200808052206.m75M6MQ6015426@sheep.berlios.de> Author: korli Date: 2008-08-06 00:06:21 +0200 (Wed, 06 Aug 2008) New Revision: 26830 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26830&view=rev Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c Log: sManagedEnviron is already checked for NULL value in free_variables() Modified: haiku/trunk/src/system/libroot/posix/stdlib/env.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-05 21:15:28 UTC (rev 26829) +++ haiku/trunk/src/system/libroot/posix/stdlib/env.c 2008-08-05 22:06:21 UTC (rev 26830) @@ -130,10 +130,8 @@ if (environ == sManagedEnviron) return B_OK; - if (sManagedEnviron != NULL) { - // free previously used "environ"; it has been changed by an application - free_variables(); - } + // free previously used "environ" if it has been changed by an application + free_variables(); sManagedEnviron = malloc((count_variables() + 1) * sizeof(char *)); if (sManagedEnviron == NULL) From ingo_weinhold at gmx.de Wed Aug 6 00:11:02 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Aug 2008 00:11:02 +0200 Subject: [Haiku-commits] r26819 - in haiku/trunk: headers/private/kernel headers/private/system src/system/boot/platform/atari_m68k src/system/boot/platform/bios_ia32 src/system/boot/platform/openfirmware/arch/ppc src/system/kernel src/system/kernel/arch/ In-Reply-To: References: Message-ID: <20080806001102.595.1@knochen-vm.localdomain> On 2008-08-05 at 19:47:37 [+0200], Rene Gollent wrote: > On Tue, Aug 5, 2008 at 12:20 PM, wrote: > > Author: bonefish > > Date: 2008-08-05 19:19:46 +0200 (Tue, 05 Aug 2008) > > New Revision: 26819 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26819&view=rev > > Does this by any chance fix ticket 2559? I haven't tested it, but it should fix the problems reported in that ticket. The ticket itself is about adding the non-standard PTHREAD_STACK_MIN, which I haven't done. I still don't really know what the point of the macro is. If anyone does or has an opinion why to add it (or not) and with what value, please speak up. CU, Ingo From oruizdorantes at mail.berlios.de Wed Aug 6 00:12:27 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Wed, 6 Aug 2008 00:12:27 +0200 Subject: [Haiku-commits] r26831 - haiku/trunk/headers/os/bluetooth/HCI Message-ID: <200808052212.m75MCRC6016004@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-06 00:12:24 +0200 (Wed, 06 Aug 2008) New Revision: 26831 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26831&view=rev Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h Log: Commit the file i forgot yesterday (ioctl change and cleanups) Modified: haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h =================================================================== --- haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-05 22:06:21 UTC (rev 26830) +++ haiku/trunk/headers/os/bluetooth/HCI/btHCI_transport.h 2008-08-05 22:12:24 UTC (rev 26831) @@ -17,9 +17,8 @@ PROCESSING = (1<<4) } bt_transport_status_t; -typedef uint8 bt_stat_t; +typedef uint8 bt_stat_t; typedef struct bt_hci_statistics { - bt_stat_t acceptedTX; bt_stat_t rejectedTX; bt_stat_t successfulTX; @@ -41,8 +40,6 @@ bt_stat_t bytesRX; bt_stat_t bytesTX; - - } bt_hci_statistics; /* TODO: Possible hooks which drivers will have to provide */ @@ -59,10 +56,8 @@ } bt_hci_transport; typedef struct bt_hci_device { - transport_type kind; char realName[B_OS_NAME_LENGTH]; - } bt_hci_device; @@ -92,8 +87,8 @@ #define GET_PORTCODE_HID(code) ((code&0x00FF0000)>>16) #define GET_PORTCODE_DATA(code) ((code&0x0000FFFF)) -/* Port drivers can use to send information (1 for all for - at moment refer to ioctl GET_NOTIFICATION_PORT)*/ +/* Port drivers can use to send information (1 for all for + at moment refer to ioctl GET_NOTIFICATION_PORT)*/ #define BT_USERLAND_PORT_NAME "BT kernel-user Land" #endif // _BTHCI_TRANSPORT_H_ From bonefish at mail.berlios.de Wed Aug 6 00:17:13 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 00:17:13 +0200 Subject: [Haiku-commits] r26832 - haiku/tags/haiku Message-ID: <200808052217.m75MHD9A016398@sheep.berlios.de> Author: bonefish Date: 2008-08-06 00:17:09 +0200 (Wed, 06 Aug 2008) New Revision: 26832 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26832&view=rev Added: haiku/tags/haiku/r1_pre_alpha-somewhat_stable/ Log: Place for tagging pre-alpha revisions that are somewhat stable. From bonefish at mail.berlios.de Wed Aug 6 00:17:55 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 00:17:55 +0200 Subject: [Haiku-commits] r26833 - haiku/tags/haiku/r1_pre_alpha-somewhat_stable Message-ID: <200808052217.m75MHth8016448@sheep.berlios.de> Author: bonefish Date: 2008-08-06 00:17:49 +0200 (Wed, 06 Aug 2008) New Revision: 26833 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26833&view=rev Added: haiku/tags/haiku/r1_pre_alpha-somewhat_stable/r26827/ Log: Tagging r26827 as somewhat stable. Copied: haiku/tags/haiku/r1_pre_alpha-somewhat_stable/r26827 (from rev 26827, haiku/trunk) From bonefish at mail.berlios.de Wed Aug 6 00:18:57 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 00:18:57 +0200 Subject: [Haiku-commits] r26834 - haiku/tags/haiku/r1_pre_alpha-somewhat_stable Message-ID: <200808052218.m75MIvir016510@sheep.berlios.de> Author: bonefish Date: 2008-08-06 00:18:52 +0200 (Wed, 06 Aug 2008) New Revision: 26834 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26834&view=rev Added: haiku/tags/haiku/r1_pre_alpha-somewhat_stable/latest/ Log: Marking r26827 the latest somewhat stable revision. Copied: haiku/tags/haiku/r1_pre_alpha-somewhat_stable/latest (from rev 26833, haiku/tags/haiku/r1_pre_alpha-somewhat_stable/r26827) From ingo_weinhold at gmx.de Wed Aug 6 01:16:50 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Aug 2008 01:16:50 +0200 Subject: [Haiku-commits] r26819 - in haiku/trunk: headers/private/kernel headers/private/system src/system/boot/platform/atari_m68k src/system/boot/platform/bios_ia32 src/system/boot/platform/openfirmware/arch/ppc src/system/kernel src/system/kernel/arch/ In-Reply-To: <20080806001102.595.1@knochen-vm.localdomain> References: <20080806001102.595.1@knochen-vm.localdomain> Message-ID: <20080806011650.467.1@knochen-vm.localdomain> On 2008-08-06 at 00:11:02 [+0200], Ingo Weinhold wrote: > > On 2008-08-05 at 19:47:37 [+0200], Rene Gollent wrote: > > On Tue, Aug 5, 2008 at 12:20 PM, wrote: > > > Author: bonefish > > > Date: 2008-08-05 19:19:46 +0200 (Tue, 05 Aug 2008) > > > New Revision: 26819 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26819&view=rev > > > > Does this by any chance fix ticket 2559? > > I haven't tested it, but it should fix the problems reported in that ticket. > > The ticket itself is about adding the non-standard PTHREAD_STACK_MIN, which > I haven't done. I still don't really know what the point of the macro is. > If anyone does or has an opinion why to add it (or not) and with what > value, please speak up. Oh, I just saw korli's comment to the ticket. The macro is apparently part of POSIX after all, to be defined in . If that works OK, I'd suggest a value of 4 KB. CU, Ingo From bonefish at mail.berlios.de Wed Aug 6 02:08:08 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 02:08:08 +0200 Subject: [Haiku-commits] r26835 - in haiku/trunk: headers/private/kernel/slab src/system/kernel/slab Message-ID: <200808060008.m76088RB013855@sheep.berlios.de> Author: bonefish Date: 2008-08-06 02:07:55 +0200 (Wed, 06 Aug 2008) New Revision: 26835 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26835&view=rev Modified: haiku/trunk/headers/private/kernel/slab/Slab.h haiku/trunk/src/system/kernel/slab/Slab.cpp Log: Added object_cache_get_usage() function that returns the memory allocated by an object cache. Modified: haiku/trunk/headers/private/kernel/slab/Slab.h =================================================================== --- haiku/trunk/headers/private/kernel/slab/Slab.h 2008-08-05 22:18:52 UTC (rev 26834) +++ haiku/trunk/headers/private/kernel/slab/Slab.h 2008-08-06 00:07:55 UTC (rev 26835) @@ -52,6 +52,8 @@ status_t object_cache_reserve(object_cache *cache, size_t object_count, uint32 flags); +void object_cache_get_usage(object_cache *cache, size_t *_allocatedMemory); + #ifdef __cplusplus } #endif Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp =================================================================== --- haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-08-05 22:18:52 UTC (rev 26834) +++ haiku/trunk/src/system/kernel/slab/Slab.cpp 2008-08-06 00:07:55 UTC (rev 26835) @@ -594,7 +594,7 @@ cache->free_pages = area_free_pages; } - register_low_resource_handler(object_cache_low_memory, cache, + register_low_resource_handler(object_cache_low_memory, cache, B_KERNEL_RESOURCE_PAGES | B_KERNEL_RESOURCE_MEMORY, 5); MutexLocker _(sObjectCacheListLock); @@ -904,6 +904,14 @@ } +void +object_cache_get_usage(object_cache *cache, size_t *_allocatedMemory) +{ + MutexLocker _(cache->lock); + *_allocatedMemory = cache->usage; +} + + slab * object_cache::InitSlab(slab *slab, void *pages, size_t byteCount) { From bonefish at mail.berlios.de Wed Aug 6 02:09:39 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 02:09:39 +0200 Subject: [Haiku-commits] r26836 - in haiku/trunk: headers/private/kernel src/system/kernel/cache Message-ID: <200808060009.m7609dW7013930@sheep.berlios.de> Author: bonefish Date: 2008-08-06 02:09:31 +0200 (Wed, 06 Aug 2008) New Revision: 26836 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26836&view=rev Modified: haiku/trunk/headers/private/kernel/block_cache.h haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: Added block_cache_used_memory() that returns the memory allocated by all block caches for the block cache buffers. Modified: haiku/trunk/headers/private/kernel/block_cache.h =================================================================== --- haiku/trunk/headers/private/kernel/block_cache.h 2008-08-06 00:07:55 UTC (rev 26835) +++ haiku/trunk/headers/private/kernel/block_cache.h 2008-08-06 00:09:31 UTC (rev 26836) @@ -14,9 +14,10 @@ #endif extern status_t block_cache_init(void); +extern size_t block_cache_used_memory(); #ifdef __cplusplus } #endif -#endif /* _KRENEL_BLOCK_CACHE_H */ +#endif /* _KERNEL_BLOCK_CACHE_H */ Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-08-06 00:07:55 UTC (rev 26835) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2008-08-06 00:09:31 UTC (rev 26836) @@ -1807,6 +1807,27 @@ } +extern "C" size_t +block_cache_used_memory() +{ + size_t usedMemory = 0; + + MutexLocker _(sCachesLock); + + DoublyLinkedList::Iterator it = sCaches.GetIterator(); + while (block_cache* cache = it.Next()) { + if (cache == (block_cache*)&sMarkCache) + continue; + + size_t cacheUsedMemory; + object_cache_get_usage(cache->buffer_cache, &cacheUsedMemory); + usedMemory += cacheUsedMemory; + } + + return usedMemory; +} + + // #pragma mark - public transaction API From bonefish at mail.berlios.de Wed Aug 6 02:28:36 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Wed, 6 Aug 2008 02:28:36 +0200 Subject: [Haiku-commits] r26837 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm Message-ID: <200808060028.m760SanL016537@sheep.berlios.de> Author: bonefish Date: 2008-08-06 02:28:28 +0200 (Wed, 06 Aug 2008) New Revision: 26837 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26837&view=rev Modified: haiku/trunk/headers/private/kernel/vm_page.h haiku/trunk/src/system/kernel/system_info.cpp haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * Moved the incrementing/decrementing of vm_page::wired_count into dedicated functions. * Introduced gMappedPagesCount variable which counts the total number of physical pages that are mapped. * Added vm_page_get_stats() which fills in the memory related part of the system_info structure. Used and cached pages are computed differently, now. The "available" (== not committed) memory is no longer used for the computation as it doesn't say anything about the actually used/free pages (with swap support enabled it is even less meaningful, since we first commit swap space when possible). We do also consider the memory used by the block cache as cached pages, now. All in all these changes should fix the memory statistics reported by get_system_info(), IOW bug #2574. Modified: haiku/trunk/headers/private/kernel/vm_page.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_page.h 2008-08-06 00:09:31 UTC (rev 26836) +++ haiku/trunk/headers/private/kernel/vm_page.h 2008-08-06 00:28:28 UTC (rev 26837) @@ -14,6 +14,7 @@ struct kernel_args; +extern int32 gMappedPagesCount; #ifdef __cplusplus extern "C" { @@ -34,6 +35,7 @@ size_t vm_page_num_pages(void); size_t vm_page_num_free_pages(void); size_t vm_page_num_available_pages(void); +void vm_page_get_stats(system_info *info); status_t vm_page_write_modified_page_range(struct VMCache *cache, uint32 firstPage, uint32 endPage); Modified: haiku/trunk/src/system/kernel/system_info.cpp =================================================================== --- haiku/trunk/src/system/kernel/system_info.cpp 2008-08-06 00:09:31 UTC (rev 26836) +++ haiku/trunk/src/system/kernel/system_info.cpp 2008-08-06 00:28:28 UTC (rev 26837) @@ -77,11 +77,8 @@ for (int32 i = 0; i < info->cpu_count; i++) info->cpu_infos[i].active_time = cpu_get_active_time(i); + vm_page_get_stats(info); // TODO: Add page_faults - info->max_pages = vm_page_num_pages(); - info->used_pages = info->max_pages - vm_page_num_available_pages(); - info->cached_pages = info->max_pages - vm_page_num_free_pages() - - info->used_pages; info->used_threads = thread_used_threads(); info->max_threads = thread_max_threads(); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-06 00:09:31 UTC (rev 26836) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-06 00:28:28 UTC (rev 26837) @@ -1329,6 +1329,32 @@ } +static inline void +increment_page_wired_count(vm_page* page) +{ + // TODO: needs to be atomic on all platforms! + // ... but at least the check isn't. Consequently we should hold + // sMappingLock, which would allows us to even avoid atomic_add() on + // gMappedPagesCount. + if (page->wired_count++ == 0) { + if (page->mappings.IsEmpty()) + atomic_add(&gMappedPagesCount, 1); + } +} + + +static inline void +decrement_page_wired_count(vm_page* page) +{ + if (--page->wired_count == 0) { + // TODO: needs to be atomic on all platforms! + // See above! + if (page->mappings.IsEmpty()) + atomic_add(&gMappedPagesCount, -1); + } +} + + /*! Deletes all areas in the given address range. The address space must be write-locked. */ @@ -1802,8 +1828,7 @@ physicalAddress); } - page->wired_count++; - // TODO: needs to be atomic on all platforms! + increment_page_wired_count(page); vm_page_set_state(page, PAGE_STATE_WIRED); cache->InsertPage(page, offset); } @@ -1835,8 +1860,7 @@ if (status < B_OK) panic("couldn't map physical page in page run\n"); - page->wired_count++; - // TODO: needs to be atomic on all platforms! + increment_page_wired_count(page); vm_page_set_state(page, PAGE_STATE_WIRED); cache->InsertPage(page, offset); } @@ -2740,6 +2764,9 @@ accumulatedFlags |= flags; } + if (page->wired_count == 0) + atomic_add(&gMappedPagesCount, -1); + locker.Unlock(); // free now unused mappings @@ -2778,8 +2805,7 @@ physicalAddress); } - page->wired_count--; - // TODO: needs to be atomic on all platforms! + decrement_page_wired_count(page); } } @@ -2828,9 +2854,12 @@ || page->cache_offset >= endOffset) continue; - mapping->page->mappings.Remove(mapping); + page->mappings.Remove(mapping); iterator.Remove(); + if (page->mappings.IsEmpty() && page->wired_count == 0) + atomic_add(&gMappedPagesCount, -1); + queue.Add(mapping); } @@ -2868,12 +2897,14 @@ map->ops->unlock(map); if (area->wiring != B_NO_LOCK) { - page->wired_count++; - // TODO: needs to be atomic on all platforms! + increment_page_wired_count(page); } else { // insert mapping into lists MutexLocker locker(sMappingLock); + if (page->mappings.IsEmpty() && page->wired_count == 0) + atomic_add(&gMappedPagesCount, 1); + page->mappings.Add(mapping); area->mappings.Add(mapping); } @@ -5063,8 +5094,7 @@ if (page == NULL) panic("couldn't lookup physical page just allocated\n"); - page->wired_count++; - // TODO: needs to be atomic on all platforms! + increment_page_wired_count(page); continue; } } @@ -5098,7 +5128,7 @@ if (page == NULL) panic("couldn't lookup physical page"); - page->wired_count++; + increment_page_wired_count(page); // TODO: needs to be atomic on all platforms! } @@ -5163,8 +5193,7 @@ if (page == NULL) panic("couldn't lookup physical page"); - page->wired_count--; - // TODO: needs to be atomic on all platforms! + decrement_page_wired_count(page); } out: Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-06 00:09:31 UTC (rev 26836) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-06 00:28:28 UTC (rev 26837) @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -47,6 +48,8 @@ uint32 count; } page_queue; +int32 gMappedPagesCount; + static page_queue sFreePageQueue; static page_queue sClearPageQueue; static page_queue sModifiedPageQueue; @@ -1916,3 +1919,28 @@ return count - reservedPages; } + +void +vm_page_get_stats(system_info *info) +{ + // Get free pages count -- not really exact, since we don't know how many + // of the reserved pages have already been allocated, but good citizens + // unreserve chunk-wise as they are allocating the pages, if they have + // reserved a larger quantity. + page_num_t reserved = sReservedPages; + page_num_t free = free_page_queue_count(); + free = free > reserved ? free - reserved : 0; + + // The pages used for the block cache buffers. Those should not be counted + // as used but as cached pages. + // TODO: We should subtract the blocks that are in use ATM, since those + // can't really be freed in a low memory situation. + page_num_t blockCachePages = block_cache_used_memory() / B_PAGE_SIZE; + + info->max_pages = sNumPages; + info->used_pages = gMappedPagesCount - blockCachePages; + info->cached_pages = sNumPages >= free + info->used_pages + ? sNumPages - free - info->used_pages : 0; + + // TODO: We don't consider pages used for page directories/tables yet. +} From bga at bug-br.org.br Wed Aug 6 03:25:18 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Tue, 05 Aug 2008 22:25:18 -0300 Subject: [Haiku-commits] r26837 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <200808060028.m760SanL016537@sheep.berlios.de> References: <200808060028.m760SanL016537@sheep.berlios.de> Message-ID: <4898FD7E.4010504@bug-br.org.br> Hey Ingo. First of all, thanks for the fix. I only have 2 minor comments about this: 1 - If I understand this correctly, used memory does not include memory being used by the block cache anymore, right? This is how I always thought it should be (as cache can be reclaimed "easily" if needed) but, at least in Linux, it seems to consider the block cache as used memory. Of course this is not really a problem, only something that is different. 2 - I guess the memory allocation mechanism (malloc(), new()) still use the pre-allocation scheme to check for available memory, right? The problem with this is that the user could see that there is enough memory for a specific allocation but it would fail anyway as what the user sees is not pre-allocated memory. This, in fact, could be a problem. -Bruno bonefish at mail.berlios.de escreveu: > Author: bonefish > Date: 2008-08-06 02:28:28 +0200 (Wed, 06 Aug 2008) > New Revision: 26837 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26837&view=rev > > Modified: > haiku/trunk/headers/private/kernel/vm_page.h > haiku/trunk/src/system/kernel/system_info.cpp > haiku/trunk/src/system/kernel/vm/vm.cpp > haiku/trunk/src/system/kernel/vm/vm_page.cpp > Log: > * Moved the incrementing/decrementing of vm_page::wired_count into > dedicated functions. > * Introduced gMappedPagesCount variable which counts the total number of > physical pages that are mapped. > * Added vm_page_get_stats() which fills in the memory related part of > the system_info structure. Used and cached pages are computed > differently, now. The "available" (== not committed) memory is no > longer used for the computation as it doesn't say anything about the > actually used/free pages (with swap support enabled it is even > less meaningful, since we first commit swap space when possible). > We do also consider the memory used by the block cache as cached > pages, now. All in all these changes should fix the memory statistics > reported by get_system_info(), IOW bug #2574. > > > Modified: haiku/trunk/headers/private/kernel/vm_page.h > =================================================================== > --- haiku/trunk/headers/private/kernel/vm_page.h 2008-08-06 00:09:31 UTC (rev 26836) > +++ haiku/trunk/headers/private/kernel/vm_page.h 2008-08-06 00:28:28 UTC (rev 26837) > @@ -14,6 +14,7 @@ > > struct kernel_args; > > +extern int32 gMappedPagesCount; > > #ifdef __cplusplus > extern "C" { > @@ -34,6 +35,7 @@ > size_t vm_page_num_pages(void); > size_t vm_page_num_free_pages(void); > size_t vm_page_num_available_pages(void); > +void vm_page_get_stats(system_info *info); > > status_t vm_page_write_modified_page_range(struct VMCache *cache, > uint32 firstPage, uint32 endPage); > > Modified: haiku/trunk/src/system/kernel/system_info.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/system_info.cpp 2008-08-06 00:09:31 UTC (rev 26836) > +++ haiku/trunk/src/system/kernel/system_info.cpp 2008-08-06 00:28:28 UTC (rev 26837) > @@ -77,11 +77,8 @@ > for (int32 i = 0; i < info->cpu_count; i++) > info->cpu_infos[i].active_time = cpu_get_active_time(i); > > + vm_page_get_stats(info); > // TODO: Add page_faults > - info->max_pages = vm_page_num_pages(); > - info->used_pages = info->max_pages - vm_page_num_available_pages(); > - info->cached_pages = info->max_pages - vm_page_num_free_pages() > - - info->used_pages; > > info->used_threads = thread_used_threads(); > info->max_threads = thread_max_threads(); > > Modified: haiku/trunk/src/system/kernel/vm/vm.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-06 00:09:31 UTC (rev 26836) > +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-06 00:28:28 UTC (rev 26837) > @@ -1329,6 +1329,32 @@ > } > > > +static inline void > +increment_page_wired_count(vm_page* page) > +{ > + // TODO: needs to be atomic on all platforms! > + // ... but at least the check isn't. Consequently we should hold > + // sMappingLock, which would allows us to even avoid atomic_add() on > + // gMappedPagesCount. > + if (page->wired_count++ == 0) { > + if (page->mappings.IsEmpty()) > + atomic_add(&gMappedPagesCount, 1); > + } > +} > + > + > +static inline void > +decrement_page_wired_count(vm_page* page) > +{ > + if (--page->wired_count == 0) { > + // TODO: needs to be atomic on all platforms! > + // See above! > + if (page->mappings.IsEmpty()) > + atomic_add(&gMappedPagesCount, -1); > + } > +} > + > + > /*! Deletes all areas in the given address range. > The address space must be write-locked. > */ > @@ -1802,8 +1828,7 @@ > physicalAddress); > } > > - page->wired_count++; > - // TODO: needs to be atomic on all platforms! > + increment_page_wired_count(page); > vm_page_set_state(page, PAGE_STATE_WIRED); > cache->InsertPage(page, offset); > } > @@ -1835,8 +1860,7 @@ > if (status < B_OK) > panic("couldn't map physical page in page run\n"); > > - page->wired_count++; > - // TODO: needs to be atomic on all platforms! > + increment_page_wired_count(page); > vm_page_set_state(page, PAGE_STATE_WIRED); > cache->InsertPage(page, offset); > } > @@ -2740,6 +2764,9 @@ > accumulatedFlags |= flags; > } > > + if (page->wired_count == 0) > + atomic_add(&gMappedPagesCount, -1); > + > locker.Unlock(); > > // free now unused mappings > @@ -2778,8 +2805,7 @@ > physicalAddress); > } > > - page->wired_count--; > - // TODO: needs to be atomic on all platforms! > + decrement_page_wired_count(page); > } > } > > @@ -2828,9 +2854,12 @@ > || page->cache_offset >= endOffset) > continue; > > - mapping->page->mappings.Remove(mapping); > + page->mappings.Remove(mapping); > iterator.Remove(); > > + if (page->mappings.IsEmpty() && page->wired_count == 0) > + atomic_add(&gMappedPagesCount, -1); > + > queue.Add(mapping); > } > > @@ -2868,12 +2897,14 @@ > map->ops->unlock(map); > > if (area->wiring != B_NO_LOCK) { > - page->wired_count++; > - // TODO: needs to be atomic on all platforms! > + increment_page_wired_count(page); > } else { > // insert mapping into lists > MutexLocker locker(sMappingLock); > > + if (page->mappings.IsEmpty() && page->wired_count == 0) > + atomic_add(&gMappedPagesCount, 1); > + > page->mappings.Add(mapping); > area->mappings.Add(mapping); > } > @@ -5063,8 +5094,7 @@ > if (page == NULL) > panic("couldn't lookup physical page just allocated\n"); > > - page->wired_count++; > - // TODO: needs to be atomic on all platforms! > + increment_page_wired_count(page); > continue; > } > } > @@ -5098,7 +5128,7 @@ > if (page == NULL) > panic("couldn't lookup physical page"); > > - page->wired_count++; > + increment_page_wired_count(page); > // TODO: needs to be atomic on all platforms! > } > > @@ -5163,8 +5193,7 @@ > if (page == NULL) > panic("couldn't lookup physical page"); > > - page->wired_count--; > - // TODO: needs to be atomic on all platforms! > + decrement_page_wired_count(page); > } > > out: > > Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-06 00:09:31 UTC (rev 26836) > +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-06 00:28:28 UTC (rev 26837) > @@ -15,6 +15,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -47,6 +48,8 @@ > uint32 count; > } page_queue; > > +int32 gMappedPagesCount; > + > static page_queue sFreePageQueue; > static page_queue sClearPageQueue; > static page_queue sModifiedPageQueue; > @@ -1916,3 +1919,28 @@ > return count - reservedPages; > } > > + > +void > +vm_page_get_stats(system_info *info) > +{ > + // Get free pages count -- not really exact, since we don't know how many > + // of the reserved pages have already been allocated, but good citizens > + // unreserve chunk-wise as they are allocating the pages, if they have > + // reserved a larger quantity. > + page_num_t reserved = sReservedPages; > + page_num_t free = free_page_queue_count(); > + free = free > reserved ? free - reserved : 0; > + > + // The pages used for the block cache buffers. Those should not be counted > + // as used but as cached pages. > + // TODO: We should subtract the blocks that are in use ATM, since those > + // can't really be freed in a low memory situation. > + page_num_t blockCachePages = block_cache_used_memory() / B_PAGE_SIZE; > + > + info->max_pages = sNumPages; > + info->used_pages = gMappedPagesCount - blockCachePages; > + info->cached_pages = sNumPages >= free + info->used_pages > + ? sNumPages - free - info->used_pages : 0; > + > + // TODO: We don't consider pages used for page directories/tables yet. > +} > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008 06:03 > > > From anevilyak at gmail.com Wed Aug 6 03:30:45 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Tue, 5 Aug 2008 20:30:45 -0500 Subject: [Haiku-commits] r26837 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <4898FD7E.4010504@bug-br.org.br> References: <200808060028.m760SanL016537@sheep.berlios.de> <4898FD7E.4010504@bug-br.org.br> Message-ID: On Tue, Aug 5, 2008 at 8:25 PM, Bruno Albuquerque wrote: > 2 - I guess the memory allocation mechanism (malloc(), new()) still use > the pre-allocation scheme to check for available memory, right? The > problem with this is that the user could see that there is enough memory > for a specific allocation but it would fail anyway as what the user sees > is not pre-allocated memory. This, in fact, could be a problem. If you mean what I think you mean by this, that problem will go away once we have actual swap support, that's really only a temporary issue. If you meant something else, then forget what I said :) Regards, Rene From axeld at mail.berlios.de Wed Aug 6 10:01:08 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Aug 2008 10:01:08 +0200 Subject: [Haiku-commits] r26838 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808060801.m76818Ev015485@sheep.berlios.de> Author: axeld Date: 2008-08-06 10:01:07 +0200 (Wed, 06 Aug 2008) New Revision: 26838 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26838&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.h haiku/trunk/src/system/kernel/device_manager/io_requests.cpp haiku/trunk/src/system/kernel/device_manager/io_requests.h Log: * Added Dump() method to IORequest, IOOperation, IOBuffer, and DMABuffer. * Added KDL commands "io_request", "io_operation", "io_buffer", and "dma_buffer". Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-08-06 00:28:28 UTC (rev 26837) +++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-08-06 08:01:07 UTC (rev 26838) @@ -30,6 +30,7 @@ #include "BaseDevice.h" #include "devfs_private.h" #include "id_generator.h" +#include "io_requests.h" #include "io_resources.h" @@ -268,8 +269,64 @@ static int -dump_device_nodes(int argc, char **argv) +dump_io_request(int argc, char** argv) { + if (argc != 2 || !strcmp(argv[1], "--help")) { + kprintf("usage: %s \n", argv[0]); + return 0; + } + + IORequest* request = (IORequest*)parse_expression(argv[1]); + request->Dump(); + return 0; +} + + +static int +dump_io_operation(int argc, char** argv) +{ + if (argc != 2 || !strcmp(argv[1], "--help")) { + kprintf("usage: %s \n", argv[0]); + return 0; + } + + IOOperation* operation = (IOOperation*)parse_expression(argv[1]); + operation->Dump(); + return 0; +} + + +static int +dump_io_buffer(int argc, char** argv) +{ + if (argc != 2 || !strcmp(argv[1], "--help")) { + kprintf("usage: %s \n", argv[0]); + return 0; + } + + IOBuffer* buffer = (IOBuffer*)parse_expression(argv[1]); + buffer->Dump(); + return 0; +} + + +static int +dump_dma_buffer(int argc, char** argv) +{ + if (argc != 2 || !strcmp(argv[1], "--help")) { + kprintf("usage: %s \n", argv[0]); + return 0; + } + + DMABuffer* buffer = (DMABuffer*)parse_expression(argv[1]); + buffer->Dump(); + return 0; +} + + +static int +dump_device_nodes(int argc, char** argv) +{ sRootNode->Dump(); return 0; } @@ -2160,10 +2217,16 @@ sRootNode->Dump(); #endif + register_generic_syscall(DEVICE_MANAGER_SYSCALLS, control_device_manager, + 1, 0); + add_debugger_command("dm_tree", &dump_device_nodes, "dump device node tree"); - register_generic_syscall(DEVICE_MANAGER_SYSCALLS, control_device_manager, - 1, 0); + add_debugger_command("io_request", &dump_io_request, "dump an I/O request"); + add_debugger_command("io_operation", &dump_io_operation, + "dump an I/O operation"); + add_debugger_command("io_buffer", &dump_io_buffer, "dump an I/O buffer"); + add_debugger_command("dma_buffer", &dump_dma_buffer, "dump a DMA buffer"); return B_OK; } Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-06 00:28:28 UTC (rev 26837) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-06 08:01:07 UTC (rev 26838) @@ -82,6 +82,22 @@ } +void +DMABuffer::Dump() const +{ + kprintf("DMABuffer at %p\n", this); + + kprintf(" bounce buffer: %p (physical %#lx)\n", fBounceBuffer, + fPhysicalBounceBuffer); + kprintf(" bounce buffer size: %lu\n", fBounceBufferSize); + kprintf(" vecs: %lu\n", fVecCount); + + for (uint32 i = 0; i < fVecCount; i++) { + kprintf(" [%lu] %p, %lu\n", i, fVecs[i].iov_base, fVecs[i].iov_len); + } +} + + // #pragma mark - Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-06 00:28:28 UTC (rev 26837) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-06 08:01:07 UTC (rev 26838) @@ -51,6 +51,8 @@ bool UsesBounceBufferAt(uint32 index); void SetToBounceBuffer(size_t length); + void Dump() const; + private: void* fBounceBuffer; addr_t fPhysicalBounceBuffer; Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-06 00:28:28 UTC (rev 26837) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-06 08:01:07 UTC (rev 26838) @@ -122,6 +122,23 @@ } +void +IOBuffer::Dump() const +{ + kprintf("IOBuffer at %p\n", this); + + kprintf(" origin: %s\n", fUser ? "user" : "kernel"); + kprintf(" kind: %s\n", fPhysical ? "physical" : "virtual"); + kprintf(" length: %lu\n", fLength); + kprintf(" capacity: %lu\n", fCapacity); + kprintf(" vecs: %lu\n", fVecCount); + + for (uint32 i = 0; i < fVecCount; i++) { + kprintf(" [%lu] %p, %lu\n", i, fVecs[i].iov_base, fVecs[i].iov_len); + } +} + + // #pragma mark - @@ -496,6 +513,35 @@ } +void +IOOperation::Dump() const +{ + kprintf("io_operation at %p\n", this); + + kprintf(" parent: %p\n", fParent); + kprintf(" status: %s\n", strerror(fStatus)); + kprintf(" dma buffer: %p\n", fDMABuffer); + kprintf(" offset: %-8Ld (original: %Ld)\n", fOffset, + fOriginalOffset); + kprintf(" length: %-8lu (original: %lu)\n", fLength, + fOriginalLength); + kprintf(" transferred: %lu\n", fTransferredBytes); + kprintf(" block size: %lu\n", fBlockSize); + kprintf(" saved vec index: %u\n", fSavedVecIndex); + kprintf(" saved vec length: %u\n", fSavedVecLength); + kprintf(" r/w: %s\n", IsWrite() ? "write" : "read"); + kprintf(" phase: %s\n", fPhase == PHASE_READ_BEGIN + ? "read begin" : fPhase == PHASE_READ_END ? "read end" + : fPhase == PHASE_DO_ALL ? "do all" : "unknown"); + kprintf(" partial begin: %s\n", fPartialBegin ? "yes" : "no"); + kprintf(" partial end: %s\n", fPartialEnd ? "yes" : "no"); + kprintf(" bounce buffer: %s\n", fUsesBounceBuffer ? "yes" : "no"); + + set_debug_variable("_parent", (addr_t)fParent); + set_debug_variable("_buffer", (addr_t)fDMABuffer); +} + + // #pragma mark - @@ -1055,6 +1101,47 @@ } +void +IORequest::Dump() const +{ + kprintf("io_request at %p\n", this); + + kprintf(" parent: %p\n", fParent); + kprintf(" status: %s\n", strerror(fStatus)); + kprintf(" mutex: %p\n", &fLock); + kprintf(" IOBuffer: %p\n", fBuffer); + kprintf(" offset: %Ld\n", fOffset); + kprintf(" length: %lu\n", fLength); + kprintf(" transfer size: %lu\n", fTransferSize); + kprintf(" relative offset: %lu\n", fRelativeParentOffset); + kprintf(" pending children: %ld\n", fPendingChildren); + kprintf(" flags: %#lx\n", fFlags); + kprintf(" team: %ld\n", fTeam); + kprintf(" r/w: %s\n", fIsWrite ? "write" : "read"); + kprintf(" partial transfer: %s\n", fPartialTransfer ? "yes" : "no"); + kprintf(" finished cvar: %p\n", &fFinishedCondition); + kprintf(" iteration:\n"); + kprintf(" vec index: %lu\n", fVecIndex); + kprintf(" vec offset: %lu\n", fVecOffset); + kprintf(" remaining bytes: %lu\n", fRemainingBytes); + kprintf(" callbacks:\n"); + kprintf(" finished %p, cookie %p\n", fFinishedCallback, fFinishedCookie); + kprintf(" iteration %p, cookie %p\n", fIterationCallback, + fIterationCookie); + kprintf(" children:\n"); + + IORequestChunkList::ConstIterator iterator = fChildren.GetIterator(); + while (iterator.HasNext()) { + kprintf(" %p\n", iterator.Next()); + } + + set_debug_variable("_parent", (addr_t)fParent); + set_debug_variable("_mutex", (addr_t)&fLock); + set_debug_variable("_buffer", (addr_t)fBuffer); + set_debug_variable("_cvar", (addr_t)&fFinishedCondition); +} + + // #pragma mark - Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-06 00:28:28 UTC (rev 26837) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-06 08:01:07 UTC (rev 26838) @@ -55,6 +55,8 @@ status_t LockMemory(team_id team, bool isWrite); void UnlockMemory(team_id team, bool isWrite); + void Dump() const; + private: IOBuffer(); ~IOBuffer(); @@ -155,6 +157,8 @@ void SetBuffer(DMABuffer* buffer) { fDMABuffer = buffer; } + void Dump() const; + protected: void _PrepareVecs(); status_t _CopyPartialBegin(bool isWrite, @@ -268,6 +272,8 @@ status_t CopyData(const void* buffer, off_t offset, size_t size); + void Dump() const; + private: status_t _CopyData(void* buffer, off_t offset, size_t size, bool copyIn); From axeld at mail.berlios.de Wed Aug 6 10:54:50 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Aug 2008 10:54:50 +0200 Subject: [Haiku-commits] r26839 - haiku/trunk/src/add-ons/kernel/bus_managers/scsi Message-ID: <200808060854.m768soqq021377@sheep.berlios.de> Author: axeld Date: 2008-08-06 10:54:49 +0200 (Wed, 06 Aug 2008) New Revision: 26839 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26839&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/emulation.c Log: * scsi_read_write_6() was incorrectly translating 6-byte requests with a length of 0 (as this means 256 blocks). Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/emulation.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/emulation.c 2008-08-06 08:01:07 UTC (rev 26838) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/emulation.c 2008-08-06 08:54:49 UTC (rev 26839) @@ -1,12 +1,11 @@ /* - * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel D?rfler, axeld at pinc-software.de. * Copyright 2002/03, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. */ -/* - Emulation of SCSI commands that a device cannot handle. +/*! Emulation of SCSI commands that a device cannot handle. Some SCSI devices don't support all SCSI commands, especially those connected via ATAPI, USB or FireWire. These commands are @@ -102,8 +101,7 @@ } -/*! - Some ATAPI devices don't like 6 byte read/write commands, so +/*! Some ATAPI devices don't like 6 byte read/write commands, so we translate them to their 10 byte counterparts; USB devices usually don't like 10 bytes either */ @@ -122,7 +120,10 @@ cdb->lun = cmd->lun; cdb->lba = B_HOST_TO_BENDIAN_INT32((uint32)cmd->low_lba | ((uint32)cmd->mid_lba << 8) | ((uint32)cmd->high_lba << 16)); - cdb->length = B_HOST_TO_BENDIAN_INT16((uint16)cmd->length); + if (cmd->length == 0) + cdb->length = B_HOST_TO_BENDIAN_INT16(256); + else + cdb->length = B_HOST_TO_BENDIAN_INT16((uint16)cmd->length); cdb->control = cmd->control; return true; From axeld at mail.berlios.de Wed Aug 6 10:57:24 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Aug 2008 10:57:24 +0200 Subject: [Haiku-commits] r26840 - haiku/trunk/src/add-ons/kernel/bus_managers/ata Message-ID: <200808060857.m768vO0A021555@sheep.berlios.de> Author: axeld Date: 2008-08-06 10:57:23 +0200 (Wed, 06 Aug 2008) New Revision: 26840 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26840&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c Log: * Reenabled the ASSERT() in ata_request_set_status(), the problem has been fixed. Not sure why the 6 to 10-byte command translation was triggered, though. * Minor coding style changes. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c 2008-08-06 08:54:49 UTC (rev 26839) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/ata_request.c 2008-08-06 08:57:23 UTC (rev 26840) @@ -6,6 +6,7 @@ #define TRACE dprintf + void ata_request_init(ata_request *request, struct ide_device_info *device) { @@ -14,10 +15,12 @@ } -/* Start the request, but don't clear sense to allow - * retrieving the previous sense data. - */ -void ata_request_start(ata_request **_request, struct ide_device_info *device, struct scsi_ccb *ccb) +/*! Start the request, but don't clear sense to allow + retrieving the previous sense data. +*/ +void +ata_request_start(ata_request **_request, struct ide_device_info *device, + struct scsi_ccb *ccb) { ata_request *request; @@ -77,7 +80,7 @@ void ata_request_set_status(ata_request *request, uint8 status) { -// ASSERT(status != SCSI_REQ_CMP); + ASSERT(status != SCSI_REQ_CMP); if (request && request->ccb) request->ccb->subsys_status = status; } @@ -101,9 +104,10 @@ ASSERT(ccb); - if (ccb->subsys_status != SCSI_REQ_CMP || request->senseKey) - TRACE("ata_request_finish: request %p, subsys_status 0x%02x, senseKey %02x\n", - request, ccb->subsys_status, request->senseKey); + if (ccb->subsys_status != SCSI_REQ_CMP || request->senseKey) { + TRACE("ata_request_finish: request %p, subsys_status 0x%02x, senseKey " + "%02x\n", request, ccb->subsys_status, request->senseKey); + } // when the request completed and has set sense // data, report this to the scsi stack by setting @@ -136,7 +140,8 @@ // device sense gets reset once it's read ata_request_clear_sense(request); - ASSERT(request->ccb->subsys_status == (SCSI_REQ_CMP_ERR | SCSI_AUTOSNS_VALID)); + ASSERT(request->ccb->subsys_status + == (SCSI_REQ_CMP_ERR | SCSI_AUTOSNS_VALID)); ASSERT(request->ccb->device_status == SCSI_STATUS_CHECK_CONDITION); } } From axeld at mail.berlios.de Wed Aug 6 12:01:54 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 6 Aug 2008 12:01:54 +0200 Subject: [Haiku-commits] r26841 - haiku/trunk/headers/posix/netinet Message-ID: <200808061001.m76A1s3H028128@sheep.berlios.de> Author: axeld Date: 2008-08-06 12:01:53 +0200 (Wed, 06 Aug 2008) New Revision: 26841 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26841&view=rev Modified: haiku/trunk/headers/posix/netinet/ip_icmp.h haiku/trunk/headers/posix/netinet/ip_var.h Log: * Applied patch by kaliber: those headers weren't self-containing. * This closes bug #2346. Modified: haiku/trunk/headers/posix/netinet/ip_icmp.h =================================================================== --- haiku/trunk/headers/posix/netinet/ip_icmp.h 2008-08-06 08:57:23 UTC (rev 26840) +++ haiku/trunk/headers/posix/netinet/ip_icmp.h 2008-08-06 10:01:53 UTC (rev 26841) @@ -38,8 +38,8 @@ #define NETINET_IP_ICMP_H #include - #include +#include #include struct icmp { Modified: haiku/trunk/headers/posix/netinet/ip_var.h =================================================================== --- haiku/trunk/headers/posix/netinet/ip_var.h 2008-08-06 08:57:23 UTC (rev 26840) +++ haiku/trunk/headers/posix/netinet/ip_var.h 2008-08-06 10:01:53 UTC (rev 26841) @@ -37,6 +37,7 @@ #ifndef NETINET_IP_VAR_H #define NETINET_IP_VAR_H +#include #include /* From ingo_weinhold at gmx.de Wed Aug 6 17:27:47 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Aug 2008 17:27:47 +0200 Subject: [Haiku-commits] r26837 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <4898FD7E.4010504@bug-br.org.br> References: <200808060028.m760SanL016537@sheep.berlios.de> <4898FD7E.4010504@bug-br.org.br> Message-ID: <20080806172747.549.1@knochen-vm.localdomain> On 2008-08-06 at 03:25:18 [+0200], Bruno Albuquerque wrote: > First of all, thanks for the fix. I only have 2 minor comments about this: > > 1 - If I understand this correctly, used memory does not include memory > being used by the block cache anymore, right? This is how I always > thought it should be (as cache can be reclaimed "easily" if needed) but, > at least in Linux, it seems to consider the block cache as used memory. > Of course this is not really a problem, only something that is different. The "System Monitor" widget I have in my KDE task bar actually shows the different origins of memory usage (kernel, used, buffers, cached (no idea what "buffers" is supposed to be)) in different colors. ProcessController could do the same (using a more tasteful coloring, though :-)). > 2 - I guess the memory allocation mechanism (malloc(), new()) still use > the pre-allocation scheme to check for available memory, right? The > problem with this is that the user could see that there is enough memory > for a specific allocation but it would fail anyway as what the user sees > is not pre-allocated memory. This, in fact, could be a problem. To really see how big the allocations are that you can make, the swap space would have to be added to the total memory -- e.g. with 128 MB RAM and 16 GB swap space one can do huge (non-locked) allocations. Anyway, the problem really is that the system_info structure only has three values ({max,used,cached}_pages), but we have way more numbers that might be interesting: Besides the three that currently are returned (the numbers of physical RAM pages), there're the memory that has been committed and the one that has been committed for caches, the total, committed, and allocated swap space, and the number of physical RAM pages for which swap has been allocated. Furthermore there are pages of mmap()ed files. The alternative I see to reporting the physical page numbers in system_info, is to report the total amount of virtual memory (i.e. RAM + swap) as max_pages and committed memory as used_pages. The meaning of cached_pages is a bit weird then, since the file cache doesn't commit memory and the numbers can't really be added or compared. As a variation max_pages could be the total physical RAM and used_pages the committed memory maxed at the total physical RAM (everything beyond could be considered "used swap"). cached_pages would have the same problem. CU, Ingo From bga at mail.berlios.de Wed Aug 6 18:39:58 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Wed, 6 Aug 2008 18:39:58 +0200 Subject: [Haiku-commits] r26842 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200808061639.m76Gdw91007384@sheep.berlios.de> Author: bga Date: 2008-08-06 18:39:56 +0200 (Wed, 06 Aug 2008) New Revision: 26842 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26842&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Work in progress while trying to fix ticket #2227: - Better adhere to style guide. - Remove superfluous check for device function before setting IRQ. - Added comment about setting IRQ for device with function 1. - This fixes nothing yet, in case you are wondering. :) Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-06 10:01:53 UTC (rev 26841) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-06 16:39:56 UTC (rev 26842) @@ -1,6 +1,5 @@ /* - * Copyright 2007, Marcus Overhagen. All rights reserved. - * + * Copyright 2007-2008, Marcus Overhagen. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -9,18 +8,19 @@ #include -/* The Jmicron AHCI controller has a mode that combines IDE and AHCI functionality - * into a single PCI device at function 0. This happens when the controller is set - * in the BIOS to "basic" or "IDE" mode (but not in "RAID" or "AHCI" mode). - * To avoid needing two drivers to handle a single PCI device, we switch to the - * multifunction (split device) AHCI mode. This will set PCI device at function 0 - * to AHCI, and PCI device at function 1 to IDE controller. +/* The Jmicron AHCI controller has a mode that combines IDE and AHCI + * functionality into a single PCI device at function 0. This happens when the + * controller is set in the BIOS to "basic" or "IDE" mode (but not in "RAID" or + * "AHCI" mode). To avoid needing two drivers to handle a single PCI device, we + * switch to the multifunction (split device) AHCI mode. This will set PCI + * device at function 0 to AHCI, and PCI device at function 1 to IDE controller. */ static void jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { - switch (deviceId) { + switch (deviceId) + { case 0x2361: // 1 SATA, 1 PATA case 0x2363: // 2 SATA, 1 PATA case 0x2366: // 2 SATA, 2 PATA @@ -31,14 +31,19 @@ return; } - dprintf("jmicron_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", - domain, bus, device, function, deviceId); + dprintf("jmicron_fixup_ahci: domain %u, bus %u, device %u, function %u, " + "deviceId 0x%04x\n", domain, bus, device, function, deviceId); - if (function == 0) { - dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x40, 4)); - dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); + if (function == 0) + { + dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x40, 4)); + dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); + uint32 val = pci->ReadConfig(domain, bus, device, function, 0xdc, 4); - if (!(val & (1 << 30))) { + if (!(val & (1 << 30))) + { uint8 irq = pci->ReadConfig(domain, bus, device, function, 0x3c, 1); dprintf("jmicron_fixup_ahci: enabling split device mode\n"); val &= ~(1 << 24); @@ -48,23 +53,26 @@ val &= ~(1 << 16); val |= (1 << 1) | (1 << 17) | (1 << 22); pci->WriteConfig(domain, bus, device, function, 0x40, 4, val); - if (function == 0) - pci->WriteConfig(domain, bus, device, 1, 0x3c, 1, irq); - else - dprintf("jmicron_fixup_ahci: can't assign IRQ\n"); + // Set IRQ for dfunction 2 (IDE) device. + pci->WriteConfig(domain, bus, device, 1, 0x3c, 1, irq); } - dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x40, 4)); - dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); + dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x40, 4)); + dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); } } static void -intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) +intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, + uint16 deviceId) { - return; /* disabled until the PCI manager can assign new resources */ + // TODO(bga): disabled until the PCI manager can assign new resources. + return; - switch (deviceId) { + switch (deviceId) + { case 0x2825: // ICH8 Desktop when in IDE emulation mode dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825\n"); return; @@ -83,16 +91,20 @@ return; } - dprintf("intel_fixup_ahci: domain %u, bus %u, device %u, function %u, deviceId 0x%04x\n", - domain, bus, device, function, deviceId); + dprintf("intel_fixup_ahci: domain %u, bus %u, device %u, function %u, " + "deviceId 0x%04x\n", domain, bus, device, function, deviceId); - dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); - dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", pci->ReadConfig(domain, bus, device, function, 0x90, 1)); + dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", + pci->ReadConfig(domain, bus, device, function, 0x90, 1)); uint8 map = pci->ReadConfig(domain, bus, device, function, 0x90, 1); - if ((map >> 6) == 0) { + if ((map >> 6) == 0) + { uint32 bar5 = pci->ReadConfig(domain, bus, device, function, 0x24, 4); - uint16 pcicmd = pci->ReadConfig(domain, bus, device, function, PCI_command, 2); + uint16 pcicmd = pci->ReadConfig(domain, bus, device, function, + PCI_command, 2); dprintf("intel_fixup_ahci: switching from IDE to AHCI mode\n"); @@ -100,18 +112,22 @@ pcicmd & ~(PCI_command_io | PCI_command_memory)); pci->WriteConfig(domain, bus, device, function, 0x24, 4, 0xffffffff); - dprintf("intel_fixup_ahci: ide-bar5 bits-1: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ide-bar5 bits-1: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); pci->WriteConfig(domain, bus, device, function, 0x24, 4, 0); - dprintf("intel_fixup_ahci: ide-bar5 bits-0: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ide-bar5 bits-0: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); map &= ~0x03; map |= 0x40; pci->WriteConfig(domain, bus, device, function, 0x90, 1, map); pci->WriteConfig(domain, bus, device, function, 0x24, 4, 0xffffffff); - dprintf("intel_fixup_ahci: ahci-bar5 bits-1: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ahci-bar5 bits-1: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); pci->WriteConfig(domain, bus, device, function, 0x24, 4, 0); - dprintf("intel_fixup_ahci: ahci-bar5 bits-0: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: ahci-bar5 bits-0: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); if (deviceId == 0x27c0 || deviceId == 0x27c4) // restore on ICH7 pci->WriteConfig(domain, bus, device, function, 0x24, 4, bar5); @@ -119,20 +135,26 @@ pci->WriteConfig(domain, bus, device, function, PCI_command, 2, pcicmd); } - dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", pci->ReadConfig(domain, bus, device, function, 0x24, 4)); - dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", pci->ReadConfig(domain, bus, device, function, 0x90, 1)); + dprintf("intel_fixup_ahci: 0x24: 0x%08lx\n", + pci->ReadConfig(domain, bus, device, function, 0x24, 4)); + dprintf("intel_fixup_ahci: 0x90: 0x%02lx\n", + pci->ReadConfig(domain, bus, device, function, 0x90, 1)); } void pci_fixup_device(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function) { - uint16 vendorId = pci->ReadConfig(domain, bus, device, function, PCI_vendor_id, 2); - uint16 deviceId = pci->ReadConfig(domain, bus, device, function, PCI_device_id, 2); + uint16 vendorId = pci->ReadConfig(domain, bus, device, function, + PCI_vendor_id, 2); + uint16 deviceId = pci->ReadConfig(domain, bus, device, function, + PCI_device_id, 2); -// dprintf("pci_fixup_device: domain %u, bus %u, device %u, function %u\n", domain, bus, device, function); +// dprintf("pci_fixup_device: domain %u, bus %u, device %u, function %u\n", +// domain, bus, device, function); - switch (vendorId) { + switch (vendorId) + { case 0x197b: jmicron_fixup_ahci(pci, domain, bus, device, function, deviceId); break; From stippi at mail.berlios.de Wed Aug 6 18:56:34 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Wed, 6 Aug 2008 18:56:34 +0200 Subject: [Haiku-commits] r26843 - in haiku/trunk: headers/private/storage src/kits/storage Message-ID: <200808061656.m76GuY9g026329@sheep.berlios.de> Author: stippi Date: 2008-08-06 18:56:24 +0200 (Wed, 06 Aug 2008) New Revision: 26843 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26843&view=rev Modified: haiku/trunk/headers/private/storage/PathMonitor.h haiku/trunk/src/kits/storage/PathMonitor.cpp Log: * StartWatching() now takes an optional BLooper pointer. This looper will then be used for receiving node monitoring messages. * Reenabled using be_app as default BLooper if the API user does not provide one. I think the problem that Stefano needed to work aroung in r23995 was actually caused by the incorrect locking (an never unlocking) of the looper before calling PathHandler::Quit(). ->If I understand correctly, this code as supposed to work around the possible situation that the looper holding those PathHandlers may have already quit, leaving stale PathHandler pointers behind. But that case was not prevented by the old code anyways, since one would have had to access freed memory to even get the stale BLooper pointer. The real fix would be to store the BLooper pointer with each PathHandler so that the possible gone-ness of those loopers could be checked independent of accessing the PathHandler pointer. (The whole problem is that PathHandler adds itself to the BLooper and if the looper quits, it will free all its attached handlers.) * Introduced a global fallback BLooper for the case that no BApplication is running, which resolves a TODO. All this is yet untested, but should have a good chance of working. (Famous last words...) Modified: haiku/trunk/headers/private/storage/PathMonitor.h =================================================================== --- haiku/trunk/headers/private/storage/PathMonitor.h 2008-08-06 16:39:56 UTC (rev 26842) +++ haiku/trunk/headers/private/storage/PathMonitor.h 2008-08-06 16:56:24 UTC (rev 26843) @@ -1,5 +1,5 @@ /* - * Copyright 2007, Haiku Inc. All Rights Reserved. + * Copyright 2007-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _PATH_MONITOR_H @@ -20,7 +20,8 @@ class BPathMonitor { public: static status_t StartWatching(const char* path, uint32 flags, - BMessenger target); + BMessenger target, + BLooper* useLooper = NULL); static status_t StopWatching(const char* path, BMessenger target); @@ -30,7 +31,8 @@ BPathMonitor(); ~BPathMonitor(); - static status_t _InitIfNeeded(); + static status_t _InitLockerIfNeeded(); + static status_t _InitLooperIfNeeded(); }; } // namespace BPrivate Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-06 16:39:56 UTC (rev 26842) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-06 16:56:24 UTC (rev 26843) @@ -1,9 +1,10 @@ /* - * Copyright 2007, Haiku Inc. All Rights Reserved. + * Copyright 2007-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Axel D?rfler, axeld at pinc-software.de + * Stephan A?mus */ @@ -22,6 +23,7 @@ #include #include +#include #include #undef TRACE @@ -34,6 +36,7 @@ using namespace BPrivate; using namespace std; +using std::nothrow; // TODO: Remove this line if the above line is enough. #define WATCH_NODE_FLAG_MASK 0x00ff @@ -72,7 +75,8 @@ class PathHandler : public BHandler { public: - PathHandler(const char* path, uint32 flags, BMessenger target); + PathHandler(const char* path, uint32 flags, BMessenger target, + BLooper* looper); virtual ~PathHandler(); status_t InitCheck() const; @@ -112,7 +116,6 @@ BMessenger fTarget; uint32 fFlags; status_t fStatus; - bool fOwnsLooper; DirectorySet fDirectories; FileSet fFiles; }; @@ -120,6 +123,7 @@ static WatcherMap sWatchers; static BLocker* sLocker = NULL; +static BLooper* sLooper = NULL; static status_t @@ -159,11 +163,11 @@ // #pragma mark - -PathHandler::PathHandler(const char* path, uint32 flags, BMessenger target) +PathHandler::PathHandler(const char* path, uint32 flags, BMessenger target, + BLooper* looper) : BHandler(path), fTarget(target), - fFlags(flags), - fOwnsLooper(false) + fFlags(flags) { if (path == NULL || !path[0]) { fStatus = B_BAD_VALUE; @@ -176,13 +180,6 @@ if (fStatus < B_OK) return; - BLooper* looper; - // TODO: only have a single global looper! - // TODO: Use BLooper::LooperForThread(find_looper(NULL)) ? - looper = new BLooper("PathMonitor looper"); - looper->Run(); - fOwnsLooper = true; - looper->Lock(); looper->AddHandler(this); looper->Unlock(); @@ -212,13 +209,8 @@ void PathHandler::Quit() { - if (!LockLooper()) - return; - BMessenger me(this); me.SendMessage(B_QUIT_REQUESTED); - - UnlockLooper(); } @@ -488,18 +480,15 @@ case B_QUIT_REQUESTED: { + // Obviously the looper is still valid and running + // when we receive the message here, it is also currently + // locked, because it is processing the message. BLooper* looper = Looper(); - bool ownsLooper = fOwnsLooper; stop_watching(this); looper->RemoveHandler(this); delete this; - if (ownsLooper) { - looper->Lock(); - looper->Quit(); - } - return; } @@ -773,7 +762,7 @@ /*static*/ status_t -BPathMonitor::_InitIfNeeded() +BPathMonitor::_InitLockerIfNeeded() { static vint32 lock = 0; @@ -782,7 +771,9 @@ while (sLocker == NULL) { if (atomic_add(&lock, 1) == 0) { - sLocker = new BLocker("path monitor"); + sLocker = new (nothrow) BLocker("path monitor"); + if (sLocker == NULL) + return B_NO_MEMORY; } snooze(5000); } @@ -792,12 +783,53 @@ /*static*/ status_t -BPathMonitor::StartWatching(const char* path, uint32 flags, BMessenger target) +BPathMonitor::_InitLooperIfNeeded() { - status_t status = _InitIfNeeded(); + static vint32 lock = 0; + + if (sLooper != NULL) + return B_OK; + + while (sLooper == NULL) { + if (atomic_add(&lock, 1) == 0) { + // first thread initializes the global looper + sLooper = new (nothrow) BLooper("PathMonitor looper"); + if (sLooper == NULL) + return B_NO_MEMORY; + thread_id thread = sLooper->Run(); + if (thread < B_OK) + return (status_t)thread; + } + snooze(5000); + } + + return sLooper->Thread() >= 0 ? B_OK : B_ERROR; +} + + +/*static*/ status_t +BPathMonitor::StartWatching(const char* path, uint32 flags, BMessenger target, + BLooper* looper) +{ + status_t status = _InitLockerIfNeeded(); if (status != B_OK) return status; + // Check which BLooper should be used to receive node monitoring messages. + // If no looper is given, prefer the BApplication if it is running, + // otherwise use a global BLooper just for node monitoring. + if (looper == NULL) { + if (be_app) + looper = be_app; + else { + // only use the global looper if no BApplication is running + status = _InitLooperIfNeeded(); + if (status < B_OK) + return status; + looper = sLooper; + } + } + BAutolock _(sLocker); WatcherMap::iterator iterator = sWatchers.find(target); @@ -805,13 +837,18 @@ if (iterator != sWatchers.end()) watcher = iterator->second; - PathHandler* handler = new PathHandler(path, flags, target); + PathHandler* handler = new (nothrow) PathHandler(path, flags, target, + looper); + if (handler == NULL) + return B_NO_MEMORY; status = handler->InitCheck(); if (status < B_OK) return status; if (watcher == NULL) { - watcher = new BPrivate::watcher; + watcher = new (nothrow) BPrivate::watcher; + if (watcher == NULL) + return B_NO_MEMORY; sWatchers[target] = watcher; } From stefano.ceccherini at gmail.com Wed Aug 6 18:59:01 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Wed, 6 Aug 2008 18:59:01 +0200 Subject: [Haiku-commits] r26842 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: <200808061639.m76Gdw91007384@sheep.berlios.de> References: <200808061639.m76Gdw91007384@sheep.berlios.de> Message-ID: <894b9700808060959w3f96b1a0w8af4f36d5277002d@mail.gmail.com> 2008/8/6 bga at BerliOS : > Author: bga > Date: 2008-08-06 18:39:56 +0200 (Wed, 06 Aug 2008) > New Revision: 26842 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26842&view=rev > > - switch (vendorId) { > + switch (vendorId) > + { > case 0x197b: You got this wrong, though: The parenthesis is supposed to be on the same line of the switch statement. From stefano.ceccherini at gmail.com Wed Aug 6 19:00:21 2008 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Wed, 6 Aug 2008 19:00:21 +0200 Subject: [Haiku-commits] r26843 - in haiku/trunk: headers/private/storage src/kits/storage In-Reply-To: <200808061656.m76GuY9g026329@sheep.berlios.de> References: <200808061656.m76GuY9g026329@sheep.berlios.de> Message-ID: <894b9700808061000y17cddd49i6a64f96339138763@mail.gmail.com> 2008/8/6 : > Author: stippi > Date: 2008-08-06 18:56:24 +0200 (Wed, 06 Aug 2008) > New Revision: 26843 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26843&view=rev > > Modified: > haiku/trunk/headers/private/storage/PathMonitor.h > haiku/trunk/src/kits/storage/PathMonitor.cpp > Log: > * StartWatching() now takes an optional BLooper pointer. This looper will > then be used for receiving node monitoring messages. > * Reenabled using be_app as default BLooper if the API user does not provide > one. I think the problem that Stefano needed to work aroung in r23995 was > actually caused by the incorrect locking (an never unlocking) of the looper > before calling PathHandler::Quit(). It's easy to check. Just do what is described in the bug which my commit was supposed to fix. :) From superstippi at gmx.de Wed Aug 6 19:04:37 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 06 Aug 2008 19:04:37 +0200 Subject: [Haiku-commits] r26842 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: <200808061639.m76Gdw91007384@sheep.berlios.de> References: <200808061639.m76Gdw91007384@sheep.berlios.de> Message-ID: <20080806190437.7977.2@stippis2.1218026299.fake> Hi Bruno, bga at BerliOS wrote: > - Better adhere to style guide. While you fixed the 80 char/line limit (thanks!), you introduced a few new style violations, and the change to the copyright line is incorrect. > - * Copyright 2007, Marcus Overhagen. All rights reserved. > - * > + * Copyright 2007-2008, Marcus Overhagen. All rights reserved. > * Distributed under the terms of the MIT License. > */ If Marcus didn't work on this in 2008, the change is incorrect. Either you add your own copyright at the top, or, if your changes are not significant enough yet for copyrightable work, don't change the license at all. If the license header has the style "Copyright... Haiku, Inc... Authors:..." then it is fine to update the year if you change something in the file. Please revert those: > - switch (deviceId) { > + switch (deviceId) > + { > - if (function == 0) { > + if (function == 0) > + { > - if (!(val & (1 << 30))) { > + if (!(val & (1 << 30))) > + { > - switch (deviceId) { > + switch (deviceId) > + { > - if ((map >> 6) == 0) { > + if ((map >> 6) == 0) > + { > - switch (vendorId) { > + switch (vendorId) > + { Best regards, -Stephan From superstippi at gmx.de Wed Aug 6 19:11:09 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 06 Aug 2008 19:11:09 +0200 Subject: [Haiku-commits] r26843 - in haiku/trunk: headers/private/storage src/kits/storage In-Reply-To: <894b9700808061000y17cddd49i6a64f96339138763@mail.gmail.com> References: <200808061656.m76GuY9g026329@sheep.berlios.de> <894b9700808061000y17cddd49i6a64f96339138763@mail.gmail.com> Message-ID: <20080806191109.8487.3@stippis2.1218026299.fake> Stefano Ceccherini wrote: > 2008/8/6 : > > Author: stippi > > Date: 2008-08-06 18:56:24 +0200 (Wed, 06 Aug 2008) New Revision: 26843 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26843&view=rev > > > > Modified: > > haiku/trunk/headers/private/storage/PathMonitor.h > > haiku/trunk/src/kits/storage/PathMonitor.cpp > > Log: > > * StartWatching() now takes an optional BLooper pointer. This looper > > will > > then be used for receiving node monitoring messages. > > * Reenabled using be_app as default BLooper if the API user does not > > provide > > one. I think the problem that Stefano needed to work aroung in r23995 > > was actually caused by the incorrect locking (an never unlocking) of > > the looper before calling PathHandler::Quit(). > > It's easy to check. Just do what is described in the bug which my commit > was supposed to fix. :) Ok thanks, will do in a minute. Best regards, -Stephan From axeld at pinc-software.de Wed Aug 6 19:38:33 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 06 Aug 2008 19:38:33 +0200 CEST Subject: [Haiku-commits] r26837 - in haiku/trunk: headers/private/kernel src/system/kernel src/system/kernel/vm In-Reply-To: <20080806172747.549.1@knochen-vm.localdomain> Message-ID: <40555299163-BeMail@zon> Ingo Weinhold wrote: > Anyway, the problem really is that the system_info structure only has > three > values ({max,used,cached}_pages), but we have way more numbers that > might be > interesting: Besides the three that currently are returned (the > numbers of > physical RAM pages), there're the memory that has been committed and > the one > that has been committed for caches, the total, committed, and > allocated swap > space, and the number of physical RAM pages for which swap has been > allocated. Furthermore there are pages of mmap()ed files. For that, and other interesting values, I think we should introduce a system call to retrieve VM statistics in userland. > The alternative I see to reporting the physical page numbers in > system_info, > is to report the total amount of virtual memory (i.e. RAM + swap) as > max_pages and committed memory as used_pages. The meaning of > cached_pages is > a bit weird then, since the file cache doesn't commit memory and the > numbers > can't really be added or compared. As a variation max_pages could be > the > total physical RAM and used_pages the committed memory maxed at the > total > physical RAM (everything beyond could be considered "used swap"). > cached_pages would have the same problem. Well, I added cached_pages - we can remove it again, in case we can't make it useful :-) Bye, Axel. From bga at mail.berlios.de Wed Aug 6 20:57:57 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Wed, 6 Aug 2008 20:57:57 +0200 Subject: [Haiku-commits] r26844 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200808061857.m76Ivvon029967@sheep.berlios.de> Author: bga Date: 2008-08-06 20:57:56 +0200 (Wed, 06 Aug 2008) New Revision: 26844 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26844&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Work in progress while trying to fix ticket #2227: - Removed most of the currently fixup code as, at least on my machine, it was messing stuff up. This makes the PATA controller work in IDE mode! - Added comments to clarify things and TODOs about what is still missing (specially getting AHCI mode working). Marcus, please review. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-06 16:56:24 UTC (rev 26843) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-06 18:57:56 UTC (rev 26844) @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008, Marcus Overhagen. All rights reserved. + * Copyright 2007, Marcus Overhagen. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -19,14 +19,16 @@ jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { - switch (deviceId) - { + // We only care about devices with function 0. + if (function != 0) + return; + + // And only devices with combined SATA/PATA. + switch (deviceId) { case 0x2361: // 1 SATA, 1 PATA case 0x2363: // 2 SATA, 1 PATA case 0x2366: // 2 SATA, 2 PATA break; - // case 0x2360: // 1 SATA - // case 0x2362: // 2 SATA default: return; } @@ -34,32 +36,30 @@ dprintf("jmicron_fixup_ahci: domain %u, bus %u, device %u, function %u, " "deviceId 0x%04x\n", domain, bus, device, function, deviceId); - if (function == 0) - { - dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", - pci->ReadConfig(domain, bus, device, function, 0x40, 4)); - dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", - pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); + uint32 val = pci->ReadConfig(domain, bus, device, function, 0xdc, 4); + if (!(val & (1 << 30))) { + // IDE controller at function 1 is configured in IDE mode (as opposed + // to AHCI or RAID). So we want to handle it. - uint32 val = pci->ReadConfig(domain, bus, device, function, 0xdc, 4); - if (!(val & (1 << 30))) - { - uint8 irq = pci->ReadConfig(domain, bus, device, function, 0x3c, 1); - dprintf("jmicron_fixup_ahci: enabling split device mode\n"); - val &= ~(1 << 24); - val |= (1 << 25) | (1 << 30); - pci->WriteConfig(domain, bus, device, function, 0xdc, 4, val); - val = pci->ReadConfig(domain, bus, device, function, 0x40, 4); - val &= ~(1 << 16); - val |= (1 << 1) | (1 << 17) | (1 << 22); - pci->WriteConfig(domain, bus, device, function, 0x40, 4, val); - // Set IRQ for dfunction 2 (IDE) device. - pci->WriteConfig(domain, bus, device, 1, 0x3c, 1, irq); - } - dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", - pci->ReadConfig(domain, bus, device, function, 0x40, 4)); - dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", - pci->ReadConfig(domain, bus, device, function, 0xdc, 4)); + dprintf("jmicron_fixup_ahci: PATA controller in IDE mode.\n"); + + // TODO(bga): It seems that with recent BIOS revisions no special code + // is needed here. We still want to handle IRQ assignment as seen + // below. + + // Read IRQ from controller at function 0 and assign this IRQ to the + // controller at function 1. + uint8 irq = pci->ReadConfig(domain, bus, device, function, 0x3c, 1); + pci->WriteConfig(domain, bus, device, 1, 0x3c, 1, irq); + } else { + // TODO(bga): If the PATA controller is set to AHCI mode, the IDE + // driver will try to pick it up and will fail either because there is + // no assigned IRQ or, if we assign an IRQ, because it errors-out when + // detecting devices (probably because of the AHCI mode). Then the AHCI + // driver picks the device up but fail to find the attached devices. + // Maybe fixing this would be as simple as changing the device class to + // Serial ATA Controller instead of IDE Controller (even in AHCI mode + // it reports being a standard IDE controller)? } } @@ -71,8 +71,7 @@ // TODO(bga): disabled until the PCI manager can assign new resources. return; - switch (deviceId) - { + switch (deviceId) { case 0x2825: // ICH8 Desktop when in IDE emulation mode dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825\n"); return; @@ -100,8 +99,7 @@ pci->ReadConfig(domain, bus, device, function, 0x90, 1)); uint8 map = pci->ReadConfig(domain, bus, device, function, 0x90, 1); - if ((map >> 6) == 0) - { + if ((map >> 6) == 0) { uint32 bar5 = pci->ReadConfig(domain, bus, device, function, 0x24, 4); uint16 pcicmd = pci->ReadConfig(domain, bus, device, function, PCI_command, 2); @@ -153,8 +151,7 @@ // dprintf("pci_fixup_device: domain %u, bus %u, device %u, function %u\n", // domain, bus, device, function); - switch (vendorId) - { + switch (vendorId) { case 0x197b: jmicron_fixup_ahci(pci, domain, bus, device, function, deviceId); break; From bga at bug-br.org.br Wed Aug 6 21:21:11 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Wed, 06 Aug 2008 16:21:11 -0300 Subject: [Haiku-commits] r26842 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: <894b9700808060959w3f96b1a0w8af4f36d5277002d@mail.gmail.com> References: <200808061639.m76Gdw91007384@sheep.berlios.de> <894b9700808060959w3f96b1a0w8af4f36d5277002d@mail.gmail.com> Message-ID: <4899F9A7.8080101@bug-br.org.br> Stefano Ceccherini escreveu: >> - switch (vendorId) { >> + switch (vendorId) >> + { >> case 0x197b: > > You got this wrong, though: > The parenthesis is supposed to be on the same line of the switch statement. Yep, which is inconsistent which the usage when used in fumctions/methods implementation. I have no idea why this was decided to be like this. In any case, I reverted those. -Bruno From stippi at mail.berlios.de Wed Aug 6 21:41:28 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Wed, 6 Aug 2008 21:41:28 +0200 Subject: [Haiku-commits] r26845 - haiku/trunk/src/apps/text_search Message-ID: <200808061941.m76JfSWF001579@sheep.berlios.de> Author: stippi Date: 2008-08-06 21:41:00 +0200 (Wed, 06 Aug 2008) New Revision: 26845 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26845&view=rev Modified: haiku/trunk/src/apps/text_search/GrepListView.h haiku/trunk/src/apps/text_search/Jamfile Log: Fix compilation for BeOS compatible targets. Modified: haiku/trunk/src/apps/text_search/GrepListView.h =================================================================== --- haiku/trunk/src/apps/text_search/GrepListView.h 2008-08-06 18:57:56 UTC (rev 26844) +++ haiku/trunk/src/apps/text_search/GrepListView.h 2008-08-06 19:41:00 UTC (rev 26845) @@ -23,8 +23,8 @@ #define GREP_LIST_VIEW_H #include +#include #include -#include class ResultItem : public BStringItem { Modified: haiku/trunk/src/apps/text_search/Jamfile =================================================================== --- haiku/trunk/src/apps/text_search/Jamfile 2008-08-06 18:57:56 UTC (rev 26844) +++ haiku/trunk/src/apps/text_search/Jamfile 2008-08-06 19:41:00 UTC (rev 26845) @@ -5,6 +5,12 @@ UsePrivateHeaders shared ; UsePrivateHeaders storage ; +local additionalBeOSSources ; +if $(TARGET_PLATFORM) != haiku { + SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits storage ] ; + additionalBeOSSources += PathMonitor.cpp ; +} + Application TextSearch : ChangesIterator.cpp FileIterator.cpp @@ -16,6 +22,8 @@ Model.cpp TextSearch.cpp + $(additionalBeOSSources) + : be tracker textencoding libshared.a : TextSearch.rdef ; From stippi at mail.berlios.de Wed Aug 6 21:55:21 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Wed, 6 Aug 2008 21:55:21 +0200 Subject: [Haiku-commits] r26846 - haiku/trunk/src/apps/text_search Message-ID: <200808061955.m76JtLxI002827@sheep.berlios.de> Author: stippi Date: 2008-08-06 21:55:19 +0200 (Wed, 06 Aug 2008) New Revision: 26846 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26846&view=rev Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp haiku/trunk/src/apps/text_search/GrepWindow.h Log: Stop node monitoring when the model changes. Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-06 19:41:00 UTC (rev 26845) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-06 19:55:19 UTC (rev 26846) @@ -958,11 +958,15 @@ else break; } - if (count == 0) { + } + if (count == 0) { + // During updates because of node monitor events, negatives are + // also reported (count == 0). + if (item) { // remove file item itself delete fSearchResults->RemoveItem(index); - return; } + return; } } if (item == NULL) { @@ -1010,7 +1014,7 @@ { fModel->fRecurseLinks = !fModel->fRecurseLinks; fRecurseLinks->SetMarked(fModel->fRecurseLinks); - _SavePrefs(); + _ModelChanged(); } @@ -1019,7 +1023,7 @@ { fModel->fRecurseDirs = !fModel->fRecurseDirs; fRecurseDirs->SetMarked(fModel->fRecurseDirs); - _SavePrefs(); + _ModelChanged(); } @@ -1028,7 +1032,7 @@ { fModel->fSkipDotDirs = !fModel->fSkipDotDirs; fSkipDotDirs->SetMarked(fModel->fSkipDotDirs); - _SavePrefs(); + _ModelChanged(); } @@ -1037,7 +1041,7 @@ { fModel->fEscapeText = !fModel->fEscapeText; fEscapeText->SetMarked(fModel->fEscapeText); - _SavePrefs(); + _ModelChanged(); } @@ -1046,7 +1050,7 @@ { fModel->fCaseSensitive = !fModel->fCaseSensitive; fCaseSensitive->SetMarked(fModel->fCaseSensitive); - _SavePrefs(); + _ModelChanged(); } @@ -1055,7 +1059,7 @@ { fModel->fTextOnly = !fModel->fTextOnly; fTextOnly->SetMarked(fModel->fTextOnly); - _SavePrefs(); + _ModelChanged(); } @@ -1177,8 +1181,10 @@ void GrepWindow::_OnSearchText() { - fButton->SetEnabled(fSearchText->TextView()->TextLength() != 0); - fSearch->SetEnabled(fSearchText->TextView()->TextLength() != 0); + bool enabled = fSearchText->TextView()->TextLength() != 0; + fButton->SetEnabled(enabled); + fSearch->SetEnabled(enabled); + _StopNodeMonitoring(); } @@ -1518,6 +1524,13 @@ // #pragma mark - +void +GrepWindow::_ModelChanged() +{ + _StopNodeMonitoring(); + _SavePrefs(); +} + bool GrepWindow::_OpenInPe(const entry_ref &ref, int32 lineNum) { Modified: haiku/trunk/src/apps/text_search/GrepWindow.h =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-06 19:41:00 UTC (rev 26845) +++ haiku/trunk/src/apps/text_search/GrepWindow.h 2008-08-06 19:55:19 UTC (rev 26846) @@ -89,7 +89,8 @@ void _OnOpenPanelCancel(); void _OnSelectAll(BMessage* message); void _OnNewWindow(); - + + void _ModelChanged(); bool _OpenInPe(const entry_ref& ref, int32 lineNum); void _RemoveFolderListDuplicates(BList* folderList); status_t _OpenFoldersInTracker(BList* folderList); From korli at mail.berlios.de Wed Aug 6 22:04:52 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 6 Aug 2008 22:04:52 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda Message-ID: <200808062004.m76K4qSp003991@sheep.berlios.de> Author: korli Date: 2008-08-06 22:04:51 +0200 (Wed, 06 Aug 2008) New Revision: 26847 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26847&view=rev Modified: 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: * added an ALIGN macro for easing readability and use it for 128 alignments * use HDAC_STREAM_POSITION register value to check the current buffer cycle in interrupt handler * added B_FULL_LOCK flags for area allocation, not sure it's handled but at least more correct * buffer descriptors now use a low and high address fields * applied a byte mask on format * enabled PCI bus mastering if not yet done * the PCI space register TCSEL (Traffic Class Select Register, which sets PCI express QOS) is now reset to TC0 (clear 0-2 bits) as needed on some boards like mine to ensure good playback Playback is finally working correctly here on ICH8 HDA! 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-08-06 19:55:19 UTC (rev 26846) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp 2008-08-06 20:04:51 UTC (rev 26847) @@ -26,6 +26,7 @@ (((controller)->num_input_streams + (controller)->num_output_streams \ + (index)) * HDAC_STREAM_SIZE) +#define ALIGN(size, align) (((size) + align - 1) & ~(align - 1)) #define PAGE_ALIGN(size) (((size) + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1)) static const struct { @@ -73,6 +74,7 @@ stream_handle_interrupt(hda_controller* controller, hda_stream* stream) { uint8 status; + uint32 position, bufferSize; if (!stream->running) return; @@ -83,20 +85,24 @@ stream->Write8(HDAC_STREAM_STATUS, status); - if ((status & STATUS_BUFFER_COMPLETED) != 0) { - // Buffer Completed Interrupt - acquire_spinlock(&stream->lock); + if ((status & STATUS_BUFFER_COMPLETED) == 0) { + dprintf("hda: stream status %x\n", status); + return; + } + + position = stream->Read32(HDAC_STREAM_POSITION); + bufferSize = ALIGN(stream->sample_size * stream->num_channels * stream->buffer_length, 128); + + // Buffer Completed Interrupt + acquire_spinlock(&stream->lock); - stream->real_time = system_time(); - stream->frames_count += stream->buffer_length; - stream->buffer_cycle = (stream->buffer_cycle + 1) - % stream->num_buffers; + stream->real_time = system_time(); + stream->frames_count += stream->buffer_length; + stream->buffer_cycle = 1 - (position / bufferSize); - release_spinlock(&stream->lock); - - release_sem_etc(stream->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); - } else - dprintf("hda: stream status %x\n", status); + release_spinlock(&stream->lock); + + release_sem_etc(stream->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); } @@ -301,9 +307,8 @@ } /* Determine rirb offset in memory and total size of corb+alignment+rirb */ - rirbOffset = (controller->corb_length * sizeof(corb_t) + 0x7f) & ~0x7f; - posOffset = (rirbOffset + controller->rirb_length * sizeof(rirb_t) + 0x7f) - & ~0x7f; + rirbOffset = ALIGN(controller->corb_length * sizeof(corb_t), 128); + posOffset = ALIGN(rirbOffset + controller->rirb_length * sizeof(rirb_t), 128); posSize = 8 * (controller->num_input_streams + controller->num_output_streams + controller->num_bidir_streams); @@ -312,7 +317,7 @@ /* Allocate memory area */ controller->corb_rirb_pos_area = create_area("hda corb/rirb/pos", (void**)&controller->corb, B_ANY_KERNEL_ADDRESS, memSize, - B_CONTIGUOUS, 0); + B_FULL_LOCK | B_CONTIGUOUS, 0); if (controller->corb_rirb_pos_area < 0) return controller->corb_rirb_pos_area; @@ -418,7 +423,6 @@ dprintf("%s: Unknown stream type %d!\n", __func__, type); free(stream); stream = NULL; - break; } // find I/O and Pin widgets for this stream @@ -500,17 +504,18 @@ /* Calculate size of buffer (aligned to 128 bytes) */ bufferSize = stream->sample_size * stream->num_channels * stream->buffer_length; - bufferSize = (bufferSize + 127) & (~127); -dprintf("HDA: sample size %ld, num channels %ld, buffer length %ld ****************\n", - stream->sample_size, stream->num_channels, stream->buffer_length); + bufferSize = ALIGN(bufferSize, 128); + dprintf("HDA: sample size %ld, num channels %ld, buffer length %ld ****************\n", + stream->sample_size, stream->num_channels, stream->buffer_length); + /* Calculate total size of all buffers (aligned to size of B_PAGE_SIZE) */ alloc = bufferSize * stream->num_buffers; alloc = PAGE_ALIGN(alloc); /* Allocate memory for buffers */ stream->buffer_area = create_area("hda buffers", (void**)&buffer, - B_ANY_KERNEL_ADDRESS, alloc, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); + B_ANY_KERNEL_ADDRESS, alloc, B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); if (stream->buffer_area < B_OK) return stream->buffer_area; @@ -539,7 +544,7 @@ stream->buffer_descriptors_area = create_area("hda buffer descriptors", (void**)&bufferDescriptors, B_ANY_KERNEL_ADDRESS, alloc, - B_CONTIGUOUS, 0); + B_FULL_LOCK | B_CONTIGUOUS, 0); if (stream->buffer_descriptors_area < B_OK) { delete_area(stream->buffer_area); return stream->buffer_descriptors_area; @@ -560,14 +565,15 @@ /* Setup buffer descriptor list (BDL) entries */ for (index = 0; index < stream->num_buffers; index++, bufferDescriptors++) { - bufferDescriptors->address = stream->physical_buffers[index]; + bufferDescriptors->lower = stream->physical_buffers[index]; + bufferDescriptors->upper = 0; bufferDescriptors->length = bufferSize; bufferDescriptors->ioc = 1; // we want an interrupt after every buffer } /* Configure stream registers */ - format = stream->num_channels - 1; + format = (stream->num_channels - 1) & 0xf; switch (stream->sample_format) { case B_FMT_8BIT_S: format |= FORMAT_8BIT; stream->bps = 8; break; case B_FMT_16BIT: format |= FORMAT_16BIT; stream->bps = 16; break; @@ -591,15 +597,15 @@ dprintf("IRA: %s: setup stream %ld: SR=%ld, SF=%ld\n", __func__, stream->id, stream->rate, stream->bps); - + 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_ */ - stream->Write32(HDAC_STREAM_BUFFER_SIZE, stream->sample_size - * stream->num_channels * stream->num_buffers * stream->buffer_length); + stream->Write32(HDAC_STREAM_BUFFER_SIZE, bufferSize + * stream->num_buffers); stream->Write8(HDAC_STREAM_CONTROL2, stream->id << 4); stream->controller->Write32(HDAC_DMA_POSITION_BASE_LOWER, @@ -667,9 +673,10 @@ status_t hda_hw_init(hda_controller* controller) { - uint16 capabilities, stateStatus; + uint16 capabilities, stateStatus, cmd; status_t status; - + uint8 tcsel; + /* Map MMIO registers */ controller->regs_area = map_physical_memory("hda_hw_regs", (void*)controller->pci_info.u.h0.base_registers[0], @@ -680,6 +687,15 @@ goto error; } + cmd = (gPci->read_pci_config)(controller->pci_info.bus, + controller->pci_info.device, controller->pci_info.function, PCI_command, 2); + if (!(cmd & PCI_command_master)) { + (gPci->write_pci_config)(controller->pci_info.bus, + controller->pci_info.device, controller->pci_info.function, + PCI_command, 2, cmd | PCI_command_master); + dprintf("hda: enabling PCI bus mastering\n"); + } + /* Absolute minimum hw is online; we can now install interrupt handler */ controller->irq = controller->pci_info.u.h0.interrupt_line; status = install_io_interrupt_handler(controller->irq, @@ -687,6 +703,13 @@ if (status != B_OK) goto no_irq; + /* TCSEL is reset to TC0 (clear 0-2 bits) */ + tcsel = (gPci->read_pci_config)(controller->pci_info.bus, + controller->pci_info.device, controller->pci_info.function, PCI_HDA_TCSEL, 1); + (gPci->write_pci_config)(controller->pci_info.bus, + controller->pci_info.device, controller->pci_info.function, + PCI_HDA_TCSEL, 1, tcsel & 0xf8); + capabilities = controller->Read16(HDAC_GLOBAL_CAP); controller->num_input_streams = GLOBAL_CAP_INPUT_STREAMS(capabilities); controller->num_output_streams = GLOBAL_CAP_OUTPUT_STREAMS(capabilities); 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-08-06 19:55:19 UTC (rev 26846) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller_defs.h 2008-08-06 20:04:51 UTC (rev 26847) @@ -131,6 +131,9 @@ #define HDAC_STREAM_BUFFERS_BASE_LOWER 0x18 // 32bits, BDPL #define HDAC_STREAM_BUFFERS_BASE_UPPER 0x1c // 32bits, BDPU +/* PCI space register definitions */ +#define PCI_HDA_TCSEL 0x44 + typedef uint32 corb_t; typedef struct { uint32 response; @@ -141,7 +144,8 @@ #define RESPONSE_FLAGS_UNSOLICITED (1 << 4) typedef struct { - uint64 address; + uint32 lower; + uint32 upper; uint32 length; uint32 ioc; } bdl_entry_t; From stippi at mail.berlios.de Wed Aug 6 22:22:53 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Wed, 6 Aug 2008 22:22:53 +0200 Subject: [Haiku-commits] r26848 - haiku/trunk/src/apps/text_search Message-ID: <200808062022.m76KMrK6006145@sheep.berlios.de> Author: stippi Date: 2008-08-06 22:22:50 +0200 (Wed, 06 Aug 2008) New Revision: 26848 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26848&view=rev Modified: haiku/trunk/src/apps/text_search/Grepper.cpp Log: Handle removed files. * On Haiku, this will make them disappear from the results list. * On BeOS, it will only work around the problem that we don't know which file was removed from the node monitoring message... Modified: haiku/trunk/src/apps/text_search/Grepper.cpp =================================================================== --- haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-06 20:04:51 UTC (rev 26847) +++ haiku/trunk/src/apps/text_search/Grepper.cpp 2008-08-06 20:22:50 UTC (rev 26848) @@ -188,8 +188,13 @@ message.MakeEmpty(); message.what = MSG_REPORT_RESULT; message.AddString("filename", fileName); - + BEntry entry(fileName); + if (!entry.Exists()) { + if (fIterator->NotifyNegatives()) + fTarget.SendMessage(&message); + continue; + } entry_ref ref; entry.GetRef(&ref); message.AddRef("ref", &ref); From bga at bug-br.org.br Wed Aug 6 23:11:05 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Wed, 06 Aug 2008 18:11:05 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <200808062004.m76K4qSp003991@sheep.berlios.de> References: <200808062004.m76K4qSp003991@sheep.berlios.de> Message-ID: <489A1369.8010102@bug-br.org.br> korli at BerliOS escreveu: > Playback is finally working correctly here on ICH8 HDA! Hey Korli. Congratulations! Just so you know, I have an ICH9 chipset here and I get total silence out of the speakers. At least it is not distorted. ;) -Bruno From axeld at pinc-software.de Wed Aug 6 23:14:11 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Wed, 06 Aug 2008 23:14:11 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26847_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/audio/hda?= In-Reply-To: <200808062004.m76K4qSp003991@sheep.berlios.de> Message-ID: <53493165823-BeMail@zon> korli at BerliOS wrote: > Log: > * added an ALIGN macro for easing readability and use it for 128 > alignments > * use HDAC_STREAM_POSITION register value to check the current buffer > cycle in interrupt handler > * added B_FULL_LOCK flags for area allocation, not sure it's handled > but at least more > correct Nope, the locking parameter is no flags field - B_CONTIGUOUS actually implies B_FULL_LOCK (otherwise it wouldn't make much sense). It didn't do any harm, though as (2 | 3) is still 3 :-) > * buffer descriptors now use a low and high address fields > * applied a byte mask on format > * enabled PCI bus mastering if not yet done > * the PCI space register TCSEL (Traffic Class Select Register, which > sets > PCI express QOS) is now reset to TC0 (clear 0-2 bits) as needed on > some boards > like mine to ensure good playback > > Playback is finally working correctly here on ICH8 HDA! That's absolutely amazing! The only functional change should be the bus mastering + TCSEL. I'll try to see tomorrow if this makes it work on my laptop, too (it already worked on my desktop, but only in the multi_audio_test app, and it didn't sound too well, probably because my board needs TCSEL as well). Thanks a lot! Bye, Axel. From ingo_weinhold at gmx.de Wed Aug 6 23:18:44 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 06 Aug 2008 23:18:44 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <200808062004.m76K4qSp003991@sheep.berlios.de> References: <200808062004.m76K4qSp003991@sheep.berlios.de> Message-ID: <20080806231844.403.1@knochen-vm.localdomain> On 2008-08-06 at 22:04:52 [+0200], korli at BerliOS wrote: > Author: korli > Date: 2008-08-06 22:04:51 +0200 (Wed, 06 Aug 2008) > New Revision: 26847 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26847&view=rev > > Modified: > 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: > * added an ALIGN macro for easing readability and use it for 128 alignments > * use HDAC_STREAM_POSITION register value to check the current buffer cycle > in interrupt handler > * added B_FULL_LOCK flags for area allocation, not sure it's handled but at > least more correct No, it's not correct, since the constants for the locking parameter aren't flags: B_CONTIGUOUS > B_FULL_LOCK > B_LAZY_LOCK > B_NO_LOCK CU, Ingo From bonefish at mail.berlios.de Thu Aug 7 01:03:01 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 7 Aug 2008 01:03:01 +0200 Subject: [Haiku-commits] r26849 - haiku/trunk/src/system/kernel/vm Message-ID: <200808062303.m76N31pk001203@sheep.berlios.de> Author: bonefish Date: 2008-08-07 01:02:59 +0200 (Thu, 07 Aug 2008) New Revision: 26849 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26849&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: VMCache::RemoveArea(): Don't release the store reference while having the cache locked, since it enters the VFS and might reenter VMCache, thus causing deadlocks. Fixes bug #2577. Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-06 20:22:50 UTC (rev 26848) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-06 23:02:59 UTC (rev 26849) @@ -667,6 +667,12 @@ T(RemoveArea(this, area)); + // We release the store reference first, since otherwise we would reverse + // the locking order or even deadlock ourselves (... -> free_vnode() -> ... + // -> bfs_remove_vnode() -> ... -> file_cache_set_size() -> mutex_lock()). + // Also cf. _RemoveConsumer(). + ReleaseStoreRef(); + AutoLocker locker(this); if (area->cache_prev) @@ -676,8 +682,6 @@ if (areas == area) areas = area->cache_next; - ReleaseStoreRef(); - return B_OK; } From bonefish at mail.berlios.de Thu Aug 7 02:19:46 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 7 Aug 2008 02:19:46 +0200 Subject: [Haiku-commits] r26850 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808070019.m770Jkod025621@sheep.berlios.de> Author: bonefish Date: 2008-08-07 02:19:44 +0200 (Thu, 07 Aug 2008) New Revision: 26850 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26850&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp Log: Copy and paste bug. Fixes #2576. Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-06 23:02:59 UTC (rev 26849) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-07 00:19:44 UTC (rev 26850) @@ -717,7 +717,7 @@ locker.Unlock(); - status_t error = entry.Wait(B_CAN_INTERRUPT); + status_t error = entry.Wait(flags, timeout); if (error != B_OK) return error; From bonefish at mail.berlios.de Thu Aug 7 03:18:06 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 7 Aug 2008 03:18:06 +0200 Subject: [Haiku-commits] r26851 - haiku/trunk/src/system/kernel/vm Message-ID: <200808070118.m771I6kI031668@sheep.berlios.de> Author: bonefish Date: 2008-08-07 03:18:04 +0200 (Thu, 07 Aug 2008) New Revision: 26851 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26851&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: * Improved some output and coding style. * If a segment violation occurs, we do now check whether the thread in question has a handler for SIGSEGV. If so, we just send it the signal. Otherwise we notify the debugger as before. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-07 00:19:44 UTC (rev 26850) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-07 01:18:04 UTC (rev 26851) @@ -4113,10 +4113,13 @@ // fault and someone is already waiting for a write lock on the same address // space. This thread will then try to acquire the semaphore again and will // be queued after the writer. - dprintf("vm_page_fault: sending team \"%s\" 0x%lx SIGSEGV, ip %#lx (\"%s\" +%#lx)\n", - thread_get_current_thread()->team->name, - thread_get_current_thread()->team->id, faultAddress, - area ? area->name : "???", faultAddress - (area ? area->base : 0x0)); + struct thread *thread = thread_get_current_thread(); + dprintf("vm_page_fault: thread \"%s\" (%ld) in team \"%s\" (%ld) " + "tried to %s address %#lx, ip %#lx (\"%s\" +%#lx)\n", + thread->name, thread->id, thread->team->name, thread->team->id, + isWrite ? "write" : "read", address, faultAddress, + area ? area->name : "???", + faultAddress - (area ? area->base : 0x0)); // We can print a stack trace of the userland thread here. #if 1 @@ -4171,12 +4174,21 @@ rw_lock_read_unlock(&addressSpace->lock); #endif - struct thread *thread = thread_get_current_thread(); // TODO: the fault_callback is a temporary solution for vm86 if (thread->fault_callback == NULL || thread->fault_callback(address, faultAddress, isWrite)) { - if (user_debug_exception_occurred(B_SEGMENT_VIOLATION, SIGSEGV)) - send_signal(team_get_current_team_id(), SIGSEGV); + // If the thread has a signal handler for SIGSEGV we simply send + // it the signal. Otherwise we notify the user debugger. If + // anything goes wrong, we kill the team. + struct sigaction action; + if (sigaction(SIGSEGV, NULL, &action) == 0 + && action.sa_handler != SIG_DFL + && action.sa_handler != SIG_IGN) { + send_signal(thread->id, SIGSEGV); + } else if (user_debug_exception_occurred(B_SEGMENT_VIOLATION, + SIGSEGV)) { + send_signal(team_get_current_team_id(), SIGKILL); + } } } } From axeld at mail.berlios.de Thu Aug 7 08:41:16 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 08:41:16 +0200 Subject: [Haiku-commits] r26852 - haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd Message-ID: <200808070641.m776fG7S017518@sheep.berlios.de> Author: axeld Date: 2008-08-07 08:41:15 +0200 (Thu, 07 Aug 2008) New Revision: 26852 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26852&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp Log: * Forgot to allocate the dma_resource before using it. Now scsi_cd works again. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-07 01:18:04 UTC (rev 26851) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-07 06:41:15 UTC (rev 26852) @@ -939,6 +939,12 @@ memset(info, 0, sizeof(*info)); + info->dma_resource = new(std::nothrow) DMAResource; + if (info->dma_resource == NULL) { + free(info); + return B_NO_MEMORY; + } + info->node = node; info->removable = removable; From axeld at mail.berlios.de Thu Aug 7 09:29:30 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 09:29:30 +0200 Subject: [Haiku-commits] r26853 - haiku/trunk/src/add-ons/kernel/file_systems/cdda Message-ID: <200808070729.m777TUSF021832@sheep.berlios.de> Author: axeld Date: 2008-08-07 09:29:29 +0200 (Thu, 07 Aug 2008) New Revision: 26853 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26853&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.cpp haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp Log: * read_cdda_data() needs to know the last frame of the track, so that it can cut down the buffer size on the last request. This fixes bug #2565. * cdda_read() did report an incorrect number of bytes read. This fixes bug #2511, and also that you couldn't copy tracks via "cp". * cdda_read_stat() did not include the WAV header in its reported size. Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.cpp 2008-08-07 06:41:15 UTC (rev 26852) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.cpp 2008-08-07 07:29:29 UTC (rev 26853) @@ -602,7 +602,7 @@ status_t -read_cdda_data(int fd, off_t offset, void *data, size_t length, +read_cdda_data(int fd, off_t endFrame, off_t offset, void *data, size_t length, off_t bufferOffset, void *buffer, size_t bufferSize) { if (bufferOffset >= 0 && bufferOffset <= offset + length @@ -627,12 +627,14 @@ length -= bytes; } - // we don't handle the case we would need to split the request + // we don't handle the case where we would need to split the request } while (length > 0) { off_t frame = offset / kFrameSize; uint32 count = bufferSize / kFrameSize; + if (frame + count > endFrame) + count = endFrame - frame; status_t status = read_frames(fd, frame, (uint8 *)buffer, count); if (status < B_OK) Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h 2008-08-07 06:41:15 UTC (rev 26852) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h 2008-08-07 07:29:29 UTC (rev 26853) @@ -1,5 +1,5 @@ /* - * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2007-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef CDDA_H @@ -30,7 +30,7 @@ status_t read_cdtext(int fd, cdtext &text); status_t read_table_of_contents(int fd, scsi_toc_toc *toc, size_t length); -status_t read_cdda_data(int fd, off_t offset, void *data, size_t length, - off_t bufferOffset, void *buffer, size_t bufferSize); +status_t read_cdda_data(int fd, off_t endFrame, off_t offset, void *data, + size_t length, off_t bufferOffset, void *buffer, size_t bufferSize); #endif // CDDA_H 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-08-07 06:41:15 UTC (rev 26852) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2008-08-07 07:29:29 UTC (rev 26853) @@ -388,7 +388,6 @@ return false; count = B_BENDIAN_TO_HOST_INT32(count); -dprintf("inode %s read %lu attrs\n", inode->Name(), count); if (count > kMaxAttributes) return false; @@ -405,7 +404,6 @@ type = B_BENDIAN_TO_HOST_INT32(type); size = B_BENDIAN_TO_HOST_INT32(size); name[length] = '\0'; -dprintf(" type %08lx, size %lu, name %s\n", type, size, name); Attribute *attribute = new Attribute(name, type); if (attribute->SetSize(size) != B_OK @@ -431,7 +429,7 @@ stat.st_mode = S_ATTR | 0666; stat.st_type = attribute->Type(); } else { - stat.st_size = inode->Size(); + stat.st_size = inode->Size() + sizeof(wav_header); stat.st_mode = inode->Type(); stat.st_type = 0; } @@ -782,7 +780,6 @@ } else strlcat(path, "/shared", B_PATH_NAME_LENGTH); -dprintf("PATH: %s\n", path); int fd = open(path, mode | (create ? O_CREAT | O_TRUNC : 0), 0644); free(path); @@ -807,7 +804,6 @@ return; } -dprintf("VOLUME %s\n", line); SetName(line); for (Inode *inode = fFirstEntry; inode != NULL; inode = inode->Next()) { @@ -815,7 +811,6 @@ break; inode->SetName(line); -dprintf("INODE %s\n", line); } if (read_attributes(fd, fRootNode)) { @@ -1546,17 +1541,20 @@ length = maxSize - offset; status_t status = B_OK; + size_t bytesRead = 0; if (offset < sizeof(wav_header)) { // read fake WAV header size_t size = sizeof(wav_header) - offset; size = min_c(size, length); - if (user_memcpy(buffer, (uint8 *)inode->WAVHeader() + offset, size) < B_OK) + if (user_memcpy(buffer, (uint8 *)inode->WAVHeader() + offset, size) + < B_OK) return B_BAD_ADDRESS; buffer = (void *)((uint8 *)buffer + size); length -= size; + bytesRead += size; offset = 0; } else offset -= sizeof(wav_header); @@ -1565,11 +1563,14 @@ // read actual CD data offset += inode->StartFrame() * kFrameSize; - status = read_cdda_data(volume->Device(), offset, buffer, length, + status = read_cdda_data(volume->Device(), + inode->StartFrame() + inode->FrameCount(), offset, buffer, length, cookie->buffer_offset, cookie->buffer, volume->BufferSize()); + + bytesRead += length; } if (status == B_OK) - *_length = length; + *_length = bytesRead; return status; } From sbenedetto at mail.berlios.de Thu Aug 7 10:09:57 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Thu, 7 Aug 2008 10:09:57 +0200 Subject: [Haiku-commits] r26854 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200808070809.m7789vf4025623@sheep.berlios.de> Author: sbenedetto Date: 2008-08-07 10:09:56 +0200 (Thu, 07 Aug 2008) New Revision: 26854 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26854&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/TestUnitUtils.h haiku/trunk/src/tests/system/libroot/posix/xsi_sem_test1.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp Log: * Adding xsi semaphore test unit * Moving common functions and macros used in realtime_sem_test1 to a shared header as they are probably going to be used for other test unit Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-07 07:29:29 UTC (rev 26853) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-07 08:09:56 UTC (rev 26854) @@ -52,6 +52,10 @@ : init_rld_after_fork_test.cpp ; +SimpleTest xsi_sem_test1 + : xsi_sem_test1.cpp +; + # Tell Jam where to find these sources SEARCH on [ FGristFiles syslog.cpp Added: haiku/trunk/src/tests/system/libroot/posix/TestUnitUtils.h =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/TestUnitUtils.h 2008-08-07 07:29:29 UTC (rev 26853) +++ haiku/trunk/src/tests/system/libroot/posix/TestUnitUtils.h 2008-08-07 08:09:56 UTC (rev 26854) @@ -0,0 +1,150 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _UNIT_TEST_UTILS_H +#define _UNIT_TEST_UTILS_H + +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 5% deviation + bigtime_t diff = actual > expected ? actual - expected : expected - actual; + if (diff <= expected / 20) + 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_set(const char* testSet) +{ + printf("\nTEST SET: %s\n", testSet); +} + + +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); + _assert_equals(test, 0, status, lineNumber); +} + + +#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__) + +#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__) + +#endif // _UNIT_TEST_UTILS_H Modified: haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-08-07 07:29:29 UTC (rev 26853) +++ haiku/trunk/src/tests/system/libroot/posix/realtime_sem_test1.cpp 2008-08-07 08:09:56 UTC (rev 26854) @@ -35,121 +35,8 @@ #endif // !__HAIKU__ +#include "TestUnitUtils.h" -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 5% deviation - bigtime_t diff = actual > expected ? actual - expected : expected - actual; - if (diff <= expected / 20) - 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_set(const char* testSet) -{ - printf("\nTEST SET: %s\n", testSet); -} - - -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); - _assert_equals(test, 0, status, lineNumber); -} - - #if 0 static void dump_sem(const char* name, sem_t* sem) @@ -162,35 +49,6 @@ #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__) - -#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"; Added: haiku/trunk/src/tests/system/libroot/posix/xsi_sem_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/xsi_sem_test1.cpp 2008-08-07 07:29:29 UTC (rev 26853) +++ haiku/trunk/src/tests/system/libroot/posix/xsi_sem_test1.cpp 2008-08-07 08:09:56 UTC (rev 26854) @@ -0,0 +1,325 @@ +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "TestUnitUtils.h" + +#define KEY ((key_t)12345) +#define NUM_OF_SEMS 10 + +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; +}; + + +static status_t +remove_semaphore(int semID) +{ + return semctl(semID, 0, IPC_RMID, 0); +} + + +static void +test_semget() +{ + TEST_SET("semget({IPC_PRIVATE, key})"); + + const char* currentTest = NULL; + + // Open private set with IPC_PRIVATE + TEST("semget(IPC_PRIVATE) - private"); + int semID = semget(IPC_PRIVATE, NUM_OF_SEMS, S_IRUSR | S_IWUSR); + assert_posix_bool_success(semID != -1); + + // Destroy private semaphore + TEST("semctl(IPC_RMID) - private"); + status_t status = remove_semaphore(semID); + assert_posix_bool_success(status != -1); + + // Open non-private non-existing set with IPC_CREAT + TEST("semget(KEY, IPC_CREAT) non-existing"); + semID = semget(KEY, NUM_OF_SEMS, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR + | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + assert_posix_bool_success(status != -1); + + // Re-open non-private existing without IPC_CREAT + TEST("semget(KEY) re-open existing without IPC_CREAT"); + int returnID = semget(KEY, 0, 0); + assert_equals(semID, returnID); + + // Re-open non-private existing with IPC_CREAT + TEST("semget(IPC_CREATE) re-open existing with IPC_CREAT"); + returnID = semget(KEY, 0, IPC_CREAT | IPC_EXCL); + assert_posix_bool_success(errno == EEXIST); + + // Destroy non-private semaphore + TEST("semctl(IPC_RMID)"); + status = remove_semaphore(semID); + assert_posix_bool_success(status != -1); + + // Open non-private non-existing without IPC_CREAT + TEST("semget(IPC_CREATE) non-existing without IPC_CREAT"); + semID = semget(KEY, NUM_OF_SEMS, IPC_EXCL | S_IRUSR | S_IWUSR + | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + assert_posix_bool_success(errno == ENOENT); + + // Destroy non-existing semaphore + TEST("semctl()"); + status = remove_semaphore(semID); + assert_posix_bool_success(errno == EINVAL); + + TEST("done"); +} + + +static void +test_semop2() +{ + TEST_SET("semop2()"); + + const char* currentTest = NULL; + + // Re-open non-private existing without IPC_CREAT + TEST("semget(KEY) re-open existing without IPC_CREAT"); + int returnedID = semget(KEY, 0, 0); + assert_posix_bool_success(returnedID != -1); + + TEST("semop(IPC_NOWAIT) - wait for zero"); + // Set up array of semaphores + struct sembuf array[NUM_OF_SEMS]; + for (int i = 0; i < NUM_OF_SEMS; i++) { + array[i].sem_num = i; + array[i].sem_op = 0; + array[i].sem_flg = IPC_NOWAIT; + } + semop(returnedID, array, NUM_OF_SEMS); + assert_posix_bool_success(errno == EAGAIN); + + TEST("semop(IPC_NOWAIT) - wait to increase"); + for (int i = 0; i < NUM_OF_SEMS; i++) { + array[i].sem_num = i; + array[i].sem_op = -9; + array[i].sem_flg = IPC_NOWAIT; + } + semop(returnedID, array, NUM_OF_SEMS); + assert_posix_bool_success(errno == EAGAIN); + + TEST("semop(IPC_NOWAIT) - acquire resource sem #0"); + struct sembuf ops; + ops.sem_num = 0; + ops.sem_op = -8; + ops.sem_flg = 0; + status_t status = semop(returnedID, &ops, 1); + assert_posix_bool_success(status != -1); + + TEST("semop(IPC_NOWAIT) - acquire zero sem #0"); + ops.sem_num = 0; + ops.sem_op = 0; + ops.sem_flg = 0; + status = semop(returnedID, &ops, 1); + + TEST("semop(IPC_NOWAIT) - revert semop sem #0"); + ops.sem_num = 0; + ops.sem_op = 8; + ops.sem_flg = 0; + status = semop(returnedID, &ops, 1); + + // Decrease to zero even semaphores and + // use SEM_UNDO flag on odd semaphores in order + // to wake up the father on exit + // Set up array of semaphores + for (int i = 0; i < NUM_OF_SEMS; i++) { + array[i].sem_num = i; + array[i].sem_op = -8; + if (i % 2) + array[i].sem_flg = 0; + else + array[i].sem_flg = SEM_UNDO; + } + TEST("semop() - father"); + status = semop(returnedID, array, NUM_OF_SEMS); + assert_posix_bool_success(status != -1); + + TEST("done"); +} + + +static void +test_semop() +{ + TEST_SET("semop()"); + const char* currentTest = NULL; + + // Open non-private non-existing set with IPC_CREAT + TEST("semget(IPC_CREATE) non-existing"); + int semID = semget(KEY, NUM_OF_SEMS, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR + | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + assert_posix_bool_success(semID != -1); + + // SETALL + TEST("semctl(SETALL)"); + union semun args; + args.array = (unsigned short *)malloc(sizeof(unsigned short) * NUM_OF_SEMS); + for (int i = 0; i < NUM_OF_SEMS; i++) + args.array[i] = 8; + status_t status = semctl(semID, 0, SETALL, args); + assert_posix_bool_success(status != -1); + free(args.array); + + pid_t child = fork(); + if (child == 0) { + // The child first will test the IPC_NOWAIT + // feature, while the father waits for him, + // by waiting for zero on even semaphores, + // and to increase for odd semaphores, which + // will happen on process exit due to SEM_UNDO + // feature. + test_semop2(); + exit(0); + } + + wait_for_child(child); + + // Set up array of semaphores + struct sembuf array[NUM_OF_SEMS]; + for (int i = 0; i < NUM_OF_SEMS; i++) { + array[i].sem_num = i; + if (i % 2) + array[i].sem_op = 0; // wait for zero + else + array[i].sem_op = -8; // wait to increase + array[i].sem_flg = 0; + } + TEST("semop() - father acquired set"); + status = semop(semID, array, NUM_OF_SEMS); + assert_posix_bool_success(status != -1); + + // Destroy non-private semaphore + TEST("semctl(IPC_RMID)"); + status = remove_semaphore(semID); + assert_posix_bool_success(status != 1); + + TEST("done"); +} + + +static void +test_semctl() +{ + TEST_SET("semctl({GETVAL, SETVAL, GETPID, GETNCNT, GETZCNT, GETALL, SETALL, IPC_STAT, IPC_SET, IPC_RMID})"); + + const char* currentTest = NULL; + + // Open non-private non-existing set with IPC_CREAT + TEST("semget(IPC_CREATE) non-existing"); + int semID = semget(KEY, NUM_OF_SEMS, IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR + | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + assert_posix_bool_success(semID != -1); + + // GETVAL + TEST("semctl(GETVAL)"); + union semun args; + status_t status = semctl(semID, NUM_OF_SEMS - 1, GETVAL, args); + // Semaphore is not initialized. Value is unknown. + // We care about not crashing into KDL. + assert_posix_bool_success(status != -1); + + // SETALL + TEST("semctl(SETALL)"); + args.array = (unsigned short *)malloc(sizeof(unsigned short) * NUM_OF_SEMS); + for (int i = 0; i < NUM_OF_SEMS; i++) + args.array[i] = 5; + status = semctl(semID, 0, SETALL, args); + assert_posix_bool_success(status != -1); + free(args.array); + + // GETVAL semaphore 4 + int returnedValue = semctl(semID, 4, GETVAL, 0); + assert_equals((unsigned short)returnedValue, (unsigned short)5); + + // GETALL + TEST("semctl(GETALL)"); + args.array = (unsigned short *)malloc(sizeof(unsigned short) * NUM_OF_SEMS); + semctl(semID, 0, GETALL, args); + // Check only last semaphore value + assert_equals(args.array[NUM_OF_SEMS - 1], (unsigned short)5); + free(args.array); + + // SETVAL semaphore 2 + TEST("semctl(SETVAL) - semaphore #2"); + args.val = 7; + status = semctl(semID, 2, SETVAL, args); + assert_posix_bool_success(status != 1); + + // GETALL + TEST("semctl(GETALL)"); + args.array = (unsigned short *)malloc(sizeof(unsigned short) * NUM_OF_SEMS); + status = semctl(semID, 0, GETALL, args); + assert_posix_bool_success(status != -1); + TEST("semctl(GETALL) - semaphore #10"); + assert_equals(args.array[NUM_OF_SEMS - 1], (unsigned short)5); + TEST("semctl(GETALL) - semaphore #2"); + assert_equals(args.array[NUM_OF_SEMS - 1], (unsigned short)5); + free(args.array); + + // IPC_SET + TEST("semctl(IPC_SET)"); + struct semid_ds semaphore; + memset(&semaphore, 0, sizeof(struct semid_ds)); + semaphore.sem_perm.uid = getuid() + 3; + semaphore.sem_perm.gid = getgid() + 3; + semaphore.sem_perm.mode = 0666; + args.buf = &semaphore; + status = semctl(semID, 0, IPC_SET, args); + assert_posix_bool_success(status != 1); + + // IPC_STAT set + TEST("semctl(IPC_STAT)"); + memset(&semaphore, 0, sizeof(struct semid_ds)); + args.buf = &semaphore; + status = semctl(semID, 0, IPC_STAT, args); + assert_posix_bool_success(status != 1); + TEST("semctl(IPC_STAT): number of sems"); + assert_equals((unsigned short)args.buf->sem_nsems, (unsigned short)NUM_OF_SEMS); + TEST("semctl(IPC_STAT): uid"); + assert_equals(args.buf->sem_perm.uid, getuid() + 3); + TEST("semctl(IPC_STAT): gid"); + assert_equals(args.buf->sem_perm.gid, getgid() + 3); + + // Destroy non-private semaphore + TEST("semctl(IPC_RMID)"); + status = remove_semaphore(semID); + assert_posix_bool_success(status != 1); + + TEST("done"); +} + + +int +main() +{ + test_semget(); + test_semctl(); + test_semop(); + + printf("\nAll tests OK\n"); +} From sbenedetto at mail.berlios.de Thu Aug 7 10:14:10 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Thu, 7 Aug 2008 10:14:10 +0200 Subject: [Haiku-commits] r26855 - haiku/trunk/headers/posix/sys Message-ID: <200808070814.m778EAUX026321@sheep.berlios.de> Author: sbenedetto Date: 2008-08-07 10:14:09 +0200 (Thu, 07 Aug 2008) New Revision: 26855 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26855&view=rev Modified: haiku/trunk/headers/posix/sys/types.h Log: * Updating license Modified: haiku/trunk/headers/posix/sys/types.h =================================================================== --- haiku/trunk/headers/posix/sys/types.h 2008-08-07 08:09:56 UTC (rev 26854) +++ haiku/trunk/headers/posix/sys/types.h 2008-08-07 08:14:09 UTC (rev 26855) @@ -1,5 +1,6 @@ /* - * Distributed under the terms of the OpenBeOS license + * Copyright 2006, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. */ #ifndef _SYS_TYPES_H #define _SYS_TYPES_H From korli at users.berlios.de Thu Aug 7 11:40:23 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 11:40:23 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <20080806231844.403.1@knochen-vm.localdomain> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <20080806231844.403.1@knochen-vm.localdomain> Message-ID: 2008/8/6 Ingo Weinhold : > No, it's not correct, since the constants for the locking parameter aren't > flags: B_CONTIGUOUS > B_FULL_LOCK > B_LAZY_LOCK > B_NO_LOCK > Thanks for clarifying. I still maintain some old drivers with such incorrect things. Bye, J?r?me From korli at users.berlios.de Thu Aug 7 11:41:23 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 11:41:23 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <53493165823-BeMail@zon> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <53493165823-BeMail@zon> Message-ID: 2008/8/6 Axel D?rfler : > Nope, the locking parameter is no flags field - B_CONTIGUOUS actually > implies B_FULL_LOCK (otherwise it wouldn't make much sense). It didn't > do any harm, though as (2 | 3) is still 3 :-) Right. Can we check this on other drivers too and keep B_CONTIGUOUS only then ? > That's absolutely amazing! The only functional change should be the bus > mastering + TCSEL. > I'll try to see tomorrow if this makes it work on my laptop, too (it > already worked on my desktop, but only in the multi_audio_test app, and > it didn't sound too well, probably because my board needs TCSEL as > well). Indeed, this was the trick. There could be another trick with pci express snooping activation (vendor specific). BTW I tested at 48khz 16bits. I'll check with default settings too. Bye, J?r?me From korli at users.berlios.de Thu Aug 7 11:42:58 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 11:42:58 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489A1369.8010102@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> Message-ID: Hey Bruno, 2008/8/6 Bruno Albuquerque : > Congratulations! Just so you know, I have an ICH9 chipset here and I get > total silence out of the speakers. At least it is not distorted. ;) Could you give the pci ids anyway ? Bye, J?r?me From bga at bug-br.org.br Thu Aug 7 12:33:38 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 07 Aug 2008 07:33:38 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> Message-ID: <489ACF82.9060200@bug-br.org.br> J?r?me Duval escreveu: >> Congratulations! Just so you know, I have an ICH9 chipset here and I get >> total silence out of the speakers. At least it is not distorted. ;) > > Could you give the pci ids anyway ? I looked under Windows and that confused me a bit, I see tree devices: High Definition Audio Device (2 of these with same ids) Vendor: 0x1002 Device: 0xAA01 SoundMax Integrated Digital Audio Vendor: 0x11d4 Device: 0x198B Hope this helps. -Bruno From korli at users.berlios.de Thu Aug 7 12:38:12 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 12:38:12 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489ACF82.9060200@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> Message-ID: 2008/8/7 Bruno Albuquerque : > I looked under Windows and that confused me a bit, I see tree devices: > > High Definition Audio Device (2 of these with same ids) > > Vendor: 0x1002 > Device: 0xAA01 > > Obviously it's an ATI hda device. Bye, J?r?me From axeld at pinc-software.de Thu Aug 7 12:51:30 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 12:51:30 +0200 CEST Subject: [Haiku-commits] r26855 - haiku/trunk/headers/posix/sys In-Reply-To: <200808070814.m778EAUX026321@sheep.berlios.de> Message-ID: <16153514603-BeMail@zon> sbenedetto at BerliOS wrote: > Log: > * Updating license [...] > - * Distributed under the terms of the OpenBeOS license > + * Copyright 2006, Haiku Inc. All Rights Reserved. > + * Distributed under the terms of the MIT License. Why just 2006? This file exists since 2002. Bye, Axel. From axeld at pinc-software.de Thu Aug 7 12:52:32 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 12:52:32 +0200 CEST Subject: [Haiku-commits] r26854 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <200808070809.m7789vf4025623@sheep.berlios.de> Message-ID: <16215685245-BeMail@zon> sbenedetto at BerliOS wrote: > * Moving common functions and macros used in realtime_sem_test1 > to a shared header as they are probably going to be used for other > test unit If you want to do real unit tests, we actually already have a framework for that, just look at src/tests/. Bye, Axel. From sbenedetto at mail.berlios.de Thu Aug 7 12:59:36 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Thu, 7 Aug 2008 12:59:36 +0200 Subject: [Haiku-commits] r26856 - haiku/trunk/headers/posix/sys Message-ID: <200808071059.m77Axad7010222@sheep.berlios.de> Author: sbenedetto Date: 2008-08-07 12:59:35 +0200 (Thu, 07 Aug 2008) New Revision: 26856 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26856&view=rev Modified: haiku/trunk/headers/posix/sys/types.h Log: * fix year in copyright Modified: haiku/trunk/headers/posix/sys/types.h =================================================================== --- haiku/trunk/headers/posix/sys/types.h 2008-08-07 08:14:09 UTC (rev 26855) +++ haiku/trunk/headers/posix/sys/types.h 2008-08-07 10:59:35 UTC (rev 26856) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku Inc. All Rights Reserved. + * Copyright 2002-2006, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_TYPES_H From emitrax at gmail.com Thu Aug 7 13:01:15 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Thu, 7 Aug 2008 11:01:15 +0000 Subject: [Haiku-commits] r26854 - haiku/trunk/src/tests/system/libroot/posix In-Reply-To: <16215685245-BeMail@zon> References: <200808070809.m7789vf4025623@sheep.berlios.de> <16215685245-BeMail@zon> Message-ID: 2008/8/7 Axel D?rfler : > sbenedetto at BerliOS wrote: >> * Moving common functions and macros used in realtime_sem_test1 >> to a shared header as they are probably going to be used for other >> test unit > > If you want to do real unit tests, we actually already have a framework > for that, just look at src/tests/. Ok thanks. Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From bga at bug-br.org.br Thu Aug 7 13:33:27 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 07 Aug 2008 08:33:27 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> Message-ID: <489ADD87.3000307@bug-br.org.br> J?r?me Duval wrote: >> I looked under Windows and that confused me a bit, I see tree devices: >> >> High Definition Audio Device (2 of these with same ids) >> >> Vendor: 0x1002 >> Device: 0xAA01 > > Obviously it's an ATI hda device. Is this good or bad? :) In any case, what about the other devices that show? -Bruno From axeld at pinc-software.de Thu Aug 7 13:34:26 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 13:34:26 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26854_-_haiku/trunk/src/tests/system/l?= =?utf-8?q?ibroot/posix?= In-Reply-To: Message-ID: <18729777081-BeMail@zon> "Salvatore Benedetto" wrote: > 2008/8/7 Axel D?rfler : > > sbenedetto at BerliOS wrote: > >> * Moving common functions and macros used in realtime_sem_test1 > >> to a shared header as they are probably going to be used for > > > other > >> test unit > > If you want to do real unit tests, we actually already have a > > framework > > for that, just look at src/tests/. > Ok thanks. For example implementations, the src/tests/kits/storage directory is probably worth a look. Bye, Axel. From axeld at mail.berlios.de Thu Aug 7 14:29:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 14:29:32 +0200 Subject: [Haiku-commits] r26857 - haiku/trunk/src/add-ons/kernel/bus_managers/ps2 Message-ID: <200808071229.m77CTWki001160@sheep.berlios.de> Author: axeld Date: 2008-08-07 14:29:32 +0200 (Thu, 07 Aug 2008) New Revision: 26857 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26857&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_common.c Log: * White space cleanup. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_common.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_common.c 2008-08-07 10:59:35 UTC (rev 26856) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ps2/ps2_common.c 2008-08-07 12:29:32 UTC (rev 26857) @@ -128,20 +128,20 @@ { status_t res; uint8 cmdbyte; - + res = ps2_command(PS2_CTRL_READ_CMD, NULL, 0, &cmdbyte, 1); TRACE("ps2: get command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); if (res != B_OK) cmdbyte = 0x47; - + cmdbyte |= PS2_BITS_TRANSLATE_SCANCODES | PS2_BITS_KEYBOARD_INTERRUPT | PS2_BITS_AUX_INTERRUPT; cmdbyte &= ~(PS2_BITS_KEYBOARD_DISABLED | PS2_BITS_MOUSE_DISABLED); - + res = ps2_command(PS2_CTRL_WRITE_CMD, &cmdbyte, 1, NULL, 0); TRACE("ps2: set command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); - - return res; + + return res; } @@ -172,7 +172,7 @@ res = ps2_command(0xd3, &out, 1, &in, 1); if (res) goto fail; - // Step 3, if the controller doesn't support active multiplexing, + // Step 3, if the controller doesn't support active multiplexing, // then in data does match out data (0xa4), else it's version number. if (in == out) goto no_support; @@ -189,7 +189,7 @@ *enabled = true; goto done; -no_support: +no_support: TRACE("ps2: active multiplexing not supported\n"); *enabled = false; @@ -207,7 +207,7 @@ fail: TRACE("ps2: testing for active multiplexing failed\n"); *enabled = false; - // this should revert the controller into legacy mode, + // this should revert the controller into legacy mode, // just in case it has switched to multiplexed mode return ps2_selftest(); } @@ -218,7 +218,7 @@ { status_t res; int i; - + acquire_sem(gControllerSem); atomic_add(&sIgnoreInterrupts, 1); @@ -231,7 +231,7 @@ res = ps2_wait_write(); if (res == B_OK) ps2_write_ctrl(cmd); - + for (i = 0; res == B_OK && i < outCount; i++) { res = ps2_wait_write(); if (res == B_OK) @@ -256,7 +256,7 @@ atomic_add(&sIgnoreInterrupts, -1); release_sem(gControllerSem); - + return res; } @@ -264,23 +264,23 @@ // #pragma mark - -static int32 +static int32 ps2_interrupt(void* cookie) { uint8 ctrl; uint8 data; bool error; ps2_dev *dev; - + ctrl = ps2_read_ctrl(); if (!(ctrl & PS2_STATUS_OUTPUT_BUFFER_FULL)) return B_UNHANDLED_INTERRUPT; - + if (atomic_get(&sIgnoreInterrupts)) { TRACE("ps2: ps2_interrupt ignoring, ctrl 0x%02x (%s)\n", ctrl, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb"); return B_HANDLED_INTERRUPT; } - + data = ps2_read_data(); if (ctrl & PS2_STATUS_AUX_DATA) { @@ -304,7 +304,7 @@ if (data == 88) panic("keyboard requested halt.\n"); } - + dev->history[1] = dev->history[0]; dev->history[0].time = system_time(); dev->history[0].data = data; @@ -329,7 +329,7 @@ return status; gControllerSem = create_sem(1, "ps/2 keyb ctrl"); - + ps2_flush(); status = ps2_dev_init(); @@ -344,7 +344,7 @@ NULL, 0); if (status) goto err3; - + status = install_io_interrupt_handler(INT_PS2_MOUSE, &ps2_interrupt, NULL, 0); if (status) @@ -388,7 +388,7 @@ err5: remove_io_interrupt_handler(INT_PS2_MOUSE, &ps2_interrupt, NULL); -err4: +err4: remove_io_interrupt_handler(INT_PS2_KEYBOARD, &ps2_interrupt, NULL); err3: ps2_service_exit(); From korli at users.berlios.de Thu Aug 7 14:42:20 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 14:42:20 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489ADD87.3000307@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> Message-ID: 2008/8/7 Bruno Albuquerque : > J?r?me Duval wrote: >>> I looked under Windows and that confused me a bit, I see tree devices: >>> >>> High Definition Audio Device (2 of these with same ids) >>> >>> Vendor: 0x1002 >>> Device: 0xAA01 >> >> Obviously it's an ATI hda device. > > Is this good or bad? :) In any case, what about the other devices that show? It's just you talked about a ICH9 which is quite different. ALSA seems to have an unmute patch for ATI HDMI : http://fxr.watson.org/fxr/ident?v=linux-2.6&im=bigexcerpts&i=atihdmi_init I don't yet where this would go in the hda Haiku driver though. Any ideas ? Bye, J?r?me Bye, J?r?me From bga at bug-br.org.br Thu Aug 7 14:52:23 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 07 Aug 2008 09:52:23 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> Message-ID: <489AF007.8060209@bug-br.org.br> J?r?me Duval wrote: > It's just you talked about a ICH9 which is quite different. > > ALSA seems to have an unmute patch for ATI HDMI : > http://fxr.watson.org/fxr/ident?v=linux-2.6&im=bigexcerpts&i=atihdmi_init > I don't yet where this would go in the hda Haiku driver though. Any ideas ? Actually I got more confused by Windows than I expect. here are the correct information for the cards (straight from Haiku's boot): KERN: PCI: [dom 0, bus 1] bus 1, device 0, function 1: vendor 1002, device aa18, revision 00 KERN: PCI: class_base 04, class_function 03, class_api 00 KERN: PCI: vendor 1002: ATI Technologies Inc KERN: PCI: device aa18: Unknown KERN: PCI: info: Multimedia controller (Audio device) KERN: PCI: line_size 08, latency 00, header_type 80, BIST 00 KERN: PCI: ROM base host 00000000, pci 00000000, size 00000000 KERN: PCI: cardbus_CIS 00000000, subsystem_id aa18, subsystem_vendor_id 174b KERN: PCI: interrupt_line 0a, interrupt_pin 02, min_grant 00, max_latency 00 KERN: PCI: base reg 0: host fe6fc000, pci fe6fc000, size 00004000, flags 04 KERN: PCI: base reg 1: host 00000000, pci 00000000, size 00000010, flags 0f KERN: PCI: base reg 2: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 3: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 4: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 5: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: Capabilities: PM, PCIe, MSI KERN: PCI: [dom 0, bus 2] bus 2, device 0, function 1: vendor 1002, device aa18, revision 00 KERN: PCI: class_base 04, class_function 03, class_api 00 KERN: PCI: vendor 1002: ATI Technologies Inc KERN: PCI: device aa18: Unknown KERN: PCI: info: Multimedia controller (Audio device) KERN: PCI: line_size 08, latency 00, header_type 80, BIST 00 KERN: PCI: ROM base host 00000000, pci 00000000, size 00000000 KERN: PCI: cardbus_CIS 00000000, subsystem_id aa18, subsystem_vendor_id 174b KERN: PCI: interrupt_line 0a, interrupt_pin 02, min_grant 00, max_latency 00 KERN: PCI: base reg 0: host fe7fc000, pci fe7fc000, size 00004000, flags 04 KERN: PCI: base reg 1: host 00000000, pci 00000000, size 00000010, flags 0f KERN: PCI: base reg 2: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 3: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 4: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 5: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: Capabilities: PM, PCIe, MSI KERN: PCI: [dom 0, bus 0] bus 0, device 27, function 0: vendor 8086, device 293e, revision 02 KERN: PCI: class_base 04, class_function 03, class_api 00 KERN: PCI: vendor 8086: Intel Corporation KERN: PCI: device 293e: 82801I (ICH9 Family) HD Audio Controller KERN: PCI: info: Multimedia controller (Audio device) KERN: PCI: line_size 08, latency 00, header_type 00, BIST 00 KERN: PCI: ROM base host 00000000, pci 00000000, size 00000000 KERN: PCI: cardbus_CIS 00000000, subsystem_id 8277, subsystem_vendor_id 1043 KERN: PCI: interrupt_line 03, interrupt_pin 01, min_grant 00, max_latency 00 KERN: PCI: base reg 0: host fe5f8000, pci fe5f8000, size 00004000, flags 04 KERN: PCI: base reg 1: host 00000000, pci 00000000, size 00000010, flags 0f KERN: PCI: base reg 2: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 3: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 4: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: base reg 5: host 00000000, pci 00000000, size 00000000, flags 00 KERN: PCI: Capabilities: PM, MSI, PCIe it seems my motherboard has a buil-in ATI HD chipset although it is not being used at all. There are not even audio outputs or inputs anywhere in the motherboard for it (not that I can see anyway). The ICH9 card is the SoundMax one (last listed). It is and add-in PCI-Express card and this is where my speakers are connected to. With OSS I can get audio out of it but with a *HUGE* latency. -Bruno From axeld at mail.berlios.de Thu Aug 7 15:00:42 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 15:00:42 +0200 Subject: [Haiku-commits] r26858 - in haiku/trunk/src/add-ons/kernel: bus_managers/firewire bus_managers/scsi bus_managers/usb busses/ide/silicon_image_3112 busses/scsi/ahci drivers/audio/ac97/auich drivers/audio/ac97/auvia drivers/audio/ac97/es1370 drivers/audio/ac97/ich drivers/audio/ac97/ichaudio/lala drivers/audio/echo drivers/audio/emuxki drivers/audio/hda drivers/audio/ice1712 drivers/dvb/cx23882 drivers/graphics/matrox drivers/graphics/nvidia drivers/graphics/nvidia_gpgpu drivers/network/bcm570x drivers/network/dp83815 drivers/network/ipro1000 drivers/network/ipw2100 drivers/network/rtl8169 generic/block_io generic/ide_adapter Message-ID: <200808071300.m77D0gPm003738@sheep.berlios.de> Author: axeld Date: 2008-08-07 15:00:36 +0200 (Thu, 07 Aug 2008) New Revision: 26858 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26858&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c haiku/trunk/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ichaudio/lala/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/hda/hda_controller.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/ice1712/util.c haiku/trunk/src/add-ons/kernel/drivers/dvb/cx23882/util.c haiku/trunk/src/add-ons/kernel/drivers/graphics/matrox/driver.c haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/driver.c haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia_gpgpu/driver.c haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x/b57um.c haiku/trunk/src/add-ons/kernel/drivers/network/dp83815/driver.c haiku/trunk/src/add-ons/kernel/drivers/network/dp83815/util.c haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.c haiku/trunk/src/add-ons/kernel/drivers/network/ipw2100/ipw2100.cpp haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c haiku/trunk/src/add-ons/kernel/generic/block_io/block_io.c haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c Log: * Fixed a ton of wrong usages of B_CONTIGUOUS + B_FULL_LOCK. * The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming. Defining these flags means that *every user* application can access these buffers read/write, it becomes visible in userspace like any other memory (just shared among all apps). I would like to ask each driver maintainer to see if that is really wished here. If you only need one app to be able to access it, cloning the area would be more appropriate. * I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This is almost completely useless for most usages, as it tries to align the virtual to a multiple of the size of the area. It just makes the allocation more likely to fail. Please only use where appropriate, and please review your code. * Minor cleanup. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -1,7 +1,7 @@ /* Realtek RTL8169 Family Driver * Copyright (C) 2004 Marcus Overhagen . All rights reserved. * - * Permission to use, copy, modify and distribute this software and its + * Permission to use, copy, modify and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies, and that both the * copyright notice and this permission notice appear in supporting documentation. @@ -25,31 +25,35 @@ #include "fwdebug.h" #include "util.h" + static inline uint32 round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } + area_id -alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name) +alloc_mem(void **virt, void **phy, size_t size, uint32 protection, + const char *name) { physical_entry pe; - void * virtadr; - area_id areaid; + void *virtadr; + area_id area; status_t rv; - + TRACE("allocating %ld bytes for %s\n", size, name); size = round_to_pagesize(size); - areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK | B_CONTIGUOUS, protection); - if (areaid < B_OK) { + area = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, B_CONTIGUOUS, + protection); + if (area < B_OK) { ERROR("couldn't allocate area %s\n", name); return B_ERROR; } rv = get_memory_map(virtadr, size, &pe, 1); if (rv < B_OK) { - delete_area(areaid); + delete_area(area); ERROR("couldn't get mapping for %s\n", name); return B_ERROR; } @@ -58,33 +62,40 @@ *virt = virtadr; if (phy) *phy = pe.address; - TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address); - return areaid; + TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", area, size, virtadr, + pe.address); + return area; } + area_id -map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name) +map_mem(void **virt, void *phy, size_t size, uint32 protection, + const char *name) { uint32 offset; void *phyadr; void *mapadr; area_id area; - TRACE("mapping physical address %p with %ld bytes for %s\n", phy, size, name); + TRACE("mapping physical address %p with %ld bytes for %s\n", phy, size, + name); offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (char *)phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, + protection, &mapadr); if (area < B_OK) { - ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area)); + ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, + strerror(area)); return area; } - + *virt = (char *)mapadr + offset; - TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n", - phy, *virt, offset, phyadr, mapadr, size, area); - + TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = " + "%p, size = %ld, area = 0x%08lx\n", phy, *virt, offset, phyadr, mapadr, + size, area); + return area; } Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/ccb.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -99,7 +99,7 @@ // the bus is not ready yet so the CCB cannot be initialized // correctly bus->ccb_pool = locked_pool->create(sizeof(scsi_ccb), sizeof(uint32) - 1, 0, - CCB_CHUNK_SIZE, CCB_NUM_MAX, 0, "scsi_ccb_pool", B_FULL_LOCK | B_CONTIGUOUS, + CCB_CHUNK_SIZE, CCB_NUM_MAX, 0, "scsi_ccb_pool", B_CONTIGUOUS, ccb_low_alloc_hook, ccb_low_free_hook, bus); if (bus->ccb_pool == NULL) Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/dma_buffer.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, 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. * Copyright 2002/03, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -213,8 +213,7 @@ buffer->area = create_area("DMA buffer", (void **)&dma_buffer_address_unaligned, - B_ANY_KERNEL_ADDRESS, size, - B_FULL_LOCK | B_CONTIGUOUS, 0 ); + B_ANY_KERNEL_ADDRESS, size, B_CONTIGUOUS, 0); if (buffer->area < 0) { SHOW_ERROR(2, "Cannot create contignous DMA buffer of %d bytes", (int)size); Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Copyright 2004-2008, Haiku, Inc. All RightsReserved. * Copyright 2002-2003, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -50,20 +50,20 @@ if (dma_boundary != ~0UL || ccb->data_length > max_sg_block_size) { // S/G list may not be controller-compatible: - // we have to split offending entries - SHOW_FLOW(3, "Checking violation of dma boundary 0x%x and entry size 0x%x", + // we have to split offending entries + SHOW_FLOW(3, "Checking violation of dma boundary 0x%x and entry size 0x%x", (int)dma_boundary, (int)max_sg_block_size); for (cur_idx = 0; cur_idx < num_entries; ++cur_idx) { addr_t max_len; // calculate space upto next dma boundary crossing - max_len = (dma_boundary + 1) - + max_len = (dma_boundary + 1) - ((addr_t)temp_sg[cur_idx].address & dma_boundary); // restrict size per sg item max_len = min(max_len, max_sg_block_size); - SHOW_FLOW(4, "addr=%p, size=%x, max_len=%x, idx=%d, num=%d", + SHOW_FLOW(4, "addr=%p, size=%x, max_len=%x, idx=%d, num=%d", temp_sg[cur_idx].address, (int)temp_sg[cur_idx].size, (int)max_len, (int)cur_idx, (int)num_entries); @@ -72,7 +72,7 @@ if (++num_entries > max_sg_blocks) goto too_complex; - memmove(&temp_sg[cur_idx + 1], &temp_sg[cur_idx], + memmove(&temp_sg[cur_idx + 1], &temp_sg[cur_idx], (num_entries - 1 - cur_idx) * sizeof(physical_entry)); temp_sg[cur_idx].size = max_len; @@ -84,7 +84,7 @@ ccb->sg_count = num_entries; - return true; + return true; too_complex: SHOW_ERROR( 2, "S/G list to complex for IO request (max %d entries)", @@ -147,7 +147,7 @@ { status_t res; - SHOW_FLOW(3, "ccb=%p, data=%p, data_length=%d", + SHOW_FLOW(3, "ccb=%p, data=%p, data_length=%d", ccb, ccb->data, (int)ccb->data_length); res = unlock_memory(ccb->data, ccb->data_length, B_DMA_IO @@ -170,12 +170,11 @@ int init_temp_sg(void) { - temp_sg_pool = locked_pool->create( + temp_sg_pool = locked_pool->create( MAX_TEMP_SG_FRAGMENTS * sizeof(physical_entry), sizeof(physical_entry) - 1, 0, - B_PAGE_SIZE, MAX_TEMP_SG_LISTS, 1, - "scsi_temp_sg_pool", B_FULL_LOCK | B_CONTIGUOUS, - NULL, NULL, NULL); + B_PAGE_SIZE, MAX_TEMP_SG_LISTS, 1, + "scsi_temp_sg_pool", B_CONTIGUOUS, NULL, NULL, NULL); if (temp_sg_pool == NULL) return B_NO_MEMORY; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp 2008-08-07 13:00:36 UTC (rev 26858) @@ -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: @@ -69,7 +69,7 @@ roundedSize = (roundedSize + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); fArea = create_area(fName, &fLogicalBase, B_ANY_KERNEL_ADDRESS, - roundedSize, B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); + roundedSize, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); if (fArea < B_OK) { TRACE_ERROR(("PMA: failed to create memory area\n")); return; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2008-08-07 13:00:36 UTC (rev 26858) @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Copyright 2003-2008, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -282,7 +282,7 @@ void *logAddress; size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); area_id area = create_area(name, &logAddress, B_ANY_KERNEL_ADDRESS, size, - B_FULL_LOCK | B_CONTIGUOUS, 0); + B_CONTIGUOUS, 0); if (area < B_OK) { TRACE_ERROR(("USB Stack: couldn't allocate area %s\n", name)); Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -211,7 +211,7 @@ }; device_attr attrs[] = { // properties of this controller for ide bus manager - // there are always max. 2 devices + // there are always max. 2 devices // (unless this is a Compact Flash Card with a built-in IDE controller, // which has exactly 1 device) { IDE_CONTROLLER_MAX_DEVICES_ITEM, B_UINT8_TYPE, { ui8: kASICData[asicIndex].channel_count }}, @@ -221,9 +221,9 @@ { IDE_CONTROLLER_CAN_CQ_ITEM, B_UINT8_TYPE, { ui8: true }}, // choose any name here { IDE_CONTROLLER_CONTROLLER_NAME_ITEM, B_STRING_TYPE, { string: CONTROLLER_NAME }}, - + // DMA properties - // data must be word-aligned; + // data must be word-aligned; // warning: some controllers are more picky! { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1}}, // one S/G block must not cross 64K boundary @@ -232,7 +232,7 @@ { B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, B_UINT32_TYPE, { ui32: 0x10000 }}, // see definition of MAX_SG_COUNT { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, - + // private data to find controller { "silicon_image_3112/asic_index", B_UINT32_TYPE, { ui32: asicIndex }}, { "silicon_image_3112/mmio_base", B_UINT32_TYPE, { ui32: mmioBase }}, @@ -248,7 +248,7 @@ } -static status_t +static status_t controller_init(device_node *node, void **_controllerCookie) { controller_data *controller; @@ -263,9 +263,9 @@ status_t res; uint32 temp; int i; - + TRACE("controller_init\n"); - + if (dm->get_attr_uint32(node, "silicon_image_3112/asic_index", &asicIndex, false) != B_OK) return B_ERROR; if (dm->get_attr_uint32(node, "silicon_image_3112/mmio_base", &mmioBase, false) != B_OK) @@ -277,10 +277,10 @@ if (!controller) return B_NO_MEMORY; - FLOW("controller %p\n", controller); + FLOW("controller %p\n", controller); mmioArea = map_physical_memory("Silicon Image SATA regs", - (void *)mmioBase, kASICData[asicIndex].mmio_bar_size, + (void *)mmioBase, kASICData[asicIndex].mmio_bar_size, B_ANY_KERNEL_ADDRESS, 0, (void **)&mmioAddr); if (mmioArea < B_OK) { TRACE("controller_init: mapping memory failed\n"); @@ -320,7 +320,7 @@ for (i = 0; i < kASICData[asicIndex].channel_count; i++) *(volatile uint32 *)(mmioAddr + kControllerChannelData[i].sien) = 0; *(volatile uint32 *)(mmioAddr + kControllerChannelData[0].sien); // flush - + // install interrupt handler res = install_io_interrupt_handler(interruptNumber, handle_interrupt, controller, 0); @@ -336,7 +336,7 @@ temp &= (asicIndex == ASIC_SI3114) ? (~SI_MASK_4PORT) : (~SI_MASK_2PORT); *(volatile uint32 *)(mmioAddr + SI_SYSCFG) = temp; *(volatile uint32 *)(mmioAddr + SI_SYSCFG); // flush - + *_controllerCookie = controller; TRACE("controller_init success\n"); @@ -418,9 +418,9 @@ physical_entry entry; size_t prdtSize; uint32 channelIndex; - + TRACE("channel_init enter\n"); - + channel = malloc(sizeof(channel_data)); if (!channel) return B_NO_MEMORY; @@ -445,18 +445,19 @@ TRACE("channel_index %ld\n", channelIndex); TRACE("channel name: %s\n", kControllerChannelData[channelIndex].name); - TRACE("channel %p\n", channel); + TRACE("channel %p\n", channel); parent = dm->get_parent_node(node); dm->get_driver(parent, NULL, (void **)&controller); dm->put_node(parent); - TRACE("controller %p\n", controller); + TRACE("controller %p\n", controller); TRACE("mmio_addr %p\n", (void *)controller->mmio_addr); - // PRDT must be contiguous, dword-aligned and must not cross 64K boundary + // PRDT must be contiguous, dword-aligned and must not cross 64K boundary prdtSize = (IDE_ADAPTER_MAX_SG_COUNT * sizeof(prd_entry) + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1); - channel->prd_area = create_area("prd", (void **)&channel->prdt, B_ANY_KERNEL_ADDRESS, prdtSize, B_FULL_LOCK | B_CONTIGUOUS, 0); + channel->prd_area = create_area("prd", (void **)&channel->prdt, + B_ANY_KERNEL_ADDRESS, prdtSize, B_CONTIGUOUS, 0); if (channel->prd_area < B_OK) { TRACE("creating prd_area failed\n"); goto err; @@ -543,7 +544,7 @@ int i; FLOW("task_file_write\n"); - + if (channel->lost) return B_ERROR; @@ -552,14 +553,14 @@ FLOW("%x->HI(%x)\n", tf->raw.r[i + 7], i ); channel->task_file[i] = tf->raw.r[i + 7]; } - + if (((1 << i) & mask) != 0) { FLOW("%x->LO(%x)\n", tf->raw.r[i], i ); channel->task_file[i] = tf->raw.r[i]; } } *channel->dev_ctrl; // read altstatus to flush - + return B_OK; } @@ -581,7 +582,7 @@ FLOW("%x: %x\n", i, (int)tf->raw.r[i] ); } } - + return B_OK; } @@ -600,19 +601,19 @@ } -static status_t +static status_t device_control_write(void *channelCookie, uint8 val) { channel_data *channel = channelCookie; FLOW("device_control_write 0x%x\n", val); - + if (channel->lost) return B_ERROR; *channel->dev_ctrl = val; *channel->dev_ctrl; // read altstatus to flush - + return B_OK; } @@ -635,12 +636,12 @@ } else { volatile uint32 * base = (volatile uint32 *)channel->command_block; uint32 *cur_data = (uint32 *)data; - + for ( ; count > 0; count -= 2 ) *base = *(cur_data++); } *channel->dev_ctrl; // read altstatus to flush - + return B_OK; } @@ -653,7 +654,7 @@ return B_ERROR; FLOW("pio_read force_16bit = %d, (count & 1) = %d\n", force_16bit, (count & 1)); - + // The data port is only 8 bit wide in the command register block. // We are memory mapped and read using 16 or 32 bit access from this 8 bit location. @@ -664,11 +665,11 @@ } else { volatile uint32 * base = (volatile uint32 *)channel->command_block; uint32 *cur_data = (uint32 *)data; - + for ( ; count > 0; count -= 2 ) *(cur_data++) = *base; } - + return B_OK; } @@ -745,9 +746,9 @@ *channel->bm_command_reg = command; *channel->dev_ctrl; // read altstatus to flush - + FLOW("dma_start leave\n"); - + return B_OK; } @@ -772,7 +773,7 @@ | IDE_BM_STATUS_ERROR; *channel->dev_ctrl; // read altstatus to flush - + if ((status & IDE_BM_STATUS_ERROR) != 0) { FLOW("dma_finish: failed\n"); return B_ERROR; @@ -851,7 +852,7 @@ 0, NULL }, - + .supports_device = NULL, .register_device = NULL, .init_driver = &channel_init, Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -13,24 +13,28 @@ #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) #define ERROR(a...) dprintf("\33[34mahci:\33[0m " a) + static inline uint32 round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } + area_id -alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name) +alloc_mem(void **virt, void **phy, size_t size, uint32 protection, + const char *name) { physical_entry pe; void * virtadr; area_id areaid; status_t rv; - + TRACE("allocating %ld bytes for %s\n", size, name); size = round_to_pagesize(size); - areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK | B_CONTIGUOUS, protection); + areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, + B_CONTIGUOUS, protection); if (areaid < B_OK) { ERROR("couldn't allocate area %s\n", name); return B_ERROR; @@ -49,8 +53,10 @@ return areaid; } + area_id -map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name) +map_mem(void **virt, void *phy, size_t size, uint32 protection, + const char *name) { uint32 offset; void *phyadr; @@ -62,34 +68,37 @@ offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (char *)phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, + protection, &mapadr); if (area < B_OK) { ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area)); return area; } - + *virt = (char *)mapadr + offset; TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n", phy, *virt, offset, phyadr, mapadr, size, area); - + return area; } status_t -sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data, size_t dataSize) +sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data, + size_t dataSize) { int i; for (i = 0; i < sgCount && dataSize > 0; i++) { size_t size = min_c(dataSize, sgTable[i].size); addr_t address; - if (vm_get_physical_page((addr_t)sgTable[i].address, &address, PHYSICAL_PAGE_CAN_WAIT) < B_OK) + if (vm_get_physical_page((addr_t)sgTable[i].address, &address, + PHYSICAL_PAGE_CAN_WAIT) < B_OK) return B_ERROR; TRACE("sg_memcpy phyAddr %p, addr %p, size %lu\n", sgTable[i].address, (void *)address, size); - + memcpy((void *)address, data, size); vm_put_physical_page(address); Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -4,24 +4,24 @@ * Copyright (c) 2002, Marcus Overhagen * * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * 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 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 DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -38,60 +38,72 @@ uint32 round_to_pagesize(uint32 size); -cpu_status lock(void) + +cpu_status +lock(void) { cpu_status status = disable_interrupts(); acquire_spinlock(&slock); return status; } -void unlock(cpu_status status) + +void +unlock(cpu_status status) { release_spinlock(&slock); restore_interrupts(status); } -uint32 round_to_pagesize(uint32 size) + +uint32 +round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } -area_id alloc_mem(void **phy, void **log, size_t size, const char *name) + +area_id +alloc_mem(void **phy, void **log, size_t size, const char *name) { physical_entry pe; void * logadr; - area_id areaid; + area_id area; status_t rv; - + LOG(("allocating %d bytes for %s\n",size,name)); size = round_to_pagesize(size); - areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS,size,B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); - if (areaid < B_OK) { - PRINT(("couldn't allocate area %s\n",name)); + area = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size, B_CONTIGUOUS, + B_READ_AREA | B_WRITE_AREA); + if (area < B_OK) { + PRINT(("couldn't allocate area %s\n", name)); return B_ERROR; } - rv = get_memory_map(logadr,size,&pe,1); + rv = get_memory_map(logadr, size, &pe, 1); if (rv < B_OK) { - delete_area(areaid); + delete_area(area); PRINT(("couldn't map %s\n",name)); return B_ERROR; } - memset(logadr,0,size); + memset(logadr, 0, size); if (log) *log = logadr; if (phy) *phy = pe.address; - LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address)); - return areaid; + LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr, + pe.address)); + return area; } + /* This is not the most advanced method to map physical memory for io access. * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS * makes the whole offset calculation and relocation obsolete. But the code * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. */ -area_id map_mem(void **log, void *phy, size_t size, const char *name) +area_id +map_mem(void **log, void *phy, size_t size, const char *name) { uint32 offset; void *phyadr; @@ -108,6 +120,6 @@ LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", phy, *log, offset, phyadr, mapadr, size, area)); - + return area; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -4,24 +4,24 @@ * Copyright (c) 2002, Marcus Overhagen * * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * 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 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 DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -38,35 +38,44 @@ uint32 round_to_pagesize(uint32 size); -cpu_status lock(void) + +cpu_status +lock(void) { cpu_status status = disable_interrupts(); acquire_spinlock(&slock); return status; } -void unlock(cpu_status status) + +void +unlock(cpu_status status) { release_spinlock(&slock); restore_interrupts(status); } -uint32 round_to_pagesize(uint32 size) + +uint32 +round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } -area_id alloc_mem(void **phy, void **log, size_t size, const char *name) + +area_id +alloc_mem(void **phy, void **log, size_t size, const char *name) { physical_entry pe; void * logadr; area_id areaid; status_t rv; - + LOG(("allocating %d bytes for %s\n",size,name)); size = round_to_pagesize(size); - areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS,size,B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); + areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size, + B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); if (areaid < B_OK) { PRINT(("couldn't allocate area %s\n",name)); return B_ERROR; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -4,24 +4,24 @@ * Copyright (c) 2002, Marcus Overhagen * * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * 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 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 DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -38,60 +38,72 @@ uint32 round_to_pagesize(uint32 size); -cpu_status lock(void) + +cpu_status +lock(void) { cpu_status status = disable_interrupts(); acquire_spinlock(&slock); return status; } -void unlock(cpu_status status) + +void +unlock(cpu_status status) { release_spinlock(&slock); restore_interrupts(status); } -uint32 round_to_pagesize(uint32 size) + +uint32 +round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } -area_id alloc_mem(void **phy, void **log, size_t size, const char *name) + +area_id +alloc_mem(void **phy, void **log, size_t size, const char *name) { physical_entry pe; void * logadr; area_id areaid; status_t rv; - + LOG(("allocating %d bytes for %s\n",size,name)); size = round_to_pagesize(size); - areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS,size,B_FULL_LOCK | B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); + areaid = create_area(name, &logadr, B_ANY_KERNEL_ADDRESS, size, + B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); if (areaid < B_OK) { PRINT(("couldn't allocate area %s\n",name)); return B_ERROR; } - rv = get_memory_map(logadr,size,&pe,1); + rv = get_memory_map(logadr, size, &pe, 1); if (rv < B_OK) { delete_area(areaid); - PRINT(("couldn't map %s\n",name)); + PRINT(("couldn't map %s\n", name)); return B_ERROR; } - memset(logadr,0,size); + memset(logadr, 0, size); if (log) *log = logadr; if (phy) *phy = pe.address; - LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n",areaid,size,logadr,pe.address)); + LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", areaid, size, + logadr, pe.address)); return areaid; } + /* This is not the most advanced method to map physical memory for io access. * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS * makes the whole offset calculation and relocation obsolete. But the code * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. */ -area_id map_mem(void **log, void *phy, size_t size, const char *name) +area_id +map_mem(void **log, void *phy, size_t size, const char *name) { uint32 offset; void *phyadr; @@ -103,11 +115,12 @@ offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, + B_READ_AREA | B_WRITE_AREA, &mapadr); *log = mapadr + offset; LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", phy, *log, offset, phyadr, mapadr, size, area)); - + return area; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c 2008-08-07 12:29:32 UTC (rev 26857) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c 2008-08-07 13:00:36 UTC (rev 26858) @@ -4,24 +4,24 @@ * Copyright (c) 2002, Marcus Overhagen * * All rights reserved. - * Redistribution and use in source and binary forms, with or without modification, + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * - * - Redistributions of source code must retain the above copyright notice, + * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * [... truncated: 2144 lines follow ...] From axeld at pinc-software.de Thu Aug 7 15:02:45 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 15:02:45 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26847_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/audio/hda?= In-Reply-To: Message-ID: <24028213663-BeMail@zon> "J?r?me Duval" wrote: > 2008/8/6 Axel D?rfler : > > Nope, the locking parameter is no flags field - B_CONTIGUOUS > > actually > > implies B_FULL_LOCK (otherwise it wouldn't make much sense). It > > didn't > > do any harm, though as (2 | 3) is still 3 :-) > Right. Can we check this on other drivers too and keep B_CONTIGUOUS > only then ? I did so in r26858. B_{READ|WRITE}_AREA is used alarmingly often throughout the driver code. I would like to urge everyone to have a look at their drivers. > > That's absolutely amazing! The only functional change should be the > > bus > > mastering + TCSEL. > > I'll try to see tomorrow if this makes it work on my laptop, too > > (it > > already worked on my desktop, but only in the multi_audio_test app, > > and > > it didn't sound too well, probably because my board needs TCSEL as > > well). > Indeed, this was the trick. There could be another trick with pci > express snooping activation (vendor specific). > > BTW I tested at 48khz 16bits. I'll check with default settings too. My laptop hang around the time it would load the media server (I don't have any serial output, there). Not sure if that was the cause, though. Bye, Axel. From anevilyak at gmail.com Thu Aug 7 15:03:31 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 7 Aug 2008 08:03:31 -0500 Subject: [Haiku-commits] r26853 - haiku/trunk/src/add-ons/kernel/file_systems/cdda In-Reply-To: <200808070729.m777TUSF021832@sheep.berlios.de> References: <200808070729.m777TUSF021832@sheep.berlios.de> Message-ID: On Thu, Aug 7, 2008 at 2:29 AM, axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-07 09:29:29 +0200 (Thu, 07 Aug 2008) > New Revision: 26853 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26853&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.cpp > haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h > haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp > Log: > * read_cdda_data() needs to know the last frame of the track, so that it can > cut down the buffer size on the last request. This fixes bug #2565. > * cdda_read() did report an incorrect number of bytes read. This fixes bug > #2511, and also that you couldn't copy tracks via "cp". > * cdda_read_stat() did not include the WAV header in its reported size. > Nice, thanks! Does this also fix the ls problem I mentioned? Regards, Rene From bga at bug-br.org.br Thu Aug 7 15:03:43 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 07 Aug 2008 10:03:43 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489AF007.8060209@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> Message-ID: <489AF2AF.5020301@bug-br.org.br> Bruno Albuquerque wrote: > it seems my motherboard has a buil-in ATI HD chipset although it is not > being used at all. There are not even audio outputs or inputs anywhere > in the motherboard for it (not that I can see anyway). Although this sounds a bit weird, I guess the ATI Audio Devices are actually part of my video cards (I have two ATI HD3870). -Bruno From marcusoverhagen at arcor.de Thu Aug 7 15:25:37 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 07 Aug 2008 15:25:37 +0200 Subject: [Haiku-commits] r26858 - in haiku/trunk/src/add-ons/kernel: bus_managers/firewire bus_managers/scsi bus_managers/usb busses/ide/silicon_image_3112 busses/scsi/ahci drivers/audio/ac97/auich drivers/audio/ac97/auvia drivers/audio/ac97/es1370 drivers/audio/ac97/ich drivers/audio/ac97/ichaudio/lala drivers/audio/echo drivers/audio/emuxki drivers/audio/hda drivers/audio/ice1712 drivers/dvb/cx23882 drivers/graphics/matrox drivers/graphics/nvidia drivers/graphics/nvidia_gpgpu drivers/network/bcm570x drivers/network/dp83815 drivers/network/ipro1000 drivers/network/ipw2100 drivers/network/rtl8169 generic/block_io generic/ide_adapter In-Reply-To: <200808071300.m77D0gPm003738@sheep.berlios.de> References: <200808071300.m77D0gPm003738@sheep.berlios.de> Message-ID: <489AF7D1.1070300@arcor.de> axeld at BerliOS schrieb: > haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c > haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ichaudio/lala/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ice1712/util.c > haiku/trunk/src/add-ons/kernel/drivers/dvb/cx23882/util.c > haiku/trunk/src/add-ons/kernel/drivers/network/dp83815/util.c > haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.c > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c Looks like I'm guilty for all of these. > * The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming. Thats probably because of the BeBook create_area() description: protection Is a mask that describes whether the memory can be written and read. You form the mask by adding the constants B_READ_AREA (the area can be read) and B_WRITE_AREA (it can be written). The protection you describe applies only to this area. If your area is cloned, the clone can specify a different protection. > Defining these flags means that *every user* application can access these > buffers read/write, it becomes visible in userspace like any other memory Thats bad in some cases. > (just shared among all apps). I would like to ask each driver maintainer > to see if that is really wished here. If you only need one app to be able > to access it, cloning the area would be more appropriate. Has cloning any negative impact? > * I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This > is almost completely useless for most usages, as it tries to align the > virtual to a multiple of the size of the area. It just makes the allocation I used that multiple times to get an aligment of 4k. The BeBook descripton on map_physical_memory says: spec must be either B_ANY_KERNEL_ADDRESS or B_ANY_KERNEL_BLOCK_ADDRESS. If spec is B_ANY_KERNEL_ADDRESS, the memory will begin at an arbitrary location in the kernel address space. If spec is B_ANY_KERNEL_BLOCK_ADDRESS, then the memory will be mapped into a memory location aligned on a multiple of B_PAGE_SIZE. > more likely to fail. Please only use where appropriate, and please review > your code. regards Marcus From revol at free.fr Thu Aug 7 15:27:29 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Aug 2008 15:27:29 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r26847_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/drivers/audio/hda?= In-Reply-To: <489AF007.8060209@bug-br.org.br> Message-ID: <1517393687-BeMail@laptop> > The ICH9 card is the SoundMax one (last listed). It is and add-in > PCI-Express card and this is where my speakers are connected to. With > OSS I can get audio out of it but with a *HUGE* latency. Try this: ------------ Index: src/add-ons/media/media-add-ons/opensound/ OpenSoundDeviceEngine.cpp =================================================================== --- src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp (revision 26759) +++ src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp (working copy) @@ -609,7 +609,7 @@ fprintf(stderr, "failed to retrieve driver buffer size!\n"); abinfo.bytes = 0; } - fDriverBufferSize = abinfo.bytes; + fDriverBufferSize = MAX(2048, abinfo.fragsize); raw.buffer_size = fDriverBufferSize; ------------ Fran?ois. From axeld at mail.berlios.de Thu Aug 7 16:23:44 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 16:23:44 +0200 Subject: [Haiku-commits] r26859 - haiku/trunk/src/system/kernel/fs Message-ID: <200808071423.m77ENixP010538@sheep.berlios.de> Author: axeld Date: 2008-08-07 16:23:44 +0200 (Thu, 07 Aug 2008) New Revision: 26859 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26859&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * fix_dirent() now correctly handles buffers from userland. * dir_read() now takes into account that we may have read more than one dir entry, and calls fix_dirent() for each of them. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-07 13:00:36 UTC (rev 26858) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2008-08-07 14:23:44 UTC (rev 26859) @@ -5144,10 +5144,25 @@ } -static void -fix_dirent(struct vnode *parent, struct dirent *entry, - struct io_context* ioContext) +static status_t +fix_dirent(struct vnode *parent, struct dirent *userEntry, + struct io_context* ioContext, uint32* _length) { + char buffer[sizeof(struct dirent) + B_FILE_NAME_LENGTH]; + struct dirent* entry; + + if (IS_USER_ADDRESS(userEntry)) { + unsigned short length; + entry = (struct dirent*)buffer; + if (user_memcpy(&length, &userEntry->d_reclen, sizeof(length)) != B_OK + || user_memcpy(entry, userEntry, length) != B_OK) + return B_BAD_ADDRESS; + + } else + entry = userEntry; + + *_length = entry->d_reclen; + // set d_pdev and d_pino entry->d_pdev = parent->device; entry->d_pino = parent->id; @@ -5181,7 +5196,7 @@ status_t status = get_vnode(entry->d_dev, entry->d_ino, &vnode, true, false); if (status != B_OK) - return; + return status; mutex_lock(&sVnodeCoveredByMutex); if (vnode->covered_by) { @@ -5192,6 +5207,12 @@ put_vnode(vnode); } + + // copy back from userland buffer if needed + if (entry != userEntry) + return user_memcpy(userEntry, entry, sizeof(struct dirent) - 1); + + return B_OK; } @@ -5208,9 +5229,16 @@ return error; // we need to adjust the read dirents - if (*_count > 0) { - // XXX: Currently reading only one dirent is supported. Make this a loop! - fix_dirent(vnode, buffer, ioContext); + uint32 count = *_count; + if (count > 0) { + for (uint32 i = 0; i < count; i++) { + uint32 length; + error = fix_dirent(vnode, buffer, ioContext, &length); + if (error != B_OK) + return error; + + buffer = (struct dirent*)((uint8*)buffer + length); + } } return error; From axeld at mail.berlios.de Thu Aug 7 16:25:06 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 16:25:06 +0200 Subject: [Haiku-commits] r26860 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200808071425.m77EP6CF010738@sheep.berlios.de> Author: axeld Date: 2008-08-07 16:25:06 +0200 (Thu, 07 Aug 2008) New Revision: 26860 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26860&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/dirent_test.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: * Added simple test app for readdir() to see how it fills out the dirent and the private DIR parts. Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-07 14:23:44 UTC (rev 26859) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-07 14:25:06 UTC (rev 26860) @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src tests system libroot posix ; -UsePrivateHeaders syslog_daemon ; +UsePrivateHeaders libroot syslog_daemon ; SimpleTest SyslogTest : SyslogTest.cpp syslog.cpp @@ -10,6 +10,10 @@ : clearenv.cpp ; +SimpleTest dirent_test + : dirent_test.cpp +; + SimpleTest flock_test : flock_test.cpp ; Added: haiku/trunk/src/tests/system/libroot/posix/dirent_test.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/dirent_test.cpp 2008-08-07 14:23:44 UTC (rev 26859) +++ haiku/trunk/src/tests/system/libroot/posix/dirent_test.cpp 2008-08-07 14:25:06 UTC (rev 26860) @@ -0,0 +1,29 @@ +/* + * Copyright 2008, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ + +#include +#include + +#include + + +int +main(int argc, char** argv) +{ + DIR* dir = opendir("."); + + while (true) { + dirent* dirent = readdir(dir); + if (dirent == NULL) + break; + + printf("Entry: dev %ld, ino %Ld, name \"%s\"\n", dirent->d_dev, + dirent->d_ino, dirent->d_name); + printf(" left: %u, next: %d\n", dir->entries_left, dir->next_entry); + } + + closedir(dir); + return 0; +} From axeld at mail.berlios.de Thu Aug 7 16:29:12 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 16:29:12 +0200 Subject: [Haiku-commits] r26861 - haiku/trunk/src/add-ons/kernel/file_systems/cdda Message-ID: <200808071429.m77ETC5l011001@sheep.berlios.de> Author: axeld Date: 2008-08-07 16:29:12 +0200 (Thu, 07 Aug 2008) New Revision: 26861 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26861&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp Log: * cdda_read_dir() did not correctly report the number of entries put into the dirent buffer. This fixes Rene's comment about "ls" entering an endless loop. * It also didn't access the buffer passed in correctly if it came from userland. * It now also fills in as many entries in the buffer as fit. 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-08-07 14:25:06 UTC (rev 26860) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2008-08-07 14:29:12 UTC (rev 26861) @@ -1672,11 +1672,10 @@ static status_t cdda_read_dir(fs_volume *_volume, fs_vnode *_node, void *_cookie, - struct dirent *dirent, size_t bufferSize, uint32 *_num) + struct dirent *buffer, size_t bufferSize, uint32 *_num) { Volume *volume = (Volume *)_volume->private_volume; Inode *inode = (Inode *)_node->private_node; - status_t status = 0; TRACE(("cdda_read_dir: vnode %p, cookie %p, buffer = %p, bufferSize = %ld, num = %p\n", _node, _cookie, dirent, bufferSize,_num)); @@ -1690,48 +1689,62 @@ const char *name = NULL; Inode *nextChildNode = NULL; int nextState = cookie->state; + uint32 max = *_num; + uint32 count = 0; - switch (cookie->state) { - case ITERATION_STATE_DOT: - childNode = inode; - name = "."; - nextChildNode = volume->FirstEntry(); - nextState = cookie->state + 1; + while (count < max && bufferSize > sizeof(dirent)) { + switch (cookie->state) { + case ITERATION_STATE_DOT: + childNode = inode; + name = "."; + nextChildNode = volume->FirstEntry(); + nextState = cookie->state + 1; + break; + case ITERATION_STATE_DOT_DOT: + childNode = inode; // parent of the root node is the root node + name = ".."; + nextChildNode = volume->FirstEntry(); + nextState = cookie->state + 1; + break; + default: + childNode = cookie->current; + if (childNode) { + name = childNode->Name(); + nextChildNode = childNode->Next(); + } + break; + } + + if (childNode == NULL) { + // we're at the end of the directory break; - case ITERATION_STATE_DOT_DOT: - childNode = inode; // parent of the root node is the root node - name = ".."; - nextChildNode = volume->FirstEntry(); - nextState = cookie->state + 1; + } + + struct dirent entry; + entry.d_dev = volume->FSVolume()->id; + entry.d_ino = childNode->ID(); + entry.d_reclen = strlen(name) + sizeof(struct dirent); + + if (entry.d_reclen > bufferSize) { + if (count == 0) + return ENOBUFS; + break; - default: - childNode = cookie->current; - if (childNode) { - name = childNode->Name(); - nextChildNode = childNode->Next(); - } - break; - } + } - if (!childNode) { - // we're at the end of the directory - *_num = 0; - return B_OK; - } + if (user_memcpy(buffer, &entry, sizeof(struct dirent) - 1) != B_OK + || user_strlcpy(buffer->d_name, name, bufferSize) < B_OK) + return B_BAD_ADDRESS; - dirent->d_dev = volume->FSVolume()->id; - dirent->d_ino = inode->ID(); - dirent->d_reclen = strlen(name) + sizeof(struct dirent); + buffer = (struct dirent*)((uint8*)buffer + entry.d_reclen); + bufferSize -= entry.d_reclen; + count++; - if (dirent->d_reclen > bufferSize) - return ENOBUFS; + cookie->current = nextChildNode; + cookie->state = nextState; + } - status = user_strlcpy(dirent->d_name, name, bufferSize); - if (status < B_OK) - return status; - - cookie->current = nextChildNode; - cookie->state = nextState; + *_num = count; return B_OK; } From axeld at pinc-software.de Thu Aug 7 17:11:16 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 17:11:16 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26853_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/file=5Fsystems/cdda?= In-Reply-To: Message-ID: <31739026232-BeMail@zon> "Rene Gollent" wrote: > Nice, thanks! Does this also fix the ls problem I mentioned? Nope, it didn't - that's fixed in r26861. I forgot about that comment while looking into it, thanks for the reminder :-) Bye, Axel. From anevilyak at gmail.com Thu Aug 7 17:16:05 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Thu, 7 Aug 2008 10:16:05 -0500 Subject: [Haiku-commits] r26853 - haiku/trunk/src/add-ons/kernel/file_systems/cdda In-Reply-To: <31739026232-BeMail@zon> References: <31739026232-BeMail@zon> Message-ID: On Thu, Aug 7, 2008 at 10:11 AM, Axel D?rfler wrote: > Nope, it didn't - that's fixed in r26861. I forgot about that comment > while looking into it, thanks for the reminder :-) > No problem, thanks for fixing it :) I'll test tonight and let you know how everything works now :) Regards, Rene From korli at users.berlios.de Thu Aug 7 17:44:06 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 17:44:06 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489AF007.8060209@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> Message-ID: 2008/8/7 Bruno Albuquerque : > Actually I got more confused by Windows than I expect. here are the > correct information for the cards (straight from Haiku's boot): > > KERN: PCI: [dom 0, bus 1] bus 1, device 0, function 1: vendor 1002, > device aa18, revision 00 > KERN: PCI: class_base 04, class_function 03, class_api 00 > KERN: PCI: vendor 1002: ATI Technologies Inc > KERN: PCI: device aa18: Unknown BTW do you run an old snapshot of Haiku ? this id should not list as unknown with current revisions. Bye, J?r?me From bga at mail.berlios.de Thu Aug 7 18:09:45 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Thu, 7 Aug 2008 18:09:45 +0200 Subject: [Haiku-commits] r26862 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200808071609.m77G9jOV018825@sheep.berlios.de> Author: bga Date: 2008-08-07 18:09:45 +0200 (Thu, 07 Aug 2008) New Revision: 26862 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26862&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Work in progress while trying to fix ticket #2227: - Added skeleton code for setting device mode. - Next, figure out which bits to set! Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-07 14:29:12 UTC (rev 26861) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-07 16:09:45 UTC (rev 26862) @@ -40,7 +40,6 @@ if (!(val & (1 << 30))) { // IDE controller at function 1 is configured in IDE mode (as opposed // to AHCI or RAID). So we want to handle it. - dprintf("jmicron_fixup_ahci: PATA controller in IDE mode.\n"); // TODO(bga): It seems that with recent BIOS revisions no special code @@ -60,6 +59,18 @@ // Maybe fixing this would be as simple as changing the device class to // Serial ATA Controller instead of IDE Controller (even in AHCI mode // it reports being a standard IDE controller)? + dprintf("jmicron_fixup_ahci: PATA controller in AHCI or RAID mode.\n"); + + // Read controller control register (0x40). This should contain all the + // bits we need to change. + val = pci->ReadConfig(domain, bus, device, function, 0x40, 4); + dprintf("jmicron_fixup_ahci: Register 0x40 : %0x%08lx\n", val); + + // TODO(bga): Do some bit shuffling here to set the controller to split + // mode. Right now, the write operation bellow is a no-op. + + // Write controller control register (0x40). + pci->WriteConfig(domain, bus, device, 1, 0x40, 4, val); } } From superstippi at gmx.de Thu Aug 7 18:45:33 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 18:45:33 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <1517393687-BeMail@laptop> References: <1517393687-BeMail@laptop> Message-ID: <20080807184533.2360.2@stippis2.1218126141.fake> Fran?ois Revol wrote: > > The ICH9 card is the SoundMax one (last listed). It is and add-in > > PCI-Express card and this is where my speakers are connected to. With > > OSS I can get audio out of it but with a *HUGE* latency. > > > Try this: > > ------------ > Index: src/add-ons/media/media-add-ons/opensound/ > OpenSoundDeviceEngine.cpp > =================================================================== > --- src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp > (revision 26759) > +++ src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.cpp > (working copy) > @@ -609,7 +609,7 @@ > fprintf(stderr, "failed to retrieve driver > buffer size!\n"); > abinfo.bytes = 0; > } > - fDriverBufferSize = abinfo.bytes; > + fDriverBufferSize = MAX(2048, abinfo.fragsize); > > raw.buffer_size = fDriverBufferSize; Which unfortunately breaks the concept here. The true fix is to simply decrease the original buffer size that OSS creates (above that code). There should be a define for when the driver is compiled for ZETA to show how it can be done. The purpose of using the *real* driver buffer size (the one requested above that code) is to actually block in write(). If you write to the OSS buffer when there is still space left, you won't block, and that will mess up the drift calculation. It may be that it works with your particular sound hardware, but it certainly gives audible cracks for the C-Media hardware I tested with. Are you sure you don't hear cracks this way? Best regards, -Stephan From bga at bug-br.org.br Thu Aug 7 18:48:42 2008 From: bga at bug-br.org.br (Bruno Albuquerque) Date: Thu, 07 Aug 2008 13:48:42 -0300 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> Message-ID: <489B276A.5010906@bug-br.org.br> J?r?me Duval wrote: >> KERN: PCI: [dom 0, bus 1] bus 1, device 0, function 1: vendor 1002, >> device aa18, revision 00 >> KERN: PCI: class_base 04, class_function 03, class_api 00 >> KERN: PCI: vendor 1002: ATI Technologies Inc >> KERN: PCI: device aa18: Unknown > > BTW do you run an old snapshot of Haiku ? this id should not list as > unknown with current revisions. Nah. It is just that I am not at home so I looked at an old bug that had my syslog to paste it into this email. I am using recent versions (usually the most recent version). -Bruno From superstippi at gmx.de Thu Aug 7 18:49:13 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 18:49:13 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489AF007.8060209@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> Message-ID: <20080807184913.2285.3@stippis2.1218126141.fake> Bruno Albuquerque wrote: > The ICH9 card is the SoundMax one (last listed). It is and add-in > PCI-Express card and this is where my speakers are connected to. With OSS > I can get audio out of it but with a *HUGE* latency. The latency problem is of course known. The bigger problem is that it's more likely the scheduler's fault than the OSS media nodes fault (since I can make the latency much better on ZETA). I am betting that you would have to increase the buffer size the same for the "native" HDA driver in order to get smooth audio playback. The problem seems to be that even real time threads don't wake up timely enough if a semaphore that they block on is released. I don't know enough of how OSS works though to be sure it's not a problem in the OSS code. Congratulations to J?r?me for getting the native HDA driver to work, but to tell you the thruth, I am a bit torn about the effort on the native drives. With OSS, I see a chance to ease our lifes a bit just like the FreeBSD compatibility layer did for network drivers. I would be the first to agree that the mixer controls look quite messy at the moment, but there has got to be a way to make them nice. As is so often the case unfortunately, I just turned my attention away to other stuff once I got what I wanted from OSS. Always so much to do, but maybe that just proves my point. ;-) Best regards, -Stephan From superstippi at gmx.de Thu Aug 7 18:50:52 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 18:50:52 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <489AF2AF.5020301@bug-br.org.br> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> <489AF2AF.5020301@bug-br.org.br> Message-ID: <20080807185052.2327.4@stippis2.1218126141.fake> Bruno Albuquerque wrote: > Bruno Albuquerque wrote: > > > it seems my motherboard has a buil-in ATI HD chipset although it is not > > being used at all. There are not even audio outputs or inputs anywhere > > in the motherboard for it (not that I can see anyway). > > Although this sounds a bit weird, I guess the ATI Audio Devices are > actually part of my video cards (I have two ATI HD3870). Those are needed for Blue-Ray playback. It can save the hardware some de- and encryption when the stream goes out your HDMI link including audio. Best regards, -Stephan From bga at mail.berlios.de Thu Aug 7 19:05:13 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Thu, 7 Aug 2008 19:05:13 +0200 Subject: [Haiku-commits] r26863 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200808071705.m77H5D6c031612@sheep.berlios.de> Author: bga Date: 2008-08-07 19:05:12 +0200 (Thu, 07 Aug 2008) New Revision: 26863 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26863&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Work in progress while trying to fix ticket #2227: - Ooops. Copy and paste bug. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-07 16:09:45 UTC (rev 26862) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2008-08-07 17:05:12 UTC (rev 26863) @@ -70,7 +70,7 @@ // mode. Right now, the write operation bellow is a no-op. // Write controller control register (0x40). - pci->WriteConfig(domain, bus, device, 1, 0x40, 4, val); + pci->WriteConfig(domain, bus, device, function, 0x40, 4, val); } } From korli at users.berlios.de Thu Aug 7 19:08:51 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Thu, 7 Aug 2008 19:08:51 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <20080807184913.2285.3@stippis2.1218126141.fake> References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> <20080807184913.2285.3@stippis2.1218126141.fake> Message-ID: 2008/8/7 Stephan Assmus : > Congratulations to J?r?me for getting the native HDA driver to work, but to > tell you the thruth, I am a bit torn about the effort on the native drives. > With OSS, I see a chance to ease our lifes a bit just like the FreeBSD > compatibility layer did for network drivers. I would be the first to agree To tell the truth, my audio card didn't work with OSS, a good reason to implement a native driver. I think also Linux people now keep away from OSS. Bye, J?r?me From revol at free.fr Thu Aug 7 19:20:38 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Aug 2008 19:20:38 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r26847_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/drivers/audio/hda?= In-Reply-To: Message-ID: <775637897-BeMail@laptop> > 2008/8/7 Stephan Assmus : > > Congratulations to J?r?me for getting the native HDA driver to > > work, but to > > tell you the thruth, I am a bit torn about the effort on the native > > drives. > > With OSS, I see a chance to ease our lifes a bit just like the > > FreeBSD > > compatibility layer did for network drivers. I would be the first > > to agree > > To tell the truth, my audio card didn't work with OSS, a good reason > to implement a native driver. Did you try latest build ? http://revolf.free.fr/beos/oss-beos-v4.1test-bin.zip If it appears in prefs but doesn't make sound it might be some mixer bug, moving a slider sometimes unmutes the card. > I think also Linux people now keep away from OSS. That is entirely a political decision. When OSS was closed, they started on ALSA, and let the version of OSS in the kernel tree get dusted and unmaintained. When you hear ppl complain about OSS, it's about the years old version in the kernel tree, not OSSv4, which has most if not all of what ALSA peeps complain OSS lacked which makes them use ALSA. Of course now they don't have much reasons to use OSS again (actually I heard of a distro that switched back to it), but OTH it's used on many other OSes. Fran?ois. From superstippi at gmx.de Thu Aug 7 19:27:31 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 19:27:31 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: References: <200808062004.m76K4qSp003991@sheep.berlios.de> <489A1369.8010102@bug-br.org.br> <489ACF82.9060200@bug-br.org.br> <489ADD87.3000307@bug-br.org.br> <489AF007.8060209@bug-br.org.br> <20080807184913.2285.3@stippis2.1218126141.fake> Message-ID: <20080807192731.2650.7@stippis2.1218126141.fake> J?r?me Duval wrote: > 2008/8/7 Stephan Assmus : > > Congratulations to J?r?me for getting the native HDA driver to work, > > but to tell you the thruth, I am a bit torn about the effort on the > > native drives. With OSS, I see a chance to ease our lifes a bit just > > like the FreeBSD compatibility layer did for network drivers. I would > > be the first to agree > > To tell the truth, my audio card didn't work with OSS, a good reason to > implement a native driver. Oh, ok. > I think also Linux people now keep away from OSS. Can't really comment on that, I didn't read much about this anywhere. We could of course disable every driver in OSS for which we have a better working native driver. Best regards, -Stephan From revol at free.fr Thu Aug 7 19:30:54 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Aug 2008 19:30:54 +0200 CEST Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <20080807184533.2360.2@stippis2.1218126141.fake> Message-ID: <1391145942-BeMail@laptop> > > } > > - fDriverBufferSize = abinfo.bytes; > > + fDriverBufferSize = MAX(2048, abinfo.fragsize); > > > > raw.buffer_size = fDriverBufferSize; > > Which unfortunately breaks the concept here. The true fix is to > simply > decrease the original buffer size that OSS creates (above that code). > There > should be a define for when the driver is compiled for ZETA to show > how it > can be done. > > The purpose of using the *real* driver buffer size (the one requested > above > that code) is to actually block in write(). If you write to the OSS > buffer > when there is still space left, you won't block, and that will mess > up the > drift calculation. It may be that it works with your particular sound > hardware, but it certainly gives audible cracks for the C-Media > hardware I > tested with. Are you sure you don't hear cracks this way? Hmm the buffer_size advertized is the size for *one* buffer, I don't see what prevents from blocking in write() if we get N buffers of size S. Actually sending one single buffer for the entire card buffer size is more likely to get late and discarded as a whole. Fran?ois. From revol at free.fr Thu Aug 7 19:32:03 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Aug 2008 19:32:03 +0200 CEST Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <20080807192731.2650.7@stippis2.1218126141.fake> Message-ID: <1460594893-BeMail@laptop> > > I think also Linux people now keep away from OSS. > > Can't really comment on that, I didn't read much about this anywhere. > > We could of course disable every driver in OSS for which we have a > better > working native driver. > Indeed, just give me a list of PCI IDs and I can blacklist them in OSS. Fran?ois. From axeld at mail.berlios.de Thu Aug 7 19:36:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 19:36:02 +0200 Subject: [Haiku-commits] r26864 - haiku/trunk/src/system/kernel/vm Message-ID: <200808071736.m77Ha2An018881@sheep.berlios.de> Author: axeld Date: 2008-08-07 19:36:01 +0200 (Thu, 07 Aug 2008) New Revision: 26864 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26864&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: * FlushAndRemoveAllPages() cannot call WriteModified(), as it must be called with the VMCache lock held, and WriteModified() locks itself. * Added an assertion that the lock is held when calling that method. * This fixes a KDL as soon as you would have used O_NOCACHE with a file that had already some pages read in. Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-07 17:05:12 UTC (rev 26863) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2008-08-07 17:36:01 UTC (rev 26864) @@ -796,14 +796,17 @@ } +/*! You have to call this function with the VMCache lock held. */ status_t VMCache::FlushAndRemoveAllPages() { + ASSERT_LOCKED_MUTEX(&fLock); + while (page_count > 0) { // write back modified pages - status_t error = WriteModified(); - if (error != B_OK) - return error; + status_t status = vm_page_write_modified_pages(this); + if (status != B_OK) + return status; // remove pages for (VMCachePagesTree::Iterator it = pages.GetIterator(); From axeld at mail.berlios.de Thu Aug 7 19:37:07 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 7 Aug 2008 19:37:07 +0200 Subject: [Haiku-commits] r26865 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808071737.m77Hb7Ex018960@sheep.berlios.de> Author: axeld Date: 2008-08-07 19:37:07 +0200 (Thu, 07 Aug 2008) New Revision: 26865 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26865&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp Log: * Since we're using ASSERT macros, still lock/unlock the nodes when initializing the file system. * This fixes bug #2580. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2008-08-07 17:36:01 UTC (rev 26864) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2008-08-07 17:37:07 UTC (rev 26865) @@ -1072,8 +1072,6 @@ void Transaction::AddInode(Inode* inode) { - if (GetVolume()->IsInitializing()) - return; if (fJournal == NULL) panic("Transaction is not running!"); @@ -1085,7 +1083,8 @@ } } - acquire_vnode(GetVolume()->FSVolume(), inode->ID()); + if (!GetVolume()->IsInitializing()) + acquire_vnode(GetVolume()->FSVolume(), inode->ID()); rw_lock_write_lock(&inode->fLock); fLockedInodes.Add(inode); } @@ -1096,7 +1095,8 @@ { while (Inode* inode = fLockedInodes.RemoveHead()) { rw_lock_write_unlock(&inode->fLock); - put_vnode(GetVolume()->FSVolume(), inode->ID()); + if (!GetVolume()->IsInitializing()) + put_vnode(GetVolume()->FSVolume(), inode->ID()); } } From superstippi at gmx.de Thu Aug 7 20:05:17 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 20:05:17 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <1391145942-BeMail@laptop> References: <1391145942-BeMail@laptop> Message-ID: <20080807200517.2990.8@stippis2.1218126141.fake> Fran?ois Revol wrote: > > > } > > > - fDriverBufferSize = abinfo.bytes; > > > + fDriverBufferSize = MAX(2048, abinfo.fragsize); > > > > > > raw.buffer_size = fDriverBufferSize; > > > > Which unfortunately breaks the concept here. The true fix is to simply > > decrease the original buffer size that OSS creates (above that code). > > There > > should be a define for when the driver is compiled for ZETA to show how > > it > > can be done. > > > > The purpose of using the *real* driver buffer size (the one requested > > above > > that code) is to actually block in write(). If you write to the OSS > > buffer > > when there is still space left, you won't block, and that will mess up > > the > > drift calculation. It may be that it works with your particular sound > > hardware, but it certainly gives audible cracks for the C-Media > > hardware I > > tested with. Are you sure you don't hear cracks this way? > > Hmm the buffer_size advertized is the size for *one* buffer, I don't see > what prevents from blocking in write() if we get N buffers of size S. > Actually sending one single buffer for the entire card buffer size is > more likely to get late and discarded as a whole. But that's exactly how the code worked before I started digging in. The time drift calculation was turned off, because what you propose makes it inpredictable. In the end, I did have to smooth it out some more, even with the method I introduced. Anyways, the way you have set things up also gave a horrible latency, which was not even accounted for, since you based the latency calculation on the audio buffer size, and not on the buffer size inside OSS. But then the code wrote as many audio buffers into the driver buffer until it blocked, which makes the latency really as long as the driver buffer, not the individual audio buffer. By making the driver buffer as small as possible and the audio buffer size the same, thereby blocking after writing the first buffer, the latency as well as time drift calculations start to become more reliable. During the course of trying to get it working without any clicks and/or distortions, I have tried a lof of things, like writing new data at just the right time before OSS finished playing the already written part. But the trouble was that the true playback pointer had some kind of drift of it's own, and all the sudden one would have to write two buffers at once to catch up. Letting write() block turned out to be the only way and is the recommended way in the OSS documentation anyways. But doing it like you did with a smaller audio buffer and just keeping to write() until you do block, is just incorrect, since you don't account for the additional driver buffer size anywhere else in the code, and as I said, it gives the same big latency as using a large audio buffer the same size as the driver buffer in the first place. Best regards, -Stephan From superstippi at gmx.de Thu Aug 7 20:14:10 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 07 Aug 2008 20:14:10 +0200 Subject: [Haiku-commits] r26847 - haiku/trunk/src/add-ons/kernel/drivers/audio/hda In-Reply-To: <20080807200517.2990.8@stippis2.1218126141.fake> References: <1391145942-BeMail@laptop> <20080807200517.2990.8@stippis2.1218126141.fake> Message-ID: <20080807201410.3061.9@stippis2.1218126141.fake> Stephan Assmus wrote: > > Fran?ois Revol wrote: > > > > } > > > > - fDriverBufferSize = abinfo.bytes; > > > > + fDriverBufferSize = MAX(2048, abinfo.fragsize); > > > > > > > > raw.buffer_size = fDriverBufferSize; > > > > > > Which unfortunately breaks the concept here. The true fix is to > > > simply decrease the original buffer size that OSS creates (above that > > > code). There > > > should be a define for when the driver is compiled for ZETA to show > > > how it > > > can be done. > > > > > > The purpose of using the *real* driver buffer size (the one requested > > > above > > > that code) is to actually block in write(). If you write to the OSS > > > buffer > > > when there is still space left, you won't block, and that will mess > > > up the > > > drift calculation. It may be that it works with your particular sound > > > hardware, but it certainly gives audible cracks for the C-Media > > > hardware I > > > tested with. Are you sure you don't hear cracks this way? > > > > Hmm the buffer_size advertized is the size for *one* buffer, I don't > > see what prevents from blocking in write() if we get N buffers of size > > S. Actually sending one single buffer for the entire card buffer size > > is more likely to get late and discarded as a whole. > > But that's exactly how the code worked before I started digging in. The > time drift calculation was turned off, because what you propose makes it > inpredictable. In the end, I did have to smooth it out some more, even > with the method I introduced. Anyways, the way you have set things up > also gave a horrible latency, which was not even accounted for, since you > based the latency calculation on the audio buffer size, and not on the > buffer size inside OSS. But then the code wrote as many audio buffers > into the driver buffer until it blocked, which makes the latency really > as long as the driver buffer, not the individual audio buffer. Actually, that's bogus since the already written buffers will play before writing eventually blocks. So the latency is not affected as much. But the original problem of the unstable drift calculation is still there. Also the scheduler problem remains, since the next buffer needs to be written as soon as there is another one to write. Thread wake up time jitter will give clicks when the hardware already read past valid data. Best regards, -Stephan From axeld at pinc-software.de Thu Aug 7 20:45:45 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 20:45:45 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26847_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/audio/hda?= In-Reply-To: Message-ID: <44608142624-BeMail@zon> "J?r?me Duval" wrote: > ALSA seems to have an unmute patch for ATI HDMI : > http://fxr.watson.org/fxr/ident?v=linux-2.6&im=bigexcerpts&i=atihdmi_init > > I don't yet where this would go in the hda Haiku driver though. Any > ideas ? Since this would be the first work-around/quirk, I would just call the code whereever needed, maybe in dedicated quirk functions that contain solutions for all the problems we encounter with specific chipsets. Bye, Axel. From stippi at mail.berlios.de Thu Aug 7 20:58:41 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Thu, 7 Aug 2008 20:58:41 +0200 Subject: [Haiku-commits] r26866 - haiku/trunk/src/preferences/mouse Message-ID: <200808071858.m77Iwfkn005961@sheep.berlios.de> Author: stippi Date: 2008-08-07 20:58:38 +0200 (Thu, 07 Aug 2008) New Revision: 26866 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26866&view=rev Modified: haiku/trunk/src/preferences/mouse/MouseWindow.cpp Log: Patch by Alexandro D. Almeida: * Cast the slider value to double before dividing by 1000 in order to apply a smooth speed value. Fixes #1470. Thanks! Modified: haiku/trunk/src/preferences/mouse/MouseWindow.cpp =================================================================== --- haiku/trunk/src/preferences/mouse/MouseWindow.cpp 2008-08-07 17:37:07 UTC (rev 26865) +++ haiku/trunk/src/preferences/mouse/MouseWindow.cpp 2008-08-07 18:58:38 UTC (rev 26866) @@ -161,7 +161,7 @@ int32 value; if (message->FindInt32("be:value", &value) == B_OK) { // slow = 8192, fast = 524287 - fSettings.SetMouseSpeed((int32)pow(2, value * 6 / 1000) * 8192); + fSettings.SetMouseSpeed((int32)pow(2, (double)value * 6 / 1000) * 8192); fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fRevertButton->SetEnabled(true); } From korli at mail.berlios.de Thu Aug 7 20:59:07 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 7 Aug 2008 20:59:07 +0200 Subject: [Haiku-commits] r26867 - in haiku/trunk/src/add-ons/kernel/drivers/audio: ac97/auich echo Message-ID: <200808071859.m77Ix7Da006048@sheep.berlios.de> Author: korli Date: 2008-08-07 20:59:07 +0200 (Thu, 07 Aug 2008) New Revision: 26867 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26867&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/echo/midi.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c Log: * style cleanup * avoid using read/write and block flags for mapping register memory Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-08-07 18:58:38 UTC (rev 26866) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c 2008-08-07 18:59:07 UTC (rev 26867) @@ -97,11 +97,6 @@ } -/* This is not the most advanced method to map physical memory for io access. - * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS - * makes the whole offset calculation and relocation obsolete. But the code - * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. - */ area_id map_mem(void **log, void *phy, size_t size, const char *name) { @@ -115,7 +110,7 @@ offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr); *log = mapadr + offset; LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2008-08-07 18:58:38 UTC (rev 26866) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2008-08-07 18:59:07 UTC (rev 26867) @@ -123,7 +123,7 @@ void echo_mem_delete(echo_mem *mem) { - if(mem->area > B_OK) + if (mem->area > B_OK) delete_area(mem->area); free(mem); } @@ -159,11 +159,11 @@ /* Echo stream functions */ -extern char * pStatusStrs[ECHOSTATUS_LAST]; +extern char *pStatusStrs[ECHOSTATUS_LAST]; status_t echo_stream_set_audioparms(echo_stream *stream, uint8 channels, - uint8 bitsPerSample, uint32 sample_rate, uint8 index) + uint8 bitsPerSample, uint32 sample_rate, uint8 index) { int32 i; uint8 sample_size, frame_size; @@ -177,7 +177,7 @@ if (stream->pipe >= 0) { close_params.wPipeIndex = stream->pipe; status = stream->card->pEG->CloseAudio(&close_params); - if(status!=ECHOSTATUS_OK && status!=ECHOSTATUS_CHANNEL_NOT_OPEN) { + if (status != ECHOSTATUS_OK && status != ECHOSTATUS_CHANNEL_NOT_OPEN) { PRINT(("echo_stream_set_audioparms : CloseAudio failed\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -191,7 +191,7 @@ open_params.ProcessId = NULL; status = stream->card->pEG->OpenAudio(&open_params, &stream->pipe); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : OpenAudio failed\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -199,7 +199,7 @@ //PRINT(("VerifyAudioOpen\n")); status = stream->card->pEG->VerifyAudioOpen(stream->pipe); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : VerifyAudioOpen failed\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -216,14 +216,14 @@ format_params.wDataInterleave = channels == 1 ? 1 : 2; status = stream->card->pEG->QueryAudioFormat(stream->pipe, &format_params); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad format when querying\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; } status = stream->card->pEG->SetAudioFormat(stream->pipe, &format_params); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad format when setting\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -231,7 +231,7 @@ /* XXXX : setting sample rate is global in this driver */ status = stream->card->pEG->QueryAudioSampleRate(sample_rate); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad sample rate when querying\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; @@ -239,13 +239,13 @@ /* XXXX : setting sample rate is global in this driver */ status = stream->card->pEG->SetAudioSampleRate(sample_rate); - if(status!=ECHOSTATUS_OK) { + if (status != ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : bad sample rate when setting\n")); PRINT((" status: %s \n", pStatusStrs[status])); return B_ERROR; } - if(stream->buffer) + if (stream->buffer) echo_mem_free(stream->card, stream->buffer->log_base); stream->bitsPerSample = bitsPerSample; @@ -262,21 +262,21 @@ stream->blksize = stream->bufframes * frame_size; CDaffyDuck *duck = stream->card->pEG->GetDaffyDuck(stream->pipe); - if(duck == NULL) { + if (duck == NULL) { PRINT(("echo_stream_set_audioparms : Could not get daffy duck pointer\n")); return B_ERROR; } uint32 dwNumFreeEntries = 0; - for(i=0; ibufcount; i++) { + for (i=0; ibufcount; i++) { duck->AddMapping(((uint32)stream->buffer->phy_base) + i * stream->blksize, stream->blksize, 0, TRUE, dwNumFreeEntries); } duck->Wrap(); - if(stream->card->pEG->GetAudioPositionPtr(stream->pipe, stream->position)!=ECHOSTATUS_OK) { + if (stream->card->pEG->GetAudioPositionPtr(stream->pipe, stream->position)!=ECHOSTATUS_OK) { PRINT(("echo_stream_set_audioparms : Could not get audio position ptr\n")); return B_ERROR; } @@ -287,7 +287,7 @@ status_t echo_stream_get_nth_buffer(echo_stream *stream, uint8 chan, uint8 buf, - char** buffer, size_t *stride) + char** buffer, size_t *stride) { uint8 sample_size, frame_size; LOG(("echo_stream_get_nth_buffer\n")); @@ -386,7 +386,7 @@ echo_stream_delete(echo_stream *stream) { cpu_status status; - ECHOGALS_CLOSEAUDIOPARAMETERS close_params; + ECHOGALS_CLOSEAUDIOPARAMETERS close_params; LOG(("echo_stream_delete\n")); echo_stream_halt(stream); @@ -400,7 +400,7 @@ } } - if(stream->buffer) + if (stream->buffer) echo_mem_free(stream->card, stream->buffer->log_base); status = lock(); @@ -415,16 +415,15 @@ int32 echo_int(void *arg) { - echo_dev *card = (echo_dev*)arg; - BOOL midiReceived; - ECHOSTATUS err; - - echo_stream *stream; - uint32 curblk; + echo_dev* card = (echo_dev*)arg; + BOOL midiReceived; + ECHOSTATUS err; + echo_stream* stream; + uint32 curblk; err = card->pEG->ServiceIrq(midiReceived); - if(err != ECHOSTATUS_OK) { + if (err != ECHOSTATUS_OK) { return B_UNHANDLED_INTERRUPT; } @@ -442,7 +441,7 @@ //TRACE(("echo_int stream %p at trigblk %lu at stream->trigblk %lu\n", // stream, curblk, stream->trigblk)); if (curblk == stream->trigblk) { - if(stream->inth) + if (stream->inth) stream->inth(stream->inthparam); stream->trigblk++; @@ -520,7 +519,7 @@ put_module(B_PCI_MODULE_NAME); - if(err!=B_OK) { + if (err != B_OK) { PRINT(("no card found\n")); } @@ -536,11 +535,11 @@ void *settings_handle; // get driver settings - settings_handle = load_driver_settings ("echo.settings"); + settings_handle = load_driver_settings ("echo.settings"); if (settings_handle != NULL) { - const char *item; - char *end; - uint32 value; + const char* item; + char* end; + uint32 value; item = get_driver_parameter (settings_handle, "channels", NULL, NULL); if (item) { @@ -774,7 +773,7 @@ card->pOSS = new COsSupport(card->info.device_id, card->info.revision); - if(card->pOSS == NULL) + if (card->pOSS == NULL) return B_ERROR; switch (card->type) { @@ -863,7 +862,7 @@ ECHOSTATUS status; status = card->pEG->InitHw(); - if(status != ECHOSTATUS_OK) + if (status != ECHOSTATUS_OK) return B_ERROR; card->pEG->GetCapabilities(&card->caps); @@ -911,7 +910,7 @@ remove_io_interrupt_handler(card->irq, echo_int, card); #ifdef MIDI_SUPPORT - delete_sem(card->midi.midi_ready_sem); + delete_sem(card->midi.midi_ready_sem); #endif delete card->pEG; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/midi.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/midi.cpp 2008-08-07 18:58:38 UTC (rev 26866) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/midi.cpp 2008-08-07 18:59:07 UTC (rev 26867) @@ -35,23 +35,20 @@ device_hooks midi_hooks = { - &midi_open, - &midi_close, - &midi_free, - &midi_control, - &midi_read, - &midi_write, - NULL, /* select */ - NULL, /* deselect */ - NULL, /* readv */ - NULL /* writev */ + &midi_open, + &midi_close, + &midi_free, + &midi_control, + &midi_read, + &midi_write, + NULL, /* select */ + NULL, /* deselect */ + NULL, /* readv */ + NULL /* writev */ }; static status_t -midi_open( - const char * name, - uint32 flags, - void ** cookie) +midi_open(const char* name, uint32 flags, void** cookie) { int ix; @@ -77,8 +74,7 @@ static status_t -midi_close( - void * cookie) +midi_close(void* cookie) { LOG(("midi_close()\n")); return B_OK; @@ -86,8 +82,7 @@ static status_t -midi_free( - void * cookie) +midi_free(void* cookie) { echo_dev *card = (echo_dev *) cookie; @@ -102,11 +97,7 @@ static status_t -midi_control( - void * cookie, - uint32 iop, - void * data, - size_t len) +midi_control(void* cookie, uint32 iop, void* data, size_t len) { LOG(("midi_control()\n")); @@ -115,11 +106,7 @@ static status_t -midi_read( - void * cookie, - off_t pos, - void * ptr, - size_t * nread) +midi_read(void* cookie, off_t pos, void* ptr, size_t* nread) { echo_dev *card = (echo_dev *) cookie; ECHOSTATUS err; @@ -144,18 +131,13 @@ static status_t -midi_write( - void * cookie, - off_t pos, - const void * ptr, - size_t * nwritten) +midi_write(void* cookie, off_t pos, const void* ptr, size_t* nwritten) { echo_dev *card = (echo_dev *) cookie; - ECHOSTATUS err; + ECHOSTATUS err; LOG(("midi_write()\n")); err = card->pEG->WriteMidi(*nwritten, (PBYTE)ptr, nwritten); return (err != ECHOSTATUS_OK) ? B_ERROR : B_OK; } - Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp 2008-08-07 18:58:38 UTC (rev 26866) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/multi.cpp 2008-08-07 18:59:07 UTC (rev 26867) @@ -41,14 +41,14 @@ #include "util.h" typedef enum { - B_MIX_GAIN = 1 << 0, - B_MIX_MUTE = 1 << 1, - B_MIX_NOMINAL = 1 << 2 -} mixer_type; + B_MIX_GAIN = 1 << 0, + B_MIX_MUTE = 1 << 1, + B_MIX_NOMINAL = 1 << 2 +} mixer_type; + static void echo_channel_get_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) { - echo_dev *dev = (echo_dev*) card; MIXER_MULTI_FUNCTION multi_function[2]; PMIXER_FUNCTION function = multi_function[0].MixerFunction; @@ -57,15 +57,15 @@ function[1].Channel = channel; function[1].Channel.wChannel++; switch (type) { - case B_MIX_GAIN: - function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL; - break; - case B_MIX_MUTE: - function[0].iFunction = function[1].iFunction = MXF_GET_MUTE; - break; - case B_MIX_NOMINAL: - function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL; - break; + case B_MIX_GAIN: + function[0].iFunction = function[1].iFunction = MXF_GET_LEVEL; + break; + case B_MIX_MUTE: + function[0].iFunction = function[1].iFunction = MXF_GET_MUTE; + break; + case B_MIX_NOMINAL: + function[0].iFunction = function[1].iFunction = MXF_GET_NOMINAL; + break; } multi_function[0].iCount = 2; @@ -80,23 +80,25 @@ } else { values[0] = function[0].Data.iNominal == 4 ? 1.0 : 0.0; } - PRINT(("echo_channel_get_mix iLevel: %ld, %d, %ld\n", function[0].Data.iLevel, channel.wChannel, channel.dwType)); + PRINT(("echo_channel_get_mix iLevel: %ld, %d, %ld\n", function[0].Data.iLevel, + channel.wChannel, channel.dwType)); } } + static void echo_channel_set_mix(void *card, MIXER_AUDIO_CHANNEL channel, int32 type, float *values) { echo_dev *dev = (echo_dev*) card; MIXER_MULTI_FUNCTION multi_function[2]; PMIXER_FUNCTION function = multi_function[0].MixerFunction; - INT32 size = ComputeMixerMultiFunctionSize(2); - function[0].Channel = channel; + INT32 size = ComputeMixerMultiFunctionSize(2); + function[0].Channel = channel; function[1].Channel = channel; function[1].Channel.wChannel++; if (type == B_MIX_GAIN) { function[0].Data.iLevel = (int)(values[0] * 256); - function[0].iFunction = MXF_SET_LEVEL; + function[0].iFunction = MXF_SET_LEVEL; function[1].Data.iLevel = (int)(values[1] * 256); function[1].iFunction = MXF_SET_LEVEL; } else if (type == B_MIX_MUTE) { @@ -106,35 +108,36 @@ function[1].iFunction = MXF_SET_MUTE; } else { function[0].Data.iNominal = values[0] == 1.0 ? 4 : -10; - function[0].iFunction = MXF_SET_NOMINAL; - function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10; - function[1].iFunction = MXF_SET_NOMINAL; + function[0].iFunction = MXF_SET_NOMINAL; + function[1].Data.iNominal = values[0] == 1.0 ? 4 : -10; + function[1].iFunction = MXF_SET_NOMINAL; } multi_function[0].iCount = 2; - dev->pEG->ProcessMixerMultiFunction(multi_function, size); + dev->pEG->ProcessMixerMultiFunction(multi_function, size); + + if (function[0].RtnStatus == ECHOSTATUS_OK) { + PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, + channel.wChannel, channel.dwType)); + } - if (function[0].RtnStatus == ECHOSTATUS_OK) { - PRINT(("echo_channel_set_mix OK: %ld, %d, %ld\n", function[0].Data.iLevel, channel.wChannel, channel.dwType)); - } - } static int32 echo_create_group_control(multi_dev *multi, uint32 *index, int32 parent, - enum strind_id string, const char* name) { - uint32 i = *index; - (*index)++; - multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i; - multi->controls[i].mix_control.parent = parent; - multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; - multi->controls[i].mix_control.master = MULTI_CONTROL_MASTERID; - multi->controls[i].mix_control.string = string; - if(name) - strcpy(multi->controls[i].mix_control.name, name); - - return multi->controls[i].mix_control.id; + enum strind_id string, const char* name) { + uint32 i = *index; + (*index)++; + multi->controls[i].mix_control.id = MULTI_CONTROL_FIRSTID + i; + multi->controls[i].mix_control.parent = parent; + multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; + multi->controls[i].mix_control.master = MULTI_CONTROL_MASTERID; + multi->controls[i].mix_control.string = string; + if (name) + strcpy(multi->controls[i].mix_control.name, name); + + return multi->controls[i].mix_control.id; } static void @@ -216,7 +219,7 @@ channel.wChannel = i * 2; parent2 = echo_create_group_control(multi, &index, parent, S_null, "Input"); - + echo_create_channel_control(multi, &index, parent2, 0, channel, card->caps.dwBusInCaps[i*2] & ECHOCAPS_NOMINAL_LEVEL); } @@ -232,32 +235,32 @@ int32 i; uint32 id; multi_mixer_control *control = NULL; - for(i=0; iitem_count; i++) { + for (i=0; iitem_count; i++) { id = MMVI->values[i].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_get_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; - if(control->mix_control.flags & B_MULTI_MIX_GAIN) { - if(control->get) { + if (control->mix_control.flags & B_MULTI_MIX_GAIN) { + if (control->get) { float values[2]; control->get(card, control->channel, control->type, values); - if(control->mix_control.master == MULTI_CONTROL_MASTERID) + if (control->mix_control.master == MULTI_CONTROL_MASTERID) MMVI->values[i].gain = values[0]; else MMVI->values[i].gain = values[1]; } } - if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) { + if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) { float values[1]; control->get(card, control->channel, control->type, values); MMVI->values[i].enable = (values[0] == 1.0); } - if(control->mix_control.flags & B_MULTI_MIX_MUX && control->get) { + if (control->mix_control.flags & B_MULTI_MIX_MUX && control->get) { float values[1]; control->get(card, control->channel, control->type, values); MMVI->values[i].mux = (int32)values[0]; @@ -266,61 +269,62 @@ return B_OK; } + static status_t echo_set_mix(echo_dev *card, multi_mix_value_info * MMVI) { int32 i; uint32 id; multi_mixer_control *control = NULL; - for(i=0; iitem_count; i++) { + for (i=0; iitem_count; i++) { id = MMVI->values[i].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); continue; } control = &card->multi.controls[id]; - if(control->mix_control.flags & B_MULTI_MIX_GAIN) { + if (control->mix_control.flags & B_MULTI_MIX_GAIN) { multi_mixer_control *control2 = NULL; - if(i+1item_count) { + if (i+1item_count) { id = MMVI->values[i + 1].id - MULTI_CONTROL_FIRSTID; - if(id < 0 || id >= card->multi.control_count) { + if (id < 0 || id >= card->multi.control_count) { PRINT(("echo_set_mix : invalid control id requested : %li\n", id)); } else { control2 = &card->multi.controls[id]; - if(control2->mix_control.master != control->mix_control.id) + if (control2->mix_control.master != control->mix_control.id) control2 = NULL; } } - if(control->set) { + if (control->set) { float values[2]; values[0] = 0.0; values[1] = 0.0; - if(control->mix_control.master == MULTI_CONTROL_MASTERID) + if (control->mix_control.master == MULTI_CONTROL_MASTERID) values[0] = MMVI->values[i].gain; else values[1] = MMVI->values[i].gain; - if(control2 && control2->mix_control.master != MULTI_CONTROL_MASTERID) + if (control2 && control2->mix_control.master != MULTI_CONTROL_MASTERID) values[1] = MMVI->values[i+1].gain; control->set(card, control->channel, control->type, values); } - if(control2) - i++; + if (control2) + i++; } - if(control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) { + if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) { float values[1]; values[0] = MMVI->values[i].enable ? 1.0 : 0.0; control->set(card, control->channel, control->type, values); } - if(control->mix_control.flags & B_MULTI_MIX_MUX && control->set) { + if (control->mix_control.flags & B_MULTI_MIX_MUX && control->set) { float values[1]; values[0] = (float)MMVI->values[i].mux; @@ -330,6 +334,7 @@ return B_OK; } + static status_t echo_list_mix_controls(echo_dev *card, multi_mix_control_info * MMCI) { @@ -337,12 +342,12 @@ uint32 i; MMC = MMCI->controls; - if(MMCI->control_count < 24) + if (MMCI->control_count < 24) return B_ERROR; - if(echo_create_controls_list(&card->multi) < B_OK) + if (echo_create_controls_list(&card->multi) < B_OK) return B_ERROR; - for(i=0; imulti.control_count; i++) { + for (i=0; imulti.control_count; i++) { MMC[i] = card->multi.controls[i].mix_control; } @@ -350,12 +355,14 @@ return B_OK; } + static status_t -echo_list_mix_connections(echo_dev *card, multi_mix_connection_info * data) +echo_list_mix_connections(echo_dev* card, multi_mix_connection_info* data) { return B_ERROR; } + static status_t echo_list_mix_channels(echo_dev *card, multi_mix_channel_info *data) { @@ -414,18 +421,18 @@ chans = multi->chans; index = 0; - for(mode=ECHO_USE_PLAY; mode!=-1; + for (mode=ECHO_USE_PLAY; mode!=-1; mode = (mode == ECHO_USE_PLAY) ? ECHO_USE_RECORD : -1) { LIST_FOREACH(stream, &((echo_dev*)multi->card)->streams, next) { if ((stream->use & mode) == 0) continue; - if(stream->channels == 2) + if (stream->channels == 2) designations = B_CHANNEL_STEREO_BUS; else designations = B_CHANNEL_SURROUND_BUS; - for(i=0; ichannels; i++) { + for (i=0; ichannels; i++) { chans[index].channel_id = index; chans[index].kind = (mode == ECHO_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL; chans[index].designations = designations | chan_designations[i]; @@ -434,7 +441,7 @@ } } - if(mode==ECHO_USE_PLAY) { + if (mode==ECHO_USE_PLAY) { multi->output_channel_count = index; } else { multi->input_channel_count = index - multi->output_channel_count; @@ -618,8 +625,8 @@ if (data->request_playback_channels < data->return_playback_channels) { LOG(("not enough channels\n")); } - for(i=0; ichannels; j++) + for (i=0; ichannels; j++) echo_stream_get_nth_buffer(stream, j, i, &data->playback_buffers[i][channels+j].base, &data->playback_buffers[i][channels+j].stride); @@ -638,8 +645,8 @@ if (data->request_record_channels < data->return_record_channels) { LOG(("not enough channels\n")); } - for(i=0; ichannels; j++) + for (i=0; ichannels; j++) echo_stream_get_nth_buffer(stream, j, i, &data->record_buffers[i][channels+j].base, &data->record_buffers[i][channels+j].stride); @@ -706,7 +713,7 @@ (stream->use & ECHO_USE_PLAY == 0) ? echo_record_inth : echo_play_inth, stream); } - if(acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000) + if (acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000) == B_TIMED_OUT) { LOG(("buffer_exchange timeout ff\n")); } @@ -717,7 +724,7 @@ if ((pstream->use & ECHO_USE_PLAY) == 0 || (pstream->state & ECHO_STATE_STARTED) == 0) continue; - if(pstream->update_needed) + if (pstream->update_needed) break; } @@ -725,13 +732,13 @@ if ((rstream->use & ECHO_USE_RECORD) == 0 || (rstream->state & ECHO_STATE_STARTED) == 0) continue; - if(rstream->update_needed) + if (rstream->update_needed) break; } - if(!pstream) + if (!pstream) pstream = card->pstream; - if(!rstream) + if (!rstream) rstream = card->rstream; /* do playback */ @@ -753,6 +760,7 @@ return B_OK; } + static status_t echo_buffer_force_stop(echo_dev *card) { @@ -760,6 +768,7 @@ return B_OK; } + static status_t echo_multi_control(void *cookie, uint32 op, void *data, size_t length) { @@ -773,7 +782,7 @@ } #endif - switch (op) { + switch (op) { case B_MULTI_GET_DESCRIPTION: LOG(("B_MULTI_GET_DESCRIPTION\n")); return echo_get_description(card, (multi_description *)data); @@ -841,6 +850,7 @@ return B_ERROR; } + static status_t echo_open(const char *name, uint32 flags, void** cookie); static status_t echo_close(void* cookie); static status_t echo_free(void* cookie); @@ -848,6 +858,7 @@ static status_t echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes); static status_t echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes); + device_hooks multi_hooks = { echo_open, /* -> open entry point */ echo_close, /* -> close entry point */ @@ -861,6 +872,7 @@ NULL /* scatter-gather write to the device */ }; + static status_t echo_open(const char *name, uint32 flags, void** cookie) { @@ -884,7 +896,7 @@ } #endif - if(card == NULL) { + if (card == NULL) { LOG(("open() card not found %s\n", name)); #ifdef CARDBUS LIST_FOREACH(card, &devices, next) { @@ -963,6 +975,7 @@ return B_OK; } + static status_t echo_close(void* cookie) { @@ -975,6 +988,7 @@ return B_OK; } + static status_t echo_free(void* cookie) { @@ -999,12 +1013,14 @@ return B_OK; } + static status_t echo_control(void* cookie, uint32 op, void* arg, size_t len) { return echo_multi_control(cookie, op, arg, len); } + static status_t echo_read(void* cookie, off_t position, void *buf, size_t* num_bytes) { @@ -1012,10 +1028,10 @@ return B_IO_ERROR; } + static status_t echo_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes) { *num_bytes = 0; /* tell caller nothing was written */ return B_IO_ERROR; } - Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c 2008-08-07 18:58:38 UTC (rev 26866) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c 2008-08-07 18:59:07 UTC (rev 26867) @@ -93,15 +93,10 @@ *phy = pe.address; LOG(("area = %d, size = %d, log = %#08X, phy = %#08X\n", area, size, logadr, pe.address)); - return areaid; + return area; } -/* This is not the most advanced method to map physical memory for io access. - * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS - * makes the whole offset calculation and relocation obsolete. But the code - * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. - */ area_id map_mem(void **log, void *phy, size_t size, const char *name) { @@ -115,7 +110,7 @@ offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (void*)((uint32)phy - offset); size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, 0, &mapadr); *log = (void*) ((uint32)mapadr + offset); LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", From stippi at mail.berlios.de Thu Aug 7 21:03:09 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Thu, 7 Aug 2008 21:03:09 +0200 Subject: [Haiku-commits] r26868 - haiku/trunk/src/preferences/mouse Message-ID: <200808071903.m77J39d6006528@sheep.berlios.de> Author: stippi Date: 2008-08-07 21:03:06 +0200 (Thu, 07 Aug 2008) New Revision: 26868 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26868&view=rev Modified: haiku/trunk/src/preferences/mouse/MouseWindow.cpp haiku/trunk/src/preferences/mouse/SettingsView.cpp Log: * Apply the same trick to the acceleration value, too. * When reading the settings, get smoother values also. Modified: haiku/trunk/src/preferences/mouse/MouseWindow.cpp =================================================================== --- haiku/trunk/src/preferences/mouse/MouseWindow.cpp 2008-08-07 18:59:07 UTC (rev 26867) +++ haiku/trunk/src/preferences/mouse/MouseWindow.cpp 2008-08-07 19:03:06 UTC (rev 26868) @@ -161,7 +161,8 @@ int32 value; if (message->FindInt32("be:value", &value) == B_OK) { // slow = 8192, fast = 524287 - fSettings.SetMouseSpeed((int32)pow(2, (double)value * 6 / 1000) * 8192); + fSettings.SetMouseSpeed((int32)pow(2, + value * 6.0 / 1000) * 8192); fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fRevertButton->SetEnabled(true); } @@ -173,7 +174,8 @@ int32 value; if (message->FindInt32("be:value", &value) == B_OK) { // slow = 0, fast = 262144 - fSettings.SetAccelerationFactor((int32)pow(value * 4 / 1000, 2) * 16384); + fSettings.SetAccelerationFactor((int32)pow( + value * 4.0 / 1000, 2) * 16384); fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fRevertButton->SetEnabled(true); } Modified: haiku/trunk/src/preferences/mouse/SettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/mouse/SettingsView.cpp 2008-08-07 18:59:07 UTC (rev 26867) +++ haiku/trunk/src/preferences/mouse/SettingsView.cpp 2008-08-07 19:03:06 UTC (rev 26868) @@ -283,11 +283,11 @@ // slow = 1000000, fast = 0 fClickSpeedSlider->SetValue(value); - value = int32((log(fSettings.MouseSpeed() / 8192) / log(2)) * 1000 / 6); + value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6); // slow = 8192, fast = 524287 fMouseSpeedSlider->SetValue(value); - value = int32(sqrt(fSettings.AccelerationFactor() / 16384) * 1000 / 4); + value = int32(sqrt(fSettings.AccelerationFactor() / 16384.0) * 1000 / 4); // slow = 0, fast = 262144 fAccelerationSlider->SetValue(value); From axeld at pinc-software.de Thu Aug 7 21:19:18 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 07 Aug 2008 21:19:18 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26858_-_in_haiku/trunk/src/add-ons/ker?= =?utf-8?q?nel=3A_bus=5Fmanagers/firewire__bus=5Fmanagers/scsi_bus=5Fmanag?= =?utf-8?q?ers/usb_busses/ide/silicon=5Fimage=5F3112__busses/scsi/ahci_dri?= =?utf-8?q?vers/audio/ac97/auich_drivers/audio/ac97/auvia_drivers/audio/ac?= =?utf-8?q?97/es1370_drivers/audio/ac97/ich_drivers/audio/ac97/ichaudio/la?= =?utf-8?q?la__drivers/audio/echo_drivers/audio/emuxki_drivers/audio/hda_d?= =?utf-8?q?rivers/audio/ice1712_drivers/dvb/cx23882_drivers/graphics/matro?= =?utf-8?q?x_drivers/graphics/nvidia__drivers/graphics/nvidia=5Fgpgpu_driv?= =?utf-8?q?ers/network/bcm570x_drivers/network/dp83815_drivers/network/ipr?= =?utf-8?q?o1000_drivers/network/ipw2100_drivers/network/rtl8169_generic/b?= =?utf-8?q?lock=5Fio_generic/ide=5Fadapter?= In-Reply-To: <489AF7D1.1070300@arcor.de> Message-ID: <46621678902-BeMail@zon> Marcus Overhagen wrote: > axeld at BerliOS schrieb: [...] > > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c > Looks like I'm guilty for all of these. Well, at least you layed the groundwork and wrote often copied code :-) > > * The use of B_{READ|WRITE}_AREA throughout the drivers is surely > > alarming. > Thats probably because of the BeBook create_area() description: > > protection > Is a mask that describes whether the memory can be written and > read. You form the mask by adding the constants B_READ_AREA > (the > area can be read) and B_WRITE_AREA (it can be written). The > protection you describe applies only to this area. If your area > is > cloned, the clone can specify a different protection. I know that the BeBook is quite unprecise there (and other places). It's not that I didn't make this mistake either in my driver code :-) > > Defining these flags means that *every user* application can > > access these > > buffers read/write, it becomes visible in userspace like any > > other memory > Thats bad in some cases. That's why I didn't just change it; it might actually be the wanted behaviour at times. > > (just shared among all apps). I would like to ask each driver > > maintainer > > to see if that is really wished here. If you only need one app to > > be able > > to access it, cloning the area would be more appropriate. > Has cloning any negative impact? Besides the additional creation overhead, the only disadvantage are the local TLBs; the CPU is likely to rebuild the TLB; SMP could help here a tiny bit, but not with our scheduler. That's why it might be a good idea to keep the ring buffers of audio drivers writable instead - it doesn't really hurt when an applications accidently overwrites that memory either (unlike register mappings, for example). > > * I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of > > times. This > > is almost completely useless for most usages, as it tries to > > align the > > virtual to a multiple of the size of the area. It just makes the > > allocation > I used that multiple times to get an aligment of 4k. The BeBook > descripton on map_physical_memory says: > > spec > must be either B_ANY_KERNEL_ADDRESS or > B_ANY_KERNEL_BLOCK_ADDRESS. > If spec is B_ANY_KERNEL_ADDRESS, the memory will begin at an > arbitrary location in the kernel address space. If spec is > B_ANY_KERNEL_BLOCK_ADDRESS, then the memory will be mapped into > a > memory location aligned on a multiple of B_PAGE_SIZE. In BeOS/Haiku all areas are always B_PAGE_SIZE aligned. The B_ANY_KERNEL_BLOCK_ADDRESS description is really pretty much useless, even though it's indeed a multiple of B_PAGE_SIZE :-) I only found out about what it does exactly by trying in BeOS. Bye, Axel. From revol at free.fr Thu Aug 7 22:14:38 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 07 Aug 2008 22:14:38 +0200 CEST Subject: [Haiku-commits] r26858 - in haiku/trunk/src/add-ons/kernel: bus_managers/firewire bus_managers/scsi bus_managers/usb busses/ide/silicon_image_3112 busses/scsi/ahci drivers/audio/ac97/auich drivers/audio/ac97/auvia drivers/audio/ac97/es1370 drivers/audio/ac97/ich drivers/audio/ac97/ichaudio/lala drivers/audio/echo drivers/audio/emuxki drivers/audio/hda drivers/audio/ice1712 drivers/dvb/cx23882 drivers/graphics/matrox drivers/graphics/nvidia drivers/graphics/nvidia_gpgpu drivers/network/bcm570x drivers/network/dp83815 drivers/network/ipro1000 drivers/network/ipw2100 drivers/network/rtl8169 generic/block_io generic/ide_adapter In-Reply-To: <46621678902-BeMail@zon> Message-ID: <1197959906-BeMail@laptop> > I know that the BeBook is quite unprecise there (and other places). > It's not that I didn't make this mistake either in my driver code :-) So for kernel rw areas we should use 0 ? Indeed that's not what I understood (and I'm not sure it's what BeOS does either...) > In BeOS/Haiku all areas are always B_PAGE_SIZE aligned. The > B_ANY_KERNEL_BLOCK_ADDRESS description is really pretty much useless, > even though it's indeed a multiple of B_PAGE_SIZE :-) > I only found out about what it does exactly by trying in BeOS. Right, I was misled more than once on that too. Fran?ois. From stippi at mail.berlios.de Thu Aug 7 23:37:35 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Thu, 7 Aug 2008 23:37:35 +0200 Subject: [Haiku-commits] r26869 - haiku/trunk/src/apps/text_search Message-ID: <200808072137.m77LbZQ2020024@sheep.berlios.de> Author: stippi Date: 2008-08-07 23:37:32 +0200 (Thu, 07 Aug 2008) New Revision: 26869 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26869&view=rev Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp Log: * Turn the debug output for node monitoring optional tracing. * Output something if the node monitor message does not contain the expected fields (Haiku node monitoring is soo much easier...) Modified: haiku/trunk/src/apps/text_search/GrepWindow.cpp =================================================================== --- haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-07 19:03:06 UTC (rev 26868) +++ haiku/trunk/src/apps/text_search/GrepWindow.cpp 2008-08-07 21:37:32 UTC (rev 26869) @@ -50,7 +50,14 @@ static const bigtime_t kChangesPulseInterval = 500000; +#define TRACE_NODE_MONITORING +#ifdef TRACE_NODE_MONITORING +# define TRACE_NM(x...) printf(x) +#else +# define TRACE_NM(x...) +#endif + GrepWindow::GrepWindow(BMessage* message) : BWindow(BRect(0, 0, 1, 1), NULL, B_DOCUMENT_WINDOW, 0), fSearchText(NULL), @@ -691,7 +698,7 @@ // watch the top level folder BPath path(&fModel->fDirectory); if (path.InitCheck() == B_OK) { -//printf("start monitoring root folder: %s\n", path.Path()); + TRACE_NM("start monitoring root folder: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags, messenger); } @@ -703,13 +710,13 @@ if (entry.IsDirectory()) { // subfolder if (iterator.FollowSubdir(entry)) { -//printf("start monitoring folder: %s\n", path.Path()); + TRACE_NM("start monitoring folder: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), dirFlags | B_WATCH_RECURSIVELY, messenger); } } else { // regular file -//printf("start monitoring file: %s\n", path.Path()); + TRACE_NM("start monitoring file: %s\n", path.Path()); BPrivate::BPathMonitor::StartWatching(path.Path(), fileFlags, messenger); } @@ -850,6 +857,8 @@ case B_ENTRY_CREATED: case B_ENTRY_REMOVED: { + TRACE_NM("%s\n", opCode == B_ENTRY_CREATED ? "B_ENTRY_CREATED" + : "B_ENTRY_REMOVED"); const char* name; BString path; if (message->FindString("path", &path) == B_OK @@ -859,25 +868,40 @@ fChangesIterator->EntryAdded(path.String()); else fChangesIterator->EntryRemoved(path.String()); + } else { + #ifdef TRACE_NODE_MONITORING + printf("B_ENTRY_CREATED/REMOVED - incompatible message:\n"); + message->PrintToStream(); + #endif } break; } case B_ENTRY_MOVED: -printf("B_ENTRY_MOVED\n"); -message->PrintToStream(); + #ifdef TRACE_NODE_MONITORING + printf("B_ENTRY_MOVED\n"); + message->PrintToStream(); + #endif // TODO: If the path is now outside the folder hierarchy, it's just // a "removed" entry. If the move happened within the hierarchy, // it should be a combined removed/added event. break; case B_STAT_CHANGED: { + TRACE_NM("B_STAT_CHANGED\n"); BString path; if (message->FindString("path", &path) == B_OK) fChangesIterator->EntryChanged(path.String()); + else { + #ifdef TRACE_NODE_MONITORING + printf("incompatible message:\n"); + message->PrintToStream(); + #endif + } break; } default: + TRACE_NM("unkown op code\n"); break; } From stippi at mail.berlios.de Thu Aug 7 23:42:04 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Thu, 7 Aug 2008 23:42:04 +0200 Subject: [Haiku-commits] r26870 - haiku/trunk/src/kits/app Message-ID: <200808072142.m77Lg430020532@sheep.berlios.de> Author: stippi Date: 2008-08-07 23:42:02 +0200 (Thu, 07 Aug 2008) New Revision: 26870 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26870&view=rev Modified: haiku/trunk/src/kits/app/Looper.cpp Log: The previous loop to remove all the BHandlers in the destructor was really quite inefficient. And while it did check if the handler was not NULL, it would have resulted in an endless loop if it was. I think we can safely assume we have no NULL BHandlers in that list though. Modified: haiku/trunk/src/kits/app/Looper.cpp =================================================================== --- haiku/trunk/src/kits/app/Looper.cpp 2008-08-07 21:37:32 UTC (rev 26869) +++ haiku/trunk/src/kits/app/Looper.cpp 2008-08-07 21:42:02 UTC (rev 26870) @@ -153,12 +153,13 @@ RemoveHandler(this); // Remove all the "child" handlers - BHandler* child; - while (CountHandlers()) { - child = HandlerAt(0); - if (child) - RemoveHandler(child); + int32 count = fHandlers.CountItems(); + for (int32 i = 0; i < count; i++) { + BHandler* handler = (BHandler*)fHandlers.ItemAtFast(i); + handler->SetNextHandler(NULL); + handler->SetLooper(NULL); } + fHandlers.MakeEmpty(); Unlock(); gLooperList.RemoveLooper(this); From axeld at pinc-software.de Fri Aug 8 00:07:19 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 08 Aug 2008 00:07:19 +0200 CEST Subject: [Haiku-commits] r26858 - in haiku/trunk/src/add-ons/kernel: bus_managers/firewire bus_managers/scsi bus_managers/usb busses/ide/silicon_image_3112 busses/scsi/ahci drivers/audio/ac97/auich drivers/audio/ac97/auvia drivers/audio/ac97/es1370 drivers/audio/ac97/ich drivers/audio/ac97/ichaudio/lala drivers/audio/echo drivers/audio/emuxki drivers/audio/hda drivers/audio/ice1712 drivers/dvb/cx23882 drivers/graphics/matrox drivers/graphics/nvidia drivers/graphics/nvidia_gpgpu drivers/network/bcm570x drivers/network/dp83815 drivers/network/ipro1000 drivers/network/ipw2100 drivers/network/rtl8169 generic/block_io generic/ide_adapter In-Reply-To: <1197959906-BeMail@laptop> Message-ID: <56702897844-BeMail@zon> "Fran?ois Revol" wrote: > > I know that the BeBook is quite unprecise there (and other places). > > It's not that I didn't make this mistake either in my driver code : > > -) > So for kernel rw areas we should use 0 ? > Indeed that's not what I understood (and I'm not sure it's what BeOS > does either...) It's exactly what BeOS does, but feel free to test it :-) I've added the B_KERNEL_READ_AREA and B_KERNEL_WRITE_AREA flags to make this more expressive (you can now also create read-only areas in the kernel which is not possible in BeOS). Bye, Axel. From bonefish at mail.berlios.de Fri Aug 8 03:00:15 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 8 Aug 2008 03:00:15 +0200 Subject: [Haiku-commits] r26871 - in haiku/trunk: headers/posix/sys headers/private/kernel headers/private/system src/system/kernel/vm src/system/libroot/posix/sys Message-ID: <200808080100.m7810FYa027899@sheep.berlios.de> Author: bonefish Date: 2008-08-08 03:00:06 +0200 (Fri, 08 Aug 2008) New Revision: 26871 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26871&view=rev Modified: haiku/trunk/headers/posix/sys/mman.h haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/headers/private/system/syscalls.h haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/libroot/posix/sys/mman.cpp Log: * Implemented mprotect(). A vm_area does now have an optional array specifying the protection of each page (4 bits per page). * Added no-op implementation of posix_madvise(). * Replaced a few "addr_t size" parameters by "size_t size". Modified: haiku/trunk/headers/posix/sys/mman.h =================================================================== --- haiku/trunk/headers/posix/sys/mman.h 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/headers/posix/sys/mman.h 2008-08-08 01:00:06 UTC (rev 26871) @@ -9,7 +9,8 @@ #include -/* memory protection for mmap() and others */ +/* memory protection for mmap() and others; assignment compatible with + B_{READ,WRITE,EXECUTE}_AREA */ #define PROT_READ 0x01 #define PROT_WRITE 0x02 #define PROT_EXEC 0x04 @@ -30,15 +31,25 @@ #define MS_SYNC 0x02 #define MS_INVALIDATE 0x04 +/* posix_madvise() values */ +#define POSIX_MADV_NORMAL 1 +#define POSIX_MADV_SEQUENTIAL 2 +#define POSIX_MADV_RANDOM 3 +#define POSIX_MADV_WILLNEED 4 +#define POSIX_MADV_DONTNEED 5 + __BEGIN_DECLS void* mmap(void* address, size_t length, int protection, int flags, int fd, off_t offset); int munmap(void* address, size_t length); +int mprotect(void* address, size_t length, int protection); int msync(void* address, size_t length, int flags); +int posix_madvise(void* address, size_t length, int advice); + int shm_open(const char* name, int openMode, mode_t permissions); int shm_unlink(const char* name); Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/headers/private/kernel/vm.h 2008-08-08 01:00:06 UTC (rev 26871) @@ -93,10 +93,15 @@ area_id _user_create_area(const char *name, void **address, uint32 addressSpec, size_t size, uint32 lock, uint32 protection); status_t _user_delete_area(area_id area); + area_id _user_map_file(const char *uname, void **uaddress, int addressSpec, - addr_t size, int protection, int mapping, int fd, off_t offset); -status_t _user_unmap_memory(void *address, addr_t size); -status_t _user_sync_memory(void *address, addr_t size, int flags); + size_t size, int protection, int mapping, int fd, off_t offset); +status_t _user_unmap_memory(void *address, size_t size); +status_t _user_set_memory_protection(void* address, size_t size, + int protection); +status_t _user_sync_memory(void *address, size_t size, int flags); +status_t _user_memory_advice(void* address, size_t size, int advice); + area_id _user_area_for(void *address); area_id _user_find_area(const char *name); status_t _user_get_area_info(area_id area, area_info *info); Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/headers/private/kernel/vm_types.h 2008-08-08 01:00:06 UTC (rev 26871) @@ -301,6 +301,7 @@ off_t cache_offset; uint32 cache_type; vm_area_mappings mappings; + uint8 *page_protections; struct vm_address_space *address_space; struct vm_area *address_space_next; Modified: haiku/trunk/headers/private/system/syscalls.h =================================================================== --- haiku/trunk/headers/private/system/syscalls.h 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/headers/private/system/syscalls.h 2008-08-08 01:00:06 UTC (rev 26871) @@ -327,10 +327,14 @@ addr_t size); extern area_id _kern_map_file(const char *name, void **address, - int addressSpec, addr_t size, int protection, + int addressSpec, size_t size, int protection, int mapping, int fd, off_t offset); -extern status_t _kern_unmap_memory(void *address, addr_t size); -extern status_t _kern_sync_memory(void *address, addr_t size, int flags); +extern status_t _kern_unmap_memory(void *address, size_t size); +extern status_t _kern_set_memory_protection(void *address, size_t size, + int protection); +extern status_t _kern_sync_memory(void *address, size_t size, int flags); +extern status_t _kern_memory_advice(void *address, size_t size, + int advice); /* kernel port functions */ extern port_id _kern_create_port(int32 queue_length, const char *name); Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-08 01:00:06 UTC (rev 26871) @@ -878,6 +878,7 @@ area->cache_next = area->cache_prev = NULL; area->hash_next = NULL; new (&area->mappings) vm_area_mappings; + area->page_protections = NULL; return area; } @@ -1226,6 +1227,37 @@ } +static inline void +set_area_page_protection(vm_area* area, addr_t pageAddress, uint32 protection) +{ + protection &= B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA; + uint32 pageIndex = (pageAddress - area->base) / B_PAGE_SIZE; + uint8& entry = area->page_protections[pageIndex / 2]; + if (pageIndex % 2 == 0) + entry = entry & 0xf0 | protection; + else + entry = entry & 0x0f | (protection << 4); +} + + +static inline uint32 +get_area_page_protection(vm_area* area, addr_t pageAddress) +{ + if (area->page_protections == NULL) + return area->protection; + + uint32 pageIndex = (pageAddress - area->base) / B_PAGE_SIZE; + uint32 protection = area->page_protections[pageIndex / 2]; + if (pageIndex % 2 == 0) + protection &= 0x0f; + else + protection >>= 4; + + return protection | B_KERNEL_READ_AREA + | (protection & B_WRITE_AREA ? B_KERNEL_WRITE_AREA : 0); +} + + /*! Cuts a piece out of an area. If the given cut range covers the complete area, it is deleted. If it covers the beginning or the end, the area is resized accordingly. If the range covers some part in the middle of the @@ -2340,6 +2372,7 @@ area->cache->RemoveArea(area); area->cache->ReleaseRef(); + free(area->page_protections); free(area->name); free(area); } @@ -4603,11 +4636,13 @@ } // check permissions - if (isUser && (area->protection & B_USER_PROTECTION) == 0) { + uint32 protection = get_area_page_protection(area, address); + if (isUser && (protection & B_USER_PROTECTION) == 0) { dprintf("user access on kernel area 0x%lx at %p\n", area->id, (void *)originalAddress); return B_PERMISSION_DENIED; } - if (isWrite && (area->protection & (B_WRITE_AREA | (isUser ? 0 : B_KERNEL_WRITE_AREA))) == 0) { + if (isWrite && (protection + & (B_WRITE_AREA | (isUser ? 0 : B_KERNEL_WRITE_AREA))) == 0) { dprintf("write access attempted on read-only area 0x%lx at %p\n", area->id, (void *)originalAddress); return B_PERMISSION_DENIED; @@ -4678,7 +4713,7 @@ // If the page doesn't reside in the area's cache, we need to make sure it's // mapped in read-only, so that we cannot overwrite someone else's data (copy-on-write) - uint32 newProtection = area->protection; + uint32 newProtection = protection; if (page->cache != topCache && !isWrite) newProtection &= ~(B_WRITE_AREA | B_KERNEL_WRITE_AREA); @@ -5797,7 +5832,7 @@ area_id _user_map_file(const char *userName, void **userAddress, int addressSpec, - addr_t size, int protection, int mapping, int fd, off_t offset) + size_t size, int protection, int mapping, int fd, off_t offset) { char name[B_OS_NAME_LENGTH]; void *address; @@ -5834,7 +5869,7 @@ status_t -_user_unmap_memory(void *_address, addr_t size) +_user_unmap_memory(void *_address, size_t size) { addr_t address = (addr_t)_address; @@ -5857,11 +5892,146 @@ status_t -_user_sync_memory(void *_address, addr_t size, int flags) +_user_set_memory_protection(void* _address, size_t size, int protection) { + // check address range addr_t address = (addr_t)_address; size = PAGE_ALIGN(size); + if ((address % B_PAGE_SIZE) != 0) + return B_BAD_VALUE; + if ((addr_t)address + size < (addr_t)address || !IS_USER_ADDRESS(address) + || !IS_USER_ADDRESS((addr_t)address + size)) { + // weird error code required by POSIX + return ENOMEM; + } + + // extend and check protection + protection &= B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA; + uint32 actualProtection = protection | B_KERNEL_READ_AREA + | (protection & B_WRITE_AREA ? B_KERNEL_WRITE_AREA : 0); + + if (!arch_vm_supports_protection(actualProtection)) + return B_NOT_SUPPORTED; + + // We need to write lock the address space, since we're going to play with + // the areas. + AddressSpaceWriteLocker locker; + status_t status = locker.SetTo(team_get_current_team_id()); + if (status != B_OK) + return status; + + // First round: Check whether the whole range is covered by areas and we are + // allowed to modify them. + addr_t currentAddress = address; + size_t sizeLeft = size; + while (sizeLeft > 0) { + vm_area* area = vm_area_lookup(locker.AddressSpace(), currentAddress); + if (area == NULL) + return B_NO_MEMORY; + + if ((area->protection & B_KERNEL_AREA) != 0) + return B_NOT_ALLOWED; + + // TODO: For (shared) mapped files we should check whether the new + // protections are compatible with the file permissions. We don't have + // a way to do that yet, though. + + addr_t offset = currentAddress - area->base; + size_t rangeSize = min_c(area->size - offset, sizeLeft); + + currentAddress += rangeSize; + sizeLeft -= rangeSize; + } + + // Second round: If the protections differ from that of the area, create a + // page protection array and re-map mapped pages. + vm_translation_map* map = &locker.AddressSpace()->translation_map; + currentAddress = address; + sizeLeft = size; + while (sizeLeft > 0) { + vm_area* area = vm_area_lookup(locker.AddressSpace(), currentAddress); + if (area == NULL) + return B_NO_MEMORY; + + addr_t offset = currentAddress - area->base; + size_t rangeSize = min_c(area->size - offset, sizeLeft); + + currentAddress += rangeSize; + sizeLeft -= rangeSize; + + if (area->page_protections == NULL) { + if (area->protection == actualProtection) + continue; + + // In the page protections we store only the three user protections, + // so we use 4 bits per page. + uint32 bytes = (area->size / B_PAGE_SIZE + 1) / 2; + area->page_protections = (uint8*)malloc(bytes); + if (area->page_protections == NULL) + return B_NO_MEMORY; + + // init the page protections for all pages to that of the area + uint32 areaProtection = area->protection + & (B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA); + memset(area->page_protections, + areaProtection | (areaProtection << 4), bytes); + } + + for (addr_t pageAddress = area->base + offset; + pageAddress < currentAddress; pageAddress += B_PAGE_SIZE) { + map->ops->lock(map); + + set_area_page_protection(area, pageAddress, protection); + + addr_t physicalAddress; + uint32 flags; + + status_t error = map->ops->query(map, pageAddress, &physicalAddress, + &flags); + if (error != B_OK || (flags & PAGE_PRESENT) == 0) { + map->ops->unlock(map); + continue; + } + + vm_page *page = vm_lookup_page(physicalAddress / B_PAGE_SIZE); + if (page == NULL) { + panic("area %p looking up page failed for pa 0x%lx\n", area, + physicalAddress); + map->ops->unlock(map); + return B_ERROR;; + } + + // If the page is not in the topmost cache and write access is + // requested, we have to unmap it. Otherwise we can re-map it with + // the new protection. + bool unmapPage = page->cache != area->cache + && (protection & B_WRITE_AREA) != 0; + + if (!unmapPage) { + map->ops->unmap(map, pageAddress, + pageAddress + B_PAGE_SIZE - 1); + map->ops->map(map, pageAddress, physicalAddress, + actualProtection); + } + + map->ops->unlock(map); + + if (unmapPage) + vm_unmap_pages(area, pageAddress, B_PAGE_SIZE, true); + } + } + + return B_OK; +} + + +status_t +_user_sync_memory(void *_address, size_t size, int flags) +{ + addr_t address = (addr_t)_address; + size = PAGE_ALIGN(size); + // check params if ((address % B_PAGE_SIZE) != 0) return B_BAD_VALUE; @@ -5934,3 +6104,11 @@ return B_OK; } + + +status_t +_user_memory_advice(void* address, size_t size, int advice) +{ + // TODO: Implement! + return B_OK; +} Modified: haiku/trunk/src/system/libroot/posix/sys/mman.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2008-08-07 21:42:02 UTC (rev 26870) +++ haiku/trunk/src/system/libroot/posix/sys/mman.cpp 2008-08-08 01:00:06 UTC (rev 26871) @@ -143,6 +143,14 @@ int +mprotect(void* address, size_t length, int protection) +{ + RETURN_AND_SET_ERRNO(_kern_set_memory_protection(address, length, + protection)); +} + + +int msync(void* address, size_t length, int flags) { RETURN_AND_SET_ERRNO(_kern_sync_memory(address, length, flags)); @@ -150,6 +158,13 @@ int +posix_madvise(void* address, size_t length, int advice) +{ + RETURN_AND_SET_ERRNO(_kern_memory_advice(address, length, advice)); +} + + +int shm_open(const char* name, int openMode, mode_t permissions) { char path[PATH_MAX]; From bonefish at mail.berlios.de Fri Aug 8 03:00:42 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 8 Aug 2008 03:00:42 +0200 Subject: [Haiku-commits] r26872 - haiku/trunk/src/tests/system/libroot/posix Message-ID: <200808080100.m7810gWb027932@sheep.berlios.de> Author: bonefish Date: 2008-08-08 03:00:40 +0200 (Fri, 08 Aug 2008) New Revision: 26872 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26872&view=rev Added: haiku/trunk/src/tests/system/libroot/posix/mprotect_test.cpp Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile Log: Small test for mprotect(). Modified: haiku/trunk/src/tests/system/libroot/posix/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-08 01:00:06 UTC (rev 26871) +++ haiku/trunk/src/tests/system/libroot/posix/Jamfile 2008-08-08 01:00:40 UTC (rev 26872) @@ -18,6 +18,10 @@ : flock_test.cpp ; +SimpleTest mprotect_test + : mprotect_test.cpp +; + SimpleTest realtime_sem_test1 : realtime_sem_test1.cpp ; Added: haiku/trunk/src/tests/system/libroot/posix/mprotect_test.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/mprotect_test.cpp 2008-08-08 01:00:06 UTC (rev 26871) +++ haiku/trunk/src/tests/system/libroot/posix/mprotect_test.cpp 2008-08-08 01:00:40 UTC (rev 26872) @@ -0,0 +1,106 @@ +/* + * 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 + + +#ifndef PAGE_SIZE +# define PAGE_SIZE 4096 +#endif + + +static const size_t kMapChunkSize = 4 * PAGE_SIZE; +static const size_t kTestSize = 256 * PAGE_SIZE; + +static int64_t sHandledSignals = 0; + +static uint8_t* sMappedBase; +static size_t sMappedSize; +static uint8_t* sTouchedAddress; + + +static void +signal_handler(int signal) +{ + sHandledSignals++; + + //printf("SIGSEGV at %p\n", sTouchedAddress); + + // protect the last page of the current allocation writable + if (mprotect(sMappedBase + sMappedSize - PAGE_SIZE, PAGE_SIZE, + PROT_READ | PROT_WRITE) < 0) { + fprintf(stderr, "SIGSEGV: mprotect() failed: %s\n", strerror(errno)); + exit(1); + } + + // allocate the next chunk + void* mappedAddress = mmap(sMappedBase + sMappedSize, kMapChunkSize, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); + if (mappedAddress == MAP_FAILED) { + fprintf(stderr, "SIGSEGV: mmap() failed: %s\n", strerror(errno)); + exit(1); + } + + printf("mapped %d bytes at %p\n", (int)kMapChunkSize, mappedAddress); + + sMappedSize += kMapChunkSize; + + // map the last page read-only + if (mprotect(sMappedBase + sMappedSize - PAGE_SIZE, PAGE_SIZE, PROT_READ) + < 0) { + fprintf(stderr, "SIGSEGV: mprotect() failed: %s\n", strerror(errno)); + exit(1); + } +} + + +int +main() +{ + // install signal handler + if (signal(SIGSEGV, signal_handler) == SIG_ERR) { + fprintf(stderr, "Error: Failed to install signal handler: %s\n", + strerror(errno)); + exit(1); + } + + // Map the complete test size plus one chunk and unmap all but the first + // chunk again, so no other memory gets into the way, when we mmap() the + // other chunks with MAP_FIXED. + sMappedBase = (uint8_t*)mmap(NULL, kTestSize + kMapChunkSize, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (sMappedBase == MAP_FAILED) { + fprintf(stderr, "mmap() failed: %s\n", strerror(errno)); + return 1; + } + munmap(sMappedBase + kMapChunkSize, kTestSize); + + sMappedSize = kMapChunkSize; + + printf("mapped %d bytes at %p\n", (int)sMappedSize, sMappedBase); + + if (mprotect(sMappedBase + sMappedSize - PAGE_SIZE, PAGE_SIZE, PROT_READ) + < 0) { + fprintf(stderr, "mprotect() failed: %s\n", strerror(errno)); + return 1; + } + + for (int i = 0; i < 256 * PAGE_SIZE; i++) { + sTouchedAddress = sMappedBase + i; + *sTouchedAddress = 1; + } + + printf("test finished successfully!\n"); + + return 0; +} From stippi at mail.berlios.de Fri Aug 8 12:43:10 2008 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 8 Aug 2008 12:43:10 +0200 Subject: [Haiku-commits] r26873 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 Message-ID: <200808081043.m78AhALB024103@sheep.berlios.de> Author: stippi Date: 2008-08-08 12:43:08 +0200 (Fri, 08 Aug 2008) New Revision: 26873 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26873&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c Log: Applied patch by "anxiety": * Tracked down the problem[1] to the wrong offset being read from the pci config. Now matches Realtek's Linux driver. I couldn't find why it worked before as the value hasn't changed since the original version added to the repository. This is only verified with my own 8168 but I found no special logic in other drivers for 8167 or 8169. [1] See #1853, "RTL8168 recognized but not working" I don't have the hardware myself to test. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-08 01:00:40 UTC (rev 26872) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-08 10:43:08 UTC (rev 26873) @@ -499,9 +499,9 @@ } TRACE("IRQ %d\n", device->irq); - + // map registers into memory - val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, 0x14, 4); + val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, 0x18, 4); val &= PCI_address_memory_32_mask; TRACE("hardware register address %p\n", (void *) val); device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, "rtl8169 register"); From axeld at mail.berlios.de Fri Aug 8 13:26:58 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 8 Aug 2008 13:26:58 +0200 Subject: [Haiku-commits] r26874 - haiku/trunk/build/jam Message-ID: <200808081126.m78BQwTu001415@sheep.berlios.de> Author: axeld Date: 2008-08-08 13:26:58 +0200 (Fri, 08 Aug 2008) New Revision: 26874 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26874&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: * scsi_cd/scsi_disk are new drivers, and therefore they need to use a different rule. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-08-08 10:43:08 UTC (rev 26873) +++ haiku/trunk/build/jam/HaikuImage 2008-08-08 11:26:58 UTC (rev 26874) @@ -171,13 +171,15 @@ } # drivers +AddNewDriversToHaikuImage disk scsi : scsi_cd scsi_disk ; + +# legacy drivers AddDriversToHaikuImage : console dprintf $(X86_ONLY)keyboard null random tty zero ; AddDriversToHaikuImage audio hmulti : $(BEOS_ADD_ONS_DRIVERS_AUDIO) ; AddDriversToHaikuImage midi : $(BEOS_ADD_ONS_DRIVERS_MIDI) ; AddDriversToHaikuImage bus : usb_raw fw_raw ; AddDriversToHaikuImage disk floppy : $(X86_ONLY)pc_floppy ; -AddDriversToHaikuImage disk scsi : scsi_cd scsi_disk ; AddDriversToHaikuImage disk usb : usb_disk ; AddDriversToHaikuImage disk virtual : nbd ; AddDriversToHaikuImage dvb : cx23882 ; From korli at users.berlios.de Fri Aug 8 14:35:52 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Fri, 8 Aug 2008 14:35:52 +0200 Subject: [Haiku-commits] r26873 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 In-Reply-To: <200808081043.m78AhALB024103@sheep.berlios.de> References: <200808081043.m78AhALB024103@sheep.berlios.de> Message-ID: Hi Stephan, 2008/8/8 stippi at BerliOS : > // map registers into memory > - val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, 0x14, 4); > + val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, 0x18, 4); > val &= PCI_address_memory_32_mask; > TRACE("hardware register address %p\n", (void *) val); > device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, "rtl8169 register"); Isn't this value one of pci_info.h0.base_registers[] ? Bye, J?r?me From superstippi at gmx.de Fri Aug 8 15:37:29 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 08 Aug 2008 15:37:29 +0200 Subject: [Haiku-commits] r26873 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 In-Reply-To: References: <200808081043.m78AhALB024103@sheep.berlios.de> Message-ID: <20080808153729.1502.1@stippis2.1218192491.fake> J?r?me Duval wrote: > Hi Stephan, > > 2008/8/8 stippi at BerliOS : > > // map registers into memory > > - val = gPci->read_pci_config(device->pciInfo->bus, > > device->pciInfo->device, device->pciInfo->function, 0x14, 4); > > + val = gPci->read_pci_config(device->pciInfo->bus, > > device->pciInfo->device, device->pciInfo->function, 0x18, 4); > > val &= PCI_address_memory_32_mask; > > TRACE("hardware register address %p\n", (void *) val); > > device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, > > "rtl8169 register"); > > Isn't this value one of pci_info.h0.base_registers[] ? I wouldn't have a clue! :-\ Best regards, -Stephan From bonefish at mail.berlios.de Fri Aug 8 16:00:15 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 8 Aug 2008 16:00:15 +0200 Subject: [Haiku-commits] r26875 - haiku/trunk/src/system/kernel/vm Message-ID: <200808081400.m78E0FsR014281@sheep.berlios.de> Author: bonefish Date: 2008-08-08 16:00:07 +0200 (Fri, 08 Aug 2008) New Revision: 26875 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26875&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: "page_stats" does now also print the number of mapped pages. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-08 11:26:58 UTC (rev 26874) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2008-08-08 14:00:07 UTC (rev 26875) @@ -624,6 +624,7 @@ counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]); kprintf("reserved pages: %lu\n", sReservedPages); kprintf("page deficit: %lu\n", sPageDeficit); + kprintf("mapped pages: %lu\n", gMappedPagesCount); kprintf("\nfree queue: %p, count = %ld\n", &sFreePageQueue, sFreePageQueue.count); From bonefish at mail.berlios.de Fri Aug 8 16:01:11 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Fri, 8 Aug 2008 16:01:11 +0200 Subject: [Haiku-commits] r26876 - haiku/trunk/src/system/kernel/vm Message-ID: <200808081401.m78E1BL1014390@sheep.berlios.de> Author: bonefish Date: 2008-08-08 16:01:09 +0200 (Fri, 08 Aug 2008) New Revision: 26876 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26876&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: vm_remove_all_page_mappings(): Decrement the mapped pages count only, if the page was really mapped before. Fixes bug #2585. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-08 14:00:07 UTC (rev 26875) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2008-08-08 14:01:09 UTC (rev 26876) @@ -2797,7 +2797,7 @@ accumulatedFlags |= flags; } - if (page->wired_count == 0) + if (page->wired_count == 0 && !queue.IsEmpty()) atomic_add(&gMappedPagesCount, -1); locker.Unlock(); From stippi at mail.berlios.de Fri Aug 8 16:22:03 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Fri, 8 Aug 2008 16:22:03 +0200 Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage Message-ID: <200808081422.m78EM3fL015860@sheep.berlios.de> Author: stippi Date: 2008-08-08 16:22:00 +0200 (Fri, 08 Aug 2008) New Revision: 26877 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26877&view=rev Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp Log: * Rename the private structs to use the same scheme as for classes, which seems to be the habbit now. * Improve PathHandler::Quit() to delete the object in case the BMessenger was not valid or failed to send the Quit message. This should handle the corner case that the PathHandler's looper was already Quit(). There could still be a race condition, although I don't know if it affects local message targets in Haiku. I added a TODO note for that, but I believe it can be neglected. Modified: haiku/trunk/src/kits/storage/PathMonitor.cpp =================================================================== --- haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-08 14:01:09 UTC (rev 26876) +++ haiku/trunk/src/kits/storage/PathMonitor.cpp 2008-08-08 14:22:00 UTC (rev 26877) @@ -58,20 +58,20 @@ typedef set FileSet; #endif -struct watched_directory { - node_ref node; - bool contained; +struct WatchedDirectory { + node_ref node; + bool contained; }; -typedef set DirectorySet; +typedef set DirectorySet; class PathHandler; typedef map HandlerMap; -struct watcher { +struct Watcher { HandlerMap handlers; }; -typedef map WatcherMap; +typedef map WatcherMap; class PathHandler : public BHandler { public: @@ -154,7 +154,7 @@ bool -operator<(const watched_directory& a, const watched_directory& b) +operator<(const WatchedDirectory& a, const WatchedDirectory& b) { return a.node < b.node; } @@ -209,8 +209,29 @@ void PathHandler::Quit() { - BMessenger me(this); - me.SendMessage(B_QUIT_REQUESTED); + // We are not allowed to lock the BLooper, or we could deadlock! + // So we will remove the handler from the looper in it's own thread + // and also delete us there by sending ourself a message. But this + // handler may possibly not be attached to it's looper any more. The + // BMessenger can check this in a thread safe way without locking + // the looper. + status_t status; + BMessenger toSelf(this, NULL, &status); + if (status == B_OK) + status = toSelf.SendMessage(B_QUIT_REQUESTED); + + // TODO: Could there still be a race condition? What if the + // looper was right in it's destructor, sending the message may + // succeed, but it may still not arrive. The worst that happens + // though is that this object is leaked. But I do anticipate this + // case to only happen during the shutdown of an application, in + // which case the point is moot... Also note - one could introduce a + // reply for this message to know whether it arrived, but in the case + // the reply is wrong (default reply), one would still not know at + // which time the BLooper removes this handler without locking it. + + if (status != B_OK) + delete this; } @@ -541,7 +562,7 @@ PathHandler::_HasDirectory(const node_ref& nodeRef, bool* _contained /* = NULL */) const { - watched_directory directory; + WatchedDirectory directory; directory.node = nodeRef; DirectorySet::const_iterator iterator = fDirectories.find(directory); @@ -579,7 +600,7 @@ status_t PathHandler::_AddDirectory(BEntry& entry) { - watched_directory directory; + WatchedDirectory directory; status_t status = entry.GetNodeRef(&directory.node); if (status != B_OK) return status; @@ -643,7 +664,7 @@ { TRACE((" REMOVE DIRECTORY %ld:%Ld\n", nodeRef.device, nodeRef.node)); - watched_directory directory; + WatchedDirectory directory; directory.node = nodeRef; DirectorySet::iterator iterator = fDirectories.find(directory); @@ -833,7 +854,7 @@ BAutolock _(sLocker); WatcherMap::iterator iterator = sWatchers.find(target); - struct watcher* watcher = NULL; + Watcher* watcher = NULL; if (iterator != sWatchers.end()) watcher = iterator->second; @@ -846,7 +867,7 @@ return status; if (watcher == NULL) { - watcher = new (nothrow) BPrivate::watcher; + watcher = new (nothrow) BPrivate::Watcher; if (watcher == NULL) return B_NO_MEMORY; sWatchers[target] = watcher; @@ -869,7 +890,7 @@ if (iterator == sWatchers.end()) return B_BAD_VALUE; - struct watcher* watcher = iterator->second; + Watcher* watcher = iterator->second; HandlerMap::iterator i = watcher->handlers.find(path); if (i == watcher->handlers.end()) @@ -901,7 +922,7 @@ if (iterator == sWatchers.end()) return B_BAD_VALUE; - struct watcher* watcher = iterator->second; + Watcher* watcher = iterator->second; while (!watcher->handlers.empty()) { HandlerMap::iterator i = watcher->handlers.begin(); PathHandler* handler = i->second; From korli at users.berlios.de Fri Aug 8 16:32:35 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Fri, 8 Aug 2008 16:32:35 +0200 Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage In-Reply-To: <200808081422.m78EM3fL015860@sheep.berlios.de> References: <200808081422.m78EM3fL015860@sheep.berlios.de> Message-ID: Hi Stephan, 2008/8/8 : > * Improve PathHandler::Quit() to delete the object in case the BMessenger was > not valid or failed to send the Quit message. This should handle the corner > case that the PathHandler's looper was already Quit(). There could still be > a race condition, although I don't know if it affects local message targets > in Haiku. I added a TODO note for that, but I believe it can be neglected. I lack the background context on the role of PathHandler::Quit() but wouldn't it be possible to check Looper() and wait for Looper().Thread() ? Bye, J?r?me From superstippi at gmx.de Fri Aug 8 17:15:24 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 08 Aug 2008 17:15:24 +0200 Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage In-Reply-To: References: <200808081422.m78EM3fL015860@sheep.berlios.de> Message-ID: <20080808171524.2106.5@stippis2.1218192491.fake> J?r?me Duval wrote: > Hi Stephan, > > 2008/8/8 : > > * Improve PathHandler::Quit() to delete the object in case the > > BMessenger was > > not valid or failed to send the Quit message. This should handle the > > corner case that the PathHandler's looper was already Quit(). There > > could still be a race condition, although I don't know if it affects > > local message targets in Haiku. I added a TODO note for that, but I > > believe it can be neglected. > > I lack the background context on the role of PathHandler::Quit() but > wouldn't it be possible to check Looper() and wait for Looper().Thread() ? In the case PathHandler::Quit() is exectuted in another thread than the looper for this handler, then calling handler->Looper() is not thread safe without locking that looper. In another words, handler->LockLooper() would be threadsafe, but the situation is at hand where that looper is already locked and waiting on another thread/looper which executes PathHandler::Quit(). Any form of trying to lock that looper will then deadlock. Using the BMessenger uses another lock (gLooperList) and avoids the deadlock. If I analyzed the BLooper destructor correctly, then there may be the race condition that the handler's looper is right in it's destructor before deleting the message port and BMessenger may succeed to still send it a message which will never be processed but only get a generic reply. In that case, the PathHandler object would be leaked. Best regards, -Stephan From axeld at pinc-software.de Fri Aug 8 17:21:34 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 08 Aug 2008 17:21:34 +0200 CEST Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage In-Reply-To: <200808081422.m78EM3fL015860@sheep.berlios.de> Message-ID: <27143178312-BeMail@zon> stippi at mail.berlios.de wrote: > Log: > * Rename the private structs to use the same scheme as for classes, > which seems > to be the habbit now. Habit from whom? AFAIK we still use lower_case_with_underscore for C structs, and UpperCase for C++ classes. And I would actually prefer to keep it that way :-) Bye, Axel. From axeld at mail.berlios.de Fri Aug 8 17:23:44 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 8 Aug 2008 17:23:44 +0200 Subject: [Haiku-commits] r26878 - haiku/trunk/src/system/boot/platform/pxe_ia32 Message-ID: <200808081523.m78FNig1022069@sheep.berlios.de> Author: axeld Date: 2008-08-08 17:23:44 +0200 (Fri, 08 Aug 2008) New Revision: 26878 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26878&view=rev Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile Log: * Fixed PXE boot loader build. Modified: haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile =================================================================== --- haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile 2008-08-08 14:22:00 UTC (rev 26877) +++ haiku/trunk/src/system/boot/platform/pxe_ia32/Jamfile 2008-08-08 15:23:44 UTC (rev 26878) @@ -17,7 +17,7 @@ SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; } -local bios_ia32_src = +local bios_ia32_src = start.c debug.c bios.S @@ -27,13 +27,14 @@ menu.cpp mmu.cpp cpu.cpp + acpi.cpp smp.cpp support.S video.cpp apm.cpp ; -local bios_ia32_edid_src = +local bios_ia32_edid_src = decode_edid.c dump_edid.c ; From axeld at mail.berlios.de Fri Aug 8 17:37:43 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 8 Aug 2008 17:37:43 +0200 Subject: [Haiku-commits] r26879 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 Message-ID: <200808081537.m78Fbh7D023277@sheep.berlios.de> Author: axeld Date: 2008-08-08 17:37:43 +0200 (Fri, 08 Aug 2008) New Revision: 26879 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26879&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c Log: * Reverted last commit - not a good idea to provide untested patches. With the patch applied, the card didn't work at all anymore. * Minor 80-column/white space cleanup. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-08 15:23:44 UTC (rev 26878) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-08 15:37:43 UTC (rev 26879) @@ -1,7 +1,7 @@ /* Realtek RTL8169 Family Driver * Copyright (C) 2004 Marcus Overhagen . All rights reserved. * - * Permission to use, copy, modify and distribute this software and its + * Permission to use, copy, modify and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies, and that both the * copyright notice and this permission notice appear in supporting documentation. @@ -16,6 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + #include #include #include @@ -39,11 +40,11 @@ void *handle; const char *param; int mtu, count; - + handle = load_driver_settings("rtl8169"); if (!handle) return; - + param = get_driver_parameter(handle, "mtu", "-1", "-1"); mtu = atoi(param); if (mtu >= 50 && mtu <= 1500) @@ -126,8 +127,8 @@ // see IEE 802.3-2002 (is also uses decimal numbers when refering // to the registers, as do we). Added a little documentation write_phy_reg(device, 31, 0x0001); // vendor specific (enter programming mode?) - write_phy_reg(device, 21, 0x1000); // vendor specific - write_phy_reg(device, 24, 0x65c7); // vendor specific + write_phy_reg(device, 21, 0x1000); // vendor specific + write_phy_reg(device, 24, 0x65c7); // vendor specific write_phy_reg_bit(device, 4, 11, 0); // reset T (T=toggle) bit in reg 4 (ability) val = read_phy_reg(device, 4) & 0x0fff; // get only the message code fields write_phy_reg(device, 4, val); // and write them back. this clears the page and makes it unformatted (see 37.2.4.3.1) @@ -171,7 +172,7 @@ write_phy_reg_bit(device, 4, 11, 1); // set toggle bit high write_phy_reg_bit(device, 4, 11, 0); // set toggle bit low => this is a toggle write_phy_reg(device, 31, 0x0000); // vendor specific (leave programming mode?) - } + } write_phy_reg(device, 4, 0x01e1); // 10/100 capability write_phy_reg(device, 9, 0x0200); // 1000 capability @@ -261,7 +262,7 @@ device->intTxCurrentCount, device->intTimerTotalCount, device->intTimerCurrentCount); - + device->intTotalCountOld = device->intTotalCount; device->intCurrentCount = 0; device->intRxCurrentCount = 0; @@ -280,21 +281,27 @@ void *rx_buf_virt, *rx_buf_phy; int i; - device->txBufArea = alloc_mem(&tx_buf_virt, &tx_buf_phy, device->txBufferCount * FRAME_SIZE, 0, "rtl8169 tx buf"); - device->rxBufArea = alloc_mem(&rx_buf_virt, &rx_buf_phy, device->rxBufferCount * FRAME_SIZE, 0, "rtl8169 rx buf"); - device->txDescArea = alloc_mem(&tx_buf_desc_virt, &tx_buf_desc_phy, device->txBufferCount * sizeof(buf_desc), 0, "rtl8169 tx desc"); - device->rxDescArea = alloc_mem(&rx_buf_desc_virt, &rx_buf_desc_phy, device->rxBufferCount * sizeof(buf_desc), 0, "rtl8169 rx desc"); - if (device->txBufArea < B_OK || device->rxBufArea < B_OK || device->txDescArea < B_OK || device->rxDescArea < B_OK) + device->txBufArea = alloc_mem(&tx_buf_virt, &tx_buf_phy, + device->txBufferCount * FRAME_SIZE, 0, "rtl8169 tx buf"); + device->rxBufArea = alloc_mem(&rx_buf_virt, &rx_buf_phy, + device->rxBufferCount * FRAME_SIZE, 0, "rtl8169 rx buf"); + device->txDescArea = alloc_mem(&tx_buf_desc_virt, &tx_buf_desc_phy, + device->txBufferCount * sizeof(buf_desc), 0, "rtl8169 tx desc"); + device->rxDescArea = alloc_mem(&rx_buf_desc_virt, &rx_buf_desc_phy, + device->rxBufferCount * sizeof(buf_desc), 0, "rtl8169 rx desc"); + if (device->txBufArea < B_OK || device->rxBufArea < B_OK + || device->txDescArea < B_OK || device->rxDescArea < B_OK) return B_NO_MEMORY; - - device->txDesc = (buf_desc *) tx_buf_desc_virt; - device->rxDesc = (buf_desc *) rx_buf_desc_virt; + device->txDesc = (buf_desc *)tx_buf_desc_virt; + device->rxDesc = (buf_desc *)rx_buf_desc_virt; + // setup transmit descriptors for (i = 0; i < device->txBufferCount; i++) { device->txBuf[i] = (char *)tx_buf_virt + (i * FRAME_SIZE); device->txDesc[i].stat_len = TX_DESC_FS | TX_DESC_LS; - device->txDesc[i].buf_low = (uint32)((char *)tx_buf_phy + (i * FRAME_SIZE)); + device->txDesc[i].buf_low + = (uint32)((char *)tx_buf_phy + (i * FRAME_SIZE)); device->txDesc[i].buf_high = 0; } device->txDesc[i - 1].stat_len |= TX_DESC_EOR; @@ -303,11 +310,12 @@ for (i = 0; i < device->rxBufferCount; i++) { device->rxBuf[i] = (char *)rx_buf_virt + (i * FRAME_SIZE); device->rxDesc[i].stat_len = RX_DESC_OWN | FRAME_SIZE; - device->rxDesc[i].buf_low = (uint32)((char *)rx_buf_phy + (i * FRAME_SIZE)); + device->rxDesc[i].buf_low + = (uint32)((char *)rx_buf_phy + (i * FRAME_SIZE)); device->rxDesc[i].buf_high = 0; } device->rxDesc[i - 1].stat_len |= RX_DESC_EOR; - + write32(REG_RDSAR_LOW, (uint32)rx_buf_desc_phy); write32(REG_RDSAR_HIGH, 0); write32(REG_TNPDS_LOW, (uint32)tx_buf_desc_phy); @@ -350,7 +358,7 @@ { int32 limit; int32 count; - + acquire_spinlock(&device->rxSpinlock); for (count = 0, limit = device->rxFree; limit > 0; limit--) { @@ -361,7 +369,7 @@ } // dprintf("rx int, rxFree %d, count %d\n", device->rxFree, count); - + device->rxFree -= count; release_spinlock(&device->rxSpinlock); @@ -381,13 +389,13 @@ stat = read16(REG_INT_STAT); if (stat == 0 || stat == 0xffff) return B_UNHANDLED_INTERRUPT; - + write16(REG_INT_STAT, stat); ret = B_HANDLED_INTERRUPT; PROFILING_ONLY(device->intTotalCount++); PROFILING_ONLY(device->intCurrentCount++); - + if (stat & INT_FOVW) { TRACE("INT_FOVW\n"); } @@ -429,36 +437,36 @@ int dev_id; int mask; int i; - + TRACE("rtl8169_open()\n"); for (dev_id = 0; (deviceName = gDevNameList[dev_id]) != NULL; dev_id++) { if (!strcmp(name, deviceName)) break; - } + } if (deviceName == NULL) { ERROR("invalid device name\n"); return B_ERROR; } - + // allow only one concurrent access mask = 1 << dev_id; if (atomic_or(&gOpenMask, mask) & mask) return B_BUSY; - + *cookie = device = (rtl8169_device *)malloc(sizeof(rtl8169_device)); if (!device) { atomic_and(&gOpenMask, ~(1 << dev_id)); return B_NO_MEMORY; } - + memset(device, 0, sizeof(*device)); device->devId = dev_id; device->pciInfo = gDevList[dev_id]; device->nonblocking = (flags & O_NONBLOCK) ? true : false; device->closed = false; - + // setup defaults device->maxframesize = 1514; // not FRAME_SIZE device->txBufferCount = DEFAULT_TX_BUF_COUNT; @@ -473,7 +481,7 @@ device->rxFree = device->rxBufferCount; device->rxReadySem = create_sem(0, "rtl8169 rx ready"); set_sem_owner(device->rxReadySem, B_SYSTEM_TEAM); - + device->txBuf = (void **)malloc(sizeof(void *) * device->txBufferCount); B_INITIALIZE_SPINLOCK(&device->txSpinlock); device->txNextIndex = 0; @@ -481,18 +489,23 @@ device->txUsed = 0; device->txFreeSem = create_sem(device->txBufferCount, "rtl8169 tx free"); set_sem_owner(device->txFreeSem, B_SYSTEM_TEAM); - + // enable busmaster and memory mapped access, disable io port access - val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, PCI_command, 2); + val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, + device->pciInfo->function, PCI_command, 2); val = PCI_PCICMD_BME | PCI_PCICMD_MSE | (val & ~PCI_PCICMD_IOS); - gPci->write_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, PCI_command, 2, val); + gPci->write_pci_config(device->pciInfo->bus, device->pciInfo->device, + device->pciInfo->function, PCI_command, 2, val); // adjust PCI latency timer TRACE("changing PCI latency to 0x40\n"); - gPci->write_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, PCI_latency, 1, 0x40); + gPci->write_pci_config(device->pciInfo->bus, device->pciInfo->device, + device->pciInfo->function, PCI_latency, 1, 0x40); // get IRQ - device->irq = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, PCI_interrupt_line, 1); + device->irq = gPci->read_pci_config(device->pciInfo->bus, + device->pciInfo->device, device->pciInfo->function, PCI_interrupt_line, + 1); if (device->irq == 0 || device->irq == 0xff) { ERROR("no IRQ assigned\n"); goto err; @@ -501,15 +514,17 @@ TRACE("IRQ %d\n", device->irq); // map registers into memory - val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, device->pciInfo->function, 0x18, 4); + val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, + device->pciInfo->function, 0x14, 4); val &= PCI_address_memory_32_mask; TRACE("hardware register address %p\n", (void *) val); - device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, "rtl8169 register"); + device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, + "rtl8169 register"); if (device->regArea < B_OK) { ERROR("can't map hardware registers\n"); goto err; } - + TRACE("mapped registers to %p\n", device->regAddr); // disable receiver & transmitter XXX might be removed @@ -527,7 +542,8 @@ TRACE("reset done\n"); // get MAC hardware version - device->mac_version = ((read32(REG_TX_CONFIG) & 0x7c000000) >> 25) | ((read32(REG_TX_CONFIG) & 0x00800000) >> 23); + device->mac_version = ((read32(REG_TX_CONFIG) & 0x7c000000) >> 25) + | ((read32(REG_TX_CONFIG) & 0x00800000) >> 23); TRACE("8169 Mac Version %d\n", device->mac_version); if (device->mac_version > 0) { // this is a RTL8169s single chip // get PHY hardware version @@ -538,35 +554,38 @@ device->phy_version = 0; TRACE("8169 Phy Version unknown\n"); } - + if (device->mac_version == 1) { // as it's done by the BSD driver... TRACE("Setting MAC Reg C+CR 0x82h = 0x01h\n"); write8(0x82, 0x01); // don't know what this does TRACE("Setting PHY Reg 0x0bh = 0x00h\n"); - write_phy_reg(device, 0x0b, 0x0000); // 0xb is a reserved (vendor specific register), don't know what this does + write_phy_reg(device, 0x0b, 0x0000); + // 0xb is a reserved (vendor specific register), don't know what + // this does } - + // configure PHY phy_config(device); - + dump_phy_stat(device); print_link_status(device); - // initialize MAC address + // initialize MAC address for (i = 0; i < 6; i++) device->macaddr[i] = read8(i); - + TRACE("MAC %02x:%02x:%02x:%02x:%02x:%02x\n", device->macaddr[0], device->macaddr[1], device->macaddr[2], device->macaddr[3], device->macaddr[4], device->macaddr[5]); - + // setup interrupt handler - if (install_io_interrupt_handler(device->irq, rtl8169_int, device, 0) < B_OK) { + if (install_io_interrupt_handler(device->irq, rtl8169_int, device, 0) + < B_OK) { ERROR("can't install interrupt handler\n"); goto err; } - + #ifdef PROFILING device->intTotalCount = 0; device->intTotalCountOld = 0; @@ -577,16 +596,19 @@ device->intRxCurrentCount = 0; device->intTxCurrentCount = 0; device->intTimerCurrentCount = 0; - device->timer = create_timer(print_debug_info, device, 1000000, B_PERIODIC_TIMER); + device->timer = create_timer(print_debug_info, device, 1000000, + B_PERIODIC_TIMER); #endif // PROFILING - + write16(0xe0, read16(0xe0)); // write CR+ command - write16(0xe0, read16(0xe0) | 0x0003); // don't know what this does, BSD says "enable C+ Tx/Rx" + write16(0xe0, read16(0xe0) | 0x0003); + // don't know what this does, BSD says "enable C+ Tx/Rx" if (device->mac_version == 1) { TRACE("Setting Reg C+CR bit 3 and bit 14 to 1\n"); - // bit 3 is PCI multiple read/write enable (max Tx/Rx DMA burst size setting is no longer valid then) + // bit 3 is PCI multiple read/write enable (max Tx/Rx DMA burst size + // setting is no longer valid then) // bit 14 ??? (need more docs) write16(0xe0, read16(0xe0) | 0x4008); } @@ -599,36 +621,39 @@ // enable receiver & transmitter write8(REG_CR, read8(REG_CR) | CR_RE | CR_TE); - + write8(REG_9346CR, 0xc0); // enable config access write8(REG_CONFIG1, read8(REG_CONFIG1) & ~1); // disable power management write8(REG_9346CR, 0x00); // disable config access - + write8(0xec, 0x3f); // disable early transmit treshold write16(0xda, FRAME_SIZE); // receive packet maximum size write16(0x5c, read16(0x5c) & 0xf000); // disable early receive interrupts - + write32(0x4c, 0); // RxMissed ??? // setup receive config, can only be done when receiver is enabled! // 1024 byte FIFO treshold, 1024 DMA burst write32(REG_RX_CONFIG, (read32(REG_RX_CONFIG) & RX_CONFIG_MASK) | (0x6 << RC_CONFIG_RXFTH_Shift) | (0x6 << RC_CONFIG_MAXDMA_Shift) - | RX_CONFIG_AcceptBroad | RX_CONFIG_AcceptMulti | RX_CONFIG_AcceptMyPhys); + | RX_CONFIG_AcceptBroad | RX_CONFIG_AcceptMulti + | RX_CONFIG_AcceptMyPhys); write32(0x8, 0); // multicast filter write32(0xc, 0); // multicast filter - // setup transmit config, can only be done when transmitter is enabled! + // setup transmit config, can only be done when transmitter is enabled! // append CRC, 1024 DMA burst - write32(REG_TX_CONFIG, (read32(REG_TX_CONFIG) & ~(0x10000 | (1 << 8))) | (0x6 << 8)); - + write32(REG_TX_CONFIG, (read32(REG_TX_CONFIG) & ~(0x10000 | (1 << 8))) + | (0x6 << 8)); + // clear pending interrupt status write16(REG_INT_STAT, 0xffff); - + // enable used interrupts - write16(REG_INT_MASK, INT_FOVW | INT_PUN | INT_TER | INT_TOK | INT_RER | INT_ROK); + write16(REG_INT_MASK, INT_FOVW | INT_PUN | INT_TER | INT_TOK | INT_RER + | INT_ROK); return B_OK; @@ -653,7 +678,7 @@ { rtl8169_device *device = (rtl8169_device *)cookie; TRACE("rtl8169_close()\n"); - + device->closed = true; release_sem(device->rxReadySem); release_sem(device->txFreeSem); @@ -673,9 +698,9 @@ // disable interrupts write16(REG_INT_MASK, 0); - + PROFILING_ONLY(delete_timer(device->timer)); - + // well... remove_io_interrupt_handler (device->irq, rtl8169_int, device); @@ -695,27 +720,30 @@ status_t -rtl8169_read(void* cookie, off_t position, void *buf, size_t* num_bytes) +rtl8169_read(void* cookie, off_t position, void *buf, size_t* numBytes) { rtl8169_device *device = (rtl8169_device *)cookie; cpu_status cpu; status_t stat; int len; TRACE("rtl8169_read() enter\n"); - + if (device->closed) { TRACE("rtl8169_read() interrupted 1\n"); return B_INTERRUPTED; } retry: - stat = acquire_sem_etc(device->rxReadySem, 1, B_CAN_INTERRUPT | (device->nonblocking ? B_TIMEOUT : 0), 0); + stat = acquire_sem_etc(device->rxReadySem, 1, + B_CAN_INTERRUPT | (device->nonblocking ? B_TIMEOUT : 0), 0); if (device->closed) { - // TRACE("rtl8169_read() interrupted 2\n"); // net_server will crash if we print this (race condition in net_server?) + // TRACE("rtl8169_read() interrupted 2\n"); + // net_server will crash if we print this + // (race condition in net_server?) return B_INTERRUPTED; } if (stat == B_WOULD_BLOCK) { TRACE("rtl8169_read() would block (OK 0 bytes)\n"); - *num_bytes = 0; + *numBytes = 0; return B_OK; } if (stat != B_OK) { @@ -732,39 +760,41 @@ len -= 4; // remove CRC that Realtek always appends if (len < 0) len = 0; - if (len > (int)*num_bytes) - len = *num_bytes; + if (len > (int)*numBytes) + len = *numBytes; memcpy(buf, device->rxBuf[device->rxNextIndex], len); - *num_bytes = len; + *numBytes = len; cpu = disable_interrupts(); acquire_spinlock(&device->rxSpinlock); - device->rxDesc[device->rxNextIndex].stat_len = RX_DESC_OWN | FRAME_SIZE | (device->rxDesc[device->rxNextIndex].stat_len & RX_DESC_EOR); + device->rxDesc[device->rxNextIndex].stat_len = RX_DESC_OWN | FRAME_SIZE + | (device->rxDesc[device->rxNextIndex].stat_len & RX_DESC_EOR); device->rxFree++; release_spinlock(&device->rxSpinlock); restore_interrupts(cpu); - + device->rxNextIndex = (device->rxNextIndex + 1) % device->rxBufferCount; - + TRACE("rtl8169_read() leave\n"); return B_OK; } status_t -rtl8169_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes) +rtl8169_write(void* cookie, off_t position, const void* buffer, + size_t* numBytes) { rtl8169_device *device = (rtl8169_device *)cookie; cpu_status cpu; status_t stat; int len; - + TRACE("rtl8169_write() enter\n"); - len = *num_bytes; + len = *numBytes; if (len > FRAME_SIZE) { TRACE("rtl8169_write() buffer too large\n"); return B_ERROR; @@ -775,14 +805,15 @@ return B_INTERRUPTED; } retry: - stat = acquire_sem_etc(device->txFreeSem, 1, B_CAN_INTERRUPT | B_TIMEOUT, device->nonblocking ? 0 : TX_TIMEOUT); + stat = acquire_sem_etc(device->txFreeSem, 1, B_CAN_INTERRUPT | B_TIMEOUT, + device->nonblocking ? 0 : TX_TIMEOUT); if (device->closed) { TRACE("rtl8169_write() interrupted 2\n"); return B_INTERRUPTED; } if (stat == B_WOULD_BLOCK) { TRACE("rtl8169_write() would block (OK 0 bytes)\n"); - *num_bytes = 0; + *numBytes = 0; return B_OK; } if (stat == B_TIMED_OUT) { @@ -793,7 +824,7 @@ TRACE("rtl8169_write() error\n"); return B_ERROR; } - + if (device->txDesc[device->txNextIndex].stat_len & TX_DESC_OWN) { ERROR("rtl8169_write() buffer still in use\n"); goto retry; @@ -805,13 +836,15 @@ acquire_spinlock(&device->txSpinlock); device->txUsed++; - device->txDesc[device->txNextIndex].stat_len = (device->txDesc[device->txNextIndex].stat_len & RX_DESC_EOR) | TX_DESC_OWN | TX_DESC_FS | TX_DESC_LS | len; + device->txDesc[device->txNextIndex].stat_len + = (device->txDesc[device->txNextIndex].stat_len & RX_DESC_EOR) + | TX_DESC_OWN | TX_DESC_FS | TX_DESC_LS | len; release_spinlock(&device->txSpinlock); restore_interrupts(cpu); device->txNextIndex = (device->txNextIndex + 1) % device->txBufferCount; - + write8(REG_TPPOLL, read8(REG_TPPOLL) | TPPOLL_NPQ); // set queue polling bit TRACE("rtl8169_write() leave\n"); @@ -828,12 +861,12 @@ case ETHER_INIT: TRACE("rtl8169_control() ETHER_INIT\n"); return B_OK; - + case ETHER_GETADDR: TRACE("rtl8169_control() ETHER_GETADDR\n"); memcpy(arg, &device->macaddr, sizeof(device->macaddr)); return B_OK; - + case ETHER_NONBLOCK: if (*(int32 *)arg) { TRACE("non blocking mode on\n"); @@ -852,20 +885,22 @@ case ETHER_ADDMULTI: TRACE("rtl8169_control() ETHER_ADDMULTI\n"); break; - + case ETHER_REMMULTI: TRACE("rtl8169_control() ETHER_REMMULTI\n"); return B_OK; - + case ETHER_SETPROMISC: if (*(int32 *)arg) { TRACE("promiscuous mode on\n"); - write32(REG_RX_CONFIG, read32(REG_RX_CONFIG) | RX_CONFIG_AcceptAllPhys); + write32(REG_RX_CONFIG, read32(REG_RX_CONFIG) + | RX_CONFIG_AcceptAllPhys); write32(0x8, 0xffffffff); // multicast filter write32(0xc, 0xffffffff); // multicast filter } else { TRACE("promiscuous mode off\n"); - write32(REG_RX_CONFIG, read32(REG_RX_CONFIG) & ~RX_CONFIG_AcceptAllPhys); + write32(REG_RX_CONFIG, read32(REG_RX_CONFIG) + & ~RX_CONFIG_AcceptAllPhys); write32(0x8, 0); // multicast filter write32(0xc, 0); // multicast filter } @@ -875,12 +910,12 @@ TRACE("rtl8169_control() ETHER_GETFRAMESIZE, framesize = %d (MTU = %d)\n", device->maxframesize, device->maxframesize - 14); *(uint32*)arg = device->maxframesize; return B_OK; - + default: TRACE("rtl8169_control() Invalid command\n"); break; } - + return B_ERROR; } From anevilyak at gmail.com Fri Aug 8 17:41:06 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Fri, 8 Aug 2008 10:41:06 -0500 Subject: [Haiku-commits] r26879 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 In-Reply-To: <200808081537.m78Fbh7D023277@sheep.berlios.de> References: <200808081537.m78Fbh7D023277@sheep.berlios.de> Message-ID: On Fri, Aug 8, 2008 at 10:37 AM, axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-08 17:37:43 +0200 (Fri, 08 Aug 2008) > New Revision: 26879 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26879&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c > Log: > * Reverted last commit - not a good idea to provide untested patches. With the > patch applied, the card didn't work at all anymore. > * Minor 80-column/white space cleanup. Does the driver maybe have to special case for the 8168 then? The patch was specifically to get the 8168 working. Regards, Rene From korli at users.berlios.de Fri Aug 8 18:44:48 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Fri, 8 Aug 2008 18:44:48 +0200 Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage In-Reply-To: <20080808171524.2106.5@stippis2.1218192491.fake> References: <200808081422.m78EM3fL015860@sheep.berlios.de> <20080808171524.2106.5@stippis2.1218192491.fake> Message-ID: 2008/8/8 Stephan Assmus : >> I lack the background context on the role of PathHandler::Quit() but >> wouldn't it be possible to check Looper() and wait for Looper().Thread() ? > > In the case PathHandler::Quit() is exectuted in another thread than the > looper for this handler, then calling handler->Looper() is not thread safe > without locking that looper. In another words, handler->LockLooper() would > be threadsafe, but the situation is at hand where that looper is already > locked and waiting on another thread/looper which executes > PathHandler::Quit(). Any form of trying to lock that looper will then > deadlock. Using the BMessenger uses another lock (gLooperList) and avoids > the deadlock. If I analyzed the BLooper destructor correctly, then there > may be the race condition that the handler's looper is right in it's > destructor before deleting the message port and BMessenger may succeed to > still send it a message which will never be processed but only get a > generic reply. In that case, the PathHandler object would be leaked. So you're using Quit() instead of simply deleting the BHandler to avoid a possible deadlock in the BHandler destructor ? This seems fairly complex IMO. Bye, J?r?me From superstippi at gmx.de Fri Aug 8 19:40:26 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 08 Aug 2008 19:40:26 +0200 Subject: [Haiku-commits] r26877 - haiku/trunk/src/kits/storage In-Reply-To: References: <200808081422.m78EM3fL015860@sheep.berlios.de> <20080808171524.2106.5@stippis2.1218192491.fake> Message-ID: <20080808194026.9383.8@stippis2.1218192491.fake> J?r?me Duval wrote: > 2008/8/8 Stephan Assmus : > >> I lack the background context on the role of PathHandler::Quit() but > >> wouldn't it be possible to check Looper() and wait for > >> Looper().Thread() ? > > > > In the case PathHandler::Quit() is exectuted in another thread than the > > looper for this handler, then calling handler->Looper() is not thread > > safe without locking that looper. In another words, > > handler->LockLooper() would be threadsafe, but the situation is at hand > > where that looper is already locked and waiting on another > > thread/looper which executes PathHandler::Quit(). Any form of trying to > > lock that looper will then deadlock. Using the BMessenger uses another > > lock (gLooperList) and avoids the deadlock. If I analyzed the BLooper > > destructor correctly, then there may be the race condition that the > > handler's looper is right in it's destructor before deleting the > > message port and BMessenger may succeed to still send it a message > > which will never be processed but only get a generic reply. In that > > case, the PathHandler object would be leaked. > > So you're using Quit() instead of simply deleting the BHandler to avoid a > possible deadlock in the BHandler destructor ? This seems fairly complex > IMO. Actually, you are absolutely right and I just realized that this asynchronous removal of node monitor targets gives trouble (StopWatching() -> StartWatching() the effects of StopWatching() may happen after StartWatching() did it's thing...). The basic idea was to be able to reuse existing BLoopers, but also after talking to Axel, I am just going to change the code to always use a private looper and then the behavior is completely known. Best regards, -Stephan From axeld at pinc-software.de Fri Aug 8 23:27:07 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 08 Aug 2008 23:27:07 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26873_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/network/rtl8169?= In-Reply-To: Message-ID: <49075796300-BeMail@zon> "J?r?me Duval" wrote: > Isn't this value one of pci_info.h0.base_registers[] ? Yes, it is; it's just obvioulsy not clear which range to use :-) Bye, Axel. From axeld at pinc-software.de Fri Aug 8 23:41:11 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Fri, 08 Aug 2008 23:41:11 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26879_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/network/rtl8169?= In-Reply-To: Message-ID: <49919831412-BeMail@zon> "Rene Gollent" wrote: > On Fri, Aug 8, 2008 at 10:37 AM, axeld at BerliOS < > axeld at mail.berlios.de> wrote: > > Author: axeld > > Date: 2008-08-08 17:37:43 +0200 (Fri, 08 Aug 2008) > > New Revision: 26879 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26879&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c > > Log: > > * Reverted last commit - not a good idea to provide untested > > patches. With the > > patch applied, the card didn't work at all anymore. > > * Minor 80-column/white space cleanup. > Does the driver maybe have to special case for the 8168 then? The > patch was specifically to get the 8168 working. I thought that would be the chip I have, but apparently I have the 8167. I also misread the SVN commit message, or else I wouldn't just have it reverted. Bye, Axel. From sbenedetto at mail.berlios.de Sat Aug 9 00:53:39 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 9 Aug 2008 00:53:39 +0200 Subject: [Haiku-commits] r26880 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808082253.m78MrduI013108@sheep.berlios.de> Author: sbenedetto Date: 2008-08-09 00:53:36 +0200 (Sat, 09 Aug 2008) New Revision: 26880 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26880&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h Log: Start porting udf - Cleaning up AllocationDescriptorList in order to follow our coding guidelines - Moving methods implentation outside the class I've already ported udf but I'm going to commit it one file at the time so it's easier to review, plus I still have to clean up the code. Please review. Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h 2008-08-08 15:37:43 UTC (rev 26879) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h 2008-08-08 22:53:36 UTC (rev 26880) @@ -1,27 +1,25 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ + #ifndef _UDF_ALLOCATION_DESCRIPTOR_LIST_H #define _UDF_ALLOCATION_DESCRIPTOR_LIST_H -/*! \file AllocationDescriptorList.h -*/ +/*! \file AllocationDescriptorList.h */ -#include "kernel_cpp.h" #include "UdfDebug.h" +#include "Icb.h" #include "UdfStructures.h" -#include "Icb.h" #include "Volume.h" -namespace Udf { +#include /*! \brief Common interface for dealing with the three standard forms of allocation descriptors used in UDF icbs. - + The \c Accessor class is an allocation descriptor accessor class for the allocation scheme of interest. Instances of it should be passable by value, and should define the following public members: @@ -35,227 +33,272 @@ class AllocationDescriptorList { private: typedef typename Accessor::DescriptorType Descriptor; + public: - AllocationDescriptorList(Icb *icb, Accessor accessor = Accessor()) - : fIcb(icb) - , fVolume(icb->GetVolume()) - , fIcbDescriptors(reinterpret_cast(icb->AllocationDescriptors())) - , fIcbDescriptorsSize(icb->AllocationDescriptorsSize()) - , fAdditionalDescriptors(icb->GetVolume()) - , fReadFromIcb(true) - , fAccessor(accessor) - , fDescriptorIndex(0) - , fDescriptorNumber(0) - , fBlockIndex(0) - { - DEBUG_INIT("AllocationDescriptorList<>"); - _WalkContinuationChain(_CurrentDescriptor()); - } - - /*! \brief Finds the extent for the given address in the stream, - returning it in the address pointed to by \a blockRun. - - \param start The byte address of interest - \param extent The extent containing the stream address given - by \c start. - \param isEmpty If set to true, indicates that the given extent is unrecorded - and thus its contents should be interpreted as all zeros. - */ - status_t FindExtent(off_t start, long_address *extent, bool *isEmpty) { - DEBUG_INIT_ETC("AllocationDescriptorList<>", - ("start: %Ld, extent: %p, isEmpty: %p", start, extent, isEmpty)); - off_t startBlock = start >> fVolume->BlockShift(); - - // This should never have to happen, as FindExtent is only called by - // Icb::_Read() sequentially as a file read is performed, but you - // never know. :-) - if (startBlock < _BlockIndex()) - _Rewind(); - - status_t error = B_OK; - while (true) { - Descriptor *descriptor = _CurrentDescriptor(); - if (descriptor) { - if (_BlockIndex() <= startBlock - && startBlock < _BlockIndex()+fAccessor.GetLength(*descriptor)) - { - // The start block is somewhere in this extent, so return - // the applicable tail end portion. - off_t offset = startBlock - _BlockIndex(); - extent->set_block(fAccessor.GetBlock(*descriptor)+offset); - extent->set_partition(fAccessor.GetPartition(*descriptor)); - extent->set_length(fAccessor.GetLength(*descriptor)-(offset*fVolume->BlockSize())); - extent->set_type(fAccessor.GetType(*descriptor)); - break; - } else { - _MoveToNextDescriptor(); - } + AllocationDescriptorList(Icb *icb, + Accessor accessor = Accessor()); + + status_t FindExtent(off_t start, long_address *extent, + bool *isEmpty); + +private: + + off_t _BlockIndex() const { return fBlockIndex; } + Descriptor *_CurrentDescriptor() const; + Descriptor *_DescriptorArray() const; + size_t _DescriptorArraySize() const; + int32 _DescriptorIndex() const { return fDescriptorIndex; } + int32 _DescriptorNumber() const { return fDescriptorNumber; } + status_t _MoveToNextDescriptor(); + void _Rewind(); + void _WalkContinuationChain(Descriptor *descriptor); + + CachedBlock fAdditionalDescriptors; + Icb *fIcb; + Descriptor *fIcbDescriptors; + int32 fIcbDescriptorsSize; + bool fReadFromIcb; + Volume *fVolume; + + Accessor fAccessor; + int32 fDescriptorIndex; + int32 fDescriptorNumber; + off_t fBlockIndex; +}; + + +template +AllocationDescriptorList::AllocationDescriptorList(Icb *icb, + Accessor accessor) + : + fAccessor(accessor), + fAdditionalDescriptors(icb->GetVolume()), + fBlockIndex(0), + fIcb(icb), + fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()), + fDescriptorIndex(0), + fDescriptorNumber(0), + fIcbDescriptorsSize(icb->AllocationDescriptorsSize()), + fReadFromIcb(true), + fVolume(icb->GetVolume()) +{ + DEBUG_INIT("AllocationDescriptorList<>"); + _WalkContinuationChain(_CurrentDescriptor()); +} + +/*! \brief Finds the extent for the given address in the stream, + returning it in the address pointed to by \a blockRun. + + \param start The byte address of interest + \param extent The extent containing the stream address given + by \c start. + \param isEmpty If set to true, indicates that the given extent is + unrecorded and thus its contents should be interpreted + as all zeros. +*/ +template +status_t +AllocationDescriptorList::FindExtent(off_t start, + long_address *extent, bool *isEmpty) +{ + TRACE(("UDF: AllocationDescriptorList<>::FindExtent: start: %Ld, " + "extent: %p, isEmpty: %p", start, extent, isEmpty)); + + off_t startBlock = start >> fVolume->BlockShift(); + + // This should never have to happen, as FindExtent is only called by + // Icb::_Read() sequentially, as a file read is performed, but you + // never know. :-) + if (startBlock < _BlockIndex()) + _Rewind(); + + status_t status = B_OK; + while (true) { + Descriptor *descriptor = _CurrentDescriptor(); + if (descriptor) { + if (_BlockIndex() <= startBlock && startBlock + < _BlockIndex() + fAccessor.GetLength(*descriptor)) { + // The start block is somewhere in this extent, so return + // the applicable tail end portion. + off_t offset = startBlock - _BlockIndex(); + extent->set_block(fAccessor.GetBlock(*descriptor) + offset); + extent->set_partition(fAccessor.GetPartition(*descriptor)); + extent->set_length(fAccessor.GetLength(*descriptor) + - (offset*fVolume->BlockSize())); + extent->set_type(fAccessor.GetType(*descriptor)); + break; } else { - PRINT(("Descriptor #%ld found NULL\n", _DescriptorNumber())); - error = B_ERROR; - break; + _MoveToNextDescriptor(); } + } else { + TRACE_ERROR(("UDF: AllocationDescriptorList<>::FindExtent: " + "Descriptor #%ld found NULL\n", _DescriptorNumber())); + status = B_ERROR; + break; } - RETURN(error); } -private: - - Descriptor* _CurrentDescriptor() const { - DEBUG_INIT("AllocationDescriptorList<>"); - PRINT(("(_DescriptorIndex()+1)*sizeof(Descriptor) = %ld\n", (_DescriptorIndex()+1)*sizeof(Descriptor))); - PRINT(("_DescriptorArraySize() = %ld\n", _DescriptorArraySize())); - PRINT(("_DescriptorArray() = %p\n", _DescriptorArray())); - return ((_DescriptorIndex()+1)*sizeof(Descriptor) <= _DescriptorArraySize()) - ? &(_DescriptorArray()[_DescriptorIndex()]) - : NULL; - } + return status; +} - status_t _MoveToNextDescriptor() { - DEBUG_INIT("AllocationDescriptorList<>"); - - Descriptor* descriptor = _CurrentDescriptor(); - if (!descriptor) { - RETURN(B_ENTRY_NOT_FOUND); - } else { - // Increment our indices and get the next descriptor - // from this extent. - fBlockIndex += fAccessor.GetLength(*descriptor); - fDescriptorIndex++; - fDescriptorNumber++; - descriptor = _CurrentDescriptor(); - - // If no such descriptor exists, we've run out of - // descriptors in this extent, and we're done. The - // next time _CurrentDescriptor() is called, it will - // return NULL, signifying this. Otherwise, we have to - // see if the new descriptor identifies the next extent - // of allocation descriptors, in which case we have to - // load up the appropriate extent (guaranteed to be at - // most one block in length by UDF-2.01 5.1 and UDF-2.01 - // 2.3.11). - _WalkContinuationChain(descriptor); - } - - - RETURN(B_ERROR); - } - - void _WalkContinuationChain(Descriptor *descriptor) { - DEBUG_INIT_ETC("AllocationDescriptorList<>", - ("descriptor: %p", descriptor)); - if (descriptor && fAccessor.GetType(*descriptor) == EXTENT_TYPE_CONTINUATION) { - // Load the new block, make sure we're not trying - // to read from the icb descriptors anymore, and - // reset the descriptor index. - fAdditionalDescriptors.SetTo(fAccessor, *descriptor); - fReadFromIcb = false; - fDescriptorIndex = 0; - - // Make sure that the first descriptor in this extent isn't - // another continuation. That would be stupid, but not - // technically illegal. - _WalkContinuationChain(_CurrentDescriptor()); - - } - - - } - - void _Rewind() { + +// #pragma - Private methods + +template +AllocationDescriptorList::Descriptor* +AllocationDescriptorList::_CurrentDescriptor() const +{ + DEBUG_INIT("AllocationDescriptorList<>"); + PRINT(("(_DescriptorIndex()+1)*sizeof(Descriptor) = %ld\n", (_DescriptorIndex()+1)*sizeof(Descriptor))); + PRINT(("_DescriptorArraySize() = %ld\n", _DescriptorArraySize())); + PRINT(("_DescriptorArray() = %p\n", _DescriptorArray())); + return ((_DescriptorIndex() + 1) * sizeof(Descriptor) + <= _DescriptorArraySize()) + ? &(_DescriptorArray()[_DescriptorIndex()]) + : NULL; +} + +template +status_t +AllocationDescriptorList::_MoveToNextDescriptor() +{ + Descriptor* descriptor = _CurrentDescriptor(); + if (!descriptor) + return B_ENTRY_NOT_FOUND; + + // Increment our indices and get the next descriptor + // from this extent. + fBlockIndex += fAccessor.GetLength(*descriptor); + fDescriptorIndex++; + fDescriptorNumber++; + descriptor = _CurrentDescriptor(); + + // If no such descriptor exists, we've run out of + // descriptors in this extent, and we're done. The + // next time _CurrentDescriptor() is called, it will + // return NULL, signifying this. Otherwise, we have to + // see if the new descriptor identifies the next extent + // of allocation descriptors, in which case we have to + // load up the appropriate extent (guaranteed to be at + // most one block in length by UDF-2.01 5.1 and UDF-2.01 + // 2.3.11). + _WalkContinuationChain(descriptor); + + return B_ERROR; +} + + +template +void +AllocationDescriptorList::_WalkContinuationChain(Descriptor *descriptor) +{ + if (descriptor + && fAccessor.GetType(*descriptor) == EXTENT_TYPE_CONTINUATION) { + // Load the new block, make sure we're not trying + // to read from the icb descriptors anymore, and + // reset the descriptor index. + fAdditionalDescriptors.SetTo(fAccessor, *descriptor); + fReadFromIcb = false; fDescriptorIndex = 0; - fDescriptorNumber = 0; - fReadFromIcb = true; - } - Descriptor *_DescriptorArray() const { - return fReadFromIcb - ? fIcbDescriptors - : reinterpret_cast(fAdditionalDescriptors.Block()); + // Make sure that the first descriptor in this extent isn't + // another continuation. That would be stupid, but not + // technically illegal. + _WalkContinuationChain(_CurrentDescriptor()); } - - size_t _DescriptorArraySize() const { - return fReadFromIcb ? fIcbDescriptorsSize : fAdditionalDescriptors.BlockSize(); - } - - int32 _DescriptorIndex() const { - return fDescriptorIndex; - } - - int32 _DescriptorNumber() const { - return fDescriptorNumber; - } - - off_t _BlockIndex() const { - return fBlockIndex; - } +} - Icb *fIcb; - Volume *fVolume; - Descriptor *fIcbDescriptors; - int32 fIcbDescriptorsSize; - CachedBlock fAdditionalDescriptors; - bool fReadFromIcb; - - Accessor fAccessor; - int32 fDescriptorIndex; - int32 fDescriptorNumber; - off_t fBlockIndex; - -}; -// Accessors +template +void +AllocationDescriptorList::_Rewind() +{ + fDescriptorIndex = 0; + fDescriptorNumber = 0; + fReadFromIcb = true; +} + +template +AllocationDescriptorList::Descriptor* +AllocationDescriptorList::_DescriptorArray() const +{ + return fReadFromIcb ? fIcbDescriptors + : (AllocationDescriptorList::Descriptor *) + fAdditionalDescriptors.Block(); +} + + +template +size_t +AllocationDescriptorList::_DescriptorArraySize() const +{ + return fReadFromIcb ? fIcbDescriptorsSize + : fAdditionalDescriptors.BlockSize(); +} + + +// pragma - Accessors + class ShortDescriptorAccessor { public: ShortDescriptorAccessor(uint16 partition) - : fPartition(partition) + : + fPartition(partition) { } - + typedef short_address DescriptorType; - inline uint8 GetType(DescriptorType &descriptor) const { - return descriptor.type(); + inline uint32 GetBlock(DescriptorType &descriptor) const + { + return descriptor.block(); } - inline uint32 GetBlock(DescriptorType &descriptor) const { - return descriptor.block(); + inline uint32 GetLength(DescriptorType &descriptor) const + { + return descriptor.length(); } - - inline uint16 GetPartition(DescriptorType &descriptor) const { + + inline uint16 GetPartition(DescriptorType &descriptor) const + { return fPartition; } - - inline uint32 GetLength(DescriptorType &descriptor) const { - return descriptor.length(); + + inline uint8 GetType(DescriptorType &descriptor) const + { + return descriptor.type(); } + private: - uint16 fPartition; + uint16 fPartition; }; + class LongDescriptorAccessor { public: typedef long_address DescriptorType; - inline uint8 GetType(DescriptorType &descriptor) const { - return descriptor.type(); + inline uint32 GetBlock(DescriptorType &descriptor) const + { + return descriptor.block(); } - inline uint32 GetBlock(DescriptorType &descriptor) const { - return descriptor.block(); + inline uint32 GetLength(DescriptorType &descriptor) const + { + return descriptor.length(); } - - inline uint16 GetPartition(DescriptorType &descriptor) const { + + inline uint16 GetPartition(DescriptorType &descriptor) const + { return descriptor.partition(); } - - inline uint32 GetLength(DescriptorType &descriptor) const { - return descriptor.length(); + + inline uint8 GetType(DescriptorType &descriptor) const + { + return descriptor.type(); } }; +#endif // _UDF_ALLOCATION_DESCRIPTOR_LIST_H -}; // namespace Udf - -#endif // _UDF_ALLOCATION_DESCRIPTOR_LIST_H From ingo_weinhold at gmx.de Sat Aug 9 01:02:39 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 09 Aug 2008 01:02:39 +0200 Subject: [Haiku-commits] r26825 - haiku/trunk/src/system/kernel/device_manager In-Reply-To: <200808052100.m75L03SL006727@sheep.berlios.de> References: <200808052100.m75L03SL006727@sheep.berlios.de> Message-ID: <20080809010239.739.1@knochen-vm.localdomain> On 2008-08-05 at 23:00:03 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-05 23:00:02 +0200 (Tue, 05 Aug 2008) > New Revision: 26825 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26825&view=rev > > Modified: > haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp > haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp > haiku/trunk/src/system/kernel/device_manager/dma_resources.h > Log: > * Added a DMAResource::Init() method that gets a device node - for now, it > will > reuse the block_io attributes in the node to build the dma_restrictions. > * DMAResource::Init() now dumps the dma_resources (should be done with the > TRACE() macro later). > * Turned off IOScheduler debug output. > > > Modified: haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp > 2008-08-05 20:42:34 UTC (rev 26824) > +++ haiku/trunk/src/system/kernel/device_manager/IOScheduler.cpp > 2008-08-05 21:00:02 UTC (rev 26825) > @@ -20,7 +20,7 @@ > #include > > > -#define TRACE_IO_SCHEDULER > +//#define TRACE_IO_SCHEDULER > #ifdef TRACE_IO_SCHEDULER > # define TRACE(x...) dprintf(x) > #else > > Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp > =================================================================== > --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp > 2008-08-05 20:42:34 UTC (rev 26824) > +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp > 2008-08-05 21:00:02 UTC (rev 26825) > @@ -6,6 +6,8 @@ > > #include "dma_resources.h" > > +#include > + > #include > #include > > @@ -20,6 +22,8 @@ > #endif > > > +extern device_manager_info gDeviceManagerModule; > + > const size_t kMaxBounceBufferSize = 4 * B_PAGE_SIZE; > > > @@ -95,6 +99,40 @@ > > > status_t > +DMAResource::Init(device_node* node, size_t blockSize) > +{ > + dma_restrictions restrictions; > + memset(&restrictions, 0, sizeof(dma_restrictions)); > + > + // TODO: add DMA attributes instead of reusing block_io's > + > + uint32 value; > + if (gDeviceManagerModule.get_attr_uint32(node, > + B_BLOCK_DEVICE_DMA_ALIGNMENT, &value, true) == B_OK) > + restrictions.alignment = value + 1; > + > + if (gDeviceManagerModule.get_attr_uint32(node, > + B_BLOCK_DEVICE_DMA_BOUNDARY, &value, true) == B_OK) > + restrictions.boundary = value + 1; > + > + if (gDeviceManagerModule.get_attr_uint32(node, > + B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &value, true) == B_OK) > + restrictions.max_segment_size = value; > + > + if (gDeviceManagerModule.get_attr_uint32(node, > + B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &value, true) == B_OK) > + restrictions.max_transfer_size = value * blockSize; > + > + uint32 bufferCount; > + if (gDeviceManagerModule.get_attr_uint32(node, > + B_BLOCK_DEVICE_MAX_SG_BLOCKS, &bufferCount, true) != B_OK) > + bufferCount = 16; > + > + return Init(restrictions, blockSize, bufferCount); > +} Is dma_restrictions::max_segment_count intentionally not set in case the B_BLOCK_DEVICE_MAX_SG_BLOCKS attribute exists? CU, Ingo From bonefish at mail.berlios.de Sat Aug 9 01:15:27 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Sat, 9 Aug 2008 01:15:27 +0200 Subject: [Haiku-commits] r26881 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808082315.m78NFRbp001616@sheep.berlios.de> Author: bonefish Date: 2008-08-09 01:15:21 +0200 (Sat, 09 Aug 2008) New Revision: 26881 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26881&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp Log: DMAResource::TranslateNext(), in case of given physical vecs: * segmentCount was potentially set incorrectly. It could be too big, since we considered all vecs, not only those remaining. * The main loop condition was incorrect. This would lead to too few DMABuffer vecs (or none at all) for any but the first IOOperation of a request. Should fix #2586. * Correctly offset by vecIndex in debug output. Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-08 22:53:36 UTC (rev 26880) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-08 23:15:21 UTC (rev 26881) @@ -444,14 +444,15 @@ // We do already have physical addresses. locker.Unlock(); vecs = buffer->Vecs(); - segmentCount = min_c(buffer->VecCount(), + segmentCount = min_c(buffer->VecCount() - vecIndex, fRestrictions.max_segment_count); } #ifdef TRACE_DMA_RESOURCE TRACE(" physical count %lu\n", segmentCount); for (uint32 i = 0; i < segmentCount; i++) { - TRACE(" [%lu] %p, %lu\n", i, vecs[i].iov_base, vecs[i].iov_len); + TRACE(" [%lu] %p, %lu\n", i, vecs[vecIndex + i].iov_base, + vecs[vecIndex + i].iov_len); } #endif @@ -488,7 +489,7 @@ "%lu\n", offset, length); } - for (uint32 i = vecIndex; i < segmentCount;) { + for (uint32 i = vecIndex; i < vecIndex + segmentCount;) { if (dmaBuffer->VecCount() >= fRestrictions.max_segment_count) break; From sbenedetto at mail.berlios.de Sat Aug 9 01:27:25 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 9 Aug 2008 01:27:25 +0200 Subject: [Haiku-commits] r26882 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808082327.m78NRPQ3015145@sheep.berlios.de> Author: sbenedetto Date: 2008-08-09 01:27:23 +0200 (Sat, 09 Aug 2008) New Revision: 26882 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26882&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.h Log: * Clean up Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.cpp 2008-08-08 23:15:21 UTC (rev 26881) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.cpp 2008-08-08 23:27:23 UTC (rev 26882) @@ -1,3 +1,8 @@ +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ + #include "DString.h" #include @@ -2,42 +7,46 @@ -using namespace Udf; - -/*! \brief Creates a useless, empty string object. -*/ +/*! \brief Creates a useless, empty string object. */ DString::DString() - : fString(NULL) - , fLength(0) + : + fLength(0), + fString(NULL) { } -/*! \brief Create a new DString object that is a copy of \a ref. -*/ + +/*! \brief Create a new DString object that is a copy of \a ref. */ DString::DString(const DString &ref) - : fString(NULL) - , fLength(0) + : + fLength(0), + fString(NULL) { SetTo(ref); } + /*! \brief Creates a new DString \a fieldLength bytes long that contains at most the first \c (fieldLength-1) bytes of \a string.Cs0(). -*/ -DString::DString(const Udf::String &string, uint8 fieldLength) - : fString(NULL) - , fLength(0) +*/ +DString::DString(const UdfString &string, uint8 fieldLength) + : + fLength(0), + fString(NULL) { SetTo(string, fieldLength); } + /*! \brief Creates a new DString \a fieldLength bytes long that contains at most the first \c (fieldLength-1) bytes of the Cs0 representation of the NULL-terminated UTF8 string \a utf8. -*/ +*/ DString::DString(const char *utf8, uint8 fieldLength) - : fString(NULL) - , fLength(0) + : + fLength(0), + fString(NULL) { SetTo(utf8, fieldLength); } + void @@ -55,11 +64,12 @@ } } + /*! \brief Sets the DString be \a fieldLength bytes long and contain at most the first \c (fieldLength-1) bytes of \a string.Cs0(). -*/ +*/ void -DString::SetTo(const Udf::String &string, uint8 fieldLength) +DString::SetTo(const UdfString &string, uint8 fieldLength) { _Clear(); if (fieldLength > 0) { @@ -70,44 +80,46 @@ // Figure out how many bytes to copy uint32 sourceLength = string.Cs0Length(); if (sourceLength > 0) { - uint8 destLength = sourceLength > uint8(fieldLength-1) - ? uint8(fieldLength-1) - : uint8(sourceLength); + uint8 destLength = sourceLength > uint8(fieldLength - 1) + ? uint8(fieldLength - 1) : uint8(sourceLength); // If the source string is 16-bit unicode, make sure any dangling // half-character at the end of the string is not copied - if (string.Cs0()[1] == '\x10' && destLength > 0 && destLength % 2 == 0) + if (string.Cs0()[1] == '\x10' && destLength > 0 + && destLength % 2 == 0) destLength--; // Copy memcpy(fString, string.Cs0(), destLength); // Zero any characters between the end of the string and // the terminating string length character - if (destLength < fieldLength-1) - memset(&fString[destLength], 0, fieldLength-1-destLength); + if (destLength < fieldLength - 1) + memset(&fString[destLength], 0, fieldLength - 1 - destLength); // Write the string length to the last character in the field - fString[fieldLength-1] = destLength; + fString[fieldLength - 1] = destLength; } else { // Empty strings are to contain all zeros memset(fString, 0, fieldLength); } } - } + } } + /*! \brief Sets the DString be \a fieldLength bytes long and contain at most the first \c (fieldLength-1) bytes of the Cs0 representation of the NULL-terminated UTF8 string \a utf8. -*/ +*/ void DString::SetTo(const char *utf8, uint8 fieldLength) { - Udf::String string(utf8); + UdfString string(utf8); SetTo(string, fieldLength); } + void DString::_Clear() { - DEBUG_INIT("DString"); + DEBUG_INIT("DString"); delete [] fString; fString = NULL; fLength = 0; Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.h 2008-08-08 23:15:21 UTC (rev 26881) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/DString.h 2008-08-08 23:27:23 UTC (rev 26882) @@ -1,47 +1,42 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _D_STRING_H #define _D_STRING_H -#include "kernel_cpp.h" -#include "UdfString.h" #include "UdfDebug.h" -namespace Udf { +#include "UdfString.h" -/*! \brief Fixed-length d-string class that takes a Udf::String as input +#include + +/*! \brief Fixed-length d-string class that takes a UdfString as input and provides a properly formatted ECMA-167 d-string of the given field length as ouput. - + For d-string info, see: ECMA-167 1/7.2.12, UDF-2.50 2.1.3 */ class DString { public: - DString(); - DString(const DString &ref); - DString(const Udf::String &string, uint8 fieldLength); - DString(const char *utf8, uint8 fieldLength); + DString(); + DString(const DString &ref); + DString(const UdfString &string, uint8 fieldLength); + DString(const char *utf8, uint8 fieldLength); - void SetTo(const DString &ref); - void SetTo(const Udf::String &string, uint8 fieldLength); - void SetTo(const char *utf8, uint8 fieldLength); + uint8 Length() const { return fLength; } - const uint8* String() const { return fString; } - uint8 Length() const { return fLength; } + void SetTo(const DString &ref); + void SetTo(const UdfString &string, uint8 fieldLength); + void SetTo(const char *utf8, uint8 fieldLength); + + const uint8* String() const { return fString; } private: - void _Clear(); + void _Clear(); - uint8 *fString; - uint8 fLength; + uint8 fLength; + uint8 *fString; }; -}; // namespace UDF - - - #endif // _D_STRING_H From sbenedetto at mail.berlios.de Sat Aug 9 10:14:41 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 9 Aug 2008 10:14:41 +0200 Subject: [Haiku-commits] r26883 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808090814.m798EfnU027936@sheep.berlios.de> Author: sbenedetto Date: 2008-08-09 10:14:40 +0200 (Sat, 09 Aug 2008) New Revision: 26883 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26883&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h Log: * Applied our coding guidelines Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h 2008-08-08 23:27:23 UTC (rev 26882) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h 2008-08-09 08:14:40 UTC (rev 26883) @@ -53,17 +53,16 @@ void _Rewind(); void _WalkContinuationChain(Descriptor *descriptor); + Accessor fAccessor; CachedBlock fAdditionalDescriptors; + off_t fBlockIndex; + int32 fDescriptorIndex; + int32 fDescriptorNumber; Icb *fIcb; Descriptor *fIcbDescriptors; int32 fIcbDescriptorsSize; bool fReadFromIcb; Volume *fVolume; - - Accessor fAccessor; - int32 fDescriptorIndex; - int32 fDescriptorNumber; - off_t fBlockIndex; }; @@ -74,10 +73,10 @@ fAccessor(accessor), fAdditionalDescriptors(icb->GetVolume()), fBlockIndex(0), - fIcb(icb), - fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()), fDescriptorIndex(0), fDescriptorNumber(0), + fIcb(icb), + fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()), fIcbDescriptorsSize(icb->AllocationDescriptorsSize()), fReadFromIcb(true), fVolume(icb->GetVolume()) Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp 2008-08-08 23:27:23 UTC (rev 26882) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp 2008-08-09 08:14:40 UTC (rev 26883) @@ -1,25 +1,20 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ -/*! \file DirectoryIterator.cpp -*/ +/*! \file DirectoryIterator.cpp */ #include "DirectoryIterator.h" -#include -#include - #include "Icb.h" - #include "UdfString.h" #include "Utils.h" -using namespace Udf; +#include +#include + status_t DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) { @@ -32,7 +27,6 @@ PRINT(("fPosition: %Ld\n", fPosition)); PRINT(("Parent()->Length(): %Ld\n", Parent()->Length())); - status_t error = B_OK; if (fAtBeginning) { sprintf(name, "."); @@ -41,65 +35,62 @@ fAtBeginning = false; } else { - if (uint64(fPosition) >= Parent()->Length()) - RETURN(B_ENTRY_NOT_FOUND); + if (uint64(fPosition) >= Parent()->Length()) + RETURN(B_ENTRY_NOT_FOUND); - uint8 data[kMaxFileIdSize]; - file_id_descriptor *entry = reinterpret_cast(data); + uint8 data[kMaxFileIdSize]; + file_id_descriptor *entry = reinterpret_cast(data); - uint32 block = 0; - off_t offset = fPosition; + uint32 block = 0; + off_t offset = fPosition; - size_t entryLength = kMaxFileIdSize; - // First read in the static portion of the file id descriptor, - // then, based on the information therein, read in the variable - // length tail portion as well. - error = Parent()->Read(offset, entry, &entryLength, &block); - if (!error && entryLength >= sizeof(file_id_descriptor) && entry->tag().init_check(block) == B_OK) { - PDUMP(entry); - offset += entry->total_length(); - - if (entry->is_parent()) { - sprintf(name, ".."); - *length = 3; - } else { - String string(entry->id(), entry->id_length()); - PRINT(("id == `%s'\n", string.Utf8())); - DUMP(entry->icb()); - sprintf(name, "%s", string.Utf8()); - *length = string.Utf8Length(); - } - *id = to_vnode_id(entry->icb()); - } + size_t entryLength = kMaxFileIdSize; + // First read in the static portion of the file id descriptor, + // then, based on the information therein, read in the variable + // length tail portion as well. + error = Parent()->Read(offset, entry, &entryLength, &block); + if (!error && entryLength >= sizeof(file_id_descriptor) + && entry->tag().init_check(block) == B_OK) { + PDUMP(entry); + offset += entry->total_length(); - if (!error) - fPosition = offset; + if (entry->is_parent()) { + sprintf(name, ".."); + *length = 3; + } else { + UdfString string(entry->id(), entry->id_length()); + PRINT(("id == `%s'\n", string.Utf8())); + DUMP(entry->icb()); + sprintf(name, "%s", string.Utf8()); + *length = string.Utf8Length(); + } + *id = to_vnode_id(entry->icb()); + } + + if (!error) + fPosition = offset; } - + RETURN(error); } -/* \brief Rewinds the iterator to point to the first - entry in the directory. -*/ + +/* \brief Rewinds the iterator to point to the first entry in the directory. */ void DirectoryIterator::Rewind() { - fPosition = 0; fAtBeginning = true; + fPosition = 0; } + +// #pragma - Private methods + + DirectoryIterator::DirectoryIterator(Icb *parent) - : fParent(parent) - , fPosition(0) - , fAtBeginning(true) + : + fAtBeginning(true), + fParent(parent), + fPosition(0) { } - -void -DirectoryIterator::Invalidate() -{ - fParent = NULL; -} - - Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h 2008-08-08 23:27:23 UTC (rev 26882) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h 2008-08-09 08:14:40 UTC (rev 26883) @@ -1,54 +1,40 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_DIRECTORY_ITERATOR_H #define _UDF_DIRECTORY_ITERATOR_H -/*! \file DirectoryIterator.h -*/ +/*! \file DirectoryIterator.h */ -#ifndef _IMPEXP_KERNEL -# define _IMPEXP_KERNEL -#endif -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif - -#include "kernel_cpp.h" #include "UdfDebug.h" -namespace Udf { +#include class Icb; class DirectoryIterator { public: - status_t GetNextEntry(char *name, uint32 *length, ino_t *id); - void Rewind(); - - Icb* Parent() { return fParent; } - const Icb* Parent() const { return fParent; } - + status_t GetNextEntry(char *name, uint32 *length, + ino_t *id); + + Icb *Parent() { return fParent; } + const Icb *Parent() const { return fParent; } + + void Rewind(); + private: - friend class Icb; +friend class Icb; - DirectoryIterator(); // unimplemented - DirectoryIterator(Icb *parent); // called by Icb::GetDirectoryIterator() - void Invalidate(); // called by Icb::~Icb() + /* The following is called by Icb::GetDirectoryIterator() */ + DirectoryIterator(Icb *parent); + /* The following is called by Icb::~Icb() */ + void _Invalidate() { fParent = NULL; } - Icb *fParent; - off_t fPosition; - bool fAtBeginning; + bool fAtBeginning; + Icb *fParent; + off_t fPosition; }; -}; // namespace Udf - #endif // _UDF_DIRECTORY_ITERATOR_H From axeld at pinc-software.de Sat Aug 9 10:27:37 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 09 Aug 2008 10:27:37 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26880_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/file=5Fsystems/udf?= In-Reply-To: <200808082253.m78MrduI013108@sheep.berlios.de> Message-ID: <2748284332-BeMail@zon> sbenedetto at BerliOS wrote: > Log: > Start porting udf > - Cleaning up AllocationDescriptorList in order to follow our coding > guidelines > - Moving methods implentation outside the class > > I've already ported udf but I'm going to commit it one file at the > time > so it's easier to review, plus I still have to clean up the code. It would be preferred if you don't mix cleanup with functional changes - that would also make it much easier to review. So please go ahead, and commit the UDF port at once, and do the cleanup later. Or do you mean cleanup of your own changes only in this case? Bye, Axel. From sbenedetto at mail.berlios.de Sat Aug 9 10:32:49 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 9 Aug 2008 10:32:49 +0200 Subject: [Haiku-commits] r26884 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808090832.m798WnL5028749@sheep.berlios.de> Author: sbenedetto Date: 2008-08-09 10:32:48 +0200 (Sat, 09 Aug 2008) New Revision: 26884 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26884&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.h Log: * Clean up continues * Removing _IMPEXP_KERNEL macro along with the COMPILE_FOR_R5 macro * Also removing Udf namespace Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.cpp 2008-08-09 08:14:40 UTC (rev 26883) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.cpp 2008-08-09 08:32:48 UTC (rev 26884) @@ -1,54 +1,83 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ -/*! \file Utils.cpp +/*! \file Utils.cpp - Miscellaneous Udf utility functions. */ - Miscellaneous Udf utility functions. -*/ - #include "Utils.h" extern "C" { - #ifndef _IMPEXP_KERNEL - # define _IMPEXP_KERNEL - #endif - extern int32 timezone_offset; } +/*! \brief Returns "true" if \a value is true, "false" otherwise. */ +const char* +bool_to_string(bool value) +{ + return value ? "true" : "false"; +} -namespace Udf { -long_address -to_long_address(ino_t id, uint32 length) +/*! \brief Calculates the UDF crc checksum for the given byte stream. + + Based on crc code from UDF-2.50 6.5, as permitted. + + \param data Pointer to the byte stream. + \param length Length of the byte stream in bytes. + + \return The crc checksum, or 0 if an error occurred. +*/ +uint16 +calculate_crc(uint8 *data, uint16 length) { - DEBUG_INIT_ETC(NULL, ("ino_t: %Ld (0x%Lx), length: %ld", id, id, length)); - long_address result; - result.set_block((id >> 16) & 0xffffffff); - result.set_partition(id & 0xffff); - result.set_length(length); - DUMP(result); - return result; + uint16 crc = 0; + if (data) { + for ( ; length > 0; length--, data++) + crc = kCrcTable[(crc >> 8 ^ *data) & 0xff] ^ (crc << 8); + } + return crc; } -ino_t -to_vnode_id(long_address address) + +/*! \brief Takes an overloaded ssize_t return value like those returned + by BFile::Read() and friends, as well as an expected number of bytes, + and returns B_OK if the byte counts match, or the appropriate error + code otherwise. +*/ +status_t +check_size_error(ssize_t bytesReturned, ssize_t bytesExpected) { - DEBUG_INIT(NULL); - ino_t result = address.block(); - result <<= 16; - result |= address.partition(); - PRINT(("block: %ld, 0x%lx\n", address.block(), address.block())); - PRINT(("partition: %d, 0x%x\n", address.partition(), address.partition())); - PRINT(("length: %ld, 0x%lx\n", address.length(), address.length())); - PRINT(("ino_t: %Ld, 0x%Lx\n", result, result)); - return result; + return bytesReturned == bytesExpected + ? B_OK : (bytesReturned >= 0 ? B_IO_ERROR : status_t(bytesReturned)); } + +/*! \brief Calculates the block shift amount for the given + block size, which must be a positive power of 2. +*/ +status_t +get_block_shift(uint32 blockSize, uint32 &blockShift) +{ + if (blockSize == 0) + return B_BAD_VALUE; + uint32 bitCount = 0; + uint32 result = 0; + for (int i = 0; i < 32; i++) { + // Zero out all bits except bit i + uint32 block = blockSize & (uint32(1) << i); + if (block) { + if (++bitCount > 1) + return B_BAD_VALUE; + else + result = i; + } + } + blockShift = result; + return B_OK; +} + + time_t make_time(timestamp ×tamp) { @@ -59,9 +88,10 @@ timestamp.month(), timestamp.day(), timestamp.hour(), timestamp.minute(), timestamp.second())); time_t result = 0; - + if (timestamp.year() >= 1970) { - const int monthLengths[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + const int monthLengths[12] + = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int year = timestamp.year(); int month = timestamp.month(); @@ -78,12 +108,12 @@ if (-1440 > timezone_offset || timezone_offset > 1440) timezone_offset = 0; timezone_offset -= timezone_offset % 60; - + int previousLeapYears = (year - 1968) / 4; bool isLeapYear = (year - 1968) % 4 == 0; if (isLeapYear) --previousLeapYears; - + // Years to days result = (year - 1970) * 365 + previousLeapYears; // Months to days @@ -97,77 +127,36 @@ // Hours to minutes result = (result + hour) * 60 + timezone_offset; // Minutes to seconds - result = (result + minute) * 60 + second; + result = (result + minute) * 60 + second; } - + return result; } -/*! \brief Calculates the block shift amount for the given - block size, which must be a positive power of 2. -*/ -status_t -Udf::get_block_shift(uint32 blockSize, uint32 &blockShift) -{ - if (blockSize == 0) - return B_BAD_VALUE; - uint32 bitCount = 0; - uint32 result = 0; - for (int i = 0; i < 32; i++) { - // Zero out all bits except bit i - uint32 block = blockSize & (uint32(1) << i); - if (block) { - if (++bitCount > 1) { - return B_BAD_VALUE; - } else { - result = i; - } - } - } - blockShift = result; - return B_OK; -} -/*! \brief Returns "true" if \a value is true, "false" otherwise. -*/ -const char* -Udf::bool_to_string(bool value) +long_address +to_long_address(ino_t id, uint32 length) { - return value ? "true" : "false"; + DEBUG_INIT_ETC(NULL, ("ino_t: %Ld (0x%Lx), length: %ld", id, id, length)); + long_address result; + result.set_block((id >> 16) & 0xffffffff); + result.set_partition(id & 0xffff); + result.set_length(length); + DUMP(result); + return result; } -/*! \brief Takes an overloaded ssize_t return value like those returned - by BFile::Read() and friends, as well as an expected number of bytes, - and returns B_OK if the byte counts match, or the appropriate error - code otherwise. -*/ -status_t -Udf::check_size_error(ssize_t bytesReturned, ssize_t bytesExpected) -{ - return bytesReturned == bytesExpected - ? B_OK - : (bytesReturned >= 0 ? B_IO_ERROR : status_t(bytesReturned)); -} -/*! \brief Calculates the UDF crc checksum for the given byte stream. - - Based on crc code from UDF-2.50 6.5, as permitted. - - \param data Pointer to the byte stream. - \param length Length of the byte stream in bytes. - - \return The crc checksum, or 0 if an error occurred. -*/ -uint16 -Udf::calculate_crc(uint8 *data, uint16 length) +ino_t +to_vnode_id(long_address address) { - uint16 crc = 0; - if (data) { - for ( ; length > 0; length--, data++) - crc = Udf::kCrcTable[(crc >> 8 ^ *data) & 0xff] ^ (crc << 8); - } - return crc; + DEBUG_INIT(NULL); + ino_t result = address.block(); + result <<= 16; + result |= address.partition(); + PRINT(("block: %ld, 0x%lx\n", address.block(), address.block())); + PRINT(("partition: %d, 0x%x\n", address.partition(), address.partition())); + PRINT(("length: %ld, 0x%lx\n", address.length(), address.length())); + PRINT(("ino_t: %Ld, 0x%Lx\n", result, result)); + return result; } - -} // namespace Udf - Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.h 2008-08-09 08:14:40 UTC (rev 26883) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Utils.h 2008-08-09 08:32:48 UTC (rev 26884) @@ -1,47 +1,20 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_UTILS_H #define _UDF_UTILS_H -/*! \file Utils.h +/*! \file Utils.h - Miscellaneous Udf utility functions. */ - Miscellaneous Udf utility functions. -*/ - -#ifndef _IMPEXP_KERNEL -# define _IMPEXP_KERNEL -#endif -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif - #include "UdfStructures.h" -namespace Udf { +const char *bool_to_string(bool value); +uint16 calculate_crc(uint8 *data, uint16 length); +status_t check_size_error(ssize_t bytesReturned, ssize_t bytesExpected); +status_t get_block_shift(uint32 blockSize, uint32 &blockShift); +time_t make_time(timestamp ×tamp); +long_address to_long_address(ino_t id, uint32 length = 0); +ino_t to_vnode_id(long_address address); -long_address to_long_address(ino_t id, uint32 length = 0); - -ino_t to_vnode_id(long_address address); - -time_t make_time(timestamp ×tamp); - -status_t get_block_shift(uint32 blockSize, uint32 &blockShift); - -const char* bool_to_string(bool value); - -status_t check_size_error(ssize_t bytesReturned, ssize_t bytesExpected); - -uint16 calculate_crc(uint8 *data, uint16 length); - -} // namespace Udf - #endif // _UDF_UTILS_H - From emitrax at gmail.com Sat Aug 9 10:33:59 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Sat, 9 Aug 2008 08:33:59 +0000 Subject: [Haiku-commits] r26880 - haiku/trunk/src/add-ons/kernel/file_systems/udf In-Reply-To: <2748284332-BeMail@zon> References: <200808082253.m78MrduI013108@sheep.berlios.de> <2748284332-BeMail@zon> Message-ID: 2008/8/9 Axel D?rfler : > sbenedetto at BerliOS wrote: >> Log: >> Start porting udf >> - Cleaning up AllocationDescriptorList in order to follow our coding >> guidelines >> - Moving methods implentation outside the class >> >> I've already ported udf but I'm going to commit it one file at the >> time >> so it's easier to review, plus I still have to clean up the code. > > It would be preferred if you don't mix cleanup with functional changes > - that would also make it much easier to review. So please go ahead, > and commit the UDF port at once, and do the cleanup later. Ok, I'll do that. > Or do you mean cleanup of your own changes only in this case? Actually both. 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 Aug 9 11:05:24 2008 From: julun at mail.berlios.de (julun at BerliOS) Date: Sat, 9 Aug 2008 11:05:24 +0200 Subject: [Haiku-commits] r26885 - haiku/trunk/src/apps/people Message-ID: <200808090905.m7995OhS030374@sheep.berlios.de> Author: julun Date: 2008-08-09 11:05:24 +0200 (Sat, 09 Aug 2008) New Revision: 26885 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26885&view=rev Modified: haiku/trunk/src/apps/people/PeopleApp.cpp Log: * fix warning Modified: haiku/trunk/src/apps/people/PeopleApp.cpp =================================================================== --- haiku/trunk/src/apps/people/PeopleApp.cpp 2008-08-09 08:32:48 UTC (rev 26884) +++ haiku/trunk/src/apps/people/PeopleApp.cpp 2008-08-09 09:05:24 UTC (rev 26885) @@ -1,5 +1,5 @@ /* - * Copyright 2005, Haiku, Inc. + * Copyright 2005 - 2008, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -43,7 +43,7 @@ { "META:email", 120, "E-mail" }, { "META:url", 120, "URL" }, { "META:group", 120, "Group" }, - { NULL, NULL } + { NULL, 0, NULL } }; From axeld at mail.berlios.de Sat Aug 9 11:43:20 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 9 Aug 2008 11:43:20 +0200 Subject: [Haiku-commits] r26886 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 Message-ID: <200808090943.m799hKo8000297@sheep.berlios.de> Author: axeld Date: 2008-08-09 11:43:19 +0200 (Sat, 09 Aug 2008) New Revision: 26886 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26886&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.h Log: * Now uses different base addresses for mapping the registers depending on the chipset. This should now finally fix bug #1853. * Instead of reading values directly from the PCI config space, we now just use the pci_info structure to retrieve them (interrupt, and base address). * Renamed alloc_mem() to alloc_contiguous() to make clearer what it does. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-09 09:05:24 UTC (rev 26885) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/device.c 2008-08-09 09:43:19 UTC (rev 26886) @@ -281,13 +281,13 @@ void *rx_buf_virt, *rx_buf_phy; int i; - device->txBufArea = alloc_mem(&tx_buf_virt, &tx_buf_phy, + device->txBufArea = alloc_contiguous(&tx_buf_virt, &tx_buf_phy, device->txBufferCount * FRAME_SIZE, 0, "rtl8169 tx buf"); - device->rxBufArea = alloc_mem(&rx_buf_virt, &rx_buf_phy, + device->rxBufArea = alloc_contiguous(&rx_buf_virt, &rx_buf_phy, device->rxBufferCount * FRAME_SIZE, 0, "rtl8169 rx buf"); - device->txDescArea = alloc_mem(&tx_buf_desc_virt, &tx_buf_desc_phy, + device->txDescArea = alloc_contiguous(&tx_buf_desc_virt, &tx_buf_desc_phy, device->txBufferCount * sizeof(buf_desc), 0, "rtl8169 tx desc"); - device->rxDescArea = alloc_mem(&rx_buf_desc_virt, &rx_buf_desc_phy, + device->rxDescArea = alloc_contiguous(&rx_buf_desc_virt, &rx_buf_desc_phy, device->rxBufferCount * sizeof(buf_desc), 0, "rtl8169 rx desc"); if (device->txBufArea < B_OK || device->rxBufArea < B_OK || device->txDescArea < B_OK || device->rxDescArea < B_OK) @@ -433,6 +433,7 @@ { rtl8169_device *device; char *deviceName; + int mmioIndex; uint32 val; int dev_id; int mask; @@ -480,7 +481,6 @@ device->rxIntIndex = 0; device->rxFree = device->rxBufferCount; device->rxReadySem = create_sem(0, "rtl8169 rx ready"); - set_sem_owner(device->rxReadySem, B_SYSTEM_TEAM); device->txBuf = (void **)malloc(sizeof(void *) * device->txBufferCount); B_INITIALIZE_SPINLOCK(&device->txSpinlock); @@ -488,7 +488,6 @@ device->txIntIndex = 0; device->txUsed = 0; device->txFreeSem = create_sem(device->txBufferCount, "rtl8169 tx free"); - set_sem_owner(device->txFreeSem, B_SYSTEM_TEAM); // enable busmaster and memory mapped access, disable io port access val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, @@ -503,9 +502,7 @@ device->pciInfo->function, PCI_latency, 1, 0x40); // get IRQ - device->irq = gPci->read_pci_config(device->pciInfo->bus, - device->pciInfo->device, device->pciInfo->function, PCI_interrupt_line, - 1); + device->irq = device->pciInfo->u.h0.interrupt_line; if (device->irq == 0 || device->irq == 0xff) { ERROR("no IRQ assigned\n"); goto err; @@ -514,11 +511,17 @@ TRACE("IRQ %d\n", device->irq); // map registers into memory - val = gPci->read_pci_config(device->pciInfo->bus, device->pciInfo->device, - device->pciInfo->function, 0x14, 4); - val &= PCI_address_memory_32_mask; - TRACE("hardware register address %p\n", (void *) val); - device->regArea = map_mem(&device->regAddr, (void *)val, 256, 0, + + if (device->pciInfo->device == 0x8168) + mmioIndex = 0; + else + mmioIndex = 1; + + TRACE("hardware register address %p\n", + (void *)device->pciInfo->u.h0.base_registers[mmioIndex]); + + device->regArea = map_mem(&device->regAddr, + (void *)device->pciInfo->u.h0.base_registers[mmioIndex], 256, 0, "rtl8169 register"); if (device->regArea < B_OK) { ERROR("can't map hardware registers\n"); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c 2008-08-09 09:05:24 UTC (rev 26885) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c 2008-08-09 09:43:19 UTC (rev 26886) @@ -34,7 +34,7 @@ area_id -alloc_mem(void **virt, void **phy, size_t size, uint32 protection, +alloc_contiguous(void **virt, void **phy, size_t size, uint32 protection, const char *name) { physical_entry pe; @@ -81,7 +81,7 @@ offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (char *)phy - offset; size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_ADDRESS, protection, &mapadr); if (area < B_OK) { ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area)); Modified: haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.h 2008-08-09 09:05:24 UTC (rev 26885) +++ haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.h 2008-08-09 09:43:19 UTC (rev 26886) @@ -1,7 +1,7 @@ /* Realtek RTL8169 Family Driver * Copyright (C) 2004 Marcus Overhagen . All rights reserved. * - * Permission to use, copy, modify and distribute this software and its + * Permission to use, copy, modify and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies, and that both the * copyright notice and this permission notice appear in supporting documentation. @@ -21,7 +21,8 @@ #include -area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name); +area_id alloc_contiguous(void **virt, void **phy, size_t size, + uint32 protection, const char *name); area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name); #endif From axeld at pinc-software.de Sat Aug 9 11:47:29 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 09 Aug 2008 11:47:29 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26881_-_haiku/trunk/src/system/kernel/?= =?utf-8?q?device=5Fmanager?= In-Reply-To: <200808082315.m78NFRbp001616@sheep.berlios.de> Message-ID: <7540236508-BeMail@zon> bonefish at mail.berlios.de wrote: > - segmentCount = min_c(buffer->VecCount(), > + segmentCount = min_c(buffer->VecCount() - vecIndex, > fRestrictions.max_segment_count); [...] > - for (uint32 i = vecIndex; i < segmentCount;) { > + for (uint32 i = vecIndex; i < vecIndex + segmentCount;) { At least it fit together well ;-) But since "this is hardcode" - have you eventually added any tests to our dma_resource_test driver that would have triggered that bug? Bye, Axel. From axeld at pinc-software.de Sat Aug 9 11:50:42 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sat, 09 Aug 2008 11:50:42 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26847_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/audio/hda?= In-Reply-To: Message-ID: <7733341251-BeMail@zon> "J?r?me Duval" wrote: > 2008/8/7 Stephan Assmus : > > Congratulations to J?r?me for getting the native HDA driver to > > work, but to > > tell you the thruth, I am a bit torn about the effort on the native > > drives. > > With OSS, I see a chance to ease our lifes a bit just like the > > FreeBSD > > compatibility layer did for network drivers. I would be the first > > to agree > To tell the truth, my audio card didn't work with OSS, a good reason > to implement a native driver. > I think also Linux people now keep away from OSS. Just an update: it now works, as expected, flawlessly on my desktop machine (there it worked before with the multi_audio_test driver). It's very silent, though, so we might want to implement at least the main volume slider for hda :-) I still don't hear anything on my laptop, but I'll have a look at that some day. Also, I can now easily reproduce the audio stuttering when moving windows around or doing something similar. I'll have a look into this next, and will add a few debugging capabilities into our scheduler. Bye, Axel. From mmu_man at mail.berlios.de Sat Aug 9 12:46:36 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 9 Aug 2008 12:46:36 +0200 Subject: [Haiku-commits] r26887 - in haiku/vendor: . wget wget/current wget/current/doc wget/current/m4 wget/current/po wget/current/src wget/current/util wget/current/windows Message-ID: <200808091046.m79AkaSE024029@sheep.berlios.de> Author: mmu_man Date: 2008-08-09 12:46:09 +0200 (Sat, 09 Aug 2008) New Revision: 26887 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26887&view=rev Added: haiku/vendor/wget/ haiku/vendor/wget/current/ haiku/vendor/wget/current/AUTHORS haiku/vendor/wget/current/COPYING haiku/vendor/wget/current/ChangeLog haiku/vendor/wget/current/ChangeLog.README haiku/vendor/wget/current/INSTALL haiku/vendor/wget/current/MAILING-LIST haiku/vendor/wget/current/Makefile.in haiku/vendor/wget/current/NEWS haiku/vendor/wget/current/PATCHES haiku/vendor/wget/current/README haiku/vendor/wget/current/README.checkout haiku/vendor/wget/current/TODO haiku/vendor/wget/current/autogen.sh haiku/vendor/wget/current/config.guess haiku/vendor/wget/current/config.rpath haiku/vendor/wget/current/config.sub haiku/vendor/wget/current/configure haiku/vendor/wget/current/configure.bat haiku/vendor/wget/current/configure.bat.in haiku/vendor/wget/current/configure.in haiku/vendor/wget/current/doc/ haiku/vendor/wget/current/doc/ChangeLog haiku/vendor/wget/current/doc/Makefile.in haiku/vendor/wget/current/doc/ansi2knr.1 haiku/vendor/wget/current/doc/fdl.texi haiku/vendor/wget/current/doc/gpl.texi haiku/vendor/wget/current/doc/sample.wgetrc haiku/vendor/wget/current/doc/sample.wgetrc.munged_for_texi_inclusion haiku/vendor/wget/current/doc/texi2pod.pl.in haiku/vendor/wget/current/doc/texinfo.tex haiku/vendor/wget/current/doc/version.texi haiku/vendor/wget/current/doc/wget.info haiku/vendor/wget/current/doc/wget.texi haiku/vendor/wget/current/install-sh haiku/vendor/wget/current/m4/ haiku/vendor/wget/current/m4/lib-ld.m4 haiku/vendor/wget/current/m4/lib-link.m4 haiku/vendor/wget/current/m4/lib-prefix.m4 haiku/vendor/wget/current/m4/wget.m4 haiku/vendor/wget/current/mkinstalldirs haiku/vendor/wget/current/po/ haiku/vendor/wget/current/po/Makefile.in.in haiku/vendor/wget/current/po/POTFILES.in haiku/vendor/wget/current/po/bg.po haiku/vendor/wget/current/po/ca.po haiku/vendor/wget/current/po/cs.po haiku/vendor/wget/current/po/da.po haiku/vendor/wget/current/po/de.po haiku/vendor/wget/current/po/el.po haiku/vendor/wget/current/po/en_GB.po haiku/vendor/wget/current/po/eo.po haiku/vendor/wget/current/po/es.po haiku/vendor/wget/current/po/et.po haiku/vendor/wget/current/po/eu.po haiku/vendor/wget/current/po/fi.po haiku/vendor/wget/current/po/fr.po haiku/vendor/wget/current/po/ga.po haiku/vendor/wget/current/po/gl.po haiku/vendor/wget/current/po/he.po haiku/vendor/wget/current/po/hr.po haiku/vendor/wget/current/po/hu.po haiku/vendor/wget/current/po/it.po haiku/vendor/wget/current/po/ja.po haiku/vendor/wget/current/po/nl.po haiku/vendor/wget/current/po/no.po haiku/vendor/wget/current/po/pl.po haiku/vendor/wget/current/po/pt_BR.po haiku/vendor/wget/current/po/ro.po haiku/vendor/wget/current/po/ru.po haiku/vendor/wget/current/po/sk.po haiku/vendor/wget/current/po/sl.po haiku/vendor/wget/current/po/sr.po haiku/vendor/wget/current/po/sv.po haiku/vendor/wget/current/po/tr.po haiku/vendor/wget/current/po/uk.po haiku/vendor/wget/current/po/vi.po haiku/vendor/wget/current/po/zh_CN.po haiku/vendor/wget/current/po/zh_TW.po haiku/vendor/wget/current/src/ haiku/vendor/wget/current/src/ChangeLog haiku/vendor/wget/current/src/Makefile.in haiku/vendor/wget/current/src/alloca.c haiku/vendor/wget/current/src/ansi2knr.c haiku/vendor/wget/current/src/cmpt.c haiku/vendor/wget/current/src/config-post.h haiku/vendor/wget/current/src/config.h.in haiku/vendor/wget/current/src/connect.c haiku/vendor/wget/current/src/connect.h haiku/vendor/wget/current/src/convert.c haiku/vendor/wget/current/src/convert.h haiku/vendor/wget/current/src/cookies.c haiku/vendor/wget/current/src/cookies.h haiku/vendor/wget/current/src/ftp-basic.c haiku/vendor/wget/current/src/ftp-ls.c haiku/vendor/wget/current/src/ftp-opie.c haiku/vendor/wget/current/src/ftp.c haiku/vendor/wget/current/src/ftp.h haiku/vendor/wget/current/src/gen-md5.c haiku/vendor/wget/current/src/gen-md5.h haiku/vendor/wget/current/src/getopt.c haiku/vendor/wget/current/src/getopt.h haiku/vendor/wget/current/src/gnu-md5.c haiku/vendor/wget/current/src/gnu-md5.h haiku/vendor/wget/current/src/hash.c haiku/vendor/wget/current/src/hash.h haiku/vendor/wget/current/src/host.c haiku/vendor/wget/current/src/host.h haiku/vendor/wget/current/src/html-parse.c haiku/vendor/wget/current/src/html-parse.h haiku/vendor/wget/current/src/html-url.c haiku/vendor/wget/current/src/http-ntlm.c haiku/vendor/wget/current/src/http-ntlm.h haiku/vendor/wget/current/src/http.c haiku/vendor/wget/current/src/init.c haiku/vendor/wget/current/src/init.h haiku/vendor/wget/current/src/log.c haiku/vendor/wget/current/src/log.h haiku/vendor/wget/current/src/main.c haiku/vendor/wget/current/src/mswindows.c haiku/vendor/wget/current/src/mswindows.h haiku/vendor/wget/current/src/netrc.c haiku/vendor/wget/current/src/netrc.h haiku/vendor/wget/current/src/openssl.c haiku/vendor/wget/current/src/options.h haiku/vendor/wget/current/src/progress.c haiku/vendor/wget/current/src/progress.h haiku/vendor/wget/current/src/ptimer.c haiku/vendor/wget/current/src/ptimer.h haiku/vendor/wget/current/src/recur.c haiku/vendor/wget/current/src/recur.h haiku/vendor/wget/current/src/res.c haiku/vendor/wget/current/src/res.h haiku/vendor/wget/current/src/retr.c haiku/vendor/wget/current/src/retr.h haiku/vendor/wget/current/src/safe-ctype.c haiku/vendor/wget/current/src/safe-ctype.h haiku/vendor/wget/current/src/snprintf.c haiku/vendor/wget/current/src/ssl.h haiku/vendor/wget/current/src/sysdep.h haiku/vendor/wget/current/src/url.c haiku/vendor/wget/current/src/url.h haiku/vendor/wget/current/src/utils.c haiku/vendor/wget/current/src/utils.h haiku/vendor/wget/current/src/version.c haiku/vendor/wget/current/src/wget.h haiku/vendor/wget/current/src/xmalloc.c haiku/vendor/wget/current/src/xmalloc.h haiku/vendor/wget/current/stamp-h.in haiku/vendor/wget/current/util/ haiku/vendor/wget/current/util/Makefile.in haiku/vendor/wget/current/util/README haiku/vendor/wget/current/util/dist-wget haiku/vendor/wget/current/util/download-netscape.html haiku/vendor/wget/current/util/download.html haiku/vendor/wget/current/util/rmold.pl haiku/vendor/wget/current/util/update_po_files.sh haiku/vendor/wget/current/util/wget.spec haiku/vendor/wget/current/windows/ haiku/vendor/wget/current/windows/ChangeLog haiku/vendor/wget/current/windows/Makefile.doc haiku/vendor/wget/current/windows/Makefile.in haiku/vendor/wget/current/windows/Makefile.src haiku/vendor/wget/current/windows/Makefile.src.bor haiku/vendor/wget/current/windows/Makefile.src.mingw haiku/vendor/wget/current/windows/Makefile.top haiku/vendor/wget/current/windows/Makefile.top.bor haiku/vendor/wget/current/windows/Makefile.top.mingw haiku/vendor/wget/current/windows/Makefile.watcom haiku/vendor/wget/current/windows/README haiku/vendor/wget/current/windows/config.h.bor haiku/vendor/wget/current/windows/config.h.mingw haiku/vendor/wget/current/windows/config.h.ms Log: Add wget vendor branch, it's 1.10.1. Added: haiku/vendor/wget/current/AUTHORS =================================================================== --- haiku/vendor/wget/current/AUTHORS 2008-08-09 09:43:19 UTC (rev 26886) +++ haiku/vendor/wget/current/AUTHORS 2008-08-09 10:46:09 UTC (rev 26887) @@ -0,0 +1,39 @@ +Authors of GNU Wget. + +[ Note that this file does not attempt to list all the contributors to + Wget; look at the ChangeLogs for that. This is a list of people who + contributed sizeable amounts of code and assigned the copyright to + the FSF. ] + +Hrvoje Niksic. Designed and implemented Wget. + +Gordon Matzigkeit. Wrote netrc.c and netrc.h. + +Darko Budor. Wrote initial support for Windows, wrote wsstartup.c, +wsstartup.h and windecl.h. (The files were later renamed, but his +code and ideas remained present.) + +Junio Hamano. Added support for FTP Opie and HTTP digest +authentication. + +Dan Harkless. Added --backup-converted, --follow-tags, --html-extension, +--ignore-tags, and --page-requisites; improved documentation; etc. + +Christian Fraenkel. Initially implemented SSL support. + +Thomas Lussnig. Initially implemented IPv6 support. + +Ian Abbott. Contributed bugfixes, Windows-related fixes, provided a +prototype implementation of the new recursive code, and more. + +Gisle Vanem. Contributed Windows improvements, including a port of +run_with_timeout to Windows, additions to Makefiles, and many bug +reports and fixes. + +Mauro Tortonesi. Improved IPv6 support, adding support for dual +family systems. Refactored and enhanced FTP IPv6 code. + +Nicolas Schodet. Contributed to cookie code and documentation. + +Daniel Stenberg. NTLM authentication in http-ntlm.c and http-ntlm.h +originally written for curl donated for use in GNU Wget. Added: haiku/vendor/wget/current/COPYING =================================================================== --- haiku/vendor/wget/current/COPYING 2008-08-09 09:43:19 UTC (rev 26886) +++ haiku/vendor/wget/current/COPYING 2008-08-09 10:46:09 UTC (rev 26887) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: haiku/vendor/wget/current/ChangeLog =================================================================== --- haiku/vendor/wget/current/ChangeLog 2008-08-09 09:43:19 UTC (rev 26886) +++ haiku/vendor/wget/current/ChangeLog 2008-08-09 10:46:09 UTC (rev 26887) @@ -0,0 +1,1649 @@ +2005-08-11 Hrvoje Niksic + + * configure.in: Check for strtoll and strtoimax. + +2005-07-05 Hrvoje Niksic + + * configure.in: Check for timegm. + +2005-07-03 Hrvoje Niksic + + * po/POTFILES.in: Include src/ptimer.c. + +2005-06-29 Hrvoje Niksic + + * configure.in: Test for $LIBSSL instead of the old $ssl_success + when deciding which MD5 to use. + +2005-06-29 Hrvoje Niksic + + * configure.in: Require Autoconf 2.59. + +2005-06-27 Hrvoje Niksic + + * configure.in: Replace libtool with AC_LIB_HAVE_LINKFLAGS. + Modify makefiles accordingly. (Imported from the trunk.) + +2005-06-23 Hrvoje Niksic + + * util/dist-wget: Port to subversion. + +2005-06-22 Hrvoje Niksic + + * README.svn: Renamed to README.checkout. Edited to mention the + autogen.sh script. + +2005-06-22 Hrvoje Niksic + + * autogen.sh: New file. + + * Makefile.svn: Deleted, replaced with the even simpler (and more + standard) `autogen.sh' script. + +2005-06-22 Hrvoje Niksic + + * MAILING-LIST: Remove reference to the obsolete `wget-cvs' + mailing list. + +2005-06-22 Hrvoje Niksic + + * config.sub, config.guess: Updated from canonical location. + +2005-06-21 Hrvoje Niksic + + * Makefile.cvs: Renamed to Makefile.svn. + + * README.cvs: Renamed to README.svn. + +2005-05-10 Hrvoje Niksic + + * configure.in: Test for OpenSSL includes we actually need. + +2005-05-06 Hrvoje Niksic + + * Makefile.in ($(srcdir)/stamp-h.in): Don't print the line with + the comment about running autoheader. + +2005-05-06 Hrvoje Niksic + + * configure.in: Set MAKEINFO to "true" so build doesn't fail for + users without either makeinfo or the pre-packaged info files. + +2005-05-02 Hrvoje Niksic + + * INSTALL: Document environment variables affecting configure, + especially $CC. + + * INSTALL: Mention that make install requires root. + +2005-04-29 Hrvoje Niksic + + * configure.in: Don't set ipv6 to yes only because struct + sockaddr_in6 was found. Stop the rest of the IPv6 checks when one + check fails. Abort if IPv6 was explicitly requested, but not + found. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.top.bor: Use MAKEDIR for make clean too. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.src.bor: Don't delete executables other than + wget.exe. Delete various auxilliary files created by the Borland + build process. + +2005-04-28 Hrvoje Niksic + + * NEWS: Advertise new-style syntax for --no-dns-cache instead + of --dns-cache=off. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.src.bor: Don't suppress unreachable code + warning. + +2005-04-28 Herold Heiko + + * windows/wget.dep: Rename gen_sslfunc.c to openssl.c. + +2005-04-28 Hrvoje Niksic + + * INSTALL: Mention --disable-ntlm. + +2005-04-27 Mauro Tortonesi + + * NEWS: Mention the new --ftp-user, --ftp-password, --user and + --password options, the name changes for --http-passwd and + --proxy-passwd and the deprecation of login and passwd commands. + +2005-04-22 Hrvoje Niksic + + * po/eo.po: Added Esperanto translation. + +2005-04-21 Hrvoje Niksic + + * po/vi.po: Added Vietnamese translation. + +2005-04-18 Hrvoje Niksic + + * MACHINES: Removed. + +2005-04-08 Hrvoje Niksic + + * configure.in: When checking for OpenSSL headers, check for all + the ones that Wget is using. + +2005-04-08 Hrvoje Niksic + + * windows/Makefile.src: Compile ptimer.c and http-ntlm.c. + +2005-04-08 Hrvoje Niksic + + * configure.in: Use it. + + * aclocal.m4 (WGET_POSIX_CLOCK): Check whether -lrt is needed to + use POSIX clock functions like clock_gettime. + +2005-04-08 Hrvoje Niksic + + * Makefile.in ($(srcdir)/stamp-h.in): Don't attempt to run + autoheader automatically; it breaks things with fresh CVS builds. + +2005-04-06 Hrvoje Niksic + + * configure.in: Allow the user to disable NTLM authorization. + Make sure NTLM is disabled if OpenSSL is unavailable. If NTLM is + *explicitly* requested and OpenSSL is unavailable, abort. + + * configure.in: Renamed USE_* to ENABLE_*. + +2005-03-23 Hrvoje Niksic + + * po/POTFILES.in: Removed headers.c and rbuf.c. + +2005-03-06 Hrvoje Niksic + + * windows/Makefile.src.bor: Reenable warnings under Borland C, + disabling only specific warnings. Generate Pentium Pro code by + default. + +2003-02-24 Hrvoje Niksic + + * configure.in: Don't check for AI_ADDRCONFIG here, it is checked + for in the source directly. + +2003-02-25 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5.14. + +2003-02-23 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5.8. + +2005-02-20 Hrvoje Niksic + + * configure.in: Check for LFS. Determine SIZEOF_OFF_T. + Check for ftello. + +2005-02-18 Marco Colombo + + * po/it.po: Updated Italian translation. + +2004-05-09 David Fritz + + * windows/Makefile.src.bor: Fix broken build rule. Add clean target. + + * windows/Makefile.top.bor: Use tabs instead of spaces. Ignore + errors in clean rules. Use lowercase filenames when building + distribution .zip archive. + + * windows/config.h.bor: Don't define HAVE_UINT32_T. + + * windows/Makefile.doc: Fix remaining instance of build rules + indented with spaces instead of tabs. + + * windows/Makefile.src: Update copyright year. + + * windows/Makefile.top: Update copyright year. + + * windows/config.h.mingw (WGET_USE_STDARG, HAVE_SIG_ATOMIC_T): Define. + + * windows/config.h.ms (HAVE_STRPBRK, HAVE_LIMITS_H) + (HAVE_LOCALE_H): Define. + + * windows/Makefile.watcom: Add /I. to CFLAGS. Remove reference to + specific Wget version from linker flags. Add missing + dependencies. + +2004-02-09 David Fritz + + * configure.bat.in: Don't clear the screen. + + * windows/README: Add introductory paragraph. Re-word a few + sentences. Correct minor typographical errors. Use consistent + capitalization of Wget, SSL, and OpenSSL. Refer to Microsoft + Visual C++ as MSVC instead of VC++. Mention the --msvc option to + configure.bat. Reflow paragraphs. + + * windows/Makefile.top: Use tabs instead of spaces. Ignore errors + in clean rules. Use lowercase filenames when building distribution + .zip archive. + + * windows/Makefile.doc: Use tabs instead of spaces. Ignore errors + in clean rules. + + * windows/Makefile.src: Clean-up clean rules. Use tabs instead of + spaces. Link against gdi32.lib. Don't define SYSTEM_WGETRC. + Remove unused macros. Remove anachronistic and superfluous linker + flags. Don't rename wget.exe to all upper-case. Add + `preprocessor' conditionals for SSL and newer MSVC options. Use + batch rules. Don't suppress all warnings. + +2003-11-26 Hrvoje Niksic + + * aclocal.m4: Don't check for AI_V4MAPPED and for AI_ALL, since + Wget doesn't need them. + + * configure.in: Check for struct sockaddr_storage. + +2003-11-12 Hrvoje Niksic + + * configure.in: Use a more standard checking message when checking + for md5.h. + +2003-11-12 Hrvoje Niksic + + * configure.in: Tweak ansi2knr test, use : instead of true. + +2003-11-12 Hrvoje Niksic + + * configure.in: Check for limits.h. + +2003-11-10 Hrvoje Niksic + + * aclocal.m4 (WGET_SOCKLEN_T): Use AC_COMPILE_IFELSE instead of + AC_TRY_COMPILE. + +2003-11-10 Hrvoje Niksic + + * aclocal.m4 (WGET_STRUCT_UTIMBUF): Use AC_CHECK_TYPES instead of + AC_EGREP_CPP to check for struct utimbuf. + +2003-11-09 Hrvoje Niksic + + * aclocal.m4 (WGET_WITH_NLS): Respect the user's setting of + LINGUAS, e.g. `LINGUAS="en bg ja" ./configure'. + +2003-11-09 Hrvoje Niksic + + * configure.in: Don't attempt to use Emacs as a makeinfo + substitute. + +2003-11-07 Hrvoje Niksic + + * README: Remove explicit version reference, so that the file + doesn't have to be updated for each new release. + +2003-11-05 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5. + +2003-11-05 Hrvoje Niksic + + * windows/config.h.ms: MSVC doesn't have uint32_t. + +2003-11-05 Hrvoje Niksic + + * configure.in: Remove the broken check for socks. + +2003-11-05 Hrvoje Niksic + + * configure.in: Substitute ANSI2KNR and U, so we can compile. + +2003-11-05 Hrvoje Niksic + + * configure.in: Use the Autoconf macro AC_C_PROTOTYPES instead of + the old AM_C_PROTOTYPES. + +2003-11-04 Hrvoje Niksic + + * configure.in: Use the new form of AC_OUTPUT. + + * Makefile.cvs (prep): Invoke autoheader. + +2003-11-04 Hrvoje Niksic + + * configure.in: Require Autoconf 2.57. + +2003-11-04 Hrvoje Niksic + + * aclocal.m4: Ditto. + + * configure.in: Add description annotations to AC_DEFINE. + + * Makefile.in: Update maintenance targets, preparing them for the + use of `autoheader'. + +2003-11-04 Hrvoje Niksic + + * configure.in: Don't misuse AC_MSG_RESULT. Use AC_MSG_NOTICE + where appropriate. + +2003-11-04 Hrvoje Niksic + + * configure.in: Check whether volatile is supported. Don't check + for gethostname and uname, which are not used. + +2003-11-04 Hrvoje Niksic + + * configure.in: Move some checks into aclocal.m4. Check whether + fnmatch.h is includable. + + * configure.in: Also check whether #include works before + deciding to use Solaris libmd5. + + * configure.in: Use AC_MSG_NOTICE instead of echo. Use + AC_MSG_ERROR for fatal errors. + +2003-11-03 Hrvoje Niksic + + * configure.in: Look for nanosleep in -lrt and -lposix4, which is + where Solaris has them. + +2003-11-03 Hrvoje Niksic + + * configure.in: Check for nanosleep. + +2003-03-09 Nicolas Schodet + + * Makefile.in: Fixed bad configure.bat scrdir. + +2003-10-29 Hrvoje Niksic + + * configure.in: Reenable IPv6 autodetection. + +2003-10-26 Hrvoje Niksic + + * configure.in: Switch from u_int32_t to uint32_t. Check for + inttypes.h so it's used to get the definition of uint32_t where + available. + +2003-10-26 Hrvoje Niksic + + * windows/Makefile.src.watcom (OBJS): Use convert.c. + From Chin-yuan Kuo. + +2003-10-26 Hrvoje Niksic + + * windows/config.h.bor: DEBUG is now ENABLE_DEBUG. Borland has + snprintf, but not u_int32_t. + + * windows/Makefile.src.bor (OBJS): Use convert.c. + + From Chin-yuan Kuo. + +2003-10-26 Hrvoje Niksic + + * windows/config.h.mingw: Ditto. + + * windows/Makefile.top.mingw: Ditto. + + * windows/Makefile.src.mingw: New file. + + * windows/wget.dep: Support convert.o. + + * configure.bat.in: New option `--mingw'. + From Chin-yuan Kuo. + +2003-10-23 Hrvoje Niksic + + * Makefile.in (dist): Depend on configure.bat. + (realclean-top): Delete configure.bat. + +2003-10-21 Hrvoje Niksic + + * Makefile.in (distclean-top): Remove the libtool script, because + it's generated by configure. + +2003-10-16 Hrvoje Niksic + + * configure.in: Don't check for int32_t because we're not really + using it. + +2003-10-11 Hrvoje Niksic + + * configure.in: Check for int32_t and u_int32_t. Check for + SIZEOF_INT. + +2003-10-10 Hrvoje Niksic + + * aclocal.m4 (WGET_WITH_NLS): First check for gettext in libintl, + then use the libc version. That way systems that get libintl.h + from /usr/local/include will get the matching gettext. + +2003-10-10 Hrvoje Niksic + + * po/tr.po: Ditto. + + * po/sv.po: Updated from TP. + +2003-10-09 Herold Heiko + + * windows/Makefile.watcom (OBJS): Ditto. + + * windows/Makefile.src.bor: Ditto. + + * windows/wget.dep: Ditto. + + * windows/Makefile.src: Removed references to fnmatch.c and + fnmatch.o. + +2003-10-09 Hrvoje Niksic + + * po/ft.po, po/sk.po, po/ja.po: Updated from the TP. + +2003-10-08 Hrvoje Niksic + + * po/wget.pot: Recreated. + +2003-10-08 Hrvoje Niksic + + * configure.in: Renamed DEBUG to ENABLE_DEBUG. + +2003-10-04 Hrvoje Niksic + + * libtool.m4: New file with contents imported from libtool. + + * aclocal.m4: Move libtool stuff into a separate file. That + leaves this file only with Wget-specific stuff. + +2003-10-01 Hrvoje Niksic + + * po/hu.po: Updated from the TP. + + * po/et.po: Updated from the TP. + + * po/ro.po: New file from the TP. + +2003-10-01 Hrvoje Niksic + + * po/hr.po: Updated. + +2003-10-01 Hrvoje Niksic + + * po/POTFILES.in: Added src/convert.c. + +2003-09-30 Herold Heiko + + * windows/Makefile.src (OBJ): Fix typo. + +2003-09-26 Gisle Vanem + + * windows/config.h.ms: Don't declare alloca under compilers that + support it. + + * windows/config.h.ms: Define HAVE_SNPRINTF, HAVE_VSNPRINTF, and + HAVE_MEMMOVE. + +2003-09-25 Herold Heiko + + * windows/Makefile.src: Updated OBJ list. + +2003-09-23 Hrvoje Niksic + + * Makefile.in (clean-top): Remove .libs. + +2003-09-23 Hrvoje Niksic + + * Makefile.in (distclean-top): Remove autom4te.cache. + +2003-09-17 Hrvoje Niksic + + * install-sh, mkinstalldirs: Updated from Autoconf 2.57. + +2003-09-17 Hrvoje Niksic + + * ltmain.sh, aclocal.m4: Upgrade to libtool 1.4.3. Libtool 1.5 + has been out for a while now, but it can wait until after Wget 1.9 + is released. + +2003-09-17 Hrvoje Niksic + + * config.sub: Ditto. + + * config.guess: Updated from Autoconf 2.57. + +2003-09-16 Hrvoje Niksic + + * util/dist-wget: Fixed portable echo checking under Bash. + +2003-09-16 Hrvoje Niksic + + * configure.in: Change AC_CHECK_FUNC(getaddrinfo...) to + AC_CHECK_FUNCS, which automatically defines HAVE_GETADDRINFO. + +2003-09-16 Mauro Tortonesi + + * configure.in, aclocal.m4: Added proper IPv6 detection. + +2003-09-16 Hrvoje Niksic + + * Makefile.in (all): Don't build configure.bat by default. + +2003-09-09 Hrvoje Niksic + + * configure.in, aclocal.m4: Added configure check for IPv6 and + getaddrinfo. From Daniel Stenberg. + +2003-09-05 Maciej W. Rozycki + + * configure.in: Additional M4 quoting. + +2003-09-04 Hrvoje Niksic + + * aclocal.m4, configure.in: Made them work under Autoconf 2.5x. + +2002-05-27 Ian Abbott + + * windows/config.h.bor: Do #define WGET_USE_STDARG. + +2002-05-20 Hrvoje Niksic + + * windows/config.h.ms: Ditto. + + * windows/config.h.bor: Don't #define __STDC__. + +2002-05-18 Hrvoje Niksic + + * ALL: Update the license to reflect the OpenSSL exception. + +2002-04-23 Ian Abbott + + * windows/config.h.ms: Accounted for MSVC not defining `__STDC__' when + Microsoft's extensions are enabled and define it anyway (set to `1'). + Defined some things that broke as a result of this. + +2002-04-20 Hrvoje Niksic + + * po/de.po: Updated from the TP. + +2001-04-15 Ian Abbott + + windows/wget.dep: The target `connect$o' (connect.obj) now depends on + `utils.h'. + +2001-04-15 Hrvoje Niksic + + * po/da.po: Ditto. + + * po/de.po: Ditto. + + * po/el.po: Ditto. + + * po/es.po: Ditto. + + * po/et.po: Ditto. + + * po/fr.po: Ditto. + + * po/gl.po: Ditto. + + * po/he.po: Ditto. + + * po/ja.po: Ditto. + + * po/pl.po: Ditto. + + * po/sk.po: Ditto. + + * po/sl.po: Ditto. + [... truncated: 144462 lines follow ...] From mmu_man at mail.berlios.de Sat Aug 9 13:24:40 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 9 Aug 2008 13:24:40 +0200 Subject: [Haiku-commits] r26888 - haiku/vendor/wget Message-ID: <200808091124.m79BOeTd005513@sheep.berlios.de> Author: mmu_man Date: 2008-08-09 13:24:34 +0200 (Sat, 09 Aug 2008) New Revision: 26888 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26888&view=rev Added: haiku/vendor/wget/1.10.1/ Log: Tagging wget 1.10.1 Copied: haiku/vendor/wget/1.10.1 (from rev 26887, haiku/vendor/wget/current) From mmu_man at mail.berlios.de Sat Aug 9 13:46:58 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 9 Aug 2008 13:46:58 +0200 Subject: [Haiku-commits] r26889 - haiku/vendor/wget Message-ID: <200808091146.m79Bkwoh030483@sheep.berlios.de> Author: mmu_man Date: 2008-08-09 13:46:57 +0200 (Sat, 09 Aug 2008) New Revision: 26889 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26889&view=rev Removed: haiku/vendor/wget/1.10.1/ Log: Seems we used 1.10.2 actually, let's just start there instead... From mmu_man at mail.berlios.de Sat Aug 9 13:47:12 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 9 Aug 2008 13:47:12 +0200 Subject: [Haiku-commits] r26890 - haiku/vendor/wget Message-ID: <200808091147.m79BlCUG030498@sheep.berlios.de> Author: mmu_man Date: 2008-08-09 13:47:12 +0200 (Sat, 09 Aug 2008) New Revision: 26890 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26890&view=rev Removed: haiku/vendor/wget/current/ Log: Seems we used 1.10.2 actually, let's just start there instead... From mmu_man at mail.berlios.de Sat Aug 9 13:50:40 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sat, 9 Aug 2008 13:50:40 +0200 Subject: [Haiku-commits] r26891 - in haiku/vendor/wget: . current current/doc current/m4 current/po current/src current/util current/windows Message-ID: <200808091150.m79BoeY8030716@sheep.berlios.de> Author: mmu_man Date: 2008-08-09 13:50:13 +0200 (Sat, 09 Aug 2008) New Revision: 26891 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26891&view=rev Added: haiku/vendor/wget/current/ haiku/vendor/wget/current/AUTHORS haiku/vendor/wget/current/COPYING haiku/vendor/wget/current/ChangeLog haiku/vendor/wget/current/ChangeLog.README haiku/vendor/wget/current/INSTALL haiku/vendor/wget/current/MAILING-LIST haiku/vendor/wget/current/Makefile.in haiku/vendor/wget/current/NEWS haiku/vendor/wget/current/PATCHES haiku/vendor/wget/current/README haiku/vendor/wget/current/README.checkout haiku/vendor/wget/current/TODO haiku/vendor/wget/current/autogen.sh haiku/vendor/wget/current/config.guess haiku/vendor/wget/current/config.rpath haiku/vendor/wget/current/config.sub haiku/vendor/wget/current/configure haiku/vendor/wget/current/configure.bat haiku/vendor/wget/current/configure.bat.in haiku/vendor/wget/current/configure.in haiku/vendor/wget/current/doc/ haiku/vendor/wget/current/doc/ChangeLog haiku/vendor/wget/current/doc/Makefile.in haiku/vendor/wget/current/doc/ansi2knr.1 haiku/vendor/wget/current/doc/fdl.texi haiku/vendor/wget/current/doc/gpl.texi haiku/vendor/wget/current/doc/sample.wgetrc haiku/vendor/wget/current/doc/sample.wgetrc.munged_for_texi_inclusion haiku/vendor/wget/current/doc/texi2pod.pl.in haiku/vendor/wget/current/doc/texinfo.tex haiku/vendor/wget/current/doc/version.texi haiku/vendor/wget/current/doc/wget.info haiku/vendor/wget/current/doc/wget.texi haiku/vendor/wget/current/install-sh haiku/vendor/wget/current/m4/ haiku/vendor/wget/current/m4/lib-ld.m4 haiku/vendor/wget/current/m4/lib-link.m4 haiku/vendor/wget/current/m4/lib-prefix.m4 haiku/vendor/wget/current/m4/wget.m4 haiku/vendor/wget/current/mkinstalldirs haiku/vendor/wget/current/po/ haiku/vendor/wget/current/po/Makefile.in.in haiku/vendor/wget/current/po/POTFILES.in haiku/vendor/wget/current/po/bg.po haiku/vendor/wget/current/po/ca.po haiku/vendor/wget/current/po/cs.po haiku/vendor/wget/current/po/da.po haiku/vendor/wget/current/po/de.po haiku/vendor/wget/current/po/el.po haiku/vendor/wget/current/po/en_GB.po haiku/vendor/wget/current/po/eo.po haiku/vendor/wget/current/po/es.po haiku/vendor/wget/current/po/et.po haiku/vendor/wget/current/po/eu.po haiku/vendor/wget/current/po/fi.po haiku/vendor/wget/current/po/fr.po haiku/vendor/wget/current/po/ga.po haiku/vendor/wget/current/po/gl.po haiku/vendor/wget/current/po/he.po haiku/vendor/wget/current/po/hr.po haiku/vendor/wget/current/po/hu.po haiku/vendor/wget/current/po/it.po haiku/vendor/wget/current/po/ja.po haiku/vendor/wget/current/po/nl.po haiku/vendor/wget/current/po/no.po haiku/vendor/wget/current/po/pl.po haiku/vendor/wget/current/po/pt_BR.po haiku/vendor/wget/current/po/ro.po haiku/vendor/wget/current/po/ru.po haiku/vendor/wget/current/po/sk.po haiku/vendor/wget/current/po/sl.po haiku/vendor/wget/current/po/sr.po haiku/vendor/wget/current/po/sv.po haiku/vendor/wget/current/po/tr.po haiku/vendor/wget/current/po/uk.po haiku/vendor/wget/current/po/vi.po haiku/vendor/wget/current/po/zh_CN.po haiku/vendor/wget/current/po/zh_TW.po haiku/vendor/wget/current/src/ haiku/vendor/wget/current/src/ChangeLog haiku/vendor/wget/current/src/Makefile.in haiku/vendor/wget/current/src/alloca.c haiku/vendor/wget/current/src/ansi2knr.c haiku/vendor/wget/current/src/cmpt.c haiku/vendor/wget/current/src/config-post.h haiku/vendor/wget/current/src/config.h.in haiku/vendor/wget/current/src/connect.c haiku/vendor/wget/current/src/connect.h haiku/vendor/wget/current/src/convert.c haiku/vendor/wget/current/src/convert.h haiku/vendor/wget/current/src/cookies.c haiku/vendor/wget/current/src/cookies.h haiku/vendor/wget/current/src/ftp-basic.c haiku/vendor/wget/current/src/ftp-ls.c haiku/vendor/wget/current/src/ftp-opie.c haiku/vendor/wget/current/src/ftp.c haiku/vendor/wget/current/src/ftp.h haiku/vendor/wget/current/src/gen-md5.c haiku/vendor/wget/current/src/gen-md5.h haiku/vendor/wget/current/src/getopt.c haiku/vendor/wget/current/src/getopt.h haiku/vendor/wget/current/src/gnu-md5.c haiku/vendor/wget/current/src/gnu-md5.h haiku/vendor/wget/current/src/hash.c haiku/vendor/wget/current/src/hash.h haiku/vendor/wget/current/src/host.c haiku/vendor/wget/current/src/host.h haiku/vendor/wget/current/src/html-parse.c haiku/vendor/wget/current/src/html-parse.h haiku/vendor/wget/current/src/html-url.c haiku/vendor/wget/current/src/http-ntlm.c haiku/vendor/wget/current/src/http-ntlm.h haiku/vendor/wget/current/src/http.c haiku/vendor/wget/current/src/init.c haiku/vendor/wget/current/src/init.h haiku/vendor/wget/current/src/log.c haiku/vendor/wget/current/src/log.h haiku/vendor/wget/current/src/main.c haiku/vendor/wget/current/src/mswindows.c haiku/vendor/wget/current/src/mswindows.h haiku/vendor/wget/current/src/netrc.c haiku/vendor/wget/current/src/netrc.h haiku/vendor/wget/current/src/openssl.c haiku/vendor/wget/current/src/options.h haiku/vendor/wget/current/src/progress.c haiku/vendor/wget/current/src/progress.h haiku/vendor/wget/current/src/ptimer.c haiku/vendor/wget/current/src/ptimer.h haiku/vendor/wget/current/src/recur.c haiku/vendor/wget/current/src/recur.h haiku/vendor/wget/current/src/res.c haiku/vendor/wget/current/src/res.h haiku/vendor/wget/current/src/retr.c haiku/vendor/wget/current/src/retr.h haiku/vendor/wget/current/src/safe-ctype.c haiku/vendor/wget/current/src/safe-ctype.h haiku/vendor/wget/current/src/snprintf.c haiku/vendor/wget/current/src/ssl.h haiku/vendor/wget/current/src/sysdep.h haiku/vendor/wget/current/src/url.c haiku/vendor/wget/current/src/url.h haiku/vendor/wget/current/src/utils.c haiku/vendor/wget/current/src/utils.h haiku/vendor/wget/current/src/version.c haiku/vendor/wget/current/src/wget.h haiku/vendor/wget/current/src/xmalloc.c haiku/vendor/wget/current/src/xmalloc.h haiku/vendor/wget/current/stamp-h.in haiku/vendor/wget/current/util/ haiku/vendor/wget/current/util/Makefile.in haiku/vendor/wget/current/util/README haiku/vendor/wget/current/util/dist-wget haiku/vendor/wget/current/util/download-netscape.html haiku/vendor/wget/current/util/download.html haiku/vendor/wget/current/util/rmold.pl haiku/vendor/wget/current/util/update_po_files.sh haiku/vendor/wget/current/util/wget.spec haiku/vendor/wget/current/windows/ haiku/vendor/wget/current/windows/ChangeLog haiku/vendor/wget/current/windows/Makefile.doc haiku/vendor/wget/current/windows/Makefile.in haiku/vendor/wget/current/windows/Makefile.src haiku/vendor/wget/current/windows/Makefile.src.bor haiku/vendor/wget/current/windows/Makefile.src.mingw haiku/vendor/wget/current/windows/Makefile.top haiku/vendor/wget/current/windows/Makefile.top.bor haiku/vendor/wget/current/windows/Makefile.top.mingw haiku/vendor/wget/current/windows/Makefile.watcom haiku/vendor/wget/current/windows/README haiku/vendor/wget/current/windows/config.h.bor haiku/vendor/wget/current/windows/config.h.mingw haiku/vendor/wget/current/windows/config.h.ms Log: wget 1.10.2 Added: haiku/vendor/wget/current/AUTHORS =================================================================== --- haiku/vendor/wget/current/AUTHORS 2008-08-09 11:47:12 UTC (rev 26890) +++ haiku/vendor/wget/current/AUTHORS 2008-08-09 11:50:13 UTC (rev 26891) @@ -0,0 +1,39 @@ +Authors of GNU Wget. + +[ Note that this file does not attempt to list all the contributors to + Wget; look at the ChangeLogs for that. This is a list of people who + contributed sizeable amounts of code and assigned the copyright to + the FSF. ] + +Hrvoje Niksic. Designed and implemented Wget. + +Gordon Matzigkeit. Wrote netrc.c and netrc.h. + +Darko Budor. Wrote initial support for Windows, wrote wsstartup.c, +wsstartup.h and windecl.h. (The files were later renamed, but his +code and ideas remained present.) + +Junio Hamano. Added support for FTP Opie and HTTP digest +authentication. + +Dan Harkless. Added --backup-converted, --follow-tags, --html-extension, +--ignore-tags, and --page-requisites; improved documentation; etc. + +Christian Fraenkel. Initially implemented SSL support. + +Thomas Lussnig. Initially implemented IPv6 support. + +Ian Abbott. Contributed bugfixes, Windows-related fixes, provided a +prototype implementation of the new recursive code, and more. + +Gisle Vanem. Contributed Windows improvements, including a port of +run_with_timeout to Windows, additions to Makefiles, and many bug +reports and fixes. + +Mauro Tortonesi. Improved IPv6 support, adding support for dual +family systems. Refactored and enhanced FTP IPv6 code. + +Nicolas Schodet. Contributed to cookie code and documentation. + +Daniel Stenberg. NTLM authentication in http-ntlm.c and http-ntlm.h +originally written for curl donated for use in GNU Wget. Added: haiku/vendor/wget/current/COPYING =================================================================== --- haiku/vendor/wget/current/COPYING 2008-08-09 11:47:12 UTC (rev 26890) +++ haiku/vendor/wget/current/COPYING 2008-08-09 11:50:13 UTC (rev 26891) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: haiku/vendor/wget/current/ChangeLog =================================================================== --- haiku/vendor/wget/current/ChangeLog 2008-08-09 11:47:12 UTC (rev 26890) +++ haiku/vendor/wget/current/ChangeLog 2008-08-09 11:50:13 UTC (rev 26891) @@ -0,0 +1,1653 @@ +2005-08-26 Stepan Kasal + + * configure.in: Abort if --with-ssl given and OpenSSL unavailable. + +2005-08-11 Hrvoje Niksic + + * configure.in: Check for strtoll and strtoimax. + +2005-07-05 Hrvoje Niksic + + * configure.in: Check for timegm. + +2005-07-03 Hrvoje Niksic + + * po/POTFILES.in: Include src/ptimer.c. + +2005-06-29 Hrvoje Niksic + + * configure.in: Test for $LIBSSL instead of the old $ssl_success + when deciding which MD5 to use. + +2005-06-29 Hrvoje Niksic + + * configure.in: Require Autoconf 2.59. + +2005-06-27 Hrvoje Niksic + + * configure.in: Replace libtool with AC_LIB_HAVE_LINKFLAGS. + Modify makefiles accordingly. (Imported from the trunk.) + +2005-06-23 Hrvoje Niksic + + * util/dist-wget: Port to subversion. + +2005-06-22 Hrvoje Niksic + + * README.svn: Renamed to README.checkout. Edited to mention the + autogen.sh script. + +2005-06-22 Hrvoje Niksic + + * autogen.sh: New file. + + * Makefile.svn: Deleted, replaced with the even simpler (and more + standard) `autogen.sh' script. + +2005-06-22 Hrvoje Niksic + + * MAILING-LIST: Remove reference to the obsolete `wget-cvs' + mailing list. + +2005-06-22 Hrvoje Niksic + + * config.sub, config.guess: Updated from canonical location. + +2005-06-21 Hrvoje Niksic + + * Makefile.cvs: Renamed to Makefile.svn. + + * README.cvs: Renamed to README.svn. + +2005-05-10 Hrvoje Niksic + + * configure.in: Test for OpenSSL includes we actually need. + +2005-05-06 Hrvoje Niksic + + * Makefile.in ($(srcdir)/stamp-h.in): Don't print the line with + the comment about running autoheader. + +2005-05-06 Hrvoje Niksic + + * configure.in: Set MAKEINFO to "true" so build doesn't fail for + users without either makeinfo or the pre-packaged info files. + +2005-05-02 Hrvoje Niksic + + * INSTALL: Document environment variables affecting configure, + especially $CC. + + * INSTALL: Mention that make install requires root. + +2005-04-29 Hrvoje Niksic + + * configure.in: Don't set ipv6 to yes only because struct + sockaddr_in6 was found. Stop the rest of the IPv6 checks when one + check fails. Abort if IPv6 was explicitly requested, but not + found. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.top.bor: Use MAKEDIR for make clean too. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.src.bor: Don't delete executables other than + wget.exe. Delete various auxilliary files created by the Borland + build process. + +2005-04-28 Hrvoje Niksic + + * NEWS: Advertise new-style syntax for --no-dns-cache instead + of --dns-cache=off. + +2005-04-28 Hrvoje Niksic + + * windows/Makefile.src.bor: Don't suppress unreachable code + warning. + +2005-04-28 Herold Heiko + + * windows/wget.dep: Rename gen_sslfunc.c to openssl.c. + +2005-04-28 Hrvoje Niksic + + * INSTALL: Mention --disable-ntlm. + +2005-04-27 Mauro Tortonesi + + * NEWS: Mention the new --ftp-user, --ftp-password, --user and + --password options, the name changes for --http-passwd and + --proxy-passwd and the deprecation of login and passwd commands. + +2005-04-22 Hrvoje Niksic + + * po/eo.po: Added Esperanto translation. + +2005-04-21 Hrvoje Niksic + + * po/vi.po: Added Vietnamese translation. + +2005-04-18 Hrvoje Niksic + + * MACHINES: Removed. + +2005-04-08 Hrvoje Niksic + + * configure.in: When checking for OpenSSL headers, check for all + the ones that Wget is using. + +2005-04-08 Hrvoje Niksic + + * windows/Makefile.src: Compile ptimer.c and http-ntlm.c. + +2005-04-08 Hrvoje Niksic + + * configure.in: Use it. + + * aclocal.m4 (WGET_POSIX_CLOCK): Check whether -lrt is needed to + use POSIX clock functions like clock_gettime. + +2005-04-08 Hrvoje Niksic + + * Makefile.in ($(srcdir)/stamp-h.in): Don't attempt to run + autoheader automatically; it breaks things with fresh CVS builds. + +2005-04-06 Hrvoje Niksic + + * configure.in: Allow the user to disable NTLM authorization. + Make sure NTLM is disabled if OpenSSL is unavailable. If NTLM is + *explicitly* requested and OpenSSL is unavailable, abort. + + * configure.in: Renamed USE_* to ENABLE_*. + +2005-03-23 Hrvoje Niksic + + * po/POTFILES.in: Removed headers.c and rbuf.c. + +2005-03-06 Hrvoje Niksic + + * windows/Makefile.src.bor: Reenable warnings under Borland C, + disabling only specific warnings. Generate Pentium Pro code by + default. + +2003-02-24 Hrvoje Niksic + + * configure.in: Don't check for AI_ADDRCONFIG here, it is checked + for in the source directly. + +2003-02-25 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5.14. + +2003-02-23 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5.8. + +2005-02-20 Hrvoje Niksic + + * configure.in: Check for LFS. Determine SIZEOF_OFF_T. + Check for ftello. + +2005-02-18 Marco Colombo + + * po/it.po: Updated Italian translation. + +2004-05-09 David Fritz + + * windows/Makefile.src.bor: Fix broken build rule. Add clean target. + + * windows/Makefile.top.bor: Use tabs instead of spaces. Ignore + errors in clean rules. Use lowercase filenames when building + distribution .zip archive. + + * windows/config.h.bor: Don't define HAVE_UINT32_T. + + * windows/Makefile.doc: Fix remaining instance of build rules + indented with spaces instead of tabs. + + * windows/Makefile.src: Update copyright year. + + * windows/Makefile.top: Update copyright year. + + * windows/config.h.mingw (WGET_USE_STDARG, HAVE_SIG_ATOMIC_T): Define. + + * windows/config.h.ms (HAVE_STRPBRK, HAVE_LIMITS_H) + (HAVE_LOCALE_H): Define. + + * windows/Makefile.watcom: Add /I. to CFLAGS. Remove reference to + specific Wget version from linker flags. Add missing + dependencies. + +2004-02-09 David Fritz + + * configure.bat.in: Don't clear the screen. + + * windows/README: Add introductory paragraph. Re-word a few + sentences. Correct minor typographical errors. Use consistent + capitalization of Wget, SSL, and OpenSSL. Refer to Microsoft + Visual C++ as MSVC instead of VC++. Mention the --msvc option to + configure.bat. Reflow paragraphs. + + * windows/Makefile.top: Use tabs instead of spaces. Ignore errors + in clean rules. Use lowercase filenames when building distribution + .zip archive. + + * windows/Makefile.doc: Use tabs instead of spaces. Ignore errors + in clean rules. + + * windows/Makefile.src: Clean-up clean rules. Use tabs instead of + spaces. Link against gdi32.lib. Don't define SYSTEM_WGETRC. + Remove unused macros. Remove anachronistic and superfluous linker + flags. Don't rename wget.exe to all upper-case. Add + `preprocessor' conditionals for SSL and newer MSVC options. Use + batch rules. Don't suppress all warnings. + +2003-11-26 Hrvoje Niksic + + * aclocal.m4: Don't check for AI_V4MAPPED and for AI_ALL, since + Wget doesn't need them. + + * configure.in: Check for struct sockaddr_storage. + +2003-11-12 Hrvoje Niksic + + * configure.in: Use a more standard checking message when checking + for md5.h. + +2003-11-12 Hrvoje Niksic + + * configure.in: Tweak ansi2knr test, use : instead of true. + +2003-11-12 Hrvoje Niksic + + * configure.in: Check for limits.h. + +2003-11-10 Hrvoje Niksic + + * aclocal.m4 (WGET_SOCKLEN_T): Use AC_COMPILE_IFELSE instead of + AC_TRY_COMPILE. + +2003-11-10 Hrvoje Niksic + + * aclocal.m4 (WGET_STRUCT_UTIMBUF): Use AC_CHECK_TYPES instead of + AC_EGREP_CPP to check for struct utimbuf. + +2003-11-09 Hrvoje Niksic + + * aclocal.m4 (WGET_WITH_NLS): Respect the user's setting of + LINGUAS, e.g. `LINGUAS="en bg ja" ./configure'. + +2003-11-09 Hrvoje Niksic + + * configure.in: Don't attempt to use Emacs as a makeinfo + substitute. + +2003-11-07 Hrvoje Niksic + + * README: Remove explicit version reference, so that the file + doesn't have to be updated for each new release. + +2003-11-05 Hrvoje Niksic + + * libtool.m4, ltmain.sh, config.sub, config.guess: Upgrade to + libtool 1.5. + +2003-11-05 Hrvoje Niksic + + * windows/config.h.ms: MSVC doesn't have uint32_t. + +2003-11-05 Hrvoje Niksic + + * configure.in: Remove the broken check for socks. + +2003-11-05 Hrvoje Niksic + + * configure.in: Substitute ANSI2KNR and U, so we can compile. + +2003-11-05 Hrvoje Niksic + + * configure.in: Use the Autoconf macro AC_C_PROTOTYPES instead of + the old AM_C_PROTOTYPES. + +2003-11-04 Hrvoje Niksic + + * configure.in: Use the new form of AC_OUTPUT. + + * Makefile.cvs (prep): Invoke autoheader. + +2003-11-04 Hrvoje Niksic + + * configure.in: Require Autoconf 2.57. + +2003-11-04 Hrvoje Niksic + + * aclocal.m4: Ditto. + + * configure.in: Add description annotations to AC_DEFINE. + + * Makefile.in: Update maintenance targets, preparing them for the + use of `autoheader'. + +2003-11-04 Hrvoje Niksic + + * configure.in: Don't misuse AC_MSG_RESULT. Use AC_MSG_NOTICE + where appropriate. + +2003-11-04 Hrvoje Niksic + + * configure.in: Check whether volatile is supported. Don't check + for gethostname and uname, which are not used. + +2003-11-04 Hrvoje Niksic + + * configure.in: Move some checks into aclocal.m4. Check whether + fnmatch.h is includable. + + * configure.in: Also check whether #include works before + deciding to use Solaris libmd5. + + * configure.in: Use AC_MSG_NOTICE instead of echo. Use + AC_MSG_ERROR for fatal errors. + +2003-11-03 Hrvoje Niksic + + * configure.in: Look for nanosleep in -lrt and -lposix4, which is + where Solaris has them. + +2003-11-03 Hrvoje Niksic + + * configure.in: Check for nanosleep. + +2003-03-09 Nicolas Schodet + + * Makefile.in: Fixed bad configure.bat scrdir. + +2003-10-29 Hrvoje Niksic + + * configure.in: Reenable IPv6 autodetection. + +2003-10-26 Hrvoje Niksic + + * configure.in: Switch from u_int32_t to uint32_t. Check for + inttypes.h so it's used to get the definition of uint32_t where + available. + +2003-10-26 Hrvoje Niksic + + * windows/Makefile.src.watcom (OBJS): Use convert.c. + From Chin-yuan Kuo. + +2003-10-26 Hrvoje Niksic + + * windows/config.h.bor: DEBUG is now ENABLE_DEBUG. Borland has + snprintf, but not u_int32_t. + + * windows/Makefile.src.bor (OBJS): Use convert.c. + + From Chin-yuan Kuo. + +2003-10-26 Hrvoje Niksic + + * windows/config.h.mingw: Ditto. + + * windows/Makefile.top.mingw: Ditto. + + * windows/Makefile.src.mingw: New file. + + * windows/wget.dep: Support convert.o. + + * configure.bat.in: New option `--mingw'. + From Chin-yuan Kuo. + +2003-10-23 Hrvoje Niksic + + * Makefile.in (dist): Depend on configure.bat. + (realclean-top): Delete configure.bat. + +2003-10-21 Hrvoje Niksic + + * Makefile.in (distclean-top): Remove the libtool script, because + it's generated by configure. + +2003-10-16 Hrvoje Niksic + + * configure.in: Don't check for int32_t because we're not really + using it. + +2003-10-11 Hrvoje Niksic + + * configure.in: Check for int32_t and u_int32_t. Check for + SIZEOF_INT. + +2003-10-10 Hrvoje Niksic + + * aclocal.m4 (WGET_WITH_NLS): First check for gettext in libintl, + then use the libc version. That way systems that get libintl.h + from /usr/local/include will get the matching gettext. + +2003-10-10 Hrvoje Niksic + + * po/tr.po: Ditto. + + * po/sv.po: Updated from TP. + +2003-10-09 Herold Heiko + + * windows/Makefile.watcom (OBJS): Ditto. + + * windows/Makefile.src.bor: Ditto. + + * windows/wget.dep: Ditto. + + * windows/Makefile.src: Removed references to fnmatch.c and + fnmatch.o. + +2003-10-09 Hrvoje Niksic + + * po/ft.po, po/sk.po, po/ja.po: Updated from the TP. + +2003-10-08 Hrvoje Niksic + + * po/wget.pot: Recreated. + +2003-10-08 Hrvoje Niksic + + * configure.in: Renamed DEBUG to ENABLE_DEBUG. + +2003-10-04 Hrvoje Niksic + + * libtool.m4: New file with contents imported from libtool. + + * aclocal.m4: Move libtool stuff into a separate file. That + leaves this file only with Wget-specific stuff. + +2003-10-01 Hrvoje Niksic + + * po/hu.po: Updated from the TP. + + * po/et.po: Updated from the TP. + + * po/ro.po: New file from the TP. + +2003-10-01 Hrvoje Niksic + + * po/hr.po: Updated. + +2003-10-01 Hrvoje Niksic + + * po/POTFILES.in: Added src/convert.c. + +2003-09-30 Herold Heiko + + * windows/Makefile.src (OBJ): Fix typo. + +2003-09-26 Gisle Vanem + + * windows/config.h.ms: Don't declare alloca under compilers that + support it. + + * windows/config.h.ms: Define HAVE_SNPRINTF, HAVE_VSNPRINTF, and + HAVE_MEMMOVE. + +2003-09-25 Herold Heiko + + * windows/Makefile.src: Updated OBJ list. + +2003-09-23 Hrvoje Niksic + + * Makefile.in (clean-top): Remove .libs. + +2003-09-23 Hrvoje Niksic + + * Makefile.in (distclean-top): Remove autom4te.cache. + +2003-09-17 Hrvoje Niksic + + * install-sh, mkinstalldirs: Updated from Autoconf 2.57. + +2003-09-17 Hrvoje Niksic + + * ltmain.sh, aclocal.m4: Upgrade to libtool 1.4.3. Libtool 1.5 + has been out for a while now, but it can wait until after Wget 1.9 + is released. + +2003-09-17 Hrvoje Niksic + + * config.sub: Ditto. + + * config.guess: Updated from Autoconf 2.57. + +2003-09-16 Hrvoje Niksic + + * util/dist-wget: Fixed portable echo checking under Bash. + +2003-09-16 Hrvoje Niksic + + * configure.in: Change AC_CHECK_FUNC(getaddrinfo...) to + AC_CHECK_FUNCS, which automatically defines HAVE_GETADDRINFO. + +2003-09-16 Mauro Tortonesi + + * configure.in, aclocal.m4: Added proper IPv6 detection. + +2003-09-16 Hrvoje Niksic + + * Makefile.in (all): Don't build configure.bat by default. + +2003-09-09 Hrvoje Niksic + + * configure.in, aclocal.m4: Added configure check for IPv6 and + getaddrinfo. From Daniel Stenberg. + +2003-09-05 Maciej W. Rozycki + + * configure.in: Additional M4 quoting. + +2003-09-04 Hrvoje Niksic + + * aclocal.m4, configure.in: Made them work under Autoconf 2.5x. + +2002-05-27 Ian Abbott + + * windows/config.h.bor: Do #define WGET_USE_STDARG. + +2002-05-20 Hrvoje Niksic + + * windows/config.h.ms: Ditto. + + * windows/config.h.bor: Don't #define __STDC__. + +2002-05-18 Hrvoje Niksic + + * ALL: Update the license to reflect the OpenSSL exception. + +2002-04-23 Ian Abbott + + * windows/config.h.ms: Accounted for MSVC not defining `__STDC__' when + Microsoft's extensions are enabled and define it anyway (set to `1'). + Defined some things that broke as a result of this. + +2002-04-20 Hrvoje Niksic + + * po/de.po: Updated from the TP. + +2001-04-15 Ian Abbott + + windows/wget.dep: The target `connect$o' (connect.obj) now depends on + `utils.h'. + +2001-04-15 Hrvoje Niksic + + * po/da.po: Ditto. + + * po/de.po: Ditto. + + * po/el.po: Ditto. + + * po/es.po: Ditto. + + * po/et.po: Ditto. + + * po/fr.po: Ditto. + + * po/gl.po: Ditto. + + * po/he.po: Ditto. + + * po/ja.po: Ditto. + + * po/pl.po: Ditto. + [... truncated: 144505 lines follow ...] From axeld at mail.berlios.de Thu Aug 14 14:28:45 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 14 Aug 2008 14:28:45 +0200 Subject: [Haiku-commits] r26971 - in haiku/trunk/src/add-ons/mail_daemon: inbound_protocols/imap inbound_protocols/pop3 outbound_protocols/smtp Message-ID: <200808141228.m7ECSj88000283@sheep.berlios.de> Author: axeld Date: 2008-08-14 14:28:44 +0200 (Thu, 14 Aug 2008) New Revision: 26971 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26971&view=rev Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/Jamfile haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_config.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/Jamfile haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.h haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/Jamfile haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.h Log: * If USE_SSL is set when compiling the MDR add-ons, SSL will be used. * By default, it will use a directory generated/cross-ssl where you need to unzip the optional openssl package into before. If you're on Haiku, you can use the SSL_DIR environment variable to point it to /boot/home/config instead. * Fixed build with USE_SSL defined. * Renamed USESSL to USE_SSL. Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/Jamfile =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/Jamfile 2008-08-14 02:10:31 UTC (rev 26970) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/Jamfile 2008-08-14 12:28:44 UTC (rev 26971) @@ -11,9 +11,14 @@ SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ; -if $(USESSL) { - SubDirC++Flags -DUSESSL ; - SubDirHdrs [ FDirName / boot home config include ] ; +if $(USE_SSL) { + SubDirC++Flags -DUSE_SSL ; + if ! $(SSL_DIR) { + sslDir = [ FDirName $(HAIKU_OUTPUT_DIR) cross-ssl config ] ; + } else { + sslDir = $(SSL_DIR) ; + } + SubDirSysHdrs [ FDirName $(sslDir) include ] ; } Addon IMAP : @@ -23,10 +28,10 @@ LinkAgainst IMAP : be libmail.so $(TARGET_NETWORK_LIBS) ; -if $(USESSL) { - LinkAgainst IMAP : ssl crypto ; +if $(USE_SSL) { + LinkAgainst IMAP : $(sslDir)/lib/libssl.so $(sslDir)/lib/libcrypto.so ; } Package haiku-maildaemon-cvs : - IMAP : + IMAP : boot home config add-ons mail_daemon inbound_protocols ; Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp 2008-08-14 02:10:31 UTC (rev 26970) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp 2008-08-14 12:28:44 UTC (rev 26971) @@ -1,3 +1,10 @@ +/* + * Copyright 2007-2008, Haiku Inc. All Rights Reserved. + * Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ + #include #include #include @@ -22,13 +29,13 @@ #include #include #ifndef HAIKU_TARGET_PLATFORM_BEOS // These headers don't exist in BeOS R5. - #include - #include +# include +# include #endif -#ifdef USESSL - #include - #include +#ifdef USE_SSL +# include +# include #endif #include "NestedString.h" @@ -51,13 +58,13 @@ public: IMAP4Client(BMessage *settings, BMailChainRunner *run); virtual ~IMAP4Client(); - + virtual status_t GetMessage(const char *mailbox, const char *message, BPositionIO **, BMessage *headers); virtual status_t AddMessage(const char *mailbox, BPositionIO *data, BString *id); - + virtual status_t DeleteMessage(const char *mailbox, const char *message); virtual status_t CopyMessage(const char *mailbox, const char *to_mailbox, BString *message); - + virtual status_t CreateMailbox(const char *mailbox); virtual status_t DeleteMailbox(const char *mailbox); @@ -67,43 +74,43 @@ BPath* out_folder_location) { return BRemoteMailStorageProtocol::GetMessage(uid, out_file, out_headers, out_folder_location); } virtual status_t DeleteMessage(const char* uid) { return BRemoteMailStorageProtocol::DeleteMessage(uid); } - + void GetUniqueIDs(); - + status_t ReceiveLine(BString &out); status_t SendCommand(const char *command); - + status_t Select(const char *mb, bool force_reselect = false, bool queue_new_messages = true, bool noop = true, bool no_command = false, bool ignore_forced_reselect = false); status_t Close(); - + virtual status_t InitCheck(BString *) { if (net < 0 && err == B_OK) return net; return err; } - + int GetResponse(BString &tag, NestedString *parsed_response, bool report_literals = false, bool recursion_flag = false); bool WasCommandOkay(BString &response); - + void InitializeMailboxes(); - + private: friend class NoopWorker; friend class IMAP4PartialReader; - + NoopWorker *noop; BMessageRunner *nooprunner; - + int32 commandCount; int net; BString selected_mb, inbox_name, hierarchy_delimiter, mb_root; BList box_info; status_t err; - - #ifdef USESSL + + #ifdef USE_SSL SSL_CTX *ctx; SSL *ssl; BIO *sbio; - + bool use_ssl; #endif - + bool force_reselect; }; @@ -113,10 +120,10 @@ void MessageReceived(BMessage *msg) { if (msg->what != 'impn' /* IMaP Noop */) return; - + if ((time(NULL) - last_run) < 9) return; - + us->Select(us->inbox_name.String()); last_run = time(NULL); } @@ -127,32 +134,32 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMailStorageProtocol(settings,run), noop(NULL), commandCount(0), net(-1), selected_mb(""), force_reselect(false) { err = B_OK; - + mb_root = settings->FindString("root"); - #ifdef USESSL + #ifdef USE_SSL use_ssl = (settings->FindInt32("flavor") == 1); ssl = NULL; ctx = NULL; #endif - + int port = settings->FindInt32("port"); - + if (port <= 0) - #ifdef USESSL + #ifdef USE_SSL port = use_ssl ? 993 : 143; #else port = 143; #endif -//-----Open TCP link +//-----Open TCP link runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Opening connection...","???...")); - + uint32 hostIP = inet_addr(settings->FindString("server")); // first see if we can parse it as a numeric address if ((hostIP == 0)||(hostIP == (uint32)-1)) { struct hostent * he = gethostbyname(settings->FindString("server")); hostIP = he ? *((uint32*)he->h_addr) : 0; } - + if (hostIP == 0) { BString error; error << "Could not connect to IMAP server " << settings->FindString("server"); @@ -163,7 +170,7 @@ runner->Stop(true); return; } - + #ifndef HAIKU_TARGET_PLATFORM_BEOS net = socket(AF_INET, SOCK_STREAM, 0); #else @@ -203,8 +210,8 @@ runner->Stop(true); return; } - -#ifdef USESSL + +#ifdef USE_SSL if (use_ssl) { SSL_library_init(); SSL_load_error_strings(); @@ -212,12 +219,12 @@ /*--- Because we're an add-on loaded at an unpredictable time, all the memory addresses and things contained in ourself are esssentially random. */ - + ctx = SSL_CTX_new(SSLv23_method()); ssl = SSL_new(ctx); sbio=BIO_new_socket(net,BIO_NOCLOSE); SSL_set_bio(ssl,sbio,sbio); - + if (SSL_connect(ssl) <= 0) { BString error; error << "Could not connect to IMAP server " << settings->FindString("server"); @@ -236,16 +243,16 @@ return; } } - + #endif - + //-----Wait for welcome message BString response; ReceiveLine(response); //-----Log in runner->ReportProgress(0,0,MDR_DIALECT_CHOICE ("Authenticating...","???...")); - + const char *password = settings->FindString("password"); { char *passwd = get_passwd(settings,"cpasswd"); @@ -265,30 +272,30 @@ runner->Stop(true); return; } - + runner->ReportProgress(0,0,"Logged in"); - + InitializeMailboxes(); GetUniqueIDs(); - + BStringList to_dl; unique_ids->NotThere(*manifest,&to_dl); - + noop = new NoopWorker(this); runner->AddHandler(noop); nooprunner = new BMessageRunner(BMessenger(noop,runner),new BMessage('impn'),10e6); - + if (to_dl.CountItems() > 0) runner->GetMessages(&to_dl,-1); } IMAP4Client::~IMAP4Client() { - if (net > 0) { + if (net > 0) { if (selected_mb != "") SendCommand("CLOSE"); SendCommand("LOGOUT"); - - #ifdef USESSL + + #ifdef USE_SSL if (use_ssl) { if (ssl) SSL_shutdown(ssl); @@ -296,7 +303,7 @@ SSL_CTX_free(ctx); } #endif - + #ifndef HAIKU_TARGET_PLATFORM_BEOS close(net); #else @@ -307,16 +314,16 @@ for (int32 i = 0; i < box_info.CountItems(); i++) delete (struct mailbox_info *)(box_info.ItemAt(i)); - + delete noop; } void IMAP4Client::InitializeMailboxes() { BString command; command << "LSUB \"" << mb_root << "\" \"*\""; - + SendCommand(command.String()); - + BString tag; char expected[255]; ::sprintf(expected,"a%.7ld",commandCount); @@ -328,10 +335,10 @@ val = GetResponse(tag,&response); if (val != NOT_COMMAND_RESPONSE) break; - + if (tag == expected) break; - + if (response[3]()[0] != '.') { struct mailbox_info *info = new struct mailbox_info; info->exists = -1; @@ -341,7 +348,7 @@ BString parsed_name = response[3](); if ((mb_root != "") && (strncmp(mb_root.String(),parsed_name.String(),mb_root.Length()) == 0)) parsed_name.Remove(0,mb_root.Length()); - + if (strcasecmp(response[2](),"NIL")) { hierarchy_delimiter = response[2](); if (strcmp(response[2](),"/")) { @@ -349,24 +356,24 @@ parsed_name.ReplaceAll('/','\\'); else parsed_name.ReplaceAll('/','-'); - + parsed_name.ReplaceAll(response[2](),"/"); } } if (parsed_name.ByteAt(0) == '/') parsed_name.Remove(0,1); - + mailboxes += parsed_name.String(); if (strcasecmp(parsed_name.String(),"INBOX") == 0) inbox_name = parsed_name; - + BPath blorp(path); blorp.Append(parsed_name.String()); create_directory(blorp.Path(),0777); } } while (1); - - + + if (hierarchy_delimiter == "" || hierarchy_delimiter == "NIL") { SendCommand("LIST \"\" \"\""); NestedString dem; @@ -375,8 +382,8 @@ if (hierarchy_delimiter == "" || hierarchy_delimiter == "NIL") hierarchy_delimiter = "/"; } - - if (mb_root.ByteAt(mb_root.Length() - 1) != hierarchy_delimiter.ByteAt(0)) { + + if (mb_root.ByteAt(mb_root.Length() - 1) != hierarchy_delimiter.ByteAt(0)) { command = "SELECT "; command << mb_root; SendCommand(command.String()); @@ -385,10 +392,10 @@ info->exists = -1; info->next_uid = -1; info->server_mb_name = mb_root; - + mailboxes += ""; box_info.AddItem(info); - + if (strcasecmp(mb_root.String(),"INBOX") == 0) inbox_name = ""; SendCommand("CLOSE"); @@ -403,21 +410,21 @@ status_t IMAP4Client::AddMessage(const char *mailbox, BPositionIO *data, BString *id) { Select(mailbox); //---Update info - + const int32 box_index = mailboxes.IndexOf(mailbox); char expected[255]; BString tag; - + BString command = "APPEND \""; off_t size; data->Seek(0,SEEK_END); size = data->Position(); - + BString attributes = "\\Seen"; - + { BNode *node = dynamic_cast(data); - + if (node != NULL) { BString status; node->ReadAttrString(B_MAIL_ATTR_STATUS,&status); @@ -429,68 +436,68 @@ attributes += " \\Answered"; } } - - + + command << ((struct mailbox_info *)(box_info.ItemAt(box_index)))->server_mb_name << "\" (" << attributes << ") {" << size << '}'; SendCommand(command.String()); status_t err = ReceiveLine(command); if (err < B_OK) return err; - + char *buffer = new char[size]; data->ReadAt(0,buffer,size); -#ifdef USESSL +#ifdef USE_SSL if (use_ssl) { SSL_write(ssl,buffer,size); SSL_write(ssl,"\r\n",2); - } else + } else #endif { send(net,buffer,size,0); send(net,"\r\n",2,0); } Select(mailbox,false,false,false,true); - + if (((struct mailbox_info *)(box_info.ItemAt(box_index)))->next_uid <= 0) { command = "FETCH "; command << ((struct mailbox_info *)(box_info.ItemAt(box_index)))->exists << " UID"; - + SendCommand(command.String()); ::sprintf(expected,"a%.7ld",commandCount); *id = ""; while (1) { NestedString response; GetResponse(tag,&response); - + if (tag == expected) break; - + *id = response[2][1](); } } else { *id = ""; *id << (((struct mailbox_info *)(box_info.ItemAt(box_index)))->next_uid - 1); } - + return B_OK; } status_t IMAP4Client::DeleteMessage(const char *mailbox, const char *message) { BString command = "UID STORE "; command << message << " +FLAGS.SILENT (\\Deleted)"; - + if (Select(mailbox,false,true,true,false,true) < B_OK) return B_ERROR; - + SendCommand(command.String()); if (!WasCommandOkay(command)) { command.Prepend("Error while deleting message: "); runner->ShowError(command.String()); return B_ERROR; } - + force_reselect = true; - + return B_OK; } @@ -498,44 +505,44 @@ struct mailbox_info *to_mb = (struct mailbox_info *)(box_info.ItemAt(mailboxes.IndexOf(to_mailbox))); char expected[255]; BString tag; - + Select(mailbox); - + BString command = "UID COPY "; command << *message << " \"" << to_mb->server_mb_name << '\"'; SendCommand(command.String()); if (!WasCommandOkay(command)) return B_ERROR; - + Select(to_mailbox,false,false,true); //---Update mailbox info - + if (to_mb->next_uid <= 0) { command = "FETCH "; command << to_mb->exists << " UID"; - + SendCommand(command.String()); ::sprintf(expected,"a%.7ld",commandCount); *message = ""; while (1) { NestedString response; GetResponse(tag,&response); - + if (tag == expected) break; - + *message = response[2][1](); } } else { *message = ""; *message << (to_mb->next_uid - 1); } - + return B_OK; } status_t IMAP4Client::CreateMailbox(const char *mailbox) { Close(); - + struct mailbox_info *info = new struct mailbox_info; info->exists = -1; info->next_uid = -1; @@ -543,20 +550,20 @@ info->server_mb_name.ReplaceAll("/",hierarchy_delimiter.String()); if ((mb_root.ByteAt(mb_root.Length() - 1) != hierarchy_delimiter.ByteAt(0)) && (mb_root.Length() > 0)) info->server_mb_name.Prepend(hierarchy_delimiter); - + info->server_mb_name.Prepend(mb_root.String()); - + BString command; command << "CREATE \"" << info->server_mb_name << '\"'; SendCommand(command.String()); BString response; WasCommandOkay(response); //--- Deliberately ignore errors in the case of extant, but unsubscribed, mailboxes - + command = "SUBSCRIBE \""; command << info->server_mb_name << '\"'; SendCommand(command.String()); - + if (!WasCommandOkay(response)) { command = "Error creating mailbox "; command << mailbox << ". The server said: \n" << response << "\nThis may mean you can't create a new mailbox in this location."; @@ -564,40 +571,40 @@ delete info; return B_ERROR; } - + box_info.AddItem(info); - + return B_OK; } status_t IMAP4Client::DeleteMailbox(const char *mailbox) { Close(); - + if (!mailboxes.HasItem(mailbox)) return B_ERROR; - + BString command; - + command = "UNSUBSCRIBE \""; command << ((struct mailbox_info *)(box_info.ItemAt(mailboxes.IndexOf(mailbox))))->server_mb_name << '\"'; SendCommand(command.String()); WasCommandOkay(command); //---If this fails, that's fine. - + command = "DELETE \""; command << ((struct mailbox_info *)(box_info.ItemAt(mailboxes.IndexOf(mailbox))))->server_mb_name << '\"'; - + SendCommand(command.String()); if (!WasCommandOkay(command)) { command = "Error deleting mailbox "; command << mailbox << '.'; runner->ShowError(command.String()); - + return B_ERROR; } - + delete ((struct mailbox_info *)(box_info.RemoveItem(mailboxes.IndexOf(mailbox)))); - + return B_OK; } @@ -607,28 +614,28 @@ BString tag; BString uid; struct mailbox_info *info; - + runner->ReportProgress(0,0,"Getting Unique IDs"); - + for (int32 i = 0; i < mailboxes.CountItems(); i++) { Select(mailboxes[i],true,false /* We queue them as a group */); - + info = (struct mailbox_info *)(box_info.ItemAt(i)); if (info->exists <= 0) continue; - + command = "FETCH 1:"; command << info->exists << " UID"; - SendCommand(command.String()); - + SendCommand(command.String()); + ::sprintf(expected,"a%.7ld",commandCount); while(1) { NestedString response; GetResponse(tag,&response); - + if (tag == expected) break; - + uid = mailboxes[i]; uid << '/' << response[2][1](); unique_ids->AddItem(uid.String()); @@ -642,31 +649,31 @@ SendCommand("CLOSE"); if (!WasCommandOkay(worthless)) return B_ERROR; - + selected_mb = ""; } - + return B_OK; } status_t IMAP4Client::Select(const char *mb, bool reselect, bool queue_new_messages, bool noop, bool no_command, bool ignore_forced_reselect) { if (net < 0) return B_NO_INIT; - + if (force_reselect && !ignore_forced_reselect) { reselect = true; force_reselect = false; } - + if (reselect) Close(); - + struct mailbox_info *info = (struct mailbox_info *)(box_info.ItemAt(mailboxes.IndexOf(mb))); if (info == NULL) return B_NAME_NOT_FOUND; const char *real_mb = info->server_mb_name.String(); - + if ((selected_mb != real_mb) || (noop) || (no_command)) { if ((selected_mb != "") && (selected_mb != real_mb)){ BString trash; @@ -680,35 +687,35 @@ cmd = "NOOP"; else cmd << "SELECT \"" << real_mb << '\"'; - + if (!no_command) if (SendCommand(cmd.String()) < B_OK) return B_ERROR; - + char expected[255]; BString tag; ::sprintf(expected,"a%.7ld",commandCount); - + int32 new_exists(-1), new_next_uid(-1), recent(-1); - + while(1) { NestedString response; if (GetResponse(tag,&response) < B_OK) return B_ERROR; - + if (tag == expected) break; - + if ((response.CountItems() > 1) && (strcasecmp(response[1](),"EXISTS") == 0)) new_exists = atoi(response[0]()); - + if (response[0].CountItems() == 2 && strcasecmp(response[0][0](),"UIDNEXT") == 0) new_next_uid = atol(response[0][1]()); - + if ((response.CountItems() > 1) && (strcasecmp(response[1](),"RECENT") == 0)) recent = atoi(response[0]()); } - + if ((queue_new_messages) && (recent > 0)) { BString command = "FETCH "; command << new_exists - recent + 1 << ':' << new_exists << " UID"; @@ -720,31 +727,31 @@ NestedString response; if (GetResponse(tag,&response) < 0) return B_ERROR; - + if (tag == expected) break; - + if (strcmp(response[2][0](),"UID") != 0) continue; //--- Courier IMAP blows. Hard. - + uid = mb; uid << '/' << response[2][1](); if (!unique_ids->HasItem(uid.String())) list.AddItem(uid.String()); } - + if (list.CountItems() > 0) { (*unique_ids) += list; runner->GetMessages(&list,-1); } } - + info->exists = new_exists; info->next_uid = new_next_uid; - + selected_mb = real_mb; } - + return B_OK; } @@ -757,7 +764,7 @@ delete slave; us->runner->ReportProgress(0,1); } - off_t Seek(off_t position, uint32 seek_mode) { + off_t Seek(off_t position, uint32 seek_mode) { if (seek_mode == SEEK_END) { if (!done) { slave->Seek(0,SEEK_END); @@ -792,9 +799,9 @@ NestedString response; if (us->GetResponse(command,&response) != NOT_COMMAND_RESPONSE && command == cmd) return; - + //response.PrintToStream(); - + us->WasCommandOkay(command); for (int32 i = 0; (i+1) < response[2].CountItems(); i++) { if (strcmp(response[2][i](),part) == 0) { @@ -802,16 +809,16 @@ break; } } - + } - + IMAP4Client *us; char unique[25]; BPositionIO *slave; bool done; }; -status_t IMAP4Client::GetMessage(const char *mailbox, const char *message, BPositionIO **data, BMessage *headers) { +status_t IMAP4Client::GetMessage(const char *mailbox, const char *message, BPositionIO **data, BMessage *headers) { { //--- Error reporting for non-existant messages often simply doesn't exist. So we have to check first... BString uid = mailbox; @@ -823,21 +830,21 @@ return B_NAME_NOT_FOUND; } } - + Select(mailbox); - - if (headers->FindBool("ENTIRE_MESSAGE")) { + + if (headers->FindBool("ENTIRE_MESSAGE")) { BString command = "UID FETCH "; command << message << " (FLAGS RFC822)"; - + SendCommand(command.String()); static char cmd[255]; ::sprintf(cmd,"a%.7ld"CRLF,commandCount); NestedString response; - + if (GetResponse(command,&response,true) != NOT_COMMAND_RESPONSE && command == cmd) return B_ERROR; - + for (int32 i = 0; i < response[2][1].CountItems(); i++) { if (strcmp(response[2][1][i](),"\\Seen") == 0) { headers->AddString("STATUS","Read"); @@ -855,7 +862,7 @@ headers->AddString("STATUS","Replied"); } } - + WasCommandOkay(command); (*data)->WriteAt(0,response[2][5](),strlen(response[2][5]())); runner->ReportProgress(0,1); @@ -869,9 +876,9 @@ NestedString response; if (GetResponse(command,&response) != NOT_COMMAND_RESPONSE && command == cmd) return B_ERROR; - + WasCommandOkay(command); - + for (int32 i = 0; i < response[2].CountItems(); i++) { if (strcmp(response[2][i](),"RFC822.SIZE") == 0) { i++; @@ -891,7 +898,7 @@ (*data)->Write(response[2][i](),strlen(response[2][i]())); } } - + *data = new IMAP4PartialReader(this,*data,message); return B_OK; } @@ -902,10 +909,10 @@ { if (net < 0) return B_ERROR; - + static char cmd[255]; ::sprintf(cmd,"a%.7ld %s"CRLF,++commandCount,command); -#ifdef USESSL +#ifdef USE_SSL if (use_ssl) SSL_write(ssl,cmd,strlen(cmd)); else @@ -913,7 +920,7 @@ send(net,cmd,strlen(cmd),0); PRINT(("C: %s",cmd)); - + return B_OK; } @@ -922,38 +929,38 @@ { if (net < 0) return net; - + uint8 c = 0; int32 len = 0,r; out = ""; - + struct timeval tv; - struct fd_set fds; + struct fd_set fds; - tv.tv_sec = long(kIMAP4ClientTimeout / 1e6); - tv.tv_usec = long(kIMAP4ClientTimeout-(tv.tv_sec * 1e6)); - - /* Initialize (clear) the socket mask. */ + tv.tv_sec = long(kIMAP4ClientTimeout / 1e6); + tv.tv_usec = long(kIMAP4ClientTimeout-(tv.tv_sec * 1e6)); + + /* Initialize (clear) the socket mask. */ FD_ZERO(&fds); - - /* Set the socket in the mask. */ + + /* Set the socket in the mask. */ FD_SET(net, &fds); int result; -#ifdef USESSL +#ifdef USE_SSL if ((use_ssl) && (SSL_pending(ssl))) result = 1; else #endif result = select(32, &fds, NULL, NULL, &tv); - + if (result < 0) return errno; - + if(result > 0) { while(c != '\n' && c != xEOF) { - #ifdef USESSL + #ifdef USE_SSL if (use_ssl) r = SSL_read(ssl,&c,1); else @@ -962,7 +969,7 @@ if(r <= 0) { BString error; error << "Connection to " << settings->FindString("server") << " lost."; - #ifdef USESSL + #ifdef USE_SSL if (use_ssl) { if (ssl) SSL_shutdown(ssl); @@ -980,7 +987,7 @@ runner->ShowError(error.String()); return -1; } - + out += (char)c; len += r; } @@ -997,7 +1004,7 @@ int IMAP4Client::GetResponse(BString &tag, NestedString *parsed_response, bool report_literals, bool internal_flag) { if (net < 0) return net; - + uint8 c = 0; int32 r; int8 delimiters_passed = internal_flag ? 2 : 0; @@ -1006,30 +1013,30 @@ bool in_quote = false; bool was_cr = false; [... truncated: 948 lines follow ...] From axeld at mail.berlios.de Thu Aug 14 16:28:21 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 14 Aug 2008 16:28:21 +0200 Subject: [Haiku-commits] r26972 - in haiku/trunk/src: add-ons/kernel/drivers/disk/scsi/scsi_cd add-ons/kernel/drivers/disk/scsi/scsi_disk system/kernel/device_manager Message-ID: <200808141428.m7EESL1E011221@sheep.berlios.de> Author: axeld Date: 2008-08-14 16:28:20 +0200 (Thu, 14 Aug 2008) New Revision: 26972 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26972&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp haiku/trunk/src/system/kernel/device_manager/dma_resources.h Log: * Fixed the mix of bufferCount vs. max_segment_count with regards to B_BLOCK_DEVICE_MAX_SG_BLOCKS as pointed out by Ingo. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-14 12:28:44 UTC (rev 26971) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-14 14:28:20 UTC (rev 26972) @@ -817,7 +817,7 @@ } // TODO: we need to replace the DMAResource in our IOScheduler - status_t status = info->dma_resource->Init(info->node, blockSize); + status_t status = info->dma_resource->Init(info->node, blockSize, 32); if (status != B_OK) panic("initializing DMAResource failed: %s", strerror(status)); Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-14 12:28:44 UTC (rev 26971) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-14 14:28:20 UTC (rev 26972) @@ -363,7 +363,7 @@ } // TODO: we need to replace the DMAResource in our IOScheduler - status_t status = info->dma_resource->Init(info->node, blockSize); + status_t status = info->dma_resource->Init(info->node, blockSize, 32); if (status != B_OK) panic("initializing DMAResource failed: %s", strerror(status)); Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-14 12:28:44 UTC (rev 26971) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-14 14:28:20 UTC (rev 26972) @@ -115,7 +115,7 @@ status_t -DMAResource::Init(device_node* node, size_t blockSize) +DMAResource::Init(device_node* node, size_t blockSize, uint32 bufferCount) { dma_restrictions restrictions; memset(&restrictions, 0, sizeof(dma_restrictions)); @@ -139,10 +139,9 @@ B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &value, true) == B_OK) restrictions.max_transfer_size = value * blockSize; - uint32 bufferCount; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_MAX_SG_BLOCKS, &bufferCount, true) != B_OK) - bufferCount = 16; + B_BLOCK_DEVICE_MAX_SG_BLOCKS, &value, true) == B_OK) + restrictions.max_segment_count = value; return Init(restrictions, blockSize, bufferCount); } Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-14 12:28:44 UTC (rev 26971) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.h 2008-08-14 14:28:20 UTC (rev 26972) @@ -72,7 +72,8 @@ status_t Init(const dma_restrictions& restrictions, size_t blockSize, uint32 bufferCount); - status_t Init(device_node* node, size_t blockSize); + status_t Init(device_node* node, size_t blockSize, + uint32 bufferCount); status_t CreateBuffer(DMABuffer** _buffer) { return CreateBuffer(0, _buffer); } From axeld at mail.berlios.de Thu Aug 14 17:08:19 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 14 Aug 2008 17:08:19 +0200 Subject: [Haiku-commits] r26973 - in haiku/trunk: headers/os/drivers headers/private/drivers src/add-ons/kernel/bus_managers src/add-ons/kernel/bus_managers/ata src/add-ons/kernel/bus_managers/ide src/add-ons/kernel/bus_managers/scsi src/add-ons/kernel/busses/ide/ide_isa src/add-ons/kernel/busses/ide/legacy_sata src/add-ons/kernel/busses/ide/promise_tx2 src/add-ons/kernel/busses/ide/silicon_image_3112 src/add-ons/kernel/busses/scsi/ahci src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/add-ons/kernel/generic src/add-ons/kernel/generic/ide_adapter src/add-ons/kernel/generic/scsi_periph src/system/kernel/device_manager Message-ID: <200808141508.m7EF8JoH013973@sheep.berlios.de> Author: axeld Date: 2008-08-14 17:08:16 +0200 (Thu, 14 Aug 2008) New Revision: 26973 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26973&view=rev Removed: haiku/trunk/headers/os/drivers/block_io.h haiku/trunk/src/add-ons/kernel/generic/block_io/ Modified: haiku/trunk/headers/os/drivers/device_manager.h haiku/trunk/headers/private/drivers/scsi_periph.h haiku/trunk/src/add-ons/kernel/bus_managers/Jamfile haiku/trunk/src/add-ons/kernel/bus_managers/ata/channels.c haiku/trunk/src/add-ons/kernel/bus_managers/ide/channels.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/busses.c haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/promise_tx2.c haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h haiku/trunk/src/add-ons/kernel/generic/Jamfile haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp Log: * Replaced the B_BLOCK_DEVICE_* defines with B_DMA_* defines that better match our dma_restrictions structure (but we're using blocks instead of bytes, since unlike the block size, the restrictions attributes are constant). * We might want to use blocks for the dma_restrictions structure as well in the future... * Fixed another bug in the device_node variant of DMAResource::Init(): the max segment size was specified in blocks as well. * Removed the "hardcode" block_io module and header. Deleted: haiku/trunk/headers/os/drivers/block_io.h Modified: haiku/trunk/headers/os/drivers/device_manager.h =================================================================== --- haiku/trunk/headers/os/drivers/device_manager.h 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/headers/os/drivers/device_manager.h 2008-08-14 15:08:16 UTC (rev 26973) @@ -150,6 +150,14 @@ #define B_FIND_MULTIPLE_CHILDREN 0x02 #define B_KEEP_DRIVER_LOADED 0x04 +/* DMA attributes */ +#define B_DMA_LOW_ADDRESS "dma/low_address" +#define B_DMA_HIGH_ADDRESS "dma/high_address" +#define B_DMA_ALIGNMENT "dma/alignment" +#define B_DMA_BOUNDARY "dma/boundary" +#define B_DMA_MAX_TRANSFER_BLOCKS "dma/max_transfer_blocks" +#define B_DMA_MAX_SEGMENT_BLOCKS "dma/max_segment_blocks" +#define B_DMA_MAX_SEGMENT_COUNT "dma/max_segment_count" /* interface of device */ Modified: haiku/trunk/headers/private/drivers/scsi_periph.h =================================================================== --- haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-14 15:08:16 UTC (rev 26973) @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Copyright 2004-2008, Haiku, Inc. All RightsReserved. * Copyright 2002/03, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -18,7 +18,6 @@ #include -#include #include #include Modified: haiku/trunk/src/add-ons/kernel/bus_managers/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/Jamfile 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/bus_managers/Jamfile 2008-08-14 15:08:16 UTC (rev 26973) @@ -4,6 +4,7 @@ SubInclude HAIKU_TOP src add-ons kernel bus_managers agp_gart ; SubInclude HAIKU_TOP src add-ons kernel bus_managers config_manager ; SubInclude HAIKU_TOP src add-ons kernel bus_managers firewire ; +#SubInclude HAIKU_TOP src add-ons kernel bus_managers ata ; SubInclude HAIKU_TOP src add-ons kernel bus_managers ide ; SubInclude HAIKU_TOP src add-ons kernel bus_managers isa ; SubInclude HAIKU_TOP src add-ons kernel bus_managers pci ; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ata/channels.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ata/channels.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ata/channels.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -16,8 +16,6 @@ #include #include -#include - #define TRACE dprintf @@ -30,7 +28,7 @@ TRACE("ide_channel_added, parent is %p\n", parent); - if (pnp->get_attr_string(parent, IDE_CONTROLLER_CONTROLLER_NAME_ITEM, + if (pnp->get_attr_string(parent, IDE_CONTROLLER_CONTROLLER_NAME_ITEM, &controller_name, true) != B_OK) { dprintf("ide: ignored controller - controller name missing\n"); goto err; @@ -61,7 +59,7 @@ // which should be sufficient) // Note: to fix specific drive bugs, use ide_sim_get_restrictions() // in ide_sim.c! - { B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }}, + { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 255 }}, { IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }}, // { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }}, // { PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }}, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/channels.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/channels.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/channels.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -18,9 +18,7 @@ #include #include -#include - /** called when an IDE channel was registered by a controller driver */ static status_t @@ -62,7 +60,7 @@ // which should be sufficient) // Note: to fix specific drive bugs, use ide_sim_get_restrictions() // in ide_sim.c! - { B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }}, + { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 255 }}, { IDE_CHANNEL_ID_ITEM, B_UINT32_TYPE, { ui32: channel_id }}, // { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, { string: IDE_CHANNEL_ID_GENERATOR }}, // { PNP_MANAGER_AUTO_ID, B_UINT32_TYPE, { ui32: channel_id }}, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/busses.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/busses.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/busses.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -18,7 +18,6 @@ #include #include -#include // bus service should hurry up a bit - good controllers don't take much time @@ -198,19 +197,23 @@ return B_NO_MEMORY; // extract controller/protocoll restrictions from node - if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_DMA_ALIGNMENT, &bus->dma_params.alignment, true) != B_OK) + if (pnp->get_attr_uint32(node, B_DMA_ALIGNMENT, &bus->dma_params.alignment, + true) != B_OK) bus->dma_params.alignment = 0; - if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &bus->dma_params.max_blocks, true) != B_OK) + if (pnp->get_attr_uint32(node, B_DMA_MAX_TRANSFER_BLOCKS, + &bus->dma_params.max_blocks, true) != B_OK) bus->dma_params.max_blocks = 0xffffffff; - if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_DMA_BOUNDARY, &bus->dma_params.dma_boundary, true) != B_OK) + if (pnp->get_attr_uint32(node, B_DMA_BOUNDARY, + &bus->dma_params.dma_boundary, true) != B_OK) bus->dma_params.dma_boundary = ~0; - if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &bus->dma_params.max_sg_block_size, true) != B_OK) + if (pnp->get_attr_uint32(node, B_DMA_MAX_SEGMENT_BLOCKS, + &bus->dma_params.max_sg_block_size, true) != B_OK) bus->dma_params.max_sg_block_size = 0xffffffff; - if (pnp->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_SG_BLOCKS, &bus->dma_params.max_sg_blocks, true) != B_OK) + if (pnp->get_attr_uint32(node, B_DMA_MAX_SEGMENT_COUNT, + &bus->dma_params.max_sg_blocks, true) != B_OK) bus->dma_params.max_sg_blocks = ~0; // do some sanity check: - // (see blkman.c) bus->dma_params.max_sg_block_size &= ~bus->dma_params.alignment; if (bus->dma_params.alignment > B_PAGE_SIZE) { Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/devices.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -15,8 +15,6 @@ #include "scsi_internal.h" -#include - #include #include #include @@ -103,7 +101,8 @@ // find maximum transfer blocks // set default value to max (need something like ULONG_MAX here) orig_max_blocks = ~0; - pnp->get_attr_uint32(bus->node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &orig_max_blocks, true); + pnp->get_attr_uint32(bus->node, B_DMA_MAX_TRANSFER_BLOCKS, &orig_max_blocks, + true); max_blocks = min(max_blocks, orig_max_blocks); @@ -130,7 +129,7 @@ { B_DEVICE_BUS, B_STRING_TYPE, { string: "scsi" }}, // extra restriction of maximum number of blocks per transfer - { B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: max_blocks }}, + { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: max_blocks }}, // atapi emulation { SCSI_DEVICE_IS_ATAPI_ITEM, B_UINT8_TYPE, { ui8: is_atapi }}, Modified: haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -20,7 +20,6 @@ #include #include #include -#include //#define TRACE_IDE_ISA @@ -78,7 +77,7 @@ // DMA properties; the 16 bit alignment is not necessary as // the ide bus manager handles that very efficiently, but why // not use the block device manager for doing that? - { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1 }}, + { B_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1 }}, // private data to identify device { IDE_ISA_COMMAND_BLOCK_BASE, B_UINT16_TYPE, { ui16: command_block_base }}, Modified: haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -9,7 +9,6 @@ #include #include #include -#include #define DRIVER_PRETTY_NAME "Legacy SATA" Modified: haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/promise_tx2.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/promise_tx2.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/promise_tx2.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -12,7 +12,6 @@ #include #include -#include #define debug_level_flow 0 #define debug_level_error 3 @@ -95,7 +94,7 @@ if (channel->dmaing) { // in DMA mode, there is a safe test // in PIO mode, this doesn't work - *(uint8 *)&bm_status = pci->read_io_8( device, + *(uint8 *)&bm_status = pci->read_io_8( device, channel->bus_master_base + ide_bm_status_reg ); if (!bm_status.interrupt) @@ -179,7 +178,7 @@ // publish node of ide controller static status_t -publish_controller(device_node_handle parent, uint16 bus_master_base, uint8 intnum, +publish_controller(device_node_handle parent, uint16 bus_master_base, uint8 intnum, io_resource_handle *resources, device_node_handle *node) { device_attr attrs[] = { @@ -199,13 +198,13 @@ // DMA properties // some say it must be dword-aligned, others that it can be byte-aligned; // stay on the safe side - { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 3 }}, + { B_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 3 }}, // one S/G block must not cross 64K boundary - { B_BLOCK_DEVICE_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: 0xffff }}, + { B_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: 0xffff }}, // size of S/G block is 16 bits with zero being 64K - { B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, B_UINT32_TYPE, { ui32: 0x10000 }}, - // see definition of MAX_SG_COUNT - { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, + { B_DMA_MAX_SEGMENT_BLOCKS, B_UINT32_TYPE, { ui32: 0x10000 }}, + { B_DMA_MAX_SEGMENT_COUNT, B_UINT32_TYPE, + { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, // private data to find controller { IDE_ADAPTER_BUS_MASTER_BASE, B_UINT16_TYPE, { ui16: bus_master_base }}, @@ -249,7 +248,7 @@ return publish_controller(parent, bus_master_base, intnum, resource_handles, node); } - + static status_t probe_controller(device_node_handle parent) { @@ -284,14 +283,14 @@ if (res != B_OK || controller_node == NULL) goto err; - ide_adapter->detect_channel(pci, device, controller_node, + ide_adapter->detect_channel(pci, device, controller_node, PROMISE_TX2_CHANNEL_MODULE_NAME, true, command_block_base[0], control_block_base[0], bus_master_base, intnum, 0, "Primary Channel", &channels[0], false); - ide_adapter->detect_channel(pci, device, controller_node, - PROMISE_TX2_CHANNEL_MODULE_NAME, true, - command_block_base[1], control_block_base[1], bus_master_base, intnum, + ide_adapter->detect_channel(pci, device, controller_node, + PROMISE_TX2_CHANNEL_MODULE_NAME, true, + command_block_base[1], control_block_base[1], bus_master_base, intnum, 1, "Secondary Channel", &channels[1], false); pnp->uninit_driver(parent); @@ -299,7 +298,7 @@ return B_OK; err: - pnp->uninit_driver(parent); + pnp->uninit_driver(parent); return res; } Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -11,7 +11,6 @@ #include #include -#include #define TRACE(x...) dprintf("si-3112: " x) //#define FLOW(x...) dprintf("si-3112: " x) @@ -225,13 +224,13 @@ // DMA properties // data must be word-aligned; // warning: some controllers are more picky! - { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1}}, + { B_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1}}, // one S/G block must not cross 64K boundary - { B_BLOCK_DEVICE_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: 0xffff }}, + { B_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: 0xffff }}, // max size of S/G block is 16 bits with zero being 64K - { B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, B_UINT32_TYPE, { ui32: 0x10000 }}, - // see definition of MAX_SG_COUNT - { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, + { B_DMA_MAX_SEGMENT_BLOCKS, B_UINT32_TYPE, { ui32: 0x10000 }}, + { B_DMA_MAX_SEGMENT_COUNT, B_UINT32_TYPE, + { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, // private data to find controller { "silicon_image_3112/asic_index", B_UINT32_TYPE, { ui32: asicIndex }}, Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -8,9 +8,7 @@ #include #include -#include - #define TRACE(a...) dprintf("\33[35mahci:\33[0m " a) #define FLOW(a...) dprintf("ahci: " a) @@ -148,7 +146,7 @@ { SCSI_DESCRIPTION_CONTROLLER_NAME, B_STRING_TYPE, { string: AHCI_DEVICE_MODULE_NAME }}, - { B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, { ui32: 255 }}, + { B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, { ui32: 255 }}, { AHCI_ID_ITEM, B_UINT32_TYPE, { ui32: id }}, // { PNP_MANAGER_ID_GENERATOR, B_STRING_TYPE, // { string: AHCI_ID_GENERATOR }}, @@ -237,16 +235,12 @@ // DMA properties // data must be word-aligned; - { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, - { ui32: 1 }}, + { B_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: 1 }}, // one S/G block must not cross 64K boundary - { B_BLOCK_DEVICE_DMA_BOUNDARY, B_UINT32_TYPE, - { ui32: 0xffff }}, + { B_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: 0xffff }}, // max size of S/G block is 16 bits with zero being 64K - { B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, B_UINT32_TYPE, - { ui32: 0x10000 }}, - // see definition of MAX_SG_COUNT - { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, + { B_DMA_MAX_SEGMENT_BLOCKS, B_UINT32_TYPE, { ui32: 0x10000 }}, + { B_DMA_MAX_SEGMENT_COUNT, B_UINT32_TYPE, { ui32: 32 /* whatever... */ }}, { NULL } }; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-14 15:08:16 UTC (rev 26973) @@ -674,7 +674,7 @@ static status_t -cd_io(void *cookie, io_request *request) +cd_io(void* cookie, io_request* request) { cd_handle* handle = (cd_handle*)cookie; @@ -797,7 +797,7 @@ static void -cd_set_capacity(cd_driver_info *info, uint64 capacity, uint32 blockSize) +cd_set_capacity(cd_driver_info* info, uint64 capacity, uint32 blockSize) { TRACE("cd_set_capacity(info = %p, capacity = %Ld, blockSize = %ld)\n", info, capacity, blockSize); @@ -838,7 +838,7 @@ static void -cd_media_changed(cd_driver_info *info, scsi_ccb *request) +cd_media_changed(cd_driver_info* info, scsi_ccb* request) { // do a capacity check // TBD: is this a good idea (e.g. if this is an empty CD)? @@ -856,9 +856,9 @@ static float -cd_supports_device(device_node *parent) +cd_supports_device(device_node* parent) { - const char *bus; + const char* bus; uint8 deviceType; // make sure parent is really the SCSI bus manager @@ -883,20 +883,20 @@ server by the block_io module */ static status_t -cd_register_device(device_node *node) +cd_register_device(device_node* node) { - const scsi_res_inquiry *deviceInquiry = NULL; + const scsi_res_inquiry* deviceInquiry = NULL; size_t inquiryLength; uint32 maxBlocks; // get inquiry data if (sDeviceManager->get_attr_raw(node, SCSI_DEVICE_INQUIRY_ITEM, - (const void **)&deviceInquiry, &inquiryLength, true) != B_OK + (const void**)&deviceInquiry, &inquiryLength, true) != B_OK || inquiryLength < sizeof(deviceInquiry)) return B_ERROR; // get block limit of underlying hardware to lower it (if necessary) - if (sDeviceManager->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, + if (sDeviceManager->get_attr_uint32(node, B_DMA_MAX_TRANSFER_BLOCKS, &maxBlocks, true) != B_OK) maxBlocks = INT_MAX; @@ -907,10 +907,8 @@ // ready to register device_attr attrs[] = { - // tell block_io whether the device is removable {"removable", B_UINT8_TYPE, {ui8: deviceInquiry->removable_medium}}, - // impose own max block restriction - {B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, {ui32: maxBlocks}}, + {B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, {ui32: maxBlocks}}, { NULL } }; @@ -920,24 +918,21 @@ static status_t -cd_init_driver(device_node *node, void **cookie) +cd_init_driver(device_node* node, void** _cookie) { - cd_driver_info *info; - status_t status; - uint8 removable; - TRACE("cd_init_driver"); - status = sDeviceManager->get_attr_uint8(node, "removable", + uint8 removable; + status_t status = sDeviceManager->get_attr_uint8(node, "removable", &removable, false); if (status != B_OK) return status; - info = (cd_driver_info *)malloc(sizeof(*info)); + cd_driver_info* info = (cd_driver_info*)malloc(sizeof(cd_driver_info)); if (info == NULL) return B_NO_MEMORY; - memset(info, 0, sizeof(*info)); + memset(info, 0, sizeof(cd_driver_info)); info->dma_resource = new(std::nothrow) DMAResource; if (info->dma_resource == NULL) { @@ -956,8 +951,8 @@ &info->device_type, true); device_node *parent = sDeviceManager->get_parent_node(node); - sDeviceManager->get_driver(parent, (driver_module_info **)&info->scsi, - (void **)&info->scsi_device); + sDeviceManager->get_driver(parent, (driver_module_info**)&info->scsi, + (void**)&info->scsi_device); sDeviceManager->put_node(parent); status = sSCSIPeripheral->register_device((periph_device_cookie)info, @@ -968,15 +963,15 @@ return status; } - *cookie = info; + *_cookie = info; return B_OK; } static void -cd_uninit_driver(void *_cookie) +cd_uninit_driver(void* _cookie) { - cd_driver_info *info = (cd_driver_info *)_cookie; + cd_driver_info* info = (cd_driver_info*)_cookie; sSCSIPeripheral->unregister_device(info->scsi_periph_device); free(info); @@ -984,17 +979,15 @@ static status_t -cd_register_child_devices(void *_cookie) +cd_register_child_devices(void* _cookie) { - cd_driver_info *info = (cd_driver_info *)_cookie; - status_t status; - char *name; + cd_driver_info* info = (cd_driver_info*)_cookie; - name = sSCSIPeripheral->compose_device_name(info->node, "disk/scsi"); + char* name = sSCSIPeripheral->compose_device_name(info->node, "disk/scsi"); if (name == NULL) return B_ERROR; - status = sDeviceManager->publish_device(info->node, name, + status_t status = sDeviceManager->publish_device(info->node, name, SCSI_CD_DEVICE_MODULE_NAME); free(name); Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.h 2008-08-14 15:08:16 UTC (rev 26973) @@ -7,7 +7,6 @@ #define _SCSI_CD_H -#include #include #include #include Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-14 15:08:16 UTC (rev 26973) @@ -441,7 +441,7 @@ return B_ERROR; // get block limit of underlying hardware to lower it (if necessary) - if (sDeviceManager->get_attr_uint32(node, B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, + if (sDeviceManager->get_attr_uint32(node, B_DMA_MAX_TRANSFER_BLOCKS, &maxBlocks, true) != B_OK) maxBlocks = INT_MAX; @@ -455,7 +455,7 @@ // tell block_io whether the device is removable {"removable", B_UINT8_TYPE, {ui8: deviceInquiry->removable_medium}}, // impose own max block restriction - {B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, B_UINT32_TYPE, {ui32: maxBlocks}}, + {B_DMA_MAX_TRANSFER_BLOCKS, B_UINT32_TYPE, {ui32: maxBlocks}}, { NULL } }; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.h 2008-08-14 15:08:16 UTC (rev 26973) @@ -7,7 +7,6 @@ #define _SCSI_DISK_H -#include #include #include #include Modified: haiku/trunk/src/add-ons/kernel/generic/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/Jamfile 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/generic/Jamfile 2008-08-14 15:08:16 UTC (rev 26973) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src add-ons kernel generic ; SubInclude HAIKU_TOP src add-ons kernel generic atomizer ; -SubInclude HAIKU_TOP src add-ons kernel generic block_io ; SubInclude HAIKU_TOP src add-ons kernel generic dpc ; SubInclude HAIKU_TOP src add-ons kernel generic ide_adapter ; SubInclude HAIKU_TOP src add-ons kernel generic locked_pool ; Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2008-08-14 15:08:16 UTC (rev 26973) @@ -19,7 +19,6 @@ #include #include #include -#include #include #define debug_level_flow 0 @@ -656,18 +655,20 @@ // command queuing always works (unless controller is buggy) { IDE_CONTROLLER_CAN_CQ_ITEM, B_UINT8_TYPE, { ui8: can_cq }}, // choose any name here - { IDE_CONTROLLER_CONTROLLER_NAME_ITEM, B_STRING_TYPE, { string: controller_name }}, + { IDE_CONTROLLER_CONTROLLER_NAME_ITEM, B_STRING_TYPE, + { string: controller_name }}, // DMA properties // data must be word-aligned; // warning: some controllers are more picky! - { B_BLOCK_DEVICE_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: dma_alignment /*1*/}}, + { B_DMA_ALIGNMENT, B_UINT32_TYPE, { ui32: dma_alignment /*1*/}}, // one S/G block must not cross 64K boundary - { B_BLOCK_DEVICE_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: dma_boundary/*0xffff*/ }}, + { B_DMA_BOUNDARY, B_UINT32_TYPE, { ui32: dma_boundary/*0xffff*/ }}, // max size of S/G block is 16 bits with zero being 64K - { B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, B_UINT32_TYPE, { ui32: max_sg_block_size/*0x10000*/ }}, - // see definition of MAX_SG_COUNT - { B_BLOCK_DEVICE_MAX_SG_BLOCKS, B_UINT32_TYPE, { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, + { B_DMA_MAX_SEGMENT_BLOCKS, B_UINT32_TYPE, + { ui32: max_sg_block_size/*0x10000*/ }}, + { B_DMA_MAX_SEGMENT_COUNT, B_UINT32_TYPE, + { ui32: IDE_ADAPTER_MAX_SG_COUNT }}, // private data to find controller { IDE_ADAPTER_BUS_MASTER_BASE, B_UINT16_TYPE, { ui16: bus_master_base }}, Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h 2008-08-14 15:08:16 UTC (rev 26973) @@ -10,7 +10,6 @@ #include #include -#include #include #include "io_requests.h" Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-14 14:28:20 UTC (rev 26972) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-14 15:08:16 UTC (rev 26973) @@ -6,7 +6,7 @@ #include "dma_resources.h" -#include +#include #include #include @@ -124,23 +124,23 @@ uint32 value; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_DMA_ALIGNMENT, &value, true) == B_OK) + B_DMA_ALIGNMENT, &value, true) == B_OK) restrictions.alignment = value + 1; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_DMA_BOUNDARY, &value, true) == B_OK) + B_DMA_BOUNDARY, &value, true) == B_OK) restrictions.boundary = value + 1; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_MAX_SG_BLOCK_SIZE, &value, true) == B_OK) - restrictions.max_segment_size = value; + B_DMA_MAX_SEGMENT_BLOCKS, &value, true) == B_OK) + restrictions.max_segment_size = value * blockSize; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_MAX_BLOCKS_ITEM, &value, true) == B_OK) + B_DMA_MAX_TRANSFER_BLOCKS, &value, true) == B_OK) restrictions.max_transfer_size = value * blockSize; if (gDeviceManagerModule.get_attr_uint32(node, - B_BLOCK_DEVICE_MAX_SG_BLOCKS, &value, true) == B_OK) + B_DMA_MAX_SEGMENT_COUNT, &value, true) == B_OK) restrictions.max_segment_count = value; return Init(restrictions, blockSize, bufferCount); From axeld at mail.berlios.de Sun Aug 17 16:58:36 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 16:58:36 +0200 Subject: [Haiku-commits] r27005 - haiku/trunk/src/system/libroot/os Message-ID: <200808171458.m7HEwaeP020769@sheep.berlios.de> Author: axeld Date: 2008-08-17 16:58:36 +0200 (Sun, 17 Aug 2008) New Revision: 27005 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27005&view=rev Modified: haiku/trunk/src/system/libroot/os/parsedate.cpp Log: * Style cleanup, no functional change. Modified: haiku/trunk/src/system/libroot/os/parsedate.cpp =================================================================== --- haiku/trunk/src/system/libroot/os/parsedate.cpp 2008-08-17 14:32:33 UTC (rev 27004) +++ haiku/trunk/src/system/libroot/os/parsedate.cpp 2008-08-17 14:58:36 UTC (rev 27005) @@ -1,21 +1,22 @@ -/* -** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2008, Axel D?rfler, axeld at pinc-software.de. + * Distributed under the terms of the MIT License. + */ -#include #include +#include +#include #include -#include #include -#include +#include -#define TRACE_PARSEDATE 0 + +#define TRACE_PARSEDATE 1 #if TRACE_PARSEDATE -# define TRACE(x) printf x ; +# define TRACE(x) debug_printf x ; #else # define TRACE(x) ; #endif @@ -106,11 +107,11 @@ "H [p]", NULL }; -static const char * const *sFormatsTable = kFormatsTable; +static const char* const* sFormatsTable = kFormatsTable; enum field_type { - TYPE_UNKNOWN = 0, + TYPE_UNKNOWN = 0, TYPE_DAY, TYPE_MONTH, @@ -173,14 +174,21 @@ }; static const known_identifier kIdentifiers[] = { - {"today", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, UNIT_DAY, 0}, - {"tomorrow", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, UNIT_DAY, 1}, - {"yesterday", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, UNIT_DAY, -1}, - {"now", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE | FLAG_NOW, 0}, + {"today", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, + UNIT_DAY, 0}, + {"tomorrow", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, + UNIT_DAY, 1}, + {"yesterday", NULL, TYPE_UNIT, FLAG_RELATIVE | FLAG_NOT_MODIFIABLE, + UNIT_DAY, -1}, + {"now", NULL, TYPE_UNIT, + FLAG_RELATIVE | FLAG_NOT_MODIFIABLE | FLAG_NOW, 0}, - {"this", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, MODIFY_THIS}, - {"next", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, MODIFY_NEXT}, - {"last", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, MODIFY_LAST}, + {"this", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, + MODIFY_THIS}, + {"next", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, + MODIFY_NEXT}, + {"last", NULL, TYPE_MODIFIER, FLAG_NEXT_LAST_THIS, UNIT_NONE, + MODIFY_LAST}, {"years", "year", TYPE_UNIT, FLAG_RELATIVE, UNIT_YEAR, 1}, {"months", "month",TYPE_UNIT, FLAG_RELATIVE, UNIT_MONTH, 1}, @@ -194,7 +202,8 @@ {"minutes", "mins", TYPE_UNIT, FLAG_RELATIVE, UNIT_SECOND, 60}, {"am", NULL, TYPE_MERIDIAN, FLAG_NOT_MODIFIABLE, UNIT_SECOND, 0}, - {"pm", NULL, TYPE_MERIDIAN, FLAG_NOT_MODIFIABLE, UNIT_SECOND, 12 * 60 * 60}, + {"pm", NULL, TYPE_MERIDIAN, FLAG_NOT_MODIFIABLE, UNIT_SECOND, + 12 * 60 * 60}, {"sunday", "sun", TYPE_WEEKDAY, FLAG_NONE, UNIT_DAY, 0}, {"monday", "mon", TYPE_WEEKDAY, FLAG_NONE, UNIT_DAY, 1}, @@ -218,7 +227,7 @@ {"december", "dec", TYPE_MONTH, FLAG_NONE, UNIT_MONTH, 12}, {"GMT", NULL, TYPE_TIME_ZONE, FLAG_NONE, UNIT_SECOND, 0}, - // ToDo: add more time zones + // TODO: add more time zones {NULL} }; @@ -230,7 +239,7 @@ DateMask() : fMask(0UL) {} void Set(uint8 type) { fMask |= Flag(type); } - bool IsSet(uint8 type) { return fMask & Flag(type); } + bool IsSet(uint8 type) { return (fMask & Flag(type)) != 0; } bool HasTime(); bool IsComplete(); @@ -250,16 +259,16 @@ uint8 value_type; int8 modifier; bigtime_t value; - + void SetCharType(uint8 fieldType, int8 modify = MODIFY_NONE); - void Adopt(const known_identifier &identifier); - void AdoptUnit(const known_identifier &identifier); + void Adopt(const known_identifier& identifier); + void AdoptUnit(const known_identifier& identifier); bool IsNextLastThis(); }; -void +void parsed_element::SetCharType(uint8 fieldType, int8 modify) { base_type = type = fieldType; @@ -268,13 +277,13 @@ } -void -parsed_element::Adopt(const known_identifier &identifier) +void +parsed_element::Adopt(const known_identifier& identifier) { base_type = type = identifier.type; flags = identifier.flags; unit = identifier.unit; - + if (identifier.type == TYPE_MODIFIER) modifier = identifier.value; @@ -283,8 +292,8 @@ } -void -parsed_element::AdoptUnit(const known_identifier &identifier) +void +parsed_element::AdoptUnit(const known_identifier& identifier) { base_type = type = TYPE_UNIT; flags = identifier.flags; @@ -297,31 +306,31 @@ parsed_element::IsNextLastThis() { return base_type == TYPE_MODIFIER - && (modifier == MODIFY_NEXT || modifier == MODIFY_LAST || modifier == MODIFY_THIS); + && (modifier == MODIFY_NEXT || modifier == MODIFY_LAST + || modifier == MODIFY_THIS); } // #pragma mark - -bool +bool DateMask::HasTime() { - // this will cause + // this will cause return IsSet(TYPE_HOUR); } -/** This method checks if the date mask is complete in the - * sense that it doesn't need to have a prefilled "struct tm" - * when its time value is computed. - */ - -bool +/*! This method checks if the date mask is complete in the + sense that it doesn't need to have a prefilled "struct tm" + when its time value is computed. +*/ +bool DateMask::IsComplete() { // mask must be absolute, at last - if (fMask & Flag(TYPE_UNIT)) + if ((fMask & Flag(TYPE_UNIT)) != 0) return false; // minimal set of flags to have a complete set @@ -332,8 +341,8 @@ // #pragma mark - -status_t -preparseDate(const char *dateString, parsed_element *elements) +static status_t +preparseDate(const char* dateString, parsed_element* elements) { int32 index = 0, modify = MODIFY_NONE; char c; @@ -385,11 +394,12 @@ // skip number while (isdigit(dateString[1])) dateString++; - + // check for "1st", "2nd, "3rd", "4th", ... - - const char *suffixes[] = {"th", "st", "nd", "rd"}; - const char *validSuffix = elements[index].value > 3 ? "th" : suffixes[elements[index].value]; + + const char* suffixes[] = {"th", "st", "nd", "rd"}; + const char* validSuffix = elements[index].value > 3 + ? "th" : suffixes[elements[index].value]; if (!strncasecmp(dateString + 1, validSuffix, 2) && !isalpha(dateString[3])) { // for now, just ignore the suffix - but we might be able @@ -400,7 +410,7 @@ } else if (isalpha(c)) { // fetch whole string - const char *string = dateString; + const char* string = dateString; while (isalpha(dateString[1])) dateString++; int32 length = dateString + 1 - string; @@ -408,7 +418,7 @@ // compare with known strings // ToDo: should understand other languages as well... - const known_identifier *identifier = kIdentifiers; + const known_identifier* identifier = kIdentifiers; for (; identifier->string; identifier++) { if (!strncasecmp(identifier->string, string, length) && !identifier->string[length]) @@ -486,7 +496,7 @@ static void -computeRelativeUnit(parsed_element &element, struct tm &tm, int *_flags) +computeRelativeUnit(parsed_element& element, struct tm& tm, int* _flags) { // set the relative start depending on unit @@ -504,7 +514,7 @@ // adjust value - if (element.flags & FLAG_RELATIVE) { + if ((element.flags & FLAG_RELATIVE) != 0) { if (element.unit == UNIT_MONTH) tm.tm_mon += element.value; else if (element.unit == UNIT_DAY) @@ -536,17 +546,17 @@ } -/** Uses the format assignment (through "format", and "optional") for the parsed elements - * and calculates the time value with respect to "now". - * Will also set the day/minute relative flags in "_flags". - */ - +/*! Uses the format assignment (through "format", and "optional") for the + parsed elements and calculates the time value with respect to "now". + Will also set the day/minute relative flags in "_flags". +*/ static time_t -computeDate(const char *format, bool *optional, parsed_element *elements, time_t now, DateMask dateMask, int *_flags) +computeDate(const char* format, bool* optional, parsed_element* elements, + time_t now, DateMask dateMask, int* _flags) { TRACE(("matches: %s\n", format)); - parsed_element *element = elements; + parsed_element* element = elements; uint32 position = 0; struct tm tm; @@ -641,8 +651,9 @@ tm.tm_sec += element->value - timezone; break; case 'T': // time unit - if (element->flags & FLAG_NOW) { - *_flags = PARSEDATE_MINUTE_RELATIVE_TIME | PARSEDATE_RELATIVE_TIME; + if ((element->flags & FLAG_NOW) != 0) { + *_flags = PARSEDATE_MINUTE_RELATIVE_TIME + | PARSEDATE_RELATIVE_TIME; break; } @@ -666,10 +677,10 @@ time_t -parsedate_etc(const char *dateString, time_t now, int *_flags) +parsedate_etc(const char* dateString, time_t now, int* _flags) { // preparse date string so that it can be easily compared to our formats - + parsed_element elements[MAX_ELEMENTS]; if (preparseDate(dateString, elements) < B_OK) { @@ -681,10 +692,10 @@ for (int32 index = 0; elements[index].type != TYPE_END; index++) { parsed_element e = elements[index]; - printf(" %ld: type = %ld, base_type = %ld, unit = %ld, flags = %ld, value = %Ld (%s)\n", - index, e.type, e.base_type, e.unit, e.flags, e.value, - e.value_type == VALUE_NUMERICAL ? "numerical" : - (e.value_type == VALUE_STRING ? "string" : "char")); + printf(" %ld: type = %u, base_type = %u, unit = %u, flags = %u, " + "value = %Ld (%s)\n", index, e.type, e.base_type, e.unit, e.flags, + e.value, e.value_type == VALUE_NUMERICAL + ? "numerical" : (e.value_type == VALUE_STRING ? "string" : "char")); } #endif @@ -692,12 +703,12 @@ for (int32 index = 0; sFormatsTable[index]; index++) { // test if this format matches our date string - - const char *format = sFormatsTable[index]; + + const char* format = sFormatsTable[index]; uint32 position = 0; DateMask dateMask; - parsed_element *element = elements; + parsed_element* element = elements; while (element->type != TYPE_END) { // skip whitespace while (isspace(format[0])) @@ -744,7 +755,7 @@ case 'd': if (element->value > 31) goto next_format; - + dateMask.Set(TYPE_DAY); break; case 'm': @@ -775,7 +786,7 @@ dateMask.Set(TYPE_UNIT); break; case '-': - if (element->flags & FLAG_HAS_DASH) { + if ((element->flags & FLAG_HAS_DASH) != 0) { element--; // consider this element again break; } @@ -784,7 +795,7 @@ goto next_format; } break; - + case VALUE_STRING: switch (format[0]) { case 'a': // weekday @@ -833,14 +844,15 @@ // one is only optional (in which case we can continue) if (!optional[position]) goto skip_format; - + optional[position] = false; format += 2; position++; // skip the closing ']' } - // check if the format is already empty (since we reached our last element) + // check if the format is already empty (since we reached our last + // element) while (format[0]) { if (format[0] == '[') format += 3; @@ -854,7 +866,8 @@ // made it here? then we seem to have found our guy - return computeDate(sFormatsTable[index], optional, elements, now, dateMask, _flags); + return computeDate(sFormatsTable[index], optional, elements, now, + dateMask, _flags); skip_format: // check if the next format has the same beginning as the skipped one, @@ -873,24 +886,24 @@ time_t -parsedate(const char *dateString, time_t now) +parsedate(const char* dateString, time_t now) { int flags = 0; - + return parsedate_etc(dateString, now, &flags); } void -set_dateformats(const char **table) +set_dateformats(const char** table) { sFormatsTable = table ? table : kFormatsTable; } -const char ** +const char** get_dateformats(void) { - return const_cast(sFormatsTable); + return const_cast(sFormatsTable); } From axeld at mail.berlios.de Sun Aug 17 17:00:26 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 17:00:26 +0200 Subject: [Haiku-commits] r27006 - haiku/trunk/src/system/libroot/os Message-ID: <200808171500.m7HF0QkA021043@sheep.berlios.de> Author: axeld Date: 2008-08-17 17:00:25 +0200 (Sun, 17 Aug 2008) New Revision: 27006 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27006&view=rev Modified: haiku/trunk/src/system/libroot/os/parsedate.cpp Log: * Fixed bug #2616, preparseDate() would clear the elements array beyond its maximal size. * Turned off debug output accidently enabled with the last commit. Modified: haiku/trunk/src/system/libroot/os/parsedate.cpp =================================================================== --- haiku/trunk/src/system/libroot/os/parsedate.cpp 2008-08-17 14:58:36 UTC (rev 27005) +++ haiku/trunk/src/system/libroot/os/parsedate.cpp 2008-08-17 15:00:25 UTC (rev 27006) @@ -14,9 +14,9 @@ #include -#define TRACE_PARSEDATE 1 +#define TRACE_PARSEDATE 0 #if TRACE_PARSEDATE -# define TRACE(x) debug_printf x ; +# define TRACE(x) printf x ; #else # define TRACE(x) ; #endif @@ -482,7 +482,8 @@ index++; } - memset(&elements[index], 0, sizeof(parsed_element)); + if (index < MAX_ELEMENTS) + memset(&elements[index], 0, sizeof(parsed_element)); } // were there any elements? From anevilyak at mail.berlios.de Sat Aug 16 07:11:39 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sat, 16 Aug 2008 07:11:39 +0200 Subject: [Haiku-commits] r26989 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200808160511.m7G5BdxS025367@sheep.berlios.de> Author: anevilyak Date: 2008-08-16 07:11:36 +0200 (Sat, 16 Aug 2008) New Revision: 26989 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26989&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: Use __HAIKU__ instead of HAIKU_HOST_PLATFORM_HAIKU since apparently the latter doesn't get defined when cross compiling. Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 04:26:27 UTC (rev 26988) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 05:11:36 UTC (rev 26989) @@ -35,7 +35,9 @@ # include "PartitionMap.h" # include "PartitionMapParser.h" -#elif HAIKU_HOST_PLATFORM_HAIKU +#endif + +#ifdef __HAIKU__ # include #endif @@ -228,7 +230,7 @@ // read the boot code uint8 *bootCodeData = NULL; -#ifndef HAIKU_HOST_PLATFORM_HAIKU +#ifndef __HAIKU__ bootCodeData = read_boot_code_data(argv[0]); #else image_info info; From bga at mail.berlios.de Sat Aug 16 01:52:23 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sat, 16 Aug 2008 01:52:23 +0200 Subject: [Haiku-commits] r26985 - haiku/trunk/src/add-ons/mail_daemon/inbound_filters/spam_filter Message-ID: <200808152352.m7FNqN34022694@sheep.berlios.de> Author: bga Date: 2008-08-16 01:52:23 +0200 (Sat, 16 Aug 2008) New Revision: 26985 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26985&view=rev Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp Log: - We do not have the AGMS Spam Server in our tree, so fixed signature and names to load the third-party server if provided. Modified: haiku/trunk/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp =================================================================== --- haiku/trunk/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp 2008-08-15 20:55:06 UTC (rev 26984) +++ haiku/trunk/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp 2008-08-15 23:52:23 UTC (rev 26985) @@ -126,7 +126,7 @@ static const char *kAGMSBayesBeepSpamName = "SpamFilter-Spam"; static const char *kAGMSBayesBeepUncertainName = "SpamFilter-Uncertain"; -static const char *kServerSignature = "application/x-vnd.agmsmith.spamdbm"; +static const char *kServerSignature = "application/x-vnd.agmsmith.AGMSBayesianSpamServer"; AGMSBayesianSpamFilter::AGMSBayesianSpamFilter (BMessage *settings) @@ -222,6 +222,7 @@ // inbetween messages. This code used to be in InitCheck, but apparently // that isn't called. + printf("Checking for Spam Server.\n"); if (fLaunchAttemptCount == 0 || !fMessengerToServer.IsValid ()) { if (fLaunchAttemptCount > 3) goto ErrorExit; // Don't try to start the server too many times. @@ -236,7 +237,7 @@ directory_which places[] = {B_COMMON_BIN_DIRECTORY,B_BEOS_BIN_DIRECTORY}; for (int32 i = 0; i < 2; i++) { find_directory(places[i],&path); - path.Append("spamdbm"); + path.Append("AGMSBayesianSpamServer"); if (!BEntry(path.Path()).Exists()) continue; get_ref_for_path(path.Path(),&ref); From anevilyak at mail.berlios.de Sat Aug 16 06:26:28 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sat, 16 Aug 2008 06:26:28 +0200 Subject: [Haiku-commits] r26988 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200808160426.m7G4QSjI000562@sheep.berlios.de> Author: anevilyak Date: 2008-08-16 06:26:27 +0200 (Sat, 16 Aug 2008) New Revision: 26988 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26988&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: Do this somewhat differently so as to not break makebootable on non-Haiku hosts. Thanks to luroh for pointing this out. Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 03:06:02 UTC (rev 26987) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 04:26:27 UTC (rev 26988) @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,8 @@ # include "PartitionMap.h" # include "PartitionMapParser.h" +#elif HAIKU_HOST_PLATFORM_HAIKU +# include #endif @@ -107,27 +108,17 @@ // read_boot_code_data static uint8 * -read_boot_code_data(void) +read_boot_code_data(const char* programPath) { - image_info info; - int32 cookie = 0; + // open our executable BFile executableFile; - - status_t error = get_next_image_info(0, &cookie, &info); - if (error == B_OK) { - // open our executable - error = executableFile.SetTo(info.name, B_READ_ONLY); - if (error != B_OK) { - fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " - "%s\n", info.name, strerror(error)); - exit(1); - } - } else { - fprintf(stderr, "Error: Failed to get image info for executable file, " - "error: %s\n", strerror(error)); + status_t error = executableFile.SetTo(programPath, B_READ_ONLY); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " + "%s\n", programPath, strerror(error)); exit(1); } - + uint8 *bootCodeData = new uint8[kBootCodeSize]; // open our resources @@ -236,7 +227,15 @@ print_usage_and_exit(true); // read the boot code - uint8 *bootCodeData = read_boot_code_data(); + uint8 *bootCodeData = NULL; +#ifndef HAIKU_HOST_PLATFORM_HAIKU + bootCodeData = read_boot_code_data(argv[0]); +#else + image_info info; + int32 cookie = 0; + if (get_next_image_info(0, &cookie, &info) == B_OK) + bootCodeData = read_boot_code_data(info.name); +#endif if (!bootCodeData) { fprintf(stderr, "Error: Failed to read "); exit(1); From axeld at mail.berlios.de Fri Aug 15 16:47:12 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 15 Aug 2008 16:47:12 +0200 Subject: [Haiku-commits] r26981 - haiku/trunk/src/add-ons/kernel/network/protocols/tcp Message-ID: <200808151447.m7FElCWb025245@sheep.berlios.de> Author: axeld Date: 2008-08-15 16:47:11 +0200 (Fri, 15 Aug 2008) New Revision: 26981 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26981&view=rev Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp Log: * Now uses the new wait_for_timer() stack function on destruction - this fixes bug #2143. Modified: haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-08-15 14:46:16 UTC (rev 26980) +++ haiku/trunk/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.cpp 2008-08-15 14:47:11 UTC (rev 26981) @@ -406,7 +406,8 @@ this); gStackModule->init_timer(&fDelayedAcknowledgeTimer, TCPEndpoint::_DelayedAcknowledgeTimer, this); - gStackModule->init_timer(&fTimeWaitTimer, TCPEndpoint::_TimeWaitTimer, this); + gStackModule->init_timer(&fTimeWaitTimer, TCPEndpoint::_TimeWaitTimer, + this); } @@ -424,8 +425,11 @@ mutex_destroy(&fLock); - // TODO: we need to wait for all timers to return - //_WaitForTimers(); + // we need to wait for all timers to return + gStackModule->wait_for_timer(&fRetransmitTimer); + gStackModule->wait_for_timer(&fPersistTimer); + gStackModule->wait_for_timer(&fDelayedAcknowledgeTimer); + gStackModule->wait_for_timer(&fTimeWaitTimer); } From mmlr at mail.berlios.de Sat Aug 16 20:06:53 2008 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Sat, 16 Aug 2008 20:06:53 +0200 Subject: [Haiku-commits] r26992 - haiku/trunk/src/system/boot/loader Message-ID: <200808161806.m7GI6rKc016297@sheep.berlios.de> Author: mmlr Date: 2008-08-16 20:06:52 +0200 (Sat, 16 Aug 2008) New Revision: 26992 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26992&view=rev Modified: haiku/trunk/src/system/boot/loader/load_driver_settings.cpp Log: * Update the size of the safemode settings "file" when concatenating it with the kernel settings. Settings that were checked in the kernel (like on-screen debug output) didn't work anymore, because when handing the settings over to the kernel it would have copied only the old size part of the safemode file. * Add a newline when the kernel and safemode settings are combined. Otherwise the first safemode and last kernel setting would get lost if the kernel settings file didn't end with a newline. Modified: haiku/trunk/src/system/boot/loader/load_driver_settings.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/load_driver_settings.cpp 2008-08-16 12:48:27 UTC (rev 26991) +++ haiku/trunk/src/system/boot/loader/load_driver_settings.cpp 2008-08-16 18:06:52 UTC (rev 26992) @@ -107,17 +107,24 @@ find_driver_settings_file(B_SAFEMODE_DRIVER_SETTINGS); if (safemodeFile != NULL) { char *buffer = (char *)kernel_args_malloc( - safemodeFile->size + kernelFile->size + 1); + safemodeFile->size + kernelFile->size + 2); if (buffer != NULL) { memcpy(buffer, kernelFile->buffer, kernelFile->size); - memcpy(buffer + kernelFile->size, + + // insert a newline just in case the kernel settings file + // doesn't end with one + buffer[kernelFile->size] = '\n'; + + memcpy(buffer + kernelFile->size + 1, safemodeFile->buffer, safemodeFile->size); - buffer[safemodeFile->size + - kernelFile->size] = '\0'; + kernel_args_free(safemodeFile->buffer); safemodeFile->buffer = buffer; + safemodeFile->size = safemodeFile->size + + kernelFile->size + 1; + buffer[safemodeFile->size] = '\0'; } } else add_safe_mode_settings(kernelFile->buffer); From sbenedetto at mail.berlios.de Sat Aug 16 22:27:17 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 16 Aug 2008 22:27:17 +0200 Subject: [Haiku-commits] r26994 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808162027.m7GKRHLd026854@sheep.berlios.de> Author: sbenedetto Date: 2008-08-16 22:27:16 +0200 (Sat, 16 Aug 2008) New Revision: 26994 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26994&view=rev Added: haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp Removed: haiku/trunk/src/add-ons/kernel/file_systems/udf/udf.cpp Log: * Renamed udf.cpp to kernel_interface.cpp and ported it to the new FS API. Added: haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-16 18:20:54 UTC (rev 26993) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-16 20:27:16 UTC (rev 26994) @@ -0,0 +1,585 @@ +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com. + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ + +/*! \file kernel_interface.cpp */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "DirectoryIterator.h" +#include "Icb.h" +#include "Recognition.h" +#include "Utils.h" +#include "Volume.h" + + +#undef TRACE +#undef TRACE_ERROR +#define UDF_KERNEL_INTERFACE_DEBUG +#ifdef UDF_KERNEL_INTERFACE_DEBUG +# define TRACE(x) dprintf x +# define TRACE_ERROR(x) dprintf x +#else +# define TRACE(x) /* nothing */ +# define TRACE_ERROR(x) dprintf x +#endif + +extern fs_volume_ops gUDFVolumeOps; +extern fs_vnode_ops gUDFVnodeOps; + + +// #pragma mark - fs_volume_ops fuctions + +static float +udf_identify_partition(int fd, partition_data *partition, void **_cookie) +{ + TRACE(("udf_identify_partition: fd = %d\n", fd)); + logical_volume_descriptor logicalVolumeDescriptor; + partition_descriptor partitionDescriptors[kMaxPartitionDescriptors]; + uint8 partitionDescriptorCount; + uint32 blockShift; + status_t error = udf_recognize(fd, partition->offset, partition->size, 2048, blockShift, + logicalVolumeDescriptor, partitionDescriptors, partitionDescriptorCount); + + if (!error) { + UdfString name(logicalVolumeDescriptor.logical_volume_identifier()); + strcpy(partition->name, name.Utf8()); + } + return 0.8f; +} + + +static status_t +udf_scan_partition(int fd, partition_data *partition, void *_cookie) +{ + TRACE(("udf_scan_partition: fd = %d\n", fd)); + + return B_ERROR; +} + + +static status_t +udf_unmount(fs_volume *_volume) +{ + TRACE(("udb_unmount: _volume = %p\n", _volume)); + Volume *volume = (Volume *)_volume->private_volume; + delete volume; + return B_OK; +} + + +static status_t +udf_read_fs_stat(fs_volume *_volume, struct fs_info *info) +{ + TRACE(("udf_read_fs_stat: _volume = %p, info = %p\n", _volume, info)); + + Volume *volume = (Volume *)_volume->private_volume; + + // File system flags. + info->flags = B_FS_IS_PERSISTENT | B_FS_IS_READONLY; + + info->io_size = 65536; + // whatever is appropriate here? Just use the same value as BFS (and iso9660) for now + + info->block_size = volume->BlockSize(); + info->total_blocks = volume->Length(); + info->free_blocks = 0; + + // Volume name + sprintf(info->volume_name, "%s", volume->Name()); + + // File system name + strcpy(info->fsh_name, "udf"); + + return B_OK; +} + + +static status_t +udf_get_vnode(fs_volume *_volume, ino_t id, fs_vnode *_node, int *_type, + uint32 *_flags, bool reenter) +{ + TRACE(("udf_get_vnode: id = %Ld, reenter = %s\n", + id, (reenter ? "true" : "false"))); + + Volume *volume = (Volume *)_volume->private_volume; + + // Convert the given vnode id to an address, and create + // and return a corresponding Icb object for it. + Icb *icb = new(std::nothrow) Icb(volume, + to_long_address(id, volume->BlockSize())); + if (icb) { + if(icb->InitCheck() == B_OK) { + if (_node) + _node->private_node = icb; + _node->ops = &gUDFVnodeOps; + _flags = 0; + } else { + TRACE_ERROR(("udf_get_vnode: InitCheck failed\n")); + delete icb; + return B_ERROR; + } + } else + return B_NO_MEMORY; + + return B_OK; +} + + +// #pragma mark - fs_vnode_ops functions + + +static status_t +udf_lookup(fs_volume *_volume, fs_vnode *_directory, const char *file, + ino_t *vnodeID) +{ + TRACE(("udf_lookup: _directory = %p, filename = %s\n", _directory, file)); + + Volume *volume = (Volume *)_volume->private_volume; + Icb *dir = (Icb *)_directory->private_node; + Icb *node = NULL; + + status_t status = B_OK; + + if (strcmp(file, ".") == 0) { + TRACE(("udf_lookup: file = ./\n")); + *vnodeID = dir->Id(); + status = get_vnode(volume->FSVolume(), *vnodeID, (void **)&node); + if (status != B_OK) + return B_ENTRY_NOT_FOUND; + } else { + status = dir->Find(file, vnodeID); + if (status == B_OK) { + Icb *icb; + status = get_vnode(volume->FSVolume(), *vnodeID, + (void **)&icb); + if (status != B_OK) + return B_ENTRY_NOT_FOUND; + } + } + TRACE(("udf_lookup: vnodeId: %Ld\n", *vnodeID)); + + return status; +} + + +static status_t +udf_put_vnode(fs_volume *volume, fs_vnode *node, bool reenter) +{ +// No debug-to-file in release_vnode; can cause a deadlock in +// rare circumstances. +#if !DEBUG_TO_FILE + DEBUG_INIT_ETC(NULL, ("node: %p", node)); +#endif + Icb *icb = reinterpret_cast(node); + delete icb; +#if !DEBUG_TO_FILE + RETURN(B_OK); +#else + return B_OK; +#endif +} + + +static status_t +udf_read_stat(fs_volume *_volume, fs_vnode *node, struct stat *stat) +{ + DEBUG_INIT(NULL); + + if (!_volume || !node || !stat) + RETURN(B_BAD_VALUE); + + Volume *volume = (Volume *)_volume->private_volume; + Icb *icb = reinterpret_cast(node); + + //stat->st_dev = volume->Id(); + stat->st_ino = icb->Id(); + stat->st_nlink = icb->FileLinkCount(); + stat->st_blksize = volume->BlockSize(); + + stat->st_uid = icb->Uid(); + stat->st_gid = icb->Gid(); + + stat->st_mode = icb->Mode(); + PRINT(("mode = 0x%lx\n", uint32(icb->Mode()))); + stat->st_size = icb->Length(); + + // File times. For now, treat the modification time as creation + // time as well, since true creation time is an optional extended + // attribute, and supporting EAs is going to be a PITA. ;-) + stat->st_atime = icb->AccessTime(); + stat->st_mtime = stat->st_ctime = stat->st_crtime = icb->ModificationTime(); + + PRINT(("stat->st_ino: %Ld\n", stat->st_ino)); + + RETURN(B_OK); +} + + +static status_t +udf_read(fs_volume *volume, fs_vnode *vnode, void *cookie, off_t pos, + void *buffer, size_t *length) +{ + TRACE(("udf_read: ID = %d, pos = %d, length = %d\n", + ((Volume *)volume->private_volume)->ID(), pos, length)); + + Icb *icb = (Icb *)vnode->private_node; + +// if (!inode->HasUserAccessableStream()) { +// *_length = 0; +// RETURN_ERROR(B_BAD_VALUE); +// } + + RETURN(icb->Read(pos, buffer, length)); +} + + +static status_t +udf_open_dir(fs_volume *volume, fs_vnode *vnode, void **cookie) +{ + DEBUG_INIT_ETC(NULL, ("node: %p, cookie: %p", node, cookie)); + + if (!volume || !vnode || !cookie) + RETURN(B_BAD_VALUE); + + Icb *dir = (Icb *)vnode->private_node; + + status_t status = B_OK; + + if (dir->IsDirectory()) { + DirectoryIterator *iterator = NULL; + status = dir->GetDirectoryIterator(&iterator); + if (!status) { + *cookie = reinterpret_cast(iterator); + } else { + PRINT(("Error getting directory iterator: 0x%lx, `%s'\n", status, strerror(error))); + } + } else { + PRINT(("Given icb is not a directory (type: %d)\n", dir->Type())); + status = B_BAD_VALUE; + } + + RETURN(status); +} + + +static status_t +udf_read_dir(fs_volume *_volume, fs_vnode *vnode, void *cookie, + struct dirent *dirent, size_t bufferSize, uint32 *_num) +{ + DEBUG_INIT_ETC(NULL, + ("dir: %p, iterator: %p, bufferSize: %ld", node, cookie, bufferSize)); + + if (!_volume || !vnode || !cookie || !_num || bufferSize < sizeof(dirent)) + RETURN(B_BAD_VALUE); + + Volume *volume = (Volume *)_volume->private_volume; + Icb *dir = (Icb *)vnode->private_node; + DirectoryIterator *iterator = reinterpret_cast(cookie); + + if (dir != iterator->Parent()) { + PRINT(("Icb does not match parent Icb of given DirectoryIterator! (iterator->Parent = %p)\n", + iterator->Parent())); + return B_BAD_VALUE; + } + + uint32 nameLength = bufferSize - sizeof(dirent) + 1; + ino_t id; + status_t status = iterator->GetNextEntry(dirent->d_name, &nameLength, &id); + if (!status) { + *_num = 1; + dirent->d_dev = volume->ID(); + dirent->d_ino = id; + dirent->d_reclen = sizeof(dirent) + nameLength - 1; + } else { + *_num = 0; + // Clear the status for end of directory + if (status == B_ENTRY_NOT_FOUND) + status = B_OK; + } + + RETURN(status); +} + + +status_t +udf_rewind_dir(fs_volume *volume, fs_vnode *vnode, void *cookie) +{ + DEBUG_INIT_ETC(NULL, + ("dir: %p, iterator: %p", node, cookie)); + + if (!volume || !vnode || !cookie) + RETURN(B_BAD_VALUE); + + Icb *dir = (Icb *)vnode->private_node; + DirectoryIterator *iterator = reinterpret_cast(cookie); + + if (dir != iterator->Parent()) { + PRINT(("Icb does not match parent Icb of given DirectoryIterator! (iterator->Parent = %p)\n", + iterator->Parent())); + return B_BAD_VALUE; + } + + iterator->Rewind(); + + RETURN(B_OK); +} + + +// #pragma mark - + + +/*! \brief mount + + \todo I'm using the B_GET_GEOMETRY ioctl() to find out where the end of the + partition is. This won't work for handling multi-session semantics correctly. + To support them correctly in R5 I need either: + - A way to get the proper info (best) + - To ignore trying to find anchor volume descriptor pointers at + locations N-256 and N. (acceptable, perhaps, but not really correct) + Either way we should address this problem properly for OBOS::R1. + \todo Looks like B_GET_GEOMETRY doesn't work on non-device files (i.e. + disk images), so I need to use stat or something else for those + instances. +*/ +static status_t +udf_mount(fs_volume *_volume, const char *_device, uint32 flags, + const char *args, ino_t *_rootVnodeID) +{ + TRACE(("udf_mount: device = %s\n", _device)); + status_t status = B_OK; + Volume *volume = NULL; + off_t deviceOffset = 0; + off_t numBlock = 0; + partition_info info; + device_geometry geometry; + + // Here we need to figure out the length of the device, and if we're + // attempting to open a multisession volume, we need to figure out the + // offset into the raw disk at which the volume begins, then open + // the raw volume itself instead of the fake partition device the + // kernel gives us, since multisession UDF volumes are allowed to access + // the data in their own partition, as well as the data in any partitions + // that precede them physically on the disc. + int device = open(_device, O_RDONLY); + status = device < B_OK ? device : B_OK; + if (!status) { + // First try to treat the device like a special partition device. If that's + // what we have, then we can use the partition_info data to figure out the + // name of the raw device (which we'll open instead), the offset into the + // raw device at which the volume of interest will begin, and the total + // length from the beginning of the raw device that we're allowed to access. + // + // If that fails, then we try to treat the device as an actual raw device, + // and see if we can get the device size with B_GET_GEOMETRY syscall, since + // stat()ing a raw device appears to not work. + // + // Finally, if that also fails, we're probably stuck with trying to mount + // a regular file, so we just stat() it to get the device size. + // + // If that fails, you're just SOL. + + if (ioctl(device, B_GET_PARTITION_INFO, &info) == 0) { + PRINT(("partition_info:\n")); + PRINT((" offset: %Ld\n", info.offset)); + PRINT((" size: %Ld\n", info.size)); + PRINT((" logical_block_size: %ld\n", info.logical_block_size)); + PRINT((" session: %ld\n", info.session)); + PRINT((" partition: %ld\n", info.partition)); + PRINT((" device: `%s'\n", info.device)); + _device = info.device; + deviceOffset = info.offset / info.logical_block_size; + numBlock = deviceOffset + info.size / info.logical_block_size; + } else if (ioctl(device, B_GET_GEOMETRY, &geometry) == 0) { + PRINT(("geometry_info:\n")); + PRINT((" sectors_per_track: %ld\n", geometry.sectors_per_track)); + PRINT((" cylinder_count: %ld\n", geometry.cylinder_count)); + PRINT((" head_count: %ld\n", geometry.head_count)); + deviceOffset = 0; + numBlock = (off_t)geometry.sectors_per_track + * geometry.cylinder_count * geometry.head_count; + } else { + struct stat stat; + status = fstat(device, &stat) < 0 ? B_ERROR : B_OK; + if (!status) { + PRINT(("stat_info:\n")); + PRINT((" st_size: %Ld\n", stat.st_size)); + deviceOffset = 0; + numBlock = stat.st_size / 2048; + } + } + // Close the device + close(device); + } + + // Create and mount the volume + volume = new(std::nothrow) Volume(_volume); + status = volume->Mount(_device, deviceOffset, numBlock, 2048, flags); + if (status != B_OK) { + delete volume; + return status; + } + + _volume->private_volume = volume; + _volume->ops = &gUDFVolumeOps; + *_rootVnodeID = *(ino_t *)volume->RootIcb(); + + return B_OK; +} + + +// #pragma mark - + + +static status_t +udf_std_ops(int32 op, ...) +{ + switch (op) { + case B_MODULE_INIT: + case B_MODULE_UNINIT: + return B_OK; + default: + return B_ERROR; + } +} + +fs_volume_ops gUDFVolumeOps = { + &udf_unmount, + &udf_read_fs_stat, + NULL, // write_fs_stat + NULL, // sync + &udf_get_vnode, + + /* index directory & index operations */ + NULL, // open_index_dir + NULL, // close_index_dir + NULL, // free_index_dir_cookie + NULL, // read_index_dir + NULL, // rewind_index_dir + NULL, // create_index + NULL, // remove_index + NULL, // read_index_stat + + /* query operations */ + NULL, // open_query + NULL, // close_query + NULL, // free_query_cookie + NULL, // read_query + NULL, // rewind_query + + /* support for FS layers */ + NULL, // create_sub_vnode + NULL, // delete_sub_vnode +}; + +fs_vnode_ops gUDFVnodeOps = { + /* vnode operatoins */ + &udf_lookup, + NULL, // get_vnode_name + &udf_put_vnode, + NULL, // remove_vnode + + /* VM file access */ + NULL, // can_page + NULL, // read_pages + NULL, // write_pages + + /* asynchronous I/O */ + NULL, // io() + NULL, // cancel_io() + + /* cache file access */ + NULL, // &udf_get_file_map, + + /* common operations */ + NULL, // ioctl + NULL, // set_flags + NULL, // select + NULL, // deselect + NULL, // fsync + NULL, // read_symlink + NULL, // create_symlnk + NULL, // link + NULL, // unlink + NULL, // rename + NULL, // access + &udf_read_stat, + NULL, // write_stat + + /* file operations */ + NULL, // create + NULL, // open + NULL, // close + NULL, // free_cockie + &udf_read, + NULL, // write + + /* directory operations */ + NULL, // create_dir + NULL, // remove_dir + &udf_open_dir, + NULL, // close_dir + NULL, // free_dir_cookie + &udf_read_dir, + &udf_rewind_dir, + + /* attribue directory operations */ + NULL, // open_attr_dir + NULL, // close_attr_dir + NULL, // free_attr_dir_cookie + NULL, // read_attr_dir + NULL, // rewind_attr_dir + + /* attribute operations */ + NULL, // create_attr + NULL, // open_attr + NULL, // close_attr + NULL, // free_attr_cookie + NULL, // read_attr + NULL, // write_attr + NULL, // read_attr_stat + NULL, // write_attr_stat + NULL, // rename_attr + NULL, // remove_attr + + /* support for node and FS layers */ + NULL, // create_special_node + NULL // get_super_vnode + +}; + +static file_system_module_info sUDFFileSystem = { + { + "file_systems/udf" B_CURRENT_FS_API_VERSION, + 0, + udf_std_ops, + }, + + "udf", // short_name + "UDF File System", // pretty_name + 0, // DDM flags + + &udf_identify_partition, + &udf_scan_partition, + NULL, // &udf_free_identify_patition_cookie, + NULL, // free_partition_content_cookie() + + &udf_mount, + + NULL, +}; + +module_info *module[] = { + (module_info *)&sUDFFileSystem, + NULL, +}; Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/udf.cpp From bonefish at mail.berlios.de Thu Aug 14 22:46:19 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Thu, 14 Aug 2008 22:46:19 +0200 Subject: [Haiku-commits] r26975 - haiku/trunk/src/system/kernel/vm Message-ID: <200808142046.m7EKkJkx030269@sheep.berlios.de> Author: bonefish Date: 2008-08-14 22:46:12 +0200 (Thu, 14 Aug 2008) New Revision: 26975 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26975&view=rev Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h Log: Patch by Zhao Shuai with minor changes by myself: * Moved the static functions to the beginning of the file. * Renamed several variables for more clarity, particularly offset/cacheOffset to index/pageIndex in case where the unit is pages. * _SwapBlock{Build,Free}() can deal with a range of pages now, which should be more efficient. * Additional checks/panics in swap_page_alloc(). * swap_file_add(): Wrong byte count was used when allocating and clearing the bitmap. * swap_page_alloc(): Fixed off-by-one check. The last page of the swap file could not be used. Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-14 17:39:33 UTC (rev 26974) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2008-08-14 20:46:12 UTC (rev 26975) @@ -49,8 +49,9 @@ #define SWAP_PAGE_NONE (~(swap_addr_t)0) // bitmap allocation macros -#define MAP_SHIFT 5 -#define NUM_BITS_PER_WORD 32 // number of bits per word +#define NUM_BYTES_PER_WORD 4 +#define NUM_BITS_PER_WORD (8 * NUM_BYTES_PER_WORD) +#define MAP_SHIFT 5 // 1 << MAP_SHIFT == NUM_BITS_PER_WORD #define TESTBIT(map, i) \ (((map)[(i) >> MAP_SHIFT] & (1 << (i) % NUM_BITS_PER_WORD))) @@ -75,7 +76,7 @@ struct swap_hash_key { VMAnonymousCache *cache; - off_t cache_offset; + off_t page_index; // page index in the cache }; // Each swap block contains SWAP_BLOCK_PAGES pages @@ -85,14 +86,6 @@ swap_addr_t swap_pages[SWAP_BLOCK_PAGES]; }; -static swap_addr_t swap_page_alloc(uint32 npages); -static void swap_page_dealloc(swap_addr_t pageIndex, uint32 npages); -static swap_file *find_swap_file(swap_addr_t pageIndex); -static off_t swap_space_reserve(off_t amount); -static void swap_space_unreserve(off_t amount); - -static object_cache *sSwapBlockCache; - struct SwapHashTableDefinition { typedef swap_hash_key KeyType; typedef swap_block ValueType; @@ -101,9 +94,9 @@ size_t HashKey(const swap_hash_key& key) const { - off_t cacheOffset = key.cache_offset >> SWAP_BLOCK_SHIFT; + off_t blockIndex = key.page_index >> SWAP_BLOCK_SHIFT; VMAnonymousCache *cache = key.cache; - return cacheOffset ^ (int)(int *)cache; + return blockIndex ^ (int)(int *)cache; } size_t Hash(const swap_block *value) const @@ -113,8 +106,8 @@ bool Compare(const swap_hash_key& key, const swap_block *value) const { - return (key.cache_offset & ~(off_t)SWAP_BLOCK_MASK) - == (value->key.cache_offset & ~(off_t)SWAP_BLOCK_MASK) + return (key.page_index & ~(off_t)SWAP_BLOCK_MASK) + == (value->key.page_index & ~(off_t)SWAP_BLOCK_MASK) && key.cache == value->key.cache; } @@ -138,18 +131,162 @@ static off_t sAvailSwapSpace = 0; static mutex sAvailSwapSpaceLock; +static object_cache *sSwapBlockCache; + +static swap_addr_t +swap_page_alloc(uint32 npages) +{ + mutex_lock(&sSwapFileListLock); + + if (sSwapFileList.IsEmpty()) { + mutex_unlock(&sSwapFileListLock); + panic("swap_page_alloc(): no swap file in the system\n"); + return SWAP_PAGE_NONE; + } + + // compute how many pages are free in all swap files + uint32 freeSwapPages = 0; + for (SwapFileList::Iterator it = sSwapFileList.GetIterator(); + swap_file *file = it.Next();) + freeSwapPages += file->last_page - file->first_page - file->used; + + if (freeSwapPages < npages) { + mutex_unlock(&sSwapFileListLock); + panic("swap_page_alloc(): swap space exhausted!\n"); + return SWAP_PAGE_NONE; + } + + swap_addr_t hint = 0; + swap_addr_t j; + for (j = 0; j < sSwapFileCount; j++) { + if (sSwapFileAlloc == NULL) + sSwapFileAlloc = sSwapFileList.First(); + + hint = sSwapFileAlloc->hint; + swap_addr_t pageCount = sSwapFileAlloc->last_page + - sSwapFileAlloc->first_page; + + swap_addr_t i = 0; + while (i < npages && (hint + npages) <= pageCount) { + if (TESTBIT(sSwapFileAlloc->maps, hint + i)) { + hint++; + i = 0; + } else + i++; + } + + if (i == npages) + break; + + // this swap_file is full, find another + sSwapFileAlloc = sSwapFileList.GetNext(sSwapFileAlloc); + } + + // no swap file can alloc so many pages, we return SWAP_PAGE_NONE + // and VMAnonymousCache::Write() will adjust allocation amount + if (j == sSwapFileCount) { + mutex_unlock(&sSwapFileListLock); + return SWAP_PAGE_NONE; + } + + swap_addr_t swapAddress = sSwapFileAlloc->first_page + hint; + + for (uint32 i = 0; i < npages; i++) + SETBIT(sSwapFileAlloc->maps, hint + i); + if (hint == sSwapFileAlloc->hint) + sSwapFileAlloc->hint += npages; + + sSwapFileAlloc->used += npages; + + // if this swap file has used more than 90% percent of its pages + // switch to another + if (sSwapFileAlloc->used + > 9 * (sSwapFileAlloc->last_page - sSwapFileAlloc->first_page) / 10) + sSwapFileAlloc = sSwapFileList.GetNext(sSwapFileAlloc); + + mutex_unlock(&sSwapFileListLock); + + return swapAddress; +} + + +static swap_file * +find_swap_file(swap_addr_t swapAddress) +{ + for (SwapFileList::Iterator it = sSwapFileList.GetIterator(); + swap_file *swapFile = it.Next();) { + if (swapAddress >= swapFile->first_page + && swapAddress < swapFile->last_page) + return swapFile; + } + + panic("find_swap_file(): can't find swap file for %ld\n", swapAddress); + return NULL; +} + + +static void +swap_page_dealloc(swap_addr_t swapAddress, uint32 npages) +{ + if (swapAddress == SWAP_PAGE_NONE) + return; + + mutex_lock(&sSwapFileListLock); + swap_file *swapFile = find_swap_file(swapAddress); + + swapAddress -= swapFile->first_page; + + for (uint32 i = 0; i < npages; i++) + CLEARBIT(swapFile->maps, swapAddress + i); + + if (swapFile->hint > swapAddress) + swapFile->hint = swapAddress; + + swapFile->used -= npages; + mutex_unlock(&sSwapFileListLock); +} + + +static off_t +swap_space_reserve(off_t amount) +{ + mutex_lock(&sAvailSwapSpaceLock); + if (sAvailSwapSpace >= amount) + sAvailSwapSpace -= amount; + else { + sAvailSwapSpace = 0; + amount = sAvailSwapSpace; + } + mutex_unlock(&sAvailSwapSpaceLock); + + return amount; +} + + +static void +swap_space_unreserve(off_t amount) +{ + mutex_lock(&sAvailSwapSpaceLock); + sAvailSwapSpace += amount; + mutex_unlock(&sAvailSwapSpaceLock); +} + + +// #pragma mark - + + VMAnonymousCache::~VMAnonymousCache() { // free allocated swap space and swap block for (off_t offset = virtual_base, toFree = fAllocatedSwapSize; offset < virtual_end && toFree > 0; offset += B_PAGE_SIZE) { - swap_addr_t pageIndex = _SwapBlockGetAddress(offset >> PAGE_SHIFT); - if (pageIndex == SWAP_PAGE_NONE) + swap_addr_t swapAddr = _SwapBlockGetAddress(offset >> PAGE_SHIFT); + if (swapAddr == SWAP_PAGE_NONE) continue; - swap_page_dealloc(pageIndex, 1); - _SwapBlockFree(offset >> PAGE_SHIFT); + swap_page_dealloc(swapAddr, 1); + _SwapBlockFree(offset >> PAGE_SHIFT, 1); toFree -= B_PAGE_SIZE; } @@ -202,10 +339,9 @@ bool VMAnonymousCache::HasPage(off_t offset) { - offset >>= PAGE_SHIFT; - swap_addr_t pageIndex = _SwapBlockGetAddress(offset); - if (pageIndex != SWAP_PAGE_NONE) + if (_SwapBlockGetAddress(offset >> PAGE_SHIFT) != SWAP_PAGE_NONE) return true; + return false; } @@ -214,23 +350,19 @@ VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { - off_t cacheOffset = offset >> PAGE_SHIFT; + off_t pageIndex = offset >> PAGE_SHIFT; for (uint32 i = 0, j = 0; i < count; i = j) { - swap_addr_t startPageIndex = _SwapBlockGetAddress(cacheOffset + i); + swap_addr_t startSwapAddr = _SwapBlockGetAddress(pageIndex + i); for (j = i + 1; j < count; j++) { - swap_addr_t pageIndex = _SwapBlockGetAddress(cacheOffset + j); - if (pageIndex != startPageIndex + j - i) + swap_addr_t swapAddr = _SwapBlockGetAddress(pageIndex + j); + if (swapAddr != startSwapAddr + j - i) break; } - swap_file *swapFile = find_swap_file(startPageIndex); - if (swapFile == NULL) { - panic("can't find swap file for page index %ld\n", startPageIndex); - return B_ERROR; - } + swap_file *swapFile = find_swap_file(startSwapAddr); - off_t pos = (startPageIndex - swapFile->first_page) * PAGE_SIZE; + off_t pos = (startSwapAddr - swapFile->first_page) * PAGE_SIZE; status_t status = vfs_read_pages(swapFile->vnode, NULL, pos, vecs + i, j - i, 0, _numBytes); @@ -246,14 +378,14 @@ VMAnonymousCache::Write(off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { - offset >>= PAGE_SHIFT; + off_t pageIndex = offset >> PAGE_SHIFT; Lock(); for (uint32 i = 0; i < count; i++) { - swap_addr_t pageIndex = _SwapBlockGetAddress(offset + i); - if (pageIndex != SWAP_PAGE_NONE) { - swap_page_dealloc(pageIndex, 1); - _SwapBlockFree(offset + i); + swap_addr_t swapAddr = _SwapBlockGetAddress(pageIndex + i); + if (swapAddr != SWAP_PAGE_NONE) { + swap_page_dealloc(swapAddr, 1); + _SwapBlockFree(pageIndex + i, 1); fAllocatedSwapSize -= B_PAGE_SIZE; } } @@ -266,21 +398,17 @@ uint32 n = count; for (uint32 i = 0; i < count; i += n) { - swap_addr_t pageIndex; + swap_addr_t swapAddr; // try to allocate n pages, if fail, try to allocate n/2 - while ((pageIndex = swap_page_alloc(n)) == SWAP_PAGE_NONE - && n >= 2) + while ((swapAddr = swap_page_alloc(n)) == SWAP_PAGE_NONE && n >= 2) n >>= 1; - if (pageIndex == SWAP_PAGE_NONE) - panic("can't allocate swap space\n"); + if (swapAddr == SWAP_PAGE_NONE) + panic("VMAnonymousCache::Write(): can't allocate swap space\n"); - swap_file *swapFile = find_swap_file(pageIndex); - if (swapFile == NULL) { - panic("can't find swap file for page index %ld\n", pageIndex); - return B_ERROR; - } + swap_file *swapFile = find_swap_file(swapAddr); - off_t pos = (pageIndex - swapFile->first_page) * B_PAGE_SIZE; + off_t pos = (swapAddr - swapFile->first_page) * B_PAGE_SIZE; + status_t status = vfs_write_pages(swapFile->vnode, NULL, pos, vecs + i, n, 0, _numBytes); if (status != B_OK) { @@ -288,12 +416,11 @@ fAllocatedSwapSize -= n * B_PAGE_SIZE; Unlock(); - swap_page_dealloc(pageIndex, n); + swap_page_dealloc(swapAddr, n); return status; } - for (uint32 j = 0; j < n; j++) - _SwapBlockBuild(offset + i + j, pageIndex + j); + _SwapBlockBuild(pageIndex + i, swapAddr, n); } return B_OK; @@ -359,11 +486,10 @@ if (committed_size > actualSize) _Commit(actualSize); - // TODO: iterate over swap blocks for (off_t offset = source->virtual_base; offset < source->virtual_end; offset += PAGE_SIZE) { - off_t cacheOffset = offset >> PAGE_SHIFT; - swap_addr_t sourceSwapIndex = source->_SwapBlockGetAddress(cacheOffset); + off_t pageIndex = offset >> PAGE_SHIFT; + swap_addr_t sourceSwapIndex = source->_SwapBlockGetAddress(pageIndex); if (sourceSwapIndex == SWAP_PAGE_NONE) // this page is not swapped out @@ -374,12 +500,12 @@ // free the swap space swap_page_dealloc(sourceSwapIndex, 1); } else { - swap_addr_t swapIndex = _SwapBlockGetAddress(cacheOffset); + swap_addr_t swapIndex = _SwapBlockGetAddress(pageIndex); if (swapIndex == SWAP_PAGE_NONE) { // the page is not shadowed, // assign the swap address to the new cache - _SwapBlockBuild(cacheOffset, sourceSwapIndex); + _SwapBlockBuild(pageIndex, sourceSwapIndex, 1); fAllocatedSwapSize += B_PAGE_SIZE; } else { // the page is shadowed and is also swapped out @@ -387,61 +513,70 @@ } } source->fAllocatedSwapSize -= B_PAGE_SIZE; - source->_SwapBlockFree(cacheOffset); + source->_SwapBlockFree(pageIndex, 1); } } void -VMAnonymousCache::_SwapBlockBuild(off_t cacheOffset, swap_addr_t pageIndex) +VMAnonymousCache::_SwapBlockBuild(off_t startPageIndex, + swap_addr_t startSwapAddress, uint32 count) { mutex_lock(&sSwapHashLock); - swap_hash_key key = { this, cacheOffset }; + for (uint32 i = 0; i < count; i++) { + off_t pageIndex = startPageIndex + i; + swap_addr_t swapAddress = startSwapAddress + i; - swap_block *swap = sSwapHashTable.Lookup(key); - if (swap == NULL) { - swap = (swap_block *)object_cache_alloc(sSwapBlockCache, - CACHE_DONT_SLEEP); + swap_hash_key key = { this, pageIndex }; + + swap_block *swap = sSwapHashTable.Lookup(key); if (swap == NULL) { - // TODO: wait until memory can be allocated - mutex_unlock(&sSwapHashLock); - return; + swap = (swap_block *)object_cache_alloc(sSwapBlockCache, + CACHE_DONT_SLEEP); + if (swap == NULL) { + // TODO: wait until memory can be allocated + mutex_unlock(&sSwapHashLock); + return; + } + + swap->key.cache = this; + swap->key.page_index = pageIndex & ~(off_t)SWAP_BLOCK_MASK; + swap->used = 0; + for (uint32 i = 0; i < SWAP_BLOCK_PAGES; i++) + swap->swap_pages[i] = SWAP_PAGE_NONE; + + sSwapHashTable.Insert(swap); } - swap->key.cache = this; - swap->key.cache_offset = cacheOffset & ~(off_t)SWAP_BLOCK_MASK; - swap->used = 0; - for (uint32 i = 0; i < SWAP_BLOCK_PAGES; i++) - swap->swap_pages[i] = SWAP_PAGE_NONE; + swap_addr_t blockIndex = pageIndex & SWAP_BLOCK_MASK; + swap->swap_pages[blockIndex] = swapAddress; - sSwapHashTable.Insert(swap); + swap->used++; } - swap_addr_t blockIndex = cacheOffset & SWAP_BLOCK_MASK; - swap->swap_pages[blockIndex] = pageIndex; - - swap->used++; - mutex_unlock(&sSwapHashLock); } void -VMAnonymousCache::_SwapBlockFree(off_t cacheOffset) +VMAnonymousCache::_SwapBlockFree(off_t startPageIndex, uint32 count) { mutex_lock(&sSwapHashLock); - swap_hash_key key = { this, cacheOffset }; - swap_block *swap = sSwapHashTable.Lookup(key); - if (swap != NULL) { - swap_addr_t pageIndex = swap->swap_pages[cacheOffset & SWAP_BLOCK_MASK]; - if (pageIndex != SWAP_PAGE_NONE) { - swap->swap_pages[cacheOffset & SWAP_BLOCK_MASK] = SWAP_PAGE_NONE; - swap->used--; - if (swap->used == 0) { - sSwapHashTable.Remove(swap); - object_cache_free(sSwapBlockCache, swap); + for (uint32 i = 0; i < count; i++) { + off_t pageIndex = startPageIndex + i; + swap_hash_key key = { this, pageIndex }; + swap_block *swap = sSwapHashTable.Lookup(key); + if (swap != NULL) { + swap_addr_t swapAddr = swap->swap_pages[pageIndex & SWAP_BLOCK_MASK]; + if (swapAddr != SWAP_PAGE_NONE) { + swap->swap_pages[pageIndex & SWAP_BLOCK_MASK] = SWAP_PAGE_NONE; + swap->used--; + if (swap->used == 0) { + sSwapHashTable.Remove(swap); + object_cache_free(sSwapBlockCache, swap); + } } } } @@ -451,22 +586,22 @@ swap_addr_t -VMAnonymousCache::_SwapBlockGetAddress(off_t cacheOffset) +VMAnonymousCache::_SwapBlockGetAddress(off_t pageIndex) { mutex_lock(&sSwapHashLock); - swap_hash_key key = { this, cacheOffset }; + swap_hash_key key = { this, pageIndex }; swap_block *swap = sSwapHashTable.Lookup(key); - swap_addr_t pageIndex = SWAP_PAGE_NONE; + swap_addr_t swapAddress = SWAP_PAGE_NONE; if (swap != NULL) { - swap_addr_t blockIndex = cacheOffset & SWAP_BLOCK_MASK; - pageIndex = swap->swap_pages[blockIndex]; + swap_addr_t blockIndex = pageIndex & SWAP_BLOCK_MASK; + swapAddress = swap->swap_pages[blockIndex]; } mutex_unlock(&sSwapHashLock); - return pageIndex; + return swapAddress; } @@ -522,173 +657,9 @@ } -static swap_file * -find_swap_file(swap_addr_t pageIndex) -{ - for (SwapFileList::Iterator it = sSwapFileList.GetIterator(); - swap_file *swapFile = it.Next();) { - if (pageIndex >= swapFile->first_page - && pageIndex < swapFile->last_page) - return swapFile; - } +// #pragma mark - - return NULL; -} - -// used by page daemon to free swap space -bool -swap_free_page_swap_space(vm_page *page) -{ - VMAnonymousCache *cache = dynamic_cast(page->cache); - if (cache == NULL) - return false; - - swap_addr_t pageIndex = cache->_SwapBlockGetAddress(page->cache_offset); - if (pageIndex == SWAP_PAGE_NONE) - return false; - - swap_page_dealloc(pageIndex, 1); - cache->fAllocatedSwapSize -= B_PAGE_SIZE; - cache->_SwapBlockFree(page->cache_offset); - return true; -} - - -uint32 -swap_available_pages() -{ - mutex_lock(&sAvailSwapSpaceLock); - uint32 avail = sAvailSwapSpace >> PAGE_SHIFT; - mutex_unlock(&sAvailSwapSpaceLock); - - return avail; -} - - -uint32 -swap_total_swap_pages() -{ - mutex_lock(&sSwapFileListLock); - - uint32 totalSwapPages = 0; - for (SwapFileList::Iterator it = sSwapFileList.GetIterator(); - swap_file *swapFile = it.Next();) - totalSwapPages += swapFile->last_page - swapFile->first_page; - - mutex_unlock(&sSwapFileListLock); - - return totalSwapPages; -} - - -static swap_addr_t -swap_page_alloc(uint32 npages) -{ - swap_addr_t hint = 0; - swap_addr_t j; - - if (sSwapFileList.IsEmpty()) - return SWAP_PAGE_NONE; - - mutex_lock(&sSwapFileListLock); - for (j = 0; j < sSwapFileCount; j++) { - if (sSwapFileAlloc == NULL) - sSwapFileAlloc = sSwapFileList.First(); - - hint = sSwapFileAlloc->hint; - swap_addr_t pageCount = sSwapFileAlloc->last_page - - sSwapFileAlloc->first_page; - - swap_addr_t i = 0; - while (i < npages && (hint + npages) < pageCount) { - if (TESTBIT(sSwapFileAlloc->maps, hint + i)) { - hint++; - i = 0; - } else - i++; - } - - if (i == npages) - break; - - // this swap_file is full, find another - sSwapFileAlloc = sSwapFileList.GetNext(sSwapFileAlloc); - } - - if (j == sSwapFileCount) { - panic("swap space exhausted\n"); - mutex_unlock(&sSwapFileListLock); - return SWAP_PAGE_NONE; - } - - swap_addr_t pageIndex = sSwapFileAlloc->first_page + hint; - - for (uint32 i = 0; i < npages; i++) - SETBIT(sSwapFileAlloc->maps, hint + i); - if (hint == sSwapFileAlloc->hint) - sSwapFileAlloc->hint += npages; - - sSwapFileAlloc->used += npages; - - // if this swap file has used more than 90% percent of its pages - // switch to another - if (sSwapFileAlloc->used - > 9 * (sSwapFileAlloc->last_page - sSwapFileAlloc->first_page) / 10) - sSwapFileAlloc = sSwapFileList.GetNext(sSwapFileAlloc); - - mutex_unlock(&sSwapFileListLock); - return pageIndex; -} - - -static void -swap_page_dealloc(swap_addr_t pageIndex, uint32 npages) -{ - if (pageIndex == SWAP_PAGE_NONE) - return; - - mutex_lock(&sSwapFileListLock); - swap_file *swapFile = find_swap_file(pageIndex); - - pageIndex -= swapFile->first_page; - - for (uint32 i = 0; i < npages; i++) - CLEARBIT(swapFile->maps, pageIndex + i); - - if (swapFile->hint > pageIndex) - swapFile->hint = pageIndex; - - swapFile->used -= npages; - mutex_unlock(&sSwapFileListLock); -} - - -static off_t -swap_space_reserve(off_t amount) -{ - mutex_lock(&sAvailSwapSpaceLock); - if (sAvailSwapSpace >= amount) - sAvailSwapSpace -= amount; - else { - sAvailSwapSpace = 0; - amount = sAvailSwapSpace; - } - mutex_unlock(&sAvailSwapSpaceLock); - - return amount; -} - - -static void -swap_space_unreserve(off_t amount) -{ - mutex_lock(&sAvailSwapSpaceLock); - sAvailSwapSpace += amount; - mutex_unlock(&sAvailSwapSpaceLock); -} - - status_t swap_file_add(char *path) { @@ -722,14 +693,13 @@ int32 pageCount = st.st_size >> PAGE_SHIFT; swap->used = 0; - swap->maps = (uint32 *) - malloc((pageCount + NUM_BITS_PER_WORD - 1) / NUM_BITS_PER_WORD); + swap->maps = (uint32 *)malloc((pageCount + 7) / 8); if (swap->maps == NULL) { free(swap); vfs_put_vnode(node); return B_NO_MEMORY; } - memset(swap->maps, 0, pageCount % 8 + 1); + memset(swap->maps, 0, (pageCount + 7) / 8); swap->hint = 0; // set start page index and add this file to swap file list @@ -808,7 +778,7 @@ sSwapBlockCache = create_object_cache("swapblock", sizeof(swap_block), sizeof(void*), NULL, NULL, NULL); if (sSwapBlockCache == NULL) - panic("can't create object cache for swap blocks\n"); + panic("swap_init(): can't create object cache for swap blocks\n"); // init swap hash table sSwapHashTable.Init(); @@ -824,6 +794,7 @@ sAvailSwapSpace = 0; } + void swap_init_post_modules() { @@ -867,4 +838,50 @@ swap_file_add("/var/swap"); } + +// used by page daemon to free swap space +bool +swap_free_page_swap_space(vm_page *page) +{ + VMAnonymousCache *cache = dynamic_cast(page->cache); + if (cache == NULL) + return false; + + swap_addr_t swapAddress = cache->_SwapBlockGetAddress(page->cache_offset); + if (swapAddress == SWAP_PAGE_NONE) + return false; + + swap_page_dealloc(swapAddress, 1); + cache->fAllocatedSwapSize -= B_PAGE_SIZE; + cache->_SwapBlockFree(page->cache_offset, 1); + return true; +} + + +uint32 +swap_available_pages() +{ + mutex_lock(&sAvailSwapSpaceLock); + uint32 avail = sAvailSwapSpace >> PAGE_SHIFT; + mutex_unlock(&sAvailSwapSpaceLock); + + return avail; +} + + +uint32 +swap_total_swap_pages() +{ + mutex_lock(&sSwapFileListLock); + + uint32 totalSwapPages = 0; + for (SwapFileList::Iterator it = sSwapFileList.GetIterator(); + swap_file *swapFile = it.Next();) + totalSwapPages += swapFile->last_page - swapFile->first_page; + + mutex_unlock(&sSwapFileListLock); + + return totalSwapPages; +} + #endif // ENABLE_SWAP_SUPPORT Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2008-08-14 17:39:33 UTC (rev 26974) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2008-08-14 20:46:12 UTC (rev 26975) @@ -46,9 +46,10 @@ virtual void MergeStore(VMCache* source); private: - void _SwapBlockBuild(off_t cacheOffset, swap_addr_t pageIndex); - void _SwapBlockFree(off_t cacheOffset); - swap_addr_t _SwapBlockGetAddress(off_t cacheOffset); + void _SwapBlockBuild(off_t pageIndex, + swap_addr_t swapAddress, uint32 count); + void _SwapBlockFree(off_t pageIndex, uint32 count); + swap_addr_t _SwapBlockGetAddress(off_t pageIndex); status_t _Commit(off_t size); private: From axeld at mail.berlios.de Sun Aug 17 13:27:09 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 13:27:09 +0200 Subject: [Haiku-commits] r27001 - in haiku/trunk: headers/os/drivers headers/os/storage headers/private/storage src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/kits/storage src/kits/storage/disk_device src/kits/tracker Message-ID: <200808171127.m7HBR9dL000084@sheep.berlios.de> Author: axeld Date: 2008-08-17 13:27:07 +0200 (Sun, 17 Aug 2008) New Revision: 27001 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27001&view=rev Modified: haiku/trunk/headers/os/drivers/Drivers.h haiku/trunk/headers/os/storage/Mime.h haiku/trunk/headers/os/storage/Volume.h haiku/trunk/headers/private/storage/Partition.h haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp haiku/trunk/src/kits/storage/Mime.cpp haiku/trunk/src/kits/storage/Volume.cpp haiku/trunk/src/kits/storage/disk_device/Partition.cpp haiku/trunk/src/kits/tracker/MountMenu.cpp Log: * Added two new ways to retrieve an icon from a device: - B_GET_ICON_NAME: returns the name of an icon. This will then be read from a predefined location on disk (not yet implemented). This would also allow to add specifiers like "-boot", or "-fat|bfs|ntfs|...", and have special icons for those. - B_GET_VECTOR_ICON: retrieves the vector icon of a device, if any. * get_device_icon(BBitmap*, ...) now supports other color spaces than B_CMAP8. * Added get_device_icon(), BPartition::GetIcon(), and BVolume::GetIcon() variants that can also retrieve the icon data directly (like BNodeInfo::GetIcon()). * Reenabled the previous BPartition::GetIcon(), based on a patch by Justin O'Dell - this fixes #1391. * Tracker's MountMenu class now uses B_RGBA32 icons, instead of B_CMAP8. * Added vector icon to scsi_disk, and scsi_cd. The former doesn't have any special removable icon, though. * Header cleanup, added/updated license, whitespace cleanup. * Marked deprecated/obsolete driver ioctls in Drivers.h. * Removed OpenBeOS namespace in the headers I touched that still had them. Modified: haiku/trunk/headers/os/drivers/Drivers.h =================================================================== --- haiku/trunk/headers/os/drivers/Drivers.h 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/headers/os/drivers/Drivers.h 2008-08-17 11:27:07 UTC (rev 27001) @@ -1,46 +1,46 @@ +/* + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _DRIVERS_DRIVERS_H #define _DRIVERS_DRIVERS_H -#include + #include #include -#include + +#include #include +#include #ifdef __cplusplus extern "C" { #endif -/* --- - these hooks are how the kernel accesses the device ---- */ +/* These hooks are how the kernel accesses legacy devices */ +typedef status_t (*device_open_hook)(const char *name, uint32 flags, + void **cookie); +typedef status_t (*device_close_hook)(void *cookie); +typedef status_t (*device_free_hook)(void *cookie); +typedef status_t (*device_control_hook)(void *cookie, uint32 op, void *data, + size_t len); +typedef status_t (*device_read_hook)(void *cookie, off_t position, void *data, + size_t *numBytes); +typedef status_t (*device_write_hook)(void *cookie, off_t position, + const void *data, size_t *numBytes); +typedef status_t (*device_select_hook)(void *cookie, uint8 event, uint32 ref, + selectsync *sync); +typedef status_t (*device_deselect_hook)(void *cookie, uint8 event, + selectsync *sync); +typedef status_t (*device_read_pages_hook)(void *cookie, off_t position, + const iovec *vec, size_t count, size_t *_numBytes); +typedef status_t (*device_write_pages_hook)(void *cookie, off_t position, + const iovec *vec, size_t count, size_t *_numBytes); -typedef status_t (*device_open_hook) (const char *name, uint32 flags, void **cookie); -typedef status_t (*device_close_hook) (void *cookie); -typedef status_t (*device_free_hook) (void *cookie); -typedef status_t (*device_control_hook) (void *cookie, uint32 op, void *data, - size_t len); -typedef status_t (*device_read_hook) (void *cookie, off_t position, void *data, - size_t *numBytes); -typedef status_t (*device_write_hook) (void *cookie, off_t position, - const void *data, size_t *numBytes); -typedef status_t (*device_select_hook) (void *cookie, uint8 event, uint32 ref, - selectsync *sync); -typedef status_t (*device_deselect_hook) (void *cookie, uint8 event, - selectsync *sync); -typedef status_t (*device_read_pages_hook)(void *cookie, off_t position, const iovec *vec, - size_t count, size_t *_numBytes); -typedef status_t (*device_write_pages_hook) (void *cookie, off_t position, const iovec *vec, - size_t count, size_t *_numBytes); - #define B_CUR_DRIVER_API_VERSION 2 -/* --- - the device_hooks structure is a descriptor for the device, giving its - entry points. ---- */ - +/* Legacy driver device hooks */ typedef struct { device_open_hook open; /* called to open the device */ device_close_hook close; /* called to close the device */ @@ -50,55 +50,43 @@ device_write_hook write; /* writes to the device */ device_select_hook select; /* start select */ device_deselect_hook deselect; /* stop select */ - device_read_pages_hook read_pages; /* scatter-gather physical read from the device */ - device_write_pages_hook write_pages; /* scatter-gather physical write to the device */ + device_read_pages_hook read_pages; + /* scatter-gather physical read from the device */ + device_write_pages_hook write_pages; + /* scatter-gather physical write to the device */ } device_hooks; +/* Driver functions needed to be exported by legacy drivers */ status_t init_hardware(void); -const char **publish_devices(void); -device_hooks *find_device(const char *name); +const char** publish_devices(void); +device_hooks* find_device(const char* name); status_t init_driver(void); -void uninit_driver(void); +void uninit_driver(void); extern int32 api_version; enum { - B_GET_DEVICE_SIZE = 1, /* get # bytes */ - /* returns size_t in *data */ - - B_SET_DEVICE_SIZE, /* set # bytes */ - /* passed size_t in *data */ - + B_GET_DEVICE_SIZE = 1, /* get # bytes - returns size_t in *data */ + B_SET_DEVICE_SIZE, /* set # bytes - passes size_t in *data */ B_SET_NONBLOCKING_IO, /* set to non-blocking i/o */ - B_SET_BLOCKING_IO, /* set to blocking i/o */ - B_GET_READ_STATUS, /* check if can read w/o blocking */ - /* returns bool in *data */ - + /* returns bool in *data */ B_GET_WRITE_STATUS, /* check if can write w/o blocking */ - /* returns bool in *data */ - + /* returns bool in *data */ B_GET_GEOMETRY, /* get info about device geometry */ - /* returns struct geometry in *data */ - - B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving that device */ - + /* returns struct geometry in *data */ + B_GET_DRIVER_FOR_DEVICE, /* get the path of the executable serving */ + /* that device */ B_GET_PARTITION_INFO, /* get info about a device partition */ - /* returns struct partition_info in *data */ - - B_SET_PARTITION, /* create a user-defined partition */ - + /* returns struct partition_info in *data */ + B_SET_PARTITION, /* obsolete, will be removed */ B_FORMAT_DEVICE, /* low-level device format */ - B_EJECT_DEVICE, /* eject the media if supported */ - B_GET_ICON, /* return device icon (see struct below) */ - B_GET_BIOS_GEOMETRY, /* get info about device geometry */ /* as reported by the bios */ /* returns struct geometry in *data */ - B_GET_MEDIA_STATUS, /* get status of media. */ /* return status_t in *data: */ /* B_NO_ERROR: media ready */ @@ -109,21 +97,18 @@ /* B_DEV_MEDIA_CHANGE_REQUESTED: user */ /* pressed button on drive */ /* B_DEV_DOOR_OPEN: door open */ - B_LOAD_MEDIA, /* load the media if supported */ - B_GET_BIOS_DRIVE_ID, /* get bios id for this device */ - B_SET_UNINTERRUPTABLE_IO, /* prevent cntl-C from interrupting i/o */ B_SET_INTERRUPTABLE_IO, /* allow cntl-C to interrupt i/o */ - B_FLUSH_DRIVE_CACHE, /* flush drive cache */ - B_GET_PATH_FOR_DEVICE, /* get the absolute path of the device */ + B_GET_ICON_NAME, /* get an icon name identifier */ + B_GET_VECTOR_ICON, /* retrieves the device's vector icon */ - B_GET_NEXT_OPEN_DEVICE = 1000, /* iterate through open devices */ - B_ADD_FIXED_DRIVER, /* private */ - B_REMOVE_FIXED_DRIVER, /* private */ + B_GET_NEXT_OPEN_DEVICE = 1000, /* obsolete, will be removed */ + B_ADD_FIXED_DRIVER, /* obsolete, will be removed */ + B_REMOVE_FIXED_DRIVER, /* obsolete, will be removed */ B_AUDIO_DRIVER_BASE = 8000, /* base for codes in audio_driver.h */ B_MIDI_DRIVER_BASE = 8100, /* base for codes in midi_driver.h */ @@ -133,10 +118,7 @@ B_DEVICE_OP_CODES_END = 9999 /* end of Be-defined contol id's */ }; -/* --- - geometry structure for the B_GET_GEOMETRY opcode ---- */ - +/* B_GET_GEOMETRY data structure */ typedef struct { uint32 bytes_per_sector; /* sector size in bytes */ uint32 sectors_per_track; /* # sectors per track */ @@ -148,12 +130,6 @@ bool write_once; /* non-zero if write-once */ } device_geometry; - -/* --- - Be-defined device types returned by B_GET_GEOMETRY. Use these if it makes - sense for your device. ---- */ - enum { B_DISK = 0, /* Hard disks, floppy disks, etc. */ B_TAPE, /* Tape drives */ @@ -168,10 +144,7 @@ }; -/* --- - partition_info structure used by B_GET_PARTITION_INFO and B_SET_PARTITION ---- */ - +/* B_GET_PARTITION_INFO data structure */ typedef struct { off_t offset; /* offset (in bytes) */ off_t size; /* size (in bytes) */ @@ -181,30 +154,17 @@ char device[256]; /* path to the physical device */ } partition_info; -/* --- - driver_path structure returned by the B_GET_DRIVER_FOR_DEVICE ---- */ +/* B_GET_DRIVER_FOR_DEVICE data structure */ typedef char driver_path[256]; -/* --- - open_device_iterator structure used by the B_GET_NEXT_OPEN_DEVICE opcode ---- */ - +/* B_GET_ICON, and B_GET_VECTOR_ICON data structure */ typedef struct { - uint32 cookie; /* must be set to 0 before iterating */ - char device[256]; /* device path */ -} open_device_iterator; - - -/* --- - icon structure for the B_GET_ICON opcode ---- */ - -typedef struct { - int32 icon_size; /* icon size requested */ - void *icon_data; /* where to put 'em (usually BBitmap->Bits()) */ + int32 icon_size; + /* B_GET_VECTOR_ICON: size of the data buffer in icon_data */ + /* B_GET_ICON: size of the icon in pixels */ + void *icon_data; } device_icon; Modified: haiku/trunk/headers/os/storage/Mime.h =================================================================== --- haiku/trunk/headers/os/storage/Mime.h 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/headers/os/storage/Mime.h 2008-08-17 11:27:07 UTC (rev 27001) @@ -1,38 +1,19 @@ -/* - * Copyright 2004-2006, Haiku Inc. All Rights Reserved. +/* + * Copyright 2004-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ - -/*! - \file Mime.h - Mime type C functions interface declarations. -*/ #ifndef _MIME_H #define _MIME_H -#ifndef _BE_BUILD_H -#include -#endif + #include + #include #include -// C functions -#ifdef __cplusplus -extern "C" { -#endif +static const uint32 B_MIME_STRING_TYPE = 'MIMS'; -int update_mime_info(const char *path, int recursive, int synchronous, - int force); - -status_t create_app_meta_mime(const char *path, int recursive, int synchronous, - int force); - -status_t get_device_icon(const char *dev, void *icon, int32 size); - -static const uint32 B_MIME_STRING_TYPE = 'MIMS'; - enum icon_size { B_LARGE_ICON = 32, B_MINI_ICON = 16 @@ -45,22 +26,32 @@ B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL = 2, }; + +// C functions + #ifdef __cplusplus -} +extern "C" { #endif -// Haiku only! +int update_mime_info(const char* path, int recursive, int synchronous, + int force); +status_t create_app_meta_mime(const char* path, int recursive, int synchronous, + int force); +status_t get_device_icon(const char* device, void* icon, int32 size); + #ifdef __cplusplus +} +// C++ functions, Haiku only! + class BBitmap; -status_t get_device_icon(const char *dev, BBitmap *icon, icon_size which); +status_t get_device_icon(const char* device, BBitmap* icon, icon_size which); +status_t get_device_icon(const char* device, uint8** _data, size_t* _size, + type_code* _type); -#endif +// include MimeType.h for convenience +# include +#endif // __cplusplus -// include the C++ API -#ifdef __cplusplus -#include -#endif - #endif // _MIME_H Modified: haiku/trunk/headers/os/storage/Volume.h =================================================================== --- haiku/trunk/headers/os/storage/Volume.h 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/headers/os/storage/Volume.h 2008-08-17 11:27:07 UTC (rev 27001) @@ -1,18 +1,11 @@ -// ---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// File Name: Directory.cpp -// -// Description: BVolume class -// ---------------------------------------------------------------------- -/*! - \file Volume.h - BVolume interface declarations. -*/ +/* + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _VOLUME_H #define _VOLUME_H + #include #include @@ -20,67 +13,60 @@ #include #include -#ifdef USE_OPENBEOS_NAMESPACE -namespace OpenBeOS { -#endif - class BDirectory; class BBitmap; + class BVolume { public: - BVolume(); - BVolume(dev_t dev); - BVolume(const BVolume &vol); - virtual ~BVolume(); + BVolume(); + BVolume(dev_t device); + BVolume(const BVolume& volume); + virtual ~BVolume(); - status_t InitCheck() const; - status_t SetTo(dev_t dev); - void Unset(); + status_t InitCheck() const; + status_t SetTo(dev_t device); + void Unset(); - dev_t Device() const; + dev_t Device() const; - status_t GetRootDirectory(BDirectory *directory) const; + status_t GetRootDirectory(BDirectory* directory) const; - off_t Capacity() const; - off_t FreeBytes() const; + off_t Capacity() const; + off_t FreeBytes() const; - status_t GetName(char *name) const; - status_t SetName(const char *name); + status_t GetName(char* name) const; + status_t SetName(const char* name); - status_t GetIcon(BBitmap *icon, icon_size which) const; + status_t GetIcon(BBitmap* icon, icon_size which) const; + status_t GetIcon(uint8** _data, size_t* _size, + type_code* _type) const; - bool IsRemovable() const; - bool IsReadOnly() const; - bool IsPersistent() const; - bool IsShared() const; - bool KnowsMime() const; - bool KnowsAttr() const; - bool KnowsQuery() const; + bool IsRemovable() const; + bool IsReadOnly() const; + bool IsPersistent() const; + bool IsShared() const; + bool KnowsMime() const; + bool KnowsAttr() const; + bool KnowsQuery() const; - bool operator==(const BVolume &volume) const; - bool operator!=(const BVolume &volume) const; - BVolume &operator=(const BVolume &volume); + bool operator==(const BVolume& volume) const; + bool operator!=(const BVolume& volume) const; + BVolume& operator=(const BVolume& volume); private: -// friend class BVolumeRoster; + virtual void _TurnUpTheVolume1(); + virtual void _TurnUpTheVolume2(); + virtual void _TurnUpTheVolume3(); + virtual void _TurnUpTheVolume4(); + virtual void _TurnUpTheVolume5(); + virtual void _TurnUpTheVolume6(); + virtual void _TurnUpTheVolume7(); + virtual void _TurnUpTheVolume8(); - virtual void _TurnUpTheVolume1(); - virtual void _TurnUpTheVolume2(); - virtual void _TurnUpTheVolume3(); - virtual void _TurnUpTheVolume4(); - virtual void _TurnUpTheVolume5(); - virtual void _TurnUpTheVolume6(); - virtual void _TurnUpTheVolume7(); - virtual void _TurnUpTheVolume8(); - - dev_t fDevice; - status_t fCStatus; - int32 _reserved[8]; + dev_t fDevice; + status_t fCStatus; + int32 _reserved[8]; }; -#ifdef USE_OPENBEOS_NAMESPACE -} // namespace OpenBeOS -#endif - #endif // _VOLUME_H Modified: haiku/trunk/headers/private/storage/Partition.h =================================================================== --- haiku/trunk/headers/private/storage/Partition.h 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/headers/private/storage/Partition.h 2008-08-17 11:27:07 UTC (rev 27001) @@ -38,7 +38,7 @@ uint32 BlockSize() const; int32 Index() const; // 0 for devices uint32 Status() const; - + bool ContainsFileSystem() const; bool ContainsPartitioningSystem() const; @@ -47,8 +47,8 @@ bool IsMounted() const; bool IsBusy() const; - uint32 Flags() const; - + uint32 Flags() const; + const char* Name() const; const char* ContentName() const; const char* Type() const; // See DiskDeviceTypes.h @@ -58,10 +58,12 @@ const char* ContentParameters() const; status_t GetDiskSystem(BDiskSystem* diskSystem) const; - + virtual status_t GetPath(BPath* path) const; status_t GetVolume(BVolume* volume) const; status_t GetIcon(BBitmap* icon, icon_size which) const; + status_t GetIcon(uint8** _data, size_t* _size, + type_code* _type) const; status_t GetMountPoint(BPath* mountPoint) const; dev_t Mount(const char* mountPoint = NULL, @@ -80,7 +82,7 @@ status_t GetPartitioningInfo( BPartitioningInfo* info) const; - + BPartition* VisitEachChild(BDiskDeviceVisitor* visitor) const; virtual BPartition* VisitEachDescendant( @@ -90,7 +92,7 @@ bool CanDefragment(bool* whileMounted = NULL) const; status_t Defragment() const; - + bool CanRepair(bool checkOnly, bool* whileMounted = NULL) const; status_t Repair(bool checkOnly) const; @@ -149,14 +151,14 @@ bool CanInitialize(const char* diskSystem) const; status_t GetInitializationParameterEditor( - const char* system, + const char* system, BDiskDeviceParameterEditor** editor) const; status_t ValidateInitialize(const char* diskSystem, BString* name, const char* parameters); status_t Initialize(const char* diskSystem, const char* name, const char* parameters); status_t Uninitialize(); - + // Modification of child partitions bool CanCreateChild() const; @@ -170,10 +172,10 @@ const char* type, const char* name, const char* parameters, BPartition** child = NULL); - + bool CanDeleteChild(int32 index) const; status_t DeleteChild(int32 index); - + private: class Delegate; Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-17 11:27:07 UTC (rev 27001) @@ -27,6 +27,31 @@ #endif +static const uint8 kCDIcon[] = { + 0x6e, 0x63, 0x69, 0x66, 0x05, 0x05, 0x00, 0x02, 0x03, 0x06, 0x05, 0xb8, + 0x12, 0xa5, 0xbe, 0x03, 0xe1, 0x3d, 0xe7, 0x84, 0xb8, 0x02, 0x10, 0x49, + 0xf7, 0x9f, 0x49, 0xed, 0xd8, 0x00, 0xf1, 0xf1, 0xf1, 0x36, 0xd9, 0xdd, + 0xf4, 0x8a, 0x99, 0x96, 0xb9, 0xb4, 0xb8, 0xbe, 0xdb, 0xff, 0xf4, 0xf4, + 0xf4, 0x04, 0xeb, 0xd0, 0x02, 0x00, 0x06, 0x02, 0x3c, 0x92, 0xc0, 0x38, + 0x8f, 0x5f, 0xb8, 0x54, 0x50, 0x3c, 0x57, 0x63, 0x48, 0xd8, 0xdf, 0x48, + 0x89, 0x5b, 0x00, 0x41, 0x37, 0xa9, 0xff, 0xb9, 0xb9, 0xb9, 0x04, 0x01, + 0x7e, 0x04, 0x02, 0x04, 0x3f, 0x2c, 0x4e, 0x2c, 0x30, 0x2c, 0x22, 0x40, + 0x22, 0x34, 0x22, 0x4c, 0x3f, 0x54, 0x30, 0x54, 0x4e, 0x54, 0x5c, 0x40, + 0x5c, 0x4c, 0x5c, 0x34, 0x02, 0x04, 0x3f, 0x3a, 0x43, 0x3a, 0x3b, 0x3a, + 0x39, 0x3e, 0x39, 0x3c, 0x39, 0x40, 0x3f, 0x42, 0x3b, 0x42, 0x43, 0x42, + 0x45, 0x3e, 0x45, 0x40, 0x45, 0x3c, 0x02, 0x04, 0x4b, 0x3e, 0x4b, 0x3a, + 0x4b, 0x42, 0x3f, 0x46, 0x47, 0x46, 0x37, 0x46, 0x33, 0x3e, 0x33, 0x42, + 0x33, 0x3a, 0x3f, 0xbb, 0xf7, 0x37, 0xbb, 0xf7, 0x47, 0xbb, 0xf7, 0x02, + 0x04, 0x40, 0x2a, 0x54, 0x2a, 0x50, 0x2c, 0x5c, 0x40, 0x5c, 0x34, 0x5c, + 0x4c, 0x40, 0x56, 0x50, 0x54, 0x54, 0x56, 0x60, 0x40, 0x60, 0x4c, 0x60, + 0x34, 0x06, 0x0a, 0x04, 0x01, 0x03, 0x00, 0x0a, 0x00, 0x02, 0x00, 0x01, + 0x18, 0x15, 0xff, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x00, 0x02, 0x00, + 0x01, 0x18, 0x00, 0x15, 0x01, 0x17, 0x86, 0x00, 0x04, 0x0a, 0x01, 0x02, + 0x00, 0x02, 0x00, 0x0a, 0x02, 0x02, 0x02, 0x01, 0x00, 0x0a, 0x03, 0x01, + 0x02, 0x10, 0x01, 0x17, 0x82, 0x00, 0x04 +}; + + static scsi_periph_interface *sSCSIPeripheral; static device_manager_info *sDeviceManager; @@ -714,6 +739,27 @@ return user_memcpy(buffer, &geometry, sizeof(device_geometry)); } + case B_GET_ICON_NAME: + return user_strlcpy((char*)buffer, "device-cd", B_FILE_NAME_LENGTH); + + case B_GET_VECTOR_ICON: + { + device_icon iconData; + if (length != sizeof(device_icon)) + return B_BAD_VALUE; + if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK) + return B_BAD_ADDRESS; + + if (iconData.icon_size >= (int32)sizeof(kCDIcon)) { + if (user_memcpy(iconData.icon_data, kCDIcon, + sizeof(kCDIcon)) != B_OK) + return B_BAD_ADDRESS; + } + + iconData.icon_size = sizeof(kCDIcon); + return user_memcpy(buffer, &iconData, sizeof(device_icon)); + } + case B_GET_ICON: return sSCSIPeripheral->get_icon(icon_type_cd, (device_icon *)buffer); Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-17 11:27:07 UTC (rev 27001) @@ -29,6 +29,33 @@ #endif +static const uint8 kDriveIcon[] = { + 0x6e, 0x63, 0x69, 0x66, 0x08, 0x03, 0x01, 0x00, 0x00, 0x02, 0x00, 0x16, + 0x02, 0x3c, 0xc7, 0xee, 0x38, 0x9b, 0xc0, 0xba, 0x16, 0x57, 0x3e, 0x39, + 0xb0, 0x49, 0x77, 0xc8, 0x42, 0xad, 0xc7, 0x00, 0xff, 0xff, 0xd3, 0x02, + 0x00, 0x06, 0x02, 0x3c, 0x96, 0x32, 0x3a, 0x4d, 0x3f, 0xba, 0xfc, 0x01, + 0x3d, 0x5a, 0x97, 0x4b, 0x57, 0xa5, 0x49, 0x84, 0x4d, 0x00, 0x47, 0x47, + 0x47, 0xff, 0xa5, 0xa0, 0xa0, 0x02, 0x00, 0x16, 0x02, 0xbc, 0x59, 0x2f, + 0xbb, 0x29, 0xa7, 0x3c, 0x0c, 0xe4, 0xbd, 0x0b, 0x7c, 0x48, 0x92, 0xc0, + 0x4b, 0x79, 0x66, 0x00, 0x7d, 0xff, 0xd4, 0x02, 0x00, 0x06, 0x02, 0x38, + 0xdb, 0xb4, 0x39, 0x97, 0x33, 0xbc, 0x4a, 0x33, 0x3b, 0xa5, 0x42, 0x48, + 0x6e, 0x66, 0x49, 0xee, 0x7b, 0x00, 0x59, 0x67, 0x56, 0xff, 0xeb, 0xb2, + 0xb2, 0x03, 0xa7, 0xff, 0x00, 0x03, 0xff, 0x00, 0x00, 0x04, 0x01, 0x80, + 0x07, 0x0a, 0x06, 0x22, 0x3c, 0x22, 0x49, 0x44, 0x5b, 0x5a, 0x3e, 0x5a, + 0x31, 0x39, 0x25, 0x0a, 0x04, 0x22, 0x3c, 0x44, 0x4b, 0x5a, 0x31, 0x39, + 0x25, 0x0a, 0x04, 0x44, 0x4b, 0x44, 0x5b, 0x5a, 0x3e, 0x5a, 0x31, 0x0a, + 0x04, 0x22, 0x3c, 0x22, 0x49, 0x44, 0x5b, 0x44, 0x4b, 0x08, 0x02, 0x27, + 0x43, 0xb8, 0x14, 0xc1, 0xf1, 0x08, 0x02, 0x26, 0x43, 0x29, 0x44, 0x0a, + 0x05, 0x44, 0x5d, 0x49, 0x5d, 0x60, 0x3e, 0x5a, 0x3b, 0x5b, 0x3f, 0x08, + 0x0a, 0x07, 0x01, 0x06, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x10, 0x01, 0x17, + 0x84, 0x00, 0x04, 0x0a, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x02, 0x01, 0x02, + 0x00, 0x0a, 0x03, 0x01, 0x03, 0x00, 0x0a, 0x04, 0x01, 0x04, 0x10, 0x01, + 0x17, 0x85, 0x20, 0x04, 0x0a, 0x06, 0x01, 0x05, 0x30, 0x24, 0xb3, 0x99, + 0x01, 0x17, 0x82, 0x00, 0x04, 0x0a, 0x05, 0x01, 0x05, 0x30, 0x20, 0xb2, + 0xe6, 0x01, 0x17, 0x82, 0x00, 0x04 +}; + + static scsi_periph_interface* sSCSIPeripheral; static device_manager_info* sDeviceManager; @@ -318,6 +345,30 @@ return user_memcpy(buffer, &geometry, sizeof(device_geometry)); } + case B_GET_ICON_NAME: + // TODO: take device type into account! + return user_strlcpy((char*)buffer, "device-harddisk", + B_FILE_NAME_LENGTH); + + case B_GET_VECTOR_ICON: + { + // TODO: take device type into account! + device_icon iconData; + if (length != sizeof(device_icon)) + return B_BAD_VALUE; + if (user_memcpy(&iconData, buffer, sizeof(device_icon)) != B_OK) + return B_BAD_ADDRESS; + + if (iconData.icon_size >= (int32)sizeof(kDriveIcon)) { + if (user_memcpy(iconData.icon_data, kDriveIcon, + sizeof(kDriveIcon)) != B_OK) + return B_BAD_ADDRESS; + } + + iconData.icon_size = sizeof(kDriveIcon); + return user_memcpy(buffer, &iconData, sizeof(device_icon)); + } + case B_GET_ICON: return sSCSIPeripheral->get_icon(info->removable ? icon_type_floppy : icon_type_disk, (device_icon *)buffer); Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 10:31:31 UTC (rev 27000) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 11:27:07 UTC (rev 27001) @@ -1,10 +1,11 @@ /* - * Copyright 2002-2006, Haiku Inc. + * Copyright 2002-2008, Haiku Inc. * Distributed under the terms of the MIT License. * * Authors: * Tyler Dauwalder * Ingo Weinhold, bonefish at users.sf.net + * Axel D?rfler, axeld at pinc-software.de */ /*! @@ -12,11 +13,18 @@ Mime type C functions implementation. */ +#include +#include +#include +#include +#include + #include #include #include #include #include +#include #include #include #include @@ -25,9 +33,6 @@ #include #include -#include -#include - using namespace BPrivate; enum { @@ -42,7 +47,7 @@ { BEntry root; entry_ref ref; - + status_t err = root.SetTo(path ? path : "/"); if (!err) err = root.GetRef(&ref); @@ -50,7 +55,7 @@ BMessage msg(what); BMessage reply; status_t result; - + // Build and send the message, read the reply if (!err) err = msg.AddRef("entry", &ref); @@ -60,13 +65,13 @@ err = msg.AddBool("synchronous", synchronous); if (!err) err = msg.AddInt32("force", force); - if (!err) + if (!err) err = BRoster::Private().SendTo(&msg, &reply, true); if (!err) err = reply.what == B_REG_RESULT ? B_OK : B_BAD_VALUE; if (!err) err = reply.FindInt32("result", &result); - if (!err) + if (!err) err = result; } return err; @@ -106,7 +111,7 @@ recursive = true; return do_mime_update(B_REG_MIME_UPDATE_MIME_INFO, path, recursive, - synchronous, force); + synchronous, force); } // create_app_meta_mime @@ -139,50 +144,44 @@ synchronous, force); } -// get_device_icon + /*! Retrieves an icon associated with a given device. \param dev The path to the device. \param icon A pointer to a buffer the icon data shall be written to. \param size The size of the icon. Currently the sizes 16 (small, i.e \c B_MINI_ICON) and 32 (large, i.e. \c B_LARGE_ICON) are supported. - + \todo The mounted directories for volumes can also have META:X:STD_ICON attributes. Should those attributes override the icon returned by ioctl(,B_GET_ICON,)? - + \return - \c B_OK: Everything went fine. - An error code otherwise. */ status_t -get_device_icon(const char *dev, void *icon, int32 size) +get_device_icon(const char *device, void *icon, int32 size) { - status_t err = dev && icon && (size == B_LARGE_ICON || size == B_MINI_ICON) - ? B_OK : B_BAD_VALUE; + if (device == NULL || icon == NULL + || (size != B_LARGE_ICON && size != B_MINI_ICON)) + return B_BAD_VALUE; - int fd = -1; + int fd = open(device, O_RDONLY); + if (fd < 0) + return errno; - if (!err) { - fd = open(dev, O_RDONLY); - err = fd != -1 ? B_OK : B_BAD_VALUE; + device_icon iconData = {size, icon}; + if (ioctl(fd, B_GET_ICON, &iconData) != 0) { + close(fd); + return errno; } - if (!err) { - device_icon iconData = { size, icon }; - err = ioctl(fd, B_GET_ICON, &iconData); - } - if (fd != -1) { - // If the file descriptor was open()ed, we need to close it - // regardless. Only if we haven't yet encountered any errors - // do we make note close()'s return value, however. - status_t error = close(fd); - if (!err) - err = error; - } - return err; + + close(fd); + return B_OK; } -// get_device_icon + /*! Retrieves an icon associated with a given device. \param dev The path to the device. \param icon A pointer to a pre-allocated BBitmap of the correct dimension @@ -190,38 +189,118 @@ large icon). \param which Specifies the size of the icon to be retrieved: \c B_MINI_ICON for the mini and \c B_LARGE_ICON for the large icon. - + \todo The mounted directories for volumes can also have META:X:STD_ICON attributes. Should those attributes override the icon returned by ioctl(,B_GET_ICON,)? - + \return - \c B_OK: Everything went fine. - An error code otherwise. */ status_t -get_device_icon(const char *dev, BBitmap *icon, icon_size which) +get_device_icon(const char *device, BBitmap *icon, icon_size which) { // check parameters - status_t error = (dev && icon ? B_OK : B_BAD_VALUE); + if (device == NULL || icon == NULL) + return B_BAD_VALUE; + BRect rect; - if (error == B_OK) { - if (which == B_MINI_ICON) - rect.Set(0, 0, 15, 15); - else if (which == B_LARGE_ICON) - rect.Set(0, 0, 31, 31); - else - error = B_BAD_VALUE; + if (which == B_MINI_ICON) + rect.Set(0, 0, 15, 15); + else if (which == B_LARGE_ICON) + rect.Set(0, 0, 31, 31); + else + return B_BAD_VALUE; + + if (icon->Bounds() != rect) + return B_BAD_VALUE; + + uint8* data; + size_t size; + type_code type; + status_t status = get_device_icon(device, &data, &size, &type); + if (status == B_OK) { + status = BIconUtils::GetVectorIcon(data, size, icon); + delete[] data; + return status; } + + // Vector icon was not available, try old one + // check whether icon size and bitmap dimensions do match - if (error == B_OK - && (icon->Bounds() != rect || icon->ColorSpace() != B_CMAP8)) { - error = B_BAD_VALUE; + if (icon->Bounds() != rect || icon->ColorSpace() != B_CMAP8) + return B_BAD_VALUE; + + void* iconData = icon->Bits(); + size_t iconSize = icon->BitsLength(); + + if (icon->ColorSpace() != B_CMAP8) { + iconSize = (size_t)which * (size_t)which; + iconData = malloc(iconSize); + if (iconData == NULL) + return B_NO_MEMORY; } - // TODO: support bitmap with other color spaces! + // get the icon - if (error == B_OK) - error = get_device_icon(dev, icon->Bits(), which); - return error; + status = get_device_icon(device, iconData, which); + if (status == B_OK && iconData != icon->Bits()) + icon->SetBits(iconData, iconSize, 0, B_CMAP8); + + if (iconData != icon->Bits()) + free(iconData); + + return status; } + +status_t +get_device_icon(const char *device, uint8** _data, size_t* _size, + type_code* _type) +{ + if (device == NULL || _data == NULL || _size == NULL || _type == NULL) + return B_BAD_VALUE; + + int fd = open(device, O_RDONLY); + if (fd < 0) + return errno; + + // TODO: support B_GET_ICON_NAME! +#if 0 + char name[B_FILE_NAME_LENGTH]; + if (ioctl(fd, B_GET_ICON_NAME, name) == 0) { + close(fd); + return B_OK; + } +#endif + + uint8 data[8192]; + device_icon iconData = {sizeof(data), data}; + status_t status = ioctl(fd, B_GET_VECTOR_ICON, &iconData, + sizeof(device_icon)); + if (status != 0) + status = errno; + + if (status == B_OK) { + *_data = new(std::nothrow) uint8[iconData.icon_size]; + if (*_data == NULL) + status = B_NO_MEMORY; + } + + if (status == B_OK) { + if (iconData.icon_size > (int32)sizeof(data)) { + iconData.icon_data = *_data; + status = ioctl(fd, B_GET_VECTOR_ICON, &iconData, + sizeof(device_icon)); + if (status != 0) + status = errno; + } else + memcpy(*_data, data, iconData.icon_size); + + *_size = iconData.icon_size; + *_type = B_VECTOR_ICON_TYPE; + } + + close(fd); + return status; +} Modified: haiku/trunk/src/kits/storage/Volume.cpp =================================================================== [... truncated: 260 lines follow ...] From dlmcpaul at mail.berlios.de Sat Aug 16 04:24:21 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Sat, 16 Aug 2008 04:24:21 +0200 Subject: [Haiku-commits] r26986 - haiku/trunk/src/kits/media Message-ID: <200808160224.m7G2OLvc005770@sheep.berlios.de> Author: dlmcpaul Date: 2008-08-16 04:24:19 +0200 (Sat, 16 Aug 2008) New Revision: 26986 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26986&view=rev Modified: haiku/trunk/src/kits/media/MediaExtractor.cpp Log: Don't call Reader methods with invalid cookies Modified: haiku/trunk/src/kits/media/MediaExtractor.cpp =================================================================== --- haiku/trunk/src/kits/media/MediaExtractor.cpp 2008-08-15 23:52:23 UTC (rev 26985) +++ haiku/trunk/src/kits/media/MediaExtractor.cpp 2008-08-16 02:24:19 UTC (rev 26986) @@ -151,6 +151,9 @@ MediaExtractor::CountFrames(int32 stream) const { CALLED(); + if (fStreamInfo[stream].status != B_OK) + return 0LL; + int64 frameCount; bigtime_t duration; media_format format; @@ -168,6 +171,10 @@ MediaExtractor::Duration(int32 stream) const { CALLED(); + + if (fStreamInfo[stream].status != B_OK) + return 0LL; + int64 frameCount; bigtime_t duration; media_format format; From mmu_man at mail.berlios.de Sun Aug 17 01:47:21 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 17 Aug 2008 01:47:21 +0200 Subject: [Haiku-commits] r26998 - haiku/trunk/src/system/kernel/vm Message-ID: <200808162347.m7GNlL65002428@sheep.berlios.de> Author: mmu_man Date: 2008-08-17 01:47:20 +0200 (Sun, 17 Aug 2008) New Revision: 26998 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26998&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp Log: Fix building with TRACE on. Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-16 23:38:19 UTC (rev 26997) +++ haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-16 23:47:20 UTC (rev 26998) @@ -279,8 +279,8 @@ if (addressSpace == NULL) return B_NO_MEMORY; - TRACE(("vm_create_aspace: %s: %lx bytes starting at 0x%lx => %p\n", - name, size, base, addressSpace)); + TRACE(("vm_create_aspace: team %ld (%skernel): %lx bytes starting at 0x%lx => %p\n", + id, kernel?"!":"", size, base, addressSpace)); addressSpace->base = base; addressSpace->size = size; From dlmcpaul at mail.berlios.de Fri Aug 15 01:09:15 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Fri, 15 Aug 2008 01:09:15 +0200 Subject: [Haiku-commits] r26976 - in haiku/trunk/src/apps/mediaplayer: . media_node_framework/video Message-ID: <200808142309.m7EN9Fc7024363@sheep.berlios.de> Author: dlmcpaul Date: 2008-08-15 01:09:14 +0200 (Fri, 15 Aug 2008) New Revision: 26976 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26976&view=rev Modified: haiku/trunk/src/apps/mediaplayer/Controller.cpp haiku/trunk/src/apps/mediaplayer/InfoWin.cpp haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp Log: Correct display of Duration Modified: haiku/trunk/src/apps/mediaplayer/Controller.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-08-14 20:46:12 UTC (rev 26975) +++ haiku/trunk/src/apps/mediaplayer/Controller.cpp 2008-08-14 23:09:14 UTC (rev 26976) @@ -126,6 +126,7 @@ int64 Controller::Duration() { + // This should really be total frames (video frames at that) // TODO: It is not so nice that the MediaPlayer still measures // in video frames if only playing audio. Here for example, it will // return a duration of 0 if the audio clip happens to be shorter than @@ -221,12 +222,19 @@ BMediaTrack* t = mf->TrackAt(i); media_format f; err = t->EncodedFormat(&f); - if (err != B_OK || t->Duration() <= 0) { + if (err != B_OK) { printf("Controller::SetTo: EncodedFormat failed for track index %d, error 0x%08lx (%s)\n", i, err, strerror(err)); mf->ReleaseTrack(t); continue; } + + if (t->Duration() <= 0) { + printf("Controller::SetTo: track index %d has no duration\n",i); + mf->ReleaseTrack(t); + continue; + } + if (f.IsAudio()) { if (!fAudioTrackList.AddItem(t)) return B_NO_MEMORY; Modified: haiku/trunk/src/apps/mediaplayer/InfoWin.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/InfoWin.cpp 2008-08-14 20:46:12 UTC (rev 26975) +++ haiku/trunk/src/apps/mediaplayer/InfoWin.cpp 2008-08-14 23:09:14 UTC (rev 26976) @@ -321,7 +321,7 @@ if ((which & INFO_STATS) && fController->HasFile()) { fLabelsView->Insert("Duration\n"); BString s; - bigtime_t d = fController->Duration(); + bigtime_t d = fController->TimeDuration(); bigtime_t v; //s << d << "?s; "; Modified: haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp 2008-08-14 20:46:12 UTC (rev 26975) +++ haiku/trunk/src/apps/mediaplayer/media_node_framework/video/VideoProducer.cpp 2008-08-14 23:09:14 UTC (rev 26976) @@ -715,7 +715,7 @@ "Terminating video producer frame generator thread.\n"); TRACE("_FrameGeneratorThread: frame generator thread done.\n"); // do not access any member variables, since this could - // also me the Node has been deleted + // also mean the Node has been deleted return B_OK; } @@ -739,7 +739,7 @@ // nothing to do } else if (nextWaitUntil < system_time()) { // Drop frame if it's at least a frame late. - //printf("VideoProducer: dropped frame (%ld)\n", fFrame); + printf("VideoProducer: dropped frame (%Ld)\n", fFrame); if (fManager->LockWithTimeout(10000) == B_OK) { fManager->FrameDropped(); fManager->Unlock(); From axeld at mail.berlios.de Fri Aug 15 17:00:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 15 Aug 2008 17:00:27 +0200 Subject: [Haiku-commits] r26982 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread Message-ID: <200808151500.m7FF0RRb027266@sheep.berlios.de> Author: axeld Date: 2008-08-15 17:00:26 +0200 (Fri, 15 Aug 2008) New Revision: 26982 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26982&view=rev Modified: haiku/trunk/headers/posix/limits.h haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c haiku/trunk/src/system/libroot/posix/pthread/pthread_key.cpp haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h Log: * As requested by POSIX, we now have PTHREAD_STACK_MIN, and PTHREAD_KEYS_MAX defined in limits.h. * This closes ticket #2559. Modified: haiku/trunk/headers/posix/limits.h =================================================================== --- haiku/trunk/headers/posix/limits.h 2008-08-15 14:47:11 UTC (rev 26981) +++ haiku/trunk/headers/posix/limits.h 2008-08-15 15:00:26 UTC (rev 26982) @@ -41,6 +41,8 @@ #define PAGESIZE (4096) #define PATH_MAX (1024) #define PIPE_MAX (512) +#define PTHREAD_KEYS_MAX 256 +#define PTHREAD_STACK_MIN 4096 #define SSIZE_MAX (2147483647L) #define TTY_NAME_MAX (256) #define TZNAME_MAX (32) Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c 2008-08-15 14:47:11 UTC (rev 26981) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c 2008-08-15 15:00:26 UTC (rev 26982) @@ -8,6 +8,7 @@ #include #include "pthread_private.h" +#include #include #include @@ -102,7 +103,7 @@ if (_attr == NULL || (attr = *_attr) == NULL) return B_BAD_VALUE; - if (stacksize < MIN_USER_STACK_SIZE || stacksize > MAX_USER_STACK_SIZE) + if (stacksize < PTHREAD_STACK_MIN || stacksize > MAX_USER_STACK_SIZE) return B_BAD_VALUE; attr->stack_size = stacksize; Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_key.cpp =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_key.cpp 2008-08-15 14:47:11 UTC (rev 26981) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_key.cpp 2008-08-15 15:00:26 UTC (rev 26982) @@ -6,6 +6,7 @@ #include "pthread_private.h" +#include #include Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-08-15 14:47:11 UTC (rev 26981) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2008-08-15 15:00:26 UTC (rev 26982) @@ -47,7 +47,6 @@ void *value; }; -#define PTHREAD_KEYS_MAX 256 #define PTHREAD_UNUSED_SEQUENCE 0 typedef struct _pthread_thread { From axeld at mail.berlios.de Sat Aug 16 13:06:01 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 16 Aug 2008 13:06:01 +0200 Subject: [Haiku-commits] r26990 - in haiku/trunk: headers/os/storage src/system/libroot/os Message-ID: <200808161106.m7GB61f0011460@sheep.berlios.de> Author: axeld Date: 2008-08-16 13:05:59 +0200 (Sat, 16 Aug 2008) New Revision: 26990 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26990&view=rev Modified: haiku/trunk/headers/os/storage/FindDirectory.h haiku/trunk/src/system/libroot/os/find_directory.c Log: * Added find directory constants B_{BEOS|COMMON|USER}_DATA_DIRECTORY, which currently points to /etc for the system, and dedicated "data" directories for common/user (the system directory should get a dedicated "data", too, though). * Added B_USER_CACHE_DIRECTORY (in config/cache). * These additions were discussed some years ago, but I just had a good reason to use them :-) * Coding style cleanup. Modified: haiku/trunk/headers/os/storage/FindDirectory.h =================================================================== --- haiku/trunk/headers/os/storage/FindDirectory.h 2008-08-16 05:11:36 UTC (rev 26989) +++ haiku/trunk/headers/os/storage/FindDirectory.h 2008-08-16 11:05:59 UTC (rev 26990) @@ -1,39 +1,20 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -//--------------------------------------------------------------------- -/*! - \file FindDirectory.h - Declarations of find_directory() functions and associated types. -*/ - +/* + * Copyright 2002-2008, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FIND_DIRECTORY_H #define _FIND_DIRECTORY_H + #include -#ifdef USE_OPENBEOS_NAMESPACE -namespace OpenBeOS { -#endif -#ifdef __cplusplus -extern "C" { -#endif - typedef enum { - /* --- - Per volume directories. When asking for these - directories, a volume must be specified, or the call will assume - the boot volume. - --- */ - + // Per volume directories B_DESKTOP_DIRECTORY = 0, B_TRASH_DIRECTORY, - /* --- - BeOS directories. These are mostly accessed read-only. - --- */ - + // System directories B_BEOS_DIRECTORY = 1000, B_BEOS_SYSTEM_DIRECTORY, B_BEOS_ADDONS_DIRECTORY, @@ -49,11 +30,9 @@ B_BEOS_TRANSLATORS_DIRECTORY, B_BEOS_MEDIA_NODES_DIRECTORY, B_BEOS_SOUNDS_DIRECTORY, + B_BEOS_DATA_DIRECTORY, - /* --- - Common directories, shared among all users. - --- */ - + // Common directories, shared among all users. B_COMMON_DIRECTORY = 2000, B_COMMON_SYSTEM_DIRECTORY, B_COMMON_ADDONS_DIRECTORY, @@ -73,13 +52,11 @@ B_COMMON_TRANSLATORS_DIRECTORY, B_COMMON_MEDIA_NODES_DIRECTORY, B_COMMON_SOUNDS_DIRECTORY, + B_COMMON_DATA_DIRECTORY, - /* --- - User directories. These are interpreted in the context - of the user making the find_directory call. - --- */ - + // User directories. These are interpreted in the context + // of the user making the find_directory call. B_USER_DIRECTORY = 3000, B_USER_CONFIG_DIRECTORY, B_USER_ADDONS_DIRECTORY, @@ -92,46 +69,36 @@ B_USER_TRANSLATORS_DIRECTORY, B_USER_MEDIA_NODES_DIRECTORY, B_USER_SOUNDS_DIRECTORY, + B_USER_DATA_DIRECTORY, + B_USER_CACHE_DIRECTORY, - /* --- - Global directories. - --- */ - + // Global directories. B_APPS_DIRECTORY = 4000, B_PREFERENCES_DIRECTORY, B_UTILITIES_DIRECTORY } directory_which; -/* --- - The C interface ---- */ +#ifdef __cplusplus +extern "C" { +#endif +// C interface + status_t find_directory(directory_which which, dev_t volume, bool createIt, - char *pathString, int32 length); + char* pathString, int32 length); #ifdef __cplusplus } -#endif -#ifdef __cplusplus +// C++ interface class BVolume; class BPath; -/* --- - C++ interface ---- */ +status_t find_directory(directory_which which, BPath* path, + bool createIt = false, BVolume* volume = NULL); -status_t find_directory(directory_which which, BPath *path, - bool createIt = false, BVolume *volume = NULL); +#endif // __cplusplus -#endif - -#ifdef USE_OPENBEOS_NAMESPACE -}; // namespace OpenBeOS -#endif - #endif // _FIND_DIRECTORY_H - - Modified: haiku/trunk/src/system/libroot/os/find_directory.c =================================================================== --- haiku/trunk/src/system/libroot/os/find_directory.c 2008-08-16 05:11:36 UTC (rev 26989) +++ haiku/trunk/src/system/libroot/os/find_directory.c 2008-08-16 11:05:59 UTC (rev 26990) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2007, Fran?ois Revol. + * Copyright (c) 2004-2008, Fran?ois Revol. * Distributed under the terms of the MIT license. */ @@ -31,26 +31,27 @@ /* Haiku system directories */ /* os root dir; just stick to 'beos' for now */ -#define OS "beos" -//#define OS "haiku" // :) -//#define OS "os" +#define SYSTEM "beos" +//#define SYSTEM "haiku" // :) +//#define SYSTEM "os" -static const char *os_dirs[] = { - OS, // B_BEOS_DIRECTORY - OS "/system", - OS "/system/add-ons", - OS "/system/boot", - OS "/etc/fonts", - OS "/system/lib", - OS "/system/servers", - OS "/apps", - OS "/bin", - OS "/etc", - OS "/documentation", - OS "/preferences", - OS "/system/add-ons/Translators", - OS "/system/add-ons/media", - OS "/etc/sounds", +static const char *kSystemDirectories[] = { + SYSTEM, // B_BEOS_DIRECTORY + SYSTEM "/system", + SYSTEM "/system/add-ons", + SYSTEM "/system/boot", + SYSTEM "/etc/fonts", + SYSTEM "/system/lib", + SYSTEM "/system/servers", + SYSTEM "/apps", + SYSTEM "/bin", + SYSTEM "/etc", + SYSTEM "/documentation", + SYSTEM "/preferences", + SYSTEM "/system/add-ons/Translators", + SYSTEM "/system/add-ons/media", + SYSTEM "/etc/sounds", + SYSTEM "/etc", }; /* Common directories, shared among users */ @@ -59,7 +60,7 @@ // ToDo: this is for now and might be changed back to "home" // (or even something else) later -static const char *common_dirs[] = { +static const char *kCommonDirectories[] = { COMMON "", // B_COMMON_DIRECTORY COMMON "", // B_COMMON_SYSTEM_DIRECTORY COMMON "/add-ons", @@ -79,13 +80,14 @@ COMMON "/add-ons/Translators", COMMON "/add-ons/media", COMMON "/sounds", + COMMON "/data", }; /* User directories */ #define HOME "$h" -static const char *user_dirs[] = { +static const char *kUserDirectories[] = { HOME "", // B_USER_DIRECTORY HOME "/config", // B_USER_CONFIG_DIRECTORY HOME "/config/add-ons", @@ -98,6 +100,8 @@ HOME "/config/add-ons/Translators", HOME "/config/add-ons/media", HOME "/config/sounds", + HOME "/config/data", + HOME "/config/cache", }; @@ -219,7 +223,8 @@ case B_BEOS_TRANSLATORS_DIRECTORY: case B_BEOS_MEDIA_NODES_DIRECTORY: case B_BEOS_SOUNDS_DIRECTORY: - template = os_dirs[which - B_BEOS_DIRECTORY]; + case B_BEOS_DATA_DIRECTORY: + template = kSystemDirectories[which - B_BEOS_DIRECTORY]; break; /* Common directories, shared among users */ @@ -242,7 +247,8 @@ case B_COMMON_TRANSLATORS_DIRECTORY: case B_COMMON_MEDIA_NODES_DIRECTORY: case B_COMMON_SOUNDS_DIRECTORY: - template = common_dirs[which - B_COMMON_DIRECTORY]; + case B_COMMON_DATA_DIRECTORY: + template = kCommonDirectories[which - B_COMMON_DIRECTORY]; break; /* User directories */ @@ -258,7 +264,9 @@ case B_USER_TRANSLATORS_DIRECTORY: case B_USER_MEDIA_NODES_DIRECTORY: case B_USER_SOUNDS_DIRECTORY: - template = user_dirs[which - B_USER_DIRECTORY]; + case B_USER_DATA_DIRECTORY: + case B_USER_CACHE_DIRECTORY: + template = kUserDirectories[which - B_USER_DIRECTORY]; break; /* Global directories */ @@ -276,7 +284,7 @@ free(buffer); return EINVAL; } - + err = B_OK; if (template) { if (!strncmp(template, "$h", 2)) { From dlmcpaul at mail.berlios.de Sun Aug 17 01:38:20 2008 From: dlmcpaul at mail.berlios.de (dlmcpaul at BerliOS) Date: Sun, 17 Aug 2008 01:38:20 +0200 Subject: [Haiku-commits] r26997 - in haiku/trunk/src/add-ons/media/plugins/mp4_reader: . libMP4 Message-ID: <200808162338.m7GNcKpS001680@sheep.berlios.de> Author: dlmcpaul Date: 2008-08-17 01:38:19 +0200 (Sun, 17 Aug 2008) New Revision: 26997 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26997&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/MP4Parser.cpp haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp Log: Add ALAC and AAC decoder support 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-08-16 22:23:10 UTC (rev 26996) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Atom.cpp 2008-08-16 23:38:19 UTC (rev 26997) @@ -118,7 +118,7 @@ void AtomBase::DisplayAtoms(uint32 pindent) { Indent(pindent); - printf("%s\n",getAtomName()); + printf("(%s)\n",getAtomName()); } void AtomBase::Indent(uint32 pindent) @@ -278,7 +278,7 @@ void AtomContainer::DisplayAtoms(uint32 pindent) { Indent(pindent); - printf("%ld:%s\n",TotalChildren,getAtomName()); + printf("%ld:(%s)\n",TotalChildren,getAtomName()); pindent++; // for each child for (uint32 i = 0;i < TotalChildren;i++) { 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-08-16 22:23:10 UTC (rev 26996) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/libMP4/MP4Parser.cpp 2008-08-16 23:38:19 UTC (rev 26997) @@ -1747,7 +1747,6 @@ char *HDLRAtom::OnGetAtomName() { - printf("%s %s:",(char *)&(theHeader.handler_type),name); return "MPEG-4 Handler Reference Atom "; } 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-08-16 22:23:10 UTC (rev 26996) +++ haiku/trunk/src/add-ons/media/plugins/mp4_reader/mp4_reader.cpp 2008-08-16 23:38:19 UTC (rev 26997) @@ -70,6 +70,7 @@ uint32 frame_pos; uint32 frames_per_sec_rate; uint32 frames_per_sec_scale; + uint32 frame_size; }; @@ -188,7 +189,7 @@ // frame_count is actually sample_count for audio - makes media_player happy but david sad cookie->frame_count = theFileReader->getFrameCount(cookie->stream) * audio_format->FrameSize; cookie->duration = theFileReader->getAudioDuration(cookie->stream); - + cookie->audio = true; if (stream_header->scale && stream_header->rate) { @@ -199,7 +200,7 @@ cookie->frames_per_sec_scale = stream_header->scale; TRACE("bytes_per_sec_rate %ld, bytes_per_sec_scale %ld (using both)\n", cookie->bytes_per_sec_rate, cookie->bytes_per_sec_scale); - TRACE("frames_per_sec_rate %ld, frames_per_sec_scale %ld (using both)\n", + TRACE("samples_per_sec_rate %ld, samples_per_sec_scale %ld (using both)\n", cookie->frames_per_sec_rate, cookie->frames_per_sec_scale); } else if (stream_header->rate) { cookie->bytes_per_sec_rate = stream_header->rate * audio_format->SampleSize @@ -209,7 +210,7 @@ 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); - TRACE("frames_per_sec_rate %ld, frames_per_sec_scale %ld (using rate)\n", + TRACE("samples_per_sec_rate %ld, samples_per_sec_scale %ld (using rate)\n", cookie->frames_per_sec_rate, cookie->frames_per_sec_scale); } else { cookie->bytes_per_sec_rate = 128000; @@ -297,7 +298,8 @@ case 'alac': TRACE("AAC audio (mp4a) or ALAC audio\n"); - format->u.encoded_audio.output.frame_rate = 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; format->u.encoded_audio.output.format = media_raw_audio_format::B_AUDIO_SHORT; format->u.encoded_audio.output.byte_order = B_HOST_IS_LENDIAN ? B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN; @@ -307,18 +309,21 @@ // ALAC is 4096 samples per frame format->u.encoded_audio.frame_size = audio_format->FrameSize; + cookie->frame_size = audio_format->FrameSize; + format->u.encoded_audio.output.buffer_size = audio_format->BufferSize; // Average BitRate = (TotalBytes * 8 * (SampleRate / FrameSize)) / TotalFrames // Setting a bitrate seems to cause more problems than it solves - format->u.encoded_audio.bit_rate = audio_format->BitRate; // Should be 64000 * channelcount + + format->u.encoded_audio.bit_rate = audio_format->NoOfChannels * 64000; // Should be 64000 * channelcount 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); - TRACE("Track %d MP4 Audio FrameCount %ld\n",cookie->stream,theFileReader->getFrameCount(cookie->stream)); + TRACE("Track %d MP4 Audio FrameCount %ld Duration %Ld\n",cookie->stream,theFileReader->getFrameCount(cookie->stream),cookie->duration); break; default: @@ -378,6 +383,7 @@ cookie->audio = false; cookie->line_count = theFileReader->MovMainHeader()->height; + cookie->frame_size = 1; if (stream_header->scale && stream_header->rate) { cookie->frames_per_sec_rate = stream_header->rate; @@ -525,7 +531,7 @@ *infoBuffer = audio_format->theDecoderConfig; *infoSize = audio_format->DecoderConfigSize; } else { - printf("No stream Info for stream %d\n",cookie->stream); + ERROR("No stream Info for stream %d\n",cookie->stream); } } return B_OK; @@ -536,21 +542,18 @@ mp4Reader::Seek(void *cookie, uint32 flags, int64 *frame, bigtime_t *time) { // seek to the requested time or frame - mp4_cookie *mp4cookie = (mp4_cookie *)cookie; if (flags & B_MEDIA_SEEK_TO_TIME) { // frame = (time * rate) / fps / 1000000LL *frame = ((*time * mp4cookie->frames_per_sec_rate) / (int64)mp4cookie->frames_per_sec_scale) / 1000000LL; - TRACE("Time %Ld to Frame %Ld\n",*time, *frame); - mp4cookie->frame_pos = *frame; + mp4cookie->frame_pos = *frame / mp4cookie->frame_size; } if (flags & B_MEDIA_SEEK_TO_FRAME) { // time = frame * 1000000LL * fps / rate - TRACE("Frame %Ld to Time %Ld\n", *frame, *time); *time = (*frame * 1000000LL * (int64)mp4cookie->frames_per_sec_scale) / mp4cookie->frames_per_sec_rate; - mp4cookie->frame_pos = *frame; + mp4cookie->frame_pos = *frame / mp4cookie->frame_size; } TRACE("mp4Reader::Seek: seekTo%s%s%s%s, time %Ld, frame %Ld\n", @@ -585,10 +588,8 @@ (flags & B_MEDIA_SEEK_CLOSEST_BACKWARD) ? " B_MEDIA_SEEK_CLOSEST_BACKWARD" : "", *time, *frame); - if (mp4cookie->audio) { - // Audio does not have keyframes? Or all audio frames are keyframes? - return B_OK; - } else { + // Audio does not have keyframes? Or all audio frames are keyframes? + if (mp4cookie->audio == false) { while (*frame > 0 && *frame <= mp4cookie->frame_count) { keyframe = theFileReader->IsKeyFrame(mp4cookie->stream, *frame); @@ -627,8 +628,8 @@ uint32 size; bool keyframe; - if (theFileReader->GetNextChunkInfo(cookie->stream, cookie->frame_pos, &start, &size, &keyframe) == false) { - TRACE("LAST BUFFER ERROR\n"); + if (theFileReader->GetNextChunkInfo(cookie->stream, (cookie->frame_pos / cookie->frame_size), &start, &size, &keyframe) == false) { + TRACE("LAST BUFFER ERROR %ld\n",cookie->frame_pos); return B_LAST_BUFFER_ERROR; } @@ -638,12 +639,14 @@ cookie->buffer = new char [cookie->buffer_size]; } + mediaHeader->start_time = bigtime_t(double(cookie->frame_pos) * 1000000.0 * double(cookie->frames_per_sec_scale)) / cookie->frames_per_sec_rate; + if (cookie->audio) { -// TRACE("Audio stream %d: frame %ld expected start time %lld output size %ld key %d\n",cookie->stream, cookie->frame_pos, start, size, keyframe); +// TRACE("Audio"); mediaHeader->type = B_MEDIA_ENCODED_AUDIO; mediaHeader->u.encoded_audio.buffer_flags = keyframe ? B_MEDIA_KEY_FRAME : 0; } else { -// TRACE("Video stream %d: frame %ld start %lld Size %ld key %d\n",cookie->stream, cookie->frame_pos, start, size, keyframe); +// TRACE("Video"); mediaHeader->type = B_MEDIA_ENCODED_VIDEO; mediaHeader->u.encoded_video.field_flags = keyframe ? B_MEDIA_KEY_FRAME : 0; mediaHeader->u.encoded_video.first_active_line = 0; @@ -651,12 +654,10 @@ mediaHeader->u.encoded_video.field_number = 0; mediaHeader->u.encoded_video.field_sequence = cookie->frame_pos; } +// TRACE(" stream %d: frame %ld start time %.6f file pos %lld Size %ld key frame %s\n",cookie->stream, (cookie->frame_pos / cookie->frame_size), mediaHeader->start_time / 1000000.0, start, size, keyframe ? "true" : "false"); - mediaHeader->start_time = bigtime_t(cookie->frame_pos * 1000000.0 * cookie->frames_per_sec_scale) / cookie->frames_per_sec_rate; - cookie->frame_pos++; + cookie->frame_pos += cookie->frame_size; -// TRACE("stream %d: start_time %.6f\n", cookie->stream, mediaHeader->start_time / 1000000.0); - *chunkBuffer = cookie->buffer; *chunkSize = size; @@ -664,8 +665,10 @@ if (bytesRead < B_OK) return bytesRead; - if (bytesRead < (ssize_t)size) + if (bytesRead < (ssize_t)size) { + ERROR("Not enough bytes read asked for %ld got %ld\n", size, bytesRead); return B_LAST_BUFFER_ERROR; + } return B_OK; } From anevilyak at mail.berlios.de Sat Aug 16 05:06:06 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sat, 16 Aug 2008 05:06:06 +0200 Subject: [Haiku-commits] r26987 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200808160306.m7G366W6011445@sheep.berlios.de> Author: anevilyak Date: 2008-08-16 05:06:02 +0200 (Sat, 16 Aug 2008) New Revision: 26987 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26987&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: Use get_next_image_info to resolve the path to the executable. This fixes the problem that makebootable will not work unless run with an absolute path. Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 02:24:19 UTC (rev 26986) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 03:06:02 UTC (rev 26987) @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -106,17 +107,27 @@ // read_boot_code_data static uint8 * -read_boot_code_data(const char* programPath) +read_boot_code_data(void) { - // open our executable + image_info info; + int32 cookie = 0; BFile executableFile; - status_t error = executableFile.SetTo(programPath, B_READ_ONLY); - if (error != B_OK) { - fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " - "%s\n", programPath, strerror(error)); + + status_t error = get_next_image_info(0, &cookie, &info); + if (error == B_OK) { + // open our executable + error = executableFile.SetTo(info.name, B_READ_ONLY); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " + "%s\n", info.name, strerror(error)); + exit(1); + } + } else { + fprintf(stderr, "Error: Failed to get image info for executable file, " + "error: %s\n", strerror(error)); exit(1); } - + uint8 *bootCodeData = new uint8[kBootCodeSize]; // open our resources @@ -225,7 +236,7 @@ print_usage_and_exit(true); // read the boot code - uint8 *bootCodeData = read_boot_code_data(argv[0]); + uint8 *bootCodeData = read_boot_code_data(); if (!bootCodeData) { fprintf(stderr, "Error: Failed to read "); exit(1); From axeld at mail.berlios.de Sun Aug 17 12:31:32 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 12:31:32 +0200 Subject: [Haiku-commits] r27000 - haiku/trunk/src/kits/network Message-ID: <200808171031.m7HAVWeF008822@sheep.berlios.de> Author: axeld Date: 2008-08-17 12:31:31 +0200 (Sun, 17 Aug 2008) New Revision: 27000 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27000&view=rev Modified: haiku/trunk/src/kits/network/init.cpp Log: * Use addr_t instead of int32, since we're dealing with addresses here, and this way it wouldn't work on 64 bit. Modified: haiku/trunk/src/kits/network/init.cpp =================================================================== --- haiku/trunk/src/kits/network/init.cpp 2008-08-17 02:11:32 UTC (rev 26999) +++ haiku/trunk/src/kits/network/init.cpp 2008-08-17 10:31:31 UTC (rev 27000) @@ -29,8 +29,9 @@ 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)) { + if (((addr_t)info.text <= (addr_t)find_own_image + && (addr_t)info.text + (addr_t)info.text_size + > (addr_t)find_own_image)) { // found us __gNetworkStart = (addr_t)min_c(info.text, info.data); __gNetworkEnd = min_c((addr_t)info.text + info.text_size, From mmu_man at mail.berlios.de Sun Aug 17 00:23:11 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 17 Aug 2008 00:23:11 +0200 Subject: [Haiku-commits] r26996 - haiku/trunk/src/system/boot/loader Message-ID: <200808162223.m7GMNBVv002344@sheep.berlios.de> Author: mmu_man Date: 2008-08-17 00:23:10 +0200 (Sun, 17 Aug 2008) New Revision: 26996 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26996&view=rev Modified: haiku/trunk/src/system/boot/loader/partitions.cpp Log: Avoid mounting images inside images (inside images (inside images...)). Modified: haiku/trunk/src/system/boot/loader/partitions.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/partitions.cpp 2008-08-16 22:07:33 UTC (rev 26995) +++ haiku/trunk/src/system/boot/loader/partitions.cpp 2008-08-16 22:23:10 UTC (rev 26996) @@ -222,6 +222,7 @@ status_t Partition::_Mount(file_system_module_info *module, Directory **_fileSystem) { + static int fileMapDiskDepth = 0; TRACE(("%p Partition::_Mount check for file_system: %s\n", this, module->pretty_name)); @@ -236,13 +237,16 @@ fIsFileSystem = true; - // see if it contains an image file we could mount in turn - // XXX: avoid recursing too much - FileMapDisk *disk = FileMapDisk::FindAnyFileMapDisk(fileSystem); - if (disk) { - TRACE(("%p Partition::_Mount: found FileMapDisk\n", this)); - add_partitions_for(disk, true, false); + // if we aren't already mounting an image + if (!fileMapDiskDepth++) { + // see if it contains an image file we could mount in turn + FileMapDisk *disk = FileMapDisk::FindAnyFileMapDisk(fileSystem); + if (disk) { + TRACE(("%p Partition::_Mount: found FileMapDisk\n", this)); + add_partitions_for(disk, true, false); + } } + fileMapDiskDepth--; return B_OK; } From mmu_man at mail.berlios.de Sun Aug 17 04:11:37 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 17 Aug 2008 04:11:37 +0200 Subject: [Haiku-commits] r26999 - haiku/trunk/src/system/kernel/platform/atari_m68k Message-ID: <200808170211.m7H2BbJa024796@sheep.berlios.de> Author: mmu_man Date: 2008-08-17 04:11:32 +0200 (Sun, 17 Aug 2008) New Revision: 26999 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26999&view=rev Modified: haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp Log: We're actually using serial input for KDL for now... Modified: haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp =================================================================== --- haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-16 23:47:20 UTC (rev 26998) +++ haiku/trunk/src/system/kernel/platform/atari_m68k/platform.cpp 2008-08-17 02:11:32 UTC (rev 26999) @@ -329,6 +329,7 @@ if ((status & IKBD_STATUS_READ_BUFFER_FULL) == 0) { // no data in keyboard buffer spin(200); + //kprintf("no key\n"); continue; } @@ -431,7 +432,8 @@ M68KAtari::SerialDebugGetChar() { //WRITEME - return 0; + return BlueScreenGetChar(); + //return 0; } From bga at mail.berlios.de Sat Aug 16 14:48:28 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sat, 16 Aug 2008 14:48:28 +0200 Subject: [Haiku-commits] r26991 - haiku/trunk/src/apps/mail Message-ID: <200808161248.m7GCmSWT032580@sheep.berlios.de> Author: bga Date: 2008-08-16 14:48:27 +0200 (Sat, 16 Aug 2008) New Revision: 26991 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26991&view=rev Modified: haiku/trunk/src/apps/mail/MailSupport.cpp haiku/trunk/src/apps/mail/MailWindow.cpp Log: - Also fix references to the spa, server in Mail. - Now marking emails as spam through the Mail app also works. Still need to fix the Match Header filter as it seems not to be working. Modified: haiku/trunk/src/apps/mail/MailSupport.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailSupport.cpp 2008-08-16 11:05:59 UTC (rev 26990) +++ haiku/trunk/src/apps/mail/MailSupport.cpp 2008-08-16 12:48:27 UTC (rev 26991) @@ -88,7 +88,8 @@ // int32 level = L_BEGINNER; -const char* kSpamServerSignature = "application/x-vnd.agmsmith.spamdbm"; +const char* kSpamServerSignature = + "application/x-vnd.agmsmith.AGMSBayesianSpamServer"; const char* kDraftPath = "mail/draft"; const char* kDraftType = "text/x-vnd.Be-MailDraft"; const char* kMailFolder = "mail"; Modified: haiku/trunk/src/apps/mail/MailWindow.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailWindow.cpp 2008-08-16 11:05:59 UTC (rev 26990) +++ haiku/trunk/src/apps/mail/MailWindow.cpp 2008-08-16 12:48:27 UTC (rev 26991) @@ -2593,7 +2593,7 @@ directory_which places[] = {B_COMMON_BIN_DIRECTORY,B_BEOS_BIN_DIRECTORY}; for (int32 i = 0; i < 2; i++) { find_directory(places[i],&path); - path.Append("spamdbm"); + path.Append("AGMSBayesianSpamServer"); if (!BEntry(path.Path()).Exists()) continue; get_ref_for_path(path.Path(),&ref); From anevilyak at mail.berlios.de Sun Aug 17 00:07:34 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 17 Aug 2008 00:07:34 +0200 Subject: [Haiku-commits] r26995 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200808162207.m7GM7YEs001390@sheep.berlios.de> Author: anevilyak Date: 2008-08-17 00:07:33 +0200 (Sun, 17 Aug 2008) New Revision: 26995 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26995&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: Slightly more defensive approach to searching for the image. Thanks Axel :) Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 20:27:16 UTC (rev 26994) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-16 22:07:33 UTC (rev 26995) @@ -179,6 +179,24 @@ } +#ifdef __HAIKU__ +static status_t +find_own_image(image_info *info) +{ + int32 cookie = 0; + while (get_next_image_info(B_CURRENT_TEAM, &cookie, info) == B_OK) { + if (((uint32)info->text <= (uint32)find_own_image + && (uint32)info->text + info->text_size > + (uint32)find_own_image)) { + return B_OK; + } + } + + return B_NAME_NOT_FOUND; +} +#endif + + // main int main(int argc, const char *const *argv) @@ -234,8 +252,7 @@ bootCodeData = read_boot_code_data(argv[0]); #else image_info info; - int32 cookie = 0; - if (get_next_image_info(0, &cookie, &info) == B_OK) + if (find_own_image(&info) == B_OK) bootCodeData = read_boot_code_data(info.name); #endif if (!bootCodeData) { From axeld at mail.berlios.de Sun Aug 17 16:32:33 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 16:32:33 +0200 Subject: [Haiku-commits] r27004 - in haiku/trunk: headers/os/storage src/kits/storage Message-ID: <200808171432.m7HEWXWh019175@sheep.berlios.de> Author: axeld Date: 2008-08-17 16:32:33 +0200 (Sun, 17 Aug 2008) New Revision: 27004 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27004&view=rev Modified: haiku/trunk/headers/os/storage/Mime.h haiku/trunk/src/kits/storage/Mime.cpp Log: * Added two more public functions: get_named_icon(). * Implemented B_GET_ICON_NAME in get_device_icon(). * Comments welcome. Modified: haiku/trunk/headers/os/storage/Mime.h =================================================================== --- haiku/trunk/headers/os/storage/Mime.h 2008-08-17 13:21:49 UTC (rev 27003) +++ haiku/trunk/headers/os/storage/Mime.h 2008-08-17 14:32:33 UTC (rev 27004) @@ -50,6 +50,10 @@ status_t get_device_icon(const char* device, uint8** _data, size_t* _size, type_code* _type); +status_t get_named_icon(const char* name, BBitmap* icon, icon_size which); +status_t get_named_icon(const char* name, uint8** _data, size_t* _size, + type_code* _type); + // include MimeType.h for convenience # include #endif // __cplusplus Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 13:21:49 UTC (rev 27003) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 14:32:33 UTC (rev 27004) @@ -20,16 +20,19 @@ #include #include -#include -#include #include #include #include +#include +#include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -266,15 +269,19 @@ if (fd < 0) return errno; - // TODO: support B_GET_ICON_NAME! -#if 0 + // Try to get the icon by name first + char name[B_FILE_NAME_LENGTH]; - if (ioctl(fd, B_GET_ICON_NAME, name) == 0) { - close(fd); - return B_OK; + if (ioctl(fd, B_GET_ICON_NAME, name) >= 0) { + status_t status = get_named_icon(name, _data, _size, _type); + if (status == B_OK) { + close(fd); + return B_OK; + } } -#endif + // Getting the named icon failed, try vector icon next + uint8 data[8192]; device_icon iconData = {sizeof(data), data}; status_t status = ioctl(fd, B_GET_VECTOR_ICON, &iconData, @@ -302,6 +309,91 @@ *_type = B_VECTOR_ICON_TYPE; } + // TODO: also support getting the old icon? close(fd); return status; } + + +status_t +get_named_icon(const char* name, BBitmap* icon, icon_size which) +{ + // check parameters + if (name == NULL || icon == NULL) + return B_BAD_VALUE; + + BRect rect; + if (which == B_MINI_ICON) + rect.Set(0, 0, 15, 15); + else if (which == B_LARGE_ICON) + rect.Set(0, 0, 31, 31); + else + return B_BAD_VALUE; + + if (icon->Bounds() != rect) + return B_BAD_VALUE; + + uint8* data; + size_t size; + type_code type; + status_t status = get_named_icon(name, &data, &size, &type); + if (status == B_OK) + status = BIconUtils::GetVectorIcon(data, size, icon); + + delete[] data; + return status; +} + + +status_t +get_named_icon(const char* name, uint8** _data, size_t* _size, type_code* _type) +{ + if (name == NULL || _data == NULL || _size == NULL || _type == NULL) + return B_BAD_VALUE; + + directory_which kWhich[] = { + B_USER_DATA_DIRECTORY, + B_COMMON_DATA_DIRECTORY, + B_BEOS_DATA_DIRECTORY, + }; + + status_t status = B_ENTRY_NOT_FOUND; + BFile file; + off_t size; + + for (uint32 i = 0; i < sizeof(kWhich) / sizeof(kWhich[0]); i++) { + BPath path; + if (find_directory(kWhich[i], &path) != B_OK) + continue; + + path.Append("icons"); + path.Append(name); + + status = file.SetTo(path.Path(), B_READ_ONLY); + if (status == B_OK) { + status = file.GetSize(&size); + if (size > 1024 * 1024) + status = B_ERROR; + } + if (status == B_OK) + break; + } + + if (status != B_OK) + return status; + + *_data = new(std::nothrow) uint8[size]; + if (*_data == NULL) + return B_NO_MEMORY; + + if (file.Read(*_data, size) != size) { + delete[] *_data; + return B_ERROR; + } + + *_size = size; + *_type = B_VECTOR_ICON_TYPE; + // TODO: for now + + return B_OK; +} From axeld at pinc-software.de Thu Aug 14 23:51:27 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Thu, 14 Aug 2008 23:51:27 +0200 CEST Subject: [Haiku-commits] r26241 - haiku/trunk/src/add-ons/kernel/file_systems/ext2 In-Reply-To: <20080706154434.460.1@knochen-vm.nameserver> Message-ID: <44639542568-BeMail@zon> Ingo Weinhold wrote: > Computing better names would certainly be possible in the DDM or > maybe even > via the userland API. The latter might even be the best option, since > it > would allow the application in question to display the most > appropriate > amount of information. E.g. DriveSetup displays partitions in the > context > of their disk device anyway, so it doesn't make sense to add those > information to the name. Tracker on the other hand might want to do > that. > > Well, I guess in the end it might be best to just go with " > ()" and let the applications in question deal with further > disambiguation themselves (like showing a the device/partition > location in > Tracker's "Get Info" dialog or, when we manage to add those, in a > tool tip). Just how should the Tracker now that the file system didn't report the actual name of the volume? > > BTW I thought that it might be nice to have a (possibly userland > > situated) service that recognizes partition types/file systems > > (with > > volume name if possible) that are otherwise not supported. > > At least that would look much better in apps like DriveSetup. > Why another service? Adding a file system module that only implements > {identify,scan}_partition() seems the obvious way to go to me. We > might > want to add another partition flag to indicate that mounting isn't > supported, so that Tracker wouldn't display them in the mount menu, > though. That wouldn't be too bad. I thought of a userland service so that we don't have to add as many add-ons (there could be one add-on that recognizes them all, but that's not possible with how it currently works). Bye, Axel. From axeld at mail.berlios.de Fri Aug 15 13:00:13 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 15 Aug 2008 13:00:13 +0200 Subject: [Haiku-commits] r26977 - haiku/trunk/build/jam Message-ID: <200808151100.m7FB0DqR019647@sheep.berlios.de> Author: axeld Date: 2008-08-15 13:00:07 +0200 (Fri, 15 Aug 2008) New Revision: 26977 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26977&view=rev Modified: haiku/trunk/build/jam/FileRules Log: * Applied patch by Andreas that uses git as a fallback in case retrieving the revision failed using "svn info". * While there is no official git tree, this should help those people using svn over git. Modified: haiku/trunk/build/jam/FileRules =================================================================== --- haiku/trunk/build/jam/FileRules 2008-08-14 23:09:14 UTC (rev 26976) +++ haiku/trunk/build/jam/FileRules 2008-08-15 11:00:07 UTC (rev 26977) @@ -234,6 +234,10 @@ local svnEntries = entries ; SEARCH on $(svnEntries) = [ FDirName $(HAIKU_TOP) .svn ] ; Depends $(target) : $(svnEntries) ; + } else if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] { + local gitIndex = index ; + SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ; + Depends $(target) : $(gitIndex) ; } HAIKU_INCLUDE_IN_IMAGE on $(target) @@ -247,7 +251,12 @@ actions CopySetHaikuRevision1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - revision=`(LC_ALL=C LANG=C svn info $(HAIKU_TOP) 2> /dev/null || echo Revision: 0) | + revision=`(LC_ALL=C LANG=C svn info $(HAIKU_TOP) 2> /dev/null || + (cd $(HAIKU_TOP) && LC_ALL=C LANG=C git svn info) 2> /dev/null || + (git log --max-count=1 --grep="git-svn-id:" 2> /dev/null | + grep git-svn-id: | cut -d '@' -f 2 | + awk '{printf "Revision: " $1}') 2> /dev/null || + echo Revision: 0) | grep Revision | awk '{printf $2}'` $(2[1]) --data $(2[3]) $(1) && $(2[2]) $(1) ${revision} From bga at mail.berlios.de Thu Aug 14 19:39:34 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Thu, 14 Aug 2008 19:39:34 +0200 Subject: [Haiku-commits] r26974 - haiku/trunk/src/add-ons/kernel/file_systems/cdda Message-ID: <200808141739.m7EHdYxQ014826@sheep.berlios.de> Author: bga Date: 2008-08-14 19:39:33 +0200 (Thu, 14 Aug 2008) New Revision: 26974 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26974&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp Log: - Exported CDDB id trough the CD:cddbid attribute. - Tracks are now called "Track XX" instead of "XX". - We need no stinking TLAs! :) Next step, porting CDDBLinkD to Haiku. 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-08-14 15:08:16 UTC (rev 26973) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2008-08-14 17:39:33 UTC (rev 26974) @@ -568,6 +568,10 @@ return status; } + // add CD:cddbid attribute. + fRootNode->AddAttribute("CD:cddbid", B_UINT32_TYPE, true, + (const uint8 *)&fDiscID, 4); + cdtext text; if (read_cdtext(fDevice, text) < B_OK) dprintf("CDDA: no CD-Text found.\n"); @@ -595,14 +599,14 @@ if (text.titles[i] != NULL) { if (text.artists[i] != NULL) { - snprintf(title, sizeof(title), "%02ld. %s - %s.wav", track, + snprintf(title, sizeof(title), "%02ld. %s - %s", track, text.artists[i], text.titles[i]); } else { - snprintf(title, sizeof(title), "%02ld. %s.wav", track, + snprintf(title, sizeof(title), "%02ld. %s", track, text.titles[i]); } } else - snprintf(title, sizeof(title), "%02ld.wav", track); + snprintf(title, sizeof(title), "Track %02ld", track); // remove '/' and '\n' from title for (int32 j = 0; title[j]; j++) { From oruizdorantes at mail.berlios.de Fri Aug 15 21:08:53 2008 From: oruizdorantes at mail.berlios.de (oruizdorantes at mail.berlios.de) Date: Fri, 15 Aug 2008 21:08:53 +0200 Subject: [Haiku-commits] r26983 - haiku/trunk/headers/os/bluetooth Message-ID: <200808151908.m7FJ8rpg006690@sheep.berlios.de> Author: oruizdorantes Date: 2008-08-15 21:08:48 +0200 (Fri, 15 Aug 2008) New Revision: 26983 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26983&view=rev Modified: haiku/trunk/headers/os/bluetooth/bdaddrUtils.h haiku/trunk/headers/os/bluetooth/bluetooth_util.h Log: Remove warning, use the common util function for the bdaddr utils class Modified: haiku/trunk/headers/os/bluetooth/bdaddrUtils.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2008-08-15 15:00:26 UTC (rev 26982) +++ haiku/trunk/headers/os/bluetooth/bdaddrUtils.h 2008-08-15 19:08:48 UTC (rev 26983) @@ -9,25 +9,26 @@ #include #include +#include namespace Bluetooth { class bdaddrUtils { public: - static inline bdaddr_t NullAddress() + static inline bdaddr_t NullAddress() { return ((bdaddr_t) {{0, 0, 0, 0, 0, 0}}); } - static inline bdaddr_t LocalAddress() + static inline bdaddr_t LocalAddress() { return ((bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}); } - static inline bdaddr_t BroadcastAddress() + static inline bdaddr_t BroadcastAddress() { return ((bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}); } @@ -35,11 +36,11 @@ static bool Compare(bdaddr_t *ba1, bdaddr_t *ba2) { - return (memcmp(ba1, ba2, sizeof(bdaddr_t)) == 0); + return (bacmp(ba1, ba2) == 0); } - static char* ToString(const bdaddr_t bdaddr) + static char* ToString(const bdaddr_t bdaddr) { // TODO: not safe static char str[18]; @@ -64,7 +65,7 @@ } return NullAddress(); - } + } }; Modified: haiku/trunk/headers/os/bluetooth/bluetooth_util.h =================================================================== --- haiku/trunk/headers/os/bluetooth/bluetooth_util.h 2008-08-15 15:00:26 UTC (rev 26982) +++ haiku/trunk/headers/os/bluetooth/bluetooth_util.h 2008-08-15 19:08:48 UTC (rev 26983) @@ -6,6 +6,7 @@ #define _BLUETOOTH_UTIL_H #include +#include /* BD Address management */ static inline int bacmp(bdaddr_t* ba1, bdaddr_t* ba2) From axeld at mail.berlios.de Fri Aug 15 16:46:17 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 15 Aug 2008 16:46:17 +0200 Subject: [Haiku-commits] r26980 - in haiku/trunk: headers/private/net src/add-ons/kernel/network/stack Message-ID: <200808151446.m7FEkHgg025163@sheep.berlios.de> Author: axeld Date: 2008-08-15 16:46:16 +0200 (Fri, 15 Aug 2008) New Revision: 26980 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26980&view=rev Modified: haiku/trunk/headers/private/net/net_stack.h haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp haiku/trunk/src/add-ons/kernel/network/stack/utility.h Log: * Added a net_timer::flags field, and used it to implement the new wait_for_timer() function. * Moved the internal Fifo class into utility.cpp - we should probably just remove it again. * Fixed uninit_timers() so that it would even work in combination with the timer thread if there are timers left to be scheduled. * Minor cleanup. Modified: haiku/trunk/headers/private/net/net_stack.h =================================================================== --- haiku/trunk/headers/private/net/net_stack.h 2008-08-15 14:06:15 UTC (rev 26979) +++ haiku/trunk/headers/private/net/net_stack.h 2008-08-15 14:46:16 UTC (rev 26980) @@ -44,6 +44,7 @@ net_timer_func hook; void *data; bigtime_t due; + uint32 flags; }; typedef int32 (*net_deframe_func)(struct net_device *device, @@ -140,6 +141,7 @@ void (*init_timer)(struct net_timer *timer, net_timer_func hook, void *data); void (*set_timer)(struct net_timer *timer, bigtime_t delay); bool (*cancel_timer)(struct net_timer *timer); + void (*wait_for_timer)(struct net_timer *timer); bool (*is_timer_active)(struct net_timer *timer); // syscall restart Modified: haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-08-15 14:06:15 UTC (rev 26979) +++ haiku/trunk/src/add-ons/kernel/network/stack/stack.cpp 2008-08-15 14:46:16 UTC (rev 26980) @@ -250,7 +250,7 @@ for (int32 i = 0; modules[i] != NULL; i++) { if (get_module(modules[i], &infos[i]) < B_OK) { flags |= CHAIN_MISSING_MODULE; - + // put already opened modules while (i-- > 0) { put_module(modules[i]); @@ -494,7 +494,7 @@ uninit_domain_protocols(socket); chain->Release(); - return B_OK; + return B_OK; } @@ -582,7 +582,7 @@ uninit_domain_datalink_protocols(interface); chain->Release(); - return B_OK; + return B_OK; } @@ -628,7 +628,7 @@ } chain->Release(); - return B_OK; + return B_OK; } @@ -641,7 +641,7 @@ } MutexLocker locker(&sChainLock); - + struct chain *chain = chain::Lookup(sProtocolChains, family, type, protocol); if (chain != NULL) return B_OK; @@ -850,7 +850,7 @@ hash_uninit(sDatalinkProtocolChains); hash_uninit(sReceivingProtocolChains); hash_uninit(sFamilies); - + return B_OK; } @@ -913,6 +913,7 @@ init_timer, set_timer, cancel_timer, + wait_for_timer, is_timer_active, is_syscall, Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2008-08-15 14:06:15 UTC (rev 26979) +++ haiku/trunk/src/add-ons/kernel/network/stack/utility.cpp 2008-08-15 14:46:16 UTC (rev 26980) @@ -7,26 +7,63 @@ */ -#include "stack_private.h" #include "utility.h" +#include +#include + +#include #include #include #include -#include -#include +#include "stack_private.h" +#define TIMER_IS_RUNNING 0x80000000 + +// internal Fifo class which doesn't maintain it's own lock +// TODO: do we need this one for anything? +class Fifo { +public: + Fifo(const char* name, size_t maxBytes); + ~Fifo(); + + status_t InitCheck() const; + + status_t Enqueue(net_buffer* buffer); + status_t EnqueueAndNotify(net_buffer* _buffer, net_socket* socket, + uint8 event); + status_t Wait(mutex* lock, bigtime_t timeout); + net_buffer* Dequeue(bool clone); + status_t Clear(); + + void WakeAll(); + + bool IsEmpty() const { return current_bytes == 0; } + +//private: + // these field names are kept so we can use templatized + // functions together with net_fifo + sem_id notify; + int32 waiting; + size_t max_bytes; + size_t current_bytes; + struct list buffers; +}; + + + static struct list sTimers; static mutex sTimerLock; static sem_id sTimerWaitSem; +static ConditionVariable sWaitForTimerCondition; static thread_id sTimerThread; static bigtime_t sTimerTimeout; static inline void -fifo_notify_one_reader(int32 &waiting, sem_id sem) +fifo_notify_one_reader(int32& waiting, sem_id sem) { if (waiting > 0) { waiting--; @@ -36,7 +73,7 @@ template static inline status_t -base_fifo_init(FifoType *fifo, const char *name, size_t maxBytes) +base_fifo_init(FifoType* fifo, const char* name, size_t maxBytes) { fifo->notify = create_sem(0, name); fifo->max_bytes = maxBytes; @@ -49,9 +86,10 @@ template static inline status_t -base_fifo_enqueue_buffer(FifoType *fifo, net_buffer *buffer) +base_fifo_enqueue_buffer(FifoType* fifo, net_buffer* buffer) { - if (fifo->max_bytes > 0 && fifo->current_bytes + buffer->size > fifo->max_bytes) + if (fifo->max_bytes > 0 + && fifo->current_bytes + buffer->size > fifo->max_bytes) return ENOBUFS; list_add_item(&fifo->buffers, buffer); @@ -63,10 +101,10 @@ template static inline status_t -base_fifo_clear(FifoType *fifo) +base_fifo_clear(FifoType* fifo) { while (true) { - net_buffer *buffer = (net_buffer *)list_remove_head_item(&fifo->buffers); + net_buffer* buffer = (net_buffer*)list_remove_head_item(&fifo->buffers); if (buffer == NULL) break; @@ -81,8 +119,8 @@ // #pragma mark - -void * -UserBuffer::Copy(void *source, size_t length) +void* +UserBuffer::Copy(void* source, size_t length) { if (fStatus != B_OK) return NULL; @@ -100,7 +138,7 @@ memcpy(fBuffer, source, length); #endif - void *current = fBuffer; + void* current = fBuffer; fAvailable -= length; fBuffer += length; @@ -110,9 +148,9 @@ uint16 -compute_checksum(uint8 *_buffer, size_t length) +compute_checksum(uint8* _buffer, size_t length) { - uint16 *buffer = (uint16 *)_buffer; + uint16* buffer = (uint16*)_buffer; uint32 sum = 0; // TODO: unfold loop for speed @@ -125,12 +163,12 @@ if (length) { // give the last byte it's proper endian-aware treatment #if B_HOST_IS_LENDIAN - sum += *(uint8 *)buffer; + sum += *(uint8*)buffer; #else uint8 ordered[2]; - ordered[0] = *(uint8 *)buffer; + ordered[0] = *(uint8*)buffer; ordered[1] = 0; - sum += *(uint16 *)ordered; + sum += *(uint16*)ordered; #endif } @@ -143,7 +181,7 @@ uint16 -checksum(uint8 *buffer, size_t length) +checksum(uint8* buffer, size_t length) { return ~compute_checksum(buffer, length); } @@ -153,7 +191,7 @@ status_t -notify_socket(net_socket *socket, uint8 event, int32 value) +notify_socket(net_socket* socket, uint8 event, int32 value) { return gNetSocketModule.notify(socket, event, value); } @@ -162,7 +200,7 @@ // #pragma mark - FIFOs -Fifo::Fifo(const char *name, size_t maxBytes) +Fifo::Fifo(const char* name, size_t maxBytes) { base_fifo_init(this, name, maxBytes); } @@ -183,14 +221,14 @@ status_t -Fifo::Enqueue(net_buffer *buffer) +Fifo::Enqueue(net_buffer* buffer) { return base_fifo_enqueue_buffer(this, buffer); } status_t -Fifo::EnqueueAndNotify(net_buffer *_buffer, net_socket *socket, uint8 event) +Fifo::EnqueueAndNotify(net_buffer* _buffer, net_socket* socket, uint8 event) { net_buffer *buffer = gNetBufferModule.clone(_buffer, false); if (buffer == NULL) @@ -207,7 +245,7 @@ status_t -Fifo::Wait(mutex *lock, bigtime_t timeout) +Fifo::Wait(mutex* lock, bigtime_t timeout) { waiting++; mutex_unlock(lock); @@ -218,10 +256,10 @@ } -net_buffer * +net_buffer* Fifo::Dequeue(bool clone) { - net_buffer *buffer = (net_buffer *)list_get_first_item(&buffers); + net_buffer* buffer = (net_buffer*)list_get_first_item(&buffers); // assert(buffer != NULL); @@ -256,7 +294,7 @@ status_t -init_fifo(net_fifo *fifo, const char *name, size_t maxBytes) +init_fifo(net_fifo* fifo, const char* name, size_t maxBytes) { mutex_init_etc(&fifo->lock, name, MUTEX_FLAG_CLONE_NAME); @@ -269,7 +307,7 @@ void -uninit_fifo(net_fifo *fifo) +uninit_fifo(net_fifo* fifo) { clear_fifo(fifo); @@ -279,15 +317,14 @@ status_t -fifo_enqueue_buffer(net_fifo *fifo, net_buffer *buffer) +fifo_enqueue_buffer(net_fifo* fifo, net_buffer* buffer) { MutexLocker locker(fifo->lock); return base_fifo_enqueue_buffer(fifo, buffer); } -/*! - Gets the first buffer from the FIFO. If there is no buffer, it +/*! Gets the first buffer from the FIFO. If there is no buffer, it will wait depending on the \a flags and \a timeout. The following flags are supported (the rest is ignored): MSG_DONTWAIT - ignores the timeout and never wait for a buffer; if your @@ -297,15 +334,15 @@ in the FIFO. */ ssize_t -fifo_dequeue_buffer(net_fifo *fifo, uint32 flags, bigtime_t timeout, - net_buffer **_buffer) +fifo_dequeue_buffer(net_fifo* fifo, uint32 flags, bigtime_t timeout, + net_buffer** _buffer) { MutexLocker locker(fifo->lock); bool dontWait = (flags & MSG_DONTWAIT) != 0 || timeout == 0; status_t status; while (true) { - net_buffer *buffer = (net_buffer *)list_get_first_item(&fifo->buffers); + net_buffer* buffer = (net_buffer*)list_get_first_item(&fifo->buffers); if (buffer != NULL) { if ((flags & MSG_PEEK) != 0) { // we need to clone the buffer for inspection; we can't give a @@ -352,7 +389,7 @@ status_t -clear_fifo(net_fifo *fifo) +clear_fifo(net_fifo* fifo) { MutexLocker locker(fifo->lock); return base_fifo_clear(fifo); @@ -360,8 +397,8 @@ status_t -fifo_socket_enqueue_buffer(net_fifo *fifo, net_socket *socket, uint8 event, - net_buffer *_buffer) +fifo_socket_enqueue_buffer(net_fifo* fifo, net_socket* socket, uint8 event, + net_buffer* _buffer) { net_buffer *buffer = gNetBufferModule.clone(_buffer, false); if (buffer == NULL) @@ -383,7 +420,7 @@ static status_t -timer_thread(void * /*data*/) +timer_thread(void* /*data*/) { status_t status = B_OK; @@ -392,12 +429,11 @@ if (status == B_TIMED_OUT || status == B_OK) { // scan timers for new timeout and/or execute a timer - if (mutex_lock(&sTimerLock) < B_OK) - return B_OK; + mutex_lock(&sTimerLock); - struct net_timer *timer = NULL; + struct net_timer* timer = NULL; while (true) { - timer = (net_timer *)list_get_next_item(&sTimers, timer); + timer = (net_timer*)list_get_next_item(&sTimers, timer); if (timer == NULL) break; @@ -405,11 +441,14 @@ // execute timer list_remove_item(&sTimers, timer); timer->due = -1; + timer->flags |= TIMER_IS_RUNNING; mutex_unlock(&sTimerLock); timer->hook(timer, timer->data); mutex_lock(&sTimerLock); + timer->flags &= ~TIMER_IS_RUNNING; + sWaitForTimerCondition.NotifyAll(); timer = NULL; // restart scanning as we unlocked the list } else { @@ -431,7 +470,7 @@ // B_TIMED_OUT - look for timers to be executed // B_BAD_SEM_ID - we are asked to quit } while (status != B_BAD_SEM_ID); - + return B_OK; } @@ -441,11 +480,12 @@ a timer later on, but make sure you have canceled it before using set_timer(). */ void -init_timer(net_timer *timer, net_timer_func hook, void *data) +init_timer(net_timer* timer, net_timer_func hook, void* data) { timer->hook = hook; timer->data = data; timer->due = 0; + timer->flags = 0; } @@ -458,7 +498,7 @@ making any changes. */ void -set_timer(net_timer *timer, bigtime_t delay) +set_timer(net_timer* timer, bigtime_t delay) { MutexLocker locker(sTimerLock); @@ -483,7 +523,7 @@ bool -cancel_timer(struct net_timer *timer) +cancel_timer(struct net_timer* timer) { MutexLocker locker(sTimerLock); @@ -497,21 +537,41 @@ } +void +wait_for_timer(struct net_timer* timer) +{ + while (true) { + MutexLocker locker(sTimerLock); + + if (timer->due <= 0 && (timer->flags & TIMER_IS_RUNNING) == 0) + return; + + // we actually need to wait for this timer + ConditionVariableEntry entry; + sWaitForTimerCondition.Add(&entry); + + locker.Unlock(); + + entry.Wait(); + } +} + + bool -is_timer_active(net_timer *timer) +is_timer_active(net_timer* timer) { return timer->due > 0; } static int -dump_timer(int argc, char **argv) +dump_timer(int argc, char** argv) { kprintf("timer hook data due in\n"); - struct net_timer *timer = NULL; + struct net_timer* timer = NULL; while (true) { - timer = (net_timer *)list_get_next_item(&sTimers, timer); + timer = (net_timer*)list_get_next_item(&sTimers, timer); if (timer == NULL) break; @@ -545,6 +605,8 @@ goto err2; } + sWaitForTimerCondition.Init(NULL, "wait for net timer"); + add_debugger_command("net_timer", dump_timer, "Lists all active network timer"); @@ -561,9 +623,11 @@ void uninit_timers(void) { - mutex_destroy(&sTimerLock); delete_sem(sTimerWaitSem); + mutex_lock(&sTimerLock); + mutex_destroy(&sTimerLock); + status_t status; wait_for_thread(sTimerThread, &status); } Modified: haiku/trunk/src/add-ons/kernel/network/stack/utility.h =================================================================== --- haiku/trunk/src/add-ons/kernel/network/stack/utility.h 2008-08-15 14:06:15 UTC (rev 26979) +++ haiku/trunk/src/add-ons/kernel/network/stack/utility.h 2008-08-15 14:46:16 UTC (rev 26980) @@ -11,53 +11,29 @@ #include + class UserBuffer { public: - UserBuffer(void *buffer, size_t size); + UserBuffer(void* buffer, size_t size); - void *Copy(void *source, size_t size); + void* Copy(void* source, size_t size); status_t Status() const; size_t ConsumedAmount() const; private: - uint8 *fBuffer; + uint8* fBuffer; size_t fBufferSize, fAvailable; status_t fStatus; }; -// internal Fifo class which doesn't maintain it's own lock -class Fifo { -public: - Fifo(const char *name, size_t maxBytes); - ~Fifo(); - - status_t InitCheck() const; - - status_t Enqueue(net_buffer *buffer); - status_t EnqueueAndNotify(net_buffer *_buffer, net_socket *socket, uint8 event); - status_t Wait(mutex *lock, bigtime_t timeout); - net_buffer *Dequeue(bool clone); - status_t Clear(); - - void WakeAll(); - - bool IsEmpty() const { return current_bytes == 0; } - -//private: - // these field names are kept so we can use templatized - // functions together with net_fifo - sem_id notify; - int32 waiting; - size_t max_bytes; - size_t current_bytes; - struct list buffers; -}; - inline -UserBuffer::UserBuffer(void *buffer, size_t size) - : fBuffer((uint8 *)buffer), fBufferSize(size), - fAvailable(size), fStatus(B_OK) +UserBuffer::UserBuffer(void* buffer, size_t size) + : + fBuffer((uint8*)buffer), + fBufferSize(size), + fAvailable(size), + fStatus(B_OK) { } @@ -77,27 +53,28 @@ // checksums -uint16 compute_checksum(uint8 *_buffer, size_t length); -uint16 checksum(uint8 *buffer, size_t length); +uint16 compute_checksum(uint8* _buffer, size_t length); +uint16 checksum(uint8* buffer, size_t length); // notifications -status_t notify_socket(net_socket *socket, uint8 event, int32 value); +status_t notify_socket(net_socket* socket, uint8 event, int32 value); // fifos -status_t init_fifo(net_fifo *fifo, const char *name, size_t maxBytes); -void uninit_fifo(net_fifo *fifo); -status_t fifo_enqueue_buffer(net_fifo *fifo, struct net_buffer *buffer); -ssize_t fifo_dequeue_buffer(net_fifo *fifo, uint32 flags, bigtime_t timeout, - struct net_buffer **_buffer); -status_t clear_fifo(net_fifo *fifo); -status_t fifo_socket_enqueue_buffer(net_fifo *, net_socket *, uint8 event, - net_buffer *); +status_t init_fifo(net_fifo* fifo, const char *name, size_t maxBytes); +void uninit_fifo(net_fifo* fifo); +status_t fifo_enqueue_buffer(net_fifo* fifo, struct net_buffer* buffer); +ssize_t fifo_dequeue_buffer(net_fifo* fifo, uint32 flags, bigtime_t timeout, + struct net_buffer** _buffer); +status_t clear_fifo(net_fifo* fifo); +status_t fifo_socket_enqueue_buffer(net_fifo* fifo, net_socket* socket, + uint8 event, net_buffer* buffer); // timer -void init_timer(net_timer *timer, net_timer_func hook, void *data); -void set_timer(net_timer *timer, bigtime_t delay); -bool cancel_timer(struct net_timer *timer); -bool is_timer_active(net_timer *timer); +void init_timer(net_timer* timer, net_timer_func hook, void* data); +void set_timer(net_timer* timer, bigtime_t delay); +bool cancel_timer(struct net_timer* timer); +void wait_for_timer(struct net_timer* timer); +bool is_timer_active(net_timer* timer); status_t init_timers(void); void uninit_timers(void); From bga at mail.berlios.de Sun Aug 17 15:21:49 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Sun, 17 Aug 2008 15:21:49 +0200 Subject: [Haiku-commits] r27003 - haiku/trunk/src/tests/system/libroot/os Message-ID: <200808171321.m7HDLnDo012198@sheep.berlios.de> Author: bga Date: 2008-08-17 15:21:49 +0200 (Sun, 17 Aug 2008) New Revision: 27003 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27003&view=rev Modified: haiku/trunk/src/tests/system/libroot/os/ParseDateTest.cpp Log: - Added a crashing case (with a stack corruption, no less) to the ParseDateTest. Modified: haiku/trunk/src/tests/system/libroot/os/ParseDateTest.cpp =================================================================== --- haiku/trunk/src/tests/system/libroot/os/ParseDateTest.cpp 2008-08-17 13:20:45 UTC (rev 27002) +++ haiku/trunk/src/tests/system/libroot/os/ParseDateTest.cpp 2008-08-17 13:21:49 UTC (rev 27003) @@ -64,6 +64,7 @@ "-15 minutes", "3:33pm GMT", "Mon, June 10th, 1993 10:00:03 am GMT", + "Sat, 16 Aug ?????????? ????? (????)", NULL }; From bga at mail.berlios.de Fri Aug 15 16:06:15 2008 From: bga at mail.berlios.de (bga at BerliOS) Date: Fri, 15 Aug 2008 16:06:15 +0200 Subject: [Haiku-commits] r26979 - haiku/trunk/src/add-ons/kernel/file_systems/cdda Message-ID: <200808151406.m7FE6Fda021468@sheep.berlios.de> Author: bga Date: 2008-08-15 16:06:15 +0200 (Fri, 15 Aug 2008) New Revision: 26979 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26979&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp Log: - Add the TLA back. I still think it is useless but I guess even in R5 the files included the extension. 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-08-15 11:47:28 UTC (rev 26978) +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/kernel_interface.cpp 2008-08-15 14:06:15 UTC (rev 26979) @@ -599,14 +599,14 @@ if (text.titles[i] != NULL) { if (text.artists[i] != NULL) { - snprintf(title, sizeof(title), "%02ld. %s - %s", track, + snprintf(title, sizeof(title), "%02ld. %s - %s.wav", track, text.artists[i], text.titles[i]); } else { - snprintf(title, sizeof(title), "%02ld. %s", track, + snprintf(title, sizeof(title), "%02ld. %s.wav", track, text.titles[i]); } } else - snprintf(title, sizeof(title), "Track %02ld", track); + snprintf(title, sizeof(title), "Track %02ld.wav", track); // remove '/' and '\n' from title for (int32 j = 0; title[j]; j++) { From sbenedetto at mail.berlios.de Sat Aug 16 20:20:55 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Sat, 16 Aug 2008 20:20:55 +0200 Subject: [Haiku-commits] r26993 - in haiku/trunk: headers/private/kernel headers/private/kernel/posix src/system/kernel src/system/kernel/posix Message-ID: <200808161820.m7GIKtij017261@sheep.berlios.de> Author: sbenedetto Date: 2008-08-16 20:20:54 +0200 (Sat, 16 Aug 2008) New Revision: 26993 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26993&view=rev Modified: haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp haiku/trunk/src/system/kernel/team.cpp Log: * Reworked the way sem_undo requests are processed by following Ingo suggestions: instead of having one global sem_undo list, we now have two local list, one per semaphore set and one per team which is held in its xsi_sem_context structure, along with a mutex. A mutex has also been added to the semaphore set class in order to protect the local list, but also in order to (hopefully) improve concurrency. Modified: haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h =================================================================== --- haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h 2008-08-16 18:06:52 UTC (rev 26992) +++ haiku/trunk/headers/private/kernel/posix/xsi_semaphore.h 2008-08-16 18:20:54 UTC (rev 26993) @@ -17,7 +17,7 @@ __BEGIN_DECLS extern void xsi_ipc_init(); -extern void xsi_sem_undo(team_id teamID, int32 numberOfUndos); +extern void xsi_sem_undo(struct team *team); /* user calls */ int _user_xsi_semget(key_t key, int numberOfSemaphores, int flags); Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2008-08-16 18:06:52 UTC (rev 26992) +++ haiku/trunk/headers/private/kernel/thread_types.h 2008-08-16 18:20:54 UTC (rev 26993) @@ -67,6 +67,7 @@ struct realtime_sem_context; // defined in realtime_sem.cpp struct select_info; struct user_thread; // defined in libroot/user_thread.h +struct xsi_sem_context; // defined in xsi_semaphore.cpp struct death_entry { struct list_link link; @@ -183,7 +184,7 @@ int32 flags; void *io_context; struct realtime_sem_context *realtime_sem_context; - int32 xsi_sem_undo_requests; + struct xsi_sem_context *xsi_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/posix/xsi_semaphore.cpp =================================================================== --- haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-16 18:06:52 UTC (rev 26992) +++ haiku/trunk/src/system/kernel/posix/xsi_semaphore.cpp 2008-08-16 18:20:54 UTC (rev 26993) @@ -18,13 +18,14 @@ #include #include +#include #include #include #include #include -#define TRACE_XSI_SEM +//#define TRACE_XSI_SEM #ifdef TRACE_XSI_SEM # define TRACE(x) dprintf x # define TRACE_ERROR(x) dprintf x @@ -50,25 +51,42 @@ typedef DoublyLinkedList ThreadQueue; +class XsiSemaphoreSet; + struct sem_undo : DoublyLinkedListLinkImpl { - sem_undo(struct team *process, int semaphoreSetID, short semaphoreNumber, - short undoValue) + sem_undo(XsiSemaphoreSet *semaphoreSet, struct team *team, int16 *undoValues) : - team(process), - semaphore_set_id(semaphoreSetID), - semaphore_number(semaphoreNumber), - undo_value(undoValue) + semaphore_set(semaphoreSet), + team(team), + undo_values(undoValues) { } - struct team *team; - int semaphore_set_id; - short semaphore_number; - short undo_value; + DoublyLinkedListLink team_link; + XsiSemaphoreSet *semaphore_set; + struct team *team; + int16 *undo_values; }; -typedef DoublyLinkedList SemaphoreUndoList; +typedef DoublyLinkedList UndoList; +typedef DoublyLinkedList > TeamList; +struct xsi_sem_context { + xsi_sem_context() + { + mutex_init(&lock, "Private team undo_list lock"); + } + + ~xsi_sem_context() + { + mutex_destroy(&lock); + } + + TeamList undo_list; + mutex lock; +}; + // Xsi semaphore definition class XsiSemaphore { public: @@ -119,22 +137,11 @@ } } - // Implemented after sUndoListLock is declared - void ClearUndos(int semaphoreSetID, short semaphoreNumber); - pid_t LastPid() const { return fLastPidOperation; } - // Record the sem_undo operation in sUndoList. The only limit - // here is the memory needed for creating a new sem_undo structure. - // Implemented after sUndoListLock is declared - int RecordUndo(int semaphoreSetID, short semaphoreNumber, short value); - - // Implemented after sUndoListLock is declared - void RemoveUndo(int semaphoreSetID, short semaphoreNumber, short value); - void Revert(short value) { fValue -= value; @@ -202,7 +209,6 @@ fThreadsWaitingToIncrease--; } } - return result; } @@ -248,6 +254,7 @@ fNumberOfSemaphores(numberOfSemaphores), fSemaphores(0) { + mutex_init(&fLock, "XsiSemaphoreSet private mutex"); SetIpcKey((key_t)-1); SetPermissions(flags); fSemaphores = new(std::nothrow) XsiSemaphore[numberOfSemaphores]; @@ -260,15 +267,49 @@ ~XsiSemaphoreSet() { - TRACE(("XsiSemaphoreSet::~XsiSemaphoreSet(): removing semaphore set\n")); - // Clear all sem_undo left, as our ID will be reused - // by another set. - for (uint32 i = 0; i < fNumberOfSemaphores; i++) - fSemaphores[i].ClearUndos(fID, i); + TRACE(("XsiSemaphoreSet::~XsiSemaphoreSet(): removing semaphore " + "set %d\n", fID)); + mutex_destroy(&fLock); UnsetID(); - delete []fSemaphores; + delete[] fSemaphores; } + void ClearUndo(unsigned short semaphoreNumber) + { + struct team *team = thread_get_current_thread()->team; + UndoList::Iterator iterator = fUndoList.GetIterator(); + while (iterator.HasNext()) { + struct sem_undo *current = iterator.Next(); + if (current->team == team) { + TRACE(("XsiSemaphoreSet::ClearUndo: teamID = %d, " + "semaphoreSetID = %d, semaphoreNumber = %d\n", + fID, semaphoreNumber, (int)team->id)); + MutexLocker _(team->xsi_sem_context->lock); + current->undo_values[semaphoreNumber] = 0; + return; + } + } + } + + void ClearUndos() + { + // Clear all undo_values (POSIX semadj equivalent) + // of the calling team. This happens only on semctl SETALL. + struct team *team = thread_get_current_thread()->team; + DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); + while (iterator.HasNext()) { + struct sem_undo *current = iterator.Next(); + if (current->team == team) { + TRACE(("XsiSemaphoreSet::ClearUndos: teamID = %d, " + "semaphoreSetID = %d\n", (int)team->id, fID)); + MutexLocker _(team->xsi_sem_context->lock); + memset(current->undo_values, 0, + sizeof(int16) * fNumberOfSemaphores); + return; + } + } + } + void DoIpcSet(struct semid_ds *result) { fPermissions.uid = result->sem_perm.uid; @@ -330,11 +371,108 @@ return fLastSemopTime; } + mutex &Lock() + { + return fLock; + } + ushort NumberOfSemaphores() const { return fNumberOfSemaphores; } + // Record the sem_undo operation into our private fUndoList and + // the team undo_list. The only limit here is the memory needed + // for creating a new sem_undo structure. + int RecordUndo(short semaphoreNumber, short value) + { + // Look if there is already a record from the team caller + // for the same semaphore set + bool notFound = true; + struct team *team = thread_get_current_thread()->team; + DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); + while (iterator.HasNext()) { + struct sem_undo *current = iterator.Next(); + if (current->team == team) { + // Update its undo value + MutexLocker _(team->xsi_sem_context->lock); + int newValue = current->undo_values[semaphoreNumber] + value; + if (newValue > USHRT_MAX || newValue < -USHRT_MAX) { + TRACE_ERROR(("XsiSemaphoreSet::RecordUndo: newValue %d " + "out of range\n", newValue)); + return ERANGE; + } + current->undo_values[semaphoreNumber] = newValue; + notFound = false; + TRACE(("XsiSemaphoreSet::RecordUndo: found record. Team = %d, " + "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", + (int)team->id, fID, semaphoreNumber, + current->undo_values[semaphoreNumber])); + break; + } + } + + if (notFound) { + // First sem_undo request from this team for this + // semaphore set + int16 *undoValues + = (int16 *)malloc(sizeof(int16) * fNumberOfSemaphores); + if (undoValues == NULL) + return B_NO_MEMORY; + struct sem_undo *request + = new(std::nothrow) sem_undo(this, team, undoValues); + if (request == NULL) { + free(undoValues); + return B_NO_MEMORY; + } + memset(request->undo_values, 0, sizeof(int16) * fNumberOfSemaphores); + request->undo_values[semaphoreNumber] = value; + + // Check if it's the very first sem_undo request for this team + xsi_sem_context *context = atomic_pointer_get(&team->xsi_sem_context); + if (context == NULL) { + // Create the context + context = new(std::nothrow) xsi_sem_context; + if (context == NULL) { + free(request->undo_values); + delete request; + return B_NO_MEMORY; + } + // Since we don't hold any global lock, someone + // else could have been quicker than us, so we have + // to delete the one we just created and use the one + // in place. + if (atomic_pointer_test_and_set(&team->xsi_sem_context, context, + (xsi_sem_context *)NULL) != NULL) + delete context; + } + + // Add the request to both XsiSemaphoreSet and team list + fUndoList.Add(request); + MutexLocker _(team->xsi_sem_context->lock); + team->xsi_sem_context->undo_list.Add(request); + TRACE(("XsiSemaphoreSet::RecordUndo: new record added. Team = %d, " + "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", + (int)team->id, fID, semaphoreNumber, value)); + } + return B_OK; + } + + void RevertUndo(short semaphoreNumber, short value) + { + // This can be called only when RecordUndo fails. + struct team *team = thread_get_current_thread()->team; + DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); + while (iterator.HasNext()) { + struct sem_undo *current = iterator.Next(); + if (current->team == team) { + MutexLocker _(team->xsi_sem_context->lock); + fSemaphores[semaphoreNumber].Revert(value); + break; + } + } + } + XsiSemaphore* Semaphore(int nth) const { return &fSemaphores[nth]; @@ -365,6 +503,11 @@ fPermissions.mode = (flags & 0x01ff); } + UndoList &GetUndoList() + { + return fUndoList; + } + // Implemented after sSemaphoreHashTable is declared void UnsetID(); @@ -380,7 +523,9 @@ time_t fLastSemopTime; // sem_otime ushort fNumberOfSemaphores; // sem_nsems struct ipc_perm fPermissions; // sem_perm - XsiSemaphore *fSemaphores; + XsiSemaphore *fSemaphores; // array of semaphores + UndoList fUndoList; // undo list requests + mutex fLock; // private lock ::HashTableLink fLink; }; @@ -484,130 +629,14 @@ #define MAX_XSI_SEMAPHORE 512 static OpenHashTable sIpcHashTable; static OpenHashTable sSemaphoreHashTable; -static SemaphoreUndoList sUndoList; static mutex sIpcLock; static mutex sXsiSemaphoreSetLock; -static mutex sUndoListLock; static vint32 sNextAvailableID = 1; static vint32 sXsiSemaphoreCount = 0; -void -XsiSemaphore::ClearUndos(int semaphoreSetID, short semaphoreNumber) -{ - // Clear all undo_value (Posix semadj equivalent), - // which result in removing the sem_undo record from - // the global undo list, plus decrementing the related - // team xsi_sem_undo_requests field. - // This happens only on semctl SETVAL and SETALL. - TRACE(("XsiSemaphore::ClearUndos: semaphoreSetID = %d, " - "semaphoreNumber = %d\n", semaphoreSetID, semaphoreNumber)); - MutexLocker _(sUndoListLock); - DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); - while (iterator.HasNext()) { - struct sem_undo *current = iterator.Next(); - if (current->semaphore_set_id == semaphoreSetID - && current->semaphore_number == semaphoreNumber) { - InterruptsSpinLocker lock(gTeamSpinlock); - if (current->team) - current->team->xsi_sem_undo_requests--; - iterator.Remove(); - // Restore interrupts before calling free - lock.Unlock(); - free(current); - } - } -} - - -int -XsiSemaphore::RecordUndo(int semaphoreSetID, short semaphoreNumber, short value) -{ - // Look if there is already a record from the same - // team for the same semaphore set && semaphore number - bool notFound = true; - struct team *team = thread_get_current_thread()->team; - MutexLocker _(sUndoListLock); - DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); - while (iterator.HasNext()) { - struct sem_undo *current = iterator.Next(); - if (current->team == team - && current->semaphore_set_id == semaphoreSetID - && current->semaphore_number == semaphoreNumber) { - // Update its undo value - TRACE(("XsiSemaphore::RecordUndo: found record. Team = %d, " - "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", - (int)team->id, semaphoreSetID, semaphoreNumber, - current->undo_value)); - int newValue = current->undo_value + value; - if (newValue > USHRT_MAX || newValue < -USHRT_MAX) { - TRACE_ERROR(("XsiSemaphore::RecordUndo: newValue %d out of range\n", - newValue)); - return ERANGE; - } - current->undo_value = newValue; - notFound = false; - break; - } - } - - if (notFound) { - // First sem_undo request from this team for this - // semaphore set && semaphore number - struct sem_undo *request - = (struct sem_undo *)malloc(sizeof(struct sem_undo)); - if (request == NULL) - return B_NO_MEMORY; - request->team = team; - request->semaphore_set_id = semaphoreSetID; - request->semaphore_number = semaphoreNumber; - request->undo_value = value; - // Add the request to the global sem_undo list - InterruptsSpinLocker _(gTeamSpinlock); - if ((int)(team->xsi_sem_undo_requests + 1) < USHRT_MAX) - team->xsi_sem_undo_requests++; - else - return ENOSPC; - sUndoList.Add(request); - TRACE(("XsiSemaphore::RecordUndo: new record added. Team = %d, " - "semaphoreSetID = %d, semaphoreNumber = %d, value = %d\n", - (int)team->id, semaphoreSetID, semaphoreNumber, - request->undo_value)); - } - return B_OK; -} - - -void -XsiSemaphore::RemoveUndo(int semaphoreSetID, short semaphoreNumber, short value) -{ - // This can be called only when RecordUndo fails. - MutexLocker _(sUndoListLock); - DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); - while (iterator.HasNext()) { - struct sem_undo *current = iterator.Next(); - if (current->semaphore_set_id == semaphoreSetID - && current->semaphore_number == semaphoreNumber) { - current->undo_value -= value; - // Remove the request from sUndoList only if - // it happens to be the only one made by this - // process, that is, don't remove any valide - // sem_undo request made previously by the same - // process - if (current->undo_value == 0) { - InterruptsSpinLocker _(gTeamSpinlock); - if (current->team) - current->team->xsi_sem_undo_requests--; - iterator.Remove(); - free(current); - } - } - } -} - - // #pragma mark - @@ -647,50 +676,48 @@ mutex_init(&sIpcLock, "global Posix IPC table"); mutex_init(&sXsiSemaphoreSetLock, "global Posix xsi sem table"); - mutex_init(&sUndoListLock, "global Posix xsi sem undo list"); } -/*! Function called on team exit when there are sem_undo requests */ +/*! Function called on team exit to process any sem_undo requests */ void -xsi_sem_undo(team_id teamID, int32 numberOfUndos) +xsi_sem_undo(struct team *team) { - if (numberOfUndos <= 0) + if (team->xsi_sem_context == NULL) return; - // We must hold the set mutex before the sem_undo - // one in order to avoid deadlock with RecordUndo - MutexLocker lock(sXsiSemaphoreSetLock); - MutexLocker _(sUndoListLock); - DoublyLinkedList::Iterator iterator = sUndoList.GetIterator(); - // Look for all sem_undo request from this team + // By acquiring first the semaphore hash table lock + // we make sure the semaphore set in our sem_undo + // list won't get removed by IPC_RMID call + MutexLocker _(sXsiSemaphoreSetLock); + + // Process all sem_undo request in the team sem undo list + // if any + TeamList::Iterator iterator + = team->xsi_sem_context->undo_list.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); - if (current->team->id == teamID) { - // Check whether the semaphore set still exist - int semaphoreSetID = current->semaphore_set_id; - XsiSemaphoreSet *semaphoreSet - = sSemaphoreHashTable.Lookup(semaphoreSetID); - if (semaphoreSet != NULL) { - // Revert the changes done by this process - XsiSemaphore *semaphore - = semaphoreSet->Semaphore(current->semaphore_number); + XsiSemaphoreSet *semaphoreSet = current->semaphore_set; + // Acquire the set lock in order to prevent race + // condition with RecordUndo + MutexLocker setLocker(semaphoreSet->Lock()); + MutexLocker _(team->xsi_sem_context->lock); + // Revert the changes done by this process + for (int i = 0; i < semaphoreSet->NumberOfSemaphores(); i++) + if (current->undo_values[i] != 0) { TRACE(("xsi_sem_undo: TeamID = %d, SemaphoreSetID = %d, " - "SemaphoreNumber = %d, undo value = %d\n", (int)teamID, - semaphoreSetID, current->semaphore_number, - current->undo_value)); - semaphore->Revert(current->undo_value); - } else - TRACE(("xsi_sem_undo: semaphore set %d does not exist " - "anymore. Ignore record.\n", semaphoreSetID)); + "SemaphoreNumber = %d, undo value = %d\n", (int)team->id, + semaphoreSet->ID(), i, (int)current->undo_values[i])); + semaphoreSet->Semaphore(i)->Revert(current->undo_values[i]); + } - // Remove and free the sem_undo structure from sUndoList - iterator.Remove(); - free(current); - if (--numberOfUndos == 0) - break; - } + // Remove and free the sem_undo structure from both lists + iterator.Remove(); + semaphoreSet->GetUndoList().Remove(current); + delete current; } + delete team->xsi_sem_context; + team->xsi_sem_context = NULL; } @@ -776,16 +803,15 @@ "semaphores allowed\n")); return ENOSPC; } - atomic_add(&sXsiSemaphoreCount, 1); semaphoreSet = new(std::nothrow) XsiSemaphoreSet(numberOfSemaphores, flags); if (semaphoreSet == NULL || !semaphoreSet->InitOK()) { TRACE_ERROR(("xsi_semget: failed to allocate a new xsi " "semaphore set\n")); - atomic_add(&sXsiSemaphoreCount, -1); return ENOMEM; } + atomic_add(&sXsiSemaphoreCount, numberOfSemaphores); MutexLocker _(sXsiSemaphoreSetLock); semaphoreSet->SetID(); @@ -808,7 +834,8 @@ { TRACE(("xsi_semctl: semaphoreID = %d, semaphoreNumber = %d, command = %d\n", semaphoreID, semaphoreNumber, command)); - MutexLocker _(sXsiSemaphoreSetLock); + MutexLocker ipcHashLocker(sIpcLock); + MutexLocker setHashLocker(sXsiSemaphoreSetLock); XsiSemaphoreSet *semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreID); if (semaphoreSet == NULL) { TRACE_ERROR(("xsi_semctl: semaphore set id %d not valid\n", @@ -821,89 +848,110 @@ "semaphore %d\n", semaphoreNumber, semaphoreID)); return EINVAL; } - if (args != 0 && !IS_USER_ADDRESS(args)) { TRACE_ERROR(("xsi_semctl: semun address is not valid\n")); return B_BAD_ADDRESS; } + // Lock the semaphore set itself and release both the semaphore + // set hash table lock and the ipc hash table lock _only_ if + // the command it's not IPC_RMID, this prevents undesidered + // situation from happening while (hopefully) improving the + // concurrency. + MutexLocker setLocker; + if (command != IPC_RMID) { + setLocker.SetTo(&semaphoreSet->Lock(), false); + setHashLocker.Unlock(); + ipcHashLocker.Unlock(); + } + + int result = 0; XsiSemaphore *semaphore = semaphoreSet->Semaphore(semaphoreNumber); switch (command) { - case GETVAL: + case GETVAL: { if (!semaphoreSet->HasReadPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - return semaphore->Value(); + result = EACCES; + } else + result = semaphore->Value(); + break; + } - case SETVAL: + case SETVAL: { if (!semaphoreSet->HasPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; + result = EACCES; + } else { + int value; + if (user_memcpy(&value, &args->val, sizeof(int)) < B_OK) { + TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); + result = B_BAD_ADDRESS; + } else if (value > USHRT_MAX) { + TRACE_ERROR(("xsi_semctl: value %d out of range\n", value)); + result = ERANGE; + } else { + semaphore->SetValue(value); + semaphoreSet->ClearUndo(semaphoreNumber); + } } - int value; - if (user_memcpy(&value, &args->val, sizeof(int)) < B_OK) { - TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); - return B_BAD_ADDRESS; - } - if (value > USHRT_MAX) { - TRACE_ERROR(("xsi_semctl: value %d out of range\n", value)); - return ERANGE; - } - TRACE(("xsi_semctl: SemaphoreNumber = %d, SETVAL value = %d\n", - semaphoreNumber, value)); - semaphore->SetValue(value); - semaphore->ClearUndos(semaphoreSet->ID(), semaphoreNumber); - return 0; + break; + } - case GETPID: + case GETPID: { if (!semaphoreSet->HasReadPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - return semaphore->LastPid(); + result = EACCES; + } else + result = semaphore->LastPid(); + break; + } - case GETNCNT: + case GETNCNT: { if (!semaphoreSet->HasReadPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - return semaphore->ThreadsWaitingToIncrease(); + result = EACCES; + } else + result = semaphore->ThreadsWaitingToIncrease(); + break; + } - case GETZCNT: + case GETZCNT: { if (!semaphoreSet->HasReadPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - return semaphore->ThreadsWaitingToBeZero(); + result = EACCES; + } else + result = semaphore->ThreadsWaitingToBeZero(); + break; + } case GETALL: { if (!semaphoreSet->HasReadPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not read " "permission on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - for (int i = 0; i < semaphoreSet->NumberOfSemaphores(); i++) { - semaphore = semaphoreSet->Semaphore(i); - unsigned short value = semaphore->Value(); - if (user_memcpy(&args->array[i], &value, sizeof(unsigned short)) - < B_OK) { - TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); - return B_BAD_ADDRESS; + result = EACCES; + } else + for (int i = 0; i < semaphoreSet->NumberOfSemaphores(); i++) { + semaphore = semaphoreSet->Semaphore(i); + unsigned short value = semaphore->Value(); + if (user_memcpy(&args->array[i], &value, + sizeof(unsigned short)) < B_OK) { + TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); + result = B_BAD_ADDRESS; + break; + } } - } - return 0; + break; } case SETALL: { @@ -911,20 +959,25 @@ TRACE_ERROR(("xsi_semctl: calling process has not permission " "on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; - } - for (int i = 0; i < semaphoreSet->NumberOfSemaphores(); i++) { - semaphore = semaphoreSet->Semaphore(i); - unsigned short value; - if (user_memcpy(&value, &args->array[i], sizeof(unsigned short)) - < B_OK) { - TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); - return B_BAD_ADDRESS; + result = EACCES; + } else { + bool doClear = true; + for (int i = 0; i < semaphoreSet->NumberOfSemaphores(); i++) { + semaphore = semaphoreSet->Semaphore(i); + unsigned short value; + if (user_memcpy(&value, &args->array[i], sizeof(unsigned short)) + < B_OK) { + TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); + result = B_BAD_ADDRESS; + doClear = false; + break; + } else + semaphore->SetValue(value); } - semaphore->SetValue(value); - semaphore->ClearUndos(semaphoreSet->ID(), semaphoreNumber); + if (doClear) + semaphoreSet->ClearUndos(); } - return 0; + break; } case IPC_STAT: { @@ -932,19 +985,20 @@ TRACE_ERROR(("xsi_semctl: calling process has not read " "permission on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; + result = EACCES; + } else { + struct semid_ds sem; + sem.sem_perm = semaphoreSet->IpcPermission(); + sem.sem_nsems = semaphoreSet->NumberOfSemaphores(); + sem.sem_otime = semaphoreSet->LastSemopTime(); + sem.sem_ctime = semaphoreSet->LastSemctlTime(); + if (user_memcpy(args->buf, &sem, sizeof(struct semid_ds)) + < B_OK) { + TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); + result = B_BAD_ADDRESS; + } } - struct semid_ds result; - result.sem_perm = semaphoreSet->IpcPermission(); - result.sem_nsems = semaphoreSet->NumberOfSemaphores(); - result.sem_otime = semaphoreSet->LastSemopTime(); - result.sem_ctime = semaphoreSet->LastSemctlTime(); - if (user_memcpy(args->buf, &result, sizeof(struct semid_ds)) - < B_OK) { - TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); - return B_BAD_ADDRESS; - } - return 0; + break; } case IPC_SET: { @@ -952,19 +1006,24 @@ TRACE_ERROR(("xsi_semctl: calling process has not " "permission on semaphore %d, key %d\n", semaphoreSet->ID(), (int)semaphoreSet->IpcKey())); - return EACCES; + result = EACCES; + } else { + struct semid_ds sem; + if (user_memcpy(&sem, args->buf, sizeof(struct semid_ds)) + < B_OK) { + TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); + result = B_BAD_ADDRESS; + } else + semaphoreSet->DoIpcSet(&sem); } - struct semid_ds result; - if (user_memcpy(&result, args->buf, sizeof(struct semid_ds)) - < B_OK) { - TRACE_ERROR(("xsi_semctl: user_memcpy failed\n")); - return B_BAD_ADDRESS; - } - semaphoreSet->DoIpcSet(&result); - return 0; + break; } case IPC_RMID: { + // If this was the command, we are still holding + // the semaphore set hash table lock along with the + // ipc hash table lock, but not the semaphore set + // itself lock as it would be useless in this case if (!semaphoreSet->HasPermission()) { TRACE_ERROR(("xsi_semctl: calling process has not " "permission on semaphore %d, key %d\n", @@ -974,25 +1033,33 @@ key_t key = semaphoreSet->IpcKey(); Ipc *ipcKey = NULL; if (key != -1) { - MutexLocker _(sIpcLock); ipcKey = sIpcHashTable.Lookup(key); sIpcHashTable.Remove(ipcKey); } sSemaphoreHashTable.Remove(semaphoreSet); - atomic_add(&sXsiSemaphoreCount, - semaphoreSet->NumberOfSemaphores()); // Wake up of threads waiting on this set // happens in the destructor if (key != -1) delete ipcKey; + atomic_add(&sXsiSemaphoreCount, -semaphoreSet->NumberOfSemaphores()); + // Remove any sem_undo request + while (struct sem_undo *entry + = semaphoreSet->GetUndoList().RemoveHead()) { + MutexLocker _(entry->team->xsi_sem_context->lock); + entry->team->xsi_sem_context->undo_list.Remove(entry); + delete entry; + } + delete semaphoreSet; return 0; } default: TRACE_ERROR(("xsi_semctl: command %d not valid\n", command)); - return EINVAL; + result = EINVAL; } + + return result; } @@ -1001,13 +1068,15 @@ { TRACE(("xsi_semop: semaphoreID = %d, ops = %p, numOps = %ld\n", semaphoreID, ops, numOps)); - MutexLocker lock(sXsiSemaphoreSetLock); + MutexLocker setHashLocker(sXsiSemaphoreSetLock); XsiSemaphoreSet *semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreID); if (semaphoreSet == NULL) { TRACE_ERROR(("xsi_semop: semaphore set id %d not valid\n", semaphoreID)); return EINVAL; } + MutexLocker setLocker(semaphoreSet->Lock()); + setHashLocker.Unlock(); if (!IS_USER_ADDRESS(ops)) { TRACE_ERROR(("xsi_semop: sembuf address is not valid\n")); @@ -1101,19 +1170,23 @@ if (operations[i].sem_op != 0) waitOnZero = false; - lock.Unlock(); + setLocker.Unlock(); result = semaphore->Wait((int32)operations[i].sem_op, waitOnZero); TRACE(("xsi_semop: back to life\n")); // We are back to life. // Find out why! - lock.Lock(); + setHashLocker.Lock(); semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreID); - if (result == EIDRM || result == B_INTERRUPTED) { + if (result == EIDRM || result == B_INTERRUPTED + || semaphoreSet == NULL) { TRACE_ERROR(("xsi_semop: semaphore set id %d got destroyed\n", semaphoreID)); result = EIDRM; notDone = false; + } else { + setLocker.Lock(); + setHashLocker.Unlock(); } } else { // everything worked like a charm (so far) @@ -1128,8 +1201,8 @@ semaphore = semaphoreSet->Semaphore(semaphoreNumber); short operation = operations[i].sem_op; if (operations[i].sem_flg & SEM_UNDO) - if (semaphore->RecordUndo(semaphoreSet->ID(), - semaphoreNumber, operation) != B_OK) { + if (semaphoreSet->RecordUndo(semaphoreNumber, operation) + != B_OK) { // Unlikely scenario, but we might get here. // Undo everything! // Start with semaphore operations @@ -1143,8 +1216,8 @@ // Remove all previously registered sem_undo request for (uint32 j = 0; j < i; j++) { if (operations[j].sem_flg & SEM_UNDO) - semaphore->RemoveUndo(semaphoreSet->ID(), - operations[j].sem_num, operations[j].sem_op); + semaphoreSet->RevertUndo(operations[j].sem_num, + operations[j].sem_op); } result = ENOSPC; } Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2008-08-16 18:06:52 UTC (rev 26992) +++ haiku/trunk/src/system/kernel/team.cpp 2008-08-16 18:20:54 UTC (rev 26993) @@ -703,7 +703,7 @@ team->io_context = NULL; team->address_space = NULL; team->realtime_sem_context = NULL; - team->xsi_sem_undo_requests = 0; + team->xsi_sem_context = NULL; team->thread_list = NULL; team->main_thread = NULL; team->loading_info = NULL; @@ -1327,7 +1327,7 @@ delete_team_user_data(team); vm_delete_areas(team->address_space); - xsi_sem_undo(team->id, team->xsi_sem_undo_requests); + xsi_sem_undo(team); delete_owned_ports(team->id); sem_delete_owned_sems(team->id); remove_images(team); @@ -2353,7 +2353,7 @@ vfs_free_io_context(team->io_context); delete_realtime_sem_context(team->realtime_sem_context); - xsi_sem_undo(team->id, team->xsi_sem_undo_requests); + xsi_sem_undo(team); delete_owned_ports(teamID); sem_delete_owned_sems(teamID); remove_images(team); From mmlr at mail.berlios.de Fri Aug 15 22:55:08 2008 From: mmlr at mail.berlios.de (mmlr at mail.berlios.de) Date: Fri, 15 Aug 2008 22:55:08 +0200 Subject: [Haiku-commits] r26984 - haiku/trunk/src/kits/app Message-ID: <200808152055.m7FKt8gZ015217@sheep.berlios.de> Author: mmlr Date: 2008-08-15 22:55:06 +0200 (Fri, 15 Aug 2008) New Revision: 26984 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26984&view=rev Modified: haiku/trunk/src/kits/app/Message.cpp Log: Obviously noone ever really used BFlattenable objects with our BMessage, as it was pretty broken. It would store the address of the buffer in the message instead of the actual data. Funnily, since it was completely stack based before, it would have stored the address plus the actual data (minus 4 bytes) as that did reside directly after the address on the stack and the original buffer length was still used. This corrupted the data, but still "worked" for MDR because it has fault tolerance, loosing only part of its flattened StringList. This broke however when switching to a heap allocated buffer for large sizes, as then the heap address plus some random heap data was added to the message instead of the actual buffer. Sure interesting that nobody noticed that before... Modified: haiku/trunk/src/kits/app/Message.cpp =================================================================== --- haiku/trunk/src/kits/app/Message.cpp 2008-08-15 19:08:48 UTC (rev 26983) +++ haiku/trunk/src/kits/app/Message.cpp 2008-08-15 20:55:06 UTC (rev 26984) @@ -2405,7 +2405,7 @@ status_t error = object->Flatten(buffer, size); if (error >= B_OK) - error = AddData(name, object->TypeCode(), &buffer, size, false); + error = AddData(name, object->TypeCode(), buffer, size, false); if (buffer != stackBuffer) free(buffer); From axeld at mail.berlios.de Fri Aug 15 13:47:28 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 15 Aug 2008 13:47:28 +0200 Subject: [Haiku-commits] r26978 - in haiku/trunk/src/preferences: media screen Message-ID: <200808151147.m7FBlSs5007772@sheep.berlios.de> Author: axeld Date: 2008-08-15 13:47:28 +0200 (Fri, 15 Aug 2008) New Revision: 26978 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26978&view=rev Modified: haiku/trunk/src/preferences/media/Jamfile haiku/trunk/src/preferences/media/MediaAlert.cpp haiku/trunk/src/preferences/screen/AlertView.cpp haiku/trunk/src/preferences/screen/Jamfile Log: * Applied patch by Marten Svanfeldt: the info alert icon was missing, as it's now a vector resource. * Changed bitmap icon to B_RGBA32 instead of B_CMAP8, use B_OP_ALPHA for drawing the bitmap. * Style cleanup in the MediaAlert.cpp. Modified: haiku/trunk/src/preferences/media/Jamfile =================================================================== --- haiku/trunk/src/preferences/media/Jamfile 2008-08-15 11:00:07 UTC (rev 26977) +++ haiku/trunk/src/preferences/media/Jamfile 2008-08-15 11:47:28 UTC (rev 26978) @@ -6,6 +6,7 @@ SubDirC++Flags -fmultiple-symbol-spaces ; } +UseLibraryHeaders icon ; UsePrivateHeaders media ; Preference Media : Modified: haiku/trunk/src/preferences/media/MediaAlert.cpp =================================================================== --- haiku/trunk/src/preferences/media/MediaAlert.cpp 2008-08-15 11:00:07 UTC (rev 26977) +++ haiku/trunk/src/preferences/media/MediaAlert.cpp 2008-08-15 11:47:28 UTC (rev 26978) @@ -1,188 +1,161 @@ -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -// -// Copyright (c) 2003, OpenBeOS -// -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// -// File: MediaAlert.cpp -// Author: J?r?me Duval -// Description: Media Preferences -// Created : June 25, 2003 -// -// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +/* + * Copyright 2003-2008 Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * J?r?me Duval + */ +#include "MediaAlert.h" -// Standard Includes ----------------------------------------------------------- #include -// System Includes ------------------------------------------------------------- -#include "MediaAlert.h" -#include -#include - #include #include +#include #include #include +#include +#include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- +const int kWindowIconOffset = 27; +const int kIconStripeWidth = 30; +const int kTextIconOffset = kWindowIconOffset + kIconStripeWidth - 2; +const int kTextTopOffset = 6; -// Local Defines --------------------------------------------------------------- +class TAlertView : public BView { +public: + TAlertView(BRect frame); + TAlertView(BMessage* archive); + ~TAlertView(); -// Globals --------------------------------------------------------------------- + virtual void Draw(BRect updateRect); -const int kWindowIconOffset = 27; -const int kIconStripeWidth = 30; -const int kTextIconOffset = kWindowIconOffset + kIconStripeWidth - 2; -const int kTextTopOffset = 6; + void SetBitmap(BBitmap* Icon) { fIconBitmap = Icon; } + BBitmap* Bitmap() { return fIconBitmap; } -//------------------------------------------------------------------------------ -class TAlertView : public BView -{ - public: - TAlertView(BRect frame); - TAlertView(BMessage* archive); - ~TAlertView(); - - virtual void Draw(BRect updateRect); - - void SetBitmap(BBitmap* Icon) { fIconBitmap = Icon; } - BBitmap* Bitmap() { return fIconBitmap; } - - private: - BBitmap* fIconBitmap; +private: + BBitmap* fIconBitmap; }; -//------------------------------------------------------------------------------ + MediaAlert::MediaAlert(BRect _rect, const char* title, const char* text) - : BWindow(_rect, title, B_MODAL_WINDOW, - B_NOT_CLOSABLE | B_NOT_RESIZABLE) + : BWindow(_rect, title, B_MODAL_WINDOW, B_NOT_CLOSABLE | B_NOT_RESIZABLE) { fTextView = NULL; - + // Set up the "_master_" view - TAlertView* MasterView = new TAlertView(Bounds()); - MasterView->SetBitmap(InitIcon()); - AddChild(MasterView); - + TAlertView* masterView = new TAlertView(Bounds()); + masterView->SetBitmap(InitIcon()); + AddChild(masterView); + // Set up the text view - BRect TextViewRect(kTextIconOffset, kTextTopOffset, + BRect textViewRect(kTextIconOffset, kTextTopOffset, Bounds().right, Bounds().bottom); - BRect rect = TextViewRect; + BRect rect = textViewRect; rect.OffsetTo(B_ORIGIN); - rect.InsetBy(4,2); - fTextView = new BTextView(TextViewRect, "_tv_", - rect, - B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + rect.InsetBy(4, 2); + + fTextView = new BTextView(textViewRect, "_tv_", rect, + B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTextView->SetText(text, strlen(text)); fTextView->MakeEditable(false); fTextView->MakeSelectable(false); fTextView->SetWordWrap(true); - fTextView->SetFontAndColor(be_bold_font); - MasterView->AddChild(fTextView); - - BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame()); - BPoint pt; - pt.x = screenFrame.Width()/2 - Bounds().Width()/2; - pt.y = screenFrame.Height()/2 - Bounds().Height()/2; + masterView->AddChild(fTextView); + BRect screenFrame = BScreen(B_MAIN_SCREEN_ID).Frame(); + BPoint pt; + pt.x = screenFrame.Width() / 2 - Bounds().Width() / 2; + pt.y = screenFrame.Height() / 2 - Bounds().Height() / 2; + if (screenFrame.Contains(pt)) MoveTo(pt); } -//------------------------------------------------------------------------------ + MediaAlert::~MediaAlert() { - } -//------------------------------------------------------------------------------ -BTextView* MediaAlert::TextView() const + +BTextView* +MediaAlert::TextView() const { return fTextView; } -//------------------------------------------------------------------------------ -BBitmap* MediaAlert::InitIcon() + +BBitmap* +MediaAlert::InitIcon() { - // After a bit of a search, I found the icons in app_server. =P - BBitmap* Icon = NULL; - BPath Path; - if (find_directory(B_BEOS_SERVERS_DIRECTORY, &Path) == B_OK) - { - Path.Append("app_server"); - BFile File; - if (File.SetTo(Path.Path(), B_READ_ONLY) == B_OK) - { - BResources Resources; - if (Resources.SetTo(&File) == B_OK) - { + // The alert icons are in the app_server resources + BBitmap* icon = NULL; + BPath path; + if (find_directory(B_BEOS_SERVERS_DIRECTORY, &path) == B_OK) { + path.Append("app_server"); + BFile file; + if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK) { + BResources resources; + if (resources.SetTo(&file) == B_OK) { // Which icon are we trying to load? const char* iconName = "warn"; - + // Load the raw icon data size_t size; const void* rawIcon = - Resources.LoadResource(B_LARGE_ICON_TYPE, iconName, &size); + resources.LoadResource(B_VECTOR_ICON_TYPE, iconName, &size); - if (rawIcon) - { + if (rawIcon != NULL) { // Now build the bitmap - Icon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); - Icon->SetBits(rawIcon, size, 0, B_CMAP8); + icon = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32); + if (BIconUtils::GetVectorIcon((const uint8*)rawIcon, size, + icon) != B_OK) { + delete icon; + return NULL; + } } } } } - return Icon; + return icon; } -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -// #pragma mark - -// #pragma mark TAlertView -// #pragma mark - -//------------------------------------------------------------------------------ +// #pragma mark - TAlertView + + TAlertView::TAlertView(BRect frame) - : BView(frame, "TAlertView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), - fIconBitmap(NULL) + : BView(frame, "TAlertView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), + fIconBitmap(NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } -//------------------------------------------------------------------------------ + + TAlertView::~TAlertView() { - if (fIconBitmap) - { - delete fIconBitmap; - } + delete fIconBitmap; } -//------------------------------------------------------------------------------ -void TAlertView::Draw(BRect updateRect) + + +void +TAlertView::Draw(BRect updateRect) { // Here's the fun stuff - if (fIconBitmap) - { - BRect StripeRect = Bounds(); - StripeRect.right = kIconStripeWidth; + if (fIconBitmap) { + BRect stripeRect = Bounds(); + stripeRect.right = kIconStripeWidth; SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); - FillRect(StripeRect); + FillRect(stripeRect); - SetDrawingMode(B_OP_OVER); + SetDrawingMode(B_OP_ALPHA); DrawBitmapAsync(fIconBitmap, BPoint(18, 6)); SetDrawingMode(B_OP_COPY); } } -//------------------------------------------------------------------------------ - - - Modified: haiku/trunk/src/preferences/screen/AlertView.cpp =================================================================== --- haiku/trunk/src/preferences/screen/AlertView.cpp 2008-08-15 11:00:07 UTC (rev 26977) +++ haiku/trunk/src/preferences/screen/AlertView.cpp 2008-08-15 11:47:28 UTC (rev 26978) @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -64,7 +65,8 @@ if (width < Bounds().Width()) width = Bounds().Width(); - float height = fCountdownView->Frame().bottom + 24 + button->Bounds().Height(); + float height + = fCountdownView->Frame().bottom + 24 + button->Bounds().Height(); ResizeTo(width, height); keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(), @@ -79,7 +81,8 @@ void AlertView::AttachedToWindow() { - // the view displays a decrementing counter (until the user must take action) + // the view displays a decrementing counter + // (until the user must take action) Window()->SetPulseRate(1000000); // every second @@ -90,7 +93,8 @@ void AlertView::Draw(BRect updateRect) { - rgb_color dark = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT); + rgb_color dark = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), + B_DARKEN_1_TINT); SetHighColor(dark); FillRect(BRect(0.0, 0.0, 30.0, Bounds().bottom)); @@ -121,7 +125,7 @@ } -void +void AlertView::UpdateCountdownView() { BString string; @@ -142,13 +146,16 @@ BFile file; if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK && resources.SetTo(&file) == B_OK) { - // Load the raw icon data size_t size; - const void* data = resources.LoadResource(B_LARGE_ICON_TYPE, "warn", &size); + const void* data = resources.LoadResource(B_VECTOR_ICON_TYPE, + "warn", &size); if (data) { - // Now build the bitmap - icon = new BBitmap(BRect(0, 0, 31, 31), 0, B_CMAP8); - icon->SetBits(data, size, 0, B_CMAP8); + icon = new BBitmap(BRect(0, 0, 31, 31), 0, B_RGBA32); + if (BIconUtils::GetVectorIcon((const uint8*)data, size, icon) + != B_OK) { + delete icon; + icon = NULL; + } } } } Modified: haiku/trunk/src/preferences/screen/Jamfile =================================================================== --- haiku/trunk/src/preferences/screen/Jamfile 2008-08-15 11:00:07 UTC (rev 26977) +++ haiku/trunk/src/preferences/screen/Jamfile 2008-08-15 11:47:28 UTC (rev 26978) @@ -3,6 +3,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; AddSubDirSupportedPlatforms libbe_test ; +UseLibraryHeaders icon ; UsePrivateHeaders [ FDirName graphics radeon ] ; Preference Screen : From mauricek at mail.berlios.de Sun Aug 17 15:20:45 2008 From: mauricek at mail.berlios.de (mauricek at BerliOS) Date: Sun, 17 Aug 2008 15:20:45 +0200 Subject: [Haiku-commits] r27002 - haiku/trunk/src/kits/storage Message-ID: <200808171320.m7HDKjbl012133@sheep.berlios.de> Author: mauricek Date: 2008-08-17 15:20:45 +0200 (Sun, 17 Aug 2008) New Revision: 27002 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27002&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: fix gcc4 build Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 11:27:07 UTC (rev 27001) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-17 13:20:45 UTC (rev 27002) @@ -16,6 +16,7 @@ #include #include #include +#include #include #include From marcusoverhagen at arcor.de Sun Aug 17 18:02:16 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Sun, 17 Aug 2008 18:02:16 +0200 Subject: [Haiku-commits] r26858 - in haiku/trunk/src/add-ons/kernel: bus_managers/firewire bus_managers/scsi bus_managers/usb busses/ide/silicon_image_3112 busses/scsi/ahci drivers/audio/ac97/auich drivers/audio/ac97/auvia drivers/audio/ac97/es1370 drivers/audio/ac97/ich drivers/audio/ac97/ichaudio/lala drivers/audio/echo drivers/audio/emuxki drivers/audio/hda drivers/audio/ice1712 drivers/dvb/cx23882 drivers/graphics/matrox drivers/graphics/nvidia drivers/graphics/nvidia_gpgpu drivers/network/bcm570x drivers/network/dp83815 drivers/network/ipro1000 drivers/network/ipw2100 drivers/network/rtl8169 generic/block_io generic/ide_adapter In-Reply-To: <200808071300.m77D0gPm003738@sheep.berlios.de> References: <200808071300.m77D0gPm003738@sheep.berlios.de> Message-ID: <48A84B88.4080109@arcor.de> (message resent after maillinglist recovery) axeld at BerliOS schrieb: > haiku/trunk/src/add-ons/kernel/bus_managers/firewire/util.c > haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c > haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ich/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/ichaudio/lala/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/echo/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/util.c > haiku/trunk/src/add-ons/kernel/drivers/audio/ice1712/util.c > haiku/trunk/src/add-ons/kernel/drivers/dvb/cx23882/util.c > haiku/trunk/src/add-ons/kernel/drivers/network/dp83815/util.c > haiku/trunk/src/add-ons/kernel/drivers/network/ipro1000/if_em_osdep.c > haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c Looks like I'm guilty for all of these. > * The use of B_{READ|WRITE}_AREA throughout the drivers is surely alarming. Thats probably because of the BeBook create_area() description: protection Is a mask that describes whether the memory can be written and read. You form the mask by adding the constants B_READ_AREA (the area can be read) and B_WRITE_AREA (it can be written). The protection you describe applies only to this area. If your area is cloned, the clone can specify a different protection. > Defining these flags means that *every user* application can access these > buffers read/write, it becomes visible in userspace like any other memory Thats bad in some cases. > (just shared among all apps). I would like to ask each driver maintainer > to see if that is really wished here. If you only need one app to be able > to access it, cloning the area would be more appropriate. Has cloning any negative impact? > * I came across the use of B_ANY_KERNEL_BLOCK_ADDRESS a number of times. This > is almost completely useless for most usages, as it tries to align the > virtual to a multiple of the size of the area. It just makes the allocation I used that multiple times to get an aligment of 4k. The BeBook descripton on map_physical_memory says: spec must be either B_ANY_KERNEL_ADDRESS or B_ANY_KERNEL_BLOCK_ADDRESS. If spec is B_ANY_KERNEL_ADDRESS, the memory will begin at an arbitrary location in the kernel address space. If spec is B_ANY_KERNEL_BLOCK_ADDRESS, then the memory will be mapped into a memory location aligned on a multiple of B_PAGE_SIZE. > more likely to fail. Please only use where appropriate, and please review > your code. regards Marcus From revol at free.fr Sun Aug 17 18:04:15 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 17 Aug 2008 18:04:15 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r26990_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/os/storage_src/system/libroot/os?= In-Reply-To: <200808161106.m7GB61f0011460@sheep.berlios.de> Message-ID: <5597270990-BeMail@laptop> > * Added find directory constants B_{BEOS|COMMON|USER}_DATA_DIRECTORY, > which > currently points to /etc for the system, and dedicated "data" > directories > for common/user (the system directory should get a dedicated > "data", too, > though). How do they defer from the [/usr/]shared/ folder on unix ? could we reuse it (as ~/config/shared and common/shared/) maybe ? > * Added B_USER_CACHE_DIRECTORY (in config/cache). > * These additions were discussed some years ago, but I just had a > good reason > to use them :-) With app-named subfolders ? Btw, how about a logs/ one ? Vision puts its logs in apps/.../ which is horrendously bad, IM Kit puts a ~/Logs/ without warning... Fran?ois. From marcusoverhagen at arcor.de Sun Aug 17 18:02:30 2008 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Sun, 17 Aug 2008 18:02:30 +0200 Subject: [Haiku-commits] r26879 - haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169 In-Reply-To: <200808081537.m78Fbh7D023277@sheep.berlios.de> References: <200808081537.m78Fbh7D023277@sheep.berlios.de> Message-ID: <48A84B96.2090504@arcor.de> (message resent after maillinglist recovery) axeld at BerliOS schrieb: > Log: > * Reverted last commit - not a good idea to provide untested patches. With the > patch applied, the card didn't work at all anymore. > * Minor 80-column/white space cleanup. Quoting axeld: | It would be preferred if you don't mix cleanup with functional changes | - that would also make it much easier to review. (Trotzdem danke f?rs reparieren, ich war ?bers Wochenende weg) Gruss Marcus From revol at free.fr Sun Aug 17 18:09:05 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 17 Aug 2008 18:09:05 +0200 CEST Subject: [Haiku-commits] =?windows-1252?q?r27001_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/os/drivers_headers/os/storage__headers/private/storag?= =?windows-1252?q?e_src/add-ons/kernel/drivers/disk/scsi/scsi=5Fcd_src/add?= =?windows-1252?q?-ons/kernel/drivers/disk/scsi/scsi=5Fdisk_src/kits/stora?= =?windows-1252?q?ge_src/kits/storage/disk=5Fdevice_src/kits/tracker?= In-Reply-To: <200808171127.m7HBR9dL000084@sheep.berlios.de> Message-ID: <5887877603-BeMail@laptop> > * Added two new ways to retrieve an icon from a device: > - B_GET_ICON_NAME: returns the name of an icon. This will then be > read from > a predefined location on disk (not yet implemented). This would > also allow > to add specifiers like "-boot", or "-fat|bfs|ntfs|...", and have > special > icons for those. Here I think we might want to see if we can at least reuse FreeDesktop.org naming from icon specs, I saw some discussion about it recently, someone wants to dig it ? That would allow easy reuse of existing icon sets (not necessarily for official releases, but for distro makers or integrators wanting to use Haiku with their own branding and GUI). Fran?ois. From anevilyak at mail.berlios.de Sun Aug 17 18:49:40 2008 From: anevilyak at mail.berlios.de (anevilyak at BerliOS) Date: Sun, 17 Aug 2008 18:49:40 +0200 Subject: [Haiku-commits] r27007 - haiku/trunk/src/bin/makebootable/platform/bios_ia32 Message-ID: <200808171649.m7HGneF9020676@sheep.berlios.de> Author: anevilyak Date: 2008-08-17 18:49:39 +0200 (Sun, 17 Aug 2008) New Revision: 27007 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27007&view=rev Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp Log: Follow Axel's example in r27000 and use addr_t here. Modified: haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp =================================================================== --- haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-17 15:00:25 UTC (rev 27006) +++ haiku/trunk/src/bin/makebootable/platform/bios_ia32/makebootable.cpp 2008-08-17 16:49:39 UTC (rev 27007) @@ -185,9 +185,9 @@ { int32 cookie = 0; while (get_next_image_info(B_CURRENT_TEAM, &cookie, info) == B_OK) { - if (((uint32)info->text <= (uint32)find_own_image - && (uint32)info->text + info->text_size > - (uint32)find_own_image)) { + if (((addr_t)info->text <= (addr_t)find_own_image + && (addr_t)info->text + info->text_size + > (addr_t)find_own_image)) { return B_OK; } } From anevilyak at gmail.com Sun Aug 17 18:53:29 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 17 Aug 2008 11:53:29 -0500 Subject: [Haiku-commits] r27001 - in haiku/trunk: headers/os/drivers headers/os/storage headers/private/storage src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/kits/storage src/kits/storage/disk_device src/k Message-ID: Hi, On Sun, Aug 17, 2008 at 6:27 AM, axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-17 13:27:07 +0200 (Sun, 17 Aug 2008) > New Revision: 27001 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27001&view=rev > Log: > * Added two new ways to retrieve an icon from a device: Just curious, does this change also make it possible to fix ticket #2583, or is that a different issue entirely? Regards, Rene From axeld at pinc-software.de Sun Aug 17 19:13:55 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 19:13:55 +0200 CEST Subject: [Haiku-commits] r27001 - in haiku/trunk: headers/os/drivers headers/os/storage headers/private/storage src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/kits/storage src/kits/storage/disk_device src/kits/tracker In-Reply-To: <5887877603-BeMail@laptop> Message-ID: <28147379595-BeMail@zon> "Fran?ois Revol" wrote: > > * Added two new ways to retrieve an icon from a device: > > - B_GET_ICON_NAME: returns the name of an icon. This will then be > > read from > > a predefined location on disk (not yet implemented). This would > > also allow > > to add specifiers like "-boot", or "-fat|bfs|ntfs|...", and > > have > > special > > icons for those. > Here I think we might want to see if we can at least reuse > FreeDesktop.org naming from icon specs, I saw some discussion about > it > recently, someone wants to dig it ? > That would allow easy reuse of existing icon sets (not necessarily > for > official releases, but for distro makers or integrators wanting to > use > Haiku with their own branding and GUI). Since we currently only support our own vector format, I am not sure what good it brings, but for those wanting to have a look: http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html I guess using those names wouldn't hurt, at least, even though they don't make some differentiations one might want to have (but since one can use self-made names, too, this shouldn't be much of a problem either). I'll just change scsi_disk/scsi_cd to return "drive-harddisk" resp. "drive-optical", then. Bye, Axel. From axeld at mail.berlios.de Sun Aug 17 19:17:38 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 19:17:38 +0200 Subject: [Haiku-commits] r27008 - in haiku/trunk/src/add-ons/kernel/drivers/disk/scsi: scsi_cd scsi_disk Message-ID: <200808171717.m7HHHcqr021115@sheep.berlios.de> Author: axeld Date: 2008-08-17 19:17:36 +0200 (Sun, 17 Aug 2008) New Revision: 27008 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27008&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp Log: * Changed scsi_disk/scsi_cd to return FreeDesktop.org compatible icon names, see http://www.freedesktop.org/wiki/Specifications/icon-naming-spec for more info. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-17 16:49:39 UTC (rev 27007) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd.cpp 2008-08-17 17:17:36 UTC (rev 27008) @@ -740,7 +740,8 @@ } case B_GET_ICON_NAME: - return user_strlcpy((char*)buffer, "device-cd", B_FILE_NAME_LENGTH); + return user_strlcpy((char*)buffer, "devices/drive-optical", + B_FILE_NAME_LENGTH); case B_GET_VECTOR_ICON: { @@ -760,10 +761,6 @@ return user_memcpy(buffer, &iconData, sizeof(device_icon)); } - case B_GET_ICON: - return sSCSIPeripheral->get_icon(icon_type_cd, - (device_icon *)buffer); - case B_SCSI_GET_TOC: // TODO: we pass a user buffer here! return get_toc(info, (scsi_toc *)buffer); Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-17 16:49:39 UTC (rev 27007) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-17 17:17:36 UTC (rev 27008) @@ -347,7 +347,8 @@ case B_GET_ICON_NAME: // TODO: take device type into account! - return user_strlcpy((char*)buffer, "device-harddisk", + return user_strlcpy((char*)buffer, info->removable + ? "devices/drive-removable-media" : "devices/drive-harddisk", B_FILE_NAME_LENGTH); case B_GET_VECTOR_ICON: From revol at free.fr Sun Aug 17 19:20:11 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 17 Aug 2008 19:20:11 +0200 CEST Subject: [Haiku-commits] r27001 - in haiku/trunk: headers/os/drivers headers/os/storage headers/private/storage src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/kits/storage src/kits/storage/disk_device src/kits/tracker In-Reply-To: <28147379595-BeMail@zon> Message-ID: <10153313613-BeMail@laptop> > Since we currently only support our own vector format, I am not sure > what good it brings, but for those wanting to have a look: > http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html > > > I guess using those names wouldn't hurt, at least, even though they > don't make some differentiations one might want to have (but since > one > can use self-made names, too, this shouldn't be much of a problem > either). > I'll just change scsi_disk/scsi_cd to return "drive-harddisk" resp. > "drive-optical", then. It was under discussion allowing suffixes with + IIRC... like +scsi maybe... Anyway, yeah it doesn't hurt there. Fran?ois. From axeld at pinc-software.de Sun Aug 17 19:23:10 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 19:23:10 +0200 CEST Subject: [Haiku-commits] r26998 - haiku/trunk/src/system/kernel/vm In-Reply-To: <200808162347.m7GNlL65002428@sheep.berlios.de> Message-ID: <28702379182-BeMail@zon> mmu_man at mail.berlios.de wrote: > Log: > Fix building with TRACE on. [...] > - TRACE(("vm_create_aspace: %s: %lx bytes starting at 0x%lx => %p\n", > - name, size, base, addressSpace)); + TRACE(("vm_create_aspace: team %ld (%skernel): %lx bytes starting at 0x%lx => %p\n", + id, kernel?"!":"", size, base, addressSpace)); Actually, this fixes nothing, but uglifies the output, and violates our style guide :-)) Bye, Axel. From axeld at pinc-software.de Sun Aug 17 19:29:12 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 19:29:12 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r26879_-_haiku/trunk/src/add-ons/kernel?= =?utf-8?q?/drivers/network/rtl8169?= In-Reply-To: <48A84B96.2090504@arcor.de> Message-ID: <29064590174-BeMail@zon> Marcus Overhagen wrote: > (message resent after maillinglist recovery) > > axeld at BerliOS schrieb: > > Log: > > * Reverted last commit - not a good idea to provide untested > > patches. With the > > patch applied, the card didn't work at all anymore. > > * Minor 80-column/white space cleanup. > > Quoting axeld: > | It would be preferred if you don't mix cleanup with functional > changes > | - that would also make it much easier to review. > > (Trotzdem danke f?rs reparieren, ich war ?bers Wochenende weg) Hehe :-) I know I don't always cleanly separate those two, but this was just a minor change, though, and you know the previous version of it already. Bye, Axel. From revol at free.fr Sun Aug 17 19:32:22 2008 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Sun, 17 Aug 2008 19:32:22 +0200 CEST Subject: [Haiku-commits] r26998 - haiku/trunk/src/system/kernel/vm In-Reply-To: <28702379182-BeMail@zon> Message-ID: <10884604355-BeMail@laptop> > mmu_man at mail.berlios.de wrote: > > Log: > > Fix building with TRACE on. > [...] > > - TRACE(("vm_create_aspace: %s: %lx bytes starting at 0x%lx => %p > > \n", > > - name, size, base, addressSpace)); > + TRACE(("vm_create_aspace: team %ld (%skernel): %lx bytes starting > at 0x%lx => %p\n", > + id, kernel?"!":"", size, base, addressSpace)); > > Actually, this fixes nothing, but uglifies the output, and violates > our > style guide :-)) Well it does fix the build at least :P Fran?ois. From axeld at pinc-software.de Sun Aug 17 19:54:30 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 19:54:30 +0200 CEST Subject: [Haiku-commits] r26998 - haiku/trunk/src/system/kernel/vm In-Reply-To: <10884604355-BeMail@laptop> Message-ID: <30582689813-BeMail@zon> "Fran?ois Revol" wrote: > > mmu_man at mail.berlios.de wrote: > > > Log: > > > Fix building with TRACE on. > > [...] > > > - TRACE(("vm_create_aspace: %s: %lx bytes starting at 0x%lx => %p > > > \n", > > > - name, size, base, addressSpace)); > > + TRACE(("vm_create_aspace: team %ld (%skernel): %lx bytes > > starting > > at 0x%lx => %p\n", > > + id, kernel?"!":"", size, base, addressSpace)); > > > > Actually, this fixes nothing, but uglifies the output, and violates > > our style guide :-)) > Well it does fix the build at least :P Damn, I misread it (I didn't notice name vs. id). Sorry, but at least the other complaints are still vaild ;-) Bye, Axel. From mmu_man at mail.berlios.de Sun Aug 17 20:01:34 2008 From: mmu_man at mail.berlios.de (mmu_man at mail.berlios.de) Date: Sun, 17 Aug 2008 20:01:34 +0200 Subject: [Haiku-commits] r27009 - haiku/trunk/src/system/kernel/vm Message-ID: <200808171801.m7HI1Ypa026791@sheep.berlios.de> Author: mmu_man Date: 2008-08-17 20:01:32 +0200 (Sun, 17 Aug 2008) New Revision: 27009 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27009&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp Log: Fix style, ok now ? Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-17 17:17:36 UTC (rev 27008) +++ haiku/trunk/src/system/kernel/vm/vm_address_space.cpp 2008-08-17 18:01:32 UTC (rev 27009) @@ -279,8 +279,9 @@ if (addressSpace == NULL) return B_NO_MEMORY; - TRACE(("vm_create_aspace: team %ld (%skernel): %lx bytes starting at 0x%lx => %p\n", - id, kernel?"!":"", size, base, addressSpace)); + TRACE(("vm_create_aspace: team %ld (%skernel):" + " %lx bytes starting at 0x%lx => %p\n", + id, kernel ? "!" : "", size, base, addressSpace)); addressSpace->base = base; addressSpace->size = size; From axeld at pinc-software.de Sun Aug 17 20:07:49 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 20:07:49 +0200 CEST Subject: [Haiku-commits] =?utf-8?q?r27001_-_in_haiku/trunk=3A_headers/os/d?= =?utf-8?q?rivers_headers/os/storage__headers/private/storage_src/add-ons/?= =?utf-8?q?kernel/drivers/disk/scsi/scsi=5Fcd_src/add-ons/kernel/drivers/d?= =?utf-8?q?isk/scsi/scsi=5Fdisk_src/kits/storage_src/kits/storage/disk=5Fd?= =?utf-8?q?evice_src/k?= In-Reply-To: Message-ID: <31381196688-BeMail@zon> "Rene Gollent" wrote: > > Log: > > * Added two new ways to retrieve an icon from a device: > Just curious, does this change also make it possible to fix ticket > #2583, or is that a different issue entirely? It actually already fixes it. Bye, Axel. From anevilyak at gmail.com Sun Aug 17 20:09:39 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Sun, 17 Aug 2008 13:09:39 -0500 Subject: [Haiku-commits] r27001 - in haiku/trunk: headers/os/drivers headers/os/storage headers/private/storage src/add-ons/kernel/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_disk src/kits/storage src/kits/storage/disk_device src/k In-Reply-To: <31381196688-BeMail@zon> References: <31381196688-BeMail@zon> Message-ID: On Sun, Aug 17, 2008 at 1:07 PM, Axel D?rfler wrote: > It actually already fixes it. Even better :) Regards, Rene From mmu_man at mail.berlios.de Sun Aug 17 20:37:24 2008 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 17 Aug 2008 20:37:24 +0200 Subject: [Haiku-commits] r27010 - haiku/trunk/src/add-ons/media/media-add-ons/esound_sink Message-ID: <200808171837.m7HIbOaF029180@sheep.berlios.de> Author: mmu_man Date: 2008-08-17 20:37:23 +0200 (Sun, 17 Aug 2008) New Revision: 27010 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27010&view=rev Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.cpp haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.h haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.h Log: - style cleanup - remove multi_audio commented code - don't connect in ctor, but in Node::Connected(), this way it doesn't hang up everything on startup even if it's not the selected system output. - prepare for asynchronous connection - add an enable checkbox and change parameter handling Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.cpp 2008-08-17 18:01:32 UTC (rev 27009) +++ haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.cpp 2008-08-17 18:37:23 UTC (rev 27010) @@ -46,6 +46,7 @@ #include #include "ESDEndpoint.h" + ESDEndpoint::ESDEndpoint() : BDataIO() , fHost(NULL) @@ -56,6 +57,7 @@ Reset(); } + ESDEndpoint::~ESDEndpoint() { CALLED(); @@ -64,8 +66,18 @@ fSocket = -1; } -void ESDEndpoint::Reset() + +status_t +ESDEndpoint::InitCheck() const { + return fInitStatus; +} + + +void +ESDEndpoint::Reset() +{ + fInitStatus = B_NO_INIT; fDefaultCommand = ESD_PROTO_STREAM_PLAY; fDefaultCommandSent = false; fDefaultFormat = ESD_BITS8 | ESD_MONO; @@ -73,7 +85,9 @@ fLatency = 0LL; } -status_t ESDEndpoint::SendAuthKey() + +status_t +ESDEndpoint::SendAuthKey() { CALLED(); BPath kfPath; @@ -106,13 +120,49 @@ return write(fSocket, fAuthKey, ESD_MAX_KEY); } -status_t ESDEndpoint::Connect(const char *host, uint16 port) + +bool +ESDEndpoint::Connected() const { + return (fInitStatus == B_OK); +} + + +status_t +ESDEndpoint::Connect(const char *host, uint16 port) +{ status_t err; + // set up connection asynchronously + fHost = host; + fPort = port; + + err = fConnectThread = spawn_thread(_ConnectThread, "ESDEndpoint Connection", B_LOW_PRIORITY, this); + if (err < B_OK) + return err; + err = resume_thread(fConnectThread); + + // TODO: return now instead and move Connect() call + wait_for_thread(fConnectThread, &err); + + return err; +} + + +int32 +ESDEndpoint::_ConnectThread(void *_arg) +{ + ESDEndpoint *_this = (ESDEndpoint *)_arg; + return _this->ConnectThread(); +} + +int32 +ESDEndpoint::ConnectThread(void) +{ + const char *host = fHost.String(); + uint16 port = fPort; + status_t err; int flag; CALLED(); - fHost = host; - fPort = port; struct hostent *he; struct sockaddr_in sin; @@ -140,7 +190,7 @@ */ err = connect(fSocket, (struct sockaddr *) &sin, sizeof(sin)); - PRINT(("connect: %s\n", strerror(err))); + PRINT(("connect: %ld, %s\n", err, strerror(errno))); if (err < 0) return errno; @@ -220,17 +270,17 @@ setsockopt(fSocket, SOL_SOCKET, SO_SNDBUF, &flag, sizeof(flag)); */ -// read(fSocket, &ok, sizeof(uint32)); -// connect -// auth -// ask server latency -// calc network latency (time (send+recv) / 2) ? -// get default format + + // TODO: get default format + + fInitStatus = B_OK; + return B_OK; } -status_t ESDEndpoint::Disconnect() +status_t +ESDEndpoint::Disconnect() { CALLED(); if (fSocket > -1) @@ -239,7 +289,8 @@ return B_OK; } -status_t ESDEndpoint::SetCommand(esd_command_t cmd) +status_t +ESDEndpoint::SetCommand(esd_command_t cmd) { CALLED(); if (fDefaultCommandSent) @@ -248,7 +299,8 @@ return B_OK; } -status_t ESDEndpoint::SetFormat(int bits, int channels, float rate) +status_t +ESDEndpoint::SetFormat(int bits, int channels, float rate) { esd_format_t fmt = 0; CALLED(); @@ -282,7 +334,8 @@ return B_OK; } -status_t ESDEndpoint::GetServerInfo() +status_t +ESDEndpoint::GetServerInfo() { CALLED(); struct serverinfo { @@ -298,19 +351,22 @@ return B_OK; } -bool ESDEndpoint::CanSend() +bool +ESDEndpoint::CanSend() { CALLED(); return fDefaultCommandSent; } -ssize_t ESDEndpoint::Read(void *buffer, size_t size) +ssize_t +ESDEndpoint::Read(void *buffer, size_t size) { CALLED(); return EINVAL; } -ssize_t ESDEndpoint::Write(const void *buffer, size_t size) +ssize_t +ESDEndpoint::Write(const void *buffer, size_t size) { status_t err = B_OK; CALLED(); @@ -336,7 +392,8 @@ return err; } -status_t ESDEndpoint::SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen) +status_t +ESDEndpoint::SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen) { status_t err; CALLED(); @@ -358,7 +415,8 @@ return err; } -status_t ESDEndpoint::SendDefaultCommand() +status_t +ESDEndpoint::SendDefaultCommand() { status_t err; struct { Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.h 2008-08-17 18:01:32 UTC (rev 27009) +++ haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDEndpoint.h 2008-08-17 18:37:23 UTC (rev 27010) @@ -44,8 +44,11 @@ ~ESDEndpoint(); /* */ +status_t InitCheck() const; void Reset(); status_t SendAuthKey(); + +bool Connected() const; status_t Connect(const char *host, uint16 port=ESD_DEFAULT_PORT); status_t Disconnect(); @@ -71,7 +74,12 @@ status_t SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen); status_t SendDefaultCommand(); private: - + + static int32 _ConnectThread(void *_arg); + int32 ConnectThread(void); + + status_t fInitStatus; + thread_id fConnectThread; BString fHost; uint16 fPort; int fSocket; Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp 2008-08-17 18:01:32 UTC (rev 27009) +++ haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.cpp 2008-08-17 18:37:23 UTC (rev 27010) @@ -133,9 +133,11 @@ config->FindString("hostname", &fHostname); } if (fHostname.Length() < 1) - fHostname = "192.168.0.253"; + fHostname = "192.168.0.1"; + fPort = ESD_DEFAULT_PORT; fDevice = new ESDEndpoint(); + /* if (fDevice) { if (fDevice->Connect(fHostname.String()) >= 0) { fDevice->SetCommand(); @@ -144,6 +146,10 @@ fInitCheckStatus = fDevice->SendDefaultCommand(); } } + */ + if (!fDevice) + return; + fInitCheckStatus = B_OK; } status_t ESDSinkNode::InitCheck(void) const @@ -432,6 +438,15 @@ return B_MEDIA_BAD_DESTINATION; } + // + if (fDevice) { + if (fDevice->Connect(fHostname.String(), fPort) >= 0) { + fDevice->SetCommand(); + //fDevice->GetServerInfo(); + fDevice->SetFormat(ESD_FMT, 2); + fInitCheckStatus = fDevice->SendDefaultCommand(); + } + } // use one buffer length latency fInternalLatency = with_format.u.raw_audio.buffer_size * 10000 / 2 / ( (with_format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK) @@ -1076,19 +1091,28 @@ if (!fDevice) return B_ERROR; //PRINT(("id : %i\n", id)); - if (id == fWebHostId) { - BString s = fDevice->Host(); - *ioSize = MIN(*ioSize, s.Length()); - memcpy(value, s.String(), *ioSize); - return B_OK; + switch (id) { + case PARAM_ENABLED: + // XXX + break; + case PARAM_HOST: + { + BString s = fDevice->Host(); + *ioSize = MIN(*ioSize, s.Length()); + memcpy(value, s.String(), *ioSize); + return B_OK; + } + case PARAM_PORT: + { + BString s; + s << fDevice->Port(); + *ioSize = MIN(*ioSize, s.Length()); + memcpy(value, s.String(), *ioSize); + return B_OK; + } + default: + break; } - if (id == fWebPortId) { - BString s; - s << fDevice->Port(); - *ioSize = MIN(*ioSize, s.Length()); - memcpy(value, s.String(), *ioSize); - return B_OK; - } #if 0 BParameter *parameter = NULL; for(int32 i=0; iCountParameters(); i++) { @@ -1098,78 +1122,6 @@ } #endif -#if 0 - if(!parameter) { - // Hmmm, we were asked for a parameter that we don't actually - // support. Report an error back to the caller. - PRINT(("\terror - asked for illegal parameter %ld\n", id)); - return B_ERROR; - } - - multi_mix_value_info MMVI; - multi_mix_value MMV[2]; - int rval; - MMVI.values = MMV; - id = id - 100; - MMVI.item_count = 0; - - if (*ioSize < sizeof(float)) - return B_ERROR; - - if(parameter->Type() == BParameter::B_CONTINUOUS_PARAMETER) { - MMVI.item_count = 1; - MMV[0].id = id; - - if(parameter->CountChannels() == 2) { - if (*ioSize < 2*sizeof(float)) - return B_ERROR; - MMVI.item_count = 2; - MMV[1].id = id + 1; - } - - } else if(parameter->Type() == BParameter::B_DISCRETE_PARAMETER) { - MMVI.item_count = 1; - MMV[0].id = id; - } - - if(MMVI.item_count > 0) { - rval = fDevice->DoGetMix(&MMVI); - - if (B_OK != rval) { - fprintf(stderr, "Failed on DRIVER_GET_MIX\n"); - } else { - - if(parameter->Type() == BParameter::B_CONTINUOUS_PARAMETER) { - ((float*)value)[0] = MMV[0].gain; - *ioSize = sizeof(float); - - if(parameter->CountChannels() == 2) { - ((float*)value)[1] = MMV[1].gain; - *ioSize = 2*sizeof(float); - } - - for(uint32 i=0; i < (*ioSize/sizeof(float)); i++) { - PRINT(("B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); - } - } else if(parameter->Type() == BParameter::B_DISCRETE_PARAMETER) { - - BDiscreteParameter *dparameter = (BDiscreteParameter*) parameter; - if(dparameter->CountItems()<=2) { - ((int32*)value)[0] = (MMV[0].enable) ? 1 : 0; - } else { - ((int32*)value)[0] = MMV[0].mux; - } - *ioSize = sizeof(int32); - - for(uint32 i=0; i < (*ioSize/sizeof(int32)); i++) { - PRINT(("B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); - } - } - - } - } - return B_OK; -#endif return EINVAL; } @@ -1184,70 +1136,40 @@ if(parameter->ID() == id) break; } - if (id == fWebHostId) { - fprintf(stderr, "set HOST: %s\n", (const char *)value); - BString host = (const char *)value; - uint16 port = fDevice->Port(); - fDevice->Connect(host.String(), port); - return; - } - if (id == fWebPortId) { - fprintf(stderr, "set PORT: %s\n", (const char *)value); - BString host = fDevice->Host(); - uint16 port = atoi((const char *)value); - fDevice->Connect(host.String(), port); - return; - } -#if 0 - if(parameter) { - multi_mix_value_info MMVI; - multi_mix_value MMV[2]; - int rval; - MMVI.values = MMV; - id = id - 100; - MMVI.item_count = 0; - - if(parameter->Type() == BParameter::B_CONTINUOUS_PARAMETER) { - for(uint32 i=0; i < (size/sizeof(float)); i++) { - PRINT(("B_CONTINUOUS_PARAMETER value[%i] : %f\n", i, ((float*)value)[i])); + switch (id) { + case PARAM_ENABLED: + break; + case PARAM_HOST: + { + fprintf(stderr, "set HOST: %s\n", (const char *)value); + fHostname = (const char *)value; + if (fDevice && fDevice->Connected()) { + if (fDevice->Connect(fHostname.String(), fPort) >= 0) { + fDevice->SetCommand(); + fDevice->SetFormat(ESD_FMT, 2); + //fDevice->GetServerInfo(); + fInitCheckStatus = fDevice->SendDefaultCommand(); + } } - MMVI.item_count = 1; - MMV[0].id = id; - MMV[0].gain = ((float*)value)[0]; - - if(parameter->CountChannels() == 2) { - MMVI.item_count = 2; - MMV[1].id = id + 1; - MMV[1].gain = ((float*)value)[1]; - } - - } else if(parameter->Type() == BParameter::B_DISCRETE_PARAMETER) { - for(uint32 i=0; i < (size/sizeof(int32)); i++) { - PRINT(("B_DISCRETE_PARAMETER value[%i] : %i\n", i, ((int32*)value)[i])); - } - BDiscreteParameter *dparameter = (BDiscreteParameter*) parameter; - - if(dparameter->CountItems()<=2) { - MMVI.item_count = 1; - MMV[0].id = id; - MMV[0].enable = (((int32*)value)[0] == 1) ? true : false; - } else { - MMVI.item_count = 1; - MMV[0].id = id; - MMV[0].mux = ((uint32*)value)[0]; - } + return; } - - if(MMVI.item_count > 0) { - rval = fDevice->DoSetMix(&MMVI); - - if (B_OK != rval) - { - fprintf(stderr, "Failed on DRIVER_SET_MIX\n"); + case PARAM_PORT: + { + fprintf(stderr, "set PORT: %s\n", (const char *)value); + fPort = atoi((const char *)value); + if (fDevice && fDevice->Connected()) { + if (fDevice->Connect(fHostname.String(), fPort) >= 0) { + fDevice->SetCommand(); + fDevice->SetFormat(ESD_FMT, 2); + //fDevice->GetServerInfo(); + fInitCheckStatus = fDevice->SendDefaultCommand(); + } } + return; } + default: + break; } -#endif } BParameterWeb* @@ -1276,12 +1198,12 @@ int id = 0; BParameterGroup *group = web->MakeGroup("Server"); BParameter *p; - fWebHostId = fWebPortId = -1; + // XXX: use B_MEDIA_UNKNOWN_TYPE or _NO_TYPE ? + // keep in sync with enum { PARAM_* } ! + p = group->MakeDiscreteParameter(PARAM_ENABLED, B_MEDIA_RAW_AUDIO, "Enable", B_ENABLE); #if defined(B_BEOS_VERSION_DANO) || defined(__HAIKU__) - fWebHostId = id++; - p = group->MakeTextParameter(fWebHostId, B_MEDIA_RAW_AUDIO, "Hostname", B_GENERIC, 128); - fWebPortId = id++; - p = group->MakeTextParameter(fWebPortId, B_MEDIA_RAW_AUDIO, "Port", B_GENERIC, 16); + p = group->MakeTextParameter(PARAM_HOST, B_MEDIA_RAW_AUDIO, "Hostname", B_GENERIC, 128); + p = group->MakeTextParameter(PARAM_PORT, B_MEDIA_RAW_AUDIO, "Port", B_GENERIC, 16); #endif return web; } Modified: haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.h =================================================================== --- haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.h 2008-08-17 18:01:32 UTC (rev 27009) +++ haiku/trunk/src/add-ons/media/media-add-ons/esound_sink/ESDSinkNode.h 2008-08-17 18:37:23 UTC (rev 27010) @@ -52,6 +52,13 @@ const media_format & producer_format, const media_format & consumer_format);*/ + +enum { + PARAM_ENABLED, + PARAM_HOST, + PARAM_PORT +}; + class ESDSinkNode : public BBufferConsumer, #if ENABLE_INPUT @@ -345,6 +352,7 @@ thread_id fThread; BString fHostname; + uint16 fPort; ESDEndpoint *fDevice; //multi_description MD; @@ -357,8 +365,6 @@ bool fTimeSourceStarted; BParameterWeb *fWeb; - int32 fWebHostId; - int32 fWebPortId; BMessage fConfig; }; From superstippi at gmx.de Sun Aug 17 21:28:57 2008 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 17 Aug 2008 21:28:57 +0200 Subject: [Haiku-commits] r26979 - haiku/trunk/src/add-ons/kernel/file_systems/cdda In-Reply-To: <200808151406.m7FE6Fda021468@sheep.berlios.de> References: <200808151406.m7FE6Fda021468@sheep.berlios.de> Message-ID: <20080817192857.271670@gmx.net> Hi, > Log: > - Add the TLA back. I still think it is useless but I guess even in R5 the > files included the extension. Thanks. I think when I was using gogo, it depended on these extensions. Not 100% sure though, that was a loong time ago. :-) Best regards, -Stephan From axeld at mail.berlios.de Sun Aug 17 22:35:05 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 17 Aug 2008 22:35:05 +0200 Subject: [Haiku-commits] r27011 - haiku/trunk/src/system/libroot/os/arch/x86 Message-ID: <200808172035.m7HKZ55e006068@sheep.berlios.de> Author: axeld Date: 2008-08-17 22:35:05 +0200 (Sun, 17 Aug 2008) New Revision: 27011 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27011&view=rev Modified: haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c Log: * Adds the _kunlock_node_() syscall obviously used by p4. This should fix ticket #2626. Modified: haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c =================================================================== --- haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c 2008-08-17 18:37:23 UTC (rev 27010) +++ haiku/trunk/src/system/libroot/os/arch/x86/compatibility.c 2008-08-17 20:35:05 UTC (rev 27011) @@ -1,5 +1,5 @@ /* - * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Copyright 2005-2008, Axel D?rfler, axeld at pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -8,8 +8,7 @@ // least they should only be used when compiling for GCC 2.95.3, though. #if __GNUC__ < 30 -// This file includes some known R5 syscalls -// ToDo: maybe they should indeed do something... +//! This file includes some known R5 syscalls #include #include @@ -24,6 +23,7 @@ int _kset_mon_limit_(int num); int _kset_fd_limit_(int num); int _klock_node_(int fd); +int _kunlock_node_(int fd); int _kget_cpu_state_(int cpuNum); int _kset_cpu_state_(int cpuNum, int state); int _kstatfs_(dev_t device, void *whatever, int fd, const char *path, fs_info *info); @@ -65,6 +65,13 @@ int +_kunlock_node_(int fd) +{ + return _kern_unlock_node(fd); +} + + +int _kget_cpu_state_(int cpuNum) { return _kern_cpu_enabled(cpuNum); From axeld at pinc-software.de Sun Aug 17 22:35:59 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Sun, 17 Aug 2008 22:35:59 +0200 CEST Subject: [Haiku-commits] r27009 - haiku/trunk/src/system/kernel/vm In-Reply-To: <200808171801.m7HI1Ypa026791@sheep.berlios.de> Message-ID: <40271302347-BeMail@zon> mmu_man at mail.berlios.de wrote: > Log: > Fix style, ok now ? Lovely ;-) Bye, Axel. From korli at mail.berlios.de Mon Aug 18 00:03:25 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 00:03:25 +0200 Subject: [Haiku-commits] r27012 - in haiku/trunk: headers/libs/png src/libs/png Message-ID: <200808172203.m7HM3P8a012040@sheep.berlios.de> Author: korli Date: 2008-08-18 00:03:24 +0200 (Mon, 18 Aug 2008) New Revision: 27012 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27012&view=rev Modified: haiku/trunk/headers/libs/png/png.h haiku/trunk/headers/libs/png/pngconf.h haiku/trunk/src/libs/png/png.c haiku/trunk/src/libs/png/pngerror.c haiku/trunk/src/libs/png/pnggccrd.c haiku/trunk/src/libs/png/pngget.c haiku/trunk/src/libs/png/pngmem.c haiku/trunk/src/libs/png/pngpread.c haiku/trunk/src/libs/png/pngread.c haiku/trunk/src/libs/png/pngrio.c haiku/trunk/src/libs/png/pngrtran.c haiku/trunk/src/libs/png/pngrutil.c haiku/trunk/src/libs/png/pngset.c haiku/trunk/src/libs/png/pngtrans.c haiku/trunk/src/libs/png/pngwio.c haiku/trunk/src/libs/png/pngwrite.c haiku/trunk/src/libs/png/pngwtran.c haiku/trunk/src/libs/png/pngwutil.c Log: updated libpng to 1.2.30 Modified: haiku/trunk/headers/libs/png/png.h =================================================================== --- haiku/trunk/headers/libs/png/png.h 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/headers/libs/png/png.h 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,7 +1,6 @@ - /* png.h - header file for PNG reference library * - * libpng version 1.2.26 - April 2, 2008 + * libpng version 1.2.30 - August 15, 2008 * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -9,7 +8,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.26 - April 2, 2008: Glenn + * libpng versions 0.97, January 1998, through 1.2.30 - August 15, 2008: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -181,6 +180,24 @@ * 1.2.25 13 10225 12.so.0.25[.0] * 1.2.26beta01-06 13 10226 12.so.0.26[.0] * 1.2.26rc01 13 10226 12.so.0.26[.0] + * 1.2.26 13 10226 12.so.0.26[.0] + * 1.0.32 10 10032 10.so.0.32[.0] + * 1.2.27beta01-06 13 10227 12.so.0.27[.0] + * 1.2.27rc01 13 10227 12.so.0.27[.0] + * 1.0.33 10 10033 10.so.0.33[.0] + * 1.2.27 13 10227 12.so.0.27[.0] + * 1.0.34 10 10034 10.so.0.34[.0] + * 1.2.28 13 10228 12.so.0.28[.0] + * 1.2.29beta01-03 13 10229 12.so.0.29[.0] + * 1.2.29rc01 13 10229 12.so.0.29[.0] + * 1.0.35 10 10035 10.so.0.35[.0] + * 1.2.29 13 10229 12.so.0.29[.0] + * 1.0.37 10 10037 10.so.0.37[.0] + * 1.2.30beta01-04 13 10230 12.so.0.30[.0] + * 1.0.38rc01-08 10 10038 10.so.0.38[.0] + * 1.2.30rc01-08 13 10230 12.so.0.30[.0] + * 1.0.38 10 10038 10.so.0.38[.0] + * 1.2.30 13 10230 12.so.0.30[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -190,7 +207,7 @@ * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". + * release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled @@ -210,7 +227,7 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.2.6, August 15, 2004, through 1.2.26, April 2, 2008, are + * libpng versions 1.2.6, August 15, 2004, through 1.2.30, August 15, 2008, are * Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: @@ -322,13 +339,13 @@ * Y2K compliance in libpng: * ========================= * - * April 2, 2008 + * August 15, 2008 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.26 are Y2K compliant. It is my belief that earlier + * upward through 1.2.30 are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -384,9 +401,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.26" +#define PNG_LIBPNG_VER_STRING "1.2.30" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.26 - April 2, 2008\n" + " libpng version 1.2.30 - August 15, 2008\n" #define PNG_LIBPNG_VER_SONUM 0 #define PNG_LIBPNG_VER_DLLNUM 13 @@ -394,7 +411,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 26 +#define PNG_LIBPNG_VER_RELEASE 30 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ @@ -422,7 +439,7 @@ * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10226 /* 1.2.26 */ +#define PNG_LIBPNG_VER 10230 /* 1.2.30 */ #ifndef PNG_VERSION_INFO_ONLY /* include the compression library's header */ @@ -1193,7 +1210,7 @@ png_uint_32 row_number; /* current row in interlace pass */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */ -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */ @@ -1433,13 +1450,17 @@ /* New members added in libpng-1.2.26 */ png_uint_32 old_big_row_buf_size, old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + }; /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef png_structp version_1_2_26; +typedef png_structp version_1_2_30; typedef png_struct FAR * FAR * png_structpp; @@ -2634,6 +2655,7 @@ png_ptr)); #endif + /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED @@ -3015,8 +3037,8 @@ /* Decompress data in a chunk that uses compression */ #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, png_size_t prefix_length, png_size_t *data_length)); #endif @@ -3545,6 +3567,9 @@ #endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ Modified: haiku/trunk/headers/libs/png/pngconf.h =================================================================== --- haiku/trunk/headers/libs/png/pngconf.h 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/headers/libs/png/pngconf.h 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.2.26 - April 2, 2008 + * libpng version 1.2.30 - August 15, 2008 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -1123,10 +1123,10 @@ change (I'm not sure if you will or not, so I thought I'd be safe) */ #ifdef PNG_SIZE_T typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) +# define png_sizeof(x) png_convert_size(sizeof(x)) #else typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) +# define png_sizeof(x) sizeof(x) #endif /* The following is needed for medium model support. It cannot be in the Modified: haiku/trunk/src/libs/png/png.c =================================================================== --- haiku/trunk/src/libs/png/png.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/png.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,9 +1,9 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.21 October 4, 2007 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ @@ -13,7 +13,7 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_26 Your_png_h_is_not_version_1_2_26; +typedef version_1_2_30 Your_png_h_is_not_version_1_2_30; /* Version information for C files. This had better match the version * string defined in png.h. */ @@ -92,7 +92,7 @@ void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; png_debug(1, "in png_set_sig_bytes\n"); if (num_bytes > 8) png_error(png_ptr, "Too many bytes for PNG signature."); @@ -153,7 +153,7 @@ png_uint_32 save_flags=p->flags; png_uint_32 num_bytes; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); if (items > PNG_UINT_32_MAX/size) { png_warning (p, "Potential overflow in png_zalloc()"); @@ -241,7 +241,7 @@ png_infop info_ptr; png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, png_ptr->malloc_fn, png_ptr->mem_ptr); @@ -263,7 +263,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { png_infop info_ptr = NULL; - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; png_debug(1, "in png_destroy_info_struct\n"); if (info_ptr_ptr != NULL) @@ -302,11 +302,11 @@ { png_infop info_ptr = *ptr_ptr; - if(info_ptr == NULL) return; + if (info_ptr == NULL) return; png_debug(1, "in png_info_init_3\n"); - if(png_sizeof(png_info) > png_info_struct_size) + if (png_sizeof(png_info) > png_info_struct_size) { png_destroy_struct(info_ptr); info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); @@ -314,7 +314,7 @@ } /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); + png_memset(info_ptr, 0, png_sizeof(png_info)); } #ifdef PNG_FREE_ME_SUPPORTED @@ -325,9 +325,9 @@ png_debug(1, "in png_data_freer\n"); if (png_ptr == NULL || info_ptr == NULL) return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) + if (freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) + else if (freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; else png_warning(png_ptr, @@ -380,11 +380,11 @@ #endif { png_free(png_ptr, info_ptr->trans); + info_ptr->trans = NULL; info_ptr->valid &= ~PNG_INFO_tRNS; #ifndef PNG_FREE_ME_SUPPORTED png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif - info_ptr->trans = NULL; } #endif @@ -459,7 +459,7 @@ { if (num != -1) { - if(info_ptr->splt_palettes) + if (info_ptr->splt_palettes) { png_free(png_ptr, info_ptr->splt_palettes[num].name); png_free(png_ptr, info_ptr->splt_palettes[num].entries); @@ -469,7 +469,7 @@ } else { - if(info_ptr->splt_palettes_num) + if (info_ptr->splt_palettes_num) { int i; for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) @@ -485,11 +485,12 @@ #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if(png_ptr->unknown_chunk.data) + if (png_ptr->unknown_chunk.data) { png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } + #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) #else @@ -498,7 +499,7 @@ { if (num != -1) { - if(info_ptr->unknown_chunks) + if (info_ptr->unknown_chunks) { png_free(png_ptr, info_ptr->unknown_chunks[num].data); info_ptr->unknown_chunks[num].data = NULL; @@ -508,7 +509,7 @@ { int i; - if(info_ptr->unknown_chunks_num) + if (info_ptr->unknown_chunks_num) { for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); @@ -562,7 +563,7 @@ if (mask & PNG_FREE_ROWS) #endif { - if(info_ptr->row_pointers) + if (info_ptr->row_pointers) { int row; for (row = 0; row < (int)info_ptr->height; row++) @@ -578,7 +579,7 @@ #endif #ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) + if (num == -1) info_ptr->free_me &= ~mask; else info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); @@ -601,7 +602,7 @@ { png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; + png_ptr->num_chunk_list = 0; } #endif @@ -616,7 +617,7 @@ png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); return (png_ptr->io_ptr); } @@ -632,7 +633,7 @@ png_init_io(png_structp png_ptr, png_FILE_p fp) { png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; png_ptr->io_ptr = (png_voidp)fp; } #endif @@ -648,7 +649,7 @@ {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); if (png_ptr->time_buffer == NULL) { png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* @@ -669,7 +670,7 @@ #ifdef USE_FAR_KEYWORD { char near_time_buf[29]; - png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -677,7 +678,7 @@ 29*png_sizeof(char)); } #else - png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -693,7 +694,7 @@ png_get_copyright(png_structp png_ptr) { png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.26 - April 2, 2008\n\ + return ((png_charp) "\n libpng version 1.2.30 - August 15, 2008\n\ Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\ Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); @@ -743,12 +744,12 @@ /* check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; - if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) + if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) + p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5; + for (i = png_ptr->num_chunk_list; i; i--, p -= 5) if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); + return ((int)*(p + 4)); return 0; } #endif Modified: haiku/trunk/src/libs/png/pngerror.c =================================================================== --- haiku/trunk/src/libs/png/pngerror.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/pngerror.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,9 +1,9 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.22 [October 13, 2007] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -15,8 +15,8 @@ #define PNG_INTERNAL #include "png.h" +#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) static void /* PRIVATE */ png_default_error PNGARG((png_structp png_ptr, png_const_charp error_message)); @@ -44,28 +44,29 @@ { if (*error_message == '#') { + /* Strip "#nnnn " from beginning of error message. */ int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') + for (offset = 1; offset<15; offset++) + if (error_message[offset] == ' ') break; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { int i; - for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; } } } @@ -110,16 +111,16 @@ { if (*warning_message == '#') { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') + for (offset = 1; offset < 15; offset++) + if (warning_message[offset] == ' ') break; } } if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); + (*(png_ptr->warning_fn))(png_ptr, warning_message + offset); } else - png_default_warning(png_ptr, warning_message+offset); + png_default_warning(png_ptr, warning_message + offset); } #endif /* PNG_NO_WARNINGS */ @@ -167,8 +168,8 @@ { buffer[iout++] = ':'; buffer[iout++] = ' '; - png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT); - buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0'; + png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT); + buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0'; } } @@ -216,22 +217,23 @@ #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == '#') { + /* Strip "#nnnn " from beginning of warning message. */ int offset; char error_number[16]; - for (offset=0; offset<15; offset++) + for (offset = 0; offset<15; offset++) { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') + error_number[offset] = error_message[offset + 1]; + if (error_message[offset] == ' ') break; } - if((offset > 1) && (offset < 15)) + if ((offset > 1) && (offset < 15)) { - error_number[offset-1]='\0'; + error_number[offset - 1] = '\0'; fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); + error_message + offset + 1); } else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); + fprintf(stderr, "libpng error: %s, offset=%d\n", error_message, offset); } else #endif @@ -274,17 +276,17 @@ { int offset; char warning_number[16]; - for (offset=0; offset<15; offset++) + for (offset = 0; offset < 15; offset++) { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') + warning_number[offset] = warning_message[offset + 1]; + if (warning_message[offset] == ' ') break; } - if((offset > 1) && (offset < 15)) + if ((offset > 1) && (offset < 15)) { - warning_number[offset-1]='\0'; + warning_number[offset + 1] = '\0'; fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); + warning_message + offset); } else fprintf(stderr, "libpng warning: %s\n", warning_message); @@ -333,7 +335,7 @@ void PNGAPI png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) { - if(png_ptr != NULL) + if (png_ptr != NULL) { png_ptr->flags &= ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); Modified: haiku/trunk/src/libs/png/pnggccrd.c =================================================================== --- haiku/trunk/src/libs/png/pnggccrd.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/pnggccrd.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -2,8 +2,10 @@ /* This code snippet is for use by configure's compilation test. */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ +#if (!defined _MSC_VER) && \ + defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ defined(PNG_MMX_CODE_SUPPORTED) + int PNGAPI png_dummy_mmx_support(void); static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested Modified: haiku/trunk/src/libs/png/pngget.c =================================================================== --- haiku/trunk/src/libs/png/pngget.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/pngget.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,16 +1,15 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.15 January 5, 2007 + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) png_uint_32 PNGAPI @@ -122,7 +121,7 @@ if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->x_pixels_per_unit); } @@ -140,7 +139,7 @@ if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->y_pixels_per_unit); } @@ -158,7 +157,7 @@ if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) return (0); else return (info_ptr->x_pixels_per_unit); @@ -199,7 +198,7 @@ if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->x_offset); } @@ -217,7 +216,7 @@ if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->y_offset); } @@ -235,7 +234,7 @@ if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->x_offset); } @@ -253,7 +252,7 @@ if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->y_offset); } @@ -323,7 +322,7 @@ { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; - if(*unit_type == 1) + if (*unit_type == 1) { if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); @@ -784,10 +783,10 @@ *trans_values = &(info_ptr->trans_values); retval |= PNG_INFO_tRNS; } - if(trans != NULL) + if (trans != NULL) *trans = NULL; } - if(num_trans != NULL) + if (num_trans != NULL) { *num_trans = info_ptr->num_trans; retval |= PNG_INFO_tRNS; Modified: haiku/trunk/src/libs/png/pngmem.c =================================================================== --- haiku/trunk/src/libs/png/pngmem.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/pngmem.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.26 [April 2, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -16,7 +16,6 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Borland DOS special memory handler */ @@ -48,7 +47,7 @@ return (png_get_copyright(NULL)); #ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) + if (malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -80,7 +79,7 @@ if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) + if (free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -122,7 +121,7 @@ return (NULL); #ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) + if (png_ptr->malloc_fn != NULL) ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); @@ -171,7 +170,7 @@ ret = NULL; } - if(png_ptr->zlib_window_bits > 14) + if (png_ptr->zlib_window_bits > 14) num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); else num_blocks = 1; @@ -210,7 +209,7 @@ png_ptr->offset_table = table; png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); + png_sizeof(png_bytep)); if (png_ptr->offset_table_ptr == NULL) { @@ -273,6 +272,7 @@ /* free a pointer allocated by png_malloc(). In the default configuration, png_ptr is not used, but is passed in case it is needed. If ptr is NULL, return without taking any action. */ + void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { @@ -293,7 +293,7 @@ { #endif /* PNG_USER_MEM_SUPPORTED */ - if(png_ptr == NULL) return; + if (png_ptr == NULL || ptr == NULL) return; if (png_ptr->offset_table != NULL) { @@ -353,7 +353,7 @@ return (NULL); #ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) + if (malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -369,7 +369,7 @@ struct_ptr = (png_voidp)farmalloc(size); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); + struct_ptr = (png_voidp)halloc(size, 1); # else struct_ptr = (png_voidp)malloc(size); # endif @@ -398,7 +398,7 @@ if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) + if (free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -434,7 +434,7 @@ if (png_ptr == NULL || size == 0) return (NULL); - if(png_ptr->malloc_fn != NULL) + if (png_ptr->malloc_fn != NULL) ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); @@ -542,9 +542,9 @@ { png_voidp ptr; png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); - save_flags=png_ptr->flags; + save_flags = png_ptr->flags; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); png_ptr->flags=save_flags; @@ -560,7 +560,7 @@ size = (png_size_t)length; if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); + png_error(png_ptr, "Overflow in png_memcpy_check."); return(png_memcpy (s1, s2, size)); } @@ -573,7 +573,7 @@ size = (png_size_t)length; if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); + png_error(png_ptr, "Overflow in png_memset_check."); return (png_memset (s1, value, size)); @@ -587,10 +587,11 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; + if (png_ptr != NULL) + { + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; } } @@ -601,7 +602,7 @@ png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) return (NULL); return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ Modified: haiku/trunk/src/libs/png/pngpread.c =================================================================== --- haiku/trunk/src/libs/png/pngpread.c 2008-08-17 20:35:05 UTC (rev 27011) +++ haiku/trunk/src/libs/png/pngpread.c 2008-08-17 22:03:24 UTC (rev 27012) @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.26 [April 2, 2008] + * Last changed in libpng 1.2.30 [August 15, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -10,7 +10,6 @@ #define PNG_INTERNAL #include "png.h" - #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* push model modes */ @@ -28,7 +27,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size) { - if(png_ptr == NULL || info_ptr == NULL) return; + if (png_ptr == NULL || info_ptr == NULL) return; png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) @@ -43,7 +42,7 @@ void /* PRIVATE */ png_process_some_data(png_structp png_ptr, png_infop info_ptr) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: @@ -114,7 +113,7 @@ png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { @@ -210,22 +209,23 @@ } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) + if (png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) { + if (png_ptr->push_length != 13) + png_error(png_ptr, "Invalid IHDR length"); if (png_ptr->push_length + 4 > png_ptr->buffer_size) { - if (png_ptr->push_length != 13) - png_error(png_ptr, "Invalid IHDR length"); png_push_save_buffer(png_ptr); return; } @@ -565,7 +565,7 @@ { png_bytep ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; [... truncated: 5002 lines follow ...] From korli at mail.berlios.de Mon Aug 18 00:10:09 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 00:10:09 +0200 Subject: [Haiku-commits] r27013 - haiku/trunk/build/jam Message-ID: <200808172210.m7HMA94i012444@sheep.berlios.de> Author: korli Date: 2008-08-18 00:10:08 +0200 (Mon, 18 Aug 2008) New Revision: 27013 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27013&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added echo3g driver to the image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2008-08-17 22:03:24 UTC (rev 27012) +++ haiku/trunk/build/jam/HaikuImage 2008-08-17 22:10:08 UTC (rev 27013) @@ -123,7 +123,7 @@ Print\ To\ File Serial\ Port USB\ Port ; BEOS_ADD_ONS_SCREENSAVERS = Haiku IFS Spider ; -BEOS_ADD_ONS_DRIVERS_AUDIO = auich auvia emuxki ; #hda +BEOS_ADD_ONS_DRIVERS_AUDIO = auich auvia echo3g emuxki ; #hda BEOS_ADD_ONS_DRIVERS_GRAPHICS = $(X86_ONLY)radeon $(X86_ONLY)nvidia $(X86_ONLY)neomagic $(X86_ONLY)matrox $(X86_ONLY)intel_extreme $(X86_ONLY)s3 $(X86_ONLY)vesa #$(X86_ONLY)via #$(X86_ONLY)vmware From korli at mail.berlios.de Mon Aug 18 00:34:57 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 00:34:57 +0200 Subject: [Haiku-commits] r27014 - haiku/trunk/data/system/boot Message-ID: <200808172234.m7HMYvZm020402@sheep.berlios.de> Author: korli Date: 2008-08-18 00:34:56 +0200 (Mon, 18 Aug 2008) New Revision: 27014 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27014&view=rev Modified: haiku/trunk/data/system/boot/InstallerFinishScript Log: makebootable is now usable without absolute path Modified: haiku/trunk/data/system/boot/InstallerFinishScript =================================================================== --- haiku/trunk/data/system/boot/InstallerFinishScript 2008-08-17 22:10:08 UTC (rev 27013) +++ haiku/trunk/data/system/boot/InstallerFinishScript 2008-08-17 22:34:56 UTC (rev 27014) @@ -15,5 +15,5 @@ mkdir -p "$mount/var/tmp" -/bin/makebootable $mount +makebootable $mount From korli at mail.berlios.de Mon Aug 18 00:41:58 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 00:41:58 +0200 Subject: [Haiku-commits] r27015 - haiku/trunk/data/etc/fonts/ttfonts Message-ID: <200808172241.m7HMfwtd029036@sheep.berlios.de> Author: korli Date: 2008-08-18 00:41:03 +0200 (Mon, 18 Aug 2008) New Revision: 27015 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27015&view=rev Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-Bold.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-BoldOblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-ExtraLight.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-Oblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-Bold.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-BoldOblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-Oblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-Bold.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-BoldOblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-Oblique.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-Bold.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-BoldItalic.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-Italic.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-Bold.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-BoldItalic.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-Italic.ttf haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed.ttf Log: updated DejaVu fonts to to 2.26 Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-Bold.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-BoldOblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-ExtraLight.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans-Oblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSans.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-Bold.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-BoldOblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed-Oblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansCondensed.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-Bold.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-BoldOblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono-Oblique.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSansMono.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-Bold.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-BoldItalic.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif-Italic.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerif.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-Bold.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-BoldItalic.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed-Italic.ttf =================================================================== (Binary files differ) Modified: haiku/trunk/data/etc/fonts/ttfonts/DejaVuSerifCondensed.ttf =================================================================== (Binary files differ) From axeld at mail.berlios.de Mon Aug 18 10:39:46 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 10:39:46 +0200 Subject: [Haiku-commits] r27016 - haiku/trunk/build/scripts Message-ID: <200808180839.m7I8dkOC017345@sheep.berlios.de> Author: axeld Date: 2008-08-18 10:39:46 +0200 (Mon, 18 Aug 2008) New Revision: 27016 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27016&view=rev Modified: haiku/trunk/build/scripts/build_haiku_image Log: * Use -f (force) when copying, or else it may bail out if the target already exists -- this seems to happen only in case a specific name is given for the target, though, so it might well be a bug in the fs_shell as well. Seen when copying kernel.so to _KERNEL_ on a "update-all". Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2008-08-17 22:41:03 UTC (rev 27015) +++ haiku/trunk/build/scripts/build_haiku_image 2008-08-18 08:39:46 UTC (rev 27016) @@ -13,7 +13,7 @@ # dontClearImage # isVMwareImage # optionalPackageDescriptions -# +# # addattr # bfsShell # copyattr @@ -48,7 +48,7 @@ tPrefix=/myfs/ cd="$fsShellCommand cd" scd="$fsShellCommand cd" - cp="$fsShellCommand cp" + cp="$fsShellCommand cp -f" copyAttrs="$fsShellCommand cp -a" ln="$fsShellCommand ln" mkdir="$fsShellCommand mkdir" From sbenedetto at mail.berlios.de Mon Aug 18 11:40:46 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:40:46 +0200 Subject: [Haiku-commits] r27017 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180940.m7I9ek2n021585@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:40:42 +0200 (Mon, 18 Aug 2008) New Revision: 27017 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27017&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.h haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp Log: * Removed DirectoryIterator.{h,cpp} and included them in Icp.{h,cpp} * Porting Icb to new file cache system Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.cpp 2008-08-18 08:39:46 UTC (rev 27016) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.cpp 2008-08-18 09:40:42 UTC (rev 27017) @@ -9,19 +9,98 @@ #include "time.h" #include "AllocationDescriptorList.h" -#include "DirectoryIterator.h" #include "Utils.h" #include "Volume.h" -using namespace Udf; +status_t +DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) +{ + DEBUG_INIT_ETC("DirectoryIterator", + ("name: %p, length: %p, id: %p", name, length, id)); + + if (!id || !name || !length) + return B_BAD_VALUE; + + PRINT(("fPosition: %Ld\n", fPosition)); + PRINT(("Parent()->Length(): %Ld\n", Parent()->Length())); + + status_t error = B_OK; + if (fAtBeginning) { + sprintf(name, "."); + *length = 2; + *id = Parent()->Id(); + fAtBeginning = false; + } else { + + if (uint64(fPosition) >= Parent()->Length()) + RETURN(B_ENTRY_NOT_FOUND); + + uint8 data[kMaxFileIdSize]; + file_id_descriptor *entry = reinterpret_cast(data); + + uint32 block = 0; + off_t offset = fPosition; + + size_t entryLength = kMaxFileIdSize; + // First read in the static portion of the file id descriptor, + // then, based on the information therein, read in the variable + // length tail portion as well. + error = Parent()->Read(offset, entry, &entryLength, &block); + if (!error && entryLength >= sizeof(file_id_descriptor) + && entry->tag().init_check(block) == B_OK) { + PDUMP(entry); + offset += entry->total_length(); + + if (entry->is_parent()) { + sprintf(name, ".."); + *length = 3; + } else { + UdfString string(entry->id(), entry->id_length()); + PRINT(("id == `%s'\n", string.Utf8())); + DUMP(entry->icb()); + sprintf(name, "%s", string.Utf8()); + *length = string.Utf8Length(); + } + *id = to_vnode_id(entry->icb()); + } + + if (!error) + fPosition = offset; + } + + RETURN(error); +} + + +/* \brief Rewinds the iterator to point to the first entry in the directory. */ +void +DirectoryIterator::Rewind() +{ + fAtBeginning = true; + fPosition = 0; +} + + +// #pragma - Private methods + + +DirectoryIterator::DirectoryIterator(Icb *parent) + : + fAtBeginning(true), + fParent(parent), + fPosition(0) +{ +} + Icb::Icb(Volume *volume, long_address address) - : fVolume(volume) - , fData(volume) - , fInitStatus(B_NO_INIT) - , fId(to_vnode_id(address)) - , fFileEntry(&fData) - , fExtendedEntry(&fData) + : + fVolume(volume), + fData(volume), + fInitStatus(B_NO_INIT), + fId(to_vnode_id(address)), + fFileEntry(&fData), + fExtendedEntry(&fData) { DEBUG_INIT_ETC("Icb", ("volume: %p, address(block: %ld, " "partition: %d, length: %ld)", volume, address.block(), @@ -31,7 +110,7 @@ off_t block; error = fVolume->MapBlock(address, &block); if (!error) { - icb_header *header = reinterpret_cast(fData.SetTo(block)); + icb_header *header = (icb_header *)fData.SetTo(block); if (header->tag().id() == TAGID_FILE_ENTRY) { file_icb_entry *entry = reinterpret_cast(header); PDUMP(entry); @@ -49,25 +128,46 @@ fInitStatus = error; PRINT(("result: 0x%lx, `%s'\n", error, strerror(error))); } - + + status_t +Icb::GetDirectoryIterator(DirectoryIterator **iterator) +{ + status_t error = iterator ? B_OK : B_BAD_VALUE; + + if (!error) { + *iterator = new(std::nothrow) DirectoryIterator(this); + if (*iterator) + fIteratorList.Add(*iterator); + else + error = B_NO_MEMORY; + } + + return error; +} + + +status_t Icb::InitCheck() { return fInitStatus; } + time_t Icb::AccessTime() { - return make_time(FileEntry()->access_date_and_time()); + return make_time(_FileEntry()->access_date_and_time()); } + time_t Icb::ModificationTime() { - return make_time(FileEntry()->modification_date_and_time()); + return make_time(_FileEntry()->modification_date_and_time()); } + status_t Icb::Read(off_t pos, void *buffer, size_t *length, uint32 *block) { @@ -82,7 +182,7 @@ return B_OK; } - switch (IcbTag().descriptor_flags()) { + switch (_IcbTag().descriptor_flags()) { case ICB_DESCRIPTOR_TYPE_SHORT: { PRINT(("descriptor type: short\n")); AllocationDescriptorList list(this, ShortDescriptorAccessor(0)); @@ -96,7 +196,7 @@ RETURN(_Read(list, pos, buffer, length, block)); break; } - + case ICB_DESCRIPTOR_TYPE_EXTENDED: { PRINT(("descriptor type: extended\n")); // AllocationDescriptorList list(this, ExtendedDescriptorAccessor(0)); @@ -112,29 +212,13 @@ } default: - PRINT(("Invalid icb descriptor flags! (flags = %d)\n", IcbTag().descriptor_flags())); + PRINT(("Invalid icb descriptor flags! (flags = %d)\n", _IcbTag().descriptor_flags())); RETURN(B_BAD_VALUE); break; } } -status_t -Icb::GetDirectoryIterator(DirectoryIterator **iterator) -{ - status_t error = iterator ? B_OK : B_BAD_VALUE; - if (!error) { - *iterator = new(nothrow) DirectoryIterator(this); - if (*iterator) { - error = fIteratorList.PushBack(*iterator); - } else { - error = B_NO_MEMORY; - } - } - - return error; -} - status_t Icb::Find(const char *filename, ino_t *id) { Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.h 2008-08-18 08:39:46 UTC (rev 27016) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Icb.h 2008-08-18 09:40:42 UTC (rev 27017) @@ -1,41 +1,27 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com. + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_ICB_H #define _UDF_ICB_H -/*! \file Icb.h -*/ +/*! \file Icb.h */ -#ifndef _IMPEXP_KERNEL -# define _IMPEXP_KERNEL -#endif -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif +#include "UdfStructures.h" -#include "kernel_cpp.h" -#include "UdfDebug.h" +#include +#include #include "CachedBlock.h" -#include "UdfStructures.h" -#include "SinglyLinkedList.h" -namespace Udf { - class DirectoryIterator; +class Icb; class Volume; /*! \brief Abstract interface to file entry structure members that are not commonly accessible through file_icb_entry(). - + This is necessary, since we can't use virtual functions in the disk structure structs themselves, since we generally don't create disk structure objects by calling new, but @@ -46,86 +32,110 @@ */ class AbstractFileEntry { public: - virtual uint8* AllocationDescriptors() = 0; - virtual uint32 AllocationDescriptorsLength() = 0; + virtual uint8* AllocationDescriptors() = 0; + virtual uint32 AllocationDescriptorsLength() = 0; }; + template class FileEntry : public AbstractFileEntry { public: - FileEntry(CachedBlock *descriptorBlock = NULL); - void SetTo(CachedBlock *descriptorBlock); - virtual uint8* AllocationDescriptors(); - virtual uint32 AllocationDescriptorsLength(); + FileEntry(CachedBlock *descriptorBlock = NULL); + void SetTo(CachedBlock *descriptorBlock); + virtual uint8* AllocationDescriptors(); + virtual uint32 AllocationDescriptorsLength(); + private: - Descriptor* _Descriptor(); - - CachedBlock *fDescriptorBlock; + Descriptor *_Descriptor(); + CachedBlock *fDescriptorBlock; }; + +class DirectoryIterator : public SinglyLinkedListLinkImpl { +public: + + status_t GetNextEntry(char *name, uint32 *length, + ino_t *id); + + Icb *Parent() { return fParent; } + const Icb *Parent() const { return fParent; } + + void Rewind(); + +private: +friend class Icb; + + /* The following is called by Icb::GetDirectoryIterator() */ + DirectoryIterator(Icb *parent); + /* The following is called by Icb::~Icb() */ + void _Invalidate() { fParent = NULL; } + + bool fAtBeginning; + Icb *fParent; + off_t fPosition; +}; + + class Icb { public: - Icb(Volume *volume, long_address address); - status_t InitCheck(); - ino_t Id() { return fId; } - + Icb(Volume *volume, long_address address); + status_t InitCheck(); + ino_t Id() { return fId; } + // categorization - uint8 Type() { return IcbTag().file_type(); } - bool IsFile() { return InitCheck() == B_OK && Type() == ICB_TYPE_REGULAR_FILE; } - bool IsDirectory() { return InitCheck() == B_OK - && (Type() == ICB_TYPE_DIRECTORY || Type() == ICB_TYPE_STREAM_DIRECTORY); } - - uint32 Uid() { return 0; }//FileEntry()->uid(); } - uint32 Gid() { return 0; } - uint16 FileLinkCount() { return FileEntry()->file_link_count(); } - uint64 Length() { return FileEntry()->information_length(); } - mode_t Mode() { return (IsDirectory() ? S_IFDIR : S_IFREG) | S_IRUSR | S_IRGRP | S_IROTH; } - time_t AccessTime(); - time_t ModificationTime(); - - uint8 *AllocationDescriptors() { return AbstractEntry()->AllocationDescriptors(); } - uint32 AllocationDescriptorsSize() { return AbstractEntry()->AllocationDescriptorsLength(); } - - status_t Read(off_t pos, void *buffer, size_t *length, uint32 *block = NULL); - + uint8 Type() { return _IcbTag().file_type(); } + bool IsFile() { return Type() == ICB_TYPE_REGULAR_FILE; } + bool IsDirectory() { return (Type() == ICB_TYPE_DIRECTORY + || Type() == ICB_TYPE_STREAM_DIRECTORY); } + + uint32 Uid() { return _FileEntry()->uid(); } + uint32 Gid() { return 0; } + uint16 FileLinkCount() { return _FileEntry()->file_link_count(); } + uint64 Length() { return _FileEntry()->information_length(); } + mode_t Mode() { return (IsDirectory() ? S_IFDIR : S_IFREG) + | S_IRUSR | S_IRGRP | S_IROTH; } + time_t AccessTime(); + time_t ModificationTime(); + + uint8 *AllocationDescriptors() + { return _AbstractEntry()->AllocationDescriptors(); } + uint32 AllocationDescriptorsSize() + { return _AbstractEntry()->AllocationDescriptorsLength(); } + + status_t Read(off_t pos, void *buffer, size_t *length, + uint32 *block = NULL); + // for directories only - status_t GetDirectoryIterator(DirectoryIterator **iterator); - status_t Find(const char *filename, ino_t *id); - - Volume* GetVolume() const { return fVolume; } - + status_t GetDirectoryIterator(DirectoryIterator **iterator); + status_t Find(const char *filename, ino_t *id); + + Volume *GetVolume() const { return fVolume; } + private: - Icb(); // unimplemented - - descriptor_tag & Tag() { return (reinterpret_cast(fData.Block()))->tag(); } - icb_entry_tag& IcbTag() { return (reinterpret_cast(fData.Block()))->icb_tag(); } - AbstractFileEntry* AbstractEntry() { - DEBUG_INIT("Icb"); - return (Tag().id() == TAGID_EXTENDED_FILE_ENTRY) -// ? reinterpret_cast(fData.Block()) -// : reinterpret_cast(fData.Block())); - ? &fExtendedEntry - : &fFileEntry; - } - file_icb_entry* FileEntry() { return (reinterpret_cast(fData.Block())); } - extended_file_icb_entry& ExtendedEntry() { return *(reinterpret_cast(fData.Block())); } + AbstractFileEntry *_AbstractEntry() { return (_Tag().id() + == TAGID_EXTENDED_FILE_ENTRY) + ? &fExtendedEntry : &fFileEntry; } + descriptor_tag &_Tag() { return ((icb_header *)fData.Block())->tag(); } + icb_entry_tag &_IcbTag() { return ((icb_header *)fData.Block())->icb_tag(); } + file_icb_entry *_FileEntry() { return (file_icb_entry *)fData.Block(); } + extended_file_icb_entry &_ExtendedEntry() { return *(extended_file_icb_entry *)fData.Block(); } + template - status_t _Read(DescriptorList &list, off_t pos, void *buffer, size_t *length, uint32 *block); + status_t _Read(DescriptorList &list, off_t pos, + void *buffer, size_t *length, uint32 *block); - private: - Volume *fVolume; - CachedBlock fData; - status_t fInitStatus; - ino_t fId; - SinglyLinkedList fIteratorList; - /* [zooey]: gcc-2.95.3 requires the explicit namespace here, otherwise - it complains about a syntax error(!). This is most probably a bug. */ - Udf::FileEntry fFileEntry; - Udf::FileEntry fExtendedEntry; + Volume *fVolume; + CachedBlock fData; + status_t fInitStatus; + ino_t fId; + SinglyLinkedList fIteratorList; + FileEntry fFileEntry; + FileEntry fExtendedEntry; }; + /*! \brief Does the dirty work of reading using the given DescriptorList object to access the allocation descriptors properly. */ @@ -133,48 +143,47 @@ status_t Icb::_Read(DescriptorList &list, off_t pos, void *_buffer, size_t *length, uint32 *block) { - DEBUG_INIT_ETC("Icb", ("list: %p, pos: %Ld, buffer: %p, length: (%p)->%ld", - &list, pos, _buffer, length, (length ? *length : 0))); - if (!_buffer || !length) - RETURN(B_BAD_VALUE); - + TRACE(("Icb::_Read(): list: %p, pos: %Ld, buffer: %p, length: (%p)->%ld", + &list, pos, _buffer, length, (length ? *length : 0))); + uint64 bytesLeftInFile = uint64(pos) > Length() ? 0 : Length() - pos; size_t bytesLeft = (*length >= bytesLeftInFile) ? bytesLeftInFile : *length; size_t bytesRead = 0; - - Volume *volume = GetVolume(); - status_t error = B_OK; - uint8 *buffer = reinterpret_cast(_buffer); + + Volume *volume = GetVolume(); + status_t error = B_OK; + uint8 *buffer = (uint8 *)_buffer; bool isFirstBlock = true; - + while (bytesLeft > 0 && !error) { - - PRINT(("pos: %Ld\n", pos)); - PRINT(("bytesLeft: %ld\n", bytesLeft)); - + + TRACE(("Icb::_Read(): pos: %Ld\n, bytesLeft: %ld\n", pos, bytesLeft)); + long_address extent; bool isEmpty = false; error = list.FindExtent(pos, &extent, &isEmpty); if (!error) { - PRINT(("found extent for offset %Ld: (block: %ld, partition: %d, length: %ld, type: %d)\n", - pos, extent.block(), extent.partition(), extent.length(), extent.type())); - + TRACE(("Icb::_Read(): found extent for offset %Ld: (block: %ld, " + "partition: %d, length: %ld, type: %d)\n", pos, extent.block(), + extent.partition(), extent.length(), extent.type())); + switch (extent.type()) { case EXTENT_TYPE_RECORDED: isEmpty = false; break; - + case EXTENT_TYPE_ALLOCATED: case EXTENT_TYPE_UNALLOCATED: isEmpty = true; break; - + default: - PRINT(("Invalid extent type found: %d\n", extent.type())); + TRACE_ERROR(("Icb::_Read(): Invalid extent type " + "found: %d\n", extent.type())); error = B_ERROR; - break; + break; } - + if (!error) { // Note the unmapped first block of the total read in // the block output parameter if provided @@ -183,37 +192,40 @@ if (block) *block = extent.block(); } - - off_t blockOffset = pos - off_t((pos >> volume->BlockShift()) << volume->BlockShift()); + + off_t blockOffset = pos - off_t((pos >> volume->BlockShift()) + << volume->BlockShift()); size_t fullBlocksLeft = bytesLeft >> volume->BlockShift(); if (fullBlocksLeft > 0 && blockOffset == 0) { - PRINT(("reading full block (or more)\n")); - // Block aligned and at least one full block left. Read in using - // cached_read() calls. + TRACE(("Icb::_Read(): reading full block (or more)\n")); + // Block aligned and at least one full block left. Read + // in using cached_read() calls. off_t diskBlock; error = volume->MapBlock(extent, &diskBlock); if (!error) { - size_t fullBlockBytesLeft = fullBlocksLeft << volume->BlockShift(); + size_t fullBlockBytesLeft = + fullBlocksLeft << volume->BlockShift(); size_t readLength = fullBlockBytesLeft < extent.length() - ? fullBlockBytesLeft - : extent.length(); - + ? fullBlockBytesLeft : extent.length(); + if (isEmpty) { - PRINT(("reading %ld empty bytes as zeros\n", readLength)); + TRACE(("Icb::_Read(): reading %ld empty bytes " + "as zeros\n", readLength)); memset(buffer, 0, readLength); } else { off_t diskBlock; error = volume->MapBlock(extent, &diskBlock); - if (!error) { - PRINT(("reading %ld bytes from disk block %Ld using cached_read()\n", - readLength, diskBlock)); - error = cached_read(volume->Device(), diskBlock, buffer, - readLength >> volume->BlockShift(), - volume->BlockSize()); - } + if (!error) { + TRACE(("Icb::_Read(): reading %ld bytes from " + "disk block %Ld using cached_read()\n", + readLength, diskBlock)); + size_t length = readLength >> volume->BlockShift(); + error = file_cache_read(volume->BlockCache(), + NULL, pos, buffer, &length); + } } - + if (!error) { bytesLeft -= readLength; bytesRead += readLength; @@ -221,7 +233,7 @@ buffer += readLength; } } - + } else { PRINT(("partial block\n")); off_t partialOffset; @@ -251,15 +263,15 @@ if (!error) { PRINT(("reading %ld bytes from disk block %Ld using get_block()\n", partialLength, diskBlock)); - uint8 *data = (uint8*)get_block(volume->Device(), diskBlock, volume->BlockSize()); + uint8 *data = (uint8*)block_cache_get_etc((void*)volume->BlockCache(), diskBlock, 0, partialLength); error = data ? B_OK : B_BAD_DATA; if (!error) { memcpy(buffer, data+partialOffset, partialLength); - release_block(volume->Device(), diskBlock); + block_cache_put(volume->BlockCache(), diskBlock); } } } - + if (!error) { bytesLeft -= partialLength; bytesRead += partialLength; @@ -280,12 +292,14 @@ RETURN(error); } + template FileEntry::FileEntry(CachedBlock *descriptorBlock) : fDescriptorBlock(descriptorBlock) { } + template void FileEntry::SetTo(CachedBlock *descriptorBlock) @@ -293,6 +307,7 @@ fDescriptorBlock = descriptorBlock; } + template uint8* FileEntry::AllocationDescriptors() @@ -301,6 +316,7 @@ return descriptor ? descriptor->allocation_descriptors() : NULL; } + template uint32 FileEntry::AllocationDescriptorsLength() @@ -309,13 +325,13 @@ return descriptor ? descriptor->allocation_descriptors_length() : 0; } + template Descriptor* FileEntry::_Descriptor() { - return fDescriptorBlock ? reinterpret_cast(fDescriptorBlock->Block()) : NULL; + return fDescriptorBlock + ? (Descriptor *)fDescriptorBlock->Block() : NULL; } -}; // namespace Udf - #endif // _UDF_ICB_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-18 08:39:46 UTC (rev 27016) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-18 09:40:42 UTC (rev 27017) @@ -16,7 +16,6 @@ #include #include -#include "DirectoryIterator.h" #include "Icb.h" #include "Recognition.h" #include "Utils.h" From sbenedetto at mail.berlios.de Mon Aug 18 11:41:30 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:41:30 +0200 Subject: [Haiku-commits] r27018 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180941.m7I9fU62021709@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:41:29 +0200 (Mon, 18 Aug 2008) New Revision: 27018 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27018&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/udf/fsproto.h Log: * Removed fsproto.h Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/fsproto.h From sbenedetto at mail.berlios.de Mon Aug 18 11:43:14 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:43:14 +0200 Subject: [Haiku-commits] r27019 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180943.m7I9hElS022038@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:43:14 +0200 (Mon, 18 Aug 2008) New Revision: 27019 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27019&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/CachedBlock.h Log: * Update CachedBlock.h Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/CachedBlock.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/CachedBlock.h 2008-08-18 09:41:29 UTC (rev 27018) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/CachedBlock.h 2008-08-18 09:43:14 UTC (rev 27019) @@ -1,11 +1,9 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -// Based on the CachedBlock class from OpenBFS, -// Copyright (c) 2002 Axel D?rfler, axeld at pinc-software.de -//--------------------------------------------------------------------- +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net + * Copyright 2002, Axel D?rfler, axeld at pinc-software.de + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_CACHED_BLOCK_H #define _UDF_CACHED_BLOCK_H @@ -15,145 +13,133 @@ Axel D?rfler, axeld at pinc-software.de */ -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif +#include +#include -extern "C" { - #ifndef _IMPEXP_KERNEL - # define _IMPEXP_KERNEL - #endif - - #include "lock.h" - #include "cache.h" -} - -#include "kernel_cpp.h" #include "UdfDebug.h" - #include "UdfStructures.h" #include "Volume.h" -namespace Udf { - class CachedBlock { - public: - CachedBlock(Volume *volume); - CachedBlock(Volume *volume, off_t block, bool empty = false); - CachedBlock(CachedBlock *cached); - ~CachedBlock(); +public: + CachedBlock(Volume *volume); + CachedBlock(Volume *volume, off_t block); + CachedBlock(CachedBlock *cached); + ~CachedBlock(); - inline void Keep(); - inline void Unset(); - inline uint8 *SetTo(off_t block, bool empty = false); - inline uint8 *SetTo(long_address address, bool empty = false); - template - inline uint8* SetTo(Accessor &accessor, Descriptor &descriptor, - bool empty = false); + uint8 *Block() const { return fBlock; } + off_t BlockNumber() const { return fBlockNumber; } + uint32 BlockSize() const { return fVolume->BlockSize(); } + uint32 BlockShift() const { return fVolume->BlockShift(); } - uint8 *Block() const { return fBlock; } - off_t BlockNumber() const { return fBlockNumber; } - uint32 BlockSize() const { return fVolume->BlockSize(); } - uint32 BlockShift() const { return fVolume->BlockShift(); } + inline void Keep(); + inline void Unset(); - private: - CachedBlock(const CachedBlock &); // unimplemented - CachedBlock &operator=(const CachedBlock &); // unimplemented + inline uint8 *SetTo(off_t block); + inline uint8 *SetTo(off_t block, off_t base, size_t length); + inline uint8 *SetTo(long_address address); + template + inline uint8* SetTo(Accessor &accessor, Descriptor &descriptor); - protected: - Volume *fVolume; - off_t fBlockNumber; - uint8 *fBlock; +protected: + uint8 *fBlock; + off_t fBlockNumber; + Volume *fVolume; }; + inline CachedBlock::CachedBlock(Volume *volume) : - fVolume(volume), - fBlock(NULL) + fBlock(NULL), + fBlockNumber(0), + fVolume(volume) { } + inline -CachedBlock::CachedBlock(Volume *volume, off_t block, bool empty = false) +CachedBlock::CachedBlock(Volume *volume, off_t block) : - fVolume(volume), - fBlock(NULL) + fBlock(NULL), + fBlockNumber(0), + fVolume(volume) { - SetTo(block, empty); + SetTo(block); } + inline CachedBlock::CachedBlock(CachedBlock *cached) - : fVolume(cached->fVolume) - , fBlockNumber(cached->BlockNumber()) - , fBlock(cached->fBlock) + : + fBlock(cached->fBlock), + fBlockNumber(cached->BlockNumber()), + fVolume(cached->fVolume) { cached->Keep(); } + inline CachedBlock::~CachedBlock() { Unset(); } + inline void CachedBlock::Keep() { fBlock = NULL; } + inline void CachedBlock::Unset() { - DEBUG_INIT("CachedBlock"); if (fBlock) { - PRINT(("releasing block #%Ld\n", BlockNumber())); - release_block(fVolume->Device(), fBlockNumber); - } else { - PRINT(("no block to release\n")); + block_cache_put(fVolume->BlockCache(), fBlockNumber); + fBlock = NULL; } } -inline uint8 * -CachedBlock::SetTo(off_t block, bool empty = false) + +inline uint8* +CachedBlock::SetTo(off_t block) { - DEBUG_INIT_ETC("CachedBlock", ("block: %Ld, empty: %s", - block, (empty ? "true" : "false"))); + return SetTo(block, block, 1); +} + + +inline uint8* +CachedBlock::SetTo(off_t block, off_t base, size_t length) +{ Unset(); fBlockNumber = block; - PRINT(("getting block #%Ld\n", block)); - return fBlock = empty ? (uint8 *)get_empty_block(fVolume->Device(), block, BlockSize()) - : (uint8 *)get_block(fVolume->Device(), block, BlockSize()); + return fBlock = (uint8 *)block_cache_get_etc(fVolume->BlockCache(), + block, base, length); } + inline uint8 * -CachedBlock::SetTo(long_address address, bool empty = false) +CachedBlock::SetTo(long_address address) { off_t block; if (fVolume->MapBlock(address, &block) == B_OK) - return SetTo(block, empty); + return SetTo(block, block, 1); else return NULL; } template inline uint8* -CachedBlock::SetTo(Accessor &accessor, Descriptor &descriptor, bool empty = false) +CachedBlock::SetTo(Accessor &accessor, Descriptor &descriptor) { // Make a long_address out of the descriptor and call it a day long_address address; address.set_to(accessor.GetBlock(descriptor), - accessor.GetPartition(descriptor)); - return SetTo(address, empty); + accessor.GetPartition(descriptor)); + return SetTo(address); } -}; // namespace Udf - #endif // _UDF_CACHED_BLOCK_H - From sbenedetto at mail.berlios.de Mon Aug 18 11:44:48 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:44:48 +0200 Subject: [Haiku-commits] r27020 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180944.m7I9imvi022094@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:44:48 +0200 (Mon, 18 Aug 2008) New Revision: 27020 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27020&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/udf/cache.h Log: * delete unnecessary cache.h Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/cache.h From sbenedetto at mail.berlios.de Mon Aug 18 11:46:53 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:46:53 +0200 Subject: [Haiku-commits] r27021 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180946.m7I9krRI022237@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:46:53 +0200 (Mon, 18 Aug 2008) New Revision: 27021 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27021&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.h Log: * Removed Udf namespace * Renamed String to UdfString Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.h 2008-08-18 09:44:48 UTC (rev 27020) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.h 2008-08-18 09:46:53 UTC (rev 27021) @@ -10,57 +10,58 @@ #include -#include "kernel_cpp.h" #include "Array.h" #include "UdfDebug.h" -namespace Udf { +#include -/*! \brief String class that takes as input either a UTF8 string or a +#include +/*! \brief UdfString class that takes as input either a UTF8 string or a CS0 unicode string and then provides access to said string in both formats. For CS0 info, see: ECMA-167 1/7.2.2 (not very helpful), UDF-2.01 2.1.1 */ -class String { +class UdfString { public: - String(); - String(const char *utf8); - String(const char *cs0, uint32 length); + UdfString(); + UdfString(const char *utf8); + UdfString(const char *cs0, uint32 length); + template - String(const array &dString); - ~String(); + UdfString(const array &dString); + ~UdfString(); - void SetTo(const char *utf8); - void SetTo(const char *cs0, uint32 length); + void SetTo(const char *utf8); + void SetTo(const char *cs0, uint32 length); template - void SetTo(const array &dString); + void SetTo(const array &dString); template - String& operator=(const array &dString); + UdfString& operator=(const array &dString); - const char* Cs0() const { return fCs0String; } - const char* Utf8() const { return fUtf8String; } - uint32 Cs0Length() const { return fCs0Length; } - uint32 Utf8Length() const { return fUtf8String ? strlen(fUtf8String) : 0; } + const char *Cs0() const { return fCs0String; } + const char *Utf8() const { return fUtf8String; } + uint32 Cs0Length() const { return fCs0Length; } + uint32 Utf8Length() const { return fUtf8String ? strlen(fUtf8String) : 0; } private: - void _Clear(); + void _Clear(); - char *fCs0String; - uint32 fCs0Length; - char *fUtf8String; + char *fCs0String; + uint32 fCs0Length; + char *fUtf8String; }; -/*! \brief Creates a new String object from the given d-string. +/*! \brief Creates a new UdfString object from the given d-string. */ template -String::String(const array &dString) +UdfString::UdfString(const array &dString) : fCs0String(NULL) , fUtf8String(NULL) { - DEBUG_INIT_ETC("String", ("dString.length(): %ld", dString.length())); + DEBUG_INIT_ETC("UdfString", ("dString.length(): %ld", dString.length())); SetTo(dString); } @@ -72,7 +73,7 @@ */ template void -String::SetTo(const array &dString) +UdfString::SetTo(const array &dString) { uint8 dataLength = dString.length() == 0 ? 0 @@ -91,16 +92,11 @@ /*! \brief Assignment from a d-string. */ template -String& -String::operator=(const array &dString) +UdfString& +UdfString::operator=(const array &dString) { SetTo(dString); return *this; } - -}; // namespace UDF - - - #endif // _UDF_STRING_H From sbenedetto at mail.berlios.de Mon Aug 18 11:48:01 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:48:01 +0200 Subject: [Haiku-commits] r27022 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180948.m7I9m1uk022328@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:48:00 +0200 (Mon, 18 Aug 2008) New Revision: 27022 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27022&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.cpp Log: Ooops! Should have been part of previous commit Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.cpp 2008-08-18 09:46:53 UTC (rev 27021) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfString.cpp 2008-08-18 09:48:00 UTC (rev 27022) @@ -45,7 +45,7 @@ \param in Pointer to a C-String from which utf8 characters will be read. *in will be incremented to reflect the number of characters read, similarly to the - \c out parameter for Udf::unicode_to_utf8(). + \c out parameter for unicode_to_utf8(). \return The 4-byte unicode character, or **in if passed an invalid character, or 0 if passed any NULL pointers. @@ -91,35 +91,34 @@ return c; } -using namespace Udf; /*! \brief Creates an empty string object. */ -String::String() +UdfString::UdfString() : fCs0String(NULL) , fUtf8String(NULL) { } -/*! \brief Creates a new String object from the given Utf8 string. +/*! \brief Creates a new UdfString object from the given Utf8 string. */ -String::String(const char *utf8) +UdfString::UdfString(const char *utf8) : fCs0String(NULL) , fUtf8String(NULL) { SetTo(utf8); } -/*! \brief Creates a new String object from the given Cs0 string. +/*! \brief Creates a new UdfString object from the given Cs0 string. */ -String::String(const char *cs0, uint32 length) +UdfString::UdfString(const char *cs0, uint32 length) : fCs0String(NULL) , fUtf8String(NULL) { SetTo(cs0, length); } -String::~String() +UdfString::~UdfString() { DEBUG_INIT("String"); @@ -129,9 +128,9 @@ /*! \brief Assignment from a Utf8 string. */ void -String::SetTo(const char *utf8) +UdfString::SetTo(const char *utf8) { - DEBUG_INIT_ETC("String", ("utf8: `%s', strlen(utf8): %ld", utf8, + DEBUG_INIT_ETC("UdfString", ("utf8: `%s', strlen(utf8): %ld", utf8, utf8 ? strlen(utf8) : 0)); _Clear(); if (!utf8) { @@ -221,9 +220,9 @@ /*! \brief Assignment from a Cs0 string. */ void -String::SetTo(const char *cs0, uint32 length) +UdfString::SetTo(const char *cs0, uint32 length) { - DEBUG_INIT_ETC("String", ("cs0: %p, length: %ld", cs0, length)); + DEBUG_INIT_ETC("UdfString", ("cs0: %p, length: %ld", cs0, length)); _Clear(); if (length == 0) @@ -301,9 +300,9 @@ } void -String::_Clear() +UdfString::_Clear() { - DEBUG_INIT("String"); + DEBUG_INIT("UdfString"); delete [] fCs0String; fCs0String = NULL; From sbenedetto at mail.berlios.de Mon Aug 18 11:53:29 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 11:53:29 +0200 Subject: [Haiku-commits] r27023 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808180953.m7I9rT6i022614@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 11:53:28 +0200 (Mon, 18 Aug 2008) New Revision: 27023 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27023&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/Partition.h haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.h haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.h haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.h Log: * Replaced kernel_cpp.h with util/kernel_cpp.h * Removed Udf namespace * Clean up Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.cpp 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.cpp 2008-08-18 09:53:28 UTC (rev 27023) @@ -2,7 +2,6 @@ #define B_NOT_IMPLEMENTED B_ERROR -using namespace Udf; /*! \brief Creates a new MetadataPartition object. */ Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Partition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Partition.h 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Partition.h 2008-08-18 09:53:28 UTC (rev 27023) @@ -12,8 +12,6 @@ #include -namespace Udf { - /*! \brief Abstract base class for various UDF partition types. */ class Partition { @@ -24,6 +22,4 @@ // uint32 &physicalBlock, uint32 &physicalLength) = 0; }; -}; // namespace Udf - #endif // _UDF_PARTITION_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.h 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.h 2008-08-18 09:53:28 UTC (rev 27023) @@ -10,13 +10,11 @@ /*! \file PhysicalPartition.h */ -#include +#include #include "Partition.h" #include "UdfDebug.h" -namespace Udf { - /*! \brief Standard type 1 physical partition PhysicalPartitions map logical block numbers directly to physical @@ -39,6 +37,4 @@ uint32 fLength; }; -}; // namespace Udf - #endif // _UDF_PHYSICAL_PARTITION_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.h 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.h 2008-08-18 09:53:28 UTC (rev 27023) @@ -10,14 +10,12 @@ /*! \file SparablePartition.h */ -#include +#include #include "UdfStructures.h" #include "Partition.h" #include "UdfDebug.h" -namespace Udf { - /*! \brief Type 2 sparable partition Sparable partitions provide a defect-managed partition @@ -58,6 +56,4 @@ status_t fInitStatus; }; -}; // namespace Udf - #endif // _UDF_SPARABLE_PARTITION_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.cpp 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.cpp 2008-08-18 09:53:28 UTC (rev 27023) @@ -17,13 +17,12 @@ #include "UdfString.h" #include "Utils.h" -using namespace Udf; //---------------------------------------------------------------------- // Constants //---------------------------------------------------------------------- -const charspec Udf::kCs0CharacterSet(0, "OSTA Compressed Unicode"); +const charspec kCs0CharacterSet(0, "OSTA Compressed Unicode"); //const charspec kCs0Charspec = { _character_set_type: 0, // _character_set_info: "OSTA Compressed Unicode" // "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" @@ -31,30 +30,30 @@ // }; // Volume structure descriptor ids -const char* Udf::kVSDID_BEA = "BEA01"; -const char* Udf::kVSDID_TEA = "TEA01"; -const char* Udf::kVSDID_BOOT = "BOOT2"; -const char* Udf::kVSDID_ISO = "CD001"; -const char* Udf::kVSDID_ECMA167_2 = "NSR02"; -const char* Udf::kVSDID_ECMA167_3 = "NSR03"; -const char* Udf::kVSDID_ECMA168 = "CDW02"; +const char* kVSDID_BEA = "BEA01"; +const char* kVSDID_TEA = "TEA01"; +const char* kVSDID_BOOT = "BOOT2"; +const char* kVSDID_ISO = "CD001"; +const char* kVSDID_ECMA167_2 = "NSR02"; +const char* kVSDID_ECMA167_3 = "NSR03"; +const char* kVSDID_ECMA168 = "CDW02"; // entity_ids -const entity_id Udf::kMetadataPartitionMapId(0, "*UDF Metadata Partition"); -const entity_id Udf::kSparablePartitionMapId(0, "*UDF Sparable Partition"); -const entity_id Udf::kVirtualPartitionMapId(0, "*UDF Virtual Partition"); -const entity_id Udf::kImplementationId(0, "*OpenBeOS UDF", implementation_id_suffix(OS_BEOS, BEOS_GENERIC)); -const entity_id Udf::kPartitionContentsId1xx(0, "+NSR02"); -const entity_id Udf::kPartitionContentsId2xx(0, "+NSR03"); -const entity_id Udf::kLogicalVolumeInfoId150(0, "*UDF LV Info", udf_id_suffix(0x0150, OS_BEOS, BEOS_GENERIC)); -const entity_id Udf::kLogicalVolumeInfoId201(0, "*UDF LV Info", udf_id_suffix(0x0201, OS_BEOS, BEOS_GENERIC)); -const entity_id Udf::kDomainId150(0, "*OSTA UDF Compliant", domain_id_suffix(0x0150, +const entity_id kMetadataPartitionMapId(0, "*UDF Metadata Partition"); +const entity_id kSparablePartitionMapId(0, "*UDF Sparable Partition"); +const entity_id kVirtualPartitionMapId(0, "*UDF Virtual Partition"); +const entity_id kImplementationId(0, "*OpenBeOS UDF", implementation_id_suffix(OS_BEOS, BEOS_GENERIC)); +const entity_id kPartitionContentsId1xx(0, "+NSR02"); +const entity_id kPartitionContentsId2xx(0, "+NSR03"); +const entity_id kLogicalVolumeInfoId150(0, "*UDF LV Info", udf_id_suffix(0x0150, OS_BEOS, BEOS_GENERIC)); +const entity_id kLogicalVolumeInfoId201(0, "*UDF LV Info", udf_id_suffix(0x0201, OS_BEOS, BEOS_GENERIC)); +const entity_id kDomainId150(0, "*OSTA UDF Compliant", domain_id_suffix(0x0150, DF_HARD_WRITE_PROTECT)); -const entity_id Udf::kDomainId201(0, "*OSTA UDF Compliant", domain_id_suffix(0x0201, +const entity_id kDomainId201(0, "*OSTA UDF Compliant", domain_id_suffix(0x0201, DF_HARD_WRITE_PROTECT)); //! crc 010041 table, as generated by crc_table.cpp -const uint16 Udf::kCrcTable[256] = { +const uint16 kCrcTable[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, @@ -89,7 +88,7 @@ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; -const uint32 Udf::kLogicalVolumeDescriptorBaseSize = sizeof(logical_volume_descriptor) +const uint32 kLogicalVolumeDescriptorBaseSize = sizeof(logical_volume_descriptor) - (UDF_MAX_PARTITION_MAPS * UDF_MAX_PARTITION_MAP_SIZE); @@ -98,7 +97,7 @@ // Helper functions //---------------------------------------------------------------------- -const char *Udf::tag_id_to_string(tag_id id) +const char *tag_id_to_string(tag_id id) { switch (id) { case TAGID_UNDEFINED: @@ -532,7 +531,7 @@ PRINT(("location (in structure) == %ld\n", location())); if (calculateCrc) { PRINT(("crc (calculated) == %d\n", - Udf::calculate_crc(reinterpret_cast(this)+sizeof(descriptor_tag), + calculate_crc(reinterpret_cast(this)+sizeof(descriptor_tag), crc_length()))) } else { PRINT(("crc (calculated) == (not calculated)\n")); @@ -552,7 +551,7 @@ } // crc if (!error && calculateCrc) { - uint16 _crc = Udf::calculate_crc(reinterpret_cast(this) + uint16 _crc = calculate_crc(reinterpret_cast(this) + sizeof(descriptor_tag), crc_length()); error = _crc == crc() ? B_OK : B_NO_INIT; } @@ -568,7 +567,7 @@ { DUMP_INIT("primary_volume_descriptor"); - String string; + UdfString string; PRINT(("tag:\n")); DUMP(tag()); @@ -629,7 +628,7 @@ void logical_volume_info::dump() const { - String string; + UdfString string; DUMP_INIT("logical_volume_information"); PRINT(("character_set:\n")); DUMP(character_set()); @@ -666,7 +665,7 @@ // partition_descriptor //---------------------------------------------------------------------- -const uint8 Udf::kMaxPartitionDescriptors = 2; +const uint8 kMaxPartitionDescriptors = 2; void partition_descriptor::dump() const @@ -704,7 +703,7 @@ PRINT(("vds_number: %ld\n", vds_number())); PRINT(("character_set:\n")); DUMP(character_set()); - String string(logical_volume_identifier()); + UdfString string(logical_volume_identifier()); PRINT(("logical_volume_identifier: `%s'\n", string.Utf8())); PRINT(("logical_block_size: %ld\n", logical_block_size())); PRINT(("domain_id:\n")); @@ -957,7 +956,7 @@ PRINT(("icb:\n")); DUMP(icb()); PRINT(("implementation_use_length: %d\n", is_parent())); - String fileId(id()); + UdfString fileId(id()); PRINT(("id: `%s'", fileId.Utf8())); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.h 2008-08-18 09:48:00 UTC (rev 27022) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.h 2008-08-18 09:53:28 UTC (rev 27023) @@ -10,14 +10,12 @@ /*! \file VirtualPartition.h */ -#include +#include #include "Partition.h" #include "PhysicalPartition.h" #include "UdfDebug.h" -namespace Udf { - /*! \brief Type 2 virtual partition VirtualPartitions add an extra layer of indirection between logical @@ -41,6 +39,4 @@ PhysicalPartition fPhysicalPartition; }; -}; // namespace Udf - #endif // _UDF_VIRTUAL_PARTITION_H From sbenedetto at mail.berlios.de Mon Aug 18 12:01:28 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 12:01:28 +0200 Subject: [Haiku-commits] r27024 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808181001.m7IA1SwH023812@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 12:01:27 +0200 (Mon, 18 Aug 2008) New Revision: 27024 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27024&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.h Log: * Partially ported Volume.cpp. Some stuff is still comment out. Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.cpp 2008-08-18 09:53:28 UTC (rev 27023) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.cpp 2008-08-18 10:01:27 UTC (rev 27024) @@ -1,11 +1,9 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -// Mad props to Axel D?rfler and his BFS implementation, from which -// this UDF implementation draws much influence (and a little code :-P). -//---------------------------------------------------------------------- +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ + #include "Volume.h" #include "Icb.h" @@ -13,19 +11,19 @@ #include "PhysicalPartition.h" #include "Recognition.h" -using namespace Udf; -/*! \brief Creates an unmounted volume with the given id. -*/ -Volume::Volume(nspace_id id) - : fId(id) - , fDevice(-1) - , fMounted(false) - , fOffset(0) - , fLength(0) - , fBlockSize(0) - , fBlockShift(0) - , fRootIcb(NULL) +/*! \brief Creates an unmounted volume with the given id. */ +Volume::Volume(fs_volume *fsVolume) + : + fBlockCache(NULL), + fBlockShift(0), + fBlockSize(0), + fDevice(-1), + fFSVolume(fsVolume), + fLength(0), + fMounted(false), + fOffset(0), + fRootIcb(NULL) { for (int i = 0; i < UDF_MAX_PARTITION_MAPS; i++) fPartitions[i] = NULL; @@ -39,15 +37,15 @@ /*! \brief Attempts to mount the given device. \param volumeStart The block on the given device whereat the volume begins. - \param volumeLength The block length of the volume on the given device. + \param volumeLength The block numBlocks of the volume on the given device. */ status_t -Volume::Mount(const char *deviceName, off_t offset, off_t length, - uint32 blockSize, uint32 flags) +Volume::Mount(const char *deviceName, off_t offset, off_t numBlocks, + uint32 blockSize, uint32 flags) { DEBUG_INIT_ETC("Volume", - ("deviceName: `%s', offset: %Ld, length: %Ld, blockSize: %ld, " - "flags: %ld", deviceName, offset, length, blockSize, flags)); + ("deviceName: `%s', offset: %Ld, numBlocks: %Ld, blockSize: %ld, " + "flags: %ld", deviceName, offset, numBlocks, blockSize, flags)); if (!deviceName) RETURN(B_BAD_VALUE); if (Mounted()) { @@ -64,7 +62,7 @@ // If the device is actually a normal file, try to disable the cache // for the file in the parent filesystem -#if _KERNEL_MODE +#if 0 // _KERNEL_MODE struct stat stat; error = fstat(device, &stat) < 0 ? B_ERROR : B_OK; if (!error) { @@ -75,19 +73,19 @@ #endif logical_volume_descriptor logicalVolumeDescriptor; - partition_descriptor partitionDescriptors[Udf::kMaxPartitionDescriptors]; + partition_descriptor partitionDescriptors[kMaxPartitionDescriptors]; uint8 partitionDescriptorCount; uint32 blockShift; // Run through the volume recognition and descriptor sequences to // see if we have a potentially valid UDF volume on our hands - error = udf_recognize(device, offset, length, blockSize, blockShift, - logicalVolumeDescriptor, partitionDescriptors, - partitionDescriptorCount); + //error = udf_recognize(device, offset, numBlocks, blockSize, blockShift, + // logicalVolumeDescriptor, partitionDescriptors, + // partitionDescriptorCount); // Set up the block cache if (!error) - error = init_cache_for_device(device, length); + fBlockCache = block_cache_create(device, numBlocks, blockSize, IsReadOnly()); int physicalCount = 0; int virtualCount = 0; @@ -128,7 +126,7 @@ error = partition ? B_OK : B_NO_MEMORY; if (!error) { PRINT(("Adding PhysicalPartition(number: %d, start: %ld, " - "length: %ld)\n", map->partition_number(), + "numBlocks: %ld)\n", map->partition_number(), descriptor->start(), descriptor->length())); error = _SetPartition(i, partition); if (!error) @@ -197,7 +195,7 @@ if (!error) { fDevice = device; fOffset = offset; - fLength = length; + fLength = numBlocks; fBlockSize = blockSize; fBlockShift = blockShift; } @@ -242,7 +240,7 @@ error = fRootIcb ? fRootIcb->InitCheck() : B_NO_MEMORY; } if (!error) { - error = new_vnode(Id(), RootIcb()->Id(), (void*)RootIcb()); + //error = new_vnode(fFSVolume->Id(), RootIcb()->Id(), (void*)RootIcb()); if (error) { PRINT(("Error creating vnode for root icb! " "error = 0x%lx, `%s'\n", error, @@ -301,9 +299,9 @@ Volume::_Unset() { DEBUG_INIT("Volume"); - fId = 0; + fFSVolume->id = 0; if (fDevice >= 0) { - remove_cached_device_blocks(fDevice, NO_WRITES); + block_cache_delete(fBlockCache, true); close(fDevice); } fDevice = -1; @@ -340,10 +338,9 @@ /*! \brief Returns the partition associated with the given number, or NULL if no such partition exists or the number is invalid. */ -Udf::Partition* +Partition* Volume::_GetPartition(uint number) { return (number < UDF_MAX_PARTITION_MAPS) ? fPartitions[number] : NULL; } - Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.h 2008-08-18 09:53:28 UTC (rev 27023) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Volume.h 2008-08-18 10:01:27 UTC (rev 27024) @@ -1,90 +1,74 @@ -//---------------------------------------------------------------------- -// This software is part of the OpenBeOS distribution and is covered -// by the OpenBeOS license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler at dauwalder.net -// Mad props to Axel D?rfler and his BFS implementation, from which -// this UDF implementation draws much influence (and a little code :-P). -//--------------------------------------------------------------------- +/* + * Copyright 2008, Salvatore Benedetto, salvatore.benedetto at gmail.com + * Copyright 2003, Tyler Dauwalder, tyler at dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_VOLUME_H #define _UDF_VOLUME_H -/*! \file Volume.h -*/ +/*! \file Volume.h */ +#include +#include #include -#ifndef _IMPEXP_KERNEL -# define _IMPEXP_KERNEL -#endif -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif +#include -#include "kernel_cpp.h" -#include "UdfDebug.h" +#include #include "UdfString.h" #include "UdfStructures.h" #include "Partition.h" -namespace Udf { - class Icb; class Volume { public: - // Construction/destruction - Volume(nspace_id id); - ~Volume(); - - // Mounting/unmounting - status_t Mount(const char *deviceName, off_t offset, off_t length, - uint32 blockSize, uint32 flags); - status_t Unmount(); - + Volume(fs_volume *volume); + ~Volume(); + + status_t Mount(const char *device, off_t offset, off_t length, + uint32 blockSize, uint32 flags); + status_t Unmount(); + + bool IsReadOnly() { return true; } + // Address mapping - status_t MapBlock(long_address address, off_t *mappedBlock); - status_t MapExtent(long_address logicalExtent, extent_address &physicalExtent); + status_t MapBlock(long_address address, off_t *mappedBlock); + status_t MapExtent(long_address logicalExtent, + extent_address &physicalExtent); // Miscellaneous info - const char *Name() const; - int Device() const { return fDevice; } - nspace_id Id() const { return fId; } - off_t Offset() const { return fOffset; } - off_t Length() const { return fLength; } - uint32 BlockSize() const { return fBlockSize; } - uint32 BlockShift() const { return fBlockShift; } - bool Mounted() const { return fMounted; } - Icb* RootIcb() { return fRootIcb; } - + const char *Name() const; + int Device() const { return fDevice; } + dev_t ID() const { return fFSVolume ? fFSVolume->id : -1; } + fs_volume *FSVolume() const { return fFSVolume; } + off_t Offset() const { return fOffset; } + off_t Length() const { return fLength; } + void *BlockCache() {return fBlockCache; } + uint32 BlockSize() const { return fBlockSize; } + uint32 BlockShift() const { return fBlockShift; } + bool Mounted() const { return fMounted; } + Icb* RootIcb() { return fRootIcb; } + private: - Volume(); // unimplemented - Volume(const Volume &ref); // unimplemented - Volume& operator=(const Volume &ref); // unimplemented + void _Unset(); - void _Unset(); + status_t _SetPartition(uint number, Partition *partition); + Partition* _GetPartition(uint number); - status_t _SetPartition(uint number, Partition *partition); - Partition* _GetPartition(uint number); - private: - nspace_id fId; - int fDevice; - bool fMounted; - off_t fOffset; - off_t fLength; - uint32 fBlockSize; - uint32 fBlockShift; - Partition *fPartitions[UDF_MAX_PARTITION_MAPS]; - Icb *fRootIcb; // Destroyed by vfs via callback to release_node() - String fName; + void *fBlockCache; + uint32 fBlockShift; + uint32 fBlockSize; + int fDevice; + fs_volume *fFSVolume; + off_t fLength; + bool fMounted; + UdfString fName; + off_t fOffset; + Partition *fPartitions[UDF_MAX_PARTITION_MAPS]; + Icb *fRootIcb; // Destroyed by vfs via callback to put_node() }; -}; // namespace Udf - #endif // _UDF_VOLUME_H From sbenedetto at mail.berlios.de Mon Aug 18 12:02:50 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 12:02:50 +0200 Subject: [Haiku-commits] r27025 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808181002.m7IA2oU5024154@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 12:02:50 +0200 (Mon, 18 Aug 2008) New Revision: 27025 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27025&view=rev Removed: haiku/trunk/src/add-ons/kernel/file_systems/udf/lock.h Log: * Remove unnecessary file Deleted: haiku/trunk/src/add-ons/kernel/file_systems/udf/lock.h From sbenedetto at mail.berlios.de Mon Aug 18 12:11:45 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 12:11:45 +0200 Subject: [Haiku-commits] r27026 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808181011.m7IABjB2025759@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 12:11:44 +0200 (Mon, 18 Aug 2008) New Revision: 27026 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27026&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.h Log: * Removed udf_recognize as it has been moved to kernel_interface.cpp Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.cpp 2008-08-18 10:02:50 UTC (rev 27025) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.cpp 2008-08-18 10:11:44 UTC (rev 27026) @@ -4,8 +4,9 @@ #include "MemoryChunk.h" #include "Utils.h" -using namespace Udf; +#include + //------------------------------------------------------------------------------ // forward declarations //------------------------------------------------------------------------------ @@ -36,7 +37,7 @@ //------------------------------------------------------------------------------ status_t -Udf::udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, +udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, uint32 &blockShift, logical_volume_descriptor &logicalVolumeDescriptor, partition_descriptor partitionDescriptors[], uint8 &partitionDescriptorCount) @@ -76,27 +77,6 @@ RETURN(error); } -status_t -Udf::udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, - char *volumeName) -{ - DEBUG_INIT_ETC(NULL, ("device: %d, offset: %Ld, length: %Ld, " - "blockSize: %ld, volumeName: %p", device, offset, length, - blockSize, volumeName)); - logical_volume_descriptor logicalVolumeDescriptor; - partition_descriptor partitionDescriptors[Udf::kMaxPartitionDescriptors]; - uint8 partitionDescriptorCount; - uint32 blockShift; - status_t error = udf_recognize(device, offset, length, blockSize, blockShift, - logicalVolumeDescriptor, partitionDescriptors, - partitionDescriptorCount); - if (!error && volumeName) { - String name(logicalVolumeDescriptor.logical_volume_identifier()); - strcpy(volumeName, name.Utf8()); - } - RETURN(error); -} - //------------------------------------------------------------------------------ // local functions //------------------------------------------------------------------------------ @@ -344,7 +324,7 @@ // If we didn't find a duplicate, see if we have any open descriptor // spaces left. if (!foundDuplicate) { - if (num < Udf::kMaxPartitionDescriptors) { + if (num < kMaxPartitionDescriptors) { // At least one more partition descriptor allowed partitionDescriptors[num] = *partition; uniquePartitions++; @@ -546,4 +526,3 @@ error = highestMinimumUDFReadRevision <= UDF_MAX_READ_REVISION ? B_OK : B_ERROR; RETURN(error); } - Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.h 2008-08-18 10:02:50 UTC (rev 27025) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Recognition.h 2008-08-18 10:11:44 UTC (rev 27026) @@ -13,16 +13,10 @@ #include "UdfStructures.h" #include "UdfDebug.h" -namespace Udf { - status_t udf_recognize(int device, off_t offset, off_t length, uint32 blockSize, uint32 &blockShift, logical_volume_descriptor &logicalVolumeDescriptor, partition_descriptor partitionDescriptors[], uint8 &partitionDescriptorCount); -status_t udf_recognize(int device, off_t offset, off_t length, - uint32 blockSize, char *volumeName); -} // namespace Udf - #endif // _UDF_RECOGNITION_H From sbenedetto at mail.berlios.de Mon Aug 18 12:13:58 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 12:13:58 +0200 Subject: [Haiku-commits] r27027 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808181013.m7IADwDN026008@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 12:13:57 +0200 (Mon, 18 Aug 2008) New Revision: 27027 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27027&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Array.h haiku/trunk/src/add-ons/kernel/file_systems/udf/MemoryChunk.h haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.h haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.cpp haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.h haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.h haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.cpp Log: * Replaced kernel_cpp.h with util/kernel_cpp.h * Removed Udf namespace * Minor clean up Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Array.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Array.h 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Array.h 2008-08-18 10:13:57 UTC (rev 27027) @@ -8,12 +8,11 @@ #ifndef _UDF_ARRAY_H #define _UDF_ARRAY_H -#include "kernel_cpp.h" #include "SupportDefs.h" #include "UdfDebug.h" -namespace Udf { +#include /*! \brief Slightly more typesafe static array type than built-in arrays, with array length information stored implicitly (i.e. consuming no @@ -87,7 +86,4 @@ uint8 data[arrayLength]; }; - -}; // namespace UDF - #endif // _UDF_ARRAY_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/MemoryChunk.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/MemoryChunk.h 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/MemoryChunk.h 2008-08-18 10:13:57 UTC (rev 27027) @@ -10,10 +10,8 @@ #include -#include "kernel_cpp.h" +#include -namespace Udf { - /*! Simple class to encapsulate the boring details of allocating and deallocating a chunk of memory. @@ -67,6 +65,4 @@ uint8 fData[size]; }; -}; // namespace Udf - #endif // _UDF_MEMORY_CHUNK_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.h 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/MetadataPartition.h 2008-08-18 10:13:57 UTC (rev 27027) @@ -10,13 +10,11 @@ /*! \file MetadataPartition.h */ -#include +#include #include "Partition.h" #include "UdfDebug.h" -namespace Udf { - /*! \brief Type 2 metadata partition Metadata partitions allow for clustering of metadata (ICBs, directory @@ -46,6 +44,4 @@ status_t fInitStatus; }; -}; // namespace Udf - #endif // _UDF_METADATA_PARTITION_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/PhysicalPartition.cpp 2008-08-18 10:13:57 UTC (rev 27027) @@ -2,7 +2,6 @@ #define B_NOT_IMPLEMENTED B_ERROR -using namespace Udf; /*! \brief Creates a new PhysicalPartition object. */ Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/SparablePartition.cpp 2008-08-18 10:13:57 UTC (rev 27027) @@ -2,7 +2,6 @@ #define B_NOT_IMPLEMENTED B_ERROR -using namespace Udf; /*! \brief Creates a new SparablePartition object. */ Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.cpp 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.cpp 2008-08-18 10:13:57 UTC (rev 27027) @@ -14,6 +14,7 @@ #include "UdfDebug.h" #include +#include #include #include Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.h 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfDebug.h 2008-08-18 10:13:57 UTC (rev 27027) @@ -47,7 +47,7 @@ //# define __out printf #endif -#include "kernel_cpp.h" +#include class DebugHelper; @@ -230,6 +230,7 @@ #endif // ifdef DEBUG else #define TRACE(x) DBG(dprintf x) +#define TRACE_ERROR(x) DBG(dprintf x) // These macros turn on or off extensive and generally unnecessary // debugging output regarding table of contents parsing Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.h 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/UdfStructures.h 2008-08-18 10:13:57 UTC (rev 27027) @@ -12,11 +12,12 @@ #include #include -#include "kernel_cpp.h" #include "UdfDebug.h" #include "Array.h" +#include + /*! \file UdfStructures.h \brief UDF on-disk data structure declarations @@ -42,8 +43,6 @@ - Possible test disc image generator (?) */ -namespace Udf { - //---------------------------------------------------------------------- // ECMA-167 Part 1 //---------------------------------------------------------------------- @@ -615,7 +614,7 @@ // crc_length, based off provided descriptor set_crc_length(size - sizeof(descriptor_tag)); // crc - uint16 crc = Udf::calculate_crc(reinterpret_cast(this) + uint16 crc = calculate_crc(reinterpret_cast(this) + sizeof(descriptor_tag), crc_length()); set_crc(crc); // checksum (which depends on the other two values) @@ -2198,7 +2197,5 @@ }; -}; // namespace Udf - #endif // _UDF_DISK_STRUCTURES_H Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.cpp 2008-08-18 10:11:44 UTC (rev 27026) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/VirtualPartition.cpp 2008-08-18 10:13:57 UTC (rev 27027) @@ -2,7 +2,6 @@ #define B_NOT_IMPLEMENTED B_ERROR -using namespace Udf; /*! \brief Creates a new VirtualPartition object. From sbenedetto at mail.berlios.de Mon Aug 18 12:17:08 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 12:17:08 +0200 Subject: [Haiku-commits] r27028 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808181017.m7IAH8JX026307@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 12:17:08 +0200 (Mon, 18 Aug 2008) New Revision: 27028 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27028&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Jamfile Log: * Update Jamfile Udf is now compilable, although probably not working. I'll post on the kernel mailing list as I'm having trouble to get it loaded. Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/Jamfile 2008-08-18 10:13:57 UTC (rev 27027) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/Jamfile 2008-08-18 10:17:08 UTC (rev 27028) @@ -12,26 +12,14 @@ KEEP_WRONG_DIRENT_RECLEN ; - defines += COMPILE_FOR_R5 ; - - if $(DEBUG) = 0 { - # the gcc on BeOS doesn't compile BFS correctly with -O2 or more - OPTIM = -O1 ; - } - defines = [ FDefines $(defines) ] ; SubDirCcFlags $(defines) -Wall -Wno-multichar ; SubDirC++Flags $(defines) -Wall -Wno-multichar ; } -UsePrivateHeaders kernel ; # For kernel_cpp.cpp -UsePrivateHeaders [ FDirName kernel util ] ; # For all the UDF source files +UsePrivateKernelHeaders ; KernelAddon udf : - kernel_cpp.cpp - udf.cpp - - DirectoryIterator.cpp DString.cpp Icb.cpp MetadataPartition.cpp @@ -44,8 +32,10 @@ Utils.cpp VirtualPartition.cpp Volume.cpp -; + kernel_interface.cpp + ; + SEARCH on [ FGristFiles kernel_cpp.cpp ] = [ FDirName $(HAIKU_TOP) src system kernel util ] ; @@ -66,4 +56,4 @@ # restore original optimization level OPTIM = $(oldOPTIM) ; -SubInclude HAIKU_TOP src add-ons kernel file_systems udf drive_setup_addon ; +#SubInclude HAIKU_TOP src add-ons kernel file_systems udf drive_setup_addon ; From axeld at mail.berlios.de Mon Aug 18 13:02:12 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:02:12 +0200 Subject: [Haiku-commits] r27029 - in haiku/trunk/src/add-ons/kernel: drivers/disk/scsi/scsi_disk generic/scsi_periph Message-ID: <200808181102.m7IB2CSH000704@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:02:05 +0200 (Mon, 18 Aug 2008) New Revision: 27029 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27029&view=rev Removed: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.h Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h Log: * Removed icon support from scsi_periph. * Removed B_GET_ICON support from scsi_disk, and scsi_cd. This won't be necessary anymore soon. Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-18 10:17:08 UTC (rev 27028) +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp 2008-08-18 11:02:05 UTC (rev 27029) @@ -370,10 +370,6 @@ return user_memcpy(buffer, &iconData, sizeof(device_icon)); } - case B_GET_ICON: - return sSCSIPeripheral->get_icon(info->removable - ? icon_type_floppy : icon_type_disk, (device_icon *)buffer); - case B_EJECT_DEVICE: case B_SCSI_EJECT: return load_eject(info, false); Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile 2008-08-18 10:17:08 UTC (rev 27028) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile 2008-08-18 11:02:05 UTC (rev 27029) @@ -10,7 +10,6 @@ KernelAddon scsi_periph : block.cpp - device_icons.cpp device.cpp error_handling.cpp handle.cpp Deleted: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.cpp Deleted: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.h Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp 2008-08-18 10:17:08 UTC (rev 27028) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp 2008-08-18 11:02:05 UTC (rev 27029) @@ -139,11 +139,9 @@ periph_check_error, periph_send_start_stop, periph_get_media_status, + periph_synchronize_cache, - periph_compose_device_name, - periph_get_icon, - - periph_synchronize_cache + periph_compose_device_name }; scsi_periph_interface *modules[] = { Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h =================================================================== --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h 2008-08-18 10:17:08 UTC (rev 27028) +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h 2008-08-18 11:02:05 UTC (rev 27029) @@ -105,10 +105,6 @@ uchar cdb_len, void *data, size_t data_len, int ccb_flags); -// device_icons.c - -status_t periph_get_icon(icon_type type, device_icon *data); - // sync.c err_res periph_synchronize_cache(scsi_periph_device_info *device, From axeld at mail.berlios.de Mon Aug 18 13:03:04 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:03:04 +0200 Subject: [Haiku-commits] r27030 - haiku/trunk/headers/private/drivers Message-ID: <200808181103.m7IB34gI002126@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:03:03 +0200 (Mon, 18 Aug 2008) New Revision: 27030 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27030&view=rev Modified: haiku/trunk/headers/private/drivers/scsi_periph.h Log: * Build fix: this should have been part of the last commit. Modified: haiku/trunk/headers/private/drivers/scsi_periph.h =================================================================== --- haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-18 11:02:05 UTC (rev 27029) +++ haiku/trunk/headers/private/drivers/scsi_periph.h 2008-08-18 11:03:03 UTC (rev 27030) @@ -47,14 +47,6 @@ res; \ }) -// device icon type -typedef enum { - icon_type_disk, - icon_type_removal, - icon_type_floppy, - icon_type_cd -} icon_type; - // cookie issued by driver to identify itself //typedef struct periph_info *periph_cookie; // cookie issued by driver per device @@ -133,16 +125,12 @@ // returns: B_OK, B_DEV_MEDIA_CHANGE_REQUESTED, B_NO_MEMORY or // pending error reported by handle_get_error status_t (*get_media_status)(scsi_periph_handle handle); + // synchronizes (flush) the device cache + err_res(*synchronize_cache)(scsi_periph_device device, scsi_ccb *request); // compose device name consisting of prefix and path/target/LUN // (result must be freed by caller) char *(*compose_device_name)(device_node *device_node, const char *prefix); - - // fill data with icon (for B_GET_ICON ioctl) - status_t (*get_icon)(icon_type type, device_icon *data); - - // synchronizes (flush) the device cache - err_res(*synchronize_cache)(scsi_periph_device device, scsi_ccb *request); } scsi_periph_interface; #define SCSI_PERIPH_MODULE_NAME "generic/scsi_periph/v1" From axeld at mail.berlios.de Mon Aug 18 13:03:57 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:03:57 +0200 Subject: [Haiku-commits] r27031 - haiku/trunk/src/system/runtime_loader Message-ID: <200808181103.m7IB3vGs002944@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:03:50 +0200 (Mon, 18 Aug 2008) New Revision: 27031 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27031&view=rev Modified: haiku/trunk/src/system/runtime_loader/elf.cpp Log: * More specific error message when relocating fails. * Whitespace cleanup. Modified: haiku/trunk/src/system/runtime_loader/elf.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/elf.cpp 2008-08-18 11:03:03 UTC (rev 27030) +++ haiku/trunk/src/system/runtime_loader/elf.cpp 2008-08-18 11:03:50 UTC (rev 27031) @@ -96,7 +96,7 @@ va_list list; va_start(list, format); - + vsnprintf(buffer, sizeof(buffer), format, list); _kern_debug_output(buffer); @@ -1131,7 +1131,7 @@ info.init_order = 0; info.init_routine = (void (*)())image->init_routine; info.term_routine = (void (*)())image->term_routine; - + if (_kern_read_stat(fd, NULL, false, &stat, sizeof(struct stat)) == B_OK) { info.device = stat.st_dev; info.node = stat.st_ino; @@ -1154,7 +1154,8 @@ { status_t status = arch_relocate_image(rootImage, image); if (status < B_OK) { - FATAL("troubles relocating: 0x%lx (image: %s)\n", status, image->name); + FATAL("troubles relocating: 0x%lx (image: %s, %s)\n", status, + image->path, image->name); return status; } @@ -1762,7 +1763,7 @@ dequeue_image(&sDisposableImages, image); unmap_image(image); - + delete_image(image); } } @@ -1816,7 +1817,7 @@ } } out: - rld_unlock(); + rld_unlock(); if (num != count) return B_BAD_INDEX; From stippi at mail.berlios.de Mon Aug 18 13:05:21 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Mon, 18 Aug 2008 13:05:21 +0200 Subject: [Haiku-commits] r27032 - haiku/trunk/src/kits/storage Message-ID: <200808181105.m7IB5Lto004774@sheep.berlios.de> Author: stippi Date: 2008-08-18 13:05:15 +0200 (Mon, 18 Aug 2008) New Revision: 27032 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27032&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: * r27001 left some parameter checks which need to be ommited for vector icons. Simplified the checks and moved them to where the old B_CMAP8 icon is retrieved. The bitmap is allowed to have another color space, in which case the icon data is converted (code was already in place). * Added a NOTE comment to how the new B_GET_VECTOR_ICON ioctl knows about the correct buffer size for the icon data. I've tested setting the desktop icon size to something else than 16x16 or 32x32 and it works fine now. Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:03:50 UTC (rev 27031) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:05:15 UTC (rev 27032) @@ -209,17 +209,6 @@ if (device == NULL || icon == NULL) return B_BAD_VALUE; - BRect rect; - if (which == B_MINI_ICON) - rect.Set(0, 0, 15, 15); - else if (which == B_LARGE_ICON) - rect.Set(0, 0, 31, 31); - else - return B_BAD_VALUE; - - if (icon->Bounds() != rect) - return B_BAD_VALUE; - uint8* data; size_t size; type_code type; @@ -230,12 +219,21 @@ return status; } - // Vector icon was not available, try old one + // Vector icon was not available, try old one, also checking the icon_size + // parameter - // check whether icon size and bitmap dimensions do match - if (icon->Bounds() != rect || icon->ColorSpace() != B_CMAP8) + BRect rect; + if (which == B_MINI_ICON) + rect.Set(0, 0, 15, 15); + else if (which == B_LARGE_ICON) + rect.Set(0, 0, 31, 31); + else return B_BAD_VALUE; + // check whether icon size and bitmap dimensions do match + if (icon->Bounds() != rect) + return B_MISMATCHED_VALUES; + void* iconData = icon->Bits(); size_t iconSize = icon->BitsLength(); @@ -246,7 +244,7 @@ return B_NO_MEMORY; } - // get the icon + // get the icon, convert temporary data into bitmap if necessary status = get_device_icon(device, iconData, which); if (status == B_OK && iconData != icon->Bits()) icon->SetBits(iconData, iconSize, 0, B_CMAP8); @@ -282,6 +280,12 @@ // Getting the named icon failed, try vector icon next + // NOTE: The actual icon size is unknown as of yet. After the first call + // to B_GET_VECTOR_ICON, the actual size is known and the final buffer + // is allocated with the correct size. If the buffer needed to be + // larger, then the temporary buffer above will not yet contain the + // valid icon data. In that case, a second call to B_GET_VECTOR_ICON + // retrieves it into the final buffer. uint8 data[8192]; device_icon iconData = {sizeof(data), data}; status_t status = ioctl(fd, B_GET_VECTOR_ICON, &iconData, @@ -297,6 +301,7 @@ if (status == B_OK) { if (iconData.icon_size > (int32)sizeof(data)) { + // the stack buffer does not contain the data, see NOTE above iconData.icon_data = *_data; status = ioctl(fd, B_GET_VECTOR_ICON, &iconData, sizeof(device_icon)); From axeld at mail.berlios.de Mon Aug 18 13:07:52 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:07:52 +0200 Subject: [Haiku-commits] r27033 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808181107.m7IB7qZf006959@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:07:47 +0200 (Mon, 18 Aug 2008) New Revision: 27033 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27033&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/BaseDevice.h haiku/trunk/src/system/kernel/device_manager/devfs.cpp haiku/trunk/src/system/kernel/device_manager/devfs_private.h haiku/trunk/src/system/kernel/device_manager/device_manager.cpp haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp Log: * Added new devfs_unpublish_device() that gets a BaseDevice instead of a path. * Added inode ID member to BaseDevice to make this possible. * Removed unused and unmaintained legacy_driver::devices_published field. * Implemented legacy driver's unpublish_driver(). * Reenabled legacy driver reloading on changes. * Renamed devfs_driver_{added|removed}() to driver_{added|removed}(), and made them private. * Simplified deletion of device_node lists (no need to use an iterator here), added device unpublishing. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/device_manager/BaseDevice.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/BaseDevice.h 2008-08-18 11:05:15 UTC (rev 27032) +++ haiku/trunk/src/system/kernel/device_manager/BaseDevice.h 2008-08-18 11:07:47 UTC (rev 27033) @@ -14,6 +14,9 @@ BaseDevice(); virtual ~BaseDevice(); + void SetID(ino_t id) { fID = id; } + ino_t ID() const { return fID; } + device_node* Node() const { return fNode; } virtual status_t InitDevice(); @@ -50,6 +53,7 @@ status_t Free(void* cookie); protected: + ino_t fID; device_node* fNode; int32 fInitialized; device_module_info* fDeviceModule; Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-08-18 11:05:15 UTC (rev 27032) +++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-08-18 11:07:47 UTC (rev 27033) @@ -483,13 +483,6 @@ status = remove_vnode(fs->volume, node->id); -#if 0 - if (status == B_OK && S_ISCHR(node->stream.type) - && node->stream.u.dev.driver != NULL) { - node->stream.u.dev.driver->devices_published--; - } -#endif - out: recursive_lock_unlock(&fs->lock); return status; @@ -2082,6 +2075,9 @@ } +// #pragma mark - device_manager private API + + status_t devfs_publish_device(const char* path, BaseDevice* device) { @@ -2089,6 +2085,25 @@ } +status_t +devfs_unpublish_device(BaseDevice* device, bool disconnect) +{ + devfs_vnode* node; + status_t status = get_vnode(sDeviceFileSystem->volume, device->ID(), + (void**)&node); + if (status != B_OK) + return status; + + status = unpublish_node(sDeviceFileSystem, node, S_IFCHR); + + if (status == B_OK && disconnect) + vfs_disconnect_vnode(sDeviceFileSystem->id, node->id); + + put_vnode(sDeviceFileSystem->volume, node->id); + return status; +} + + // #pragma mark - support API for legacy drivers Modified: haiku/trunk/src/system/kernel/device_manager/devfs_private.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/devfs_private.h 2008-08-18 11:05:15 UTC (rev 27032) +++ haiku/trunk/src/system/kernel/device_manager/devfs_private.h 2008-08-18 11:07:47 UTC (rev 27033) @@ -12,6 +12,7 @@ class BaseDevice; status_t devfs_publish_device(const char* path, BaseDevice* device); +status_t devfs_unpublish_device(BaseDevice* device, bool disconnect); status_t devfs_get_device(dev_t device, ino_t node, BaseDevice** _device); #endif /* DEVFS_PRIVATE_H */ Modified: haiku/trunk/src/system/kernel/device_manager/device_manager.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-08-18 11:05:15 UTC (rev 27032) +++ haiku/trunk/src/system/kernel/device_manager/device_manager.cpp 2008-08-18 11:07:47 UTC (rev 27033) @@ -1156,35 +1156,23 @@ } // Delete children - NodeList::Iterator nodeIterator = fChildren.GetIterator(); - while (nodeIterator.HasNext()) { - device_node* child = nodeIterator.Next(); - nodeIterator.Remove(); + while (device_node* child = fChildren.RemoveHead()) { delete child; } // Delete devices - DeviceList::Iterator deviceIterator = fDevices.GetIterator(); - while (deviceIterator.HasNext()) { - Device* device = deviceIterator.Next(); - deviceIterator.Remove(); - // TODO: unpublish! + while (Device* device = fDevices.RemoveHead()) { + devfs_unpublish_device(device, true); delete device; } // Delete attributes - AttributeList::Iterator attrIterator = fAttributes.GetIterator(); - while (attrIterator.HasNext()) { - device_attr_private* attr = attrIterator.Next(); - attrIterator.Remove(); + while (device_attr_private* attr = fAttributes.RemoveHead()) { delete attr; } // Delete resources - ResourceList::Iterator resourceIterator = fResources.GetIterator(); - while (resourceIterator.HasNext()) { - io_resource_private* resource = resourceIterator.Next(); - resourceIterator.Remove(); + while (io_resource_private* resource = fResources.RemoveHead()) { delete resource; } Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-08-18 11:05:15 UTC (rev 27032) +++ haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-08-18 11:07:47 UTC (rev 27033) @@ -80,7 +80,6 @@ ino_t node; time_t last_modified; image_id image; - uint32 devices_published; uint32 devices_used; bool binary_updated; int32 priority; @@ -454,42 +453,14 @@ } -/*! Collects all devices belonging to the \a driver and unpublishs them. -*/ +/*! Unpublishes all devices belonging to the \a driver. */ static void unpublish_driver(legacy_driver *driver) { - // Iterate through all nodes until all devices of this driver have - // been unpublished - -dprintf("IMPLEMENT unpublish_driver()!\n"); -#if 0 - while (driver->devices_published > 0) { - struct hash_iterator i; - hash_open(sDeviceFileSystem->vnode_hash, &i); - - while (true) { - devfs_vnode *vnode = (devfs_vnode *)hash_next( - sDeviceFileSystem->vnode_hash, &i); - if (vnode == NULL) - break; - - if (S_ISCHR(vnode->stream.type) - && vnode->stream.u.dev.driver == driver) { - void *dummy; - get_vnode(sDeviceFileSystem->volume, vnode->id, &dummy); - // We need to get/put the node, so that it is - // actually removed - - unpublish_node(sDeviceFileSystem, vnode, S_IFCHR); - put_vnode(sDeviceFileSystem->volume, vnode->id); - break; - } - } - - hash_close(sDeviceFileSystem->vnode_hash, &i, false); + while (LegacyDevice* device = driver->devices.RemoveHead()) { + devfs_unpublish_device(device, true); + delete device; } -#endif } @@ -618,7 +589,6 @@ driver->node = stat.st_ino; driver->image = image; driver->last_modified = stat.st_mtime; - driver->devices_published = 0; driver->devices_used = 0; driver->binary_updated = false; driver->priority = priority; @@ -708,6 +678,51 @@ } +static void +driver_added(const char *path) +{ + int32 priority = get_priority(path); + RecursiveLocker locker(sLock); + + legacy_driver *driver = (legacy_driver *)hash_lookup(sDriverHash, + get_leaf(path)); + + if (driver == NULL) { + // Add the driver to our list + path_entry *entry = new(std::nothrow) path_entry; + if (entry == NULL) + return; + + strlcpy(entry->path, path, sizeof(entry->path)); + sDriversToAdd.Add(entry); + } else { + // Update the driver if it is affected by the new entry + if (priority < driver->priority) + return; + + driver->binary_updated = true; + } + + atomic_add(&sDriverEvents, 1); +} + + +static void +driver_removed(const char* path) +{ + int32 priority = get_priority(path); + RecursiveLocker locker(sLock); + + legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash, + get_leaf(path)); + if (driver == NULL || priority < driver->priority) + return; + + driver->binary_updated = true; + atomic_add(&sDriverEvents, 1); +} + + // #pragma mark - DriverWatcher @@ -737,7 +752,7 @@ return; driver->binary_updated = true; -//dprintf("%s: devices published %ld, used %ld\n", driver->name, driver->devices_published, driver->devices_used); + if (driver->devices_used == 0) { // trigger a reload of the driver atomic_add(&sDriverEvents, 1); @@ -764,7 +779,7 @@ kprintf("%p %5ld %3ld %5ld %c %3ld %s\n", driver, driver->image < 0 ? -1 : driver->image, - driver->devices_used, driver->devices_published, + driver->devices_used, driver->devices.Size(), driver->binary_updated ? 'U' : ' ', driver->priority, driver->name); } @@ -792,7 +807,7 @@ kprintf(" node: %Ld\n", driver->node); kprintf(" last modified: %ld\n", driver->last_modified); kprintf(" devs used: %ld\n", driver->devices_used); - kprintf(" devs published: %ld\n", driver->devices_published); + kprintf(" devs published: %ld\n", driver->devices.Size()); kprintf(" binary updated: %d\n", driver->binary_updated); kprintf(" priority: %ld\n", driver->priority); kprintf(" api version: %ld\n", driver->api_version); @@ -988,16 +1003,14 @@ dprintf("driver \"%s\" %s\n", path.Leaf(), opcode == B_ENTRY_CREATED ? "added" : "removed"); -#if 0 switch (opcode) { case B_ENTRY_CREATED: - devfs_driver_added(path.Path()); + driver_added(path.Path()); break; case B_ENTRY_REMOVED: - devfs_driver_removed(path.Path()); + driver_removed(path.Path()); break; } -#endif } @@ -1306,51 +1319,6 @@ } -extern "C" void -devfs_driver_added(const char *path) -{ - int32 priority = get_priority(path); - RecursiveLocker locker(sLock); - - legacy_driver *driver = (legacy_driver *)hash_lookup(sDriverHash, - get_leaf(path)); - - if (driver == NULL) { - // Add the driver to our list - path_entry *entry = new(std::nothrow) path_entry; - if (entry == NULL) - return; - - strlcpy(entry->path, path, sizeof(entry->path)); - sDriversToAdd.Add(entry); - } else { - // Update the driver if it is affected by the new entry - if (priority < driver->priority) - return; - - driver->binary_updated = true; - } - - atomic_add(&sDriverEvents, 1); -} - - -extern "C" void -devfs_driver_removed(const char* path) -{ - int32 priority = get_priority(path); - RecursiveLocker locker(sLock); - - legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash, - get_leaf(path)); - if (driver == NULL || priority < driver->priority) - return; - - driver->binary_updated = true; - atomic_add(&sDriverEvents, 1); -} - - extern "C" status_t legacy_driver_publish(const char *path, device_hooks *hooks) { From teammaui at web.de Mon Aug 18 13:16:27 2008 From: teammaui at web.de (Ralf Schuelke) Date: Mon, 18 Aug 2008 13:16:27 +0200 Subject: [Haiku-commits] r27029 - in haiku/trunk/src/add-ons/kernel: drivers/disk/scsi/scsi_disk generic/scsi_periph In-Reply-To: <200808181102.m7IB2CSH000704@sheep.berlios.de> References: <200808181102.m7IB2CSH000704@sheep.berlios.de> Message-ID: <20080818131627.940.1@2006.Belkin> On 2008-08-18 at 13:02:12 [+0200], axeld at BerliOS wrote: > Date: 2008-08-18 13:02:05 +0200 (Mon, 18 Aug 2008) > New Revision: 27029 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27029&view=rev > > Removed: > haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.cpp > haiku/trunk/src/add-ons/kernel/generic/scsi_periph/device_icons.h > Modified: > haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_disk/scsi_disk.cpp > haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile > haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph.cpp > haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h > Log: > * Removed icon support from scsi_periph. > * Removed B_GET_ICON support from scsi_disk, and scsi_cd. This won't be > necessary anymore soon. Why is this not more necessary ? This make on the Desktop the CD/Disk Icon or? -- Ralf Sch?lke aka Stargater From axeld at mail.berlios.de Mon Aug 18 13:38:53 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:38:53 +0200 Subject: [Haiku-commits] r27034 - haiku/trunk/src/kits/storage Message-ID: <200808181138.m7IBcrbg023115@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:38:53 +0200 (Mon, 18 Aug 2008) New Revision: 27034 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27034&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: * The bitmap variant of get_device_icon() should now support getting all sizes even if the icon is not available in that size (ie. is not a vector icon). Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:07:47 UTC (rev 27033) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:38:53 UTC (rev 27034) @@ -219,38 +219,39 @@ return status; } - // Vector icon was not available, try old one, also checking the icon_size - // parameter + // Vector icon was not available, try old one BRect rect; if (which == B_MINI_ICON) rect.Set(0, 0, 15, 15); else if (which == B_LARGE_ICON) rect.Set(0, 0, 31, 31); - else - return B_BAD_VALUE; - // check whether icon size and bitmap dimensions do match - if (icon->Bounds() != rect) - return B_MISMATCHED_VALUES; + BBitmap* bitmap = icon; + int32 iconSize = which; - void* iconData = icon->Bits(); - size_t iconSize = icon->BitsLength(); + if (icon->ColorSpace() != B_CMAP8 + || (which != B_MINI_ICON && which != B_LARGE_ICON)) { + if (which < B_LARGE_ICON) + iconSize = B_MINI_ICON; + else + iconSize = B_LARGE_ICON; - if (icon->ColorSpace() != B_CMAP8) { - iconSize = (size_t)which * (size_t)which; - iconData = malloc(iconSize); - if (iconData == NULL) + bitmap = new(std::nothrow) BBitmap( + BRect(0, 0, iconSize - 1, iconSize -1), B_CMAP8); + if (bitmap == NULL || bitmap->InitCheck() != B_OK) { + delete bitmap; return B_NO_MEMORY; + } } // get the icon, convert temporary data into bitmap if necessary - status = get_device_icon(device, iconData, which); - if (status == B_OK && iconData != icon->Bits()) - icon->SetBits(iconData, iconSize, 0, B_CMAP8); + status = get_device_icon(device, bitmap->Bits(), iconSize); + if (status == B_OK && icon != bitmap) + status = BIconUtils::ConvertFromCMAP8(bitmap, icon); - if (iconData != icon->Bits()) - free(iconData); + if (icon != bitmap) + delete bitmap; return status; } From axeld at mail.berlios.de Mon Aug 18 13:40:02 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:40:02 +0200 Subject: [Haiku-commits] r27035 - in haiku/trunk: headers/libs/icon src/libs/icon Message-ID: <200808181140.m7IBe2eN023220@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:40:01 +0200 (Mon, 18 Aug 2008) New Revision: 27035 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27035&view=rev Modified: haiku/trunk/headers/libs/icon/IconUtils.h haiku/trunk/src/libs/icon/IconUtils.cpp Log: * Added ConvertToCMAP8() bitmap variant. * Put header guards in the system namespace. * Cleanup. Modified: haiku/trunk/headers/libs/icon/IconUtils.h =================================================================== --- haiku/trunk/headers/libs/icon/IconUtils.h 2008-08-18 11:38:53 UTC (rev 27034) +++ haiku/trunk/headers/libs/icon/IconUtils.h 2008-08-18 11:40:01 UTC (rev 27035) @@ -1,17 +1,17 @@ /* * Copyright 2006-2008, Haiku. All rights reserved. * Distributed under the terms of the MIT License. - * */ +#ifndef _ICON_UTILS_H +#define _ICON_UTILS_H -#ifndef ICON_UTILS_H -#define ICON_UTILS_H #include class BBitmap; class BNode; + // This class is a little different from many other classes. // You don't create an instance of it; you just call its various // static member functions for utility-like operations. @@ -65,6 +65,8 @@ // to make any sense). static status_t ConvertFromCMAP8(BBitmap* source, BBitmap* result); + static status_t ConvertToCMAP8(BBitmap* source, + BBitmap* result); static status_t ConvertFromCMAP8(const uint8* data, uint32 width, uint32 height, @@ -75,4 +77,4 @@ uint32 bytesPerRow, BBitmap* result); }; -#endif // ICON_UTILS_H +#endif // _ICON_UTILS_H Modified: haiku/trunk/src/libs/icon/IconUtils.cpp =================================================================== --- haiku/trunk/src/libs/icon/IconUtils.cpp 2008-08-18 11:38:53 UTC (rev 27034) +++ haiku/trunk/src/libs/icon/IconUtils.cpp 2008-08-18 11:40:01 UTC (rev 27035) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku. All rights reserved. + * Copyright 2006-2008, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -33,14 +33,79 @@ using std::nothrow; -// GetIcon +static void +scale_bilinear(uint8* bits, int32 srcWidth, int32 srcHeight, int32 dstWidth, + int32 dstHeight, uint32 bpr) +{ + // first pass: scale bottom to top + + uint8* dst = bits + (dstHeight - 1) * bpr; + // offset to bottom left pixel in target size + for (int32 x = 0; x < srcWidth; x++) { + uint8* d = dst; + for (int32 y = dstHeight - 1; y >= 0; y--) { + int32 lineF = y * 256 * (srcHeight - 1) / (dstHeight - 1); + int32 lineI = lineF >> 8; + uint8 weight = (uint8)(lineF & 0xff); + uint8* s1 = bits + lineI * bpr + 4 * x; + if (weight == 0) { + d[0] = s1[0]; + d[1] = s1[1]; + d[2] = s1[2]; + d[3] = s1[3]; + } else { + uint8* s2 = s1 + bpr; + + d[0] = (((s2[0] - s1[0]) * weight) + (s1[0] << 8)) >> 8; + d[1] = (((s2[1] - s1[1]) * weight) + (s1[1] << 8)) >> 8; + d[2] = (((s2[2] - s1[2]) * weight) + (s1[2] << 8)) >> 8; + d[3] = (((s2[3] - s1[3]) * weight) + (s1[3] << 8)) >> 8; + } + + d -= bpr; + } + dst += 4; + } + + // second pass: scale right to left + + dst = bits + (dstWidth - 1) * 4; + // offset to top left pixel in target size + for (int32 y = 0; y < dstWidth; y++) { + uint8* d = dst; + for (int32 x = dstWidth - 1; x >= 0; x--) { + int32 columnF = x * 256 * (srcWidth - 1) / (dstWidth - 1); + int32 columnI = columnF >> 8; + uint8 weight = (uint8)(columnF & 0xff); + uint8* s1 = bits + y * bpr + 4 * columnI; + if (weight == 0) { + d[0] = s1[0]; + d[1] = s1[1]; + d[2] = s1[2]; + d[3] = s1[3]; + } else { + uint8* s2 = s1 + 4; + + d[0] = (((s2[0] - s1[0]) * weight) + (s1[0] << 8)) >> 8; + d[1] = (((s2[1] - s1[1]) * weight) + (s1[1] << 8)) >> 8; + d[2] = (((s2[2] - s1[2]) * weight) + (s1[2] << 8)) >> 8; + d[3] = (((s2[3] - s1[3]) * weight) + (s1[3] << 8)) >> 8; + } + + d -= 4; + } + dst += bpr; + } +} + + +// #pragma mark - + + status_t -BIconUtils::GetIcon(BNode* node, - const char* vectorIconAttrName, - const char* smallIconAttrName, - const char* largeIconAttrName, - icon_size size, - BBitmap* result) +BIconUtils::GetIcon(BNode* node, const char* vectorIconAttrName, + const char* smallIconAttrName, const char* largeIconAttrName, + icon_size size, BBitmap* result) { if (!result || result->InitCheck()) return B_BAD_VALUE; @@ -62,24 +127,20 @@ else size = B_MINI_ICON; - ret = GetCMAP8Icon(node, - smallIconAttrName, - largeIconAttrName, - size, result); + ret = GetCMAP8Icon(node, smallIconAttrName, largeIconAttrName, + size, result); } break; case B_CMAP8: // prefer old B_CMAP8 icons - ret = GetCMAP8Icon(node, - smallIconAttrName, - largeIconAttrName, - size, result); + ret = GetCMAP8Icon(node, smallIconAttrName, largeIconAttrName, + size, result); if (ret < B_OK) { // try to fallback to vector icon #ifdef HAIKU_TARGET_PLATFORM_HAIKU - BBitmap temp(result->Bounds(), - B_BITMAP_NO_SERVER_LINK, B_RGBA32); + BBitmap temp(result->Bounds(), B_BITMAP_NO_SERVER_LINK, + B_RGBA32); #else BBitmap temp(result->Bounds(), B_RGBA32); #endif @@ -92,8 +153,8 @@ uint32 width = temp.Bounds().IntegerWidth() + 1; uint32 height = temp.Bounds().IntegerHeight() + 1; uint32 bytesPerRow = temp.BytesPerRow(); - ret = ConvertToCMAP8((uint8*)temp.Bits(), - width, height, bytesPerRow, result); + ret = ConvertToCMAP8((uint8*)temp.Bits(), width, height, + bytesPerRow, result); } break; default: @@ -104,12 +165,12 @@ return ret; } + // #pragma mark - -// GetVectorIcon + status_t -BIconUtils::GetVectorIcon(BNode* node, const char* attrName, - BBitmap* result) +BIconUtils::GetVectorIcon(BNode* node, const char* attrName, BBitmap* result) { if (!node || node->InitCheck() < B_OK || !attrName) return B_BAD_VALUE; @@ -154,10 +215,9 @@ return B_OK; } -// GetVectorIcon + status_t -BIconUtils::GetVectorIcon(const uint8* buffer, size_t size, - BBitmap* result) +BIconUtils::GetVectorIcon(const uint8* buffer, size_t size, BBitmap* result) { if (!result) return B_BAD_VALUE; @@ -211,14 +271,13 @@ return ret; } + // #pragma mark - + status_t -BIconUtils::GetCMAP8Icon(BNode* node, - const char* smallIconAttrName, - const char* largeIconAttrName, - icon_size size, - BBitmap* icon) +BIconUtils::GetCMAP8Icon(BNode* node, const char* smallIconAttrName, + const char* largeIconAttrName, icon_size size, BBitmap* icon) { // check parameters and initialization if (!icon || icon->InitCheck() != B_OK @@ -279,7 +338,7 @@ // read the attribute if (ret == B_OK) { bool tempBuffer = (icon->ColorSpace() != B_CMAP8 - || icon->Bounds() != bounds); + || icon->Bounds() != bounds); uint8* buffer = NULL; ssize_t read; if (tempBuffer) { @@ -288,12 +347,11 @@ if (!buffer) { ret = B_NO_MEMORY; } else { - read = node->ReadAttr(attribute, attrType, 0, buffer, - attrSize); + read = node->ReadAttr(attribute, attrType, 0, buffer, attrSize); } } else { - read = node->ReadAttr(attribute, attrType, 0, icon->Bits(), - attrSize); + read = node->ReadAttr(attribute, attrType, 0, icon->Bits(), + attrSize); } if (ret == B_OK) { if (read < 0) @@ -304,9 +362,8 @@ if (tempBuffer) { // other color space than stored in attribute if (ret == B_OK) { - ret = ConvertFromCMAP8(buffer, - (uint32)size, (uint32)size, - (uint32)size, icon); + ret = ConvertFromCMAP8(buffer, (uint32)size, (uint32)size, + (uint32)size, icon); } delete[] buffer; } @@ -314,21 +371,23 @@ return ret; } + // #pragma mark - -// ConvertFromCMAP8 + status_t BIconUtils::ConvertFromCMAP8(BBitmap* source, BBitmap* result) { - if (!source) + if (source == NULL || source->ColorSpace() != B_CMAP8) return B_BAD_VALUE; - status_t ret = source->InitCheck(); - if (ret < B_OK) - return ret; + status_t status = source->InitCheck(); + if (status < B_OK) + return status; - if (source->ColorSpace() != B_CMAP8) - return B_BAD_VALUE; + status = result->InitCheck(); + if (status < B_OK) + return status; uint8* src = (uint8*)source->Bits(); uint32 srcBPR = source->BytesPerRow(); @@ -338,78 +397,34 @@ return ConvertFromCMAP8(src, width, height, srcBPR, result); } -// scale_bilinear -static void -scale_bilinear(uint8* bits, int32 srcWidth, int32 srcHeight, - int32 dstWidth, int32 dstHeight, uint32 bpr) + +status_t +BIconUtils::ConvertToCMAP8(BBitmap* source, BBitmap* result) { - // first pass: scale bottom to top + if (source == NULL || source->ColorSpace() != B_RGBA32 + || result->ColorSpace() != B_CMAP8) + return B_BAD_VALUE; - uint8* dst = bits + (dstHeight - 1) * bpr; - // offset to bottom left pixel in target size - for (int32 x = 0; x < srcWidth; x++) { - uint8* d = dst; - for (int32 y = dstHeight - 1; y >= 0; y--) { - int32 lineF = y * 256 * (srcHeight - 1) / (dstHeight - 1); - int32 lineI = lineF >> 8; - uint8 weight = (uint8)(lineF & 0xff); - uint8* s1 = bits + lineI * bpr + 4 * x; - if (weight == 0) { - d[0] = s1[0]; - d[1] = s1[1]; - d[2] = s1[2]; - d[3] = s1[3]; - } else { - uint8* s2 = s1 + bpr; - - d[0] = (((s2[0] - s1[0]) * weight) + (s1[0] << 8)) >> 8; - d[1] = (((s2[1] - s1[1]) * weight) + (s1[1] << 8)) >> 8; - d[2] = (((s2[2] - s1[2]) * weight) + (s1[2] << 8)) >> 8; - d[3] = (((s2[3] - s1[3]) * weight) + (s1[3] << 8)) >> 8; - } + status_t status = source->InitCheck(); + if (status < B_OK) + return status; - d -= bpr; - } - dst += 4; - } + status = result->InitCheck(); + if (status < B_OK) + return status; - // second pass: scale right to left + uint8* src = (uint8*)source->Bits(); + uint32 srcBPR = source->BytesPerRow(); + uint32 width = source->Bounds().IntegerWidth() + 1; + uint32 height = source->Bounds().IntegerHeight() + 1; - dst = bits + (dstWidth - 1) * 4; - // offset to top left pixel in target size - for (int32 y = 0; y < dstWidth; y++) { - uint8* d = dst; - for (int32 x = dstWidth - 1; x >= 0; x--) { - int32 columnF = x * 256 * (srcWidth - 1) / (dstWidth - 1); - int32 columnI = columnF >> 8; - uint8 weight = (uint8)(columnF & 0xff); - uint8* s1 = bits + y * bpr + 4 * columnI; - if (weight == 0) { - d[0] = s1[0]; - d[1] = s1[1]; - d[2] = s1[2]; - d[3] = s1[3]; - } else { - uint8* s2 = s1 + 4; - - d[0] = (((s2[0] - s1[0]) * weight) + (s1[0] << 8)) >> 8; - d[1] = (((s2[1] - s1[1]) * weight) + (s1[1] << 8)) >> 8; - d[2] = (((s2[2] - s1[2]) * weight) + (s1[2] << 8)) >> 8; - d[3] = (((s2[3] - s1[3]) * weight) + (s1[3] << 8)) >> 8; - } - - d -= 4; - } - dst += bpr; - } + return ConvertToCMAP8(src, width, height, srcBPR, result); } -// ConvertFromCMAP8 status_t -BIconUtils::ConvertFromCMAP8(const uint8* src, - uint32 width, uint32 height, uint32 srcBPR, - BBitmap* result) +BIconUtils::ConvertFromCMAP8(const uint8* src, uint32 width, uint32 height, + uint32 srcBPR, BBitmap* result) { if (!src || !result || srcBPR == 0) return B_BAD_VALUE; @@ -460,8 +475,8 @@ if (dstWidth > width || dstHeight > height) { // up scaling - scale_bilinear((uint8*)result->Bits(), width, height, - dstWidth, dstHeight, dstBPR); + scale_bilinear((uint8*)result->Bits(), width, height, dstWidth, + dstHeight, dstBPR); } return B_OK; @@ -469,11 +484,10 @@ //#endif // __HAIKU__ } -// ConvertToCMAP8 + status_t -BIconUtils::ConvertToCMAP8(const uint8* src, - uint32 width, uint32 height, uint32 srcBPR, - BBitmap* result) +BIconUtils::ConvertToCMAP8(const uint8* src, uint32 width, uint32 height, + uint32 srcBPR, BBitmap* result) { if (!src || !result || srcBPR == 0) return B_BAD_VALUE; @@ -534,8 +548,10 @@ //#endif // __HAIKU__ } + // #pragma mark - forbidden + BIconUtils::BIconUtils() {} BIconUtils::~BIconUtils() {} BIconUtils::BIconUtils(const BIconUtils&) {} From axeld at mail.berlios.de Mon Aug 18 13:50:09 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 13:50:09 +0200 Subject: [Haiku-commits] r27036 - haiku/trunk/src/kits/storage Message-ID: <200808181150.m7IBo9E9027346@sheep.berlios.de> Author: axeld Date: 2008-08-18 13:50:08 +0200 (Mon, 18 Aug 2008) New Revision: 27036 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27036&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: * The old Be version of get_device_icon() now also supports retrieving the vector icon in case B_GET_ICON is not supported by the device anymore. (This makes B_GET_ICON deprecated API.) * Use B_BITMAP_NO_SERVER_LINK flag, as our bitmap is only used internally. Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:40:01 UTC (rev 27035) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 11:50:08 UTC (rev 27036) @@ -177,7 +177,37 @@ device_icon iconData = {size, icon}; if (ioctl(fd, B_GET_ICON, &iconData) != 0) { + // legacy icon was not available, try vector icon close(fd); + + uint8* data; + size_t size; + type_code type; + status_t status = get_device_icon(device, &data, &size, &type); + if (status == B_OK) { + BBitmap* icon = new(std::nothrow) BBitmap( + BRect(0, 0, size - 1, size - 1), B_BITMAP_NO_SERVER_LINK, + B_RGBA32); + BBitmap* target = new(std::nothrow) BBitmap( + BRect(0, 0, size - 1, size - 1), B_BITMAP_NO_SERVER_LINK, + B_CMAP8); + if (icon == NULL || icon->InitCheck() != B_OK || target == NULL + || target->InitCheck() != B_OK) { + delete icon; + delete target; + return B_NO_MEMORY; + } + status = BIconUtils::GetVectorIcon(data, size, icon); + if (status == B_OK) + status = BIconUtils::ConvertToCMAP8(icon, target); + if (status == B_OK) + memcpy(icon, target->Bits(), target->BitsLength()); + + delete icon; + delete target; + delete[] data; + return status; + } return errno; } @@ -238,7 +268,8 @@ iconSize = B_LARGE_ICON; bitmap = new(std::nothrow) BBitmap( - BRect(0, 0, iconSize - 1, iconSize -1), B_CMAP8); + BRect(0, 0, iconSize - 1, iconSize -1), B_BITMAP_NO_SERVER_LINK, + B_CMAP8); if (bitmap == NULL || bitmap->InitCheck() != B_OK) { delete bitmap; return B_NO_MEMORY; From axeld at mail.berlios.de Mon Aug 18 14:34:48 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 14:34:48 +0200 Subject: [Haiku-commits] r27037 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808181234.m7ICYmR0000493@sheep.berlios.de> Author: axeld Date: 2008-08-18 14:34:47 +0200 (Mon, 18 Aug 2008) New Revision: 27037 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27037&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp Log: * Forgot to set the BaseDevice inode ID; devfs_unpublish_device() now works as intended. Modified: haiku/trunk/src/system/kernel/device_manager/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-08-18 11:50:08 UTC (rev 27036) +++ haiku/trunk/src/system/kernel/device_manager/devfs.cpp 2008-08-18 12:34:47 UTC (rev 27037) @@ -707,6 +707,7 @@ // all went fine, let's initialize the node node->stream.type = S_IFCHR | 0644; node->stream.u.dev.device = device; + device->SetID(node->id); // the node is now fully valid and we may insert it into the dir publish_node(fs, dirNode, node); From axeld at mail.berlios.de Mon Aug 18 14:36:27 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 14:36:27 +0200 Subject: [Haiku-commits] r27038 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808181236.m7ICaR3U000572@sheep.berlios.de> Author: axeld Date: 2008-08-18 14:36:27 +0200 (Mon, 18 Aug 2008) New Revision: 27038 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27038&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp Log: * Greatly simplified republish_driver(); it doesn't need to use the path_entry stuff at all, anymore. * Removed now unused get_device_for_path(). * unpublish_driver() now only deletes the device if unpublishing actually worked out okay. * Minor cleanup. Modified: haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-08-18 12:34:47 UTC (rev 27037) +++ haiku/trunk/src/system/kernel/device_manager/legacy_drivers.cpp 2008-08-18 12:36:27 UTC (rev 27038) @@ -64,10 +64,14 @@ void** _cookie); virtual status_t Select(void* cookie, uint8 event, selectsync* sync); + bool Republished() const { return fRepublished; } + void SetRepublished(bool republished) + { fRepublished = republished; } private: legacy_driver* fDriver; const char* fPath; device_hooks* fHooks; + bool fRepublished; }; typedef DoublyLinkedList DeviceList; @@ -213,21 +217,6 @@ } -static LegacyDevice* -get_device_for_path(legacy_driver* driver, const char* path) -{ - DeviceList::Iterator iterator = driver->devices.GetIterator(); - while (iterator.HasNext()) { - LegacyDevice* device = iterator.Next(); - - if (!strcmp(device->Path(), path)) - return device; - } - - return NULL; -} - - /*! Collects all published devices of a driver, compares them to what the driver would publish now, and then publishes/unpublishes the devices as needed. @@ -241,59 +230,42 @@ return load_driver(driver); } - // build the list of currently present devices of this driver + // mark all devices DeviceList::Iterator iterator = driver->devices.GetIterator(); - DoublyLinkedList currentNodes; - while (iterator.HasNext()) { - LegacyDevice* device = iterator.Next(); - - path_entry* entry = new(std::nothrow) path_entry; - if (entry == NULL) { - while ((entry = currentNodes.RemoveHead())) - delete entry; - return B_NO_MEMORY; - } - - strlcpy(entry->path, device->Path(), sizeof(entry->path)); - currentNodes.Add(entry); + while (LegacyDevice* device = iterator.Next()) { + device->SetRepublished(false); } // now ask the driver for it's currently published devices - const char **devicePaths = driver->publish_devices(); + const char** devicePaths = driver->publish_devices(); int32 exported = 0; for (; devicePaths != NULL && devicePaths[0]; devicePaths++) { - bool present = false; - path_entry *entry = currentNodes.Head(); - while (entry) { - if (strncmp(entry->path, devicePaths[0], B_PATH_NAME_LENGTH) == 0) { - // this device was present before and still is -> no republish - currentNodes.Remove(entry); - delete entry; + LegacyDevice* device; + + iterator = driver->devices.GetIterator(); + while ((device = iterator.Next()) != NULL) { + if (!strncmp(device->Path(), devicePaths[0], B_PATH_NAME_LENGTH)) { + // mark device as republished + device->SetRepublished(true); exported++; - present = true; break; } - - entry = currentNodes.GetNext(entry); } - device_hooks *hooks = driver->find_device(devicePaths[0]); + device_hooks* hooks = driver->find_device(devicePaths[0]); if (hooks == NULL) continue; - if (present) { + if (device != NULL) { // update hooks - LegacyDevice* device = get_device_for_path(driver, devicePaths[0]); - if (device != NULL) - device->SetHooks(hooks); + device->SetHooks(hooks); continue; } // the device was not present before -> publish it now TRACE(("devfs: publishing new device \"%s\"\n", devicePaths[0])); - LegacyDevice* device = new(std::nothrow) LegacyDevice(driver, - devicePaths[0], hooks); + device = new(std::nothrow) LegacyDevice(driver, devicePaths[0], hooks); if (device != NULL && device->InitCheck() == B_OK && devfs_publish_device(devicePaths[0], device) == B_OK) { driver->devices.Add(device); @@ -302,24 +274,22 @@ delete device; } - // what's left in currentNodes was present but is not anymore -> unpublish - while (true) { - path_entry *entry = currentNodes.RemoveHead(); - if (entry == NULL) - break; + // remove all devices that weren't republished + iterator = driver->devices.GetIterator(); + while (LegacyDevice* device = iterator.Next()) { + if (device->Republished()) + continue; - TRACE(("devfs: unpublishing no more present \"%s\"\n", entry->path)); - LegacyDevice* device = get_device_for_path(driver, entry->path); - if (device != NULL) - driver->devices.Remove(device); + TRACE(("devfs: unpublishing no more present \"%s\"\n", device->Path())); + iterator.Remove(); - devfs_unpublish_device(entry->path, true); + devfs_unpublish_device(device, true); delete device; - delete entry; } if (exported == 0) { - TRACE(("devfs: driver \"%s\" does not publish any more nodes and is unloaded\n", driver->path)); + TRACE(("devfs: driver \"%s\" does not publish any more nodes and is " + "unloaded\n", driver->path)); unload_driver(driver); } @@ -458,8 +428,8 @@ unpublish_driver(legacy_driver *driver) { while (LegacyDevice* device = driver->devices.RemoveHead()) { - devfs_unpublish_device(device, true); - delete device; + if (devfs_unpublish_device(device, true) == B_OK) + delete device; } } @@ -550,7 +520,7 @@ // isn't the same anymore so rescanning of drivers will work in // case this driver was loaded so early that it has a boot module // path and not a proper driver path - free((char *)driver->path); + free((char*)driver->path); driver->path = strdup(path); driver->name = get_leaf(driver->path); driver->binary_updated = true; @@ -652,7 +622,7 @@ RecursiveLocker locker(sLock); while (true) { - path_entry *path = sDriversToAdd.RemoveHead(); + path_entry* path = sDriversToAdd.RemoveHead(); if (path == NULL) break; @@ -679,17 +649,17 @@ static void -driver_added(const char *path) +driver_added(const char* path) { int32 priority = get_priority(path); RecursiveLocker locker(sLock); - legacy_driver *driver = (legacy_driver *)hash_lookup(sDriverHash, + legacy_driver* driver = (legacy_driver*)hash_lookup(sDriverHash, get_leaf(path)); if (driver == NULL) { // Add the driver to our list - path_entry *entry = new(std::nothrow) path_entry; + path_entry* entry = new(std::nothrow) path_entry; if (entry == NULL) return; @@ -1155,7 +1125,8 @@ LegacyDevice::LegacyDevice(legacy_driver* driver, const char* path, device_hooks* hooks) : - fDriver(driver) + fDriver(driver), + fRepublished(true) { fDeviceModule = (device_module_info*)malloc(sizeof(device_module_info)); if (fDeviceModule != NULL) From bonefish at mail.berlios.de Mon Aug 18 16:44:37 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 18 Aug 2008 16:44:37 +0200 Subject: [Haiku-commits] r27039 - haiku/trunk/build/jam Message-ID: <200808181444.m7IEibjl012437@sheep.berlios.de> Author: bonefish Date: 2008-08-18 16:44:35 +0200 (Mon, 18 Aug 2008) New Revision: 27039 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27039&view=rev Modified: haiku/trunk/build/jam/UserBuildConfig.ReadMe Log: Removed the description for obsolete HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE. There's a PosixTestSuite optional package instead. Modified: haiku/trunk/build/jam/UserBuildConfig.ReadMe =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-08-18 12:36:27 UTC (rev 27038) +++ haiku/trunk/build/jam/UserBuildConfig.ReadMe 2008-08-18 14:44:35 UTC (rev 27039) @@ -16,7 +16,7 @@ AddSymlinkToHaikuImage home config settings : /boot/beos/etc/timezones/Europe/Paris : timezone ; -AddFilesToHaikuImage home config settings : US-International +AddFilesToHaikuImage home config settings : US-International : Key_map ; @@ -216,7 +216,7 @@ # jam command line prefixed by an "@" character, the profile will be selected. # The second parameter specifies the action to be performed, further optional # parameters may follow. Jam command line examples: -# +# # jam -q @disk build # -> Equivalent to running "jam -q haiku-image" with the settings for the # "disk" profile. "build" is the default action, so it could even be @@ -281,8 +281,3 @@ # usual). Omitting this parameter or specifying "global" will cause the given # name to be used recursively. DeferredSubInclude HAIKU_TOP src 3rdparty myproject : Jamfile.haiku : local ; - - -# Copy the posix test suite onto the image (or on the installation) into -# "home/posixtestsuite" directory, including the run script. -HAIKU_ADD_POSIX_TEST_SUITE_TO_IMAGE = 1 ; From bonefish at mail.berlios.de Mon Aug 18 17:10:48 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 18 Aug 2008 17:10:48 +0200 Subject: [Haiku-commits] r27040 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808181510.m7IFAmgp015127@sheep.berlios.de> Author: bonefish Date: 2008-08-18 17:10:47 +0200 (Mon, 18 Aug 2008) New Revision: 27040 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27040&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp Log: The return value of the identify_partition() hook is not error code compatible. Small floats have to be returned. 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-08-18 14:44:35 UTC (rev 27039) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2008-08-18 15:10:47 UTC (rev 27040) @@ -94,11 +94,11 @@ disk_super_block superBlock; status_t status = Volume::Identify(fd, &superBlock); if (status != B_OK) - return status; + return -1; identify_cookie* cookie = new(std::nothrow) identify_cookie; if (cookie == NULL) - return B_NO_MEMORY; + return -1; memcpy(&cookie->super_block, &superBlock, sizeof(disk_super_block)); From bonefish at mail.berlios.de Mon Aug 18 17:16:28 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 18 Aug 2008 17:16:28 +0200 Subject: [Haiku-commits] r27041 - haiku/trunk/src/tests/system/kernel/device_manager Message-ID: <200808181516.m7IFGSES015724@sheep.berlios.de> Author: bonefish Date: 2008-08-18 17:16:27 +0200 (Mon, 18 Aug 2008) New Revision: 27041 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27041&view=rev Modified: haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp Log: Tests exposing several problems with partial writes shorter than the vector size, and partial writes of less than one block. Modified: haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp 2008-08-18 15:10:47 UTC (rev 27040) +++ haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp 2008-08-18 15:16:27 UTC (rev 27041) @@ -829,6 +829,19 @@ .AddTarget(0, 2048, false) .AddTarget(0, 512, true); + suite.AddTest(0, 51, true, B_PHYSICAL_IO_REQUEST) + .AddSource(0, 4096) + .NextResult(0, false, true) + .AddTarget(0, 512, true); + + suite.AddTest(32, 51, true, B_PHYSICAL_IO_REQUEST) + .AddSource(0, 4096) + .NextResult(0, true, false) + .AddTarget(0, 512, true); + // Note: The operation has actually both partial begin and end, but + // our Test is not clever enough to realize that it is only one + // block and thus only one read phase is needed. + suite.Run(); } From anevilyak at gmail.com Mon Aug 18 17:18:54 2008 From: anevilyak at gmail.com (Rene Gollent) Date: Mon, 18 Aug 2008 10:18:54 -0500 Subject: [Haiku-commits] r27041 - haiku/trunk/src/tests/system/kernel/device_manager In-Reply-To: <200808181516.m7IFGSES015724@sheep.berlios.de> References: <200808181516.m7IFGSES015724@sheep.berlios.de> Message-ID: Hiya On Mon, Aug 18, 2008 at 10:16 AM, wrote: > Author: bonefish > Date: 2008-08-18 17:16:27 +0200 (Mon, 18 Aug 2008) > New Revision: 27041 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27041&view=rev > > Modified: > haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp > Log: > Tests exposing several problems with partial writes shorter than the > vector size, and partial writes of less than one block. > > Is this by any chance related to makebootable succeeding maybe 50% of the time? Michael was looking at that with me and he suggested it might be a partial write problem. Regards, Rene From bonefish at mail.berlios.de Mon Aug 18 17:32:12 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Mon, 18 Aug 2008 17:32:12 +0200 Subject: [Haiku-commits] r27042 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808181532.m7IFWCk9017465@sheep.berlios.de> Author: bonefish Date: 2008-08-18 17:32:11 +0200 (Mon, 18 Aug 2008) New Revision: 27042 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27042&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp Log: DMAResource::TranslateNext(): Fixed several bugs that could cause too many bytes to be read/written, which, among other things, could trigger an assert in the IORequest code: * In case of a partial (i.e. non-block-aligned) begin, transferLeft was not adjusted correctly. * The main loop was lacking a transferLeft check. * Main loop: When finally using a bounce buffer, the unrestricted vec length was used as base length for the bounce buffer. Modified: haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-18 15:16:27 UTC (rev 27041) +++ haiku/trunk/src/system/kernel/device_manager/dma_resources.cpp 2008-08-18 15:32:11 UTC (rev 27042) @@ -483,13 +483,21 @@ dmaLength += length; - vecOffset += length - partialBegin; + size_t transferred = length - partialBegin; + vecOffset += transferred; offset -= partialBegin; + + if (transferLeft > transferred) + transferLeft -= transferred; + else + transferLeft = 0; + TRACE(" partial begin, using bounce buffer: offset: %lld, length: " "%lu\n", offset, length); } - for (uint32 i = vecIndex; i < vecIndex + segmentCount;) { + for (uint32 i = vecIndex; + i < vecIndex + segmentCount && transferLeft > 0;) { if (dmaBuffer->VecCount() >= fRestrictions.max_segment_count) break; @@ -501,9 +509,10 @@ } addr_t base = (addr_t)vec.iov_base + vecOffset; - size_t length = vec.iov_len - vecOffset; - if (length > transferLeft) - length = transferLeft; + size_t maxLength = vec.iov_len - vecOffset; + if (maxLength > transferLeft) + maxLength = transferLeft; + size_t length = maxLength; // Cut the vec according to transfer size, segment size, and boundary. @@ -540,7 +549,7 @@ // If length is 0, use bounce buffer for complete vec. if (length == 0) { - length = vec.iov_len - vecOffset; + length = maxLength; useBounceBufferSize = length; TRACE(" vec %lu: 0 length, using bounce buffer: %lu\n", i, useBounceBufferSize); @@ -567,7 +576,7 @@ dmaLength += length; vecOffset += length; - transferLeft -= length; + transferLeft -= min_c(length, transferLeft); } // If we're writing partially, we always need to have a block sized bounce From ingo_weinhold at gmx.de Mon Aug 18 17:44:54 2008 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Mon, 18 Aug 2008 17:44:54 +0200 Subject: [Haiku-commits] r27041 - haiku/trunk/src/tests/system/kernel/device_manager In-Reply-To: References: <200808181516.m7IFGSES015724@sheep.berlios.de> Message-ID: <20080818174454.1296.4@knochen-vm.localdomain> On 2008-08-18 at 17:18:54 [+0200], Rene Gollent wrote: > Hiya > > On Mon, Aug 18, 2008 at 10:16 AM, wrote: > > Author: bonefish > > Date: 2008-08-18 17:16:27 +0200 (Mon, 18 Aug 2008) > > New Revision: 27041 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27041&view=rev > > > > Modified: > > haiku/trunk/src/tests/system/kernel/device_manager/dma_resource_test.cpp > > Log: > > Tests exposing several problems with partial writes shorter than the > > vector size, and partial writes of less than one block. > > Is this by any chance related to makebootable succeeding maybe 50% of > the time? Michael was looking at that with me and he suggested it > might be a partial write problem. It could definitely lead to too many bytes to be written, which could e.g. overwrite the BFS superblock with garbage. Then the volume shouldn't be mountable either anymore, though. I'm not sure whether it might also have caused garbage to be written to the intended write location. At any rate you can test with r27042 if the makebootable problem still persists. CU, Ingo From axeld at pinc-software.de Mon Aug 18 18:01:21 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 18 Aug 2008 18:01:21 +0200 CEST Subject: [Haiku-commits] r27029 - in haiku/trunk/src/add-ons/kernel: drivers/disk/scsi/scsi_disk generic/scsi_periph In-Reply-To: <20080818131627.940.1@2006.Belkin> Message-ID: <34123268953-BeMail@zon> Ralf Schuelke wrote: > > * Removed B_GET_ICON support from scsi_disk, and scsi_cd. This > > won't be > > necessary anymore soon. > Why is this not more necessary ? > This make on the Desktop the CD/Disk Icon or? Following earlier commits might have been helpful in this case. Haiku introduces new B_GET_VECTOR_ICON, and B_GET_ICON_NAME ioctl. Since there is an API to retrieve the icon of a device (in form of get_device_icon()), it will always be able to retrieve the icon, no matter what the driver actually supports. Bye, Axel. From umccullough at gmail.com Mon Aug 18 19:55:12 2008 From: umccullough at gmail.com (Urias McCullough) Date: Mon, 18 Aug 2008 10:55:12 -0700 Subject: [Haiku-commits] r27041 - haiku/trunk/src/tests/system/kernel/device_manager In-Reply-To: <20080818174454.1296.4@knochen-vm.localdomain> References: <200808181516.m7IFGSES015724@sheep.berlios.de> <20080818174454.1296.4@knochen-vm.localdomain> Message-ID: <1e80d8750808181055x742dcdfcyf917fd8f7ed16a11@mail.gmail.com> 2008/8/18 Ingo Weinhold : > It could definitely lead to too many bytes to be written, which could e.g. > overwrite the BFS superblock with garbage. Then the volume shouldn't be > mountable either anymore, though. I'm not sure whether it might also have > caused garbage to be written to the intended write location. At any rate you > can test with r27042 if the makebootable problem still persists. I'll definitely test this ASAP as I was having problems whenever makebootable was called from the Installer - it was apparently corrupting the second block on the disk making it unbootable (ironic). - Urias From axeld at mail.berlios.de Mon Aug 18 19:57:04 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 19:57:04 +0200 Subject: [Haiku-commits] r27043 - haiku/trunk/src/system/kernel/disk_device_manager Message-ID: <200808181757.m7IHv432019823@sheep.berlios.de> Author: axeld Date: 2008-08-18 19:57:03 +0200 (Mon, 18 Aug 2008) New Revision: 27043 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27043&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp Log: * Try to create unknown devices before failing in RegisterDevice(), and RegisterPartition(). Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2008-08-18 15:32:11 UTC (rev 27042) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDeviceManager.cpp 2008-08-18 17:57:03 UTC (rev 27043) @@ -396,25 +396,33 @@ return NULL; } -// RegisterDevice -KDiskDevice * -KDiskDeviceManager::RegisterDevice(const char *path) + +KDiskDevice* +KDiskDeviceManager::RegisterDevice(const char* path) { if (ManagerLocker locker = this) { - if (KDiskDevice *device = FindDevice(path)) { - device->Register(); - return device; + for (int32 i = 0; i < 2; i++) { + if (KDiskDevice* device = FindDevice(path)) { + device->Register(); + return device; + } + + // if the device is not known yet, create it and try again + const char* leaf = strrchr(path, '/'); + if (i == 0 && !strncmp(path, "/dev/disk", 9) + && !strcmp(leaf + 1, "raw") && CreateDevice(path) < B_OK) + break; } } return NULL; } -// RegisterDevice -KDiskDevice * + +KDiskDevice* KDiskDeviceManager::RegisterDevice(partition_id id, bool deviceOnly) { if (ManagerLocker locker = this) { - if (KDiskDevice *device = FindDevice(id, deviceOnly)) { + if (KDiskDevice* device = FindDevice(id, deviceOnly)) { device->Register(); return device; } @@ -422,14 +430,15 @@ return NULL; } -// RegisterNextDevice -KDiskDevice * -KDiskDeviceManager::RegisterNextDevice(int32 *cookie) + +KDiskDevice* +KDiskDeviceManager::RegisterNextDevice(int32* cookie) { if (!cookie) return NULL; + if (ManagerLocker locker = this) { - if (KDiskDevice *device = NextDevice(cookie)) { + if (KDiskDevice* device = NextDevice(cookie)) { device->Register(); return device; } @@ -437,25 +446,33 @@ return NULL; } -// RegisterPartition -KPartition * -KDiskDeviceManager::RegisterPartition(const char *path) + +KPartition* +KDiskDeviceManager::RegisterPartition(const char* path) { if (ManagerLocker locker = this) { - if (KPartition *partition = FindPartition(path)) { - partition->Register(); - return partition; + for (int32 i = 0; i < 2; i++) { + if (KPartition* partition = FindPartition(path)) { + partition->Register(); + return partition; + } + + // if the device is not known yet, create it and try again + const char* leaf = strrchr(path, '/'); + if (i == 0 && !strncmp(path, "/dev/disk", 9) + && !strcmp(leaf + 1, "raw") && CreateDevice(path) < B_OK) + break; } } return NULL; } -// RegisterPartition -KPartition * + +KPartition* KDiskDeviceManager::RegisterPartition(partition_id id) { if (ManagerLocker locker = this) { - if (KPartition *partition = FindPartition(id)) { + if (KPartition* partition = FindPartition(id)) { partition->Register(); return partition; } From stippi at mail.berlios.de Mon Aug 18 20:53:31 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Mon, 18 Aug 2008 20:53:31 +0200 Subject: [Haiku-commits] r27044 - haiku/trunk/src/kits/storage Message-ID: <200808181853.m7IIrVZF026747@sheep.berlios.de> Author: stippi Date: 2008-08-18 20:53:29 +0200 (Mon, 18 Aug 2008) New Revision: 27044 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27044&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: * Puh, there was quite a confusion with variable names here, Axel. Don't we have this "blah shadows a parameter" warning enabled? * data was leaked in the error code path when allocating the bitmaps failed. * I've added a check if the provided buffer even has the right size before copying the B_CMAP8 bitmap data into it. Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 17:57:03 UTC (rev 27043) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 18:53:29 UTC (rev 27044) @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -181,31 +182,35 @@ close(fd); uint8* data; - size_t size; + size_t dataSize; type_code type; - status_t status = get_device_icon(device, &data, &size, &type); + status_t status = get_device_icon(device, &data, &dataSize, &type); if (status == B_OK) { - BBitmap* icon = new(std::nothrow) BBitmap( + BBitmap* icon32 = new(std::nothrow) BBitmap( BRect(0, 0, size - 1, size - 1), B_BITMAP_NO_SERVER_LINK, B_RGBA32); - BBitmap* target = new(std::nothrow) BBitmap( + BBitmap* icon8 = new(std::nothrow) BBitmap( BRect(0, 0, size - 1, size - 1), B_BITMAP_NO_SERVER_LINK, B_CMAP8); - if (icon == NULL || icon->InitCheck() != B_OK || target == NULL - || target->InitCheck() != B_OK) { - delete icon; - delete target; + + ArrayDeleter dataDeleter(data); + ObjectDeleter icon32Deleter(icon32); + ObjectDeleter icon8Deleter(icon8); + + if (icon32 == NULL || icon32->InitCheck() != B_OK || icon8 == NULL + || icon8->InitCheck() != B_OK) { return B_NO_MEMORY; } - status = BIconUtils::GetVectorIcon(data, size, icon); + + if (size < icon8->BitsLength()) + return B_BAD_VALUE; + + status = BIconUtils::GetVectorIcon(data, dataSize, icon32); if (status == B_OK) - status = BIconUtils::ConvertToCMAP8(icon, target); + status = BIconUtils::ConvertToCMAP8(icon32, icon8); if (status == B_OK) - memcpy(icon, target->Bits(), target->BitsLength()); + memcpy(icon, icon8->Bits(), icon8->BitsLength()); - delete icon; - delete target; - delete[] data; return status; } return errno; From haiku at kaldience.com Mon Aug 18 21:03:14 2008 From: haiku at kaldience.com (Maurice Kalinowski) Date: Mon, 18 Aug 2008 21:03:14 +0200 Subject: [Haiku-commits] r26977 - haiku/trunk/build/jam In-Reply-To: <200808151100.m7FB0DqR019647@sheep.berlios.de> References: <200808151100.m7FB0DqR019647@sheep.berlios.de> Message-ID: <48A9C772.5080607@kaldience.com> axeld at BerliOS wrote: > Author: axeld > Date: 2008-08-15 13:00:07 +0200 (Fri, 15 Aug 2008) > New Revision: 26977 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26977&view=rev > > Modified: > haiku/trunk/build/jam/FileRules > Log: > * Applied patch by Andreas that uses git as a fallback in case retrieving > the revision failed using "svn info". > * While there is no official git tree, this should help those people using > svn over git. > > With this change I have a dead git-svn call hanging with 30% cpu usage in my VM. Maybe it's related to a network-timeout (vmware is quite unstable here for some reason), or something different. Can anybody else reproduce this? Maurice From korli at mail.berlios.de Mon Aug 18 22:03:06 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 22:03:06 +0200 Subject: [Haiku-commits] r27045 - in haiku/vendor/mesa/current: glu/libutil headers/public src/drivers/common src/glapi src/main src/shader src/shader/slang src/shader/slang/library src/swrast src/vbo src/x86 Message-ID: <200808182003.m7IK36Iu031203@sheep.berlios.de> Author: korli Date: 2008-08-18 22:03:00 +0200 (Mon, 18 Aug 2008) New Revision: 27045 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27045&view=rev Added: haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_common_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_builtin_120_fragment_gc.h haiku/vendor/mesa/current/src/x86/matypes.h Modified: haiku/vendor/mesa/current/glu/libutil/mipmap.c haiku/vendor/mesa/current/glu/libutil/quad.c haiku/vendor/mesa/current/headers/public/glext.h haiku/vendor/mesa/current/src/drivers/common/driverfuncs.c haiku/vendor/mesa/current/src/glapi/glapi.c haiku/vendor/mesa/current/src/main/context.c haiku/vendor/mesa/current/src/main/context.h haiku/vendor/mesa/current/src/main/dd.h haiku/vendor/mesa/current/src/main/depthstencil.c haiku/vendor/mesa/current/src/main/dlist.c haiku/vendor/mesa/current/src/main/drawpix.c haiku/vendor/mesa/current/src/main/execmem.c haiku/vendor/mesa/current/src/main/extensions.c haiku/vendor/mesa/current/src/main/fbobject.c haiku/vendor/mesa/current/src/main/get.c haiku/vendor/mesa/current/src/main/glheader.h haiku/vendor/mesa/current/src/main/image.c haiku/vendor/mesa/current/src/main/imports.c haiku/vendor/mesa/current/src/main/mm.c haiku/vendor/mesa/current/src/main/mm.h haiku/vendor/mesa/current/src/main/shaders.c haiku/vendor/mesa/current/src/main/stencil.c haiku/vendor/mesa/current/src/main/texcompress_s3tc.c haiku/vendor/mesa/current/src/main/texenvprogram.c haiku/vendor/mesa/current/src/main/texformat.h haiku/vendor/mesa/current/src/main/texstate.c haiku/vendor/mesa/current/src/main/texstore.c haiku/vendor/mesa/current/src/main/version.h haiku/vendor/mesa/current/src/shader/arbprogparse.c haiku/vendor/mesa/current/src/shader/prog_execute.c haiku/vendor/mesa/current/src/shader/prog_parameter.c haiku/vendor/mesa/current/src/shader/program.c haiku/vendor/mesa/current/src/shader/shader_api.c haiku/vendor/mesa/current/src/shader/shader_api.h haiku/vendor/mesa/current/src/shader/slang/library/slang_common_builtin.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_common_builtin_gc.h haiku/vendor/mesa/current/src/shader/slang/library/slang_core.gc haiku/vendor/mesa/current/src/shader/slang/library/slang_core_gc.h haiku/vendor/mesa/current/src/shader/slang/slang_compile.c haiku/vendor/mesa/current/src/shader/slang/slang_emit.c haiku/vendor/mesa/current/src/shader/slang/slang_link.c haiku/vendor/mesa/current/src/shader/slang/slang_preprocess.c haiku/vendor/mesa/current/src/swrast/s_aatriangle.c haiku/vendor/mesa/current/src/swrast/s_aatritemp.h haiku/vendor/mesa/current/src/swrast/s_bitmap.c haiku/vendor/mesa/current/src/swrast/s_context.c haiku/vendor/mesa/current/src/swrast/s_context.h haiku/vendor/mesa/current/src/swrast/s_copypix.c haiku/vendor/mesa/current/src/swrast/s_drawpix.c haiku/vendor/mesa/current/src/swrast/s_fragprog.c haiku/vendor/mesa/current/src/swrast/s_span.h haiku/vendor/mesa/current/src/swrast/s_zoom.c haiku/vendor/mesa/current/src/vbo/vbo_exec_draw.c haiku/vendor/mesa/current/src/vbo/vbo_save_api.c haiku/vendor/mesa/current/src/vbo/vbo_save_draw.c haiku/vendor/mesa/current/src/x86/assyntax.h haiku/vendor/mesa/current/src/x86/common_x86.c haiku/vendor/mesa/current/src/x86/read_rgba_span_x86.S Log: updating mesa vendor with version 7.0.4 Modified: haiku/vendor/mesa/current/glu/libutil/mipmap.c =================================================================== --- haiku/vendor/mesa/current/glu/libutil/mipmap.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/glu/libutil/mipmap.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -6627,7 +6627,7 @@ static TexImage3Dproc pTexImage3D = 0; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__WIN32__) # include # include #else @@ -6642,7 +6642,7 @@ const GLvoid *pixels ) { if (!pTexImage3D) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D"); if (!pTexImage3D) pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT"); Modified: haiku/vendor/mesa/current/glu/libutil/quad.c =================================================================== --- haiku/vendor/mesa/current/glu/libutil/quad.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/glu/libutil/quad.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -713,8 +713,8 @@ GLfloat cosCache3b[CACHE_SIZE]; GLfloat angle; GLfloat zLow, zHigh; - GLfloat sintemp1, sintemp2, sintemp3 = 0.0, sintemp4 = 0.0; - GLfloat costemp1, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0; + GLfloat sintemp1 = 0.0, sintemp2 = 0.0, sintemp3 = 0.0, sintemp4 = 0.0; + GLfloat costemp1 = 0.0, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0; GLboolean needCache2, needCache3; GLint start, finish; Modified: haiku/vendor/mesa/current/headers/public/glext.h =================================================================== --- haiku/vendor/mesa/current/headers/public/glext.h 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/headers/public/glext.h 2008-08-18 20:03:00 UTC (rev 27045) @@ -46,9 +46,9 @@ /*************************************************************/ /* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2008/03/24 */ +/* glext.h last updated 2008/08/10 */ /* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 40 +#define GL_GLEXT_VERSION 41 #ifndef GL_VERSION_1_2 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 @@ -479,6 +479,117 @@ #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B #endif +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB +#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 +#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 +#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 +#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 +#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 +#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 +#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#endif + #ifndef GL_ARB_multitexture #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 @@ -974,6 +1085,175 @@ #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF #endif +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_INDEX 0x8222 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -3382,7 +3662,41 @@ #ifndef GL_GREMEDY_frame_terminator #endif +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + + /*************************************************************/ #include @@ -3419,16 +3733,16 @@ #endif #ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glext.h, so must be protected */ +/* This code block is duplicated in glxext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ /* (as used in the GL_EXT_timer_query extension). */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #include -#elif defined(__sun__) +#elif defined(__sun__) || defined(__digital__) #include #if defined(__STDC__) -#if defined(__arch64__) +#if defined(__arch64__) || defined(_LP64) typedef long int int64_t; typedef unsigned long int uint64_t; #else @@ -3436,7 +3750,7 @@ typedef unsigned long long int uint64_t; #endif /* __arch64__ */ #endif /* __STDC__ */ -#elif defined( __VMS ) +#elif defined( __VMS ) || defined(__sgi) #include #elif defined(__SCO__) || defined(__USLC__) #include @@ -3990,6 +4304,10 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +#endif + #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #ifdef GL_GLEXT_PROTOTYPES @@ -4569,6 +4887,54 @@ #define GL_ARB_pixel_buffer_object 1 #endif +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #endif @@ -7263,7 +7629,19 @@ typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); #endif +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#endif +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#endif + + #ifdef __cplusplus } #endif Modified: haiku/vendor/mesa/current/src/drivers/common/driverfuncs.c =================================================================== --- haiku/vendor/mesa/current/src/drivers/common/driverfuncs.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/drivers/common/driverfuncs.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -284,6 +284,7 @@ driver->GetShaderInfoLog = _mesa_get_shader_info_log; driver->GetShaderSource = _mesa_get_shader_source; driver->GetUniformfv = _mesa_get_uniformfv; + driver->GetUniformiv = _mesa_get_uniformiv; driver->GetUniformLocation = _mesa_get_uniform_location; driver->IsProgram = _mesa_is_program; driver->IsShader = _mesa_is_shader; Modified: haiku/vendor/mesa/current/src/glapi/glapi.c =================================================================== --- haiku/vendor/mesa/current/src/glapi/glapi.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/glapi/glapi.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -724,7 +724,7 @@ * \returns * The offset in the dispatch table of the named function. A pointer to the * driver's implementation of the named function should be stored at - * \c dispatch_table[\c offset]. + * \c dispatch_table[\c offset]. Return -1 if error/problem. * * \sa glXGetProcAddress * @@ -773,7 +773,7 @@ */ if (!function_names[i] || function_names[i][0] != 'g' || function_names[i][1] != 'l') - return GL_FALSE; + return -1; /* Determine if the named function already exists. If the function does * exist, it must have the same parameter signature as the function Modified: haiku/vendor/mesa/current/src/main/context.c =================================================================== --- haiku/vendor/mesa/current/src/main/context.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/context.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -610,6 +610,21 @@ } /** + * Callback for freeing shader program data. Call it before delete_shader_cb + * to avoid memory access error. + */ +static void +free_shader_program_data_cb(GLuint id, void *data, void *userData) +{ + GLcontext *ctx = (GLcontext *) userData; + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + + if (shProg->Type == GL_SHADER_PROGRAM_MESA) { + _mesa_free_shader_program_data(ctx, shProg); + } +} + +/** * Callback for deleting shader and shader programs objects. * Called by _mesa_HashDeleteAll(). */ @@ -656,7 +671,8 @@ { struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; rb->RefCount = 0; /* see comment for FBOs above */ - rb->Delete(rb); + if (rb->Delete) + rb->Delete(rb); } @@ -708,6 +724,7 @@ _mesa_DeleteHashTable(ss->ArrayObjects); #if FEATURE_ARB_shader_objects + _mesa_HashWalk(ss->ShaderObjects, free_shader_program_data_cb, ctx); _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx); _mesa_DeleteHashTable(ss->ShaderObjects); #endif Modified: haiku/vendor/mesa/current/src/main/context.h =================================================================== --- haiku/vendor/mesa/current/src/main/context.h 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/context.h 2008-08-18 20:03:00 UTC (rev 27045) @@ -273,8 +273,10 @@ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ || (CTX)->Fog.ColorSumEnabled \ || ((CTX)->VertexProgram._Current && \ + ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) && \ ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \ || ((CTX)->FragmentProgram._Current && \ + ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) && \ ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \ ) Modified: haiku/vendor/mesa/current/src/main/dd.h =================================================================== --- haiku/vendor/mesa/current/src/main/dd.h 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/dd.h 2008-08-18 20:03:00 UTC (rev 27045) @@ -862,6 +862,8 @@ GLsizei *length, GLcharARB *sourceOut); void (*GetUniformfv)(GLcontext *ctx, GLuint program, GLint location, GLfloat *params); + void (*GetUniformiv)(GLcontext *ctx, GLuint program, GLint location, + GLint *params); GLint (*GetUniformLocation)(GLcontext *ctx, GLuint program, const GLcharARB *name); GLboolean (*IsProgram)(GLcontext *ctx, GLuint name); Modified: haiku/vendor/mesa/current/src/main/depthstencil.c =================================================================== --- haiku/vendor/mesa/current/src/main/depthstencil.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/depthstencil.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -213,7 +213,7 @@ const void *values, const GLubyte *mask) { struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; + const GLuint *src = (const GLuint *) values; ASSERT(z24rb->DataType == GL_UNSIGNED_INT); ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT); ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); Modified: haiku/vendor/mesa/current/src/main/dlist.c =================================================================== --- haiku/vendor/mesa/current/src/main/dlist.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/dlist.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -3246,6 +3246,36 @@ static void GLAPIENTRY +save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, + GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* GL_FRONT */ + n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_FRONT; + n[2].e = frontfunc; + n[3].i = ref; + n[4].ui = mask; + } + /* GL_BACK */ + n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_BACK; + n[2].e = backfunc; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); + CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); + } +} + + +static void GLAPIENTRY save_StencilMaskSeparate(GLenum face, GLuint mask) { GET_CURRENT_CONTEXT(ctx); @@ -7870,6 +7900,9 @@ SET_StencilMaskSeparate(table, save_StencilMaskSeparate); SET_StencilOpSeparate(table, save_StencilOpSeparate); + /* ATI_separate_stencil */ + SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); + /* GL_ARB_imaging */ /* Not all are supported */ SET_BlendColor(table, save_BlendColor); Modified: haiku/vendor/mesa/current/src/main/drawpix.c =================================================================== --- haiku/vendor/mesa/current/src/main/drawpix.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/drawpix.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -342,8 +342,9 @@ if (ctx->RenderMode == GL_RENDER) { /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig); + const GLfloat epsilon = 0.0001; + GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); + GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); } #if _HAVE_FULL_GL Modified: haiku/vendor/mesa/current/src/main/execmem.c =================================================================== --- haiku/vendor/mesa/current/src/main/execmem.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/execmem.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -36,7 +36,7 @@ -#if defined(__linux__) +#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) /* * Allocate a large block of memory which can hold code then dole it out @@ -47,6 +47,11 @@ #include #include "mm.h" +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + + #define EXEC_HEAP_SIZE (10*1024*1024) _glthread_DECLARE_STATIC_MUTEX(exec_mutex); Modified: haiku/vendor/mesa/current/src/main/extensions.c =================================================================== --- haiku/vendor/mesa/current/src/main/extensions.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/extensions.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -201,7 +201,7 @@ ctx->Extensions.ARB_shading_language_100 = GL_TRUE; #endif #if FEATURE_ARB_shading_language_120 - ctx->Extensions.ARB_shading_language_120 = GL_TRUE; + ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */ #endif ctx->Extensions.ARB_shadow = GL_TRUE; ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; @@ -415,7 +415,7 @@ ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif #ifdef FEATURE_ARB_shading_language_120 - ctx->Extensions.ARB_shading_language_120 = GL_TRUE; + ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */ #endif } Modified: haiku/vendor/mesa/current/src/main/fbobject.c =================================================================== --- haiku/vendor/mesa/current/src/main/fbobject.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/fbobject.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -1464,7 +1464,12 @@ return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: if (att->Type == GL_TEXTURE) { - *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { + *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + } + else { + *params = 0; + } } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1473,7 +1478,12 @@ return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: if (att->Type == GL_TEXTURE) { - *params = att->Zoffset; + if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { + *params = att->Zoffset; + } + else { + *params = 0; + } } else { _mesa_error(ctx, GL_INVALID_ENUM, Modified: haiku/vendor/mesa/current/src/main/get.c =================================================================== --- haiku/vendor/mesa/current/src/main/get.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/get.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -753,6 +753,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits ); break; + case GL_POLYGON_OFFSET_POINT: + params[0] = ctx->Polygon.OffsetPoint; + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = ctx->Polygon.OffsetLine; + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = ctx->Polygon.OffsetFill; + break; case GL_POLYGON_SMOOTH: params[0] = ctx->Polygon.SmoothFlag; break; @@ -879,18 +888,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = FLOAT_TO_BOOLEAN(color[0]); - params[1] = FLOAT_TO_BOOLEAN(color[1]); - params[2] = FLOAT_TO_BOOLEAN(color[2]); - params[3] = FLOAT_TO_BOOLEAN(color[3]); - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0); break; @@ -2588,6 +2585,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = ctx->Polygon.OffsetUnits ; break; + case GL_POLYGON_OFFSET_POINT: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetPoint); + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetLine); + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetFill); + break; case GL_POLYGON_SMOOTH: params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.SmoothFlag); break; @@ -2714,18 +2720,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = color[0]; - params[1] = color[1]; - params[2] = color[2]; - params[3] = color[3]; - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; @@ -4423,6 +4417,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = IROUND(ctx->Polygon.OffsetUnits ); break; + case GL_POLYGON_OFFSET_POINT: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetPoint); + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetLine); + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetFill); + break; case GL_POLYGON_SMOOTH: params[0] = BOOLEAN_TO_INT(ctx->Polygon.SmoothFlag); break; @@ -4549,18 +4552,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name; break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = FLOAT_TO_INT(color[0]); - params[1] = FLOAT_TO_INT(color[1]); - params[2] = FLOAT_TO_INT(color[2]); - params[3] = FLOAT_TO_INT(color[3]); - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_INT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; Modified: haiku/vendor/mesa/current/src/main/glheader.h =================================================================== --- haiku/vendor/mesa/current/src/main/glheader.h 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/glheader.h 2008-08-18 20:03:00 UTC (rev 27045) @@ -77,6 +77,12 @@ # if _MSC_VER == 1200 typedef UINT_PTR uintptr_t; # endif +#elif defined(__INTERIX) +/* Interix 3.x has a gcc that shadows this. */ +# ifndef _UINTPTR_T_DEFINED + typedef unsigned long uintptr_t; +# define _UINTPTR_T_DEFINED +# endif #else # include #endif Modified: haiku/vendor/mesa/current/src/main/image.c =================================================================== --- haiku/vendor/mesa/current/src/main/image.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/image.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -3963,7 +3963,7 @@ DEPTH_VALUES(GLuint, UINT_TO_FLOAT); break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ - if (dstType == GL_UNSIGNED_INT && + if (dstType == GL_UNSIGNED_INT_24_8_EXT && depthScale == (GLfloat) 0xffffff && ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { Modified: haiku/vendor/mesa/current/src/main/imports.c =================================================================== --- haiku/vendor/mesa/current/src/main/imports.c 2008-08-18 18:53:29 UTC (rev 27044) +++ haiku/vendor/mesa/current/src/main/imports.c 2008-08-18 20:03:00 UTC (rev 27045) @@ -104,6 +104,8 @@ (void) posix_memalign(& mem, alignment, bytes); return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + return _aligned_malloc(bytes, alignment); #else uintptr_t ptr, buf; @@ -144,6 +146,15 @@ } return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + void *mem; + + mem = _aligned_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; #else uintptr_t ptr, buf; @@ -180,6 +191,8 @@ { #if defined(HAVE_POSIX_MEMALIGN) free(ptr); +#elif defined(_WIN32) && defined(_MSC_VER) + _aligned_free(ptr); #else void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); void *realAddr = *cubbyHole; @@ -194,6 +207,10 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment) { +#if defined(_WIN32) && defined(_MSC_VER) + (void) oldSize; + return _aligned_realloc(oldBuffer, newSize, alignment); +#else const size_t copySize = (oldSize < newSize) ? oldSize : newSize; void *newBuf = _mesa_align_malloc(newSize, alignment); if (newBuf && oldBuffer && copySize > 0) { @@ -202,6 +219,7 @@ if (oldBuffer) _mesa_align_free(oldBuffer); return newBuf; +#endif } @@ -258,7 +276,7 @@ void _mesa_bzero( void *dst, size_t n ) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) bzero( dst, n ); #else memset( dst, 0, n ); @@ -560,6 +578,7 @@ bit++; i >>= 1; } + bit++; } return bit; #else [... truncated: 4375 lines follow ...] From korli at mail.berlios.de Mon Aug 18 22:04:20 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 22:04:20 +0200 Subject: [Haiku-commits] r27046 - haiku/vendor/mesa Message-ID: <200808182004.m7IK4KvC031319@sheep.berlios.de> Author: korli Date: 2008-08-18 22:04:20 +0200 (Mon, 18 Aug 2008) New Revision: 27046 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27046&view=rev Added: haiku/vendor/mesa/7.0.4/ Log: tagging Mesa 7.0.4 Copied: haiku/vendor/mesa/7.0.4 (from rev 27045, haiku/vendor/mesa/current) From axeld at pinc-software.de Mon Aug 18 22:16:57 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 18 Aug 2008 22:16:57 +0200 CEST Subject: [Haiku-commits] r27044 - haiku/trunk/src/kits/storage In-Reply-To: <200808181853.m7IIrVZF026747@sheep.berlios.de> Message-ID: <49459426115-BeMail@zon> stippi at mail.berlios.de wrote: > Log: > * Puh, there was quite a confusion with variable names here, Axel. > Don't we have this "blah shadows a parameter" warning enabled? We should, but at least I didn't see anything - maybe Linux compiles too fast for me ;-) Thanks for cleaning that up! > * data was leaked in the error code path when allocating the bitmaps > failed. Thanks! > * I've added a check if the provided buffer even has the right > size before copying the B_CMAP8 bitmap data into it. I think this check is wrong, though - size should be either B_MINI_ICON or B_LARGE_ICON at this point (the check is at the beginning of the function) - it has nothing to do with BitsLength(). It's always correct at this point, anyway. Bye, Axel. From axeld at pinc-software.de Mon Aug 18 22:17:57 2008 From: axeld at pinc-software.de (Axel =?utf-8?q?D=C3=B6rfler?=) Date: Mon, 18 Aug 2008 22:17:57 +0200 CEST Subject: [Haiku-commits] r26977 - haiku/trunk/build/jam In-Reply-To: <48A9C772.5080607@kaldience.com> Message-ID: <49519365637-BeMail@zon> Maurice Kalinowski wrote: > With this change I have a dead git-svn call hanging with 30% cpu > usage > in my VM. Maybe it's related to a network-timeout (vmware is quite > unstable here for some reason), or something different. > > Can anybody else reproduce this? Since I more or less failed setting up git for my use, I haven't even tested this change, but apparently Andreas has, at least :-) Bye, Axel. From korli at mail.berlios.de Mon Aug 18 22:19:05 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 22:19:05 +0200 Subject: [Haiku-commits] r27047 - in haiku/trunk: headers/os/opengl/GL src/kits/opengl/glu/libutil src/kits/opengl/mesa/drivers/common src/kits/opengl/mesa/glapi src/kits/opengl/mesa/main src/kits/opengl/mesa/shader src/kits/opengl/mesa/shader/slang src/kits/opengl/mesa/shader/slang/library src/kits/opengl/mesa/swrast src/kits/opengl/mesa/vbo src/kits/opengl/mesa/x86 Message-ID: <200808182019.m7IKJ5B1032681@sheep.berlios.de> Author: korli Date: 2008-08-18 22:19:01 +0200 (Mon, 18 Aug 2008) New Revision: 27047 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27047&view=rev Added: haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_common_gc.h haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h Modified: haiku/trunk/headers/os/opengl/GL/glext.h haiku/trunk/src/kits/opengl/glu/libutil/mipmap.c haiku/trunk/src/kits/opengl/glu/libutil/quad.c haiku/trunk/src/kits/opengl/mesa/drivers/common/driverfuncs.c haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c haiku/trunk/src/kits/opengl/mesa/main/context.c haiku/trunk/src/kits/opengl/mesa/main/context.h haiku/trunk/src/kits/opengl/mesa/main/dd.h haiku/trunk/src/kits/opengl/mesa/main/depthstencil.c haiku/trunk/src/kits/opengl/mesa/main/dlist.c haiku/trunk/src/kits/opengl/mesa/main/drawpix.c haiku/trunk/src/kits/opengl/mesa/main/execmem.c haiku/trunk/src/kits/opengl/mesa/main/extensions.c haiku/trunk/src/kits/opengl/mesa/main/fbobject.c haiku/trunk/src/kits/opengl/mesa/main/get.c haiku/trunk/src/kits/opengl/mesa/main/glheader.h haiku/trunk/src/kits/opengl/mesa/main/image.c haiku/trunk/src/kits/opengl/mesa/main/imports.c haiku/trunk/src/kits/opengl/mesa/main/mm.c haiku/trunk/src/kits/opengl/mesa/main/mm.h haiku/trunk/src/kits/opengl/mesa/main/shaders.c haiku/trunk/src/kits/opengl/mesa/main/stencil.c haiku/trunk/src/kits/opengl/mesa/main/texcompress_s3tc.c haiku/trunk/src/kits/opengl/mesa/main/texenvprogram.c haiku/trunk/src/kits/opengl/mesa/main/texformat.h haiku/trunk/src/kits/opengl/mesa/main/texstate.c haiku/trunk/src/kits/opengl/mesa/main/texstore.c haiku/trunk/src/kits/opengl/mesa/main/version.h haiku/trunk/src/kits/opengl/mesa/shader/arbprogparse.c haiku/trunk/src/kits/opengl/mesa/shader/prog_execute.c haiku/trunk/src/kits/opengl/mesa/shader/prog_parameter.c haiku/trunk/src/kits/opengl/mesa/shader/program.c haiku/trunk/src/kits/opengl/mesa/shader/shader_api.c haiku/trunk/src/kits/opengl/mesa/shader/shader_api.h haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_common_builtin_gc.h haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_core.gc haiku/trunk/src/kits/opengl/mesa/shader/slang/library/slang_core_gc.h haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_compile.c haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_emit.c haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_link.c haiku/trunk/src/kits/opengl/mesa/shader/slang/slang_preprocess.c haiku/trunk/src/kits/opengl/mesa/swrast/s_aatriangle.c haiku/trunk/src/kits/opengl/mesa/swrast/s_aatritemp.h haiku/trunk/src/kits/opengl/mesa/swrast/s_bitmap.c haiku/trunk/src/kits/opengl/mesa/swrast/s_context.c haiku/trunk/src/kits/opengl/mesa/swrast/s_context.h haiku/trunk/src/kits/opengl/mesa/swrast/s_copypix.c haiku/trunk/src/kits/opengl/mesa/swrast/s_drawpix.c haiku/trunk/src/kits/opengl/mesa/swrast/s_fragprog.c haiku/trunk/src/kits/opengl/mesa/swrast/s_span.h haiku/trunk/src/kits/opengl/mesa/swrast/s_zoom.c haiku/trunk/src/kits/opengl/mesa/vbo/vbo_exec_draw.c haiku/trunk/src/kits/opengl/mesa/vbo/vbo_save_api.c haiku/trunk/src/kits/opengl/mesa/vbo/vbo_save_draw.c haiku/trunk/src/kits/opengl/mesa/x86/assyntax.h haiku/trunk/src/kits/opengl/mesa/x86/common_x86.c haiku/trunk/src/kits/opengl/mesa/x86/matypes.h haiku/trunk/src/kits/opengl/mesa/x86/read_rgba_span_x86.S Log: updated mesa to 7.0.4 Modified: haiku/trunk/headers/os/opengl/GL/glext.h =================================================================== --- haiku/trunk/headers/os/opengl/GL/glext.h 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/headers/os/opengl/GL/glext.h 2008-08-18 20:19:01 UTC (rev 27047) @@ -46,9 +46,9 @@ /*************************************************************/ /* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2008/03/24 */ +/* glext.h last updated 2008/08/10 */ /* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 40 +#define GL_GLEXT_VERSION 41 #ifndef GL_VERSION_1_2 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 @@ -479,6 +479,117 @@ #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B #endif +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB +#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 +#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 +#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 +#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 +#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 +#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 +#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#endif + #ifndef GL_ARB_multitexture #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 @@ -974,6 +1085,175 @@ #define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF #endif +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_INDEX 0x8222 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + #ifndef GL_EXT_abgr #define GL_ABGR_EXT 0x8000 #endif @@ -3382,7 +3662,41 @@ #ifndef GL_GREMEDY_frame_terminator #endif +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + + /*************************************************************/ #include @@ -3419,16 +3733,16 @@ #endif #ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glext.h, so must be protected */ +/* This code block is duplicated in glxext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ /* (as used in the GL_EXT_timer_query extension). */ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #include -#elif defined(__sun__) +#elif defined(__sun__) || defined(__digital__) #include #if defined(__STDC__) -#if defined(__arch64__) +#if defined(__arch64__) || defined(_LP64) typedef long int int64_t; typedef unsigned long int uint64_t; #else @@ -3436,7 +3750,7 @@ typedef unsigned long long int uint64_t; #endif /* __arch64__ */ #endif /* __STDC__ */ -#elif defined( __VMS ) +#elif defined( __VMS ) || defined(__sgi) #include #elif defined(__SCO__) || defined(__USLC__) #include @@ -3990,6 +4304,10 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +#endif + #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 #ifdef GL_GLEXT_PROTOTYPES @@ -4569,6 +4887,54 @@ #define GL_ARB_pixel_buffer_object 1 #endif +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #endif @@ -7263,7 +7629,19 @@ typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); #endif +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#endif +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#endif + + #ifdef __cplusplus } #endif Modified: haiku/trunk/src/kits/opengl/glu/libutil/mipmap.c =================================================================== --- haiku/trunk/src/kits/opengl/glu/libutil/mipmap.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/glu/libutil/mipmap.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -6627,7 +6627,7 @@ static TexImage3Dproc pTexImage3D = 0; -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__WIN32__) # include # include #else @@ -6642,7 +6642,7 @@ const GLvoid *pixels ) { if (!pTexImage3D) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(__WIN32__) pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D"); if (!pTexImage3D) pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT"); Modified: haiku/trunk/src/kits/opengl/glu/libutil/quad.c =================================================================== --- haiku/trunk/src/kits/opengl/glu/libutil/quad.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/glu/libutil/quad.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -713,8 +713,8 @@ GLfloat cosCache3b[CACHE_SIZE]; GLfloat angle; GLfloat zLow, zHigh; - GLfloat sintemp1, sintemp2, sintemp3 = 0.0, sintemp4 = 0.0; - GLfloat costemp1, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0; + GLfloat sintemp1 = 0.0, sintemp2 = 0.0, sintemp3 = 0.0, sintemp4 = 0.0; + GLfloat costemp1 = 0.0, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0; GLboolean needCache2, needCache3; GLint start, finish; Modified: haiku/trunk/src/kits/opengl/mesa/drivers/common/driverfuncs.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/drivers/common/driverfuncs.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/drivers/common/driverfuncs.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -284,6 +284,7 @@ driver->GetShaderInfoLog = _mesa_get_shader_info_log; driver->GetShaderSource = _mesa_get_shader_source; driver->GetUniformfv = _mesa_get_uniformfv; + driver->GetUniformiv = _mesa_get_uniformiv; driver->GetUniformLocation = _mesa_get_uniform_location; driver->IsProgram = _mesa_is_program; driver->IsShader = _mesa_is_shader; Modified: haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/glapi/glapi.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -724,7 +724,7 @@ * \returns * The offset in the dispatch table of the named function. A pointer to the * driver's implementation of the named function should be stored at - * \c dispatch_table[\c offset]. + * \c dispatch_table[\c offset]. Return -1 if error/problem. * * \sa glXGetProcAddress * @@ -773,7 +773,7 @@ */ if (!function_names[i] || function_names[i][0] != 'g' || function_names[i][1] != 'l') - return GL_FALSE; + return -1; /* Determine if the named function already exists. If the function does * exist, it must have the same parameter signature as the function Modified: haiku/trunk/src/kits/opengl/mesa/main/context.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/context.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/context.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -610,6 +610,21 @@ } /** + * Callback for freeing shader program data. Call it before delete_shader_cb + * to avoid memory access error. + */ +static void +free_shader_program_data_cb(GLuint id, void *data, void *userData) +{ + GLcontext *ctx = (GLcontext *) userData; + struct gl_shader_program *shProg = (struct gl_shader_program *) data; + + if (shProg->Type == GL_SHADER_PROGRAM_MESA) { + _mesa_free_shader_program_data(ctx, shProg); + } +} + +/** * Callback for deleting shader and shader programs objects. * Called by _mesa_HashDeleteAll(). */ @@ -656,7 +671,8 @@ { struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; rb->RefCount = 0; /* see comment for FBOs above */ - rb->Delete(rb); + if (rb->Delete) + rb->Delete(rb); } @@ -708,6 +724,7 @@ _mesa_DeleteHashTable(ss->ArrayObjects); #if FEATURE_ARB_shader_objects + _mesa_HashWalk(ss->ShaderObjects, free_shader_program_data_cb, ctx); _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx); _mesa_DeleteHashTable(ss->ShaderObjects); #endif Modified: haiku/trunk/src/kits/opengl/mesa/main/context.h =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/context.h 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/context.h 2008-08-18 20:19:01 UTC (rev 27047) @@ -273,8 +273,10 @@ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ || (CTX)->Fog.ColorSumEnabled \ || ((CTX)->VertexProgram._Current && \ + ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) && \ ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \ || ((CTX)->FragmentProgram._Current && \ + ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) && \ ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \ ) Modified: haiku/trunk/src/kits/opengl/mesa/main/dd.h =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/dd.h 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/dd.h 2008-08-18 20:19:01 UTC (rev 27047) @@ -862,6 +862,8 @@ GLsizei *length, GLcharARB *sourceOut); void (*GetUniformfv)(GLcontext *ctx, GLuint program, GLint location, GLfloat *params); + void (*GetUniformiv)(GLcontext *ctx, GLuint program, GLint location, + GLint *params); GLint (*GetUniformLocation)(GLcontext *ctx, GLuint program, const GLcharARB *name); GLboolean (*IsProgram)(GLcontext *ctx, GLuint name); Modified: haiku/trunk/src/kits/opengl/mesa/main/depthstencil.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/depthstencil.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/depthstencil.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -213,7 +213,7 @@ const void *values, const GLubyte *mask) { struct gl_renderbuffer *dsrb = z24rb->Wrapped; - const GLubyte *src = (const GLubyte *) values; + const GLuint *src = (const GLuint *) values; ASSERT(z24rb->DataType == GL_UNSIGNED_INT); ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT); ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT); Modified: haiku/trunk/src/kits/opengl/mesa/main/dlist.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/dlist.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/dlist.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -3246,6 +3246,36 @@ static void GLAPIENTRY +save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, + GLuint mask) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + /* GL_FRONT */ + n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_FRONT; + n[2].e = frontfunc; + n[3].i = ref; + n[4].ui = mask; + } + /* GL_BACK */ + n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4); + if (n) { + n[1].e = GL_BACK; + n[2].e = backfunc; + n[3].i = ref; + n[4].ui = mask; + } + if (ctx->ExecuteFlag) { + CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask)); + CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask)); + } +} + + +static void GLAPIENTRY save_StencilMaskSeparate(GLenum face, GLuint mask) { GET_CURRENT_CONTEXT(ctx); @@ -7870,6 +7900,9 @@ SET_StencilMaskSeparate(table, save_StencilMaskSeparate); SET_StencilOpSeparate(table, save_StencilOpSeparate); + /* ATI_separate_stencil */ + SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI); + /* GL_ARB_imaging */ /* Not all are supported */ SET_BlendColor(table, save_BlendColor); Modified: haiku/trunk/src/kits/opengl/mesa/main/drawpix.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/drawpix.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/drawpix.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -342,8 +342,9 @@ if (ctx->RenderMode == GL_RENDER) { /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */ - GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig); - GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig); + const GLfloat epsilon = 0.0001; + GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig); + GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig); ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap ); } #if _HAVE_FULL_GL Modified: haiku/trunk/src/kits/opengl/mesa/main/execmem.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/execmem.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/execmem.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -36,7 +36,7 @@ -#if defined(__linux__) +#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) /* * Allocate a large block of memory which can hold code then dole it out @@ -47,6 +47,11 @@ #include #include "mm.h" +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + + #define EXEC_HEAP_SIZE (10*1024*1024) _glthread_DECLARE_STATIC_MUTEX(exec_mutex); Modified: haiku/trunk/src/kits/opengl/mesa/main/extensions.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/extensions.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/extensions.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -201,7 +201,7 @@ ctx->Extensions.ARB_shading_language_100 = GL_TRUE; #endif #if FEATURE_ARB_shading_language_120 - ctx->Extensions.ARB_shading_language_120 = GL_TRUE; + ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */ #endif ctx->Extensions.ARB_shadow = GL_TRUE; ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; @@ -415,7 +415,7 @@ ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif #ifdef FEATURE_ARB_shading_language_120 - ctx->Extensions.ARB_shading_language_120 = GL_TRUE; + ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */ #endif } Modified: haiku/trunk/src/kits/opengl/mesa/main/fbobject.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/fbobject.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/fbobject.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -1464,7 +1464,12 @@ return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: if (att->Type == GL_TEXTURE) { - *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + if (att->Texture && att->Texture->Target == GL_TEXTURE_CUBE_MAP) { + *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace; + } + else { + *params = 0; + } } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1473,7 +1478,12 @@ return; case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: if (att->Type == GL_TEXTURE) { - *params = att->Zoffset; + if (att->Texture && att->Texture->Target == GL_TEXTURE_3D) { + *params = att->Zoffset; + } + else { + *params = 0; + } } else { _mesa_error(ctx, GL_INVALID_ENUM, Modified: haiku/trunk/src/kits/opengl/mesa/main/get.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/get.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/get.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -753,6 +753,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits ); break; + case GL_POLYGON_OFFSET_POINT: + params[0] = ctx->Polygon.OffsetPoint; + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = ctx->Polygon.OffsetLine; + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = ctx->Polygon.OffsetFill; + break; case GL_POLYGON_SMOOTH: params[0] = ctx->Polygon.SmoothFlag; break; @@ -879,18 +888,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = FLOAT_TO_BOOLEAN(color[0]); - params[1] = FLOAT_TO_BOOLEAN(color[1]); - params[2] = FLOAT_TO_BOOLEAN(color[2]); - params[3] = FLOAT_TO_BOOLEAN(color[3]); - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0); break; @@ -2588,6 +2585,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = ctx->Polygon.OffsetUnits ; break; + case GL_POLYGON_OFFSET_POINT: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetPoint); + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetLine); + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.OffsetFill); + break; case GL_POLYGON_SMOOTH: params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.SmoothFlag); break; @@ -2714,18 +2720,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = color[0]; - params[1] = color[1]; - params[2] = color[2]; - params[3] = color[3]; - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_FLOAT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; @@ -4423,6 +4417,15 @@ case GL_POLYGON_OFFSET_UNITS: params[0] = IROUND(ctx->Polygon.OffsetUnits ); break; + case GL_POLYGON_OFFSET_POINT: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetPoint); + break; + case GL_POLYGON_OFFSET_LINE: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetLine); + break; + case GL_POLYGON_OFFSET_FILL: + params[0] = BOOLEAN_TO_INT(ctx->Polygon.OffsetFill); + break; case GL_POLYGON_SMOOTH: params[0] = BOOLEAN_TO_INT(ctx->Polygon.SmoothFlag); break; @@ -4549,18 +4552,6 @@ case GL_TEXTURE_BINDING_3D: params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name; break; - case GL_TEXTURE_ENV_COLOR: - { - const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; - params[0] = FLOAT_TO_INT(color[0]); - params[1] = FLOAT_TO_INT(color[1]); - params[2] = FLOAT_TO_INT(color[2]); - params[3] = FLOAT_TO_INT(color[3]); - } - break; - case GL_TEXTURE_ENV_MODE: - params[0] = ENUM_TO_INT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode); - break; case GL_TEXTURE_GEN_S: params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)); break; Modified: haiku/trunk/src/kits/opengl/mesa/main/glheader.h =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/glheader.h 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/glheader.h 2008-08-18 20:19:01 UTC (rev 27047) @@ -77,6 +77,12 @@ # if _MSC_VER == 1200 typedef UINT_PTR uintptr_t; # endif +#elif defined(__INTERIX) +/* Interix 3.x has a gcc that shadows this. */ +# ifndef _UINTPTR_T_DEFINED + typedef unsigned long uintptr_t; +# define _UINTPTR_T_DEFINED +# endif #else # include #endif Modified: haiku/trunk/src/kits/opengl/mesa/main/image.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/image.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/image.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -3963,7 +3963,7 @@ DEPTH_VALUES(GLuint, UINT_TO_FLOAT); break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ - if (dstType == GL_UNSIGNED_INT && + if (dstType == GL_UNSIGNED_INT_24_8_EXT && depthScale == (GLfloat) 0xffffff && ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { Modified: haiku/trunk/src/kits/opengl/mesa/main/imports.c =================================================================== --- haiku/trunk/src/kits/opengl/mesa/main/imports.c 2008-08-18 20:04:20 UTC (rev 27046) +++ haiku/trunk/src/kits/opengl/mesa/main/imports.c 2008-08-18 20:19:01 UTC (rev 27047) @@ -104,6 +104,8 @@ (void) posix_memalign(& mem, alignment, bytes); return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + return _aligned_malloc(bytes, alignment); #else uintptr_t ptr, buf; @@ -144,6 +146,15 @@ } return mem; +#elif defined(_WIN32) && defined(_MSC_VER) + void *mem; + + mem = _aligned_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; #else uintptr_t ptr, buf; @@ -180,6 +191,8 @@ { #if defined(HAVE_POSIX_MEMALIGN) free(ptr); +#elif defined(_WIN32) && defined(_MSC_VER) + _aligned_free(ptr); #else void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); void *realAddr = *cubbyHole; @@ -194,6 +207,10 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment) { +#if defined(_WIN32) && defined(_MSC_VER) + (void) oldSize; + return _aligned_realloc(oldBuffer, newSize, alignment); +#else const size_t copySize = (oldSize < newSize) ? oldSize : newSize; void *newBuf = _mesa_align_malloc(newSize, alignment); if (newBuf && oldBuffer && copySize > 0) { @@ -202,6 +219,7 @@ if (oldBuffer) _mesa_align_free(oldBuffer); return newBuf; +#endif } @@ -258,7 +276,7 @@ void _mesa_bzero( void *dst, size_t n ) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) bzero( dst, n ); #else memset( dst, 0, n ); @@ -560,6 +578,7 @@ bit++; i >>= 1; } + bit++; } return bit; #else [... truncated: 4124 lines follow ...] From korli at users.berlios.de Mon Aug 18 22:40:34 2008 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 18 Aug 2008 22:40:34 +0200 Subject: [Haiku-commits] r27044 - haiku/trunk/src/kits/storage In-Reply-To: <49459426115-BeMail@zon> References: <200808181853.m7IIrVZF026747@sheep.berlios.de> <49459426115-BeMail@zon> Message-ID: 2008/8/18 Axel D?rfler : > stippi at mail.berlios.de wrote: >> Log: >> * Puh, there was quite a confusion with variable names here, Axel. >> Don't we have this "blah shadows a parameter" warning enabled? > > We should, but at least I didn't see anything - maybe Linux compiles > too fast for me ;-) We don't have -Wshadow at least. It's also part of -Wextra or -W. We might not want this option for C files. Bye, J?r?me From axeld at mail.berlios.de Mon Aug 18 22:58:52 2008 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 18 Aug 2008 22:58:52 +0200 Subject: [Haiku-commits] r27048 - haiku/trunk/src/add-ons/kernel/file_systems/udf Message-ID: <200808182058.m7IKwqvD003717@sheep.berlios.de> Author: axeld Date: 2008-08-18 22:58:51 +0200 (Mon, 18 Aug 2008) New Revision: 27048 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27048&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp Log: * Fixed typo that prevented udf from being picked up: it's "modules", not "module" - hope that helps, Salvatore :-) * Fixed warnings. * Fixed udf_identify_partition() not to crash the system when a UDF partition is available, and also fixed it to actually not claim non-UDF partitions. * Moved partition naming (that shouldn't be done in identify!) to udf_scan_partition(), and corrected it (ie. use strdup(), don't copy into a NULL pointer...), but also disabled it for now, as it needs some more work to pass a cookie from identify now. * Whitespace cleanup. Modified: haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-18 20:19:01 UTC (rev 27047) +++ haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp 2008-08-18 20:58:51 UTC (rev 27048) @@ -39,21 +39,20 @@ // #pragma mark - fs_volume_ops fuctions + static float udf_identify_partition(int fd, partition_data *partition, void **_cookie) { TRACE(("udf_identify_partition: fd = %d\n", fd)); logical_volume_descriptor logicalVolumeDescriptor; partition_descriptor partitionDescriptors[kMaxPartitionDescriptors]; - uint8 partitionDescriptorCount; + uint8 descriptorCount = kMaxPartitionDescriptors; uint32 blockShift; status_t error = udf_recognize(fd, partition->offset, partition->size, 2048, blockShift, - logicalVolumeDescriptor, partitionDescriptors, partitionDescriptorCount); + logicalVolumeDescriptor, partitionDescriptors, descriptorCount); + if (error != B_OK) + return -1; - if (!error) { - UdfString name(logicalVolumeDescriptor.logical_volume_identifier()); - strcpy(partition->name, name.Utf8()); - } return 0.8f; } @@ -63,6 +62,10 @@ { TRACE(("udf_scan_partition: fd = %d\n", fd)); +#if 0 + UdfString name(logicalVolumeDescriptor.logical_volume_identifier()); + partition->content_name = strdup(name.Utf8()); +#endif return B_ERROR; } @@ -160,7 +163,7 @@ status = dir->Find(file, vnodeID); if (status == B_OK) { Icb *icb; - status = get_vnode(volume->FSVolume(), *vnodeID, + status = get_vnode(volume->FSVolume(), *vnodeID, (void **)&icb); if (status != B_OK) return B_ENTRY_NOT_FOUND; @@ -168,7 +171,7 @@ } TRACE(("udf_lookup: vnodeId: %Ld\n", *vnodeID)); - return status; + return status; } @@ -179,7 +182,7 @@ // rare circumstances. #if !DEBUG_TO_FILE DEBUG_INIT_ETC(NULL, ("node: %p", node)); -#endif +#endif Icb *icb = reinterpret_cast(node); delete icb; #if !DEBUG_TO_FILE @@ -229,8 +232,8 @@ udf_read(fs_volume *volume, fs_vnode *vnode, void *cookie, off_t pos, void *buffer, size_t *length) { - TRACE(("udf_read: ID = %d, pos = %d, length = %d\n", - ((Volume *)volume->private_volume)->ID(), pos, length)); + TRACE(("udf_read: ID = %ld, pos = %lld, length = %lu\n", + ((Volume *)volume->private_volume)->ID(), pos, *length)); Icb *icb = (Icb *)vnode->private_node; @@ -247,7 +250,7 @@ udf_open_dir(fs_volume *volume, fs_vnode *vnode, void **cookie) { DEBUG_INIT_ETC(NULL, ("node: %p, cookie: %p", node, cookie)); - + if (!volume || !vnode || !cookie) RETURN(B_BAD_VALUE); @@ -259,15 +262,15 @@ DirectoryIterator *iterator = NULL; status = dir->GetDirectoryIterator(&iterator); if (!status) { - *cookie = reinterpret_cast(iterator); + *cookie = reinterpret_cast(iterator); } else { PRINT(("Error getting directory iterator: 0x%lx, `%s'\n", status, strerror(error))); - } + } } else { PRINT(("Given icb is not a directory (type: %d)\n", dir->Type())); status = B_BAD_VALUE; } - + RETURN(status); } @@ -282,7 +285,7 @@ if (!_volume || !vnode || !cookie || !_num || bufferSize < sizeof(dirent)) RETURN(B_BAD_VALUE); - Volume *volume = (Volume *)_volume->private_volume; + Volume *volume = (Volume *)_volume->private_volume; Icb *dir = (Icb *)vnode->private_node; DirectoryIterator *iterator = reinterpret_cast(cookie); @@ -291,7 +294,7 @@ iterator->Parent())); return B_BAD_VALUE; } - + uint32 nameLength = bufferSize - sizeof(dirent) + 1; ino_t id; status_t status = iterator->GetNextEntry(dirent->d_name, &nameLength, &id); @@ -306,7 +309,7 @@ if (status == B_ENTRY_NOT_FOUND) status = B_OK; } - + RETURN(status); } @@ -316,7 +319,7 @@ { DEBUG_INIT_ETC(NULL, ("dir: %p, iterator: %p", node, cookie)); - + if (!volume || !vnode || !cookie) RETURN(B_BAD_VALUE); @@ -335,7 +338,7 @@ } -// #pragma mark - +// #pragma mark - /*! \brief mount @@ -386,8 +389,8 @@ // Finally, if that also fails, we're probably stuck with trying to mount // a regular file, so we just stat() it to get the device size. // - // If that fails, you're just SOL. - + // If that fails, you're just SOL. + if (ioctl(device, B_GET_PARTITION_INFO, &info) == 0) { PRINT(("partition_info:\n")); PRINT((" offset: %Ld\n", info.offset)); @@ -420,7 +423,7 @@ // Close the device close(device); } - + // Create and mount the volume volume = new(std::nothrow) Volume(_volume); status = volume->Mount(_device, deviceOffset, numBlock, 2048, flags); @@ -578,7 +581,7 @@ NULL, }; -module_info *module[] = { +module_info *modules[] = { (module_info *)&sUDFFileSystem, NULL, }; From korli at mail.berlios.de Mon Aug 18 23:06:39 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 23:06:39 +0200 Subject: [Haiku-commits] r27049 - haiku/trunk/src/add-ons/input_server/filters/screensaver Message-ID: <200808182106.m7IL6d9S004450@sheep.berlios.de> Author: korli Date: 2008-08-18 23:06:38 +0200 (Mon, 18 Aug 2008) New Revision: 27049 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27049&view=rev Modified: haiku/trunk/src/add-ons/input_server/filters/screensaver/ScreenSaverFilter.cpp Log: fCornerRunner could be NULL when reloading settings. Modified: haiku/trunk/src/add-ons/input_server/filters/screensaver/ScreenSaverFilter.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/filters/screensaver/ScreenSaverFilter.cpp 2008-08-18 20:58:51 UTC (rev 27048) +++ haiku/trunk/src/add-ons/input_server/filters/screensaver/ScreenSaverFilter.cpp 2008-08-18 21:06:38 UTC (rev 27049) @@ -347,7 +347,8 @@ fCurrentCorner = fBlankCorner; // start screen blanker after one second of inactivity - if (fCornerRunner->SetInterval(kCornerDelay) != B_OK) + if (fCornerRunner != NULL + && fCornerRunner->SetInterval(kCornerDelay) != B_OK) _Invoke(); break; } From korli at mail.berlios.de Mon Aug 18 23:16:34 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 23:16:34 +0200 Subject: [Haiku-commits] r27050 - haiku/trunk/src/bin/gzip Message-ID: <200808182116.m7ILGYaT005452@sheep.berlios.de> Author: korli Date: 2008-08-18 23:16:33 +0200 (Mon, 18 Aug 2008) New Revision: 27050 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27050&view=rev Modified: haiku/trunk/src/bin/gzip/Jamfile haiku/trunk/src/bin/gzip/gzip.c Log: * Applied patch http://www.gzip.org/gzip-1.2.4b.patch * Cleaned up Jamfile Modified: haiku/trunk/src/bin/gzip/Jamfile =================================================================== --- haiku/trunk/src/bin/gzip/Jamfile 2008-08-18 21:06:38 UTC (rev 27049) +++ haiku/trunk/src/bin/gzip/Jamfile 2008-08-18 21:16:33 UTC (rev 27050) @@ -16,10 +16,9 @@ unpack.c unlzh.c crypt.c + : be ; -LinkAgainst gzip : be ; - { MakeLocatePlatform zdiff ; Shell zdiff : zdiff ; Modified: haiku/trunk/src/bin/gzip/gzip.c =================================================================== --- haiku/trunk/src/bin/gzip/gzip.c 2008-08-18 21:06:38 UTC (rev 27049) +++ haiku/trunk/src/bin/gzip/gzip.c 2008-08-18 21:16:33 UTC (rev 27050) @@ -45,7 +45,7 @@ */ #ifdef RCSID -static char rcsid[] = "$Id: gzip.c,v 1.1 2003/06/11 15:56:08 darkwyrm Exp $"; +static char rcsid[] = "$Id$"; #endif #include @@ -1005,7 +1005,14 @@ #ifdef NO_MULTIPLE_DOTS char *dot; /* pointer to ifname extension, or NULL */ #endif + int max_suffix_len = (z_len > 3 ? z_len : 3); + /* Leave enough room in ifname or ofname for suffix: */ + if (strlen(iname) >= sizeof(ifname) - max_suffix_len) { + strncpy(ifname, iname, sizeof(ifname) - 1); + /* last byte of ifname is already zero and never overwritten */ + error("file name too long"); + } strcpy(ifname, iname); /* If input file exists, return OK. */ From emitrax at gmail.com Mon Aug 18 23:25:20 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Mon, 18 Aug 2008 21:25:20 +0000 Subject: [Haiku-commits] r27048 - haiku/trunk/src/add-ons/kernel/file_systems/udf In-Reply-To: <200808182058.m7IKwqvD003717@sheep.berlios.de> References: <200808182058.m7IKwqvD003717@sheep.berlios.de> Message-ID: 2008/8/18 axeld at BerliOS : > Author: axeld > Date: 2008-08-18 22:58:51 +0200 (Mon, 18 Aug 2008) > New Revision: 27048 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27048&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/file_systems/udf/kernel_interface.cpp > Log: > * Fixed typo that prevented udf from being picked up: it's "modules", not > "module" - hope that helps, Salvatore :-) I think I double checked a thousands time for typos in that part of the code, but still wasn't enough I guess! ;-) Thanks! Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From emitrax at gmail.com Mon Aug 18 23:36:06 2008 From: emitrax at gmail.com (Salvatore Benedetto) Date: Mon, 18 Aug 2008 21:36:06 +0000 Subject: [Haiku-commits] r27044 - haiku/trunk/src/kits/storage In-Reply-To: References: <200808181853.m7IIrVZF026747@sheep.berlios.de> <49459426115-BeMail@zon> Message-ID: 2008/8/18 J?r?me Duval : > 2008/8/18 Axel D?rfler : >> stippi at mail.berlios.de wrote: >>> Log: >>> * Puh, there was quite a confusion with variable names here, Axel. >>> Don't we have this "blah shadows a parameter" warning enabled? >> >> We should, but at least I didn't see anything - maybe Linux compiles >> too fast for me ;-) > > We don't have -Wshadow at least. It's also part of -Wextra or -W. We > might not want this option for C files. I can confirm we don't, at least not a global one, as in my xsi semaphore implementation I ended up using "_" as variable name in nested blocks and never got a warning, although it wasn't a problem in my case. Regards, -- Salvatore Benedetto (a.k.a. emitrax) Student of Computer Engineer University of Pisa www.haiku-os.it From korli at mail.berlios.de Mon Aug 18 23:48:02 2008 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 18 Aug 2008 23:48:02 +0200 Subject: [Haiku-commits] r27051 - haiku/trunk/src/apps/installer Message-ID: <200808182148.m7ILm2aS008192@sheep.berlios.de> Author: korli Date: 2008-08-18 23:48:02 +0200 (Mon, 18 Aug 2008) New Revision: 27051 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27051&view=rev Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp haiku/trunk/src/apps/installer/CopyEngine.h haiku/trunk/src/apps/installer/InstallerWindow.cpp Log: * improved error and cancellation handling * only enable Begin button when a menu item has been chosen Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-08-18 21:16:33 UTC (rev 27050) +++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2008-08-18 21:48:02 UTC (rev 27051) @@ -72,15 +72,7 @@ switch (msg->what) { case ENGINE_START: { - status_t err = Start(fWindow->GetSourceMenu(), - fWindow->GetTargetMenu()); - if (err != B_OK) { - ERR("Start failed"); - SetStatusMessage("Installation aborted."); - BMessenger(fWindow).SendMessage(RESET_INSTALL); - } else { - BMessenger(fWindow).SendMessage(INSTALL_FINISHED); - } + Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu()); break; } } @@ -124,45 +116,46 @@ } -status_t +void CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu) { CALLED(); + BPath targetDirectory, srcDirectory; + BDirectory targetDir, srcDir; + BDiskDevice device; + BPartition *partition; + BVolume targetVolume; + status_t err = B_OK; + fControl->Reset(); - status_t err = B_OK; PartitionMenuItem *targetItem = (PartitionMenuItem *)targetMenu->FindMarked(); PartitionMenuItem *srcItem = (PartitionMenuItem *)srcMenu->FindMarked(); if (!srcItem || !targetItem) { ERR("bad menu items\n"); - return B_BAD_VALUE; + goto error; } // check if target is initialized // ask if init or mount as is - BPath targetDirectory; - BDiskDevice device; - BPartition *partition; - BVolume targetVolume; - if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) { if (!partition->IsMounted()) { if ((err = partition->Mount()) < B_OK) { SetStatusMessage("The disk can't be mounted. Please choose a " "different disk."); ERR("BPartition::Mount"); - return err; + goto error; } } if ((err = partition->GetVolume(&targetVolume)) != B_OK) { ERR("BPartition::GetVolume"); - return err; + goto error; } if ((err = partition->GetMountPoint(&targetDirectory)) != B_OK) { ERR("BPartition::GetMountPoint"); - return err; + goto error; } } else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) { if (!device.IsMounted()) { @@ -170,19 +163,19 @@ SetStatusMessage("The disk can't be mounted. Please choose a " "different disk."); ERR("BDiskDevice::Mount"); - return err; + goto error; } } if ((err = device.GetVolume(&targetVolume)) != B_OK) { ERR("BDiskDevice::GetVolume"); - return err; + goto error; } if ((err = device.GetMountPoint(&targetDirectory)) != B_OK) { ERR("BDiskDevice::GetMountPoint"); - return err; + goto error; } } else - return B_ERROR; // shouldn't happen + goto error; // shouldn't happen // check if target has enough space if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired) @@ -190,30 +183,27 @@ "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; + goto error; } - BPath srcDirectory; if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) { if ((err = partition->GetMountPoint(&srcDirectory)) != B_OK) { ERR("BPartition::GetMountPoint"); - return err; + goto error; } } else if (fDDRoster.GetDeviceWithID(srcItem->ID(), &device) == B_OK) { if ((err = device.GetMountPoint(&srcDirectory)) != B_OK) { ERR("BDiskDevice::GetMountPoint"); - return err; + goto error; } } else - return B_ERROR; // shouldn't happen + goto error; // shouldn't happen // check not installing on itself 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; + goto error; } // check not installing on boot volume @@ -223,20 +213,19 @@ "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; + goto error; } LaunchInitScript(targetDirectory); // copy source volume - BDirectory targetDir(targetDirectory.Path()); - BDirectory srcDir(srcDirectory.Path()); + targetDir.SetTo(targetDirectory.Path()); + srcDir.SetTo(srcDirectory.Path()); err = CopyFolder(srcDir, targetDir); + + if (err != B_OK || fControl->CheckUserCanceled()) + goto error; - if (err != B_OK) - return err; - // copy selected packages if (fPackages) { srcDirectory.Append(PACKAGES_DIRECTORY); @@ -244,25 +233,24 @@ BDirectory packageDir; int32 count = fPackages->CountItems(); for (int32 i = 0; i < count; i++) { - if (fControl->CheckUserCanceled()) - return B_CANCELED; Package *p = static_cast(fPackages->ItemAt(i)); packageDir.SetTo(&srcDir, p->Folder()); err = CopyFolder(packageDir, targetDir); - if (err != B_OK) - break; + if (err != B_OK || fControl->CheckUserCanceled()) + goto error; } } - if (err != B_OK) - return err; - - if (fControl->CheckUserCanceled()) - return B_CANCELED; - LaunchFinishScript(targetDirectory); - return B_OK; + BMessenger(fWindow).SendMessage(INSTALL_FINISHED); + + return; +error: + if (err == B_CANCELED || fControl->CheckUserCanceled()) + SetStatusMessage("Installation canceled."); + ERR("Start failed"); + BMessenger(fWindow).SendMessage(RESET_INSTALL); } Modified: haiku/trunk/src/apps/installer/CopyEngine.h =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.h 2008-08-18 21:16:33 UTC (rev 27050) +++ haiku/trunk/src/apps/installer/CopyEngine.h 2008-08-18 21:48:02 UTC (rev 27051) @@ -23,8 +23,6 @@ public: CopyEngine(InstallerWindow *window); void MessageReceived(BMessage *msg); - void SetStatusMessage(char *status); - status_t Start(BMenu *srcMenu, BMenu *targetMenu); void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu); void SetPackagesList(BList *list); void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; }; @@ -32,6 +30,8 @@ private: void LaunchInitScript(BPath &path); void LaunchFinishScript(BPath &path); + void SetStatusMessage(char *status); + void Start(BMenu *srcMenu, BMenu *targetMenu); status_t CopyFolder(BDirectory &srcDir, BDirectory &targetDir); InstallerWindow *fWindow; Modified: haiku/trunk/src/apps/installer/InstallerWindow.cpp =================================================================== --- haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-08-18 21:16:33 UTC (rev 27050) +++ haiku/trunk/src/apps/installer/InstallerWindow.cpp 2008-08-18 21:48:02 UTC (rev 27051) @@ -192,7 +192,6 @@ break; case START_SCAN: StartScan(); - fBeginButton->SetEnabled(true); break; case BEGIN_MESSAGE: switch (fInstallStatus) { @@ -203,10 +202,10 @@ fPackagesView->GetPackagesToInstall(list, &size); fCopyEngine->SetPackagesList(list); fCopyEngine->SetSpaceRequired(size); + fInstallStatus = kInstalling; BMessenger(fCopyEngine).SendMessage(ENGINE_START); fBeginButton->SetLabel("Stop"); DisableInterface(true); - fInstallStatus = kInstalling; break; } case kInstalling: @@ -397,6 +396,8 @@ sprintf(message, "Press the Begin button to install from '%s' onto '%s'", item1 ? item1->Name() : "null", item2 ? item2->Name() : "null"); SetStatusMessage(message); + if (item1 && item2) + fBeginButton->SetEnabled(true); } From sbenedetto at mail.berlios.de Mon Aug 18 23:48:22 2008 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Mon, 18 Aug 2008 23:48:22 +0200 Subject: [Haiku-commits] r27052 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200808182148.m7ILmM1u008242@sheep.berlios.de> Author: sbenedetto Date: 2008-08-18 23:48:21 +0200 (Mon, 18 Aug 2008) New Revision: 27052 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27052&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h Log: * Fix potential deadlock in file system see http://www.freelists.org/archives/haiku-gsoc/08-2008/msg00024.html for more details. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2008-08-18 21:48:02 UTC (rev 27051) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.h 2008-08-18 21:48:21 UTC (rev 27052) @@ -121,8 +121,8 @@ void Done() { if (fJournal != NULL) { + _UnlockInodes(); fJournal->Unlock(this, true); - _UnlockInodes(); } fJournal = NULL; } From stippi at mail.berlios.de Tue Aug 19 00:55:05 2008 From: stippi at mail.berlios.de (stippi at mail.berlios.de) Date: Tue, 19 Aug 2008 00:55:05 +0200 Subject: [Haiku-commits] r27053 - haiku/trunk/src/kits/storage Message-ID: <200808182255.m7IMt5VW009553@sheep.berlios.de> Author: stippi Date: 2008-08-19 00:55:03 +0200 (Tue, 19 Aug 2008) New Revision: 27053 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27053&view=rev Modified: haiku/trunk/src/kits/storage/Mime.cpp Log: size is actually icon_size, not data size, thanks Axel for pointing out! Modified: haiku/trunk/src/kits/storage/Mime.cpp =================================================================== --- haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 21:48:21 UTC (rev 27052) +++ haiku/trunk/src/kits/storage/Mime.cpp 2008-08-18 22:55:03 UTC (rev 27053) @@ -202,9 +202,6 @@ return B_NO_MEMORY; } - if (size < icon8->BitsLength()) - return B_BAD_VALUE; - status = BIconUtils::GetVectorIcon(data, dataSize, icon32); if (status == B_OK) status = BIconUtils::ConvertToCMAP8(icon32, icon8); From bonefish at mail.berlios.de Tue Aug 19 00:59:58 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 19 Aug 2008 00:59:58 +0200 Subject: [Haiku-commits] r27054 - haiku/trunk/src/system/kernel/device_manager Message-ID: <200808182259.m7IMxwne016044@sheep.berlios.de> Author: bonefish Date: 2008-08-19 00:59:56 +0200 (Tue, 19 Aug 2008) New Revision: 27054 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27054&view=rev Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp haiku/trunk/src/system/kernel/device_manager/io_requests.h Log: * Added B_DELETE_IO_REQUEST flag, which causes the IORequest to be deleted automatically when it's finished. * Added IORequest::Create() for creating a IORequest on the heap (respectively the VIP heap). Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.cpp =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-18 22:55:03 UTC (rev 27053) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.cpp 2008-08-18 22:59:56 UTC (rev 27054) @@ -586,6 +586,13 @@ } +/* static */ IORequest* +IORequest::Create(bool vip) +{ + return vip ? new(vip_io_alloc) IORequest : new(std::nothrow) IORequest; +} + + status_t IORequest::Init(off_t offset, void* buffer, size_t length, bool write, uint32 flags) @@ -663,13 +670,12 @@ } // create subrequest - IORequest* subRequest = (fFlags & B_VIP_IO_REQUEST) != 0 - ? new(vip_io_alloc) IORequest : new(std::nothrow) IORequest; + IORequest* subRequest = Create((fFlags & B_VIP_IO_REQUEST) != 0); if (subRequest == NULL) return B_NO_MEMORY; status_t error = subRequest->Init(offset, vecOffset, vecs + startVec, - endVec - startVec + 1, length, fIsWrite, fFlags); + endVec - startVec + 1, length, fIsWrite, fFlags & ~B_DELETE_IO_REQUEST); if (error != B_OK) { delete subRequest; return error; @@ -781,6 +787,7 @@ status_t status = fStatus; size_t lastTransferredOffset = fRelativeParentOffset + fTransferSize; bool partialTransfer = status != B_OK || fPartialTransfer; + bool deleteRequest = (fFlags & B_DELETE_IO_REQUEST) != 0; // unblock waiters fFinishedCondition.NotifyAll(); @@ -798,6 +805,9 @@ parent->SubRequestFinished(this, status, partialTransfer, lastTransferredOffset); } + + if (deleteRequest) + delete this; } Modified: haiku/trunk/src/system/kernel/device_manager/io_requests.h =================================================================== --- haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-18 22:55:03 UTC (rev 27053) +++ haiku/trunk/src/system/kernel/device_manager/io_requests.h 2008-08-18 22:59:56 UTC (rev 27054) @@ -22,6 +22,7 @@ #define B_PHYSICAL_IO_REQUEST 0x01 /* buffer points to physical memory */ #define B_VIP_IO_REQUEST 0x02 /* used by the page writer -- make sure allocations won't fail */ +#define B_DELETE_IO_REQUEST 0x04 /* delete request when finished */ struct DMABuffer; struct IOOperation; @@ -193,6 +194,7 @@ typedef status_t (*io_request_finished_callback)(void* data, io_request* request, status_t status, bool partialTransfer, size_t transferEndOffset); + // TODO: Return type: status_t -> void typedef status_t (*io_request_iterate_callback)(void* data, io_request* request, bool* _partialTransfer); @@ -201,6 +203,8 @@ IORequest(); virtual ~IORequest(); + static IORequest* Create(bool vip); + status_t Init(off_t offset, void* buffer, size_t length, bool write, uint32 flags); status_t Init(off_t offset, const iovec* vecs, From bonefish at mail.berlios.de Tue Aug 19 01:09:13 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 19 Aug 2008 01:09:13 +0200 Subject: [Haiku-commits] r27055 - in haiku/trunk: headers/private/kernel src/system/kernel/fs Message-ID: <200808182309.m7IN9CKf024433@sheep.berlios.de> Author: bonefish Date: 2008-08-19 01:09:10 +0200 (Tue, 19 Aug 2008) New Revision: 27055 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27055&view=rev Modified: haiku/trunk/headers/private/kernel/vfs.h haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp Log: Added method vfs_asynchronous_write_pages(), which, unsurprisingly, writes the given page iovecs asynchronously. The new class AsyncIOCallback is used to inform the caller when the request has been finished. Modified: haiku/trunk/headers/private/kernel/vfs.h =================================================================== --- haiku/trunk/headers/private/kernel/vfs.h 2008-08-18 22:59:56 UTC (rev 27054) +++ haiku/trunk/headers/private/kernel/vfs.h 2008-08-18 23:09:10 UTC (rev 27055) @@ -251,10 +251,44 @@ extern status_t _user_get_next_socket_stat(int family, uint32 *cookie, struct net_stat *stat); -/* vfs entry points... */ - #ifdef __cplusplus } #endif + +#ifdef __cplusplus + +class AsyncIOCallback { +public: + virtual ~AsyncIOCallback(); + + virtual void IOFinished(status_t status, + bool partialTransfer, + size_t bytesTransferred) = 0; + + void operator delete(void* address, size_t size); + + static status_t IORequestCallback(void* data, + io_request* request, status_t status, + bool partialTransfer, + size_t transferEndOffset); +}; + + +class StackableAsyncIOCallback : public AsyncIOCallback { +public: + StackableAsyncIOCallback(AsyncIOCallback* next); + +protected: + AsyncIOCallback* fNextCallback; +}; + + +status_t vfs_asynchronous_write_pages(struct vnode* vnode, void* cookie, + off_t pos, const iovec* vecs, size_t count, size_t numBytes, + uint32 flags, AsyncIOCallback* callback); + + +#endif // __cplusplus + #endif /* _KERNEL_VFS_H */ Modified: haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-18 22:59:56 UTC (rev 27054) +++ haiku/trunk/src/system/kernel/fs/vfs_request_io.cpp 2008-08-18 23:09:10 UTC (rev 27055) @@ -14,6 +14,44 @@ #endif +// #pragma mark - AsyncIOCallback + + +AsyncIOCallback::~AsyncIOCallback() +{ +} + + +void +AsyncIOCallback::operator delete(void* address, size_t size) +{ + io_request_free(address); +} + + +/* static */ status_t +AsyncIOCallback::IORequestCallback(void* data, io_request* request, + status_t status, bool partialTransfer, size_t transferEndOffset) +{ + ((AsyncIOCallback*)data)->IOFinished(status, partialTransfer, + transferEndOffset); + return B_OK; +} + + +// #pragma mark - StackableAsyncIOCallback + + +StackableAsyncIOCallback::StackableAsyncIOCallback(AsyncIOCallback* next) + : + fNextCallback(next) +{ +} + + +// #pragma mark - + + struct iterative_io_cookie { struct vnode* vnode; file_descriptor* descriptor; @@ -379,6 +417,32 @@ } +status_t +vfs_asynchronous_write_pages(struct vnode* vnode, void* cookie, off_t pos, + const iovec* vecs, size_t count, size_t numBytes, uint32 flags, + AsyncIOCallback* callback) +{ + IORequest* request = IORequest::Create((flags & B_VIP_IO_REQUEST) != 0); + if (request == NULL) { + callback->IOFinished(B_NO_MEMORY, true, 0); + return B_NO_MEMORY; + } + + status_t status = request->Init(pos, vecs, count, numBytes, true, + flags | B_DELETE_IO_REQUEST); + if (status != B_OK) { + delete request; + callback->IOFinished(status, true, 0); + return status; + } + + request->SetFinishedCallback(&AsyncIOCallback::IORequestCallback, + callback); + + return vfs_vnode_io(vnode, cookie, request); +} + + // #pragma mark - public API From bonefish at mail.berlios.de Tue Aug 19 01:28:39 2008 From: bonefish at mail.berlios.de (bonefish at mail.berlios.de) Date: Tue, 19 Aug 2008 01:28:39 +0200 Subject: [Haiku-commits] r27056 - in haiku/trunk: headers/private/kernel src/system/kernel/cache src/system/kernel/vm Message-ID: <200808182328.m7INSd7Q017796@sheep.berlios.de> Author: bonefish Date: 2008-08-19 01:28:34 +0200 (Tue, 19 Aug 2008) New Revision: 27056 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27056&view=rev Modified: haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/system/kernel/cache/vnode_store.cpp haiku/trunk/src/system/kernel/cache/vnode_store.h haiku/trunk/src/system/kernel/vm/Jamfile haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h haiku/trunk/src/system/kernel/vm/VMAnonymousNoSwapCache.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousNoSwapCache.h haiku/trunk/src/system/kernel/vm/VMDeviceCache.cpp haiku/trunk/src/system/kernel/vm/VMDeviceCache.h haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * VMCache::Write(): Added "uint32 flags" argument which is supposed to be passed on to the IORequest. Most relevantly physical pages can now be written directly by passing B_PHYSICAL_IO_REQUEST. * Added VMCache::WriteAsync() which is supposed to write pages asynchronously. The base class version version falls back to the synchronous Write(). Only VMVnodeCache implements WriteAsync() ATM, VMAnonymousCache (swap support) still has to be adjusted accordingly. * write_page() doesn't need to map the page anymore as it can write the physical page directly. * Modified the page writer to write pages asynchronously. This shouldn't have any noticeable effect yet. It will though as soon as the I/O scheduler reorders I/O operations. Modified: haiku/trunk/headers/private/kernel/vm_types.h ==================================================