From bonefish at mail.berlios.de Sat Sep 1 02:31:20 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Sep 2007 02:31:20 +0200 Subject: [Haiku-commits] r22132 - haiku/trunk/src/apps/processcontroller Message-ID: <200709010031.l810VKif017504@sheep.berlios.de> Author: bonefish Date: 2007-09-01 02:31:19 +0200 (Sat, 01 Sep 2007) New Revision: 22132 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22132&view=rev Modified: haiku/trunk/src/apps/processcontroller/ProcessController.cpp Log: Made ProcessController's "Debug Thread" feature work under Haiku. We don't have a "db" command (we could probably add a small shell script that invokes gdb in a Terminal), but just as BeOS we have debug_thread(), which does exactly that -- throwing a thread into the debugger. It (at least Haiku's version, not sure about BeOS's) also interrupts system calls, which makes the semaphore releasing hack superfluous. Modified: haiku/trunk/src/apps/processcontroller/ProcessController.cpp =================================================================== --- haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2007-08-31 18:21:34 UTC (rev 22131) +++ haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2007-09-01 00:31:19 UTC (rev 22132) @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -745,6 +746,9 @@ thread_debug_thread(void *arg) { Tdebug_thead_param* param = (Tdebug_thead_param*) arg; +#ifdef __HAIKU__ + debug_thread(param->thread); +#else // !__HAIKU__ thread_info thinfo; get_thread_info(param->thread, &thinfo); char text[4096]; @@ -792,6 +796,7 @@ } } } +#endif // !__HAIKU__ delete param; return B_OK; } From marcusoverhagen at mail.berlios.de Sat Sep 1 14:40:39 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 14:40:39 +0200 Subject: [Haiku-commits] r22133 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011240.l81Cedxc019345@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 14:40:39 +0200 (Sat, 01 Sep 2007) New Revision: 22133 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22133&view=rev Added: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h Log: copied Copied: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c (from rev 22084, haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.c) Copied: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h (from rev 22084, haiku/trunk/src/add-ons/kernel/drivers/network/rtl8169/util.h) From stippi at mail.berlios.de Sat Sep 1 14:51:59 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 1 Sep 2007 14:51:59 +0200 Subject: [Haiku-commits] r22134 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200709011251.l81CpxVf019944@sheep.berlios.de> Author: stippi Date: 2007-09-01 14:51:59 +0200 (Sat, 01 Sep 2007) New Revision: 22134 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22134&view=rev Modified: haiku/trunk/headers/os/interface/TextControl.h haiku/trunk/src/kits/interface/TextControl.cpp haiku/trunk/src/kits/interface/TextInput.cpp Log: * make the text view layouting more robust, draw the frame around the text view, ignore the divider for this (application code could layout the textview itself, and fDivider might not be maintained) * change Draw() and TextInput::MakeFocus() accordingly this fixes the weird placement of text controls in Beam Modified: haiku/trunk/headers/os/interface/TextControl.h =================================================================== --- haiku/trunk/headers/os/interface/TextControl.h 2007-09-01 12:40:39 UTC (rev 22133) +++ haiku/trunk/headers/os/interface/TextControl.h 2007-09-01 12:51:59 UTC (rev 22134) @@ -101,6 +101,7 @@ void _InitData(const char* label, const char* initialText, BMessage* archive = NULL); void _ValidateLayout(); + void _LayoutTextView(); void _UpdateFrame(); private: Modified: haiku/trunk/src/kits/interface/TextControl.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextControl.cpp 2007-09-01 12:40:39 UTC (rev 22133) +++ haiku/trunk/src/kits/interface/TextControl.cpp 2007-09-01 12:51:59 UTC (rev 22134) @@ -252,15 +252,10 @@ void BTextControl::SetDivider(float dividingLine) { - dividingLine = floorf(dividingLine + 0.5); + fDivider = floorf(dividingLine + 0.5); - float dx = fDivider - dividingLine; + _LayoutTextView(); - fDivider = dividingLine; - - fText->MoveBy(-dx, 0.0f); - fText->ResizeBy(dx, 0.0f); - if (Window()) { fText->Invalidate(); Invalidate(); @@ -295,8 +290,8 @@ // outer bevel - BRect rect = Bounds(); - rect.left = fDivider; + BRect rect = fText->Frame(); + rect.InsetBy(-2, -2); if (enabled) SetHighColor(darken1); @@ -363,7 +358,7 @@ ceilf(fontHeight.ascent + fontHeight.descent) + 1); if (x < fDivider && updateRect.Intersects(labelArea)) { labelArea.right = fDivider; - + BRegion clipRegion(labelArea); ConstrainClippingRegion(&clipRegion); SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR) @@ -434,7 +429,7 @@ GetFontHeight(&fontHeight); float labelHeight = ceil(fontHeight.ascent + fontHeight.descent + fontHeight.leading); - float textHeight = fText->LineHeight(0) + 4.0; + float textHeight = ceilf(fText->LineHeight(0)) + 4.0; *_height = max_c(labelHeight, textHeight); } @@ -765,15 +760,36 @@ ResizeTo(Bounds().Width(), height); - float lineHeight = ceil(fText->LineHeight(0)); - fText->ResizeTo(fText->Bounds().Width(), lineHeight); - fText->MoveTo(fText->Frame().left, (height - lineHeight) / 2); + _LayoutTextView(); fPreviousHeight = Bounds().Height(); } void +BTextControl::_LayoutTextView() +{ + BRect frame = Bounds(); + frame.left = fDivider; + // we are stroking the frame around the text view, which + // is 2 pixels wide + frame.InsetBy(2.0, 2.0); + fText->MoveTo(frame.left, frame.top); + fText->ResizeTo(frame.Width(), frame.Height()); + + BRect textRect(frame.OffsetToCopy(B_ORIGIN)); + + // the label font could require the control to be higher than + // necessary for the text view, we compensate this by layouting + // the text rect to be in the middle, normally this means there + // is one pixel spacing on each side + float lineHeight = ceilf(fText->LineHeight(0)); + textRect.InsetBy(1, floorf((frame.Height() - lineHeight) / 2)); + fText->SetTextRect(textRect); +} + + +void BTextControl::_UpdateFrame() { if (fLabelLayoutItem && fTextViewLayoutItem) { Modified: haiku/trunk/src/kits/interface/TextInput.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextInput.cpp 2007-09-01 12:40:39 UTC (rev 22133) +++ haiku/trunk/src/kits/interface/TextInput.cpp 2007-09-01 12:51:59 UTC (rev 22134) @@ -141,8 +141,7 @@ // I'm leaving this in, but it looks suspicious... :-) Invalidate(Bounds()); if (BTextControl* parent = dynamic_cast(Parent())) { - BRect frame = parent->Bounds(); - frame.left = parent->Divider(); + BRect frame = Frame(); frame.InsetBy(-1.0, -1.0); parent->Invalidate(frame); } From stippi at mail.berlios.de Sat Sep 1 15:33:52 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 1 Sep 2007 15:33:52 +0200 Subject: [Haiku-commits] r22135 - haiku/trunk/src/kits/interface Message-ID: <200709011333.l81DXqtw022208@sheep.berlios.de> Author: stippi Date: 2007-09-01 15:33:51 +0200 (Sat, 01 Sep 2007) New Revision: 22135 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22135&view=rev Modified: haiku/trunk/src/kits/interface/TextControl.cpp Log: fix more glitches: * invalidate the correct rect on WindowActivated() in case fDivider is not correclty maintained * don't cut off part of the label in Draw() by constraining the clipping in case the placement of the label is a little different than intented Modified: haiku/trunk/src/kits/interface/TextControl.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextControl.cpp 2007-09-01 12:51:59 UTC (rev 22134) +++ haiku/trunk/src/kits/interface/TextControl.cpp 2007-09-01 13:33:51 UTC (rev 22135) @@ -354,10 +354,9 @@ break; } - BRect labelArea(x, fText->Frame().top, x + labelWidth, - ceilf(fontHeight.ascent + fontHeight.descent) + 1); + BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom); if (x < fDivider && updateRect.Intersects(labelArea)) { - labelArea.right = fDivider; + labelArea.right = fText->Frame().left - 3; BRegion clipRegion(labelArea); ConstrainClippingRegion(&clipRegion); @@ -606,8 +605,8 @@ { if (fText->IsFocus()) { // invalidate to remove/show focus indication - BRect rect = Bounds(); - rect.left = fDivider; + BRect rect = fText->Frame(); + rect.InsetBy(-1, -1); Invalidate(rect); // help out embedded text view which doesn't From marcusoverhagen at mail.berlios.de Sat Sep 1 16:28:48 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 16:28:48 +0200 Subject: [Haiku-commits] r22136 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011428.l81ESm9R024583@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 16:28:47 +0200 (Sat, 01 Sep 2007) New Revision: 22136 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22136&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h Log: added more definitions from specification Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-01 13:33:51 UTC (rev 22135) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-01 14:28:47 UTC (rev 22136) @@ -11,7 +11,42 @@ #define AHCI_DEVICE_MODULE_NAME "busses/scsi/ahci/device_v1" #define AHCI_SIM_MODULE_NAME "busses/scsi/ahci/sim/v1" +enum { + CAP_S64A = (1 << 31), // Supports 64-bit Addressing + CAP_SNCQ = (1 << 30), // Supports Native Command Queuing + CAP_SSNTF = (1 << 29), // Supports SNotification Register + CAP_SMPS = (1 << 28), // Supports Mechanical Presence Switch + CAP_SSS = (1 << 27), // Supports Staggered Spin-up + CAP_SALP = (1 << 26), // Supports Aggressive Link Power Management + CAP_SAL = (1 << 25), // Supports Activity LED + CAP_SCLO = (1 << 24), // Supports Command List Override + CAP_ISS_MASK = 0xf, // Interface Speed Support + CAP_ISS_SHIFT = 20, + CAP_SNZO = (1 << 19), // Supports Non-Zero DMA Offsets + CAP_SAM = (1 << 18), // Supports AHCI mode only + CAP_SPM = (1 << 17), // Supports Port Multiplier + CAP_FBSS = (1 << 16), // FIS-based Switching Supported + CAP_PMD = (1 << 15), // PIO Multiple DRQ Block + CAP_SSC = (1 << 14), // Slumber State Capable + CAP_PSC = (1 << 13), // Partial State Capable + CAP_NCS_MASK = 0x1f, // Number of Command Slots + CAP_NCS_SHIFT = 8, + CAP_CCCS = (1 << 7), // Command Completion Coalescing Supported + CAP_EMS = (1 << 6), // Enclosure Management Supported + CAP_SXS = (1 << 5), // Supports External SATA + CAP_NP_MASK = 0x1f, // Number of Ports + CAP_NP_SHIFT = 0, +}; + +enum { + GHC_AE = (1 << 31), // AHCI Enable + GHC_MRSM = (1 << 2), // MSI Revert to Single Message + GHC_IE = (1 << 1), // Interrupt Enable + GHC_HR = (1 << 0), // HBA Reset +}; + + typedef struct { uint32 clb; // Command List Base Address uint32 clbu; // Command List Base Address Upper 32-Bits @@ -50,6 +85,7 @@ ahci_port port[32]; } ahci_hba; + extern scsi_sim_interface gAHCISimInterface; extern device_manager_info *gDeviceManager; extern pci_device_module_info *gPCI; From marcusoverhagen at mail.berlios.de Sat Sep 1 16:29:10 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 16:29:10 +0200 Subject: [Haiku-commits] r22137 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011429.l81ETA1C024657@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 16:29:10 +0200 (Sat, 01 Sep 2007) New Revision: 22137 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22137&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h Log: map registers and print some information Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile 2007-09-01 14:28:47 UTC (rev 22136) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile 2007-09-01 14:29:10 UTC (rev 22137) @@ -4,4 +4,5 @@ ahci.c ahci_controller.cpp ahci_sim.cpp + util.c ; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 14:28:47 UTC (rev 22136) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 14:29:10 UTC (rev 22137) @@ -4,6 +4,7 @@ */ #include "ahci_controller.h" +#include "util.h" #include #include @@ -61,8 +62,34 @@ TRACE("satacr0 = 0x%08lx, satacr1 = 0x%08lx\n", satacr0, satacr1); } - fDevicePresentMask = (1 << 7) | (1 << 19); + void *addr = (void *)pciInfo.u.h0.base_registers[5]; + size_t size = pciInfo.u.h0.base_register_sizes[5]; + TRACE("registers at %p, size %#lx\n", addr, size); + + fRegsArea = map_mem((void **)&fRegs, addr, size, 0, "AHCI HBA regs"); + if (fRegsArea < B_OK) { + TRACE("mapping registers failed\n"); + return B_ERROR; + } + + TRACE("cap: Interface Speed Support: %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); + TRACE("cap: Number of Command Slots: %lu\n", (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); + TRACE("cap: Number of Ports: %lu\n", (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + TRACE("cap: Supports Port Multiplier: %s\n", (fRegs->cap & CAP_SPM) ? "yes" : "no"); + TRACE("cap: Supports External SATA: %s\n", (fRegs->cap & CAP_SXS) ? "yes" : "no"); + TRACE("cap: Enclosure Management Supported: %s\n", (fRegs->cap & CAP_EMS) ? "yes" : "no"); + TRACE("cap: Supports AHCI mode only: %s\n", (fRegs->cap & CAP_SAM) ? "yes" : "no"); + TRACE("ghc: AHCI Enable: %s\n", (fRegs->ghc & GHC_AE) ? "yes" : "no"); + TRACE("Ports Implemented: %08lx\n", fRegs->pi); + TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); + + // disable interrupts + fRegs->ghc &= ~GHC_IE; + // clear pending interrupts + fRegs->is = 0xffffffff; + + return B_OK; } @@ -72,6 +99,13 @@ { TRACE("AHCIController::Uninit\n"); + // disable interrupts + fRegs->ghc &= ~GHC_IE; + // clear pending interrupts + fRegs->is = 0xffffffff; + + delete_area(fRegsArea); + // --- Instance check workaround begin delete_port(fInstanceCheck); // --- Instance check workaround end Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 14:28:47 UTC (rev 22136) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 14:29:10 UTC (rev 22137) @@ -33,7 +33,10 @@ pci_device_info* fPCIDevice; uint32 fDevicePresentMask; + ahci_hba * fRegs; + area_id fRegsArea; + // --- Instance check workaround begin port_id fInstanceCheck; // --- Instance check workaround end Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2007-09-01 14:28:47 UTC (rev 22136) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2007-09-01 14:29:10 UTC (rev 22137) @@ -1,29 +1,16 @@ -/* Realtek RTL8169 Family Driver - * Copyright (C) 2004 Marcus Overhagen . All rights reserved. - * - * 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. - * - * Marcus Overhagen makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied warranty. - * - * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS - * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +/* + * Copyright 2004-2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. */ -#include +#include "util.h" + +#include #include #include -//#define DEBUG -#include "debug.h" -#include "util.h" +#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) Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h 2007-09-01 14:28:47 UTC (rev 22136) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h 2007-09-01 14:29:10 UTC (rev 22137) @@ -1,27 +1,21 @@ -/* Realtek RTL8169 Family Driver - * Copyright (C) 2004 Marcus Overhagen . All rights reserved. - * - * 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. - * - * Marcus Overhagen makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied warranty. - * - * MARCUS OVERHAGEN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL MARCUS - * OVERHAGEN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +/* + * Copyright 2004-2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. */ #ifndef __UTIL_H #define __UTIL_H #include +#ifdef __cplusplus +extern "C" { +#endif + area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name); area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name); +#ifdef __cplusplus +} #endif + +#endif From bonefish at mail.berlios.de Sat Sep 1 16:43:00 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Sep 2007 16:43:00 +0200 Subject: [Haiku-commits] r22138 - haiku/trunk/src/tests/system/kernel Message-ID: <200709011443.l81Eh0h6025233@sheep.berlios.de> Author: bonefish Date: 2007-09-01 16:42:59 +0200 (Sat, 01 Sep 2007) New Revision: 22138 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22138&view=rev Modified: haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp Log: Added test case for the r/o text segment. Modified: haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp 2007-09-01 14:29:10 UTC (rev 22137) +++ haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp 2007-09-01 14:42:59 UTC (rev 22138) @@ -6,6 +6,14 @@ #include + +int +test_function() +{ + return 0; +} + + static area_id create_test_area(const char* name, int** address, uint32 protection) { @@ -41,19 +49,23 @@ main() { // allocate read-only areas - const int kAreaCount = 3; + const int kAreaCount = 4; area_id areas[kAreaCount]; int* areaAddresses[kAreaCount]; areas[0] = create_test_area("area0", &areaAddresses[0], B_READ_AREA); areas[1] = create_test_area("area1", &areaAddresses[1], B_READ_AREA); areas[2] = create_test_area("area2", &areaAddresses[2], B_READ_AREA); + areaAddresses[3] = (int*)test_function; + areas[3] = area_for(areaAddresses[3]); int* area2CloneAddress; /*area_id area2Clone =*/ clone_test_area("area2clone", &area2CloneAddress, B_READ_AREA | B_WRITE_AREA, areas[2]); - for (int i = 0; i < kAreaCount; i++) - printf("parent: areas[%d]: %ld, %p\n", i, areas[i], areaAddresses[i]); + for (int i = 0; i < kAreaCount; i++) { + printf("parent: areas[%d]: %ld, %p (%d)\n", i, areas[i], + areaAddresses[i], *areaAddresses[i]); + } // fork() pid_t pid = fork(); From jackburton at mail.berlios.de Sat Sep 1 16:51:51 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 1 Sep 2007 16:51:51 +0200 Subject: [Haiku-commits] r22139 - haiku/trunk/src/kits/interface Message-ID: <200709011451.l81EppVq025587@sheep.berlios.de> Author: jackburton Date: 2007-09-01 16:51:51 +0200 (Sat, 01 Sep 2007) New Revision: 22139 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22139&view=rev Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: Adjusted a bit BTextView::AutoResize() so that the text rect is more centered. At least renaming a file in tracker looks a bit better now. Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2007-09-01 14:42:59 UTC (rev 22138) +++ haiku/trunk/src/kits/interface/TextView.cpp 2007-09-01 14:51:51 UTC (rev 22139) @@ -3968,8 +3968,7 @@ ssize_t dataLen = 0; const char *text = NULL; - if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &dataLen) == B_OK) { - + if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &dataLen) == B_OK) { text_run_array *runArray = NULL; ssize_t runLen = 0; if (fStylable) @@ -4083,27 +4082,24 @@ void BTextView::AutoResize(bool redraw) { - // TODO: Review this if (fResizable) { float oldWidth = Bounds().Width() + 1; - float newWidth = 0; + float newWidth = 3; for (int32 i = 0; i < CountLines(); i++) newWidth += LineWidth(i); - if (newWidth < 3) - newWidth = 3; - BRect newRect(0, 0, ceilf(newWidth) + 1, ceilf(TextHeight(0, 0)) + 1); + BRect newRect(0, 0, ceilf(newWidth), ceilf(LineHeight(0)) + 2); if (fContainerView != NULL) { - fContainerView->ResizeTo(newRect.Width(), newRect.Height()); + fContainerView->ResizeTo(newRect.Width() + 1, newRect.Height()); if (fAlignment == B_ALIGN_CENTER) - fContainerView->MoveBy((oldWidth - newRect.Width()) / 2, 0); + fContainerView->MoveBy(ceilf((oldWidth - (newRect.Width() + 1)) / 2), 0); else if (fAlignment == B_ALIGN_RIGHT) - fContainerView->MoveBy(oldWidth - newRect.Width(), 0); + fContainerView->MoveBy(oldWidth - (newRect.Width() + 1), 0); fContainerView->Invalidate(); } - fTextRect = newRect.InsetBySelf(1, 1); + fTextRect = newRect.InsetBySelf(0, 1); if (redraw) DrawLines(0, 0); From bonefish at mail.berlios.de Sat Sep 1 17:16:46 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Sep 2007 17:16:46 +0200 Subject: [Haiku-commits] r22140 - haiku/trunk/src/tests/system/kernel Message-ID: <200709011516.l81FGkxj026514@sheep.berlios.de> Author: bonefish Date: 2007-09-01 17:16:45 +0200 (Sat, 01 Sep 2007) New Revision: 22140 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22140&view=rev Modified: haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp Log: Also print the expected value. Some comment on what should happen. Modified: haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp 2007-09-01 14:51:51 UTC (rev 22139) +++ haiku/trunk/src/tests/system/kernel/set_area_protection_test1.cpp 2007-09-01 15:16:45 UTC (rev 22140) @@ -52,6 +52,7 @@ const int kAreaCount = 4; area_id areas[kAreaCount]; int* areaAddresses[kAreaCount]; + areas[0] = create_test_area("area0", &areaAddresses[0], B_READ_AREA); areas[1] = create_test_area("area1", &areaAddresses[1], B_READ_AREA); areas[2] = create_test_area("area2", &areaAddresses[2], B_READ_AREA); @@ -62,8 +63,10 @@ /*area_id area2Clone =*/ clone_test_area("area2clone", &area2CloneAddress, B_READ_AREA | B_WRITE_AREA, areas[2]); + int area3Value = *areaAddresses[3]; + for (int i = 0; i < kAreaCount; i++) { - printf("parent: areas[%d]: %ld, %p (%d)\n", i, areas[i], + printf("parent: areas[%d]: %ld, %p (0x%08x)\n", i, areas[i], areaAddresses[i], *areaAddresses[i]); } @@ -76,7 +79,19 @@ if (pid == 0) { // child + pid = find_thread(NULL); + int expectedValues[kAreaCount] = { + 0, // CoW -- the child should see the original value + pid, // clone -- the child should see the change + pid, // clone -- the child should see the change + area3Value // CoW -- the child should see the original value + // Note: It looks alright in BeOS in the first run, + // but the parent actually seems to modify some + // cached page, and in the next run, we'll see + // the changed value. + }; + // get the IDs of the copied areas area_id parentAreas[kAreaCount]; for (int i = 0; i < kAreaCount; i++) { @@ -101,8 +116,10 @@ snooze(400000); - for (int i = 0; i < kAreaCount; i++) - printf("child: area[%d] contains: %d\n", i, *areaAddresses[i]); + for (int i = 0; i < kAreaCount; i++) { + printf("child: area[%d] contains: 0x%08x (expected: 0x%08x)\n", i, + *areaAddresses[i], expectedValues[i]); + } } else { // parent From marcusoverhagen at mail.berlios.de Sat Sep 1 18:52:47 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 18:52:47 +0200 Subject: [Haiku-commits] r22141 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011652.l81Gql9e011842@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 18:52:46 +0200 (Sat, 01 Sep 2007) New Revision: 22141 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22141&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h Log: print proper values for zero-based numbers Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 15:16:45 UTC (rev 22140) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 16:52:46 UTC (rev 22141) @@ -17,6 +17,8 @@ : fNode(node) , fPCIDevice(device) , fDevicePresentMask(0) + , fCommandSlotCount(0) + , fPortCount(0) , fInstanceCheck(-1) { } @@ -73,9 +75,12 @@ return B_ERROR; } - TRACE("cap: Interface Speed Support: %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); - TRACE("cap: Number of Command Slots: %lu\n", (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); - TRACE("cap: Number of Ports: %lu\n", (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + fCommandSlotCount = 1 + ((fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); + fPortCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + + TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); + TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); + TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Supports Port Multiplier: %s\n", (fRegs->cap & CAP_SPM) ? "yes" : "no"); TRACE("cap: Supports External SATA: %s\n", (fRegs->cap & CAP_SXS) ? "yes" : "no"); TRACE("cap: Enclosure Management Supported: %s\n", (fRegs->cap & CAP_EMS) ? "yes" : "no"); Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 15:16:45 UTC (rev 22140) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 16:52:46 UTC (rev 22141) @@ -35,6 +35,8 @@ ahci_hba * fRegs; area_id fRegsArea; + int fCommandSlotCount; + int fPortCount; // --- Instance check workaround begin Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-01 15:16:45 UTC (rev 22140) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-01 16:52:46 UTC (rev 22141) @@ -29,12 +29,12 @@ CAP_PMD = (1 << 15), // PIO Multiple DRQ Block CAP_SSC = (1 << 14), // Slumber State Capable CAP_PSC = (1 << 13), // Partial State Capable - CAP_NCS_MASK = 0x1f, // Number of Command Slots + CAP_NCS_MASK = 0x1f, // Number of Command Slots (zero-based number) CAP_NCS_SHIFT = 8, CAP_CCCS = (1 << 7), // Command Completion Coalescing Supported CAP_EMS = (1 << 6), // Enclosure Management Supported CAP_SXS = (1 << 5), // Supports External SATA - CAP_NP_MASK = 0x1f, // Number of Ports + CAP_NP_MASK = 0x1f, // Number of Ports (zero-based number) CAP_NP_SHIFT = 0, }; From bonefish at mail.berlios.de Sat Sep 1 20:00:22 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Sep 2007 20:00:22 +0200 Subject: [Haiku-commits] r22142 - haiku/trunk/headers/private/shared Message-ID: <200709011800.l81I0MYv016661@sheep.berlios.de> Author: bonefish Date: 2007-09-01 20:00:22 +0200 (Sat, 01 Sep 2007) New Revision: 22142 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22142&view=rev Modified: haiku/trunk/headers/private/shared/AutoLocker.h Log: Made SetTo() deal with the lockable == NULL, alreadyLocked == true correctly. Modified: haiku/trunk/headers/private/shared/AutoLocker.h =================================================================== --- haiku/trunk/headers/private/shared/AutoLocker.h 2007-09-01 16:52:46 UTC (rev 22141) +++ haiku/trunk/headers/private/shared/AutoLocker.h 2007-09-01 18:00:22 UTC (rev 22142) @@ -94,7 +94,7 @@ { Unlock(); fLockable = lockable; - fLocked = alreadyLocked; + fLocked = (lockable && alreadyLocked); if (!alreadyLocked && lockIfNotLocked) Lock(); } From marcusoverhagen at mail.berlios.de Sat Sep 1 20:51:03 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 20:51:03 +0200 Subject: [Haiku-commits] r22143 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011851.l81Ip3FF018809@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 20:51:03 +0200 (Sat, 01 Sep 2007) New Revision: 22143 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22143&view=rev Added: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h Log: a class for the SATA ports Added: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 18:00:22 UTC (rev 22142) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 18:51:03 UTC (rev 22143) @@ -0,0 +1,38 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include "ahci_port.h" + +#include +#include + +#define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) +#define FLOW(a...) dprintf("ahci: " a) + + +AHCIPort::AHCIPort(AHCIController *controller, int index) + : fIndex(index) +{ +} + + +AHCIPort::~AHCIPort() +{ +} + + +status_t +AHCIPort::Init() +{ + TRACE("AHCIPort::Init port %d\n", fIndex); + return B_OK; +} + + +void +AHCIPort::Uninit() +{ + TRACE("AHCIPort::Uninit port %d\n", fIndex); +} Added: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 18:00:22 UTC (rev 22142) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 18:51:03 UTC (rev 22143) @@ -0,0 +1,24 @@ +/* + * Copyright 2007, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _AHCI_PORT_H +#define _AHCI_PORT_H + +#include "ahci_defs.h" + +class AHCIController; + +class AHCIPort { +public: + AHCIPort(AHCIController *controller, int index); + ~AHCIPort(); + + status_t Init(); + void Uninit(); + +private: + int fIndex; +}; + +#endif // _AHCI_PORT_H From marcusoverhagen at mail.berlios.de Sat Sep 1 20:51:57 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 20:51:57 +0200 Subject: [Haiku-commits] r22144 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011851.l81Ipvqq018914@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 20:51:57 +0200 (Sat, 01 Sep 2007) New Revision: 22144 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22144&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h Log: implemented controller reset and AHCI enable, init a port object for each implemented device port Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile 2007-09-01 18:51:03 UTC (rev 22143) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile 2007-09-01 18:51:57 UTC (rev 22144) @@ -3,6 +3,7 @@ KernelAddon ahci : ahci.c ahci_controller.cpp + ahci_port.cpp ahci_sim.cpp util.c ; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 18:51:03 UTC (rev 22143) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 18:51:57 UTC (rev 22144) @@ -8,6 +8,8 @@ #include #include +#include +#include #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) #define FLOW(a...) dprintf("ahci: " a) @@ -17,10 +19,14 @@ : fNode(node) , fPCIDevice(device) , fDevicePresentMask(0) + , fPCIVendorID(0xffff) + , fPCIDeviceID(0xffff) , fCommandSlotCount(0) , fPortCount(0) + , fPortMax(0) , fInstanceCheck(-1) { + memset(fPorts, 0, sizeof(fPorts)); } @@ -39,8 +45,11 @@ return B_ERROR; } + fPCIVendorID = pciInfo.vendor_id; + fPCIDeviceID = pciInfo.device_id; + TRACE("AHCIController::Init %u:%u:%u vendor %04x, device %04x\n", - pciInfo.bus, pciInfo.device, pciInfo.function, pciInfo.vendor_id, pciInfo.device_id); + pciInfo.bus, pciInfo.device, pciInfo.function, fPCIVendorID, fPCIDeviceID); // --- Instance check workaround begin char sName[32]; @@ -75,20 +84,59 @@ return B_ERROR; } + if (ResetController() < B_OK) { + TRACE("controller reset failed\n"); + goto err; + } + fCommandSlotCount = 1 + ((fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); fPortCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + if (fRegs->pi == 0) { + TRACE("controller doesn't implement any ports\n"); + goto err; + } + fPortMax = 31; + while ((fRegs->pi & (1 << fPortMax)) == 0) + fPortMax--; + TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Supports Port Multiplier: %s\n", (fRegs->cap & CAP_SPM) ? "yes" : "no"); TRACE("cap: Supports External SATA: %s\n", (fRegs->cap & CAP_SXS) ? "yes" : "no"); TRACE("cap: Enclosure Management Supported: %s\n", (fRegs->cap & CAP_EMS) ? "yes" : "no"); + + TRACE("cap: Supports 64-bit Addressing: %s\n", (fRegs->cap & CAP_S64A) ? "yes" : "no"); + TRACE("cap: Supports Native Command Queuing: %s\n", (fRegs->cap & CAP_SNCQ) ? "yes" : "no"); + TRACE("cap: Supports SNotification Register: %s\n", (fRegs->cap & CAP_SSNTF) ? "yes" : "no"); + TRACE("cap: Supports Command List Override: %s\n", (fRegs->cap & CAP_SCLO) ? "yes" : "no"); + + TRACE("cap: Supports AHCI mode only: %s\n", (fRegs->cap & CAP_SAM) ? "yes" : "no"); TRACE("ghc: AHCI Enable: %s\n", (fRegs->ghc & GHC_AE) ? "yes" : "no"); TRACE("Ports Implemented: %08lx\n", fRegs->pi); + TRACE("Highest port Number: %d\n", fPortMax); TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); + + for (int i = 0; i <= fPortMax; i++) { + if (fRegs->pi & (1 << i)) { + fPorts[i] = new (std::nothrow)AHCIPort(this, i); + if (!fPorts[i]) { + TRACE("out of memory creating port %d", i); + break; + } + status_t status = fPorts[i]->Init(); + if (status < B_OK) { + TRACE("init port %d failed", i); + delete fPorts[i]; + fPorts[i] = NULL; + break; + } + } + } + // disable interrupts fRegs->ghc &= ~GHC_IE; // clear pending interrupts @@ -96,6 +144,10 @@ return B_OK; + +err: + delete_area(fRegsArea); + return B_ERROR; } @@ -104,6 +156,13 @@ { TRACE("AHCIController::Uninit\n"); + for (int i = 0; i <= fPortMax; i++) { + if (fPorts[i]) { + fPorts[i]->Uninit(); + delete fPorts[i]; + } + } + // disable interrupts fRegs->ghc &= ~GHC_IE; // clear pending interrupts @@ -117,6 +176,38 @@ } +status_t +AHCIController::ResetController() +{ + uint32 saveCaps = fRegs->cap & (CAP_SMPS | CAP_SSS | CAP_SPM | CAP_EMS | CAP_SXS); + uint32 savePI = fRegs->pi; + + fRegs->ghc |= GHC_HR; + RegsFlush(); + for (int i = 0; i < 20; i++) { + snooze(50000); + if ((fRegs->ghc & GHC_HR) == 0) + break; + } + if (fRegs->ghc & GHC_HR) + return B_TIMED_OUT; + + fRegs->ghc |= GHC_AE; + RegsFlush(); + fRegs->cap |= saveCaps; + fRegs->pi = savePI; + RegsFlush(); + + if (fPCIVendorID == 0x8086) { + // Intel PCS?Port Control and Status + // In AHCI enabled systems, bits[3:0] must always be set + gPCI->write_pci_config(fPCIDevice, 0x92, 2, + 0xf | gPCI->read_pci_config(fPCIDevice, 0x92, 2)); + } + return B_OK; +} + + void AHCIController::ExecuteRequest(scsi_ccb *request) { Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 18:51:03 UTC (rev 22143) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 18:51:57 UTC (rev 22144) @@ -7,6 +7,7 @@ #include "ahci_defs.h" +#include "ahci_port.h" class AHCIController { @@ -27,16 +28,22 @@ private: bool IsDevicePresent(uint device); + status_t ResetController(); + void RegsFlush(); private: device_node_handle fNode; pci_device_info* fPCIDevice; uint32 fDevicePresentMask; + uint16 fPCIVendorID; + uint16 fPCIDeviceID; - ahci_hba * fRegs; + volatile ahci_hba * fRegs; area_id fRegsArea; int fCommandSlotCount; int fPortCount; + int fPortMax; + AHCIPort * fPorts[32]; // --- Instance check workaround begin @@ -53,4 +60,12 @@ } +inline void +AHCIController::RegsFlush() +{ + volatile uint32 dummy = fRegs->ghc; + dummy = dummy; +} + + #endif // _AHCI_CONTROLLER_H From marcusoverhagen at mail.berlios.de Sat Sep 1 21:54:45 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 21:54:45 +0200 Subject: [Haiku-commits] r22145 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709011954.l81JsjbD022777@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 21:54:45 +0200 (Sat, 01 Sep 2007) New Revision: 22145 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22145&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h Log: added Interrupt handling framework Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 18:51:57 UTC (rev 22144) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 19:54:45 UTC (rev 22145) @@ -24,6 +24,7 @@ , fCommandSlotCount(0) , fPortCount(0) , fPortMax(0) + , fIRQ(0) , fInstanceCheck(-1) { memset(fPorts, 0, sizeof(fPorts)); @@ -100,6 +101,12 @@ while ((fRegs->pi & (1 << fPortMax)) == 0) fPortMax--; + fIRQ = gPCI->read_pci_config(fPCIDevice, PCI_interrupt_line, 1); + if (fIRQ == 0 || fIRQ == 0xff) { + TRACE("no IRQ assigned\n"); + goto err; + } + TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); @@ -118,7 +125,13 @@ TRACE("Ports Implemented: %08lx\n", fRegs->pi); TRACE("Highest port Number: %d\n", fPortMax); TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); + TRACE("Interrupt %u\n", fIRQ); + // setup interrupt handler + if (install_io_interrupt_handler(fIRQ, Interrupt, this, 0) < B_OK) { + TRACE("can't install interrupt handler\n"); + goto err; + } for (int i = 0; i <= fPortMax; i++) { if (fRegs->pi & (1 << i)) { @@ -137,12 +150,6 @@ } } - // disable interrupts - fRegs->ghc &= ~GHC_IE; - // clear pending interrupts - fRegs->is = 0xffffffff; - - return B_OK; err: @@ -168,6 +175,10 @@ // clear pending interrupts fRegs->is = 0xffffffff; + // well... + remove_io_interrupt_handler(fIRQ, Interrupt, this); + + delete_area(fRegsArea); // --- Instance check workaround begin @@ -208,6 +219,31 @@ } +int32 +AHCIController::Interrupt(void *data) +{ + AHCIController *self = (AHCIController *)data; + uint32 int_stat = self->fRegs->is & self->fRegs->pi; + if (int_stat == 0) + return B_UNHANDLED_INTERRUPT; + + for (int i = 0; i < self->fPortMax; i++) { + if (int_stat & (1 << i)) { + if (self->fPorts[i]) { + self->fPorts[i]->Interrupt(); + } else { + FLOW("interrupt on non-existent port %d\n", i); + } + } + } + + // clear interrupts + self->fRegs->is = int_stat; + + return B_INVOKE_SCHEDULER; +} + + void AHCIController::ExecuteRequest(scsi_ccb *request) { Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 18:51:57 UTC (rev 22144) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 19:54:45 UTC (rev 22145) @@ -31,6 +31,8 @@ status_t ResetController(); void RegsFlush(); +static int32 Interrupt(void *data); + private: device_node_handle fNode; pci_device_info* fPCIDevice; @@ -43,6 +45,7 @@ int fCommandSlotCount; int fPortCount; int fPortMax; + uint8 fIRQ; AHCIPort * fPorts[32]; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 18:51:57 UTC (rev 22144) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 19:54:45 UTC (rev 22145) @@ -36,3 +36,10 @@ { TRACE("AHCIPort::Uninit port %d\n", fIndex); } + + +void +AHCIPort::Interrupt() +{ + TRACE("AHCIPort::Interrupt port %d\n", fIndex); +} Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 18:51:57 UTC (rev 22144) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 19:54:45 UTC (rev 22145) @@ -17,6 +17,8 @@ status_t Init(); void Uninit(); + void Interrupt(); + private: int fIndex; }; From marcusoverhagen at mail.berlios.de Sat Sep 1 22:26:08 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 22:26:08 +0200 Subject: [Haiku-commits] r22146 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709012026.l81KQ83p024208@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 22:26:07 +0200 (Sat, 01 Sep 2007) New Revision: 22146 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22146&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h Log: forward scsi request to the ports Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 19:54:45 UTC (rev 22145) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 20:26:07 UTC (rev 22146) @@ -18,7 +18,6 @@ AHCIController::AHCIController(device_node_handle node, pci_device_info *device) : fNode(node) , fPCIDevice(device) - , fDevicePresentMask(0) , fPCIVendorID(0xffff) , fPCIDeviceID(0xffff) , fCommandSlotCount(0) @@ -27,7 +26,7 @@ , fIRQ(0) , fInstanceCheck(-1) { - memset(fPorts, 0, sizeof(fPorts)); + memset(fPort, 0, sizeof(fPort)); } @@ -135,16 +134,16 @@ for (int i = 0; i <= fPortMax; i++) { if (fRegs->pi & (1 << i)) { - fPorts[i] = new (std::nothrow)AHCIPort(this, i); - if (!fPorts[i]) { + fPort[i] = new (std::nothrow)AHCIPort(this, i); + if (!fPort[i]) { TRACE("out of memory creating port %d", i); break; } - status_t status = fPorts[i]->Init(); + status_t status = fPort[i]->Init(); if (status < B_OK) { TRACE("init port %d failed", i); - delete fPorts[i]; - fPorts[i] = NULL; + delete fPort[i]; + fPort[i] = NULL; break; } } @@ -164,9 +163,9 @@ TRACE("AHCIController::Uninit\n"); for (int i = 0; i <= fPortMax; i++) { - if (fPorts[i]) { - fPorts[i]->Uninit(); - delete fPorts[i]; + if (fPort[i]) { + fPort[i]->Uninit(); + delete fPort[i]; } } @@ -229,8 +228,8 @@ for (int i = 0; i < self->fPortMax; i++) { if (int_stat & (1 << i)) { - if (self->fPorts[i]) { - self->fPorts[i]->Interrupt(); + if (self->fPort[i]) { + self->fPort[i]->Interrupt(); } else { FLOW("interrupt on non-existent port %d\n", i); } @@ -247,49 +246,42 @@ void AHCIController::ExecuteRequest(scsi_ccb *request) { - if (request->target_lun || !IsDevicePresent(request->target_id)) { + if (request->target_lun || !fPort[request->target_id]) { request->subsys_status = SCSI_DEV_NOT_THERE; gSCSI->finished(request, 1); return; } - TRACE("AHCIController::ExecuteRequest opcode %u, length %u\n", request->cdb[0], request->cdb_length); - - request->subsys_status = SCSI_DEV_NOT_THERE; - gSCSI->finished(request, 1); - return; - - request->subsys_status = SCSI_REQ_CMP; - gSCSI->finished(request, 1); + fPort[request->target_id]->ExecuteRequest(request); } uchar AHCIController::AbortRequest(scsi_ccb *request) { - if (request->target_lun || !IsDevicePresent(request->target_id)) + if (request->target_lun || !fPort[request->target_id]) return SCSI_DEV_NOT_THERE; - return SCSI_REQ_CMP; + return fPort[request->target_id]->AbortRequest(request); } uchar AHCIController::TerminateRequest(scsi_ccb *request) { - if (request->target_lun || !IsDevicePresent(request->target_id)) + if (request->target_lun || !fPort[request->target_id]) return SCSI_DEV_NOT_THERE; - return SCSI_REQ_CMP; + return fPort[request->target_id]->TerminateRequest(request); } uchar AHCIController::ResetDevice(uchar targetID, uchar targetLUN) { - if (targetLUN || !IsDevicePresent(targetID)) + if (targetLUN || !fPort[targetID]) return SCSI_DEV_NOT_THERE; - return SCSI_REQ_CMP; + return fPort[targetID]->ResetDevice(); } Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 19:54:45 UTC (rev 22145) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-01 20:26:07 UTC (rev 22146) @@ -33,10 +33,11 @@ static int32 Interrupt(void *data); + friend class AHCIPort; + private: device_node_handle fNode; pci_device_info* fPCIDevice; - uint32 fDevicePresentMask; uint16 fPCIVendorID; uint16 fPCIDeviceID; @@ -46,7 +47,7 @@ int fPortCount; int fPortMax; uint8 fIRQ; - AHCIPort * fPorts[32]; + AHCIPort * fPort[32]; // --- Instance check workaround begin @@ -56,13 +57,6 @@ }; -inline bool -AHCIController::IsDevicePresent(uint device) -{ - return fDevicePresentMask & (1 << device); -} - - inline void AHCIController::RegsFlush() { Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 19:54:45 UTC (rev 22145) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-01 20:26:07 UTC (rev 22146) @@ -4,6 +4,7 @@ */ #include "ahci_port.h" +#include "ahci_controller.h" #include #include @@ -14,6 +15,7 @@ AHCIPort::AHCIPort(AHCIController *controller, int index) : fIndex(index) + , fRegs(&controller->fRegs->port[index]) { } @@ -43,3 +45,41 @@ { TRACE("AHCIPort::Interrupt port %d\n", fIndex); } + + +void +AHCIPort::ExecuteRequest(scsi_ccb *request) +{ + + TRACE("AHCIPort::ExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length); + + request->subsys_status = SCSI_DEV_NOT_THERE; + gSCSI->finished(request, 1); + return; + + request->subsys_status = SCSI_REQ_CMP; + gSCSI->finished(request, 1); +} + + +uchar +AHCIPort::AbortRequest(scsi_ccb *request) +{ + + return SCSI_REQ_CMP; +} + + +uchar +AHCIPort::TerminateRequest(scsi_ccb *request) +{ + return SCSI_REQ_CMP; +} + + +uchar +AHCIPort::ResetDevice() +{ + return SCSI_REQ_CMP; +} + Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 19:54:45 UTC (rev 22145) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-01 20:26:07 UTC (rev 22146) @@ -19,8 +19,16 @@ void Interrupt(); + + void ExecuteRequest(scsi_ccb *request); + uchar AbortRequest(scsi_ccb *request); + uchar TerminateRequest(scsi_ccb *request); + uchar ResetDevice(); + + private: - int fIndex; + int fIndex; + volatile ahci_port * fRegs; }; #endif // _AHCI_PORT_H From marcusoverhagen at mail.berlios.de Sat Sep 1 22:49:08 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sat, 1 Sep 2007 22:49:08 +0200 Subject: [Haiku-commits] r22147 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709012049.l81Kn8v6025403@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-01 22:49:07 +0200 (Sat, 01 Sep 2007) New Revision: 22147 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22147&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp Log: enable interrupts Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 20:26:07 UTC (rev 22146) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-01 20:49:07 UTC (rev 22147) @@ -149,6 +149,10 @@ } } + // enable interrupts + fRegs->ghc |= GHC_IE; + RegsFlush(); + return B_OK; err: @@ -171,8 +175,11 @@ // disable interrupts fRegs->ghc &= ~GHC_IE; + RegsFlush(); + // clear pending interrupts fRegs->is = 0xffffffff; + RegsFlush(); // well... remove_io_interrupt_handler(fIRQ, Interrupt, this); From axeld at mail.berlios.de Sun Sep 2 14:02:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 2 Sep 2007 14:02:58 +0200 Subject: [Haiku-commits] r22148 - in haiku/trunk/src/tests/servers/app: . menu_crash Message-ID: <200709021202.l82C2wax013821@sheep.berlios.de> Author: axeld Date: 2007-09-02 14:02:57 +0200 (Sun, 02 Sep 2007) New Revision: 22148 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22148&view=rev Added: haiku/trunk/src/tests/servers/app/menu_crash/ haiku/trunk/src/tests/servers/app/menu_crash/Jamfile haiku/trunk/src/tests/servers/app/menu_crash/MenuCrash.cpp Modified: haiku/trunk/src/tests/servers/app/Jamfile Log: Added a test application to investigate how BeOS deals with keyboard input in menus - the application will crash as soon as you open the "Crash" sub menu. Modified: haiku/trunk/src/tests/servers/app/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/Jamfile 2007-09-01 20:49:07 UTC (rev 22147) +++ haiku/trunk/src/tests/servers/app/Jamfile 2007-09-02 12:02:57 UTC (rev 22148) @@ -167,6 +167,7 @@ SubInclude HAIKU_TOP src tests servers app event_mask ; SubInclude HAIKU_TOP src tests servers app following ; SubInclude HAIKU_TOP src tests servers app look_and_feel ; +SubInclude HAIKU_TOP src tests servers app menu_crash ; SubInclude HAIKU_TOP src tests servers app no_pointer_history ; SubInclude HAIKU_TOP src tests servers app painter ; SubInclude HAIKU_TOP src tests servers app playground ; Added: haiku/trunk/src/tests/servers/app/menu_crash/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/menu_crash/Jamfile 2007-09-01 20:49:07 UTC (rev 22147) +++ haiku/trunk/src/tests/servers/app/menu_crash/Jamfile 2007-09-02 12:02:57 UTC (rev 22148) @@ -0,0 +1,13 @@ +SubDir HAIKU_TOP src tests servers app menu_crash ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +Application MenuCrash : + MenuCrash.cpp + : be +; + Added: haiku/trunk/src/tests/servers/app/menu_crash/MenuCrash.cpp =================================================================== --- haiku/trunk/src/tests/servers/app/menu_crash/MenuCrash.cpp 2007-09-01 20:49:07 UTC (rev 22147) +++ haiku/trunk/src/tests/servers/app/menu_crash/MenuCrash.cpp 2007-09-02 12:02:57 UTC (rev 22148) @@ -0,0 +1,129 @@ +/* + * Copyright 2007, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + */ + + +#include + +#include +#include +#include +#include +#include +#include + + +class MenuItem : public BMenuItem { + public: + MenuItem(const char* name); + virtual ~MenuItem(); + + virtual void DrawContent(); +}; + + +MenuItem::MenuItem(const char* name) + : BMenuItem(name, NULL) +{ +} + + +MenuItem::~MenuItem() +{ +} + + +void +MenuItem::DrawContent() +{ + *(uint32*)0 = 0; +} + + +// #pragma mark - + + +class Window : public BWindow { + public: + Window(); + virtual ~Window(); + + virtual bool QuitRequested(); +}; + + +Window::Window() + : BWindow(BRect(100, 100, 400, 400), "MenuCrash-Test", + B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) +{ + BMenuBar* menuBar = new BMenuBar(Bounds(), "menu"); + AddChild(menuBar); + + // add menu + + BMenu* menu = new BMenu("File"); + BMenu* crashMenu = new BMenu("Crash"); + crashMenu->AddItem(new MenuItem("Crash")); + menu->AddItem(crashMenu); + + menu->AddSeparatorItem(); + + menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), + 'Q', B_COMMAND_KEY)); + menu->SetTargetForItems(this); + menuBar->AddItem(menu); +} + +Window::~Window() +{ +} + + +bool +Window::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + + +// #pragma mark - + + +class Application : public BApplication { + public: + Application(); + + virtual void ReadyToRun(void); +}; + + +Application::Application() + : BApplication("application/x-vnd.haiku-menu_crash") +{ +} + + +void +Application::ReadyToRun(void) +{ + Window *window = new Window(); + window->Show(); +} + + +// #pragma mark - + + +int +main(int argc, char **argv) +{ + Application app; + + app.Run(); + return 0; +} From axeld at mail.berlios.de Sun Sep 2 14:16:29 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 2 Sep 2007 14:16:29 +0200 Subject: [Haiku-commits] r22149 - haiku/trunk/src/servers/app Message-ID: <200709021216.l82CGTfO014391@sheep.berlios.de> Author: axeld Date: 2007-09-02 14:16:28 +0200 (Sun, 02 Sep 2007) New Revision: 22149 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22149&view=rev Modified: haiku/trunk/src/servers/app/Desktop.cpp haiku/trunk/src/servers/app/WindowLayer.cpp Log: * Made menu windows behave differently than others: before, they were just always put between window screens and modal all windows (before floating all ones), so a BWindowScreen couldn't have menus at all. Now, they behave more like floating app windows, just that they float above all other application windows, such that all window feels (also BWindowScreen) can now have menus. * Reenabled keyboard redirection to the top most window in case it's a menu; bug #1152 no longer applies due to the above change. Modified: haiku/trunk/src/servers/app/Desktop.cpp =================================================================== --- haiku/trunk/src/servers/app/Desktop.cpp 2007-09-02 12:02:57 UTC (rev 22148) +++ haiku/trunk/src/servers/app/Desktop.cpp 2007-09-02 12:16:28 UTC (rev 22149) @@ -1107,13 +1107,10 @@ EventTarget* Desktop::KeyboardEventTarget() { - // TODO: Not yet useful, and prevents a crashing application - // which has opened menu windows to be debugged (ticket #1152) -#if 0 WindowLayer* window = _CurrentWindows().LastWindow(); if (window != NULL && window->Feel() == kMenuWindowFeel) return &window->EventTarget(); -#endif + if (FocusWindow() != NULL) return &FocusWindow()->EventTarget(); Modified: haiku/trunk/src/servers/app/WindowLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/WindowLayer.cpp 2007-09-02 12:02:57 UTC (rev 22148) +++ haiku/trunk/src/servers/app/WindowLayer.cpp 2007-09-02 12:16:28 UTC (rev 22149) @@ -1528,13 +1528,21 @@ bool WindowLayer::HasInSubset(const WindowLayer* window) const { - if (window == NULL || fFeel == window->Feel() || fFeel == B_NORMAL_WINDOW_FEEL) + if (window == NULL || fFeel == window->Feel() + || fFeel == B_NORMAL_WINDOW_FEEL) return false; + // Menus are a special case: they will always be on-top of every window + // of their application + if (fFeel == kMenuWindowFeel) + return window->ServerWindow()->App() == ServerWindow()->App(); + else if (window->Feel() == kMenuWindowFeel) + return false; + // we have a few special feels that have a fixed order - const int32 feel[] = {kWindowScreenFeel, kMenuWindowFeel, - B_MODAL_ALL_WINDOW_FEEL, B_FLOATING_ALL_WINDOW_FEEL, 0}; + const int32 feel[] = {kWindowScreenFeel, B_MODAL_ALL_WINDOW_FEEL, + B_FLOATING_ALL_WINDOW_FEEL, 0}; for (int32 order = 0; feel[order]; order++) { if (fFeel == feel[order]) From bonefish at cs.tu-berlin.de Sun Sep 2 14:56:30 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sun, 02 Sep 2007 14:56:30 +0200 Subject: [Haiku-commits] r22148 - in haiku/trunk/src/tests/servers/app: . menu_crash In-Reply-To: <200709021202.l82C2wax013821@sheep.berlios.de> References: <200709021202.l82C2wax013821@sheep.berlios.de> Message-ID: <20070902145630.608.1@cs.tu-berlin.de> On 2007-09-02 at 14:02:58 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2007-09-02 14:02:57 +0200 (Sun, 02 Sep 2007) > New Revision: 22148 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22148&view=rev > > Added: > haiku/trunk/src/tests/servers/app/menu_crash/ > haiku/trunk/src/tests/servers/app/menu_crash/Jamfile > haiku/trunk/src/tests/servers/app/menu_crash/MenuCrash.cpp > Modified: > haiku/trunk/src/tests/servers/app/Jamfile > Log: > Added a test application to investigate how BeOS deals with keyboard input > in menus - the application will crash as soon as you open the "Crash" sub > menu. BTW, there's already src/tests/servers/debug/crashing_app.cpp. Feel free to extend it, if you invent new methods of crashing. :-) CU, Ingo From axeld at pinc-software.de Sun Sep 2 15:05:37 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 02 Sep 2007 15:05:37 +0200 CEST Subject: [Haiku-commits] r22148 - in haiku/trunk/src/tests/servers/app: . menu_crash In-Reply-To: <20070902145630.608.1@cs.tu-berlin.de> Message-ID: <14448692649-BeMail@zon> Ingo Weinhold wrote: > > Log: > > Added a test application to investigate how BeOS deals with > > keyboard input > > in menus - the application will crash as soon as you open the > > "Crash" sub > > menu. > BTW, there's already src/tests/servers/debug/crashing_app.cpp. Feel > free to > extend it, if you invent new methods of crashing. :-) It was not so much about the crash than about having a menu on screen that doesn't easily get away :-) Bye, Axel. From bonefish at mail.berlios.de Mon Sep 3 00:04:39 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 00:04:39 +0200 Subject: [Haiku-commits] r22150 - in haiku/trunk: headers/private/kernel/arch src/system/kernel/arch/x86 Message-ID: <200709022204.l82M4d4N030833@sheep.berlios.de> Author: bonefish Date: 2007-09-03 00:04:36 +0200 (Mon, 03 Sep 2007) New Revision: 22150 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22150&view=rev Modified: haiku/trunk/headers/private/kernel/arch/user_debugger.h haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp Log: * Added support for setting (hardware) break-/watchpoints in the kernel. Can be enabled by defining KERNEL_BREAKPOINTS in arch/user_debugger.h and will provide the arch_{set,clear}_kernel_{break,watch}point() function. Hitting a break-/watchpoint will throw the thread into KDL. * Finally added a comment, what's the point of i386_reinit_user_debug_after_context_switch(), since I wonder every time I see it. Should be optimized aways soon. Modified: haiku/trunk/headers/private/kernel/arch/user_debugger.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/user_debugger.h 2007-09-02 12:16:28 UTC (rev 22149) +++ haiku/trunk/headers/private/kernel/arch/user_debugger.h 2007-09-02 22:04:36 UTC (rev 22150) @@ -11,6 +11,9 @@ extern "C" { #endif +// Enable this to get support for kernel breakpoints. +//#define KERNEL_BREAKPOINTS 1 + struct arch_team_debug_info; struct arch_thread_debug_info; @@ -27,6 +30,13 @@ status_t arch_set_watchpoint(void *address, uint32 type, int32 length); status_t arch_clear_watchpoint(void *address); +#if KERNEL_BREAKPOINTS +status_t arch_set_kernel_breakpoint(void *address); +status_t arch_clear_kernel_breakpoint(void *address); +status_t arch_set_kernel_watchpoint(void *address, uint32 type, int32 length); +status_t arch_clear_kernel_watchpoint(void *address); +#endif + #ifdef __cplusplus } #endif Modified: haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-09-02 12:16:28 UTC (rev 22149) +++ haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-09-02 22:04:36 UTC (rev 22150) @@ -3,14 +3,17 @@ * Distributed under the terms of the MIT License. */ +#include + #include #include #include #include +#include #include -#include + //#define TRACE_ARCH_USER_DEBUGGER #ifdef TRACE_ARCH_USER_DEBUGGER # define TRACE(x) dprintf x @@ -18,13 +21,13 @@ # define TRACE(x) ; #endif -#define B_NO_MORE_BREAKPOINTS B_ERROR -#define B_NO_MORE_WATCHPOINTS B_ERROR -#define B_BAD_WATCHPOINT_ALIGNMENT B_ERROR -#define B_WATCHPOINT_TYPE_NOT_SUPPORTED B_ERROR -#define B_WATCHPOINT_LENGTH_NOT_SUPPORTED B_ERROR -#define B_BREAKPOINT_NOT_FOUND B_ERROR -#define B_WATCHPOINT_NOT_FOUND B_ERROR +#define B_NO_MORE_BREAKPOINTS B_BUSY +#define B_NO_MORE_WATCHPOINTS B_BUSY +#define B_BAD_WATCHPOINT_ALIGNMENT B_BAD_VALUE +#define B_WATCHPOINT_TYPE_NOT_SUPPORTED B_NOT_SUPPORTED +#define B_WATCHPOINT_LENGTH_NOT_SUPPORTED B_NOT_SUPPORTED +#define B_BREAKPOINT_NOT_FOUND B_NAME_NOT_FOUND +#define B_WATCHPOINT_NOT_FOUND B_NAME_NOT_FOUND // ToDo: Make those real error codes. // maps breakpoint slot index to LEN_i LSB number @@ -42,6 +45,11 @@ X86_DR7_L0, X86_DR7_L1, X86_DR7_L2, X86_DR7_L3 }; +// maps breakpoint slot index to G_i bit number +static const uint32 sDR7G[4] = { + X86_DR7_G0, X86_DR7_G1, X86_DR7_G2, X86_DR7_G3 +}; + // maps breakpoint slot index to B_i bit number static const uint32 sDR6B[4] = { X86_DR6_B0, X86_DR6_B1, X86_DR6_B2, X86_DR6_B3 @@ -52,6 +60,250 @@ static bool sQEmuSingleStepHack = false; +static inline void +install_breakpoints(const arch_team_debug_info &teamInfo) +{ + // set breakpoints + asm("movl %0, %%dr0" : : "r"(teamInfo.breakpoints[0].address)); + asm("movl %0, %%dr1" : : "r"(teamInfo.breakpoints[1].address)); + asm("movl %0, %%dr2" : : "r"(teamInfo.breakpoints[2].address)); +// asm("movl %0, %%dr3" : : "r"(teamInfo.breakpoints[3].address)); + // DR3 is used to hold the current struct thread*. + + // enable breakpoints + asm("movl %0, %%dr7" : : "r"(teamInfo.dr7)); +} + + +static inline void +disable_breakpoints() +{ + asm("movl %0, %%dr7" : : "r"(X86_BREAKPOINTS_DISABLED_DR7)); +} + + +/*! Sets a break-/watchpoint in the given team info. + Interrupts must be disabled and the team debug info lock be held. +*/ +static inline status_t +set_breakpoint(arch_team_debug_info &info, void *address, uint32 type, + uint32 length, bool setGlobalFlag) +{ + // check, if there is already a breakpoint at that address + bool alreadySet = false; + for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { + if (info.breakpoints[i].address == address + && info.breakpoints[i].type == type) { + alreadySet = true; + break; + } + } + + if (!alreadySet) { + // find a free slot + int32 slot = -1; + for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { + if (!info.breakpoints[i].address) { + slot = i; + break; + } + } + + // init the breakpoint + if (slot >= 0) { + info.breakpoints[slot].address = address; + info.breakpoints[slot].type = type; + info.breakpoints[slot].length = length; + + info.dr7 |= (length << sDR7Len[slot]) + | (type << sDR7RW[slot]) + | (1 << sDR7L[slot]); + if (setGlobalFlag) + info.dr7 |= (1 << sDR7G[slot]); + } else { + if (type == X86_INSTRUCTION_BREAKPOINT) + return B_NO_MORE_BREAKPOINTS; + else + return B_NO_MORE_WATCHPOINTS; + } + } + + return B_OK; +} + + +/*! Clears a break-/watchpoint in the given team info. + Interrupts must be disabled and the team debug info lock be held. +*/ +static inline status_t +clear_breakpoint(arch_team_debug_info &info, void *address, bool watchpoint) +{ + // find the breakpoint + int32 slot = -1; + for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { + if (info.breakpoints[i].address == address + && (watchpoint + != (info.breakpoints[i].type == X86_INSTRUCTION_BREAKPOINT))) { + slot = i; + break; + } + } + + // clear the breakpoint + if (slot >= 0) { + info.breakpoints[slot].address = NULL; + + info.dr7 &= ~((0x3 << sDR7Len[slot]) + | (0x3 << sDR7RW[slot]) + | (1 << sDR7L[slot]) + | (1 << sDR7G[slot])); + } else { + if (watchpoint) + return B_WATCHPOINT_NOT_FOUND; + else + return B_BREAKPOINT_NOT_FOUND; + } + + return B_OK; +} + + +static status_t +set_breakpoint(void *address, uint32 type, uint32 length) +{ + if (!address) + return B_BAD_VALUE; + + struct thread *thread = thread_get_current_thread(); + + cpu_status state = disable_interrupts(); + GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); + + status_t error = set_breakpoint(thread->team->debug_info.arch_info, address, + type, length, false); + + RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); + restore_interrupts(state); + + return error; +} + + +static status_t +clear_breakpoint(void *address, bool watchpoint) +{ + if (!address) + return B_BAD_VALUE; + + struct thread *thread = thread_get_current_thread(); + + cpu_status state = disable_interrupts(); + GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); + + status_t error = clear_breakpoint(thread->team->debug_info.arch_info, + address, watchpoint); + + RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); + restore_interrupts(state); + + return error; +} + + +#if KERNEL_BREAKPOINTS + +static status_t +set_kernel_breakpoint(void *address, uint32 type, uint32 length) +{ + if (!address) + return B_BAD_VALUE; + + struct team* kernelTeam = team_get_kernel_team(); + + cpu_status state = disable_interrupts(); + GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + + status_t error = set_breakpoint(kernelTeam->debug_info.arch_info, address, + type, length, true); + + install_breakpoints(kernelTeam->debug_info.arch_info); + + RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + restore_interrupts(state); + + return error; +} + + +static status_t +clear_kernel_breakpoint(void *address, bool watchpoint) +{ + if (!address) + return B_BAD_VALUE; + + struct team* kernelTeam = team_get_kernel_team(); + + cpu_status state = disable_interrupts(); + GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + + status_t error = clear_breakpoint(kernelTeam->debug_info.arch_info, + address, watchpoint); + + install_breakpoints(kernelTeam->debug_info.arch_info); + + RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + restore_interrupts(state); + + return error; +} + +#endif // KERNEL_BREAKPOINTS + + +static inline status_t +check_watch_point_parameters(void* address, uint32 type, int32 length, + uint32& archType, uint32& archLength) +{ + // check type + switch (type) { + case B_DATA_WRITE_WATCHPOINT: + archType = X86_DATA_WRITE_BREAKPOINT; + break; + case B_DATA_READ_WRITE_WATCHPOINT: + archType = X86_DATA_READ_WRITE_BREAKPOINT; + break; + case B_DATA_READ_WATCHPOINT: + default: + return B_WATCHPOINT_TYPE_NOT_SUPPORTED; + break; + } + + // check length and alignment + switch (length) { + case 1: + archLength = X86_BREAKPOINT_LENGTH_1; + break; + case 2: + if ((uint32)address & 0x1) + return B_BAD_WATCHPOINT_ALIGNMENT; + archLength = X86_BREAKPOINT_LENGTH_2; + break; + case 4: + if ((uint32)address & 0x3) + return B_BAD_WATCHPOINT_ALIGNMENT; + archLength = X86_BREAKPOINT_LENGTH_4; + break; + default: + return B_WATCHPOINT_LENGTH_NOT_SUPPORTED; + } + + return B_OK; +} + + +// #pragma mark - in-kernel public interface + + void arch_clear_team_debug_info(struct arch_team_debug_info *info) { @@ -116,6 +368,7 @@ } } + void arch_get_debug_cpu_state(struct debug_cpu_state *cpuState) { @@ -148,189 +401,109 @@ } } -static status_t -set_breakpoint(void *address, uint32 type, uint32 length) + +status_t +arch_set_breakpoint(void *address) { - if (!address) - return B_BAD_VALUE; + return set_breakpoint(address, X86_INSTRUCTION_BREAKPOINT, + X86_BREAKPOINT_LENGTH_1); +} - struct thread *thread = thread_get_current_thread(); - status_t error = B_OK; +status_t +arch_clear_breakpoint(void *address) +{ + return clear_breakpoint(address, false); +} - cpu_status state = disable_interrupts(); - GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); - arch_team_debug_info &info = thread->team->debug_info.arch_info; +status_t +arch_set_watchpoint(void *address, uint32 type, int32 length) +{ + uint32 archType, archLength; + status_t error = check_watch_point_parameters(address, type, length, + archType, archLength); + if (error != B_OK) + return error; - // check, if there is already a breakpoint at that address - bool alreadySet = false; - for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { - if (info.breakpoints[i].address == address - && info.breakpoints[i].type == type) { - alreadySet = true; - break; - } - } - - if (!alreadySet) { - // find a free slot - int32 slot = -1; - for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { - if (!info.breakpoints[i].address) { - slot = i; - break; - } - } - - // init the breakpoint - if (slot >= 0) { - info.breakpoints[slot].address = address; - info.breakpoints[slot].type = type; - info.breakpoints[slot].length = length; - - info.dr7 |= (length << sDR7Len[slot]) - | (type << sDR7RW[slot]) - | (1 << sDR7L[slot]); - } else { - if (type == X86_INSTRUCTION_BREAKPOINT) - error = B_NO_MORE_BREAKPOINTS; - else - error = B_NO_MORE_WATCHPOINTS; - } - } - - RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); - restore_interrupts(state); - - return error; + return set_breakpoint(address, archType, archLength); } -static status_t -clear_breakpoint(void *address, bool watchpoint) +status_t +arch_clear_watchpoint(void *address) { - if (!address) - return B_BAD_VALUE; + return clear_breakpoint(address, false); +} - struct thread *thread = thread_get_current_thread(); - status_t error = B_OK; +#if KERNEL_BREAKPOINTS - cpu_status state = disable_interrupts(); - GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); +status_t +arch_set_kernel_breakpoint(void *address) +{ + status_t error = set_kernel_breakpoint(address, X86_INSTRUCTION_BREAKPOINT, + X86_BREAKPOINT_LENGTH_1); - arch_team_debug_info &info = thread->team->debug_info.arch_info; - - // find the breakpoint - int32 slot = -1; - for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { - if (info.breakpoints[i].address == address - && (watchpoint - != (info.breakpoints[i].type == X86_INSTRUCTION_BREAKPOINT))) { - slot = i; - break; - } + if (error != B_OK) { + panic("arch_set_kernel_breakpoint() failed to set breakpoint: %s", + strerror(error)); } - // clear the breakpoint - if (slot >= 0) { - info.breakpoints[slot].address = NULL; - - info.dr7 &= ~((0x3 << sDR7Len[slot]) - | (0x3 << sDR7RW[slot]) - | (1 << sDR7L[slot])); - } else { - if (watchpoint) - error = B_WATCHPOINT_NOT_FOUND; - else - error = B_BREAKPOINT_NOT_FOUND; - } - - RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); - restore_interrupts(state); - return error; } status_t -arch_set_breakpoint(void *address) +arch_clear_kernel_breakpoint(void *address) { - return set_breakpoint(address, X86_INSTRUCTION_BREAKPOINT, - X86_BREAKPOINT_LENGTH_1); -} + status_t error = clear_kernel_breakpoint(address, false); + if (error != B_OK) { + panic("arch_clear_kernel_breakpoint() failed to clear breakpoint: %s", + strerror(error)); + } -status_t -arch_clear_breakpoint(void *address) -{ - return clear_breakpoint(address, false); + return error; } status_t -arch_set_watchpoint(void *address, uint32 type, int32 length) +arch_set_kernel_watchpoint(void *address, uint32 type, int32 length) { - // check type - uint32 archType; - switch (type) { - case B_DATA_WRITE_WATCHPOINT: - archType = X86_DATA_WRITE_BREAKPOINT; - break; - case B_DATA_READ_WRITE_WATCHPOINT: - archType = X86_DATA_READ_WRITE_BREAKPOINT; - break; - case B_DATA_READ_WATCHPOINT: - default: - return B_WATCHPOINT_TYPE_NOT_SUPPORTED; - break; - } + uint32 archType, archLength; + status_t error = check_watch_point_parameters(address, type, length, + archType, archLength); - // check length and alignment - uint32 archLength; - switch (length) { - case 1: - archLength = X86_BREAKPOINT_LENGTH_1; - break; - case 2: - if ((uint32)address & 0x1) - return B_BAD_WATCHPOINT_ALIGNMENT; - archLength = X86_BREAKPOINT_LENGTH_2; - break; - case 4: - if ((uint32)address & 0x3) - return B_BAD_WATCHPOINT_ALIGNMENT; - archLength = X86_BREAKPOINT_LENGTH_4; - break; - default: - return B_WATCHPOINT_LENGTH_NOT_SUPPORTED; + if (error == B_OK) + error = set_kernel_breakpoint(address, archType, archLength); + + if (error != B_OK) { + panic("arch_set_kernel_watchpoint() failed to set watchpoint: %s", + strerror(error)); } - return set_breakpoint(address, archType, archLength); + return error; } status_t -arch_clear_watchpoint(void *address) +arch_clear_kernel_watchpoint(void *address) { - return clear_breakpoint(address, false); + status_t error = clear_kernel_breakpoint(address, true); + + if (error != B_OK) { + panic("arch_clear_kernel_watchpoint() failed to clear watchpoint: %s", + strerror(error)); + } + + return error; } +#endif // KERNEL_BREAKPOINTS -static inline void -install_breakpoints(const arch_team_debug_info &teamInfo) -{ - // set breakpoints - asm("movl %0, %%dr0" : : "r"(teamInfo.breakpoints[0].address)); - asm("movl %0, %%dr1" : : "r"(teamInfo.breakpoints[1].address)); - asm("movl %0, %%dr2" : : "r"(teamInfo.breakpoints[2].address)); -// asm("movl %0, %%dr3" : : "r"(teamInfo.breakpoints[3].address)); - // DR3 is used to hold the current struct thread*. - // enable breakpoints - asm("movl %0, %%dr7" : : "r"(teamInfo.dr7)); -} +// #pragma mark - x86 implementation interface /** @@ -378,9 +551,16 @@ GRAB_THREAD_LOCK(); // disable breakpoints - asm("movl %0, %%dr7" : : "r"(X86_BREAKPOINTS_DISABLED_DR7)); + disable_breakpoints(); thread->debug_info.arch_info.flags &= ~X86_THREAD_DEBUG_DR7_SET; +#if KERNEL_BREAKPOINTS + struct team* kernelTeam = team_get_kernel_team(); + GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + install_breakpoints(kernelTeam->debug_info.arch_info); + RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); +#endif + RELEASE_THREAD_LOCK(); restore_interrupts(state); } @@ -392,12 +572,29 @@ void i386_reinit_user_debug_after_context_switch(struct thread *thread) { + // This function deals with a race condition: We set up the debugging + // registers in i386_init_user_debug_at_kernel_exit() when a userland + // thread is going to leave the kernel. Afterwards the thread might be + // preempted, though, since interrupts are enabled. + // X86_THREAD_DEBUG_DR7_SET indicates, when this happens. +// TODO: We should fix this by disabling interrupts before +// i386_init_user_debug_at_kernel_exit() is called and keep them disabled +// until returning from the interrupt. + if (thread->debug_info.arch_info.flags & X86_THREAD_DEBUG_DR7_SET) { GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); install_breakpoints(thread->team->debug_info.arch_info); RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); +#if KERNEL_BREAKPOINTS + } else { + // we're still in the kernel + struct team* kernelTeam = team_get_kernel_team(); + GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); + install_breakpoints(kernelTeam->debug_info.arch_info); + RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); +#endif } } @@ -415,6 +612,12 @@ TRACE(("i386_handle_debug_exception(): DR6: %lx, DR7: %lx\n", dr6, dr7)); + if (frame->cs != USER_CODE_SEG) { + panic("debug exception in kernel mode: dr6: 0x%lx, dr7: 0x%lx", dr6, + dr7); + return B_HANDLED_INTERRUPT; + } + // check, which exception condition applies if (dr6 & X86_DR6_BREAKPOINT_MASK) { // breakpoint @@ -483,6 +686,11 @@ { TRACE(("i386_handle_breakpoint_exception()\n")); + if (frame->cs != USER_CODE_SEG) { + panic("breakpoint exception in kernel mode"); + return B_HANDLED_INTERRUPT; + } + enable_interrupts(); user_debug_breakpoint_hit(true); From bonefish at mail.berlios.de Mon Sep 3 00:21:26 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 00:21:26 +0200 Subject: [Haiku-commits] r22151 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200709022221.l82MLQK4032753@sheep.berlios.de> Author: bonefish Date: 2007-09-03 00:21:26 +0200 (Mon, 03 Sep 2007) New Revision: 22151 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22151&view=rev Modified: haiku/trunk/headers/private/kernel/condition_variable.h haiku/trunk/src/system/kernel/condition_variable.cpp Log: * Fixed incorrect check in condition_variable_interrupt_thread(). Condition variables would never be interrupted. * ConditionVariableEntry::Add() did not correctly insert the entry into the per-thread list of entries (the next link of the previous entry was not adjusted), which could leave the entry unnotified when the previous entry was notified, thus leaving it in the respective condition variable's list after the end of its life time. This should fix a crashing bug I rarely encountered. * Added debug checks in the PrivateConditionVariableEntry constructor/destructor that should have helped me to find forementioned bug hours earlier, had I been bright enough to realize that I didn't include and those KDEBUG guarded checks were never executed. :-/ Modified: haiku/trunk/headers/private/kernel/condition_variable.h =================================================================== --- haiku/trunk/headers/private/kernel/condition_variable.h 2007-09-02 22:04:36 UTC (rev 22150) +++ haiku/trunk/headers/private/kernel/condition_variable.h 2007-09-02 22:21:26 UTC (rev 22151) @@ -8,6 +8,8 @@ #include +#include + #ifdef __cplusplus #include @@ -18,11 +20,28 @@ struct PrivateConditionVariableEntry { public: +#if KDEBUG + inline PrivateConditionVariableEntry() + : fVariable(NULL) + { + } + + inline ~PrivateConditionVariableEntry() + { + if (fVariable != NULL) { + panic("Destroying condition variable entry %p, but it's still " + "attached to variable %p\n", this, fVariable); + } + } +#endif + inline PrivateConditionVariable* Variable() const { return fVariable; } inline PrivateConditionVariableEntry* ThreadNext() const { return fThreadNext; } + inline PrivateConditionVariableEntry* ThreadPrevious() const + { return fThreadPrevious; } class Private; Modified: haiku/trunk/src/system/kernel/condition_variable.cpp =================================================================== --- haiku/trunk/src/system/kernel/condition_variable.cpp 2007-09-02 22:04:36 UTC (rev 22150) +++ haiku/trunk/src/system/kernel/condition_variable.cpp 2007-09-02 22:21:26 UTC (rev 22151) @@ -107,6 +107,8 @@ if (threadNext) { fThreadPrevious = threadNext->fThreadPrevious; threadNext->fThreadPrevious = this; + if (fThreadPrevious) + fThreadPrevious->fThreadNext = this; } else fThreadPrevious = NULL; @@ -399,7 +401,7 @@ // re-get the thread and do the checks again thread = thread_get_thread_struct_locked(threadID); - if (thread != NULL || thread->state != B_THREAD_WAITING + if (thread == NULL || thread->state != B_THREAD_WAITING || thread->condition_variable_entry == NULL) { return B_BAD_VALUE; } @@ -417,6 +419,7 @@ PrivateConditionVariableEntry::Private(*entry).SetResult(B_INTERRUPTED); // remove all of the thread's entries from their variables + ASSERT(entry->ThreadPrevious() == NULL); while (entry) { PrivateConditionVariableEntry::Private(*entry).Remove(); entry = entry->ThreadNext(); From bonefish at mail.berlios.de Mon Sep 3 00:55:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 00:55:25 +0200 Subject: [Haiku-commits] r22152 - in haiku/trunk: headers/private/kernel src/system/kernel/vm Message-ID: <200709022255.l82MtPb1017032@sheep.berlios.de> Author: bonefish Date: 2007-09-03 00:55:23 +0200 (Mon, 03 Sep 2007) New Revision: 22152 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22152&view=rev Modified: haiku/trunk/headers/private/kernel/vm_types.h haiku/trunk/src/system/kernel/vm/Jamfile haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: * Added "caches" debugger command (to be enable by defining DEBUG_CACHE_LIST) that prints an unspectacular list of pointers to all existing caches. Feel free to extend. * Enhanced MultiAddressSpaceLocker: - It supports choosing between read and write lock per address space, now. - Added AddAreaCacheAndLock(), which adds the address spaces of all areas that are attached to a given area's cache, locks them, and locks the cache. It makes sure that the area list didn't change in the meantime and optionally also that all areas have their no_cache_change flags cleared. * Changed vm_copy_on_write_area() to take a cache instead of an area, requiring it to be locked and all address spaces of affected areas to be read-locked, plus all areas' no_cache_change flags to be cleared. Callers simply use MultiAddressSpaceLocker:: AddAreaCacheAndLock() to do that. This resolves an open TODO, that the areas' base, size, and protection fields were accessed without their address spaces being locked. * vm_copy_area() does now always insert a cache for the target area. Not doing that would cause source and target area being attached to the same cache in case the target protection was read-only. This would make them behave like cloned areas, which would lead to trouble when one of the areas would be changed to writable later. * Fixed the !writable -> writable case in vm_set_area_protection(). It would simply change the protection of all mapped pages for this area, including ones from lower caches, thus causing later writes to the area to be seen by areas that shouldn't see them. This fixes a problem with software breakpoints in gdb. They could cause other programs to be dropped into the debugger. * resize_area() uses MultiAddressSpaceLocker::AddAreaCacheAndLock() now, too, and could be compacted quite a bit. Modified: haiku/trunk/headers/private/kernel/vm_types.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_types.h 2007-09-02 22:21:26 UTC (rev 22151) +++ haiku/trunk/headers/private/kernel/vm_types.h 2007-09-02 22:55:23 UTC (rev 22152) @@ -25,6 +25,9 @@ // between caches. //#define DEBUG_PAGE_CACHE_TRANSITIONS 1 +// Enables a global list of all vm_cache structures. +//#define DEBUG_CACHE_LIST 1 + #ifdef __cplusplus struct vm_page_mapping; typedef DoublyLinkedListLink vm_page_mapping_link; @@ -91,14 +94,14 @@ vm_page_mappings mappings; - #ifdef DEBUG_PAGE_QUEUE +#ifdef DEBUG_PAGE_QUEUE void* queue; - #endif +#endif - #ifdef DEBUG_PAGE_CACHE_TRANSITIONS +#ifdef DEBUG_PAGE_CACHE_TRANSITIONS uint32 debug_flags; struct vm_page *collided_page; - #endif +#endif uint8 type : 2; uint8 state : 3; @@ -162,8 +165,18 @@ uint32 scan_skip : 1; uint32 busy : 1; uint32 type : 5; + +#if DEBUG_CACHE_LIST + struct vm_cache* debug_previous; + struct vm_cache* debug_next; +#endif } vm_cache; + +#if DEBUG_CACHE_LIST +extern vm_cache* gDebugCacheList; +#endif + // vm area typedef struct vm_area { char *name; Modified: haiku/trunk/src/system/kernel/vm/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/vm/Jamfile 2007-09-02 22:21:26 UTC (rev 22151) +++ haiku/trunk/src/system/kernel/vm/Jamfile 2007-09-02 22:55:23 UTC (rev 22152) @@ -1,5 +1,7 @@ SubDir HAIKU_TOP src system kernel vm ; +UsePrivateHeaders shared ; + KernelMergeObject kernel_vm.o : vm.cpp vm_address_space.c Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-09-02 22:21:26 UTC (rev 22151) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-09-02 22:55:23 UTC (rev 22152) @@ -7,14 +7,18 @@ */ -#include "vm_store_anonymous_noswap.h" -#include "vm_store_device.h" -#include "vm_store_null.h" +#include +#include +#include +#include +#include + #include #include -#include +#include + #include #include #include @@ -38,11 +42,11 @@ #include #include -#include -#include -#include -#include +#include "vm_store_anonymous_noswap.h" +#include "vm_store_device.h" +#include "vm_store_null.h" + //#define TRACE_VM //#define TRACE_FAULTS #ifdef TRACE_VM @@ -114,9 +118,15 @@ MultiAddressSpaceLocker(); ~MultiAddressSpaceLocker(); - status_t AddTeam(team_id team, vm_address_space** _space = NULL); - status_t AddArea(area_id area, vm_address_space** _space = NULL); + inline status_t AddTeam(team_id team, bool writeLock, + vm_address_space** _space = NULL); + inline status_t AddArea(area_id area, bool writeLock, + vm_address_space** _space = NULL); + status_t AddAreaCacheAndLock(area_id areaID, bool writeLockThisOne, + bool writeLockOthers, vm_area*& _area, vm_cache** _cache = NULL, + bool checkNoCacheChange = false); + status_t Lock(); void Unlock(); bool IsLocked() const { return fLocked; } @@ -124,18 +134,59 @@ void Unset(); private: + struct lock_item { + vm_address_space* space; + bool write_lock; + }; + bool _ResizeIfNeeded(); - vm_address_space*& _CurrentItem() { return fSpaces[fCount]; } - bool _HasAddressSpace(vm_address_space* space) const; + int32 _IndexOfAddressSpace(vm_address_space* space) const; + status_t _AddAddressSpace(vm_address_space* space, bool writeLock, + vm_address_space** _space); static int _CompareItems(const void* _a, const void* _b); - vm_address_space** fSpaces; + lock_item* fItems; int32 fCapacity; int32 fCount; bool fLocked; }; + +class AreaCacheLocking { +public: + inline bool Lock(vm_cache* lockable) + { + return false; + } + + inline void Unlock(vm_cache* lockable) + { + vm_area_put_locked_cache(lockable); + } +}; + +class AreaCacheLocker : public AutoLocker { +public: + inline AreaCacheLocker(vm_cache* cache = NULL) + : AutoLocker(cache, true) + { + } + + inline AreaCacheLocker(vm_area* area) + : AutoLocker() + { + SetTo(area); + } + + inline void SetTo(vm_area* area) + { + return AutoLocker::SetTo( + area != NULL ? vm_area_get_locked_cache(area) : NULL, true, true); + } +}; + + #define REGION_HASH_TABLE_SIZE 1024 static area_id sNextAreaID; static hash_table *sAreaHash; @@ -396,7 +447,7 @@ MultiAddressSpaceLocker::MultiAddressSpaceLocker() : - fSpaces(NULL), + fItems(NULL), fCapacity(0), fCount(0), fLocked(false) @@ -407,16 +458,16 @@ MultiAddressSpaceLocker::~MultiAddressSpaceLocker() { Unset(); - free(fSpaces); + free(fItems); } /*static*/ int MultiAddressSpaceLocker::_CompareItems(const void* _a, const void* _b) { - vm_address_space* a = *(vm_address_space **)_a; - vm_address_space* b = *(vm_address_space **)_b; - return a->id - b->id; + lock_item* a = (lock_item*)_a; + lock_item* b = (lock_item*)_b; + return a->space->id - b->space->id; } @@ -424,53 +475,56 @@ MultiAddressSpaceLocker::_ResizeIfNeeded() { if (fCount == fCapacity) { - vm_address_space** items = (vm_address_space**)realloc(fSpaces, - (fCapacity + 4) * sizeof(void*)); + lock_item* items = (lock_item*)realloc(fItems, + (fCapacity + 4) * sizeof(lock_item)); if (items == NULL) return false; fCapacity += 4; - fSpaces = items; + fItems = items; } return true; } -bool -MultiAddressSpaceLocker::_HasAddressSpace(vm_address_space* space) const +int32 +MultiAddressSpaceLocker::_IndexOfAddressSpace(vm_address_space* space) const { for (int32 i = 0; i < fCount; i++) { - if (fSpaces[i] == space) - return true; + if (fItems[i].space == space) + return i; } - return false; + return -1; } status_t -MultiAddressSpaceLocker::AddTeam(team_id team, vm_address_space** _space) +MultiAddressSpaceLocker::_AddAddressSpace(vm_address_space* space, + bool writeLock, vm_address_space** _space) { - if (!_ResizeIfNeeded()) - return B_NO_MEMORY; - - vm_address_space*& space = _CurrentItem(); - space = vm_get_address_space_by_id(team); - if (space == NULL) + if (!space) return B_BAD_VALUE; - // check if we have already added this address space - if (_HasAddressSpace(space)) { - // no need to add it again + int32 index = _IndexOfAddressSpace(space); + if (index < 0) { + if (!_ResizeIfNeeded()) { + vm_put_address_space(space); + return B_NO_MEMORY; + } + + lock_item& item = fItems[fCount++]; + item.space = space; + item.write_lock = writeLock; + } else { + + // one reference is enough vm_put_address_space(space); - if (_space != NULL) - *_space = space; - return B_OK; + + fItems[index].write_lock |= writeLock; } - fCount++; - if (_space != NULL) *_space = space; @@ -478,32 +532,21 @@ } -status_t -MultiAddressSpaceLocker::AddArea(area_id area, vm_address_space** _space) +inline status_t +MultiAddressSpaceLocker::AddTeam(team_id team, bool writeLock, + vm_address_space** _space) { - if (!_ResizeIfNeeded()) - return B_NO_MEMORY; + return _AddAddressSpace(vm_get_address_space_by_id(team), writeLock, + _space); +} - vm_address_space*& space = _CurrentItem(); - space = get_address_space_by_area_id(area); - if (space == NULL) - return B_BAD_VALUE; - // check if we have already added this address space - if (_HasAddressSpace(space)) { - // no need to add it again - vm_put_address_space(space); - if (_space != NULL) - *_space = space; - return B_OK; - } - - fCount++; - - if (_space != NULL) - *_space = space; - - return B_OK; +inline status_t +MultiAddressSpaceLocker::AddArea(area_id area, bool writeLock, + vm_address_space** _space) +{ + return _AddAddressSpace(get_address_space_by_area_id(area), writeLock, + _space); } @@ -512,9 +555,8 @@ { Unlock(); - for (int32 i = 0; i < fCount; i++) { - vm_put_address_space(fSpaces[i]); - } + for (int32 i = 0; i < fCount; i++) + vm_put_address_space(fItems[i].space); fCount = 0; } @@ -523,13 +565,17 @@ status_t MultiAddressSpaceLocker::Lock() { - qsort(fSpaces, fCount, sizeof(void*), &_CompareItems); + ASSERT(!fLocked); + qsort(fItems, fCount, sizeof(lock_item), &_CompareItems); + for (int32 i = 0; i < fCount; i++) { - status_t status = acquire_sem_etc(fSpaces[i]->sem, WRITE_COUNT, 0, 0); + status_t status = acquire_sem_etc(fItems[i].space->sem, + fItems[i].write_lock ? WRITE_COUNT : READ_COUNT, 0, 0); if (status < B_OK) { while (--i >= 0) { - release_sem_etc(fSpaces[i]->sem, WRITE_COUNT, 0); + release_sem_etc(fItems[i].space->sem, + fItems[i].write_lock ? WRITE_COUNT : READ_COUNT, 0); } return status; } @@ -547,13 +593,135 @@ return; for (int32 i = 0; i < fCount; i++) { - release_sem_etc(fSpaces[i]->sem, WRITE_COUNT, 0); + release_sem_etc(fItems[i].space->sem, + fItems[i].write_lock ? WRITE_COUNT : READ_COUNT, 0); } fLocked = false; } +/*! Adds all address spaces of the areas associated with the given area's cache, + locks them, and locks the cache (including a reference to it). It retries + until the situation is stable (i.e. the neither cache nor cache's areas + changed) or an error occurs. If \c checkNoCacheChange ist \c true it does + not return until all areas' \c no_cache_change flags is clear. +*/ +status_t +MultiAddressSpaceLocker::AddAreaCacheAndLock(area_id areaID, + bool writeLockThisOne, bool writeLockOthers, vm_area*& _area, + vm_cache** _cache, bool checkNoCacheChange) +{ + // remember the original state + int originalCount = fCount; + lock_item* originalItems = NULL; + if (fCount > 0) { + originalItems = new(nothrow) lock_item[fCount]; + if (originalItems == NULL) + return B_NO_MEMORY; + memcpy(originalItems, fItems, fCount * sizeof(lock_item)); + } + ArrayDeleter _(originalItems); + + // get the cache + vm_cache* cache; + vm_area* area; + status_t error; + { + AddressSpaceReadLocker locker; + error = locker.SetFromArea(areaID, area); + if (error != B_OK) + return error; + + cache = vm_area_get_locked_cache(area); + } + + while (true) { + // add all areas + vm_area* firstArea = cache->areas; + for (vm_area* current = firstArea; current; + current = current->cache_next) { + error = AddArea(current->id, + current == area ? writeLockThisOne : writeLockOthers); + if (error != B_OK) { + vm_area_put_locked_cache(cache); + return error; + } + } + + // unlock the cache and attempt to lock the address spaces + vm_area_put_locked_cache(cache); + + error = Lock(); + if (error != B_OK) + return error; + + // lock the cache again and check whether anything has changed + + // check whether the area is gone in the meantime + acquire_sem_etc(sAreaHashLock, READ_COUNT, 0, 0); + area = (vm_area *)hash_lookup(sAreaHash, &areaID); + release_sem_etc(sAreaHashLock, READ_COUNT, 0); + + if (area == NULL) { + Unlock(); + return B_BAD_VALUE; + } + + // lock the cache + vm_cache* oldCache = cache; + cache = vm_area_get_locked_cache(area); + + // If neither the area's cache has changed nor its area list we're + // done... + bool done = (cache == oldCache || firstArea == cache->areas); + + // ... unless we're supposed to check the areas' "no_cache_change" flag + bool yield = false; + if (done && checkNoCacheChange) { + for (vm_area *tempArea = cache->areas; tempArea != NULL; + tempArea = tempArea->cache_next) { + if (tempArea->no_cache_change) { + done = false; + yield = true; + break; + } + } + } + + // If everything looks dandy, return the values. + if (done) { + _area = area; + if (_cache != NULL) + *_cache = cache; + return B_OK; + } + + // Restore the original state and try again. + + // Unlock the address spaces, but keep the cache locked for the next + // iteration. + Unlock(); + + // Get an additional reference to the original address spaces. + for (int32 i = 0; i < originalCount; i++) + atomic_add(&originalItems[i].space->ref_count, 1); + + // Release all references to the current address spaces. + for (int32 i = 0; i < fCount; i++) + vm_put_address_space(fItems[i].space); + + // Copy over the original state. + fCount = originalCount; + if (originalItems != NULL) + memcpy(fItems, originalItems, fCount * sizeof(lock_item)); + + if (yield) + thread_yield(); + } +} + + // #pragma mark - @@ -1738,12 +1906,12 @@ MultiAddressSpaceLocker locker; vm_address_space *sourceAddressSpace; - status_t status = locker.AddArea(sourceID, &sourceAddressSpace); + status_t status = locker.AddArea(sourceID, false, &sourceAddressSpace); if (status != B_OK) return status; vm_address_space *targetAddressSpace; - status = locker.AddTeam(team, &targetAddressSpace); + status = locker.AddTeam(team, true, &targetAddressSpace); if (status != B_OK) return status; @@ -1900,11 +2068,19 @@ } +/*! Creates a new cache on top of given cache, moves all areas from + the old cache to the new one, and changes the protection of all affected + areas' pages to read-only. + Preconditions: + - The given cache must be locked. + - All of the cache's areas' address spaces must be read locked. + - All of the cache's areas must have a clear \c no_cache_change flags. +*/ static status_t -vm_copy_on_write_area(vm_area *area) +vm_copy_on_write_area(vm_cache* lowerCache) { vm_store *store; - vm_cache *upperCache, *lowerCache; + vm_cache *upperCache; vm_page *page; status_t status; @@ -1913,33 +2089,15 @@ // We need to separate the cache from its areas. The cache goes one level // deeper and we create a new cache inbetween. - bool noCacheChange; - do { - lowerCache = vm_area_get_locked_cache(area); - noCacheChange = false; - - for (vm_area *tempArea = lowerCache->areas; tempArea != NULL; - tempArea = tempArea->cache_next) { - if (tempArea->no_cache_change) { - noCacheChange = true; - vm_area_put_locked_cache(lowerCache); - thread_yield(); - break; - } - } - } while (noCacheChange); - // create an anonymous store object store = vm_store_create_anonymous_noswap(false, 0, 0); - if (store == NULL) { - status = B_NO_MEMORY; - goto err1; - } + if (store == NULL) + return B_NO_MEMORY; upperCache = vm_cache_create(store); if (upperCache == NULL) { - status = B_NO_MEMORY; - goto err2; + store->ops->destroy(store); + return B_NO_MEMORY; } mutex_lock(&upperCache->lock); @@ -1958,6 +2116,8 @@ for (vm_area *tempArea = upperCache->areas; tempArea != NULL; tempArea = tempArea->cache_next) { + ASSERT(!tempArea->no_cache_change); + tempArea->cache = upperCache; atomic_add(&upperCache->ref_count, 1); atomic_add(&lowerCache->ref_count, -1); @@ -1972,7 +2132,6 @@ for (vm_area *tempArea = upperCache->areas; tempArea != NULL; tempArea = tempArea->cache_next) { -// TODO: Don't we have to lock the area's address space for accessing base, size, and protection? // The area must be readable in the same way it was previously writable uint32 protection = B_KERNEL_READ_AREA; if (tempArea->protection & B_READ_AREA) @@ -1984,16 +2143,9 @@ map->ops->unlock(map); } - vm_area_put_locked_cache(lowerCache); vm_area_put_locked_cache(upperCache); return B_OK; - -err2: - store->ops->destroy(store); -err1: - vm_area_put_locked_cache(lowerCache); - return status; } @@ -2010,23 +2162,22 @@ protection |= B_KERNEL_WRITE_AREA; } + // Do the locking: target address space, all address spaces associated with + // the source cache, and the cache itself. MultiAddressSpaceLocker locker; - vm_address_space *sourceAddressSpace = NULL; vm_address_space *targetAddressSpace; - status_t status = locker.AddTeam(team, &targetAddressSpace); - if (status == B_OK) - status = locker.AddArea(sourceID, &sourceAddressSpace); - if (status == B_OK) - status = locker.Lock(); + vm_cache *cache; + vm_area* source; + status_t status = locker.AddTeam(team, true, &targetAddressSpace); + if (status == B_OK) { + status = locker.AddAreaCacheAndLock(sourceID, false, false, source, + &cache, true); + } if (status != B_OK) return status; - vm_area* source = lookup_area(sourceAddressSpace, sourceID); - if (source == NULL) - return B_BAD_VALUE; + AreaCacheLocker cacheLocker(cache); // already locked - vm_cache *cache = vm_area_get_locked_cache(source); - if (addressSpec == B_CLONE_ADDRESS) { addressSpec = B_EXACT_ADDRESS; *_address = (void *)source->base; @@ -2034,31 +2185,19 @@ // First, create a cache on top of the source area - if (!writableCopy) { - // map_backing_store() cannot know it has to acquire a ref to - // the store for REGION_NO_PRIVATE_MAP - vm_cache_acquire_ref(cache); - } - vm_area *target; status = map_backing_store(targetAddressSpace, cache, _address, source->cache_offset, source->size, addressSpec, source->wiring, - protection, writableCopy ? REGION_PRIVATE_MAP : REGION_NO_PRIVATE_MAP, - &target, name); + protection, REGION_PRIVATE_MAP, &target, name); - vm_area_put_locked_cache(cache); - - if (status < B_OK) { - if (!writableCopy) - vm_cache_release_ref(cache); + if (status < B_OK) return status; - } // If the source area is writable, we need to move it one layer up as well if ((source->protection & (B_KERNEL_WRITE_AREA | B_WRITE_AREA)) != 0) { // ToDo: do something more useful if this fails! - if (vm_copy_on_write_area(source) < B_OK) + if (vm_copy_on_write_area(cache) < B_OK) panic("vm_copy_on_write_area() failed!\n"); } @@ -2093,12 +2232,17 @@ if (!arch_vm_supports_protection(newProtection)) return B_NOT_SUPPORTED; - AddressSpaceReadLocker locker; + // lock address spaces and cache + MultiAddressSpaceLocker locker; + vm_cache *cache; vm_area* area; - status_t status = locker.SetFromArea(areaID, area); - if (status != B_OK) - return status; + status_t status = locker.AddAreaCacheAndLock(areaID, true, false, area, + &cache, true); + AreaCacheLocker cacheLocker(cache); // already locked + if (area->protection == newProtection) + return B_OK; + if (team != vm_kernel_address_space_id() && area->address_space->id != team) { // unless you're the kernel, you are only allowed to set @@ -2106,11 +2250,11 @@ return B_NOT_ALLOWED; } - vm_cache *cache = vm_area_get_locked_cache(area); + bool changePageProtection = true; if ((area->protection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0 && (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) == 0) { - // change from read/write to read-only + // writable -> !writable if (cache->source != NULL && cache->temporary) { if (count_writable_areas(cache, area) == 0) { @@ -2134,43 +2278,61 @@ } } else if ((area->protection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) == 0 && (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0) { - // change from read-only to read/write + // !writable -> writable - // ToDo: if this is a shared cache, insert new cache (we only know about other - // areas in this cache yet, though, not about child areas) - // -> use this call with care, it might currently have unwanted consequences - // because of this. It should always be safe though, if there are no other - // (child) areas referencing this area's cache (you just might not know). - if (count_writable_areas(cache, area) == 0 - && (cache->areas != area || area->cache_next)) { - // ToDo: child areas are not tested for yet - dprintf("set_area_protection(): warning, would need to insert a new cache (not yet implemented)!\n"); - status = B_NOT_ALLOWED; - } else - dprintf("set_area_protection() may not work correctly yet in this direction!\n"); + if (!list_is_empty(&cache->consumers)) { + // There are consumers -- we have to insert a new cache. Fortunately + // vm_copy_on_write_area() does everything that's needed. + changePageProtection = false; + status = vm_copy_on_write_area(cache); + } else { + // No consumers, so we don't need to insert a new one. + if (cache->source != NULL && cache->temporary) { + // the cache's commitment must contain all possible pages + status = cache->store->ops->commit(cache->store, + cache->virtual_size); + } - if (status == B_OK && cache->source != NULL && cache->temporary) { - // the cache's commitment must contain all possible pages - status = cache->store->ops->commit(cache->store, - cache->virtual_size); + if (status == B_OK && cache->source != NULL) { + // There's a source cache, hence we can't just change all pages' + // protection or we might allow writing into pages belonging to + // a lower cache. + changePageProtection = false; + + struct vm_translation_map *map + = &area->address_space->translation_map; + map->ops->lock(map); + + vm_page* page = cache->page_list; + while (page) { + addr_t address = area->base + + (page->cache_offset << PAGE_SHIFT); + map->ops->protect(map, area->base, area->base + area->size, + newProtection); + page = page->cache_next; + } + + map->ops->unlock(map); + } } } else { // we don't have anything special to do in all other cases } - if (status == B_OK && area->protection != newProtection) { + if (status == B_OK) { // remap existing pages in this cache - struct vm_translation_map *map = &locker.AddressSpace()->translation_map; + struct vm_translation_map *map = &area->address_space->translation_map; - map->ops->lock(map); - map->ops->protect(map, area->base, area->base + area->size, - newProtection); - map->ops->unlock(map); + if (changePageProtection) { + map->ops->lock(map); + map->ops->protect(map, area->base, area->base + area->size, + newProtection); + map->ops->unlock(map); + } area->protection = newProtection; } - vm_area_put_locked_cache(cache); return status; } @@ -2610,6 +2772,27 @@ } +#if DEBUG_CACHE_LIST + +static int +dump_caches(int argc, char **argv) +{ + kprintf("caches:"); + + vm_cache* cache = gDebugCacheList; + while (cache) { + kprintf(" %p", cache); + cache = cache->debug_next; + } + + kprintf("\n"); + + return 0; +} + +#endif // DEBUG_CACHE_LIST + + static const char * cache_type_to_string(int32 type) { @@ -3293,6 +3476,9 @@ add_debugger_command("area", &dump_area, "Dump info about a particular area"); add_debugger_command("cache", &dump_cache, "Dump vm_cache"); add_debugger_command("cache_tree", &dump_cache_tree, "Dump vm_cache tree"); +#if DEBUG_CACHE_LIST + add_debugger_command("caches", &dump_caches, "List vm_cache structures"); +#endif add_debugger_command("avail", &dump_available_memory, "Dump available memory"); add_debugger_command("dl", &display_mem, "dump memory long words (64-bit)"); add_debugger_command("dw", &display_mem, "dump memory words (32-bit)"); @@ -4604,73 +4790,29 @@ status_t resize_area(area_id areaID, size_t newSize) { - vm_area* first; - vm_cache* cache; - // is newSize a multiple of B_PAGE_SIZE? if (newSize & (B_PAGE_SIZE - 1)) return B_BAD_VALUE; + // lock all affected address spaces and the cache + vm_area* area; + vm_cache* cache; + MultiAddressSpaceLocker locker; - vm_address_space* addressSpace; - status_t status = locker.AddArea(areaID, &addressSpace); + status_t status = locker.AddAreaCacheAndLock(areaID, true, true, area, + &cache); if (status != B_OK) return status; + AreaCacheLocker cacheLocker(cache); // already locked - { - AddressSpaceReadLocker readLocker; - vm_area* area; - status = readLocker.SetFromArea(areaID, area); - if (status != B_OK) - return status; - - // collect areas to lock their address spaces - - vm_cache* cache = vm_area_get_locked_cache(area); - readLocker.Unlock(); - - first = cache->areas; - for (vm_area* current = first; current; current = current->cache_next) { - if (current == area) - continue; - - status = locker.AddArea(current->id); - if (status != B_OK) { - vm_area_put_locked_cache(cache); - return status; - } - } - - vm_area_put_locked_cache(cache); - } - - status = locker.Lock(); - if (status != B_OK) - return status; - - vm_area* area = lookup_area(addressSpace, areaID); - if (area == NULL) - return B_BAD_VALUE; - - cache = vm_area_get_locked_cache(area); size_t oldSize = area->size; + if (newSize == oldSize) + return B_OK; - // Check if we have locked all address spaces we need to; since - // new entries are put at the top, we just have to check if the - // first area of the cache changed - we do not care if we have - // locked more address spaces, though. - if (cache->areas != first) { - // TODO: just try again in this case! - status = B_ERROR; - goto out; - } - // Resize all areas of this area's cache - if (cache->type != CACHE_TYPE_RAM) { - status = B_NOT_ALLOWED; - goto out; - } + if (cache->type != CACHE_TYPE_RAM) + return B_NOT_ALLOWED; if (oldSize < newSize) { // We need to check if all areas of this cache can be resized @@ -4689,8 +4831,7 @@ && next->base - 1 + next->size >= current->base - 1 + newSize) continue; - status = B_ERROR; - goto out; + return B_ERROR; } } } @@ -4738,9 +4879,6 @@ } } -out: - vm_area_put_locked_cache(cache); - // ToDo: we must honour the lock restrictions of this area return status; } Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-02 22:21:26 UTC (rev 22151) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-02 22:55:23 UTC (rev 22152) @@ -38,6 +38,12 @@ static hash_table *sPageCacheTable; static spinlock sPageCacheTableLock; +#if DEBUG_CACHE_LIST +vm_cache* gDebugCacheList; +static spinlock sDebugCacheListLock; +#endif + + struct page_lookup_key { uint32 offset; vm_cache *cache; @@ -120,6 +126,21 @@ cache->page_count = 0; cache->busy = false; + +#if DEBUG_CACHE_LIST + int state = disable_interrupts(); + acquire_spinlock(&sDebugCacheListLock); + + if (gDebugCacheList) + gDebugCacheList->debug_previous = cache; + cache->debug_previous = NULL; + cache->debug_next = gDebugCacheList; + gDebugCacheList = cache; + + release_spinlock(&sDebugCacheListLock); + restore_interrupts(state); +#endif + // connect the store to its cache cache->store = store; store->cache = cache; @@ -198,6 +219,21 @@ if (!list_is_empty(&cache->consumers)) [... truncated: 21 lines follow ...] From bonefish at mail.berlios.de Mon Sep 3 02:32:33 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 02:32:33 +0200 Subject: [Haiku-commits] r22153 - haiku/trunk/src/system/kernel/arch/x86 Message-ID: <200709030032.l830WXwK023751@sheep.berlios.de> Author: bonefish Date: 2007-09-03 02:32:30 +0200 (Mon, 03 Sep 2007) New Revision: 22153 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22153&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp Log: Added "breakpoint", "watchpoint", "breakpoints", and "watchpoints" kernel debugger commands, which can set/clear/list in-kernel break- and watchpoints. Only available when KERNEL_BREAKPOINTS is defined. Modified: haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-09-02 22:55:23 UTC (rev 22152) +++ haiku/trunk/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-09-03 00:32:30 UTC (rev 22153) @@ -301,6 +301,182 @@ } +// #pragma mark - kernel debugger commands + +#if KERNEL_BREAKPOINTS + +static int +debugger_breakpoints(int argc, char** argv) +{ + struct team* kernelTeam = team_get_kernel_team(); + arch_team_debug_info& info = kernelTeam->debug_info.arch_info; + + for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { + kprintf("breakpoint[%ld] ", i); + + if (info.breakpoints[i].address != NULL) { + kprintf("%p ", info.breakpoints[i].address); + switch (info.breakpoints[i].type) { + case X86_INSTRUCTION_BREAKPOINT: + kprintf("instruction"); + break; + case X86_IO_READ_WRITE_BREAKPOINT: + kprintf("io read/write"); + break; + case X86_DATA_WRITE_BREAKPOINT: + kprintf("data write"); + break; + case X86_DATA_READ_WRITE_BREAKPOINT: + kprintf("data read/write"); + break; + } + + int length = 1; + switch (info.breakpoints[i].length) { + case X86_BREAKPOINT_LENGTH_1: + length = 1; + break; + case X86_BREAKPOINT_LENGTH_2: + length = 2; + break; + case X86_BREAKPOINT_LENGTH_4: + length = 4; + break; + } + + if (info.breakpoints[i].type != X86_INSTRUCTION_BREAKPOINT) + kprintf(" %d byte%s", length, (length > 1 ? "s" : "")); + } else + kprintf("unused"); + + kprintf("\n"); + } + + return 0; +} + + +static int +debugger_breakpoint_usage(const char* command) +{ + if (command[0] == 'b') { + kprintf("Usage: breakpoint
\n"); + kprintf(" breakpoint
clear\n"); + } else { + kprintf("Usage: watchpoint
[ rw ] [ ]\n"); + kprintf(" watchpoint
clear\n"); + } + return 0; +} + + +static int +debugger_breakpoint(int argc, char** argv) +{ + // get arguments + + if (argc < 2 || argc > 3) + return debugger_breakpoint_usage(argv[0]); + + addr_t address = strtoul(argv[1], NULL, 0); + if (address == 0) + return debugger_breakpoint_usage(argv[0]); + + bool clear = false; + if (argc == 3) { + if (strcmp(argv[2], "clear") == 0) + clear = true; + else + return debugger_breakpoint_usage(argv[0]); + } + + // set/clear breakpoint + + arch_team_debug_info& info = team_get_kernel_team()->debug_info.arch_info; + + status_t error; + + if (clear) { + error = clear_breakpoint(info, (void*)address, false); + } else { + error = set_breakpoint(info, (void*)address, X86_INSTRUCTION_BREAKPOINT, + X86_BREAKPOINT_LENGTH_1, true); + } + + if (error == B_OK) + install_breakpoints(info); + else + kprintf("Failed to install breakpoint: %s\n", strerror(error)); + + return 0; +} + + +static int +debugger_watchpoint(int argc, char** argv) +{ + // get arguments + + if (argc < 2 || argc > 4) + return debugger_breakpoint_usage(argv[0]); + + addr_t address = strtoul(argv[1], NULL, 0); + if (address == 0) + return debugger_breakpoint_usage(argv[0]); + + bool clear = false; + bool readWrite = false; + int argi = 2; + int length = 1; + if (argc >= 3) { + if (strcmp(argv[argi], "clear") == 0) { + clear = true; + argi++; + } else if (strcmp(argv[argi], "rw") == 0) { + readWrite = true; + argi++; + } + + if (!clear && argi < argc) + length = strtoul(argv[argi++], NULL, 0); + + if (length == 0 || argi < argc) + return debugger_breakpoint_usage(argv[0]); + } + + // set/clear breakpoint + + arch_team_debug_info& info = team_get_kernel_team()->debug_info.arch_info; + + status_t error; + + if (clear) { + error = clear_breakpoint(info, (void*)address, true); + } else { + uint32 type = readWrite ? B_DATA_READ_WRITE_WATCHPOINT + : B_DATA_WRITE_WATCHPOINT; + + uint32 archType, archLength; + error = check_watch_point_parameters((void*)address, type, length, + archType, archLength); + + if (error == B_OK) { + error = set_breakpoint(info, (void*)address, archType, archLength, + true); + } + } + + if (error == B_OK) + install_breakpoints(info); + else + kprintf("Failed to install breakpoint: %s\n", strerror(error)); + + return 0; +} + +#endif // KERNEL_BREAKPOINTS + + // #pragma mark - in-kernel public interface @@ -709,5 +885,17 @@ unload_driver_settings(handle); } + +#if KERNEL_BREAKPOINTS + // install debugger commands + add_debugger_command("breakpoints", &debugger_breakpoints, + "lists current break-/watchpoints"); + add_debugger_command("breakpoint", &debugger_breakpoint, + "set/clear a breakpoint"); + add_debugger_command("watchpoints", &debugger_breakpoints, + "lists current break-/watchpoints"); + add_debugger_command("watchpoint", &debugger_watchpoint, + "set/clear a watchpoint"); +#endif } From axeld at mail.berlios.de Mon Sep 3 14:42:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 3 Sep 2007 14:42:54 +0200 Subject: [Haiku-commits] r22154 - haiku/trunk/src/system/kernel/cache Message-ID: <200709031242.l83CgshU022979@sheep.berlios.de> Author: axeld Date: 2007-09-03 14:42:53 +0200 (Mon, 03 Sep 2007) New Revision: 22154 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22154&view=rev Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp Log: * file_cache_set_size() now calls file_cache_invalidate_file_map() with the correct values (resolving a TODO); however, the latter doesn't do anything with those yet. * Cleanup. Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-09-03 00:32:30 UTC (rev 22153) +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp 2007-09-03 12:42:53 UTC (rev 22154) @@ -173,7 +173,8 @@ static void add_to_iovec(iovec *vecs, int32 &index, int32 max, addr_t address, size_t size) { - if (index > 0 && (addr_t)vecs[index - 1].iov_base + vecs[index - 1].iov_len == address) { + if (index > 0 && (addr_t)vecs[index - 1].iov_base + + vecs[index - 1].iov_len == address) { // the iovec can be combined with the previous one vecs[index - 1].iov_len += size; return; @@ -228,7 +229,8 @@ off_t mapOffset = 0; while (true) { - status = vfs_get_file_map(ref->vnode, mapOffset, ~0UL, vecs, &vecCount); + status = vfs_get_file_map(ref->vnode, mapOffset, ~0UL, vecs, + &vecCount); if (status < B_OK && status != B_BUFFER_OVERFLOW) { mutex_unlock(&ref->cache->lock); return status; @@ -518,8 +520,9 @@ read_chunk_into_cache(file_cache_ref *ref, off_t offset, size_t numBytes, int32 pageOffset, addr_t buffer, size_t bufferSize) { - TRACE(("read_chunk(offset = %Ld, size = %lu, pageOffset = %ld, buffer = %#lx, bufferSize = %lu\n", - offset, size, pageOffset, buffer, bufferSize)); + TRACE(("read_chunk(offset = %Ld, size = %lu, pageOffset = %ld, buffer " + "= %#lx, bufferSize = %lu\n", offset, size, pageOffset, buffer, + bufferSize)); vm_cache *cache = ref->cache; @@ -534,7 +537,8 @@ // allocate pages for the cache and mark them busy for (size_t pos = 0; pos < numBytes; pos += B_PAGE_SIZE) { - vm_page *page = pages[pageIndex++] = vm_page_allocate_page(PAGE_STATE_FREE); + vm_page *page = pages[pageIndex++] = vm_page_allocate_page( + PAGE_STATE_FREE); if (page == NULL) panic("no more pages!"); @@ -597,8 +601,10 @@ pageOffset = 0; } - for (size_t pos = 0; pos < size; pos += B_PAGE_SIZE, base += B_PAGE_SIZE) + for (size_t pos = 0; pos < size; pos += B_PAGE_SIZE, + base += B_PAGE_SIZE) { vm_put_physical_page(base); + } } mutex_lock(&cache->lock); @@ -622,10 +628,11 @@ The cache_ref lock must be hold when calling this function. */ static status_t -read_into_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, size_t bufferSize) +read_into_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, + size_t bufferSize) { - TRACE(("read_from_cache: ref = %p, offset = %Ld, size = %lu, buffer = %p, bufferSize = %lu\n", - ref, offset, size, (void *)buffer, bufferSize)); + TRACE(("read_from_cache: ref = %p, offset = %Ld, size = %lu, buffer = %p, " + "bufferSize = %lu\n", ref, offset, size, (void *)buffer, bufferSize)); // do we have to read in anything at all? if (size == 0) @@ -641,8 +648,8 @@ if (chunkSize > (MAX_IO_VECS * B_PAGE_SIZE)) chunkSize = MAX_IO_VECS * B_PAGE_SIZE; - status_t status = read_chunk_into_cache(ref, offset, chunkSize, pageOffset, - buffer, bufferSize); + status_t status = read_chunk_into_cache(ref, offset, chunkSize, + pageOffset, buffer, bufferSize); if (status != B_OK) return status; @@ -688,14 +695,15 @@ // ToDo: if space is becoming tight, and this cache is already grown // big - shouldn't we better steal the pages directly in that case? // (a working set like approach for the file cache) - vm_page *page = pages[pageIndex++] = vm_page_allocate_page(PAGE_STATE_FREE); + vm_page *page = pages[pageIndex++] = vm_page_allocate_page( + PAGE_STATE_FREE); busyConditions[pageIndex - 1].Publish(page, "page"); vm_cache_insert_page(ref->cache, page, offset + pos); addr_t virtualAddress; - vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE, &virtualAddress, - PHYSICAL_PAGE_CAN_WAIT); + vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE, + &virtualAddress, PHYSICAL_PAGE_CAN_WAIT); add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE); // ToDo: check if the array is large enough! @@ -758,7 +766,8 @@ if (writeThrough) { // write cached pages back to the file if we were asked to do that - status_t status = pages_io(ref, offset, vecs, vecCount, &numBytes, true); + status_t status = pages_io(ref, offset, vecs, vecCount, &numBytes, + true); if (status < B_OK) { // ToDo: remove allocated pages, ...? panic("file_cache: remove allocated pages! write pages failed: %s\n", @@ -773,8 +782,10 @@ for (int32 i = 0; i < vecCount; i++) { addr_t base = (addr_t)vecs[i].iov_base; size_t size = vecs[i].iov_len; - for (size_t pos = 0; pos < size; pos += B_PAGE_SIZE, base += B_PAGE_SIZE) + for (size_t pos = 0; pos < size; pos += B_PAGE_SIZE, + base += B_PAGE_SIZE) { vm_put_physical_page(base); + } } // make the pages accessible in the cache @@ -791,16 +802,17 @@ } -/** Like read_into_cache() but writes data into the cache. To preserve data consistency, - * it might also read pages into the cache, though, if only a partial page gets written. - * The cache_ref lock must be hold when calling this function. - */ - +/*! Like read_into_cache() but writes data into the cache. To preserve data + consistency, it might also read pages into the cache, though, if only a + partial page gets written. + The cache_ref lock must be hold when calling this function. +*/ static status_t -write_to_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, size_t bufferSize) +write_to_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, + size_t bufferSize) { - TRACE(("write_to_cache: ref = %p, offset = %Ld, size = %lu, buffer = %p, bufferSize = %lu\n", - ref, offset, size, (void *)buffer, bufferSize)); + TRACE(("write_to_cache: ref = %p, offset = %Ld, size = %lu, buffer = %p, " + "bufferSize = %lu\n", ref, offset, size, (void *)buffer, bufferSize)); // make sure "offset" is page aligned - but also remember the page offset int32 pageOffset = offset & (B_PAGE_SIZE - 1); @@ -812,7 +824,8 @@ if (chunkSize > (MAX_IO_VECS * B_PAGE_SIZE)) chunkSize = MAX_IO_VECS * B_PAGE_SIZE; - status_t status = write_chunk_to_cache(ref, offset, chunkSize, pageOffset, buffer, bufferSize); + status_t status = write_chunk_to_cache(ref, offset, chunkSize, + pageOffset, buffer, bufferSize); if (status != B_OK) return status; @@ -836,8 +849,8 @@ static status_t -satisfy_cache_io(file_cache_ref *ref, off_t offset, addr_t buffer, addr_t lastBuffer, - bool doWrite) +satisfy_cache_io(file_cache_ref *ref, off_t offset, addr_t buffer, + addr_t lastBuffer, bool doWrite) { size_t requestSize = buffer - lastBuffer; @@ -849,7 +862,8 @@ static status_t -cache_io(void *_cacheRef, off_t offset, addr_t buffer, size_t *_size, bool doWrite) +cache_io(void *_cacheRef, off_t offset, addr_t buffer, size_t *_size, + bool doWrite) { if (_cacheRef == NULL) panic("cache_io() called with NULL ref!\n"); @@ -929,20 +943,25 @@ size_t bytesInPage = min_c(size_t(B_PAGE_SIZE - pageOffset), bytesLeft); addr_t virtualAddress; - TRACE(("lookup page from offset %Ld: %p, size = %lu, pageOffset = %lu\n", offset, page, bytesLeft, pageOffset)); + TRACE(("lookup page from offset %Ld: %p, size = %lu, pageOffset " + "= %lu\n", offset, page, bytesLeft, pageOffset)); + if (page != NULL) { vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE, &virtualAddress, PHYSICAL_PAGE_CAN_WAIT); // and copy the contents of the page already in memory if (doWrite) { - user_memcpy((void *)(virtualAddress + pageOffset), (void *)buffer, bytesInPage); + user_memcpy((void *)(virtualAddress + pageOffset), + (void *)buffer, bytesInPage); // make sure the page is in the modified list if (page->state != PAGE_STATE_MODIFIED) vm_page_set_state(page, PAGE_STATE_MODIFIED); - } else - user_memcpy((void *)buffer, (void *)(virtualAddress + pageOffset), bytesInPage); + } else { + user_memcpy((void *)buffer, + (void *)(virtualAddress + pageOffset), bytesInPage); + } vm_put_physical_page(virtualAddress); @@ -970,10 +989,13 @@ // fill the last remaining bytes of the request (either write or read) status_t status; - if (doWrite) - status = write_to_cache(ref, lastOffset + lastPageOffset, lastLeft, lastBuffer, lastLeft); - else - status = read_into_cache(ref, lastOffset + lastPageOffset, lastLeft, lastBuffer, lastLeft); + if (doWrite) { + status = write_to_cache(ref, lastOffset + lastPageOffset, lastLeft, + lastBuffer, lastLeft); + } else { + status = read_into_cache(ref, lastOffset + lastPageOffset, lastLeft, + lastBuffer, lastLeft); + } mutex_unlock(&cache->lock); return status; @@ -981,7 +1003,8 @@ static status_t -file_cache_control(const char *subsystem, uint32 function, void *buffer, size_t bufferSize) +file_cache_control(const char *subsystem, uint32 function, void *buffer, + size_t bufferSize) { switch (function) { case CACHE_CLEAR: @@ -1008,7 +1031,8 @@ char name[B_FILE_NAME_LENGTH]; if (!IS_USER_ADDRESS(buffer) - || user_strlcpy(name, (char *)buffer, B_FILE_NAME_LENGTH) < B_OK) + || user_strlcpy(name, (char *)buffer, + B_FILE_NAME_LENGTH) < B_OK) return B_BAD_ADDRESS; if (strncmp(name, CACHE_MODULES_NAME, strlen(CACHE_MODULES_NAME))) @@ -1136,7 +1160,8 @@ size = cache->virtual_size; } - sCacheModule->node_opened(vnode, fdType, mountID, parentID, vnodeID, name, size); + sCacheModule->node_opened(vnode, fdType, mountID, parentID, vnodeID, name, + size); } @@ -1171,11 +1196,10 @@ { // ToDo: get cache module out of driver settings - if (get_module("file_cache/launch_speedup/v1", (module_info **)&sCacheModule) == B_OK) { + if (get_module("file_cache/launch_speedup/v1", + (module_info **)&sCacheModule) == B_OK) { dprintf("** opened launch speedup: %Ld\n", system_time()); - } else - dprintf("** could not open launch speedup!\n"); - + } return B_OK; } @@ -1194,7 +1218,8 @@ extern "C" void * file_cache_create(dev_t mountID, ino_t vnodeID, off_t size, int fd) { - TRACE(("file_cache_create(mountID = %ld, vnodeID = %Ld, size = %Ld, fd = %d)\n", mountID, vnodeID, size, fd)); + TRACE(("file_cache_create(mountID = %ld, vnodeID = %Ld, size = %Ld, " + "fd = %d)\n", mountID, vnodeID, size, fd)); file_cache_ref *ref = new file_cache_ref; if (ref == NULL) @@ -1263,7 +1288,7 @@ extern "C" status_t -file_cache_set_size(void *_cacheRef, off_t size) +file_cache_set_size(void *_cacheRef, off_t newSize) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; @@ -1272,13 +1297,21 @@ if (ref == NULL) return B_OK; - file_cache_invalidate_file_map(_cacheRef, 0, size); - // ToDo: make this better (we would only need to extend or shrink the map) + mutex_lock(&ref->cache->lock); - mutex_lock(&ref->cache->lock); - status_t status = vm_cache_resize(ref->cache, size); + off_t offset = ref->cache->virtual_size; + off_t size = newSize; + if (offset > newSize) { + size = offset - newSize; + offset = newSize; + } else + size = newSize - offset; + + status_t status = vm_cache_resize(ref->cache, newSize); mutex_unlock(&ref->cache->lock); + file_cache_invalidate_file_map(_cacheRef, offset, size); + return status; } @@ -1295,7 +1328,8 @@ extern "C" status_t -file_cache_read_pages(void *_cacheRef, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) +file_cache_read_pages(void *_cacheRef, off_t offset, const iovec *vecs, + size_t count, size_t *_numBytes) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; @@ -1304,14 +1338,17 @@ extern "C" status_t -file_cache_write_pages(void *_cacheRef, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) +file_cache_write_pages(void *_cacheRef, off_t offset, const iovec *vecs, + size_t count, size_t *_numBytes) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; status_t status = pages_io(ref, offset, vecs, count, _numBytes, true); - TRACE(("file_cache_write_pages(ref = %p, offset = %Ld, vecs = %p, count = %lu, bytes = %lu) = %ld\n", - ref, offset, vecs, count, *_numBytes, status)); + TRACE(("file_cache_write_pages(ref = %p, offset = %Ld, vecs = %p, " + "count = %lu, bytes = %lu) = %ld\n", ref, offset, vecs, count, + *_numBytes, status)); + return status; } @@ -1329,14 +1366,17 @@ extern "C" status_t -file_cache_write(void *_cacheRef, off_t offset, const void *buffer, size_t *_size) +file_cache_write(void *_cacheRef, off_t offset, const void *buffer, + size_t *_size) { file_cache_ref *ref = (file_cache_ref *)_cacheRef; - status_t status = cache_io(ref, offset, (addr_t)const_cast(buffer), _size, true); - TRACE(("file_cache_write(ref = %p, offset = %Ld, buffer = %p, size = %lu) = %ld\n", - ref, offset, buffer, *_size, status)); + status_t status = cache_io(ref, offset, (addr_t)const_cast(buffer), + _size, true); + TRACE(("file_cache_write(ref = %p, offset = %Ld, buffer = %p, size = %lu)" + " = %ld\n", ref, offset, buffer, *_size, status)); + return status; } @@ -1348,7 +1388,9 @@ // ToDo: honour offset/size parameters - TRACE(("file_cache_invalidate_file_map(offset = %Ld, size = %Ld)\n", offset, size)); + TRACE(("file_cache_invalidate_file_map(offset = %Ld, size = %Ld)\n", offset, + size)); + mutex_lock(&ref->cache->lock); ref->map.Free(); mutex_unlock(&ref->cache->lock); From axeld at mail.berlios.de Mon Sep 3 17:35:10 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 3 Sep 2007 17:35:10 +0200 Subject: [Haiku-commits] r22155 - haiku/trunk/src/system/kernel/vm Message-ID: <200709031535.l83FZA99000115@sheep.berlios.de> Author: axeld Date: 2007-09-03 17:35:09 +0200 (Mon, 03 Sep 2007) New Revision: 22155 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22155&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: * Renamed page queues according to our style guide. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-09-03 12:42:53 UTC (rev 22154) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-09-03 15:35:09 UTC (rev 22155) @@ -39,15 +39,15 @@ typedef struct page_queue { vm_page *head; vm_page *tail; - int count; + uint32 count; } page_queue; extern bool trimming_cycle; -static page_queue page_free_queue; -static page_queue page_clear_queue; -static page_queue page_modified_queue; -static page_queue page_active_queue; +static page_queue sFreePageQueue; +static page_queue sClearPageQueue; +static page_queue sModifiedPageQueue; +static page_queue sActivePageQueue; static vm_page *sPages; static addr_t sPhysicalPageOffset; @@ -112,7 +112,7 @@ page->queue = q; #endif - if (q == &page_modified_queue) { + if (q == &sModifiedPageQueue) { if (q->count == 1) release_sem_etc(modified_pages_available, 1, B_DO_NOT_RESCHEDULE); } @@ -177,10 +177,10 @@ const char* name; page_queue* queue; } pageQueueInfos[] = { - { "free", &page_free_queue }, - { "clear", &page_clear_queue }, - { "modified", &page_modified_queue }, - { "active", &page_active_queue }, + { "free", &sFreePageQueue }, + { "clear", &sClearPageQueue }, + { "modified", &sModifiedPageQueue }, + { "active", &sActivePageQueue }, { NULL, NULL } }; @@ -301,26 +301,29 @@ if (strlen(argv[1]) >= 2 && argv[1][0] == '0' && argv[1][1] == 'x') queue = (struct page_queue *)strtoul(argv[1], NULL, 16); if (!strcmp(argv[1], "free")) - queue = &page_free_queue; + queue = &sFreePageQueue; else if (!strcmp(argv[1], "clear")) - queue = &page_clear_queue; + queue = &sClearPageQueue; else if (!strcmp(argv[1], "modified")) - queue = &page_modified_queue; + queue = &sModifiedPageQueue; else if (!strcmp(argv[1], "active")) - queue = &page_active_queue; + queue = &sActivePageQueue; else { kprintf("page_queue: unknown queue \"%s\".\n", argv[1]); return 0; } - kprintf("queue = %p, queue->head = %p, queue->tail = %p, queue->count = %d\n", queue, queue->head, queue->tail, queue->count); + kprintf("queue = %p, queue->head = %p, queue->tail = %p, queue->count = %ld\n", + queue, queue->head, queue->tail, queue->count); if (argc == 3) { struct vm_page *page = queue->head; int i; for (i = 0; page; i++, page = page->queue_next) { - kprintf("%5d. queue_next = %p, queue_prev = %p, type = %d, state = %d\n", i, page->queue_next, page->queue_prev, page->type, page->state); + kprintf("%5d. queue_next = %p, queue_prev = %p, type = %d, " + "state = %d\n", i, page->queue_next, page->queue_prev, + page->type, page->state); } } return 0; @@ -349,10 +352,10 @@ kprintf("wired: %lu\nmodified: %lu\nfree: %lu\nclear: %lu\n", counter[PAGE_STATE_WIRED], counter[PAGE_STATE_MODIFIED], counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]); - kprintf("\nfree_queue: %p, count = %d\n", &page_free_queue, page_free_queue.count); - kprintf("clear_queue: %p, count = %d\n", &page_clear_queue, page_clear_queue.count); - kprintf("modified_queue: %p, count = %d\n", &page_modified_queue, page_modified_queue.count); - kprintf("active_queue: %p, count = %d\n", &page_active_queue, page_active_queue.count); + kprintf("\nfree_queue: %p, count = %ld\n", &sFreePageQueue, sFreePageQueue.count); + kprintf("clear_queue: %p, count = %ld\n", &sClearPageQueue, sClearPageQueue.count); + kprintf("modified_queue: %p, count = %ld\n", &sModifiedPageQueue, sModifiedPageQueue.count); + kprintf("active_queue: %p, count = %ld\n", &sActivePageQueue, sActivePageQueue.count); return 0; } @@ -420,16 +423,16 @@ case PAGE_STATE_INACTIVE: case PAGE_STATE_WIRED: case PAGE_STATE_UNUSED: - from_q = &page_active_queue; + from_q = &sActivePageQueue; break; case PAGE_STATE_MODIFIED: - from_q = &page_modified_queue; + from_q = &sModifiedPageQueue; break; case PAGE_STATE_FREE: - from_q = &page_free_queue; + from_q = &sFreePageQueue; break; case PAGE_STATE_CLEAR: - from_q = &page_clear_queue; + from_q = &sClearPageQueue; break; default: panic("vm_page_set_state: vm_page %p in invalid state %d\n", page, page->state); @@ -450,16 +453,16 @@ case PAGE_STATE_INACTIVE: case PAGE_STATE_WIRED: case PAGE_STATE_UNUSED: - to_q = &page_active_queue; + to_q = &sActivePageQueue; break; case PAGE_STATE_MODIFIED: - to_q = &page_modified_queue; + to_q = &sModifiedPageQueue; break; case PAGE_STATE_FREE: - to_q = &page_free_queue; + to_q = &sFreePageQueue; break; case PAGE_STATE_CLEAR: - to_q = &page_clear_queue; + to_q = &sClearPageQueue; break; default: panic("vm_page_set_state: invalid target state %d\n", pageState); @@ -502,7 +505,7 @@ for (;;) { snooze(100000); // 100ms - if (page_free_queue.count > 0) { + if (sFreePageQueue.count > 0) { cpu_status state; vm_page *page[SCRUB_SIZE]; int32 i, scrubCount; @@ -513,7 +516,7 @@ acquire_spinlock(&sPageLock); for (i = 0; i < SCRUB_SIZE; i++) { - page[i] = dequeue_page(&page_free_queue); + page[i] = dequeue_page(&sFreePageQueue); if (page[i] == NULL) break; page[i]->state = PAGE_STATE_BUSY; @@ -537,7 +540,7 @@ for (i = 0; i < scrubCount; i++) { page[i]->state = PAGE_STATE_CLEAR; - enqueue_page(&page_clear_queue, page[i]); + enqueue_page(&sClearPageQueue, page[i]); } release_spinlock(&sPageLock); @@ -567,7 +570,7 @@ state = disable_interrupts(); acquire_spinlock(&sPageLock); - page = dequeue_page(&page_modified_queue); + page = dequeue_page(&sModifiedPageQueue); page->state = PAGE_STATE_BUSY; vm_cache_acquire_ref(page->cache_ref, true); release_spinlock(&sPageLock); @@ -580,7 +583,7 @@ // that back anonymous stores state = disable_interrupts(); acquire_spinlock(&sPageLock); - enqueue_page(&page_modified_queue, page); + enqueue_page(&sModifiedPageQueue, page); page->state = PAGE_STATE_MODIFIED; release_spinlock(&sPageLock); restore_interrupts(state); @@ -618,7 +621,7 @@ } else { page->state = PAGE_STATE_INACTIVE; } - enqueue_page(&page_active_queue, page); + enqueue_page(&sActivePageQueue, page); release_spinlock(&sPageLock); restore_interrupts(state); @@ -683,7 +686,7 @@ acquire_spinlock(&sPageLock); if (page->state == PAGE_STATE_MODIFIED) { - remove_page_from_queue(&page_modified_queue, page); + remove_page_from_queue(&sModifiedPageQueue, page); page->state = PAGE_STATE_BUSY; busyCondition.Publish(page, "page"); gotPage = true; @@ -754,7 +757,7 @@ busyCondition.Unpublish(); - enqueue_page(&page_active_queue, page); + enqueue_page(&sActivePageQueue, page); release_spinlock(&sPageLock); restore_interrupts(state); @@ -767,7 +770,7 @@ acquire_spinlock(&sPageLock); page->state = PAGE_STATE_MODIFIED; - enqueue_page(&page_modified_queue, page); + enqueue_page(&sModifiedPageQueue, page); busyCondition.Unpublish(); @@ -812,18 +815,18 @@ sPageLock = 0; // initialize queues - page_free_queue.head = NULL; - page_free_queue.tail = NULL; - page_free_queue.count = 0; - page_clear_queue.head = NULL; - page_clear_queue.tail = NULL; - page_clear_queue.count = 0; - page_modified_queue.head = NULL; - page_modified_queue.tail = NULL; - page_modified_queue.count = 0; - page_active_queue.head = NULL; - page_active_queue.tail = NULL; - page_active_queue.count = 0; + sFreePageQueue.head = NULL; + sFreePageQueue.tail = NULL; + sFreePageQueue.count = 0; + sClearPageQueue.head = NULL; + sClearPageQueue.tail = NULL; + sClearPageQueue.count = 0; + sModifiedPageQueue.head = NULL; + sModifiedPageQueue.tail = NULL; + sModifiedPageQueue.count = 0; + sActivePageQueue.head = NULL; + sActivePageQueue.tail = NULL; + sActivePageQueue.count = 0; // map in the new free page table sPages = (vm_page *)vm_allocate_early(args, sNumPages * sizeof(vm_page), @@ -848,7 +851,7 @@ sPages[i].debug_flags = 0; sPages[i].collided_page = NULL; #endif // DEBUG_PAGE_CACHE_TRANSITIONS - enqueue_page(&page_free_queue, &sPages[i]); + enqueue_page(&sFreePageQueue, &sPages[i]); } TRACE(("initialized table\n")); @@ -977,10 +980,10 @@ switch (p->state) { case PAGE_STATE_FREE: - remove_page_from_queue(&page_free_queue, p); + remove_page_from_queue(&sFreePageQueue, p); break; case PAGE_STATE_CLEAR: - remove_page_from_queue(&page_clear_queue, p); + remove_page_from_queue(&sClearPageQueue, p); break; case PAGE_STATE_UNUSED: break; @@ -995,7 +998,7 @@ p->state = PAGE_STATE_BUSY; if (old_page_state != PAGE_STATE_UNUSED) - enqueue_page(&page_active_queue, p); + enqueue_page(&sActivePageQueue, p); out: release_spinlock(&sPageLock); @@ -1020,12 +1023,12 @@ switch (page_state) { case PAGE_STATE_FREE: - q = &page_free_queue; - q_other = &page_clear_queue; + q = &sFreePageQueue; + q_other = &sClearPageQueue; break; case PAGE_STATE_CLEAR: - q = &page_clear_queue; - q_other = &page_free_queue; + q = &sClearPageQueue; + q_other = &sFreePageQueue; break; default: return NULL; // invalid @@ -1060,7 +1063,7 @@ old_page_state = p->state; p->state = PAGE_STATE_BUSY; - enqueue_page(&page_active_queue, p); + enqueue_page(&sActivePageQueue, p); release_spinlock(&sPageLock); restore_interrupts(state); @@ -1191,6 +1194,6 @@ size_t vm_page_num_free_pages(void) { - return page_free_queue.count + page_clear_queue.count; + return sFreePageQueue.count + sClearPageQueue.count; } From axeld at mail.berlios.de Mon Sep 3 17:41:15 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 3 Sep 2007 17:41:15 +0200 Subject: [Haiku-commits] r22156 - in haiku/trunk: headers/private/kernel src/system/kernel/vm Message-ID: <200709031541.l83FfFAt000456@sheep.berlios.de> Author: axeld Date: 2007-09-03 17:41:14 +0200 (Mon, 03 Sep 2007) New Revision: 22156 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22156&view=rev Added: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp Removed: haiku/trunk/src/system/kernel/vm/vm_daemons.c Modified: haiku/trunk/headers/private/kernel/vm.h haiku/trunk/headers/private/kernel/vm_priv.h haiku/trunk/src/system/kernel/vm/Jamfile haiku/trunk/src/system/kernel/vm/vm.cpp haiku/trunk/src/system/kernel/vm/vm_address_space.c haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: * sMappingLock is now a mutex instead of a spinlock. * The vm_translation_map is now correctly held in all of the vm_ mapping functions. * Removed the old vm_daemons.c file - there is now a new vm_daemons.cpp which contains the beginnings of our new page daemon. So far, it's pretty static and not much tested. What it currently does is to rescan all pages in the system with a two-handed clock algorithm and push pages into the modified and inactive lists. * These inactive pages aren't really stolen yet, even though their mappings are removed (ie. their next access will cause a page fault). This should slow down Haiku a bit more, great, huh? :-) * The page daemon currently only runs on low memory situations, though. Modified: haiku/trunk/headers/private/kernel/vm.h =================================================================== --- haiku/trunk/headers/private/kernel/vm.h 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/headers/private/kernel/vm.h 2007-09-03 15:41:14 UTC (rev 22156) @@ -69,7 +69,7 @@ vm_area *vm_area_lookup(vm_address_space *addressSpace, addr_t address); status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type); status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr); -int32 vm_test_map_activation(vm_page *page); +int32 vm_test_map_activation(vm_page *page, bool *_modified); void vm_clear_map_activation(vm_page *page); void vm_remove_all_page_mappings(vm_page *page); status_t vm_unmap_pages(vm_area *area, addr_t base, size_t length); Modified: haiku/trunk/headers/private/kernel/vm_priv.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_priv.h 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/headers/private/kernel/vm_priv.h 2007-09-03 15:41:14 UTC (rev 22156) @@ -44,15 +44,12 @@ #endif // Should only be used by vm internals -status_t vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite, bool isUser, addr_t *newip); +status_t vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite, + bool isUser, addr_t *newip); void vm_unreserve_memory(size_t bytes); status_t vm_try_reserve_memory(size_t bytes); status_t vm_daemon_init(void); -// used by the page daemon to walk the list of address spaces -void vm_address_space_walk_start(struct hash_iterator *i); -vm_address_space *vm_address_space_walk_next(struct hash_iterator *i); - #ifdef __cplusplus } #endif Modified: haiku/trunk/src/system/kernel/vm/Jamfile =================================================================== --- haiku/trunk/src/system/kernel/vm/Jamfile 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/src/system/kernel/vm/Jamfile 2007-09-03 15:41:14 UTC (rev 22156) @@ -6,7 +6,7 @@ vm.cpp vm_address_space.c vm_cache.cpp - vm_daemons.c + vm_daemons.cpp vm_low_memory.cpp vm_page.cpp vm_store_anonymous_noswap.c Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-09-03 15:41:14 UTC (rev 22156) @@ -191,7 +191,7 @@ static area_id sNextAreaID; static hash_table *sAreaHash; static sem_id sAreaHashLock; -static spinlock sMappingLock; +static mutex sMappingLock; static mutex sAreaCacheLock; static off_t sAvailableMemory; @@ -2354,13 +2354,12 @@ int32 -vm_test_map_activation(vm_page *page) +vm_test_map_activation(vm_page *page, bool *_modified) { int32 activation = 0; + bool modified = false; - // TODO: this can't work... (we need to lock the map, so this has to be a mutex) - cpu_status state = disable_interrupts(); - acquire_spinlock(&sMappingLock); + MutexLocker locker(sMappingLock); vm_page_mappings::Iterator iterator = page->mappings.GetIterator(); vm_page_mapping *mapping; @@ -2370,17 +2369,19 @@ addr_t physicalAddress; uint32 flags; -// map->ops->lock(map); + map->ops->lock(map); addr_t address = area->base + (page->cache_offset << PAGE_SHIFT); map->ops->query_interrupt(map, address, &physicalAddress, &flags); -// map->ops->unlock(map); + map->ops->unlock(map); if (flags & PAGE_ACCESSED) activation++; + if (flags & PAGE_MODIFIED) + modified = true; } - release_spinlock(&sMappingLock); - restore_interrupts(state); + if (_modified != NULL) + *_modified = modified; return activation; } @@ -2389,9 +2390,7 @@ void vm_clear_map_activation(vm_page *page) { - // TODO: this can't work... (we need to lock the map, so this has to be a mutex) - cpu_status state = disable_interrupts(); - acquire_spinlock(&sMappingLock); + MutexLocker locker(sMappingLock); vm_page_mappings::Iterator iterator = page->mappings.GetIterator(); vm_page_mapping *mapping; @@ -2399,23 +2398,18 @@ vm_area *area = mapping->area; vm_translation_map *map = &area->address_space->translation_map; -// map->ops->lock(map); + map->ops->lock(map); addr_t address = area->base + (page->cache_offset << PAGE_SHIFT); map->ops->clear_flags(map, address, PAGE_ACCESSED); -// map->ops->unlock(map); + map->ops->unlock(map); } - - release_spinlock(&sMappingLock); - restore_interrupts(state); } void vm_remove_all_page_mappings(vm_page *page) { - // TODO: this can't work... (we need to lock the map, so this has to be a mutex) - cpu_status state = disable_interrupts(); - acquire_spinlock(&sMappingLock); + MutexLocker locker(sMappingLock); vm_page_mappings queue; queue.MoveFrom(&page->mappings); @@ -2426,16 +2420,15 @@ vm_area *area = mapping->area; vm_translation_map *map = &area->address_space->translation_map; -// map->ops->lock(map); + map->ops->lock(map); addr_t base = area->base + (page->cache_offset << PAGE_SHIFT); map->ops->unmap(map, base, base + (B_PAGE_SIZE - 1)); -// map->ops->unlock(map); + map->ops->unlock(map); area->mappings.Remove(mapping); } - release_spinlock(&sMappingLock); - restore_interrupts(state); + locker.Unlock(); // free now unused mappings @@ -2476,6 +2469,7 @@ } map->ops->unmap(map, base, end); + map->ops->unlock(map); if (area->wiring == B_NO_LOCK) { uint32 startOffset = (area->cache_offset + base - area->base) @@ -2484,15 +2478,16 @@ vm_page_mapping *mapping; vm_area_mappings queue; - cpu_status state = disable_interrupts(); - acquire_spinlock(&sMappingLock); + mutex_lock(&sMappingLock); + map->ops->lock(map); vm_area_mappings::Iterator iterator = area->mappings.GetIterator(); while (iterator.HasNext()) { mapping = iterator.Next(); vm_page *page = mapping->page; - if (page->cache_offset < startOffset || page->cache_offset >= endOffset) + if (page->cache_offset < startOffset + || page->cache_offset >= endOffset) continue; mapping->page->mappings.Remove(mapping); @@ -2501,15 +2496,14 @@ queue.Add(mapping); } - release_spinlock(&sMappingLock); - restore_interrupts(state); + map->ops->unlock(map); + mutex_unlock(&sMappingLock); while ((mapping = queue.RemoveHead()) != NULL) { free(mapping); } } - map->ops->unlock(map); return B_OK; } @@ -2532,24 +2526,19 @@ map->ops->lock(map); map->ops->map(map, address, page->physical_page_number * B_PAGE_SIZE, protection); + map->ops->unlock(map); if (area->wiring != B_NO_LOCK) { page->wired_count++; // TODO: needs to be atomic on all platforms! } else { // insert mapping into lists - cpu_status state = disable_interrupts(); - acquire_spinlock(&sMappingLock); + MutexLocker locker(sMappingLock); page->mappings.Add(mapping); area->mappings.Add(mapping); - - release_spinlock(&sMappingLock); - restore_interrupts(state); } - map->ops->unlock(map); - if (page->state != PAGE_STATE_MODIFIED) vm_page_set_state(page, PAGE_STATE_ACTIVE); @@ -3519,6 +3508,7 @@ sAreaHashLock = create_sem(WRITE_COUNT, "area hash"); mutex_init(&sAreaCacheLock, "area->cache"); + mutex_init(&sMappingLock, "page mappings"); slab_init_post_sem(); Modified: haiku/trunk/src/system/kernel/vm/vm_address_space.c =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_address_space.c 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/src/system/kernel/vm/vm_address_space.c 2007-09-03 15:41:14 UTC (rev 22156) @@ -313,27 +313,6 @@ } -void -vm_address_space_walk_start(struct hash_iterator *iterator) -{ - hash_open(sAddressSpaceTable, iterator); -} - - -vm_address_space * -vm_address_space_walk_next(struct hash_iterator *iterator) -{ - vm_address_space *aspace; - - acquire_sem_etc(sAddressSpaceHashSem, READ_COUNT, 0, 0); - aspace = hash_next(sAddressSpaceTable, iterator); - if (aspace) - atomic_add(&aspace->ref_count, 1); - release_sem_etc(sAddressSpaceHashSem, READ_COUNT, 0); - return aspace; -} - - status_t vm_address_space_init(void) { Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-03 15:41:14 UTC (rev 22156) @@ -327,6 +327,7 @@ cache->page_count++; page->cache = cache; + page->usage_count = 2; state = disable_interrupts(); acquire_spinlock(&sPageCacheTableLock); Deleted: haiku/trunk/src/system/kernel/vm/vm_daemons.c Added: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-09-03 15:35:09 UTC (rev 22155) +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-09-03 15:41:14 UTC (rev 22156) @@ -0,0 +1,233 @@ +/* + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + +#include +#include +#include +#include +#include + + +static sem_id sPageDaemonSem; +static uint32 sScanPagesCount; +static uint32 sNumPages; +static bigtime_t sScanWaitInterval; + + +class PageCacheLocker { +public: + PageCacheLocker(vm_page* page); + ~PageCacheLocker(); + + bool IsLocked() { return fPage != NULL; } + + bool Lock(vm_page* page); + void Unlock(); + +private: + bool _IgnorePage(vm_page* page); + + vm_page* fPage; +}; + + +PageCacheLocker::PageCacheLocker(vm_page* page) + : + fPage(NULL) +{ + Lock(page); +} + + +PageCacheLocker::~PageCacheLocker() +{ + Unlock(); +} + + +bool +PageCacheLocker::_IgnorePage(vm_page* page) +{ + if (page->state == PAGE_STATE_WIRED || page->state == PAGE_STATE_BUSY + || page->state == PAGE_STATE_FREE || page->state == PAGE_STATE_CLEAR + || page->state == PAGE_STATE_UNUSED || page->cache == NULL) + return true; + + return false; +} + + +bool +PageCacheLocker::Lock(vm_page* page) +{ + if (_IgnorePage(page)) + return false; + + vm_cache* cache = page->cache; + + // Grab a reference to this cache - the page does not own a reference + // to its cache, so we can't just acquire it the easy way + while (true) { + int32 count = cache->ref_count; + if (count == 0) { + cache = NULL; + break; + } + + if (atomic_test_and_set(&cache->ref_count, count + 1, count) == count) + break; + } + + if (cache == NULL) + return false; + + mutex_lock(&cache->lock); + + if (cache != page->cache || _IgnorePage(page)) { + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); + return false; + } + + fPage = page; + return true; +} + + +void +PageCacheLocker::Unlock() +{ + if (fPage == NULL) + return; + + vm_cache* cache = fPage->cache; + mutex_unlock(&cache->lock); + vm_cache_release_ref(cache); + + fPage = NULL; +} + + +// #pragma mark - + + +static void +clear_page_activation(int32 index) +{ + vm_page *page = vm_page_at_index(index); + PageCacheLocker locker(page); + if (!locker.IsLocked()) + return; + + if (page->state == PAGE_STATE_ACTIVE) + vm_clear_map_activation(page); +} + + +static bool +check_page_activation(int32 index) +{ + vm_page *page = vm_page_at_index(index); + PageCacheLocker locker(page); + if (!locker.IsLocked()) + return false; + + bool modified; + int32 activation = vm_test_map_activation(page, &modified); + if (modified && page->state != PAGE_STATE_MODIFIED) { + //dprintf("page %p -> move to modified\n", page); + vm_page_set_state(page, PAGE_STATE_MODIFIED); + } + + if (activation > 0) { + // page is still in active use + if (page->usage_count < 0) { + if (page->state != PAGE_STATE_MODIFIED) + vm_page_set_state(page, PAGE_STATE_ACTIVE); + page->usage_count = 1; + //dprintf("page %p -> move to active\n", page); + } else if (page->usage_count < 127) + page->usage_count++; + + return false; + } + + if (page->usage_count > -128) + page->usage_count--; + + if (page->usage_count < 0) { + vm_remove_all_page_mappings(page); + if (page->state == PAGE_STATE_MODIFIED) { + // TODO: schedule to write back! + } else + vm_page_set_state(page, PAGE_STATE_INACTIVE); + //dprintf("page %p -> move to inactive\n", page); + } + + return true; +} + + +static status_t +page_daemon(void *unused) +{ + uint32 clearPage = 0; + uint32 checkPage = sNumPages / 2; + + while (true) { + acquire_sem_etc(sPageDaemonSem, 1, B_RELATIVE_TIMEOUT, + sScanWaitInterval); + + if (vm_low_memory_state() < B_LOW_MEMORY_NOTE) { + // don't do anything if we have enough free memory left + continue; + } + + uint32 leftToFree = 32; + // TODO: make this depending on the low memory state + + for (uint32 i = 0; i < sScanPagesCount && leftToFree > 0; i++) { + if (clearPage == 0) + dprintf("clear through\n"); + if (checkPage == 0) + dprintf("check through\n"); + clear_page_activation(clearPage); + + if (check_page_activation(checkPage)) + leftToFree--; + + if (++clearPage == sNumPages) + clearPage = 0; + if (++checkPage == sNumPages) + checkPage = 0; + } + } + return B_OK; +} + + +status_t +vm_daemon_init() +{ + sPageDaemonSem = create_sem(0, "page daemon"); + + sNumPages = vm_page_num_pages(); + // TODO: compute those depending on sNumPages and memory pressure! + sScanPagesCount = 512; + sScanWaitInterval = 1000000; + + // create a kernel thread to select pages for pageout + thread_id thread = spawn_kernel_thread(&page_daemon, "page daemon", + B_LOW_PRIORITY, NULL); + send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE); + + return B_OK; +} + From korli at mail.berlios.de Mon Sep 3 20:44:57 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 3 Sep 2007 20:44:57 +0200 Subject: [Haiku-commits] r22157 - haiku/trunk/build/jam Message-ID: <200709031844.l83Iivj9032419@sheep.berlios.de> Author: korli Date: 2007-09-03 20:44:57 +0200 (Mon, 03 Sep 2007) New Revision: 22157 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22157&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added fwcontrol, fw_raw and firewire. This could break someone's build :) Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-09-03 15:41:14 UTC (rev 22156) +++ haiku/trunk/build/jam/HaikuImage 2007-09-03 18:44:57 UTC (rev 22157) @@ -26,11 +26,11 @@ chgrp chmod chop chown cksum clear clockconfig cmp comm compress cp copyattr $(X86_ONLY)CortexAddOnHost csplit ctags cut date dc dd desklink df diff diff3 dircolors dirname - driveinfo dstcheck du dump_cis dump_cisreg echo eject env error expand - expr factor false fdinfo ffm find finddir fmt fold fortune frcode ftp funzip gawk - $(X86_ONLY)gdb grep groups gzip gzexe hd head hey hostname id ident ideinfo - idestatus ifconfig install installsound iroster isvolume join keymap - kill less lessecho lesskey link listarea listattr listdev listimage + driveinfo dstcheck du dump_cis dump_cisreg echo eject env error expand expr + expr factor false fdinfo ffm find finddir fmt fold fortune frcode ftp funzip fwcontrol + gawk $(X86_ONLY)gdb grep groups gzip gzexe hd head hey hostname id ident + ideinfo idestatus ifconfig install installsound iroster isvolume join + keymap kill less lessecho lesskey link listarea listattr listdev listimage listport listres listsem ln locate logger login logname ls lsindex m4 make makebootable md5sum merge mimeset mkdos mkdir mkindex modifiers mount mount_nfs mountvolume mv nc netstat nl od open pack_cis paste patch pathchk pc @@ -120,7 +120,7 @@ ; #BEOS_ADD_ONS_DRIVERS_ACPI = $(X86_ONLY)acpi_button ; BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi - config_manager $(X86_ONLY)agp usb + config_manager $(X86_ONLY)agp usb firewire ; BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda dos googlefs iso9660 nfs ; @@ -154,7 +154,7 @@ random tty zero ; AddDriversToHaikuImage audio hmulti : $(BEOS_ADD_ONS_DRIVERS_AUDIO) ; AddDriversToHaikuImage midi : $(BEOS_ADD_ONS_DRIVERS_MIDI) ; -AddDriversToHaikuImage bus : usb_raw ; +AddDriversToHaikuImage bus : fw_raw usb_raw ; AddDriversToHaikuImage disk scsi : scsi_cd scsi_dsk ; AddDriversToHaikuImage disk virtual : nbd ; AddDriversToHaikuImage dvb : cx23882 ; From korli at mail.berlios.de Mon Sep 3 21:52:44 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 3 Sep 2007 21:52:44 +0200 Subject: [Haiku-commits] r22158 - haiku/trunk/src/add-ons/kernel/bus_managers/firewire Message-ID: <200709031952.l83JqiTi004116@sheep.berlios.de> Author: korli Date: 2007-09-03 21:52:44 +0200 (Mon, 03 Sep 2007) New Revision: 22158 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22158&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h Log: missing le32toh() Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h 2007-09-03 18:44:57 UTC (rev 22157) +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h 2007-09-03 19:52:44 UTC (rev 22158) @@ -95,6 +95,7 @@ #if BYTE_ORDER == BIG_ENDIAN #ifdef __HAIKU__ #define htole32(x) __swap_int32(x) +#define letoh32(x) __swap_int32(x) #endif #define FWOHCI_DMA_WRITE(x, y) ((x) = htole32(y)) #define FWOHCI_DMA_READ(x) le32toh(x) From bonefish at mail.berlios.de Mon Sep 3 22:35:28 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 22:35:28 +0200 Subject: [Haiku-commits] r22159 - haiku/trunk/src/system/kernel Message-ID: <200709032035.l83KZSj9006889@sheep.berlios.de> Author: bonefish Date: 2007-09-03 22:35:27 +0200 (Mon, 03 Sep 2007) New Revision: 22159 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22159&view=rev Modified: haiku/trunk/src/system/kernel/signal.cpp Log: Updated TODO. Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2007-09-03 19:52:44 UTC (rev 22158) +++ haiku/trunk/src/system/kernel/signal.cpp 2007-09-03 20:35:27 UTC (rev 22159) @@ -113,10 +113,15 @@ debugSignal = !(~atomic_get(&thread->team->debug_info.flags) & (B_TEAM_DEBUG_SIGNALS | B_TEAM_DEBUG_DEBUGGER_INSTALLED)); - // ToDo: since sigaction_etc() could clobber the fields at any time, + // TODO: since sigaction_etc() could clobber the fields at any time, // we should actually copy the relevant fields atomically before // accessing them (only the debugger is calling sigaction_etc() // right now). + // Update: sigaction_etc() is only used by the userland debugger + // support. We can just as well restrict getting/setting signal + // handlers to work only when the respective thread is stopped. + // Then sigaction() could be used instead and we could get rid of + // sigaction_etc(). handler = &thread->sig_action[i]; TRACE(("Thread 0x%lx received signal %s\n", thread->id, sigstr[signal])); From korli at mail.berlios.de Mon Sep 3 22:59:03 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 3 Sep 2007 22:59:03 +0200 Subject: [Haiku-commits] r22160 - haiku/trunk/src/add-ons/kernel/bus_managers/firewire Message-ID: <200709032059.l83Kx3Wx007973@sheep.berlios.de> Author: korli Date: 2007-09-03 22:59:02 +0200 (Mon, 03 Sep 2007) New Revision: 22160 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22160&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h Log: ooops it was le32toh Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h 2007-09-03 20:35:27 UTC (rev 22159) +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohcireg.h 2007-09-03 20:59:02 UTC (rev 22160) @@ -95,7 +95,7 @@ #if BYTE_ORDER == BIG_ENDIAN #ifdef __HAIKU__ #define htole32(x) __swap_int32(x) -#define letoh32(x) __swap_int32(x) +#define le32toh(x) __swap_int32(x) #endif #define FWOHCI_DMA_WRITE(x, y) ((x) = htole32(y)) #define FWOHCI_DMA_READ(x) le32toh(x) From bonefish at mail.berlios.de Mon Sep 3 23:35:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Sep 2007 23:35:25 +0200 Subject: [Haiku-commits] r22161 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200709032135.l83LZPEM009807@sheep.berlios.de> Author: bonefish Date: 2007-09-03 23:35:24 +0200 (Mon, 03 Sep 2007) New Revision: 22161 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22161&view=rev Modified: haiku/trunk/headers/private/kernel/ksignal.h haiku/trunk/src/system/kernel/signal.cpp haiku/trunk/src/system/kernel/team.cpp Log: * Resolved TODO: waitpid() clears pending SIGCHLD, if the signal is blocked and no other child status is available. * Respect SA_NOCLDWAIT and ignored SIGCHLD in waitpid(): Unless a child status is available immediately, the thread shall block until all children are gone. Modified: haiku/trunk/headers/private/kernel/ksignal.h =================================================================== --- haiku/trunk/headers/private/kernel/ksignal.h 2007-09-03 20:59:02 UTC (rev 22160) +++ haiku/trunk/headers/private/kernel/ksignal.h 2007-09-03 21:35:24 UTC (rev 22161) @@ -12,7 +12,9 @@ #define KILL_SIGNALS ((1L << (SIGKILL - 1)) | (1L << (SIGKILLTHR - 1))) +#define SIGNAL_TO_MASK(signal) (1LL << (signal - 1)) + #ifdef __cplusplus extern "C" { #endif Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2007-09-03 20:59:02 UTC (rev 22160) +++ haiku/trunk/src/system/kernel/signal.cpp 2007-09-03 21:35:24 UTC (rev 22161) @@ -33,7 +33,6 @@ #endif -#define SIGNAL_TO_MASK(signal) (1LL << (signal - 1)) #define BLOCKABLE_SIGNALS (~(KILL_SIGNALS | SIGNAL_TO_MASK(SIGSTOP))) #define STOP_SIGNALS \ (SIGNAL_TO_MASK(SIGSTOP) | SIGNAL_TO_MASK(SIGTSTP) \ Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-09-03 20:59:02 UTC (rev 22160) +++ haiku/trunk/src/system/kernel/team.cpp 2007-09-03 21:35:24 UTC (rev 22161) @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1320,6 +1321,21 @@ } +static job_control_entry* +get_job_control_entry(struct team* team, pid_t id, uint32 flags) +{ + job_control_entry* entry = get_job_control_entry(team->dead_children, id); + + if (entry == NULL && (flags & WCONTINUED) != 0) + entry = get_job_control_entry(team->continued_children, id); + + if (entry == NULL && (flags & WUNTRACED) != 0) + entry = get_job_control_entry(team->stopped_children, id); + + return entry; +} + + /*! This is the kernel backend for waitpid(). It is a bit more powerful when it comes to the reason why a thread has died than waitpid() can be. */ @@ -1327,7 +1343,8 @@ wait_for_child(pid_t child, uint32 flags, int32 *_reason, status_t *_returnCode) { - struct team *team = thread_get_current_thread()->team; + struct thread* thread = thread_get_current_thread(); + struct team* team = thread->team; struct job_control_entry foundEntry; struct job_control_entry* freeDeathEntry = NULL; status_t status = B_OK; @@ -1339,19 +1356,15 @@ child = -team->group_id; } + bool ignoreFoundEntries = false; + bool ignoreFoundEntriesChecked = false; + while (true) { InterruptsSpinLocker locker(team_spinlock); // check whether any condition holds - job_control_entry* entry = get_job_control_entry(team->dead_children, - child); + job_control_entry* entry = get_job_control_entry(team, child, flags); - if (entry == NULL && (flags & WCONTINUED) != 0) - entry = get_job_control_entry(team->continued_children, child); - - if (entry == NULL && (flags & WUNTRACED) != 0) - entry = get_job_control_entry(team->stopped_children, child); - // If we don't have an entry yet, check whether there are any children // complying to the process group specification at all. if (entry == NULL) { @@ -1410,14 +1423,36 @@ locker.Unlock(); // we got our entry and can return to our caller - if (status == B_OK) + if (status == B_OK) { + if (ignoreFoundEntries) { + // ... unless we shall ignore found entries + delete freeDeathEntry; + freeDeathEntry = NULL; + continue; + } + break; + } + if (status != B_WOULD_BLOCK || (flags & WNOHANG) != 0) return status; status = deadWaitEntry.Wait(B_CAN_INTERRUPT); if (status == B_INTERRUPTED) return status; + + // If SA_NOCLDWAIT is set or SIGCHLD is ignored, we shall wait until + // all our children are dead and fail with ECHILD. We check the + // condition at this point. + if (!ignoreFoundEntriesChecked) { + struct sigaction& handler = thread->sig_action[SIGCHLD - 1]; + if ((handler.sa_flags & SA_NOCLDWAIT) != 0 + || handler.sa_handler == SIG_IGN) { + ignoreFoundEntries = true; + } + + ignoreFoundEntriesChecked = true; + } } delete freeDeathEntry; @@ -1443,12 +1478,15 @@ *_returnCode = foundEntry.status; *_reason = (foundEntry.signal << 16) | reason; - // TODO: From the Open Group Base Specs Issue 6: - // "... if SIGCHLD is blocked, if wait() or waitpid() return because - // the status of a child process is available, any pending SIGCHLD signal - // shall be cleared unless the status of another child process is - // available." + // If SIGCHLD is blocked, we shall clear pending SIGCHLDs, if no other child + // status is available. + if ((atomic_get(&thread->sig_block_mask) & SIGNAL_TO_MASK(SIGCHLD)) != 0) { + InterruptsSpinLocker locker(team_spinlock); + if (get_job_control_entry(team, child, flags) == NULL) + atomic_and(&thread->sig_pending, ~SIGNAL_TO_MASK(SIGCHLD)); + } + return foundEntry.thread; } From mmu_man at mail.berlios.de Tue Sep 4 03:26:43 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Tue, 4 Sep 2007 03:26:43 +0200 Subject: [Haiku-commits] r22162 - haiku/trunk/src/bin Message-ID: <200709040126.l841QhZE011800@sheep.berlios.de> Author: mmu_man Date: 2007-09-04 03:26:42 +0200 (Tue, 04 Sep 2007) New Revision: 22162 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22162&view=rev Modified: haiku/trunk/src/bin/urlwrapper.cpp haiku/trunk/src/bin/urlwrapper.h haiku/trunk/src/bin/urlwrapper.rdef Log: Add reading of .url files from win, redirects to default browser. Modified: haiku/trunk/src/bin/urlwrapper.cpp =================================================================== --- haiku/trunk/src/bin/urlwrapper.cpp 2007-09-03 21:35:24 UTC (rev 22161) +++ haiku/trunk/src/bin/urlwrapper.cpp 2007-09-04 01:26:42 UTC (rev 22162) @@ -10,6 +10,7 @@ * urlwrapper: wraps URL mime types around command line apps * or other apps that don't handle them directly. */ +#define DEBUG 1 #include #include @@ -229,17 +230,64 @@ int32 index = 0; entry_ref ref; char *args[] = { "urlwrapper", buff, NULL }; -#ifdef HANDLE_BOOKMARK_FILES - /* eat everything as bookmark files */ + status_t err; + while (msg->FindRef("refs", index++, &ref) == B_OK) { BFile f(&ref, B_READ_ONLY); - if (f.InitCheck() == B_OK) { + BNodeInfo ni(&f); + BString mimetype; + if (f.InitCheck() == B_OK && ni.InitCheck() == B_OK) { + ni.GetType(mimetype.LockBuffer(B_MIME_TYPE_LENGTH)); + mimetype.UnlockBuffer(); +#ifdef HANDLE_URL_FILES + // http://filext.com/file-extension/URL + if (mimetype == "wwwserver/redirection" + || mimetype == "application/internet-shortcut" + || mimetype == "application/x-url" + || mimetype == "message/external-body" + || mimetype == "text/url" + || mimetype == "text/x-url") { + // http://www.cyanwerks.com/file-format-url.html + off_t size; + if (f.GetSize(&size) < B_OK) + continue; + BString contents, url; + if (f.ReadAt(0LL, contents.LockBuffer(size), size) < B_OK) + continue; + while (contents.Length()) { + BString line; + int32 cr = contents.FindFirst('\n'); + if (cr < 0) + cr = contents.Length(); + //contents.MoveInto(line, 0, cr); + contents.CopyInto(line, 0, cr); + contents.Remove(0, cr+1); + line.RemoveAll("\r"); + if (!line.Length()) + continue; + if (!line.ICompare("URL=", 4)) { + line.MoveInto(url, 4, line.Length()); + break; + } + } + if (url.Length()) { + args[1] = (char *)url.String(); + //ArgvReceived(2, args); + err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, args+1); + continue; + } + } +#endif + /* eat everything as bookmark files */ +#ifdef HANDLE_BOOKMARK_FILES if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff, B_PATH_NAME_LENGTH) > 0) { - ArgvReceived(2, args); + //ArgvReceived(2, args); + err = be_roster->Launch("application/x-vnd.Be.URL.http", 1, args+1); + continue; } +#endif } } -#endif } void UrlWrapperApp::ArgvReceived(int32 argc, char **argv) @@ -253,7 +301,7 @@ return; const char *failc = " || read -p 'Press any key'"; - const char *pausec = "; read -p 'Press any key'"; + const char *pausec = " ; read -p 'Press any key'"; char *args[] = { "/bin/sh", "-c", NULL, NULL}; Url u(argv[1]); @@ -333,7 +381,7 @@ } if (u.proto == "finger") { - BString cmd("finger "); + BString cmd("/bin/finger "); if (u.HasUser()) cmd << u.user; @@ -350,7 +398,7 @@ #ifdef HANDLE_HTTP_WGET if (u.proto == "http") { - BString cmd("wget "); + BString cmd("/bin/wget "); //cmd << url; if (u.HasUser()) Modified: haiku/trunk/src/bin/urlwrapper.h =================================================================== --- haiku/trunk/src/bin/urlwrapper.h 2007-09-03 21:35:24 UTC (rev 22161) +++ haiku/trunk/src/bin/urlwrapper.h 2007-09-04 01:26:42 UTC (rev 22162) @@ -19,6 +19,8 @@ /* NetPositive Bookmark file type */ #define HANDLE_BOOKMARK_FILES +/* M$IE .url files */ +#define HANDLE_URL_FILES /* file: redirects to Tracker */ #define HANDLE_FILE Modified: haiku/trunk/src/bin/urlwrapper.rdef =================================================================== --- haiku/trunk/src/bin/urlwrapper.rdef 2007-09-03 21:35:24 UTC (rev 22161) +++ haiku/trunk/src/bin/urlwrapper.rdef 2007-09-04 01:26:42 UTC (rev 22162) @@ -9,6 +9,15 @@ #ifdef HANDLE_BOOKMARK_FILES "types" = "application/x-vnd.Be-bookmark", #endif +#ifdef HANDLE_URL_FILES + /* setmime -set text/x-url -short "Internet Shortcut" -long "Internet Shortcut File" -sniffRule '0.80 ("[InternetShortcut]")' */ + "types" = "wwwserver/redirection", + "types" = "application/internet-shortcut", + "types" = "application/x-url", + "types" = "message/external-body", + "types" = "text/url", + "types" = "text/x-url", +#endif #ifdef HANDLE_FILE "types" = "application/x-vnd.Be.URL.file", #endif From leavengood at mail.berlios.de Tue Sep 4 05:08:41 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Tue, 4 Sep 2007 05:08:41 +0200 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit Message-ID: <200709040308.l8438fQS016216@sheep.berlios.de> Author: leavengood Date: 2007-09-04 05:08:40 +0200 (Tue, 04 Sep 2007) New Revision: 22163 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22163&view=rev Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp haiku/trunk/src/apps/stylededit/ColorMenuItem.h haiku/trunk/src/apps/stylededit/Constants.h haiku/trunk/src/apps/stylededit/FindWindow.cpp haiku/trunk/src/apps/stylededit/FindWindow.h haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp haiku/trunk/src/apps/stylededit/ReplaceWindow.h haiku/trunk/src/apps/stylededit/StyledEditApp.cpp haiku/trunk/src/apps/stylededit/StyledEditApp.h haiku/trunk/src/apps/stylededit/StyledEditView.cpp haiku/trunk/src/apps/stylededit/StyledEditView.h haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp haiku/trunk/src/apps/stylededit/StyledEditWindow.h Log: Applied patch from "HOST", with a few small style fixes myself. Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -7,14 +7,14 @@ * Andrew Bachmann */ - #include "ColorMenuItem.h" +#include ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *message) : BMenuItem(label, message, 0, 0) + , fItemColor(color) { - fItemColor = color; } @@ -22,9 +22,11 @@ ColorMenuItem::DrawContent() { BMenu *menu = Menu(); - rgb_color menuColor = menu->HighColor(); + if (menu) { + rgb_color menuColor = menu->HighColor(); - menu->SetHighColor(fItemColor); - BMenuItem::DrawContent(); - menu->SetHighColor(menuColor); + menu->SetHighColor(fItemColor); + BMenuItem::DrawContent(); + menu->SetHighColor(menuColor); + } } Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.h =================================================================== --- haiku/trunk/src/apps/stylededit/ColorMenuItem.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -13,15 +13,16 @@ #include +class BMessage; + + class ColorMenuItem: public BMenuItem { public: - ColorMenuItem(const char *label, rgb_color color, BMessage *message); + ColorMenuItem(const char *label, rgb_color color, BMessage *message); + void DrawContent(); - protected: - virtual void DrawContent(); - private: - rgb_color fItemColor; + rgb_color fItemColor; }; #endif // COLOR_MENU_ITEM_H Modified: haiku/trunk/src/apps/stylededit/Constants.h =================================================================== --- haiku/trunk/src/apps/stylededit/Constants.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/Constants.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -76,3 +76,4 @@ const uint32 SAVE_THEN_QUIT = 'FPsq'; #endif // CONSTANTS_H + Modified: haiku/trunk/src/apps/stylededit/FindWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/FindWindow.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/FindWindow.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -18,12 +18,11 @@ FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString, - bool *caseState, bool *wrapState, bool *backState) + bool caseState, bool wrapState, bool backState) : BWindow(frame, "FindWindow", B_MODAL_WINDOW, - B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, - B_CURRENT_WORKSPACE) + B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE) { - AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED)); + AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW); fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -31,7 +30,7 @@ font_height height; fFindView->GetFontHeight(&height); - float lineHeight = height.ascent+height.descent + height.leading; + float lineHeight = height.ascent + height.descent + height.leading; float findWidth = fFindView->StringWidth("Find:") + 6; @@ -65,12 +64,12 @@ const char *text = searchString->String(); - fSearchString->SetText(text); + fSearchString->SetText(text); fSearchString->MakeFocus(true); - fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF); - fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF); - fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF); + fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF); + fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF); + fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF); } Modified: haiku/trunk/src/apps/stylededit/FindWindow.h =================================================================== --- haiku/trunk/src/apps/stylededit/FindWindow.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/FindWindow.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -12,6 +12,7 @@ #include + class BButton; class BCheckBox; class BTextControl; @@ -20,14 +21,14 @@ class FindWindow : public BWindow { public: - FindWindow(BRect frame, BHandler* handler, BString *searchString, - bool *caseState, bool *wrapState, bool *backState); + FindWindow(BRect frame, BHandler* handler, BString *searchString, + bool caseState, bool wrapState, bool backState); - virtual void MessageReceived(BMessage* message); - virtual void DispatchMessage(BMessage* message, BHandler* handler); + void MessageReceived(BMessage* message); + void DispatchMessage(BMessage* message, BHandler* handler); private: - void _SendMessage(); + void _SendMessage(); BView *fFindView; BTextControl *fSearchString; @@ -42,8 +43,3 @@ #endif // FIND_WINDOW_H - - - - - Modified: haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -11,21 +11,23 @@ #include "Constants.h" #include "ReplaceWindow.h" -#include #include #include +#include +#include +#include +#include #include #include -#include +#include ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchString, - BString *replaceString, bool *caseState, bool *wrapState, bool *backState) + BString *replaceString, bool caseState, bool wrapState, bool backState) : BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW, - B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, - B_CURRENT_WORKSPACE) + B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE) { - AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED)); + AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); fReplaceView = new BView(Bounds(), "ReplaceView", B_FOLLOW_ALL, B_WILL_DRAW); fReplaceView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -41,7 +43,7 @@ fReplaceView->AddChild(fReplaceString = new BTextControl(BRect(5, 35, 290, 50), "", replaceWithLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE)); - float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : findWidth) + 1; + float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : findWidth) + TEXT_INSET; fSearchString->SetDivider(maxWidth); fReplaceString->SetDivider(maxWidth); @@ -78,16 +80,16 @@ fReplaceString->SetText(replacetext); fSearchString->MakeFocus(true); - fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF); - fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF); - fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF); + fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF); + fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF); + fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF); } void ReplaceWindow::MessageReceived(BMessage *msg) { - switch (msg->what){ + switch (msg->what) { case MSG_REPLACE: _SendMessage(MSG_REPLACE); break; @@ -108,22 +110,16 @@ void ReplaceWindow::_ChangeUI() { - if (!fUIchange) { - fReplaceAllButton->MakeDefault(true); - fReplaceButton->SetEnabled(false); - fWrapBox->SetValue(B_CONTROL_ON); - fWrapBox->SetEnabled(false); - fBackSearchBox->SetEnabled(false); - fUIchange = true; - } else { - fReplaceButton->MakeDefault(true); - fReplaceButton->SetEnabled(true); - fReplaceAllButton->SetEnabled(true); - fWrapBox->SetValue(B_CONTROL_OFF); - fWrapBox->SetEnabled(true); - fBackSearchBox->SetEnabled(true); - fUIchange = false; - } + fWrapBox->SetEnabled(fUIchange); + fWrapBox->SetValue(fUIchange ? B_CONTROL_OFF : B_CONTROL_ON); + + fBackSearchBox->SetEnabled(fUIchange); + + fReplaceButton->SetEnabled(fUIchange); + fUIchange ? fReplaceButton->MakeDefault(true) + : fReplaceAllButton->MakeDefault(true); + + fUIchange = !fUIchange; } Modified: haiku/trunk/src/apps/stylededit/ReplaceWindow.h =================================================================== --- haiku/trunk/src/apps/stylededit/ReplaceWindow.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/ReplaceWindow.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -11,27 +11,29 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +class BView; +class BString; +class BButton; +class BHandler; +class BMessage; +class BCheckBox; +class BTextControl; + + class ReplaceWindow : public BWindow { public: - ReplaceWindow(BRect frame, BHandler *_handler,BString *searchString, - BString *replaceString, bool *caseState, bool *wrapState, bool *backState); + ReplaceWindow(BRect frame, BHandler *_handler, + BString *searchString, BString *replaceString, + bool caseState, bool wrapState, bool backState); - virtual void MessageReceived(BMessage* message); - virtual void DispatchMessage(BMessage* message, BHandler *handler); + void MessageReceived(BMessage* message); + void DispatchMessage(BMessage* message, BHandler *handler); private: - void _SendMessage(uint32 what); - void _ChangeUI(); + void _SendMessage(uint32 what); + void _ChangeUI(); BView *fReplaceView; BTextControl *fSearchString; @@ -48,3 +50,4 @@ }; #endif // REPLACE_WINDOW_H + Modified: haiku/trunk/src/apps/stylededit/StyledEditApp.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditApp.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/StyledEditApp.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -8,61 +8,70 @@ */ +#include "Constants.h" +#include "StyledEditApp.h" +#include "StyledEditWindow.h" + #include #include -#include -#include +#include #include #include +#include +#include +#include +#include #include + #include -#include "Constants.h" -#include "StyledEditApp.h" -#include "StyledEditWindow.h" using namespace BPrivate; + StyledEditApp * styled_edit_app; BRect gWindowRect(7-15, 26-15, 507, 426); -void -cascade() +namespace { - BScreen screen(NULL); - BRect screenBorder = screen.Frame(); - float left = gWindowRect.left + 15; - if (left + gWindowRect.Width() > screenBorder.right) - left = 7; + void + cascade() + { + BScreen screen(NULL); + BRect screenBorder = screen.Frame(); + float left = gWindowRect.left + 15; + if (left + gWindowRect.Width() > screenBorder.right) + left = 7; - float top = gWindowRect.top + 15; - if (top + gWindowRect.Height() > screenBorder.bottom) - top = 26; + float top = gWindowRect.top + 15; + if (top + gWindowRect.Height() > screenBorder.bottom) + top = 26; - gWindowRect.OffsetTo(BPoint(left,top)); -} + gWindowRect.OffsetTo(BPoint(left,top)); + } -void -uncascade() -{ - BScreen screen(NULL); - BRect screenBorder = screen.Frame(); + void + uncascade() + { + BScreen screen(NULL); + BRect screenBorder = screen.Frame(); - float left = gWindowRect.left - 15; - if (left < 7) { - left = screenBorder.right - gWindowRect.Width() - 7; - left = left - ((int)left % 15) + 7; - } + float left = gWindowRect.left - 15; + if (left < 7) { + left = screenBorder.right - gWindowRect.Width() - 7; + left = left - ((int)left % 15) + 7; + } - float top = gWindowRect.top - 15; - if (top < 26) { - top = screenBorder.bottom - gWindowRect.Height() - 26; - top = top - ((int)left % 15) + 26; + float top = gWindowRect.top - 15; + if (top < 26) { + top = screenBorder.bottom - gWindowRect.Height() - 26; + top = top - ((int)left % 15) + 26; + } + + gWindowRect.OffsetTo(BPoint(left,top)); } - - gWindowRect.OffsetTo(BPoint(left,top)); } @@ -71,9 +80,10 @@ StyledEditApp::StyledEditApp() : BApplication(APP_SIGNATURE) + , fOpenPanel(NULL) { - fOpenPanel= new BFilePanel(); - BMenuBar * menuBar = + fOpenPanel = new BFilePanel(); + BMenuBar *menuBar = dynamic_cast(fOpenPanel->Window()->FindView("MenuBar")); fOpenAsEncoding = 0; @@ -110,6 +120,12 @@ } +StyledEditApp::~StyledEditApp() +{ + delete fOpenPanel; +} + + void StyledEditApp::DispatchMessage(BMessage *msg, BHandler *handler) { @@ -128,7 +144,7 @@ if (msg->FindString("cwd", &cwd) != B_OK) cwd = ""; - ArgvReceived(argc, argv, cwd); + ArgvReceivedEx(argc, argv, cwd); } else BApplication::DispatchMessage(msg, handler); } @@ -205,7 +221,7 @@ void -StyledEditApp::ArgvReceived(int32 argc, const char* argv[], const char* cwd) +StyledEditApp::ArgvReceivedEx(int32 argc, const char* argv[], const char* cwd) { for (int i = 1 ; (i < argc) ; i++) { BPath path; Modified: haiku/trunk/src/apps/stylededit/StyledEditApp.h =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditApp.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/StyledEditApp.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -11,36 +11,46 @@ #include -#include -#include +struct entry_ref; + +class BMenu; +class BHandler; +class BMessage; +class BFilePanel; class StyledEditWindow; + class StyledEditApp : public BApplication { public: - StyledEditApp(); - virtual void MessageReceived(BMessage *message); - void ArgvReceived(int32 argc, const char *argv[], const char * cwd); - virtual void RefsReceived(BMessage *message); - virtual void ReadyToRun(); + StyledEditApp(); + ~StyledEditApp(); - virtual void DispatchMessage(BMessage *an_event, BHandler *handler); + void MessageReceived(BMessage *message); + void RefsReceived(BMessage *message); + void ReadyToRun(); - int32 NumberOfWindows(); - void OpenDocument(); - void OpenDocument(entry_ref * ref); - void CloseDocument(); + void DispatchMessage(BMessage *an_event, BHandler *handler); + int32 NumberOfWindows(); + void OpenDocument(); + void OpenDocument(entry_ref * ref); + void CloseDocument(); + private: - BFilePanel* fOpenPanel; - BMenu* fOpenPanelEncodingMenu; - uint32 fOpenAsEncoding; - int32 fWindowCount; - int32 fNextUntitledWindow; + void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd); + + private: + BFilePanel *fOpenPanel; + BMenu *fOpenPanelEncodingMenu; + uint32 fOpenAsEncoding; + int32 fWindowCount; + int32 fNextUntitledWindow; }; extern StyledEditApp* styled_edit_app; #endif // STYLED_EDIT_APP + Modified: haiku/trunk/src/apps/stylededit/StyledEditView.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditView.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/StyledEditView.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -12,17 +12,19 @@ #include "Constants.h" #include "StyledEditView.h" +#include +#include +#include +#include #include #include +#include #include -#include #include -#include +#include + #include #include -#include -#include -#include using namespace BPrivate; @@ -32,7 +34,6 @@ : BTextView(viewFrame, "textview", textBounds, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW) { - fHandler = handler; fMessenger = new BMessenger(handler); fSuppressChanges = false; } @@ -45,35 +46,22 @@ void -StyledEditView::FrameResized(float width, float height) +StyledEditView::Select(int32 start, int32 finish) { - BTextView::FrameResized(width, height); + fMessenger->SendMessage(start == finish ? DISABLE_ITEMS : ENABLE_ITEMS); - if (DoesWordWrap()) { - BRect textRect; - textRect = Bounds(); - textRect.OffsetTo(B_ORIGIN); - textRect.InsetBy(TEXT_INSET, TEXT_INSET); - SetTextRect(textRect); - } + BTextView::Select(start, finish); +} -/* // I tried to do some sort of intelligent resize thing but it just doesn't work - // so we revert to the R5 stylededit yucky practice of setting the text rect to - // some crazy large number when word wrap is turned off :-( - else if (textRect.Width() > TextRect().Width()) { - SetTextRect(textRect); - } - BRegion region; - GetTextRegion(0,TextLength(),®ion); - float textWidth = region.Frame().Width(); - if (textWidth < textRect.Width()) { - BRect textRect(B_ORIGIN,BPoint(textWidth+TEXT_INSET*2,Bounds().Height())); - textRect.InsetBy(TEXT_INSET,TEXT_INSET); - SetTextRect(textRect); - } - */ -} +void +StyledEditView::Reset() +{ + fSuppressChanges = true; + SetText(""); + fEncoding = ""; + fSuppressChanges = false; +} status_t @@ -145,38 +133,17 @@ void -StyledEditView::Reset() -{ - fSuppressChanges = true; - SetText(""); - fEncoding = ""; - fSuppressChanges = false; -} - - -void -StyledEditView::Select(int32 start, int32 finish) -{ - fChangeMessage = new BMessage(start == finish ? DISABLE_ITEMS : ENABLE_ITEMS); - fMessenger->SendMessage(fChangeMessage); - - BTextView::Select(start, finish); -} - - -void StyledEditView::SetEncoding(uint32 encoding) { - if (encoding == 0) { - fEncoding = ""; + fEncoding = ""; + if (encoding == 0) return; - } - const BCharacterSet* set = BCharacterSetRoster::GetCharacterSetByFontID(encoding); + const BCharacterSet* set + = BCharacterSetRoster::GetCharacterSetByFontID(encoding); + if (set != NULL) fEncoding = set->GetName(); - else - fEncoding = ""; } @@ -186,8 +153,9 @@ if (fEncoding == "") return 0; - const BCharacterSet* set = BCharacterSetRoster::FindCharacterSetByName(fEncoding.String()); - if (set != NULL) + const BCharacterSet* set = + BCharacterSetRoster::FindCharacterSetByName(fEncoding.String()); + if(set != NULL) return set->GetFontID(); return 0; @@ -195,22 +163,37 @@ void +StyledEditView::DeleteText(int32 start, int32 finish) +{ + if (!fSuppressChanges) + fMessenger-> SendMessage(TEXT_CHANGED); + + BTextView::DeleteText(start, finish); +} + + +void StyledEditView::InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs) { if (!fSuppressChanges) - fMessenger->SendMessage(new BMessage(TEXT_CHANGED)); + fMessenger->SendMessage(TEXT_CHANGED); BTextView::InsertText(text, length, offset, runs); } void -StyledEditView::DeleteText(int32 start, int32 finish) +StyledEditView::FrameResized(float width, float height) { - if (!fSuppressChanges) - fMessenger-> SendMessage(new BMessage(TEXT_CHANGED)); + BTextView::FrameResized(width, height); - BTextView::DeleteText(start, finish); -} + if (DoesWordWrap()) { + BRect textRect; + textRect = Bounds(); + textRect.OffsetTo(B_ORIGIN); + textRect.InsetBy(TEXT_INSET, TEXT_INSET); + SetTextRect(textRect); + } +} Modified: haiku/trunk/src/apps/stylededit/StyledEditView.h =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 03:08:40 UTC (rev 22163) @@ -11,37 +11,40 @@ #define STYLED_EDIT_VIEW_H -#include -#include #include #include +class BFile; +class BHandler; +class BMessanger; + + class StyledEditView : public BTextView { public: - StyledEditView(BRect viewframe, BRect textframe, BHandler *handler); - virtual ~StyledEditView(); + StyledEditView(BRect viewframe, BRect textframe, + BHandler *handler); + ~StyledEditView(); - virtual void Select(int32 start, int32 finish); - virtual void FrameResized(float width, float height); + void Select(int32 start, int32 finish); - virtual void Reset(); - virtual status_t GetStyledText(BPositionIO * stream); - virtual status_t WriteStyledEditFile(BFile * file); + void Reset(); + status_t GetStyledText(BPositionIO * stream); + status_t WriteStyledEditFile(BFile * file); - virtual void SetEncoding(uint32 encoding); - virtual uint32 GetEncoding() const; + void SetEncoding(uint32 encoding); + uint32 GetEncoding() const; - protected: - virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs = NULL); - virtual void DeleteText(int32 start, int32 finish); - private: - BHandler *fHandler; - BMessage *fChangeMessage; + void DeleteText(int32 start, int32 finish); + void FrameResized(float width, float height); + void InsertText(const char *text, int32 length, int32 offset, + const text_run_array *runs = NULL); + BMessenger *fMessenger; bool fSuppressChanges; BString fEncoding; }; #endif // STYLED_EDIT_VIEW_H + Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2007-09-04 01:26:42 UTC (rev 22162) +++ haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2007-09-04 03:08:40 UTC (rev 22163) @@ -18,24 +18,26 @@ #include #include -#include +#include +#include #include +#include #include +#include #include +#include #include #include -#include +#include #include -#include #include +#include #include -#include +#include -#include -#include - #include + using namespace BPrivate; @@ -43,8 +45,7 @@ : BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) { InitWindow(encoding); - BString unTitled; - unTitled.SetTo("Untitled "); + BString unTitled("Untitled "); unTitled << id; SetTitle(unTitled.String()); fSaveItem->SetEnabled(true); @@ -365,7 +366,7 @@ { BRect findWindowFrame(100, 100, 400, 235); BWindow* window = new FindWindow(findWindowFrame, this, - &fStringToFind, &fCaseSens, &fWrapAround, &fBackSearch); + &fStringToFind, fCaseSens, fWrapAround, fBackSearch); window->Show(); break; } @@ -388,58 +389,45 @@ { BRect replaceWindowFrame(100, 100, 400, 284); BWindow* window = new ReplaceWindow(replaceWindowFrame, this, - &fStringToFind, &fReplaceString, &fCaseSens, &fWrapAround, &fBackSearch); + &fStringToFind, &fReplaceString, fCaseSens, fWrapAround, fBackSearch); window->Show(); break; } case MSG_REPLACE: { - BString findIt; - BString replaceWith; - bool caseSens, wrap, backSearch; + message->FindBool("casesens", &fCaseSens); + message->FindBool("wrap", &fWrapAround); + message->FindBool("backsearch", &fBackSearch); - message->FindBool("casesens", &caseSens); - message->FindBool("wrap", &wrap); - message->FindBool("backsearch", &backSearch); + message->FindString("FindText", &fStringToFind); + message->FindString("ReplaceText", &fReplaceString); - message->FindString("FindText", &findIt); - message->FindString("ReplaceText", &replaceWith); - fStringToFind = findIt; fFindAgainItem->SetEnabled(true); - fReplaceString = replaceWith; fReplaceSameItem->SetEnabled(true); - fCaseSens = caseSens; - fWrapAround = wrap; - fBackSearch = backSearch; - Replace(findIt, replaceWith, caseSens, wrap, backSearch); + Replace(fStringToFind, fReplaceString, fCaseSens, fWrapAround, fBackSearch); break; } case MENU_REPLACE_SAME: - Replace(fStringToFind,fReplaceString,fCaseSens,fWrapAround,fBackSearch); + Replace(fStringToFind, fReplaceString, fCaseSens, fWrapAround, fBackSearch); break; case MSG_REPLACE_ALL: { - BString findIt; - BString replaceWith; - bool caseSens, allWindows; + message->FindBool("casesens", &fCaseSens); + message->FindString("FindText",&fStringToFind); + message->FindString("ReplaceText",&fReplaceString); - message->FindBool("casesens", &caseSens); - message->FindString("FindText",&findIt); - message->FindString("ReplaceText",&replaceWith); + bool allWindows; message->FindBool("allwindows", &allWindows); - fStringToFind = findIt; fFindAgainItem->SetEnabled(true); - fReplaceString = replaceWith; fReplaceSameItem->SetEnabled(true); - fCaseSens = caseSens; if (allWindows) - SearchAllWindows(findIt, replaceWith, caseSens); + SearchAllWindows(fStringToFind, fReplaceString, fCaseSens); else - ReplaceAll(findIt, replaceWith,caseSens); + ReplaceAll(fStringToFind, fReplaceString, fCaseSens); break; } @@ -508,70 +496,35 @@ case ALIGN_LEFT: fTextView->SetAlignment(B_ALIGN_LEFT); - fClean = false; - fUndoCleans = false; - fRedoCleans = false; - fRevertItem->SetEnabled(fSaveMessage != NULL); - fSaveItem->SetEnabled(true); - fUndoItem->SetLabel("Can't Undo"); - fUndoItem->SetEnabled(false); - fCanUndo = false; - fCanRedo = false; + _UpdateCleanUndoRedoSaveRevert(); break; case ALIGN_CENTER: fTextView->SetAlignment(B_ALIGN_CENTER); - fClean = false; - fUndoCleans = false; - fRedoCleans = false; - fRevertItem->SetEnabled(fSaveMessage != NULL); - fSaveItem->SetEnabled(true); - fUndoItem->SetLabel("Can't Undo"); - fUndoItem->SetEnabled(false); - fCanUndo = false; - fCanRedo = false; + _UpdateCleanUndoRedoSaveRevert(); break; case ALIGN_RIGHT: fTextView->SetAlignment(B_ALIGN_RIGHT); - fClean = false; - fUndoCleans = false; - fRedoCleans = false; - fRevertItem->SetEnabled(fSaveMessage != NULL); - fSaveItem->SetEnabled(true); - fUndoItem->SetLabel("Can't Undo"); - fUndoItem->SetEnabled(false); - fCanUndo = false; - fCanRedo = false; + _UpdateCleanUndoRedoSaveRevert(); break; case WRAP_LINES: + { + BRect textRect(fTextView->Bounds()); + textRect.OffsetTo(B_ORIGIN); + textRect.InsetBy(TEXT_INSET,TEXT_INSET); if (fTextView->DoesWordWrap()) { fTextView->SetWordWrap(false); fWrapItem->SetMarked(false); - BRect textRect; - textRect = fTextView->Bounds(); - textRect.OffsetTo(B_ORIGIN); - textRect.InsetBy(TEXT_INSET,TEXT_INSET); // the width comes from stylededit R5. TODO: find a better way - textRect.SetRightBottom(BPoint(1500.0,textRect.RightBottom().y)); - fTextView->SetTextRect(textRect); + textRect.SetRightBottom(BPoint(1500.0, textRect.RightBottom().y)); } else { fTextView->SetWordWrap(true); fWrapItem->SetMarked(true); - BRect textRect; - textRect = fTextView->Bounds(); - textRect.OffsetTo(B_ORIGIN); - textRect.InsetBy(TEXT_INSET,TEXT_INSET); - fTextView->SetTextRect(textRect); - } - fClean = false; - fUndoCleans = false; - fRedoCleans = false; - fRevertItem->SetEnabled(fSaveMessage != NULL); - fSaveItem->SetEnabled(true); - fUndoItem->SetLabel("Can't Undo"); - fUndoItem->SetEnabled(false); - fCanUndo = false; - fCanRedo = false; + } + fTextView->SetTextRect(textRect); + + _UpdateCleanUndoRedoSaveRevert(); break; + } case ENABLE_ITEMS: fCutItem->SetEnabled(true); [... truncated: 165 lines follow ...] From korli at users.berlios.de Tue Sep 4 09:03:52 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 4 Sep 2007 09:03:52 +0200 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: <200709040308.l8438fQS016216@sheep.berlios.de> References: <200709040308.l8438fQS016216@sheep.berlios.de> Message-ID: 2007/9/4, leavengood at BerliOS : > +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 03:08:40 UTC (rev > : BMenuItem(label, message, 0, 0) > + , fItemColor(color) > { > - fItemColor = color; > } This is a style violation. > + > + fReplaceButton->SetEnabled(fUIchange); > + fUIchange ? fReplaceButton->MakeDefault(true) > + : fReplaceAllButton->MakeDefault(true); > + This is a style violation. > @@ -71,9 +80,10 @@ > > StyledEditApp::StyledEditApp() > : BApplication(APP_SIGNATURE) > + , fOpenPanel(NULL) > { This is a style violation. > +++ haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 03:08:40 UTC (rev 22163) > +class BMessanger; This should be BMessenger. Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp #include -#include +#include Roster.h should be included some lines before. Bye, J?r?me From superstippi at gmx.de Tue Sep 4 09:22:08 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 04 Sep 2007 09:22:08 +0200 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: <200709040308.l8438fQS016216@sheep.berlios.de> References: <200709040308.l8438fQS016216@sheep.berlios.de> Message-ID: <20070904092208.402.1@stippis.1188889344.fake> Hi Ryan, > Log: > Applied patch from "HOST", with a few small style fixes myself. Next time, it would be nicer to write in the log what the patch is supposed to do :-). I have looked over the code, and it is mostly style cleanup, refactoring and many fixes to memory leaks (ala SendMessage(new BMessage(MESSAGE_CONSTANT)) -> SendMessage(MESSAGE_CONSTANT)). Thanks a lot for the huge cleanup work! Best regards, -Stephan From axeld at mail.berlios.de Tue Sep 4 14:32:20 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 4 Sep 2007 14:32:20 +0200 Subject: [Haiku-commits] r22164 - in haiku/trunk: headers/compatibility/bsd src/libs/bsd Message-ID: <200709041232.l84CWKsK013855@sheep.berlios.de> Author: axeld Date: 2007-09-04 14:32:20 +0200 (Tue, 04 Sep 2007) New Revision: 22164 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22164&view=rev Added: haiku/trunk/src/libs/bsd/daemon.c Modified: haiku/trunk/headers/compatibility/bsd/stdlib.h haiku/trunk/src/libs/bsd/Jamfile Log: Added daemon() function to libbsd.so. Modified: haiku/trunk/headers/compatibility/bsd/stdlib.h =================================================================== --- haiku/trunk/headers/compatibility/bsd/stdlib.h 2007-09-04 03:08:40 UTC (rev 22163) +++ haiku/trunk/headers/compatibility/bsd/stdlib.h 2007-09-04 12:32:20 UTC (rev 22164) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _BSD_STDLIB_H_ @@ -13,6 +13,7 @@ extern "C" { #endif +int daemon(int noChangeDir, int noClose); const char *getprogname(void); void setprogname(const char *programName); Modified: haiku/trunk/src/libs/bsd/Jamfile =================================================================== --- haiku/trunk/src/libs/bsd/Jamfile 2007-09-04 03:08:40 UTC (rev 22163) +++ haiku/trunk/src/libs/bsd/Jamfile 2007-09-04 12:32:20 UTC (rev 22164) @@ -5,6 +5,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; SharedLibrary libbsd.so : + daemon.c err.c fgetln.c getpass.c Added: haiku/trunk/src/libs/bsd/daemon.c =================================================================== --- haiku/trunk/src/libs/bsd/daemon.c 2007-09-04 03:08:40 UTC (rev 22163) +++ haiku/trunk/src/libs/bsd/daemon.c 2007-09-04 12:32:20 UTC (rev 22164) @@ -0,0 +1,68 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel D?rfler, axeld at pinc-software.de + */ + +#include +#include +#include +#include + + +static void +restore_old_sighup(int result, struct sigaction *action) +{ + if (result != -1) + sigaction(SIGHUP, action, NULL); +} + + +int +daemon(int noChangeDir, int noClose) +{ + struct sigaction oldAction, action; + int oldActionResult; + pid_t newGroup; + pid_t pid; + + /* Ignore eventually send SIGHUPS on parent exit */ + sigemptyset(&action.sa_mask); + action.sa_handler = SIG_IGN; + action.sa_flags = 0; + oldActionResult = sigaction(SIGHUP, &action, &oldAction); + + pid = fork(); + if (pid == -1) { + restore_old_sighup(oldActionResult, &oldAction); + return -1; + } + if (pid > 0) { + // we're the parent - let's exit + exit(0); + } + + newGroup = setsid(); + restore_old_sighup(oldActionResult, &oldAction); + + if (newGroup == -1) + return -1; + + if (!noChangeDir) + chdir("/"); + + if (!noClose) { + int fd = open("/dev/null", O_RDWR); + if (fd != -1) { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + if (fd > STDERR_FILENO) + close(fd); + } + } + + return 0; +} From leavengood at gmail.com Tue Sep 4 15:43:45 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 4 Sep 2007 09:43:45 -0400 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: References: <200709040308.l8438fQS016216@sheep.berlios.de> Message-ID: On 9/4/07, J?r?me Duval wrote: > 2007/9/4, leavengood at BerliOS : > > +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 03:08:40 UTC (rev > : BMenuItem(label, message, 0, 0) > > + , fItemColor(color) > > { > > - fItemColor = color; > > } > > This is a style violation. OK. It seems as if the coding guidelines have changed in this respect since I can recall seeing the syntax with the comma first before. I prefer it this new way anyhow. > > + > > + fReplaceButton->SetEnabled(fUIchange); > > + fUIchange ? fReplaceButton->MakeDefault(true) > > + : fReplaceAllButton->MakeDefault(true); > > + > > This is a style violation. The colon belongs on the line before? I am not sure about this. There is no explicit "ternary operator guidelines", and in if conditions the operators are supposed to be at the beginning of the next line. > > @@ -71,9 +80,10 @@ > > > > StyledEditApp::StyledEditApp() > > : BApplication(APP_SIGNATURE) > > + , fOpenPanel(NULL) > > { > > This is a style violation. Same thing as above I guess. > > +++ haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 03:08:40 UTC (rev 22163) > > +class BMessanger; > > This should be BMessenger. Yeah, missed that typo. The code still compiled with GCC4. > Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp > #include > -#include > +#include > > Roster.h should be included some lines before. OK. Ryan From HOST.HAIKU at gmx.de Tue Sep 4 15:54:33 2007 From: HOST.HAIKU at gmx.de (HOST Team) Date: Tue, 04 Sep 2007 15:54:33 +0200 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: References: <200709040308.l8438fQS016216@sheep.berlios.de> Message-ID: <46DD6399.6050409@gmx.de> Ryan Leavengood wrote: > On 9/4/07, J?r?me Duval wrote: >> 2007/9/4, leavengood at BerliOS : >>> +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 03:08:40 UTC (rev > : BMenuItem(label, message, 0, 0) >>> + , fItemColor(color) >>> { >>> - fItemColor = color; >>> } >> This is a style violation. > > OK. It seems as if the coding guidelines have changed in this respect > since I can recall seeing the syntax with the comma first before. I > prefer it this new way anyhow. > >>> + >>> + fReplaceButton->SetEnabled(fUIchange); >>> + fUIchange ? fReplaceButton->MakeDefault(true) >>> + : fReplaceAllButton->MakeDefault(true); >>> + >> This is a style violation. > > The colon belongs on the line before? I am not sure about this. There > is no explicit "ternary operator guidelines", and in if conditions the > operators are supposed to be at the beginning of the next line. > >>> @@ -71,9 +80,10 @@ >>> >>> StyledEditApp::StyledEditApp() >>> : BApplication(APP_SIGNATURE) >>> + , fOpenPanel(NULL) >>> { >> This is a style violation. > > Same thing as above I guess. > >>> +++ haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 03:08:40 UTC (rev 22163) >>> +class BMessanger; >> This should be BMessenger. > > Yeah, missed that typo. The code still compiled with GCC4. > >> Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp >> #include >> -#include >> +#include >> >> Roster.h should be included some lines before. > > OK. > > Ryan > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > > Hi Ryan, no worries about that, i will fix this with my next patch while adding back the virtuals. Thx anyway for your fixes and the commit. :) Regards, Julun From jackburton at mail.berlios.de Tue Sep 4 16:10:40 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 4 Sep 2007 16:10:40 +0200 Subject: [Haiku-commits] r22165 - in haiku/trunk/src/tests/servers/app: . window_creation Message-ID: <200709041410.l84EAeUs024345@sheep.berlios.de> Author: jackburton Date: 2007-09-04 16:10:40 +0200 (Tue, 04 Sep 2007) New Revision: 22165 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22165&view=rev Added: haiku/trunk/src/tests/servers/app/window_creation/ haiku/trunk/src/tests/servers/app/window_creation/Jamfile haiku/trunk/src/tests/servers/app/window_creation/main.cpp Modified: haiku/trunk/src/tests/servers/app/Jamfile Log: Added a window creation speed test. Can test empty windows or windows with BBoxes within. Modified: haiku/trunk/src/tests/servers/app/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/Jamfile 2007-09-04 12:32:20 UTC (rev 22164) +++ haiku/trunk/src/tests/servers/app/Jamfile 2007-09-04 14:10:40 UTC (rev 22165) @@ -177,3 +177,4 @@ SubInclude HAIKU_TOP src tests servers app stress_test ; SubInclude HAIKU_TOP src tests servers app textview ; SubInclude HAIKU_TOP src tests servers app view_state ; +SubInclude HAIKU_TOP src tests servers app window_creation ; Added: haiku/trunk/src/tests/servers/app/window_creation/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/window_creation/Jamfile 2007-09-04 12:32:20 UTC (rev 22164) +++ haiku/trunk/src/tests/servers/app/window_creation/Jamfile 2007-09-04 14:10:40 UTC (rev 22165) @@ -0,0 +1,13 @@ +SubDir HAIKU_TOP src tests servers app window_creation ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +Application WindowCreation : + main.cpp + : be +; + Added: haiku/trunk/src/tests/servers/app/window_creation/main.cpp =================================================================== --- haiku/trunk/src/tests/servers/app/window_creation/main.cpp 2007-09-04 12:32:20 UTC (rev 22164) +++ haiku/trunk/src/tests/servers/app/window_creation/main.cpp 2007-09-04 14:10:40 UTC (rev 22165) @@ -0,0 +1,151 @@ +#include +#include +#include +#include +#include + +#include +#include + + +static BRect *sFrames = NULL; +static uint32 sNumFrames = 0; + + +class TestApp : public BApplication { +public: + TestApp(uint32 numWindows, bool views); + virtual ~TestApp(); + + virtual void ReadyToRun(); + +private: + uint32 fFrameNum; + BRect fScreenFrame; + uint32 fNumWindows; + uint32 fMaxWindows; + bool fTestViews; + + void _CreateFrames(uint32 numWindows); + int32 _WindowCreator(); + static int32 _ThreadStarter(void *data); +}; + + +class TestWindow : public BWindow { +public: + TestWindow(BRect frame, bool createView); + virtual ~TestWindow(); + + +}; + + +TestApp::TestApp(uint32 numWindows, bool views) + : BApplication("application/x.vnd-Haiku.window-creation"), + fScreenFrame(), + fNumWindows(0), + fMaxWindows(numWindows), + fTestViews(views) + +{ + fScreenFrame = BScreen().Frame(); + _CreateFrames(numWindows); +} + + +TestApp::~TestApp() +{ + delete[] sFrames; +} + + +void +TestApp::ReadyToRun() +{ + thread_id thread = spawn_thread(_ThreadStarter, "Window creator", B_NORMAL_PRIORITY, this); + resume_thread(thread); +} + + +void +TestApp::_CreateFrames(uint32 numWindows) +{ + BRect frame(0, 0, 50, 50); + uint32 numHorizontal = (fScreenFrame.IntegerWidth() + 1) / (frame.IntegerWidth() + 1); + uint32 numVertical = (fScreenFrame.IntegerHeight() + 1) / (frame.IntegerHeight() + 1); + sNumFrames = numHorizontal * numVertical; + sFrames = new BRect[sNumFrames]; + for (int32 i = 0; i < sNumFrames; i++) { + sFrames[i] = frame; + frame.OffsetBy(50, 0); + if (!fScreenFrame.Contains(frame)) + frame.OffsetTo(0, frame.bottom + 1); + } +} + + +int32 +TestApp::_WindowCreator() +{ + bigtime_t startTime = system_time(); + + while (fNumWindows < fMaxWindows) { + if (fFrameNum >= sNumFrames) + fFrameNum = 0; + + BWindow *window = new TestWindow(sFrames[fFrameNum++], fTestViews); + window->Show(); + fNumWindows++; + } + + bigtime_t endTime = system_time(); + + printf("Test completed. %ld windows created in %lld usecs.\n", fNumWindows, endTime - startTime); + + PostMessage(B_QUIT_REQUESTED); + return B_OK; +} + + +int32 +TestApp::_ThreadStarter(void *data) +{ + return static_cast(data)->_WindowCreator(); +} + + +TestWindow::TestWindow(BRect frame, bool views) + : BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) +{ + if (views) + AddChild(new BBox(Bounds())); +} + + +TestWindow::~TestWindow() +{ +} + + + +// main +int +main(int argc, char** argv) +{ + uint32 numWindows = 10; + bool testViews = false; + if (argc > 1) { + numWindows = atoi(argv[1]); + } + + if (argc > 2) { + if (!strcmp(argv[2], "views")) + testViews = true; + } + + TestApp app(numWindows, testViews); + app.Run(); + + return 0; +} From axeld at pinc-software.de Tue Sep 4 17:31:57 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 04 Sep 2007 17:31:57 +0200 CEST Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: Message-ID: <12891380946-BeMail@zon> "Ryan Leavengood" wrote: > > > + , fItemColor(color) > > This is a style violation. > OK. It seems as if the coding guidelines have changed in this respect > since I can recall seeing the syntax with the comma first before. I > prefer it this new way anyhow. They didn't change, but they only contain this as an example, not written explicetly. > > > + fReplaceButton->SetEnabled(fUIchange); > > > + fUIchange ? fReplaceButton->MakeDefault(true) > > > + : fReplaceAllButton->MakeDefault(true); > > This is a style violation. > The colon belongs on the line before? I am not sure about this. There > is no explicit "ternary operator guidelines", and in if conditions > the > operators are supposed to be at the beginning of the next line. The operators are fine, however, that line should read: if (fUIChange) ... else ... Bye, Axel. From leavengood at gmail.com Tue Sep 4 17:52:16 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Tue, 4 Sep 2007 11:52:16 -0400 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: <12891380946-BeMail@zon> References: <12891380946-BeMail@zon> Message-ID: On 9/4/07, Axel D?rfler wrote: > > They didn't change, but they only contain this as an example, not > written explicetly. I've found a few other coding style issues I am not sure about and will soon send a message to the mailing list about it. I think our coding guidelines need to be reformatted because new developers seem to make a lot of mistakes. If we are going to be this picky the guidelines need to be totally explicit and very clear. > The operators are fine, however, that line should read: > if (fUIChange) > ... > else > ... OK in this case the ternary operator is not appropriate, but in general should that operator not be used? In some cases it can be better, IMO. Ryan From bonefish at cs.tu-berlin.de Tue Sep 4 18:26:25 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Tue, 04 Sep 2007 18:26:25 +0200 Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: References: <12891380946-BeMail@zon> Message-ID: <20070904182625.2604.6@cs.tu-berlin.de> On 2007-09-04 at 17:52:16 [+0200], Ryan Leavengood wrote: > On 9/4/07, Axel D?rfler wrote: > > > > They didn't change, but they only contain this as an example, not > > written explicetly. > > I've found a few other coding style issues I am not sure about and > will soon send a message to the mailing list about it. I think our > coding guidelines need to be reformatted because new developers seem > to make a lot of mistakes. If we are going to be this picky the > guidelines need to be totally explicit and very clear. > > > The operators are fine, however, that line should read: > > if (fUIChange) > > ... > > else > > ... > > OK in this case the ternary operator is not appropriate, but in > general should that operator not be used? In some cases it can be > better, IMO. It is allowed and encouraged in expressions, at least when it makes the code more compact and readable (definitely a matter of personal preferences). E.g.: BView* parent = (view ? view->Parent() : NULL); or return (error == B_OK ? bytesRead : error); In both cases using "if" constructs is OK, too. CU, Ingo From axeld at pinc-software.de Tue Sep 4 18:26:33 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 04 Sep 2007 18:26:33 +0200 CEST Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: Message-ID: <16167806968-BeMail@zon> "Ryan Leavengood" wrote: > On 9/4/07, Axel D?rfler wrote: > > They didn't change, but they only contain this as an example, not > > written explicetly. > I've found a few other coding style issues I am not sure about and > will soon send a message to the mailing list about it. I think our > coding guidelines need to be reformatted because new developers seem > to make a lot of mistakes. If we are going to be this picky the > guidelines need to be totally explicit and very clear. Definitely, any further clarification is highly appreciated :-) > > The operators are fine, however, that line should read: > > if (fUIChange) > > ... > > else > > ... > OK in this case the ternary operator is not appropriate, but in > general should that operator not be used? In some cases it can be > better, IMO. Sure, and it's not forbidden to use either, it was just not the appropriate place to use it. Bye, Axel. From axeld at pinc-software.de Tue Sep 4 18:40:39 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 04 Sep 2007 18:40:39 +0200 CEST Subject: [Haiku-commits] r22163 - haiku/trunk/src/apps/stylededit In-Reply-To: <20070904182625.2604.6@cs.tu-berlin.de> Message-ID: <17013294820-BeMail@zon> Ingo Weinhold wrote: > It is allowed and encouraged in expressions, at least when it makes > the > code more compact and readable (definitely a matter of personal > preferences). E.g.: > > BView* parent = (view ? view->Parent() : NULL); > or > return (error == B_OK ? bytesRead : error); > > In both cases using "if" constructs is OK, too. As is leaving out the additional unneeded parentheses :-) Bye, Axel. From bonefish at mail.berlios.de Tue Sep 4 20:42:14 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 20:42:14 +0200 Subject: [Haiku-commits] r22166 - haiku/trunk/headers/build Message-ID: <200709041842.l84IgECl026491@sheep.berlios.de> Author: bonefish Date: 2007-09-04 20:42:13 +0200 (Tue, 04 Sep 2007) New Revision: 22166 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22166&view=rev Modified: haiku/trunk/headers/build/BeOSBuildCompatibility.h Log: Include to fix gcc 4 warning. Modified: haiku/trunk/headers/build/BeOSBuildCompatibility.h =================================================================== --- haiku/trunk/headers/build/BeOSBuildCompatibility.h 2007-09-04 14:10:40 UTC (rev 22165) +++ haiku/trunk/headers/build/BeOSBuildCompatibility.h 2007-09-04 18:42:13 UTC (rev 22166) @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef __x86_64__ #define HAIKU_HOST_PLATFORM_64_BIT From bonefish at mail.berlios.de Tue Sep 4 20:49:09 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 20:49:09 +0200 Subject: [Haiku-commits] r22167 - haiku/trunk/src/build/libroot Message-ID: <200709041849.l84In9Ro027185@sheep.berlios.de> Author: bonefish Date: 2007-09-04 20:49:08 +0200 (Tue, 04 Sep 2007) New Revision: 22167 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22167&view=rev Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp Log: * We mangle the attribute names now, since '/' in attribute names seemed to be problematic. * Changed our xattr attribute namespace to "user.haiku." to prevent xattrs from other programs (e.g. Beagle) to end up on the image. Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-04 18:42:13 UTC (rev 22166) +++ haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-04 18:49:08 UTC (rev 22167) @@ -36,8 +36,8 @@ using std::string; // the namespace all attributes live in -static const char* kAttributeNamespace = "user."; -static const int kAttributeNamespaceLen = 5; +static const char* kAttributeNamespace = "user.haiku."; +static const int kAttributeNamespaceLen = 11; // the maximum length of an attribute listing we support static const int kMaxAttributeListingLength = 10240; @@ -46,7 +46,66 @@ static const int kMaxAttributeLength = 10240 * 4; +// mangle_attribute_name +static string +mangle_attribute_name(const char* name) +{ + // prepend our xattr namespace and translate: + // '/' -> "%\" + // '%' -> "%%" + string mangledName = kAttributeNamespace; + for (int i = 0; name[i] != '\0'; i++) { + char c = name[i]; + switch (c) { + case '/': + mangledName += "%\\"; + break; + case '%': + mangledName += "%%"; + break; + default: + mangledName += c; + break; + } + } + return mangledName; +} + + +// demangle_attribute_name +static bool +demangle_attribute_name(const char* name, string& demangledName) +{ + // chop of our xattr namespace and translate: + // "%\" -> '/' + // "%%" -> '%' + + if (strncmp(name, kAttributeNamespace, kAttributeNamespaceLen) != 0) + return false; + + name += kAttributeNamespaceLen; + + demangledName = ""; + + for (int i = 0; name[i] != '\0'; i++) { + char c = name[i]; + if (c == '%') { + c = name[++i]; + if (c == '%') + demangledName += c; + else if (c == '\\') + demangledName += '/'; + else + return false; + } else + demangledName += c; + } + + return true; +} + + namespace { class AttributeDirectory; @@ -158,10 +217,11 @@ fListingIndex += nameLen + 1; // check the attribute namespace - if (strncmp(name, kAttributeNamespace, kAttributeNamespaceLen) != 0) + string demangledName; + if (!demangle_attribute_name(name, demangledName)) continue; - name += kAttributeNamespaceLen; - nameLen -= kAttributeNamespaceLen; + name = demangledName.c_str(); + nameLen = demangledName.length(); if (nameLen == 0) { // Uh, weird attribute. @@ -393,9 +453,8 @@ return -1; } - // prepend the attribute namespace - string attribute = kAttributeNamespace; - attribute += _attribute; + // mangle the attribute name + string attribute = mangle_attribute_name(_attribute); // read the attribute char attributeBuffer[sizeof(AttributeHeader) + kMaxAttributeLength]; @@ -455,9 +514,8 @@ return -1; } - // prepend the attribute namespace - string attribute = kAttributeNamespace; - attribute += _attribute; + // mangle the attribute name + string attribute = mangle_attribute_name(_attribute); // prepare an attribute buffer char attributeBuffer[sizeof(AttributeHeader) + kMaxAttributeLength]; @@ -500,9 +558,8 @@ return -1; } - // prepend the attribute namespace - string attribute = kAttributeNamespace; - attribute += _attribute; + // mangle the attribute name + string attribute = mangle_attribute_name(_attribute); // remove attribute int result; @@ -538,9 +595,8 @@ return -1; } - // prepend the attribute namespace - string attribute = kAttributeNamespace; - attribute += _attribute; + // mangle the attribute name + string attribute = mangle_attribute_name(_attribute); // read the attribute char attributeBuffer[sizeof(AttributeHeader) + kMaxAttributeLength]; From bonefish at mail.berlios.de Tue Sep 4 20:57:13 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 20:57:13 +0200 Subject: [Haiku-commits] r22168 - haiku/trunk/src/bin/unzip Message-ID: <200709041857.l84IvDDa027594@sheep.berlios.de> Author: bonefish Date: 2007-09-04 20:57:13 +0200 (Tue, 04 Sep 2007) New Revision: 22168 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22168&view=rev Modified: haiku/trunk/src/bin/unzip/beos.c Log: It suffices to open a node read-only to write its attributes. In fact open() is supposed to fail for directories when write access is requested. Modified: haiku/trunk/src/bin/unzip/beos.c =================================================================== --- haiku/trunk/src/bin/unzip/beos.c 2007-09-04 18:49:08 UTC (rev 22167) +++ haiku/trunk/src/bin/unzip/beos.c 2007-09-04 18:57:13 UTC (rev 22168) @@ -1107,7 +1107,7 @@ ptr = (unsigned char *)attr_buff; guard = ptr + attr_size; - fd = open( name, O_RDWR | O_NOTRAVERSE ); + fd = open( name, O_RDONLY | O_NOTRAVERSE ); if( fd < 0 ) { return errno; /* should it be -fd ? */ } From bonefish at mail.berlios.de Tue Sep 4 20:59:06 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 20:59:06 +0200 Subject: [Haiku-commits] r22169 - haiku/trunk/src/bin/unzip Message-ID: <200709041859.l84Ix6Kl027659@sheep.berlios.de> Author: bonefish Date: 2007-09-04 20:59:05 +0200 (Tue, 04 Sep 2007) New Revision: 22169 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22169&view=rev Modified: haiku/trunk/src/bin/unzip/unzip.c haiku/trunk/src/bin/unzip/unzip.h Log: Added macro to enabled the -J option even if not compiling under BeOS or MacOS. Modified: haiku/trunk/src/bin/unzip/unzip.c =================================================================== --- haiku/trunk/src/bin/unzip/unzip.c 2007-09-04 18:57:13 UTC (rev 22168) +++ haiku/trunk/src/bin/unzip/unzip.c 2007-09-04 18:59:05 UTC (rev 22169) @@ -1239,7 +1239,7 @@ else uO.jflag = TRUE; break; -#if (defined(__BEOS__) || defined(MACOS)) +#if (defined(__BEOS__) || defined(MACOS) || defined(HAS_JUNK_EXTRA_FIELD_OPTION)) case ('J'): /* Junk BeOS or MacOS file attributes */ if( negative ) { uO.J_flag = FALSE, negative = 0; Modified: haiku/trunk/src/bin/unzip/unzip.h =================================================================== --- haiku/trunk/src/bin/unzip/unzip.h 2007-09-04 18:57:13 UTC (rev 22168) +++ haiku/trunk/src/bin/unzip/unzip.h 2007-09-04 18:59:05 UTC (rev 22169) @@ -422,7 +422,7 @@ int scanimage; /* -I: scan image files */ #endif int jflag; /* -j: junk pathnames (unzip) */ -#if (defined(__BEOS__) || defined(MACOS)) +#if (defined(__BEOS__) || defined(MACOS) || defined(HAS_JUNK_EXTRA_FIELD_OPTION)) int J_flag; /* -J: ignore BeOS/MacOS extra field info (unzip) */ #endif int lflag; /* -12slmv: listing format (zipinfo) */ From bonefish at mail.berlios.de Tue Sep 4 21:04:48 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 21:04:48 +0200 Subject: [Haiku-commits] r22170 - in haiku/trunk/src/tools: . unzip unzip/unix Message-ID: <200709041904.l84J4mRD028129@sheep.berlios.de> Author: bonefish Date: 2007-09-04 21:04:48 +0200 (Tue, 04 Sep 2007) New Revision: 22170 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22170&view=rev Added: haiku/trunk/src/tools/unzip/ haiku/trunk/src/tools/unzip/Jamfile haiku/trunk/src/tools/unzip/unix/ haiku/trunk/src/tools/unzip/unix/unxcfg.h Modified: haiku/trunk/src/tools/Jamfile Log: Support for compiling unzip as a build tool. Modified: haiku/trunk/src/tools/Jamfile =================================================================== --- haiku/trunk/src/tools/Jamfile 2007-09-04 18:59:05 UTC (rev 22169) +++ haiku/trunk/src/tools/Jamfile 2007-09-04 19:04:48 UTC (rev 22170) @@ -86,6 +86,7 @@ SubInclude HAIKU_TOP src tools resattr ; SubInclude HAIKU_TOP src tools rman ; SubInclude HAIKU_TOP src tools translation ; +SubInclude HAIKU_TOP src tools unzip ; SubInclude HAIKU_TOP src tools vmdkheader ; SubInclude HAIKU_TOP src tools unflatten ; Added: haiku/trunk/src/tools/unzip/Jamfile =================================================================== --- haiku/trunk/src/tools/unzip/Jamfile 2007-09-04 18:59:05 UTC (rev 22169) +++ haiku/trunk/src/tools/unzip/Jamfile 2007-09-04 19:04:48 UTC (rev 22170) @@ -0,0 +1,36 @@ +SubDir HAIKU_TOP src tools unzip ; + +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src bin unzip ] ; + +if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { + DEFINES += HAVE_TERMIOS_H=1 HAS_JUNK_EXTRA_FIELD_OPTION=1 ; +} + +USES_BE_API on libunzip.a unzip = true ; + +BuildPlatformStaticLibrary libunzip.a : + crc32.c + ttyio.c + crctab.c + crypt.c + envargs.c + explode.c + extract.c + fileio.c + globals.c + inflate.c + list.c + match.c + process.c + zipinfo.c + beos.c + beosmain.cpp +; + +BuildPlatformMain unzip : + unzip.c + unreduce.c + unshrink.c + : libunzip.a $(HOST_LIBBE) +; + Added: haiku/trunk/src/tools/unzip/unix/unxcfg.h =================================================================== --- haiku/trunk/src/tools/unzip/unix/unxcfg.h 2007-09-04 18:59:05 UTC (rev 22169) +++ haiku/trunk/src/tools/unzip/unix/unxcfg.h 2007-09-04 19:04:48 UTC (rev 22170) @@ -0,0 +1,31 @@ +// That's exactly the BeOS configuration. +#ifndef __BEOS__ +# include /* [cjh]: This is pretty much a generic */ +# include /* POSIX 1003.1 system; see beos/ for */ +# include /* extra code to deal with our extra file */ +# include /* attributes. */ +# include +# include +# define DIRENT +# include +# ifndef DATE_FORMAT +# define DATE_FORMAT DF_MDY /* GRR: customize with locale.h somehow? */ +# endif +# define lenEOL 1 +# define PutNativeEOL *q++ = native(LF); +# define SCREENSIZE(ttrows, ttcols) screensize(ttrows, ttcols) +# define SCREENWIDTH 80 +# define USE_EF_UT_TIME +# define SET_DIR_ATTRIB +# if (!defined(NOTIMESTAMP) && !defined(TIMESTAMP)) +# define TIMESTAMP +# endif +# define RESTORE_UIDGID +# define NO_STRNICMP /* not in the x86 headers at least */ +# define INT_SPRINTF +# define SYMLINKS +# define MAIN main_stub /* now that we're using a wrapper... */ +# ifndef EOK +# define EOK B_OK +# endif +#endif // __BEOS__ From axeld at mail.berlios.de Tue Sep 4 23:36:00 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 4 Sep 2007 23:36:00 +0200 Subject: [Haiku-commits] r22171 - in haiku/trunk/src/bin/network: . atftpd Message-ID: <200709042136.l84La0P8005730@sheep.berlios.de> Author: axeld Date: 2007-09-04 23:35:58 +0200 (Tue, 04 Sep 2007) New Revision: 22171 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22171&view=rev Added: haiku/trunk/src/bin/network/atftpd/ haiku/trunk/src/bin/network/atftpd/Jamfile haiku/trunk/src/bin/network/atftpd/LICENSE haiku/trunk/src/bin/network/atftpd/argz.c haiku/trunk/src/bin/network/atftpd/argz.h haiku/trunk/src/bin/network/atftpd/config.h haiku/trunk/src/bin/network/atftpd/logger.c haiku/trunk/src/bin/network/atftpd/logger.h haiku/trunk/src/bin/network/atftpd/options.c haiku/trunk/src/bin/network/atftpd/options.h haiku/trunk/src/bin/network/atftpd/stats.c haiku/trunk/src/bin/network/atftpd/stats.h haiku/trunk/src/bin/network/atftpd/tftp_def.c haiku/trunk/src/bin/network/atftpd/tftp_def.h haiku/trunk/src/bin/network/atftpd/tftp_io.c haiku/trunk/src/bin/network/atftpd/tftp_io.h haiku/trunk/src/bin/network/atftpd/tftpd.c haiku/trunk/src/bin/network/atftpd/tftpd.h haiku/trunk/src/bin/network/atftpd/tftpd_file.c haiku/trunk/src/bin/network/atftpd/tftpd_list.c haiku/trunk/src/bin/network/atftpd/tftpd_mcast.c haiku/trunk/src/bin/network/atftpd/tftpd_mtftp.c haiku/trunk/src/bin/network/atftpd/tftpd_mtftp.h haiku/trunk/src/bin/network/atftpd/tftpd_pcre.c haiku/trunk/src/bin/network/atftpd/tftpd_pcre.h Modified: haiku/trunk/src/bin/network/Jamfile Log: Ported over atftpd from Linux - should work on BSD as well, now. Not yet tested, and it will probably not work correctly until we support IP_RECVDSTADDR correctly (we don't support that CMSG stuff yet). Modified: haiku/trunk/src/bin/network/Jamfile =================================================================== --- haiku/trunk/src/bin/network/Jamfile 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/Jamfile 2007-09-04 21:35:58 UTC (rev 22171) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src bin network ; SubInclude HAIKU_TOP src bin network arp ; +SubInclude HAIKU_TOP src bin network atftpd ; SubInclude HAIKU_TOP src bin network ftp ; SubInclude HAIKU_TOP src bin network ifconfig ; SubInclude HAIKU_TOP src bin network login ; Added: haiku/trunk/src/bin/network/atftpd/Jamfile =================================================================== --- haiku/trunk/src/bin/network/atftpd/Jamfile 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/Jamfile 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,19 @@ +SubDir HAIKU_TOP src bin network atftpd ; + +UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; + +BinCommand atftpd : + argz.c + logger.c + options.c + stats.c + tftp_def.c + tftp_io.c + tftpd.c + tftpd_file.c + tftpd_list.c + tftpd_mcast.c + tftpd_mtftp.c + tftpd_pcre.c + : libbsd.so $(TARGET_NETWORK_LIBS) +; Added: haiku/trunk/src/bin/network/atftpd/LICENSE =================================================================== --- haiku/trunk/src/bin/network/atftpd/LICENSE 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/LICENSE 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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/trunk/src/bin/network/atftpd/argz.c =================================================================== --- haiku/trunk/src/bin/network/atftpd/argz.c 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/argz.c 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,132 @@ +/* + * argz.h + * The functions below are "borrowed" from glibc-2.2.3 (argz-next.c). + * This has been done to make atftp compile with uclibc, BSD, Solaris + * and other platform without glic + * + * + * $Id: argz.c,v 1.1 2003/01/21 01:38:35 jp Exp $ + * + * Copyright (c) 2000 Jean-Pierre Lefebvre + * and Remi Lefebvre + * + * atftp is free software; you can redistribute them and/or modify them + * 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. + * + */ + +#ifndef HAVE_ARGZ + +/* Routines for dealing with '\0' separated arg vectors. + Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "argz.h" + +char * argz_next (const char *argz, size_t argz_len, const char *entry) +{ + if (entry) + { + if (entry < argz + argz_len) + entry = strchr (entry, '\0') + 1; + + return entry >= argz + argz_len ? NULL : (char *) entry; + } + else + if (argz_len > 0) + return (char *) argz; + else + return NULL; +} + +error_t argz_create_sep (const char *string, int delim, char **argz, size_t *len) +{ + size_t nlen = strlen (string) + 1; + + if (nlen > 1) + { + const char *rp; + char *wp; + + *argz = (char *) malloc (nlen); + if (*argz == NULL) + return ENOMEM; + + rp = string; + wp = *argz; + do + if (*rp == delim) + { + if (wp > *argz && wp[-1] != '\0') + *wp++ = '\0'; + else + --nlen; + } + else + *wp++ = *rp; + while (*rp++ != '\0'); + + if (nlen == 0) + { + free (*argz); + *argz = NULL; + *len = 0; + } + + *len = nlen; + } + else + { + *argz = NULL; + *len = 0; + } + + return 0; +} + +size_t argz_count (const char *argz, size_t len) +{ + size_t count = 0; + while (len > 0) + { + size_t part_len = strlen(argz); + argz += part_len + 1; + len -= part_len + 1; + count++; + } + return count; +} + +/* Puts pointers to each string in ARGZ, plus a terminating 0 element, into + ARGV, which must be large enough to hold them all. */ +void argz_extract (const char *argz, size_t len, char **argv) +{ + while (len > 0) + { + size_t part_len = strlen (argz); + *argv++ = (char *) argz; + argz += part_len + 1; + len -= part_len + 1; + } + *argv = 0; +} + +#endif Added: haiku/trunk/src/bin/network/atftpd/argz.h =================================================================== --- haiku/trunk/src/bin/network/atftpd/argz.h 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/argz.h 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,211 @@ +/* + * argz.h + * Source file borrowed from glibc-2.2.3. This has been done to make + * atftp compile with uclibc, BSD, Solaris and other platform without + * glic + * + * $Id: argz.h,v 1.1 2003/01/21 01:38:35 jp Exp $ + * + * Copyright (c) 2000 Jean-Pierre Lefebvre + * and Remi Lefebvre + * + * atftp is free software; you can redistribute them and/or modify them + * 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. + * + */ + +/* Routines for dealing with '\0' separated arg vectors. + Copyright (C) 1995, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ARGZ_H +#define _ARGZ_H 1 + +//#include + +#include + +#define __need_error_t +#include +#include /* Need size_t, and strchr is called below. */ + +#ifndef __const +# define __const const +#endif + +#ifndef __error_t_defined +typedef int error_t; +#endif + +#define __THROW +#define __restrict +#define __attribute_pure__ +#define __BEGIN_DECLS + +__BEGIN_DECLS + +/* Make a '\0' separated arg vector from a unix argv vector, returning it in + ARGZ, and the total length in LEN. If a memory allocation error occurs, + ENOMEM is returned, otherwise 0. The result can be destroyed using free. */ +extern error_t __argz_create (char *__const __argv[], char **__restrict __argz, + size_t *__restrict __len) __THROW; +extern error_t argz_create (char *__const __argv[], char **__restrict __argz, + size_t *__restrict __len) __THROW; + +/* Make a '\0' separated arg vector from a SEP separated list in + STRING, returning it in ARGZ, and the total length in LEN. If a + memory allocation error occurs, ENOMEM is returned, otherwise 0. + The result can be destroyed using free. */ +extern error_t __argz_create_sep (__const char *__restrict __string, + int __sep, char **__restrict __argz, + size_t *__restrict __len) __THROW; +extern error_t argz_create_sep (__const char *__restrict __string, + int __sep, char **__restrict __argz, + size_t *__restrict __len) __THROW; + +/* Returns the number of strings in ARGZ. */ +extern size_t __argz_count (__const char *__argz, size_t __len) + __THROW __attribute_pure__; +extern size_t argz_count (__const char *__argz, size_t __len) + __THROW __attribute_pure__; + +/* Puts pointers to each string in ARGZ into ARGV, which must be large enough + to hold them all. */ +extern void __argz_extract (__const char *__restrict __argz, size_t __len, + char **__restrict __argv) __THROW; +extern void argz_extract (__const char *__restrict __argz, size_t __len, + char **__restrict __argv) __THROW; + +/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's + except the last into the character SEP. */ +extern void __argz_stringify (char *__argz, size_t __len, int __sep) __THROW; +extern void argz_stringify (char *__argz, size_t __len, int __sep) __THROW; + +/* Append BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN. */ +extern error_t __argz_append (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __buf, size_t _buf_len) + __THROW; +extern error_t argz_append (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __buf, size_t __buf_len) + __THROW; + +/* Append STR to the argz vector in ARGZ & ARGZ_LEN. */ +extern error_t __argz_add (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __str) __THROW; +extern error_t argz_add (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __str) __THROW; + +/* Append SEP separated list in STRING to the argz vector in ARGZ & + ARGZ_LEN. */ +extern error_t __argz_add_sep (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __string, int __delim) + __THROW; +extern error_t argz_add_sep (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __string, int __delim) + __THROW; + +/* Delete ENTRY from ARGZ & ARGZ_LEN, if it appears there. */ +extern void __argz_delete (char **__restrict __argz, + size_t *__restrict __argz_len, + char *__restrict __entry) __THROW; +extern void argz_delete (char **__restrict __argz, + size_t *__restrict __argz_len, + char *__restrict __entry) __THROW; + +/* Insert ENTRY into ARGZ & ARGZ_LEN before BEFORE, which should be an + existing entry in ARGZ; if BEFORE is NULL, ENTRY is appended to the end. + Since ARGZ's first entry is the same as ARGZ, argz_insert (ARGZ, ARGZ_LEN, + ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ. If BEFORE is not + in ARGZ, EINVAL is returned, else if memory can't be allocated for the new + ARGZ, ENOMEM is returned, else 0. */ +extern error_t __argz_insert (char **__restrict __argz, + size_t *__restrict __argz_len, + char *__restrict __before, + __const char *__restrict __entry) __THROW; +extern error_t argz_insert (char **__restrict __argz, + size_t *__restrict __argz_len, + char *__restrict __before, + __const char *__restrict __entry) __THROW; + +/* Replace any occurrences of the string STR in ARGZ with WITH, reallocating + ARGZ as necessary. If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be + incremented by number of replacements performed. */ +extern error_t __argz_replace (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __str, + __const char *__restrict __with, + unsigned int *__restrict __replace_count); +extern error_t argz_replace (char **__restrict __argz, + size_t *__restrict __argz_len, + __const char *__restrict __str, + __const char *__restrict __with, + unsigned int *__restrict __replace_count); + +/* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there + are no more. If entry is NULL, then the first entry is returned. This + behavior allows two convenient iteration styles: + + char *entry = 0; + while ((entry = argz_next (argz, argz_len, entry))) + ...; + + or + + char *entry; + for (entry = argz; entry; entry = argz_next (argz, argz_len, entry)) + ...; +*/ +extern char *__argz_next (__const char *__restrict __argz, size_t __argz_len, + __const char *__restrict __entry) __THROW; +extern char *argz_next (__const char *__restrict __argz, size_t __argz_len, + __const char *__restrict __entry) __THROW; + +#ifdef __USE_EXTERN_INLINES +extern inline char * +__argz_next (__const char *__argz, size_t __argz_len, + __const char *__entry) __THROW +{ + if (__entry) + { + if (__entry < __argz + __argz_len) + __entry = strchr (__entry, '\0') + 1; + + return __entry >= __argz + __argz_len ? (char *) NULL : (char *) __entry; + } + else + return __argz_len > 0 ? (char *) __argz : 0; +} +extern inline char * +argz_next (__const char *__argz, size_t __argz_len, + __const char *__entry) __THROW +{ + return __argz_next (__argz, __argz_len, __entry); +} +#endif /* Use extern inlines. */ + +__END_DECLS + +#endif /* argz.h */ Added: haiku/trunk/src/bin/network/atftpd/config.h =================================================================== --- haiku/trunk/src/bin/network/atftpd/config.h 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/config.h 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,7 @@ +#include + +#define HAVE_MTFTP 1 +//#undef HAVE_PCRE +//#undef HAVE_WRAP + +#define VERSION "0.7" Added: haiku/trunk/src/bin/network/atftpd/logger.c =================================================================== --- haiku/trunk/src/bin/network/atftpd/logger.c 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/logger.c 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,137 @@ +/* hey emacs! -*- Mode: C; c-file-style: "k&r"; indent-tabs-mode: nil -*- */ +/* + * logger.c + * functions for logging messages. + * + * $Id: logger.c,v 1.12 2004/02/27 02:05:26 jp Exp $ + * + * Copyright (c) 2000 Jean-Pierre Lefebvre + * and Remi Lefebvre + * + * atftp is free software; you can redistribute them and/or modify them + * 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. + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "logger.h" + +#define MAXLEN 128 + +static int log_syslog_is_open = 0; +static int log_priority = 0; +static char *log_filename = NULL; +static int log_fd; +static FILE *log_fp = NULL; +static char *log_ident; + +/* + * Open a file for logging. If filename is NULL, then use + * stderr for the client or the syslog for the server. Log + * only message less or equal to priority. + */ +void open_logger(char *ident, char *filename, int priority) +{ + close_logger(); /* make sure we initialise variables and close + previously opened log. */ + + log_priority = priority; + + if (ident) + log_ident = strdup(ident); + else + log_ident = "unset"; + + if (filename) + log_filename = strdup(filename); + else + { + openlog(log_ident, LOG_PID, LOG_DAEMON); + log_syslog_is_open = 1; + } + + if (log_filename) + { + if ((log_fd = open(log_filename, O_WRONLY | O_APPEND)) < 0) + { + openlog(log_ident, LOG_PID, LOG_DAEMON); + log_syslog_is_open = 1; + logger(LOG_CRIT, "Unable to open %s for logging, " + "reverting to syslog", log_filename); + } + else + log_fp = fdopen(log_fd, "a"); + } +} + +/* + * Same as syslog but allow to format a string, like printf, when logging to + * file. This fonction will either call syslog or fprintf depending of the + * previous call to open_logger(). + */ +void logger(int severity, const char *fmt, ...) +{ + char message[MAXLEN]; + char time_buf[MAXLEN]; + char hostname[MAXLEN]; + time_t t; + struct tm *tm; + + + va_list args; + va_start(args, fmt); + + time(&t); + tm = localtime(&t); + strftime(time_buf, MAXLEN, "%b %d %H:%M:%S", tm); + gethostname(hostname, MAXLEN); + + if (severity <= log_priority) + { + vsnprintf(message, sizeof(message), fmt, args); + + if (log_fp) + { + fprintf(log_fp, "%s %s %s[%d.%d]: %s\n", time_buf, hostname, + log_ident, getpid(), pthread_self(), message); + fflush(log_fp); + } + else if (log_syslog_is_open) + syslog(severity, "%s", message); + else + fprintf(stderr, "%s %s %s[%d.%d]: %s\n", time_buf, hostname, + log_ident, getpid(), pthread_self(), message); + } + va_end(args); +} + +/* + * Close the file or syslog. Initialise variables. + */ +void close_logger(void) +{ + log_priority = 0; + if (log_syslog_is_open) + closelog(); + log_syslog_is_open = 0; + if (log_fp) + fclose(log_fp); + log_fp = NULL; + if (log_filename) + free(log_filename); + log_filename = NULL; + if (log_ident) + free(log_ident); +} Added: haiku/trunk/src/bin/network/atftpd/logger.h =================================================================== --- haiku/trunk/src/bin/network/atftpd/logger.h 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/logger.h 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,26 @@ +/* hey emacs! -*- Mode: C; c-file-style: "k&r"; indent-tabs-mode: nil -*- */ +/* + * logger.h + * + * $Id: logger.h,v 1.6 2000/12/27 00:57:16 remi Exp $ + * + * Copyright (c) 2000 Jean-Pierre Lefebvre + * and Remi Lefebvre + * + * atftp is free software; you can redistribute them and/or modify them + * 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. + * + */ + +#ifndef logger_h +#define logger_h + +#include + +void open_logger(char *ident, char *filename, int priority); +void logger(int severity, const char *fmt, ...); +void close_logger(void); + +#endif Added: haiku/trunk/src/bin/network/atftpd/options.c =================================================================== --- haiku/trunk/src/bin/network/atftpd/options.c 2007-09-04 19:04:48 UTC (rev 22170) +++ haiku/trunk/src/bin/network/atftpd/options.c 2007-09-04 21:35:58 UTC (rev 22171) @@ -0,0 +1,356 @@ +/* hey emacs! -*- Mode: C; c-file-style: "k&r"; indent-tabs-mode: nil -*- */ +/* + * options.c + * Set of functions to deal with the options structure and for parsing + * options in TFTP data buffer. + * + * $Id: options.c,v 1.16 2003/04/25 00:16:18 jp Exp $ + * + * Copyright (c) 2000 Jean-Pierre Lefebvre + * and Remi Lefebvre + * + * atftp is free software; you can redistribute them and/or modify them + * 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. + * + */ + +#include "config.h" + +#include +#include +#include +#include + +#if HAVE_ARGZ +#include +#else +#include "argz.h" +#endif + +#include +#include +#include "options.h" + +/* + * Fill a structure with the request packet of the client. + */ +int opt_parse_request(char *data, int data_size, struct tftp_opt *options) +{ + char *entry = NULL; + char *tmp; + struct tftphdr *tftp_data = (struct tftphdr *)data; + size_t size = data_size - sizeof(tftp_data->th_opcode); + + /* read filename */ + entry = argz_next(tftp_data->th_stuff, size, entry); + if (!entry) + return ERR; + else + opt_set_options(options, "filename", entry); + /* read mode */ + entry = argz_next(tftp_data->th_stuff, size, entry); + if (!entry) + return ERR; + else + opt_set_options(options, "mode", entry); + /* scan for options */ + // FIXME: we should use opt_parse_options() here + while ((entry = argz_next(tftp_data->th_stuff, size, entry))) + { + tmp = entry; + entry = argz_next(tftp_data->th_stuff, size, entry); + if (!entry) + return ERR; + else + opt_set_options(options, tmp, entry); + } [... truncated: 5561 lines follow ...] From axeld at mail.berlios.de Tue Sep 4 23:36:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 4 Sep 2007 23:36:59 +0200 Subject: [Haiku-commits] r22172 - haiku/trunk/headers/posix/sys Message-ID: <200709042136.l84Lax7V005794@sheep.berlios.de> Author: axeld Date: 2007-09-04 23:36:59 +0200 (Tue, 04 Sep 2007) New Revision: 22172 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22172&view=rev Modified: haiku/trunk/headers/posix/sys/param.h haiku/trunk/headers/posix/sys/socket.h Log: * Added _ALIGN() and _ALIGNBYTES macros. * Added cmsg macros. * Minor cleanup. Modified: haiku/trunk/headers/posix/sys/param.h =================================================================== --- haiku/trunk/headers/posix/sys/param.h 2007-09-04 21:35:58 UTC (rev 22171) +++ haiku/trunk/headers/posix/sys/param.h 2007-09-04 21:36:59 UTC (rev 22172) @@ -1,26 +1,33 @@ +/* + * Copyright 2002-2007, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _SYS_PARAM_H #define _SYS_PARAM_H -/* -** Distributed under the terms of the OpenBeOS License. -*/ + #include + #define MAXPATHLEN PATH_MAX #define MAXSYMLINKS SYMLOOP_MAX #define NOFILE OPEN_MAX #ifndef MIN - #define MIN(a,b) (((a) < (b)) ? (a) : (b)) +# define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX - #define MAX(a,b) (((a) > (b)) ? (a) : (b)) +# define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif +#define _ALIGNBYTES (sizeof(long) - 1) +#define _ALIGN(p) \ + (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) + /* maximum possible length of this machine's hostname */ #ifndef MAXHOSTNAMELEN - #define MAXHOSTNAMELEN 256 +# define MAXHOSTNAMELEN 256 #endif #endif /* _SYS_PARAM_H */ Modified: haiku/trunk/headers/posix/sys/socket.h =================================================================== --- haiku/trunk/headers/posix/sys/socket.h 2007-09-04 21:35:58 UTC (rev 22171) +++ haiku/trunk/headers/posix/sys/socket.h 2007-09-04 21:36:59 UTC (rev 22172) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006, Haiku Inc. All Rights Reserved. + * Copyright 2002-2007, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _SYS_SOCKET_H @@ -122,17 +122,36 @@ /* data follows */ }; +/* cmsghdr access macros */ +#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) \ + + _ALIGN(sizeof(struct cmsghdr))) +#define CMSG_NXTHDR(mhdr, cmsg) \ + (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) \ + + _ALIGN(sizeof(struct cmsghdr)) \ + > (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) \ + ? (struct cmsghdr *)NULL \ + : (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len))) +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) \ + ? (struct cmsghdr *)(mhdr)->msg_control \ + : (struct cmsghdr *)NULL) + #if __cplusplus extern "C" { #endif int accept(int socket, struct sockaddr *address, socklen_t *_addressLength); -int bind(int socket, const struct sockaddr *address, socklen_t addressLength); -int connect(int socket, const struct sockaddr *address, socklen_t addressLength); -int getpeername(int socket, struct sockaddr *address, socklen_t *_addressLength); -int getsockname(int socket, struct sockaddr *address, socklen_t *_addressLength); -int getsockopt(int socket, int level, int option, void *value, socklen_t *_length); +int bind(int socket, const struct sockaddr *address, + socklen_t addressLength); +int connect(int socket, const struct sockaddr *address, + socklen_t addressLength); +int getpeername(int socket, struct sockaddr *address, + socklen_t *_addressLength); +int getsockname(int socket, struct sockaddr *address, + socklen_t *_addressLength); +int getsockopt(int socket, int level, int option, void *value, + socklen_t *_length); int listen(int socket, int backlog); ssize_t recv(int socket, void *buffer, size_t length, int flags); ssize_t recvfrom(int socket, void *buffer, size_t bufferLength, int flags, @@ -142,7 +161,8 @@ ssize_t sendmsg(int socket, const struct msghdr *message, int flags); ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *address, socklen_t addressLength); -int setsockopt(int socket, int level, int option, const void *value, socklen_t length); +int setsockopt(int socket, int level, int option, const void *value, + socklen_t length); int shutdown(int socket, int how); int socket(int domain, int type, int protocol); int sockatmark(int socket); From bonefish at mail.berlios.de Tue Sep 4 23:50:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Sep 2007 23:50:01 +0200 Subject: [Haiku-commits] r22173 - in haiku/trunk/build: jam scripts Message-ID: <200709042150.l84Lo1qT006407@sheep.berlios.de> Author: bonefish Date: 2007-09-04 23:50:00 +0200 (Tue, 04 Sep 2007) New Revision: 22173 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22173&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/jam/UserBuildConfig.sample haiku/trunk/build/scripts/build_haiku_image Log: Added support for unzipping archives onto the Haiku image. The new rule to do that is UnzipArchiveToHaikuImage. Cf. UserBuildConfig.sample for a usage example. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-09-04 21:36:59 UTC (rev 22172) +++ haiku/trunk/build/jam/HaikuImage 2007-09-04 21:50:00 UTC (rev 22173) @@ -449,6 +449,7 @@ AddTargetVariableToScript $(script) : makebootable ; AddTargetVariableToScript $(script) : rc ; AddTargetVariableToScript $(script) : resattr ; +AddTargetVariableToScript $(script) : unzip ; #AddTargetVariableToScript $(script) : $(HAIKU_IMAGE) : imagePath ; # causes a cyclic dependency AddVariableToScript $(script) : imagePath @@ -459,11 +460,13 @@ # create the other scripts HAIKU_IMAGE_MAKE_DIRS_SCRIPT = haiku.image-make-dirs ; HAIKU_IMAGE_COPY_FILES_SCRIPT = haiku.image-copy-files ; +HAIKU_IMAGE_UNZIP_FILES_SCRIPT = haiku.image-unzip-files ; MakeLocate $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) $(HAIKU_IMAGE_COPY_FILES_SCRIPT) - : $(HAIKU_OUTPUT_DIR) ; + $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) : $(HAIKU_OUTPUT_DIR) ; CreateHaikuImageMakeDirectoriesScript $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) ; CreateHaikuImageCopyFilesScript $(HAIKU_IMAGE_COPY_FILES_SCRIPT) ; +CreateHaikuImageUnzipFilesScript $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) ; # Convenience wrapper rule around BuildHaikuImage. rule _BuildHaikuImage @@ -481,6 +484,7 @@ $(HAIKU_IMAGE_EARLY_USER_SCRIPTS) $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) $(HAIKU_IMAGE_COPY_FILES_SCRIPT) + $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) $(HAIKU_IMAGE_LATE_USER_SCRIPTS) : $(isImage) ; @@ -490,6 +494,7 @@ $(HAIKU_IMAGE_INIT_VARIABLES_SCRIPT) $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) $(HAIKU_IMAGE_COPY_FILES_SCRIPT) + $(HAIKU_IMAGE_UNZIP_FILES_SCRIPT) ; } Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2007-09-04 21:36:59 UTC (rev 22172) +++ haiku/trunk/build/jam/ImageRules 2007-09-04 21:50:00 UTC (rev 22173) @@ -202,6 +202,17 @@ SYMLINKS_TO_INSTALL on $(directory) += $(link) ; } +rule UnzipArchiveToContainer container : directoryTokens : zipFile +{ + # UnzipArchiveToContainer : : ] ; + # + + local directory = [ AddDirectoryToContainer $(container) + : $(directoryTokens) ] ; + + ZIP_FILES_TO_INSTALL on $(directory) += $(zipFile) ; +} + rule AddDriversToContainer container : relativeDirectoryTokens : targets { # AddDriversToContainer : : ; @@ -441,6 +452,45 @@ } +rule CreateContainerUnzipFilesScript container : script +{ + MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; + Always $(script) ; + + local initScript = [ InitScript $(script) ] ; + + local scriptBody + = [ FSameTargetWithPrependedGrist $(script) : script-body ] ; + LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ; + Depends $(scriptBody) : $(initScript) ; + Depends $(script) : $(scriptBody) ; + + local dir ; + for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] { + local zipFiles = [ on $(dir) return $(ZIP_FILES_TO_INSTALL) ] ; + local zipFile ; + for zipFile in $(zipFiles) { + # use a unique dummy target for this file, on which we + # can define the TARGET_DIR variable + local dummyTarget = $(script)-dummy-$(dir:G=)-$(zipFile) ; + NotFile $(dummyTarget) ; + TARGET_DIR on $(dummyTarget) = $(dir:G=) ; + + Depends $(dummyTarget) : $(initScript) $(zipFile) ; + Depends $(script) : $(dummyTarget) ; + + AddUnzipFileToContainerUnzipFilesScript $(dummyTarget) + : $(initScript) $(zipFile) ; + } + } +} + +actions AddUnzipFileToContainerUnzipFilesScript +{ + echo unzipFile "\"$(2[2])\"" "\"$(TARGET_DIR)\"" >> $(2[1]) +} + + #pragma mark - Haiku Image rules rule SetUpdateHaikuImageOnly flag @@ -496,6 +546,18 @@ } } +rule UnzipArchiveToHaikuImage dirTokens : zipFile : alwaysUpdate +{ + # UnzipArchiveToHaikuImage : : ; + + # If the image shall only be updated, we unzip only, if explicitely + # requested. + if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) { + UnzipArchiveToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(dirTokens) + : $(zipFile) ; + } +} + rule AddDriversToHaikuImage relativeDirectoryTokens : targets { # AddDriversToHaikuImage : ; @@ -531,6 +593,11 @@ CreateContainerCopyFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ; } +rule CreateHaikuImageUnzipFilesScript script +{ + CreateContainerUnzipFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ; +} + rule BuildHaikuImage haikuImage : scripts : isImage { # BuildHaikuImage : : ; Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2007-09-04 21:36:59 UTC (rev 22172) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2007-09-04 21:50:00 UTC (rev 22173) @@ -63,6 +63,10 @@ AddSourceDirectoryToHaikuImage src/kits/storage ; AddSourceDirectoryToHaikuImage src/tests/servers/debug : 1 ; +# Unzips the given zip archive onto the image under /boot/develop/tools. +UnzipArchiveToHaikuImage develop tools + : /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ; + # Specify scripts that shall be run when populating the image/installation # directory. The "early" script is run before anything has been copied onto # the image/into the installation directory. The "late" script is run after Modified: haiku/trunk/build/scripts/build_haiku_image =================================================================== --- haiku/trunk/build/scripts/build_haiku_image 2007-09-04 21:36:59 UTC (rev 22172) +++ haiku/trunk/build/scripts/build_haiku_image 2007-09-04 21:50:00 UTC (rev 22173) @@ -18,6 +18,7 @@ # makebootable # resattr # rc +# unzip # if [ $# -gt 0 ]; then . $1 @@ -53,6 +54,30 @@ mkindex=mkindex fi + +unzipFile() +{ + # unzipFile + zipFile=$1 + targetUnzipDir=$2 + + echo "Unzipping $zipFile ..." + + if [ $isImage ]; then + unzipDir=$tmpDir/unzip + rm -rf $unzipDir + mkdir -p $unzipDir + + $unzip -q -d $unzipDir $zipFile + $cp -r ${sPrefix}$unzipDir/. ${tPrefix}$targetUnzipDir + + rm -rf $unzipDir + else + $unzip -q -d ${tPrefix}$targetUnzipDir ${sPrefix}$zipFile + fi +} + + # create the image and mount it if [ $isImage ]; then echo From bonefish at cs.tu-berlin.de Wed Sep 5 00:19:03 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Wed, 05 Sep 2007 00:19:03 +0200 Subject: [Haiku-commits] r22171 - in haiku/trunk/src/bin/network: . atftpd In-Reply-To: <200709042136.l84La0P8005730@sheep.berlios.de> References: <200709042136.l84La0P8005730@sheep.berlios.de> Message-ID: <20070905001903.3929.12@cs.tu-berlin.de> On 2007-09-04 at 23:36:00 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2007-09-04 23:35:58 +0200 (Tue, 04 Sep 2007) > New Revision: 22171 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22171&view=rev [...] > Log: > Ported over atftpd from Linux - should work on BSD as well, now. You're not overly fond of vendor branches, are you? They are extremely useful when trying to keep ports up to date in the future. It would be nice, if you could add the vendor version, too. CU, Ingo From leavengood at mail.berlios.de Wed Sep 5 04:47:34 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Wed, 5 Sep 2007 04:47:34 +0200 Subject: [Haiku-commits] r22174 - haiku/trunk/src/apps/stylededit Message-ID: <200709050247.l852lYxW008618@sheep.berlios.de> Author: leavengood Date: 2007-09-05 04:47:33 +0200 (Wed, 05 Sep 2007) New Revision: 22174 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22174&view=rev Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp haiku/trunk/src/apps/stylededit/ColorMenuItem.h haiku/trunk/src/apps/stylededit/FindWindow.h haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp haiku/trunk/src/apps/stylededit/ReplaceWindow.h haiku/trunk/src/apps/stylededit/StyledEditApp.cpp haiku/trunk/src/apps/stylededit/StyledEditApp.h haiku/trunk/src/apps/stylededit/StyledEditView.h haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp haiku/trunk/src/apps/stylededit/StyledEditWindow.h Log: Additional style fixes from Julun: adding back the virtual keyword, moving the commas on class member initializers, fixing a typo. Thanks! Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.cpp 2007-09-05 02:47:33 UTC (rev 22174) @@ -12,8 +12,8 @@ #include ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *message) - : BMenuItem(label, message, 0, 0) - , fItemColor(color) + : BMenuItem(label, message, 0, 0), + fItemColor(color) { } Modified: haiku/trunk/src/apps/stylededit/ColorMenuItem.h =================================================================== --- haiku/trunk/src/apps/stylededit/ColorMenuItem.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/ColorMenuItem.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -18,11 +18,14 @@ class ColorMenuItem: public BMenuItem { public: - ColorMenuItem(const char *label, rgb_color color, BMessage *message); - void DrawContent(); + ColorMenuItem(const char *label, rgb_color color, + BMessage *message); + protected: + virtual void DrawContent(); + private: - rgb_color fItemColor; + rgb_color fItemColor; }; #endif // COLOR_MENU_ITEM_H Modified: haiku/trunk/src/apps/stylededit/FindWindow.h =================================================================== --- haiku/trunk/src/apps/stylededit/FindWindow.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/FindWindow.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -24,8 +24,8 @@ FindWindow(BRect frame, BHandler* handler, BString *searchString, bool caseState, bool wrapState, bool backState); - void MessageReceived(BMessage* message); - void DispatchMessage(BMessage* message, BHandler* handler); + virtual void MessageReceived(BMessage* message); + virtual void DispatchMessage(BMessage* message, BHandler* handler); private: void _SendMessage(); Modified: haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/ReplaceWindow.cpp 2007-09-05 02:47:33 UTC (rev 22174) @@ -116,8 +116,10 @@ fBackSearchBox->SetEnabled(fUIchange); fReplaceButton->SetEnabled(fUIchange); - fUIchange ? fReplaceButton->MakeDefault(true) - : fReplaceAllButton->MakeDefault(true); + if (fUIchange) + fReplaceButton->MakeDefault(true); + else + fReplaceAllButton->MakeDefault(true); fUIchange = !fUIchange; } Modified: haiku/trunk/src/apps/stylededit/ReplaceWindow.h =================================================================== --- haiku/trunk/src/apps/stylededit/ReplaceWindow.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/ReplaceWindow.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -24,12 +24,12 @@ class ReplaceWindow : public BWindow { public: - ReplaceWindow(BRect frame, BHandler *_handler, - BString *searchString, BString *replaceString, - bool caseState, bool wrapState, bool backState); + ReplaceWindow(BRect frame, BHandler *_handler, + BString *searchString, BString *replaceString, + bool caseState, bool wrapState, bool backState); - void MessageReceived(BMessage* message); - void DispatchMessage(BMessage* message, BHandler *handler); + virtual void MessageReceived(BMessage* message); + virtual void DispatchMessage(BMessage* message, BHandler *handler); private: void _SendMessage(uint32 what); Modified: haiku/trunk/src/apps/stylededit/StyledEditApp.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditApp.cpp 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/StyledEditApp.cpp 2007-09-05 02:47:33 UTC (rev 22174) @@ -79,8 +79,8 @@ StyledEditApp::StyledEditApp() - : BApplication(APP_SIGNATURE) - , fOpenPanel(NULL) + : BApplication(APP_SIGNATURE), + fOpenPanel(NULL) { fOpenPanel = new BFilePanel(); BMenuBar *menuBar = Modified: haiku/trunk/src/apps/stylededit/StyledEditApp.h =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditApp.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/StyledEditApp.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -24,29 +24,29 @@ class StyledEditApp : public BApplication { public: - StyledEditApp(); - ~StyledEditApp(); + StyledEditApp(); + virtual ~StyledEditApp(); - void MessageReceived(BMessage *message); - void RefsReceived(BMessage *message); - void ReadyToRun(); + virtual void MessageReceived(BMessage *message); + virtual void RefsReceived(BMessage *message); + virtual void ReadyToRun(); - void DispatchMessage(BMessage *an_event, BHandler *handler); + virtual void DispatchMessage(BMessage *an_event, BHandler *handler); - int32 NumberOfWindows(); - void OpenDocument(); - void OpenDocument(entry_ref * ref); - void CloseDocument(); + int32 NumberOfWindows(); + void OpenDocument(); + void OpenDocument(entry_ref *ref); + void CloseDocument(); private: - void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd); + void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd); private: - BFilePanel *fOpenPanel; - BMenu *fOpenPanelEncodingMenu; - uint32 fOpenAsEncoding; - int32 fWindowCount; - int32 fNextUntitledWindow; + BFilePanel *fOpenPanel; + BMenu *fOpenPanelEncodingMenu; + uint32 fOpenAsEncoding; + int32 fWindowCount; + int32 fNextUntitledWindow; }; Modified: haiku/trunk/src/apps/stylededit/StyledEditView.h =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/StyledEditView.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -17,16 +17,20 @@ class BFile; class BHandler; -class BMessanger; +class BMessenger; class StyledEditView : public BTextView { public: - StyledEditView(BRect viewframe, BRect textframe, - BHandler *handler); - ~StyledEditView(); + StyledEditView(BRect viewframe, BRect textframe, + BHandler *handler); + virtual ~StyledEditView(); - void Select(int32 start, int32 finish); + virtual void Select(int32 start, int32 finish); + virtual void DeleteText(int32 start, int32 finish); + virtual void FrameResized(float width, float height); + virtual void InsertText(const char *text, int32 length, int32 offset, + const text_run_array *runs = NULL); void Reset(); status_t GetStyledText(BPositionIO * stream); @@ -36,11 +40,6 @@ uint32 GetEncoding() const; private: - void DeleteText(int32 start, int32 finish); - void FrameResized(float width, float height); - void InsertText(const char *text, int32 length, int32 offset, - const text_run_array *runs = NULL); - BMessenger *fMessenger; bool fSuppressChanges; BString fEncoding; Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/StyledEditWindow.cpp 2007-09-05 02:47:33 UTC (rev 22174) @@ -29,11 +29,11 @@ #include #include #include +#include #include #include #include #include -#include #include Modified: haiku/trunk/src/apps/stylededit/StyledEditWindow.h =================================================================== --- haiku/trunk/src/apps/stylededit/StyledEditWindow.h 2007-09-04 21:50:00 UTC (rev 22173) +++ haiku/trunk/src/apps/stylededit/StyledEditWindow.h 2007-09-05 02:47:33 UTC (rev 22174) @@ -30,12 +30,12 @@ public: StyledEditWindow(BRect frame, int32 id, uint32 encoding = 0); StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding = 0); - ~StyledEditWindow(); + virtual ~StyledEditWindow(); - void Quit(); - bool QuitRequested(); - void MessageReceived(BMessage *message); - void MenusBeginning(); + virtual void Quit(); + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + virtual void MenusBeginning(); status_t Save(BMessage *message = 0); status_t SaveAs(BMessage *message = 0); From bonefish at mail.berlios.de Wed Sep 5 04:54:24 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 04:54:24 +0200 Subject: [Haiku-commits] r22175 - haiku/trunk/headers/build Message-ID: <200709050254.l852sOaQ008781@sheep.berlios.de> Author: bonefish Date: 2007-09-05 04:54:24 +0200 (Wed, 05 Sep 2007) New Revision: 22175 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22175&view=rev Modified: haiku/trunk/headers/build/BeOSBuildCompatibility.h Log: needs to be included for O_NOFOLLOW. Modified: haiku/trunk/headers/build/BeOSBuildCompatibility.h =================================================================== --- haiku/trunk/headers/build/BeOSBuildCompatibility.h 2007-09-05 02:47:33 UTC (rev 22174) +++ haiku/trunk/headers/build/BeOSBuildCompatibility.h 2007-09-05 02:54:24 UTC (rev 22175) @@ -5,8 +5,10 @@ #define addr_t haiku_build_addr_t #include + +#include +#include #include -#include #include #ifdef __x86_64__ From bonefish at mail.berlios.de Wed Sep 5 04:58:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 04:58:01 +0200 Subject: [Haiku-commits] r22176 - haiku/trunk/src/build/libroot Message-ID: <200709050258.l852w1Ap008922@sheep.berlios.de> Author: bonefish Date: 2007-09-05 04:58:01 +0200 (Wed, 05 Sep 2007) New Revision: 22176 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22176&view=rev Modified: haiku/trunk/src/build/libroot/fs.cpp Log: * Fixed bug in the code normalizing entry paths, causing e.g. broken symlinks to be not openable. * When _kern_open() created a new file, invalid stat data were accessed. Modified: haiku/trunk/src/build/libroot/fs.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs.cpp 2007-09-05 02:54:24 UTC (rev 22175) +++ haiku/trunk/src/build/libroot/fs.cpp 2007-09-05 02:58:01 UTC (rev 22176) @@ -159,7 +159,7 @@ } // catch special case: no leaf, or leaf is a directory - if (!leafName || strcmp(leafName, ".") == 0 || strcmp(leafName, "..")) + if (!leafName || strcmp(leafName, ".") == 0 || strcmp(leafName, "..") == 0) return normalize_dir_path(path, normalizedPath); // normalize the dir path @@ -514,7 +514,7 @@ } // cache path, if this is a directory - if (S_ISDIR(st.st_mode)) + if (exists && S_ISDIR(st.st_mode)) add_dir_path(path, NodeRef(st)); return add_descriptor(descriptor); From bonefish at mail.berlios.de Wed Sep 5 04:59:27 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 04:59:27 +0200 Subject: [Haiku-commits] r22177 - haiku/trunk/src/build/libroot Message-ID: <200709050259.l852xRUV009038@sheep.berlios.de> Author: bonefish Date: 2007-09-05 04:59:27 +0200 (Wed, 05 Sep 2007) New Revision: 22177 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22177&view=rev Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp Log: Added support for fs_fopen_attr_dir() on symlinks (if they were opened with _kern_open()). Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-05 02:58:01 UTC (rev 22176) +++ haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-05 02:59:27 UTC (rev 22177) @@ -170,6 +170,26 @@ sAttributeDirectories[fFakeDir] = this; } + string tempPath; + if (!path) { + // We've got no path. If the file descriptor is one of our own and + // not a system FD, we need to get a path for it. + Descriptor* descriptor = get_descriptor(fileFD); + if (descriptor && !descriptor->IsSystemFD()) { + if (SymlinkDescriptor* symlinkDescriptor + = dynamic_cast(descriptor)) { + status_t error = symlinkDescriptor->GetPath(tempPath); + if (error != B_OK) + return error; + path = tempPath.c_str(); + fileFD = -1; + } else { + // We don't know how to get a path. + return B_BAD_VALUE; + } + } + } + if (path) { // A path was given -- check, if it's a symlink. If so we need to // keep the path, otherwise we open a FD. From bonefish at mail.berlios.de Wed Sep 5 05:01:41 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 05:01:41 +0200 Subject: [Haiku-commits] r22178 - haiku/trunk/src/tools/fs_shell Message-ID: <200709050301.l8531fRN009174@sheep.berlios.de> Author: bonefish Date: 2007-09-05 05:01:41 +0200 (Wed, 05 Sep 2007) New Revision: 22178 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22178&view=rev Modified: haiku/trunk/src/tools/fs_shell/stat.cpp Log: Map the fssh_*stat() functions to _kern_read_stat() in libroot_build on BeOS incompatible platforms. Thus *stat()ing symlinks works. Modified: haiku/trunk/src/tools/fs_shell/stat.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/stat.cpp 2007-09-05 02:59:27 UTC (rev 22177) +++ haiku/trunk/src/tools/fs_shell/stat.cpp 2007-09-05 03:01:41 UTC (rev 22178) @@ -7,8 +7,11 @@ #include "fssh_stat.h" +#include + #include +#include "fssh_errno.h" #include "stat_util.h" @@ -16,6 +19,13 @@ using FSShell::to_platform_mode; +#ifndef __BEOS__ + // The _kern_read_stat() defined in libroot_build.so. + extern "C" status_t _kern_read_stat(int fd, const char *path, + bool traverseLink, struct stat *st, size_t statSize); +#endif + + int fssh_mkdir(const char *path, fssh_mode_t mode) { @@ -27,8 +37,19 @@ fssh_stat(const char *path, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (stat(path, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(-1, path, true, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat); @@ -40,8 +61,19 @@ fssh_fstat(int fd, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (fstat(fd, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(fd, NULL, false, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat); @@ -53,8 +85,19 @@ fssh_lstat(const char *path, struct fssh_stat *fsshStat) { struct stat st; + + // Use the _kern_read_stat() defined in libroot on BeOS incompatible + // systems. Required for support for opening symlinks. +#if __BEOS__ if (lstat(path, &st) < 0) return -1; +#else + status_t error = _kern_read_stat(-1, path, false, &st, sizeof(st)); + if (error < 0) { + fssh_set_errno(error); + return -1; + } +#endif from_platform_stat(&st, fsshStat); From bonefish at mail.berlios.de Wed Sep 5 05:06:04 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 05:06:04 +0200 Subject: [Haiku-commits] r22179 - haiku/trunk/src/tools/fs_shell Message-ID: <200709050306.l85364sw009340@sheep.berlios.de> Author: bonefish Date: 2007-09-05 05:06:04 +0200 (Wed, 05 Sep 2007) New Revision: 22179 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22179&view=rev Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp Log: * HostSymLink::fPath wasn't set to NULL by the constructor, which could cause a segfault if Init() failed early. * The -d (don't dereference symlinks) option of cp shall only take effect on the top level. When descending into directories, symlinks shall never be dereferenced. Modified: haiku/trunk/src/tools/fs_shell/command_cp.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/command_cp.cpp 2007-09-05 03:01:41 UTC (rev 22178) +++ haiku/trunk/src/tools/fs_shell/command_cp.cpp 2007-09-05 03:06:04 UTC (rev 22179) @@ -300,7 +300,8 @@ public: HostSymLink() : SymLink(), - HostNode() + HostNode(), + fPath(NULL) { } @@ -858,7 +859,8 @@ // #pragma mark - static fssh_status_t copy_entry(FSDomain *sourceDomain, const char *source, - FSDomain *targetDomain, const char *target, const Options &options); + FSDomain *targetDomain, const char *target, const Options &options, + bool dereference); static FSDomain * get_file_domain(const char *target, const char *&fsTarget) @@ -931,7 +933,7 @@ PathDeleter targetDeleter(targetEntry); fssh_status_t error = copy_entry(sourceDomain, sourceEntry, - targetDomain, targetEntry, options); + targetDomain, targetEntry, options, false); if (error != FSSH_B_OK) return error; } @@ -1032,12 +1034,13 @@ static fssh_status_t copy_entry(FSDomain *sourceDomain, const char *source, - FSDomain *targetDomain, const char *target, const Options &options) + FSDomain *targetDomain, const char *target, const Options &options, + bool dereference) { // open the source node Node *sourceNode; fssh_status_t error = sourceDomain->Open(source, - FSSH_O_RDONLY | (options.dereference ? 0 : FSSH_O_NOTRAVERSE), + FSSH_O_RDONLY | (dereference ? 0 : FSSH_O_NOTRAVERSE), sourceNode); if (error != FSSH_B_OK) { fprintf(stderr, "Error: Failed to open source path `%s': %s\n", source, @@ -1365,7 +1368,7 @@ PathDeleter targetDeleter(targetEntry); error = copy_entry(sourceDomain, source, targetDomain, - targetEntry, options); + targetEntry, options, options.dereference); } } else { // 1.2. target is no dir: @@ -1377,7 +1380,7 @@ // -> we create the target as a clone of the source // (copy_entry(, )) error = copy_entry(sourceDomain, source, targetDomain, target, - options); + options, options.dereference); } if (error != 0) From bonefish at mail.berlios.de Wed Sep 5 05:07:40 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 05:07:40 +0200 Subject: [Haiku-commits] r22180 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200709050307.l8537eo6009398@sheep.berlios.de> Author: bonefish Date: 2007-09-05 05:07:40 +0200 (Wed, 05 Sep 2007) New Revision: 22180 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22180&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp Log: Disabled the attribute name checks for "name", "size", and "last_modified" for the time being. BeOS allows creating and reading attributes with those names. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2007-09-05 03:06:04 UTC (rev 22179) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Attribute.cpp 2007-09-05 03:07:40 UTC (rev 22180) @@ -61,9 +61,9 @@ // 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' - || !strcmp(name, "name") +/* || !strcmp(name, "name") || !strcmp(name, "last_modified") - || !strcmp(name, "size")) + || !strcmp(name, "size")*/) RETURN_ERROR(B_NOT_ALLOWED); return fInode->CheckPermissions(openModeToAccess(openMode) From bonefish at mail.berlios.de Wed Sep 5 05:08:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 05:08:38 +0200 Subject: [Haiku-commits] r22181 - haiku/trunk/build/jam Message-ID: <200709050308.l8538cth009471@sheep.berlios.de> Author: bonefish Date: 2007-09-05 05:08:38 +0200 (Wed, 05 Sep 2007) New Revision: 22181 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22181&view=rev Modified: haiku/trunk/build/jam/FileRules Log: New DownloadFile rule, downloading a file using wget. Modified: haiku/trunk/build/jam/FileRules =================================================================== --- haiku/trunk/build/jam/FileRules 2007-09-05 03:07:40 UTC (rev 22180) +++ haiku/trunk/build/jam/FileRules 2007-09-05 03:08:38 UTC (rev 22181) @@ -273,3 +273,15 @@ $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) $(2[1]) $(DATA_VARIABLE) $(SIZE_VARIABLE) $(2[2]) $(1) } + +rule DownloadFile target : url +{ + URL on $(target) = $(url) ; + + DownloadFile1 $(target) ; +} + +actions DownloadFile1 +{ + wget -O $(1) $(URL) +} From bonefish at mail.berlios.de Wed Sep 5 20:16:34 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 20:16:34 +0200 Subject: [Haiku-commits] r22182 - in haiku/trunk/src: bin/unzip tools/unzip/unix Message-ID: <200709051816.l85IGYnq006122@sheep.berlios.de> Author: bonefish Date: 2007-09-05 20:16:32 +0200 (Wed, 05 Sep 2007) New Revision: 22182 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22182&view=rev Modified: haiku/trunk/src/bin/unzip/beos.c haiku/trunk/src/tools/unzip/unix/unxcfg.h Log: We need to use _kern_open() on BeOS incompatible systems, if we want to be able to open symlinks. Modified: haiku/trunk/src/bin/unzip/beos.c =================================================================== --- haiku/trunk/src/bin/unzip/beos.c 2007-09-05 03:08:38 UTC (rev 22181) +++ haiku/trunk/src/bin/unzip/beos.c 2007-09-05 18:16:32 UTC (rev 22182) @@ -1107,10 +1107,16 @@ ptr = (unsigned char *)attr_buff; guard = ptr + attr_size; +#ifdef HAIKU_USE_KERN_OPEN + fd = _kern_open( -1, name, O_RDONLY | O_NOTRAVERSE, 0 ); + if( fd < 0 ) + return fd; +#else fd = open( name, O_RDONLY | O_NOTRAVERSE ); if( fd < 0 ) { return errno; /* should it be -fd ? */ } +#endif while( ptr < guard ) { ssize_t wrote_bytes; Modified: haiku/trunk/src/tools/unzip/unix/unxcfg.h =================================================================== --- haiku/trunk/src/tools/unzip/unix/unxcfg.h 2007-09-05 03:08:38 UTC (rev 22181) +++ haiku/trunk/src/tools/unzip/unix/unxcfg.h 2007-09-05 18:16:32 UTC (rev 22182) @@ -28,4 +28,8 @@ # ifndef EOK # define EOK B_OK # endif -#endif // __BEOS__ + +# define HAIKU_USE_KERN_OPEN 1 +extern int _kern_open(int fd, const char *path, int openMode, int perms); + +#endif // !__BEOS__ From bonefish at mail.berlios.de Wed Sep 5 20:23:21 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 20:23:21 +0200 Subject: [Haiku-commits] r22183 - haiku/trunk/src/build/libroot Message-ID: <200709051823.l85INLvv006449@sheep.berlios.de> Author: bonefish Date: 2007-09-05 20:23:21 +0200 (Wed, 05 Sep 2007) New Revision: 22183 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22183&view=rev Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp Log: * Simplified the recently introduced handling for symlinks a bit. * Unfortunately it's not allowed to set user xattrs on symlinks. So, if we've failed in fs_write_attr() to set an extended attribute, we check whether the node is a symlink and the attribute just a "BEOS:TYPE", and pretend to have succeeded in this case. Thus we avoid annoying error messages e.g. in unzip. Modified: haiku/trunk/src/build/libroot/fs_attr_xattr.cpp =================================================================== --- haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-05 18:16:32 UTC (rev 22182) +++ haiku/trunk/src/build/libroot/fs_attr_xattr.cpp 2007-09-05 18:23:21 UTC (rev 22183) @@ -176,17 +176,11 @@ // not a system FD, we need to get a path for it. Descriptor* descriptor = get_descriptor(fileFD); if (descriptor && !descriptor->IsSystemFD()) { - if (SymlinkDescriptor* symlinkDescriptor - = dynamic_cast(descriptor)) { - status_t error = symlinkDescriptor->GetPath(tempPath); - if (error != B_OK) - return error; - path = tempPath.c_str(); - fileFD = -1; - } else { - // We don't know how to get a path. - return B_BAD_VALUE; - } + status_t error = descriptor->GetPath(tempPath); + if (error != B_OK) + return error; + path = tempPath.c_str(); + fileFD = -1; } } @@ -346,6 +340,18 @@ return (fFD < 0 ? fPath.c_str() : NULL); } + bool IsSymlink() const + { + struct stat st; + int result; + if (Path()) + result = lstat(Path(), &st); + else + result = fstat(fFD, &st); + + return (result == 0 && S_ISLNK(st.st_mode)); + } + private: string fPath; int fFD; @@ -554,8 +560,14 @@ result = fsetxattr(localFD.FD(), attribute.c_str(), attributeBuffer, toWrite, 0); } - if (result < 0) + if (result < 0) { + // Setting user attributes on symlinks is not allowed. So, if this is + // a symlink and we're only supposed to write a "BEOS:TYPE" attribute + // we silently pretend to have succeeded. + if (localFD.IsSymlink() && strcmp(_attribute, "BEOS:TYPE") == 0) + return writeBytes; return -1; + } return writeBytes; } From bonefish at mail.berlios.de Wed Sep 5 20:36:17 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 20:36:17 +0200 Subject: [Haiku-commits] r22184 - in haiku/trunk: . build/jam Message-ID: <200709051836.l85IaHmC007075@sheep.berlios.de> Author: bonefish Date: 2007-09-05 20:36:17 +0200 (Wed, 05 Sep 2007) New Revision: 22184 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22184&view=rev Modified: haiku/trunk/Jamrules haiku/trunk/build/jam/HaikuImage haiku/trunk/build/jam/ImageRules haiku/trunk/build/jam/UserBuildConfig.sample Log: Added support for "optional packages". Those can be defined in HaikuImage and enabled individually using the AddOptionalHaikuImagePackages rule or all at once by setting HAIKU_ADD_ALL_OPTIONAL_PACKAGES. In principle an optional package can be any kind of addition to the Haiku image, but usually a zip file will be downloaded from somewhere and unzipped onto the image. I've added a WonderBrush package as an example. Modified: haiku/trunk/Jamrules =================================================================== --- haiku/trunk/Jamrules 2007-09-05 18:23:21 UTC (rev 22183) +++ haiku/trunk/Jamrules 2007-09-05 18:36:17 UTC (rev 22184) @@ -7,6 +7,7 @@ HAIKU_BUILD_RULES_DIR = [ FDirName $(HAIKU_BUILD_DIR) jam ] ; HAIKU_OBJECT_DIR = [ FDirName $(HAIKU_OUTPUT_DIR) objects ] ; HAIKU_COMMON_PLATFORM_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_DIR) common ] ; +HAIKU_DOWNLOAD_DIR = [ FDirName $(HAIKU_OUTPUT_DIR) download ] ; # Cache files for header scanning and jamfile caching HCACHEFILE = header_cache ; Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-09-05 18:23:21 UTC (rev 22183) +++ haiku/trunk/build/jam/HaikuImage 2007-09-05 18:36:17 UTC (rev 22184) @@ -412,9 +412,23 @@ : home-config-settings-printers-save-as-pdf.rdef ; +#pragma mark - Optional Packages + +# WonderBrush +if [ IsOptionalHaikuImagePackageAdded WonderBrush ] { + InstallOptionalHaikuImagePackage WonderBrush + : http://www.yellowbites.com/downloads/WonderBrush-2.0.2-demo-x86-R5.zip + : apps + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/apps/WonderBrush/WonderBrush ; +} + + #pragma mark - Build The Image + # Set image name and directory defaults and locate the image. HAIKU_IMAGE_NAME ?= haiku.image ; HAIKU_IMAGE_DIR ?= $(HAIKU_OUTPUT_DIR) ; Modified: haiku/trunk/build/jam/ImageRules =================================================================== --- haiku/trunk/build/jam/ImageRules 2007-09-05 18:23:21 UTC (rev 22183) +++ haiku/trunk/build/jam/ImageRules 2007-09-05 18:36:17 UTC (rev 22184) @@ -582,6 +582,32 @@ : $(targets) ; } +rule AddOptionalHaikuImagePackages packages +{ + HAIKU_OPTIONAL_PACKAGE_ADDED on $(packages) = 1 ; +} + +rule IsOptionalHaikuImagePackageAdded package +{ + if [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] { + return 1 ; + } + + return $(HAIKU_ADD_ALL_OPTIONAL_PACKAGES) ; +} + +rule InstallOptionalHaikuImagePackage package : url : dirTokens +{ + # download zip file + local zipFile = $(package:S=.zip:G=download) ; + MakeLocate $(zipFile) : $(HAIKU_DOWNLOAD_DIR) ; + DownloadFile $(zipFile) : $(url) ; + + # unzip onto image + UnzipArchiveToHaikuImage $(dirTokens) : $(zipFile) ; +} + + rule CreateHaikuImageMakeDirectoriesScript script { CreateContainerMakeDirectoriesScript $(HAIKU_IMAGE_CONTAINER_NAME) Modified: haiku/trunk/build/jam/UserBuildConfig.sample =================================================================== --- haiku/trunk/build/jam/UserBuildConfig.sample 2007-09-05 18:23:21 UTC (rev 22183) +++ haiku/trunk/build/jam/UserBuildConfig.sample 2007-09-05 18:36:17 UTC (rev 22184) @@ -67,6 +67,13 @@ UnzipArchiveToHaikuImage develop tools : /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ; +# Adds the optional package WonderBrush to the image. The package is downloaded +# via wget (i.e. wget must be installed). +AddOptionalHaikuImagePackages WonderBrush ; + +# Add all available optional packages. +HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ; + # Specify scripts that shall be run when populating the image/installation # directory. The "early" script is run before anything has been copied onto # the image/into the installation directory. The "late" script is run after From bonefish at cs.tu-berlin.de Wed Sep 5 20:47:59 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Wed, 05 Sep 2007 20:47:59 +0200 Subject: [Haiku-commits] r22164 - in haiku/trunk: headers/compatibility/bsd src/libs/bsd In-Reply-To: <200709041232.l84CWKsK013855@sheep.berlios.de> References: <200709041232.l84CWKsK013855@sheep.berlios.de> Message-ID: <20070905204759.1392.3@cs.tu-berlin.de> On 2007-09-04 at 14:32:20 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2007-09-04 14:32:20 +0200 (Tue, 04 Sep 2007) > New Revision: 22164 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22164&view=rev > > Added: > haiku/trunk/src/libs/bsd/daemon.c > Modified: > haiku/trunk/headers/compatibility/bsd/stdlib.h > haiku/trunk/src/libs/bsd/Jamfile > Log: > Added daemon() function to libbsd.so. Is the created process supposed to be a session leader? Just wondering, since I have seen this daemonization with a second fork(), so that the resulting process will neither be group nor session leader. CU, Ingo From bonefish at mail.berlios.de Wed Sep 5 21:36:39 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 5 Sep 2007 21:36:39 +0200 Subject: [Haiku-commits] r22185 - haiku/trunk/src/system/kernel Message-ID: <200709051936.l85JadpN010473@sheep.berlios.de> Author: bonefish Date: 2007-09-05 21:36:38 +0200 (Wed, 05 Sep 2007) New Revision: 22185 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22185&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: * Some cleanup in _user_setpgid() (use of autolocking, don't use shadowing variables). * Resolved TODO: We wake up the parent if waiting in wait_for_child() now, if the process group changes. * Added another TODO: setpgid() is supposed to fail on a child after it has executed exec*(). Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-09-05 18:36:17 UTC (rev 22184) +++ haiku/trunk/src/system/kernel/team.cpp 2007-09-05 19:36:38 UTC (rev 22185) @@ -2411,15 +2411,9 @@ { struct thread *thread = thread_get_current_thread(); struct team *currentTeam = thread->team; - struct process_group *group = NULL, *freeGroup = NULL; struct team *team; - cpu_status state; team_id teamID = -1; - status_t status = B_OK; - // TODO: we might want to notify waiting wait_for_child() threads in case - // they wait for children of the former process group ID (see wait_test_4.cpp) - if (groupID < 0) return B_BAD_VALUE; @@ -2439,39 +2433,35 @@ return B_NOT_ALLOWED; } - - status = B_OK; } else { - state = disable_interrupts(); - GRAB_THREAD_LOCK(); + InterruptsSpinLocker _(thread_spinlock); thread = thread_get_thread_struct_locked(processID); // the thread must be the team's main thread, as that // determines its process ID - if (thread != NULL && thread == thread->team->main_thread) { - // check if the thread is in a child team of the calling team and - // if it's already a process group leader and in the same session - if (thread->team->parent != currentTeam - || is_process_group_leader(thread->team) - || thread->team->session_id != currentTeam->session_id) - status = B_NOT_ALLOWED; - else - teamID = thread->team->id; - } else - status = B_BAD_THREAD_ID; + if (thread == NULL && thread != thread->team->main_thread) + return B_BAD_THREAD_ID; - RELEASE_THREAD_LOCK(); - restore_interrupts(state); + // check if the thread is in a child team of the calling team and + // if it's already a process group leader and in the same session + if (thread->team->parent != currentTeam + || is_process_group_leader(thread->team) + || thread->team->session_id != currentTeam->session_id) { + return B_NOT_ALLOWED; + } + + // TODO: According to the standard, the call is also supposed to fail + // on a child, when the child already has executed exec*(). + + teamID = thread->team->id; } - if (status != B_OK) - return status; - // if the group ID is not specified, a new group should be created if (groupID == 0) groupID = processID; + struct process_group *group = NULL; if (groupID == processID) { // We need to create a new process group for this team group = create_process_group(groupID); @@ -2479,35 +2469,45 @@ return B_NO_MEMORY; } - state = disable_interrupts(); - GRAB_TEAM_LOCK(); + status_t status = B_OK; + struct process_group *freeGroup = NULL; + InterruptsSpinLocker locker(team_spinlock); + team = team_get_team_struct_locked(teamID); if (team != NULL) { if (processID == groupID) { - // we created a new process group, let us insert it into the team's session + // we created a new process group, let us insert it into the team's + // session insert_group_into_session(team->group->session, group); remove_team_from_group(team, &freeGroup); insert_team_into_group(group, team); } else { - // check if this team can have the group ID; there must be one matching - // process ID in the team's session + // check if this team can have the group ID; there must be one + // matching process ID in the team's session - struct process_group *group = + struct process_group *targetGroup = team_get_process_group_locked(team->group->session, groupID); - if (group) { + if (targetGroup != NULL) { // we got a group, let's move the team there remove_team_from_group(team, &freeGroup); - insert_team_into_group(group, team); + insert_team_into_group(targetGroup, team); } else status = B_NOT_ALLOWED; } } else status = B_NOT_ALLOWED; - RELEASE_TEAM_LOCK(); - restore_interrupts(state); + // Changing the process group might have changed the situation for a parent + // waiting in wait_for_child(). Hence we notify it. + if (status == B_OK) { + team->parent->dead_children->condition_variable.NotifyAll(false); + team->parent->stopped_children->condition_variable.NotifyAll(false); + team->parent->continued_children->condition_variable.NotifyAll(false); + } + locker.Unlock(); + if (status != B_OK && group != NULL) { // in case of error, the group hasn't been added into the hash team_delete_process_group(group); From bonefish at mail.berlios.de Thu Sep 6 04:03:44 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Sep 2007 04:03:44 +0200 Subject: [Haiku-commits] r22186 - in haiku/trunk: headers/private/kernel src/system/kernel Message-ID: <200709060203.l8623iUF014386@sheep.berlios.de> Author: bonefish Date: 2007-09-06 04:03:43 +0200 (Thu, 06 Sep 2007) New Revision: 22186 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22186&view=rev Modified: haiku/trunk/headers/private/kernel/ksignal.h haiku/trunk/src/system/kernel/signal.cpp Log: * Added is_signal_blocked() convenience function. * Defined flag SIGNAL_FLAG_TEAMS_LOCKED for send_signal_etc(), so it can be called with the team lock being held. Modified: haiku/trunk/headers/private/kernel/ksignal.h =================================================================== --- haiku/trunk/headers/private/kernel/ksignal.h 2007-09-05 19:36:38 UTC (rev 22185) +++ haiku/trunk/headers/private/kernel/ksignal.h 2007-09-06 02:03:43 UTC (rev 22186) @@ -14,7 +14,11 @@ #define SIGNAL_TO_MASK(signal) (1LL << (signal - 1)) +// additional send_signal_etc() flag +#define SIGNAL_FLAG_TEAMS_LOCKED (0x10000) + // interrupts are disabled and team lock is held + #ifdef __cplusplus extern "C" { #endif @@ -22,6 +26,7 @@ extern bool handle_signals(struct thread *thread); extern bool is_kill_signal_pending(void); extern int has_signals_pending(void *_thread); +extern bool is_signal_blocked(int signal); extern int sigaction_etc(thread_id threadID, int signal, const struct sigaction *newAction, struct sigaction *oldAction); Modified: haiku/trunk/src/system/kernel/signal.cpp =================================================================== --- haiku/trunk/src/system/kernel/signal.cpp 2007-09-05 19:36:38 UTC (rev 22185) +++ haiku/trunk/src/system/kernel/signal.cpp 2007-09-06 02:03:43 UTC (rev 22186) @@ -265,6 +265,14 @@ } +bool +is_signal_blocked(int signal) +{ + return (atomic_get(&thread_get_current_thread()->sig_block_mask) + & SIGNAL_TO_MASK(signal)) != 0; +} + + /*! Tries to interrupt a thread waiting for a semaphore or a condition variable. Interrupts must be disabled, the thread lock be held. Note, that the thread lock may temporarily be released. @@ -360,12 +368,13 @@ { status_t status = B_BAD_THREAD_ID; struct thread *thread; - cpu_status state; + cpu_status state = 0; if (signal < 0 || signal > MAX_SIGNO) return B_BAD_VALUE; - state = disable_interrupts(); + if ((flags & SIGNAL_FLAG_TEAMS_LOCKED) == 0) + state = disable_interrupts(); if (id > 0) { // send a signal to the specified thread @@ -388,7 +397,8 @@ } else id = -id; - GRAB_TEAM_LOCK(); + if ((flags & SIGNAL_FLAG_TEAMS_LOCKED) == 0) + GRAB_TEAM_LOCK(); group = team_get_process_group_locked(NULL, id); if (group != NULL) { @@ -413,18 +423,22 @@ } } - RELEASE_TEAM_LOCK(); + if ((flags & SIGNAL_FLAG_TEAMS_LOCKED) == 0) + RELEASE_TEAM_LOCK(); + GRAB_THREAD_LOCK(); } // ToDo: maybe the scheduler should only be invoked if there is reason to do it? // (ie. deliver_signal() moved some threads in the running queue?) - if ((flags & B_DO_NOT_RESCHEDULE) == 0) + if ((flags & (B_DO_NOT_RESCHEDULE | SIGNAL_FLAG_TEAMS_LOCKED)) == 0) scheduler_reschedule(); RELEASE_THREAD_LOCK(); - restore_interrupts(state); + if ((flags & SIGNAL_FLAG_TEAMS_LOCKED) == 0) + restore_interrupts(state); + return status; } From bonefish at mail.berlios.de Thu Sep 6 04:16:27 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Sep 2007 04:16:27 +0200 Subject: [Haiku-commits] r22187 - in haiku/trunk: headers/posix headers/private/kernel src/add-ons/kernel/drivers/tty src/system/kernel Message-ID: <200709060216.l862GRJR015055@sheep.berlios.de> Author: bonefish Date: 2007-09-06 04:16:25 +0200 (Thu, 06 Sep 2007) New Revision: 22187 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22187&view=rev Modified: haiku/trunk/headers/posix/fcntl.h haiku/trunk/headers/private/kernel/team.h haiku/trunk/headers/private/kernel/thread_types.h haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h haiku/trunk/src/system/kernel/team.cpp Log: * We store the ID of the controlling terminal and the foreground process group ID with the session and let the terminal update them. * Added an "orphaned" flag to the process_group structure and code to maintain it. * Handle the death of a controlling process correctly: The foreground process group gets a SIGHUP and all newly-orphaned process groups containing at least one stopped processes are sent SIGHUP+SIGCONT. * The tty handles the O_NOCTTY flag correctly, now. * The tty handles reads/writes from processes from other sessions correctly, now. * Handle tcsetpgrp() from background processes correctly. Modified: haiku/trunk/headers/posix/fcntl.h =================================================================== --- haiku/trunk/headers/posix/fcntl.h 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/headers/posix/fcntl.h 2007-09-06 02:16:25 UTC (rev 22187) @@ -40,7 +40,7 @@ #define O_EXCL 0x0100 /* exclusive creat */ #define O_CREAT 0x0200 /* create and open file */ #define O_TRUNC 0x0400 /* open with truncation */ -#define O_NOCTTY 0x1000 /* currently unsupported */ +#define O_NOCTTY 0x1000 /* don't make tty the controlling tty */ #define O_NOTRAVERSE 0x2000 /* do not traverse leaf link */ /* flags for open() and fcntl() */ Modified: haiku/trunk/headers/private/kernel/team.h =================================================================== --- haiku/trunk/headers/private/kernel/team.h 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/headers/private/kernel/team.h 2007-09-06 02:16:25 UTC (rev 22187) @@ -38,6 +38,9 @@ void team_set_job_control_state(struct team* team, job_control_state newState, int signal, bool threadsLocked); +void team_set_controlling_tty(int32 index); +int32 team_get_controlling_tty(); +status_t team_set_foreground_process_group(int32 ttyIndex, pid_t processGroup); status_t start_watching_team(team_id team, void (*hook)(team_id, void *), void *data); Modified: haiku/trunk/headers/private/kernel/thread_types.h =================================================================== --- haiku/trunk/headers/private/kernel/thread_types.h 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/headers/private/kernel/thread_types.h 2007-09-06 02:16:25 UTC (rev 22187) @@ -67,6 +67,9 @@ struct process_session { pid_t id; int32 group_count; + int32 controlling_tty; // index of the controlling tty, + // -1 if none + pid_t foreground_group; }; struct process_group { @@ -74,6 +77,7 @@ struct process_session *session; pid_t id; struct team *teams; + bool orphaned; }; struct team_loading_info { Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/slave.cpp 2007-09-06 02:16:25 UTC (rev 22187) @@ -8,6 +8,8 @@ #include +#include + #include "tty_private.h" @@ -41,12 +43,26 @@ if (gMasterTTYs[index].open_count == 0) return B_IO_ERROR; + bool makeControllingTTY = (flags & O_NOCTTY) == 0; + pid_t processID = getpid(); + pid_t sessionID = getsid(processID); + if (gSlaveTTYs[index].open_count == 0) { + // We only allow session leaders to open the tty initially. + if (makeControllingTTY && processID != sessionID) + return B_NOT_ALLOWED; + status_t status = tty_open(&gSlaveTTYs[index], NULL); if (status < B_OK) { // initializing TTY failed return status; } + } else if (makeControllingTTY) { + // If already open, we allow only processes from the same session + // to open the tty again. + pid_t ttySession = gSlaveTTYs[index].settings->session_id; + if (ttySession < 0 || ttySession != sessionID) + return B_NOT_ALLOWED; } slave_cookie *cookie = (slave_cookie *)malloc(sizeof(struct slave_cookie)); @@ -68,9 +84,16 @@ return status; } - if (gSlaveTTYs[index].open_count == 0) + if (gSlaveTTYs[index].open_count == 0) { gSlaveTTYs[index].lock = gMasterTTYs[index].lock; + if (makeControllingTTY) { + gSlaveTTYs[index].settings->session_id = sessionID; + team_set_controlling_tty(gSlaveTTYs[index].index); + } else + gSlaveTTYs[index].settings->session_id = -1; + } + add_tty_cookie(cookie); *_cookie = cookie; Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp 2007-09-06 02:16:25 UTC (rev 22187) @@ -17,6 +17,8 @@ #include #include +#include + #include "SemaphorePool.h" #include "tty_private.h" @@ -610,7 +612,8 @@ pid_t processGroup = getpgid(0); if (processGroup != fSource->settings->pgrp_id) { - send_signal(-processGroup, SIGTTOU); + if (team_get_controlling_tty() == fSource->index) + send_signal(-processGroup, SIGTTOU); return EIO; } @@ -698,7 +701,8 @@ pid_t processGroup = getpgid(0); if (processGroup != fTTY->settings->pgrp_id) { - send_signal(-processGroup, SIGTTIN); + if (team_get_controlling_tty() == fTTY->index) + send_signal(-processGroup, SIGTTIN); return EIO; } @@ -756,6 +760,7 @@ settings->pgrp_id = 0; // this value prevents any signal of being sent + settings->session_id = -1; // some initial window size - the TTY in question should set these values settings->window_size.ws_col = 80; @@ -1321,9 +1326,20 @@ return user_memcpy(buffer, &tty->settings->pgrp_id, sizeof(pid_t)); case TIOCSPGRP: case 'pgid': + { TRACE(("tty: set pgrp_id\n")); - return user_memcpy(&tty->settings->pgrp_id, buffer, sizeof(pid_t)); + pid_t groupID; + + if (user_memcpy(&groupID, buffer, sizeof(pid_t)) != B_OK) + return B_BAD_ADDRESS; + status_t error = team_set_foreground_process_group(tty->index, + groupID); + if (error == B_OK) + tty->settings->pgrp_id = groupID; + return error; + } + /* get and set window size */ case TIOCGWINSZ: Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h 2007-09-06 02:16:25 UTC (rev 22187) @@ -120,6 +120,7 @@ struct tty_settings { pid_t pgrp_id; + pid_t session_id; struct termios termios; struct winsize window_size; }; Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-09-06 02:03:43 UTC (rev 22186) +++ haiku/trunk/src/system/kernel/team.cpp 2007-09-06 02:16:25 UTC (rev 22187) @@ -523,6 +523,7 @@ group->id = id; group->session = NULL; group->teams = NULL; + group->orphaned = true; return group; } @@ -530,12 +531,15 @@ static struct process_session * create_process_session(pid_t id) { - struct process_session *session = (struct process_session *)malloc(sizeof(struct process_session)); + struct process_session *session + = (struct process_session *)malloc(sizeof(struct process_session)); if (session == NULL) return NULL; session->id = id; session->group_count = 0; + session->controlling_tty = -1; + session->foreground_group = -1; return session; } @@ -1480,7 +1484,7 @@ // If SIGCHLD is blocked, we shall clear pending SIGCHLDs, if no other child // status is available. - if ((atomic_get(&thread->sig_block_mask) & SIGNAL_TO_MASK(SIGCHLD)) != 0) { + if (is_signal_blocked(SIGCHLD)) { InterruptsSpinLocker locker(team_spinlock); if (get_job_control_entry(team, child, flags) == NULL) @@ -1521,6 +1525,57 @@ } +/*! Updates the \c orphaned field of a process_group and returns its new value. + Interrupts must be disabled and team lock be held. +*/ +static bool +update_orphaned_process_group(process_group* group, pid_t dyingProcess) +{ + // Orphaned Process Group: "A process group in which the parent of every + // member is either itself a member of the group or is not a member of the + // group's session." (Open Group Base Specs Issue 6) + + // once orphaned, things won't change (exception: cf. setpgid()) + if (group->orphaned) + return true; + + struct team* team = group->teams; + while (team != NULL) { + struct team* parent = team->parent; + if (team->id != dyingProcess && parent->id != dyingProcess + && parent->group_id != group->id + && parent->session_id == group->session->id) { + return false; + } + + team = team->group_next; + } + + group->orphaned = true; + return true; +} + + +/*! Returns whether the process group contains stopped processes. + Interrupts must be disabled and team lock be held. +*/ +static bool +process_group_has_stopped_processes(process_group* group) +{ + SpinLocker _(thread_spinlock); + + struct team* team = group->teams; + while (team != NULL) { + if (team->main_thread->state == B_THREAD_SUSPENDED) + return true; + + team = team->group_next; + } + + return false; +} + + // #pragma mark - Private kernel API @@ -1683,13 +1738,73 @@ } -/** Removes the specified team from the global team hash, and from its parent. - * It also moves all of its children up to the parent. - * You must hold the team lock when you call this function. - * If \a _freeGroup is set to a value other than \c NULL, it must be freed - * from the calling function. - */ +void +team_set_controlling_tty(int32 ttyIndex) +{ + struct team* team = thread_get_current_thread()->team; + InterruptsSpinLocker _(team_spinlock); + + team->group->session->controlling_tty = ttyIndex; + team->group->session->foreground_group = -1; +} + + +int32 +team_get_controlling_tty() +{ + struct team* team = thread_get_current_thread()->team; + + InterruptsSpinLocker _(team_spinlock); + + return team->group->session->controlling_tty; +} + + +status_t +team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID) +{ + struct thread* thread = thread_get_current_thread(); + struct team* team = thread->team; + + InterruptsSpinLocker locker(team_spinlock); + + process_session* session = team->group->session; + + // must be the controlling tty of the calling process + if (session->controlling_tty != ttyIndex) + return ENOTTY; + + // check process group -- must belong to our session + process_group* group = team_get_process_group_locked(session, + processGroupID); + if (group == NULL) + return B_BAD_VALUE; + + // If we are a background group, we can't do that unharmed, only if we + // ignore or block SIGTTOU. Otherwise the group gets a SIGTTOU. + if (session->foreground_group != -1 + && session->foreground_group != team->group_id + && thread->sig_action[SIGTTOU - 1].sa_handler != SIG_IGN + && !is_signal_blocked(SIGTTOU)) { + pid_t groupID = team->group->id; + locker.Unlock(); + send_signal(-groupID, SIGTTOU); + return B_INTERRUPTED; + } + + team->group->session->foreground_group = processGroupID; + + return B_OK; +} + + +/*! Removes the specified team from the global team hash, and from its parent. + It also moves all of its children up to the parent. + You must hold the team lock when you call this function. + If \a _freeGroup is set to a value other than \c NULL, it must be freed + from the calling function. +*/ void team_remove_team(struct team *team, struct process_group **_freeGroup) { @@ -1706,6 +1821,51 @@ team->state = TEAM_STATE_DEATH; + // If we're a controlling process (i.e. a session leader with controlling + // terminal), there's a bit of signalling we have to do. + if (team->session_id == team->id + && team->group->session->controlling_tty >= 0) { + process_session* session = team->group->session; + + session->controlling_tty = -1; + + // send SIGHUP to the foreground + if (session->foreground_group >= 0) { + send_signal_etc(-session->foreground_group, SIGHUP, + SIGNAL_FLAG_TEAMS_LOCKED); + } + + // send SIGHUP + SIGCONT to all newly-orphaned process groups with + // stopped processes + struct team* child = team->children; + while (child != NULL) { + process_group* childGroup = child->group; + if (!childGroup->orphaned + && update_orphaned_process_group(childGroup, team->id) + && process_group_has_stopped_processes(childGroup)) { + send_signal_etc(-childGroup->id, SIGHUP, + SIGNAL_FLAG_TEAMS_LOCKED); + send_signal_etc(-childGroup->id, SIGCONT, + SIGNAL_FLAG_TEAMS_LOCKED); + } + + child = child->siblings_next; + } + } else { + // update "orphaned" flags of all children's process groups + struct team* child = team->children; + while (child != NULL) { + process_group* childGroup = child->group; + if (!childGroup->orphaned) + update_orphaned_process_group(childGroup, team->id); + + child = child->siblings_next; + } + + // update "orphaned" flag of this team's process group + update_orphaned_process_group(team->group, team->id); + } + // reparent each of the team's children reparent_children(team); @@ -2467,6 +2627,10 @@ group = create_process_group(groupID); if (group == NULL) return B_NO_MEMORY; + + // The team has a parent in the same session, but in another process + // group, so the new group won't be orphaned. + group->orphaned = false; } status_t status = B_OK; @@ -2489,9 +2653,30 @@ struct process_group *targetGroup = team_get_process_group_locked(team->group->session, groupID); if (targetGroup != NULL) { - // we got a group, let's move the team there - remove_team_from_group(team, &freeGroup); - insert_team_into_group(targetGroup, team); + process_group* oldGroup = team->group; + if (targetGroup != oldGroup) { + // we got a group, let's move the team there + remove_team_from_group(team, &freeGroup); + insert_team_into_group(targetGroup, team); + + // Update the "orphaned" flag of all potentially affected + // groups. + + // the team's old group + if (oldGroup->teams != NULL) { + oldGroup->orphaned = false; + update_orphaned_process_group(oldGroup, -1); + } + + // children's groups + struct team* child = team->children; + while (child != NULL) { + child->group->orphaned = false; + update_orphaned_process_group(child->group, -1); + + child = child->siblings_next; + } + } } else status = B_NOT_ALLOWED; } From bonefish at mail.berlios.de Thu Sep 6 04:20:13 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Sep 2007 04:20:13 +0200 Subject: [Haiku-commits] r22188 - haiku/trunk/src/bin/bash Message-ID: <200709060220.l862KDbk015225@sheep.berlios.de> Author: bonefish Date: 2007-09-06 04:20:13 +0200 (Thu, 06 Sep 2007) New Revision: 22188 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22188&view=rev Modified: haiku/trunk/src/bin/bash/sig.c Log: Bash applies the same logic on SIGHUP as on normal exit now. Jobs are sent a SIGHUP only when that was explicitely requested via shopt huponexit. Thus it behaves like other shells (ksh, tcsh, ash,...). Background processes are no longer terminated when closing the terminal. Modified: haiku/trunk/src/bin/bash/sig.c =================================================================== --- haiku/trunk/src/bin/bash/sig.c 2007-09-06 02:16:25 UTC (rev 22187) +++ haiku/trunk/src/bin/bash/sig.c 2007-09-06 02:20:13 UTC (rev 22188) @@ -54,6 +54,7 @@ extern int return_catch_flag; extern int loop_level, continuing, breaking; extern int parse_and_execute_level, shell_initialized; +extern int hup_on_exit; /* Non-zero after SIGINT. */ int interrupt_state; @@ -412,7 +413,7 @@ #endif /* HISTORY */ #if defined (JOB_CONTROL) - if (interactive && sig == SIGHUP) + if (interactive && sig == SIGHUP && hup_on_exit) hangup_all_jobs (); end_job_control (); #endif /* JOB_CONTROL */ From stippi at mail.berlios.de Thu Sep 6 11:31:58 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 6 Sep 2007 11:31:58 +0200 Subject: [Haiku-commits] r22189 - haiku/trunk/src/kits/interface Message-ID: <200709060931.l869VwIm019057@sheep.berlios.de> Author: stippi Date: 2007-09-06 11:31:57 +0200 (Thu, 06 Sep 2007) New Revision: 22189 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22189&view=rev Modified: haiku/trunk/src/kits/interface/Font.cpp Log: * fExtraFlags was not maintained in various places, most importantly nowhere in SetFamilyAndStyle(), this should fix stuff like IsFixed() not working Modified: haiku/trunk/src/kits/interface/Font.cpp =================================================================== --- haiku/trunk/src/kits/interface/Font.cpp 2007-09-06 02:20:13 UTC (rev 22188) +++ haiku/trunk/src/kits/interface/Font.cpp 2007-09-06 09:31:57 UTC (rev 22189) @@ -572,6 +572,7 @@ link.Read(&fStyleID); link.Read(&fFace); fHeight.ascent = kUninitializedAscent; + fExtraFlags = kUninitializedExtraFlags; return B_OK; } @@ -612,6 +613,7 @@ link.Read(&fStyleID); link.Read(&fFace); fHeight.ascent = kUninitializedAscent; + fExtraFlags = kUninitializedExtraFlags; } @@ -647,6 +649,7 @@ link.Read(&fStyleID); link.Read(&fFace); fHeight.ascent = kUninitializedAscent; + fExtraFlags = kUninitializedExtraFlags; return B_OK; } @@ -1367,6 +1370,8 @@ fFace = font.fFace; fHeight = font.fHeight; fFlags = font.fFlags; + fExtraFlags = font.fExtraFlags; + return *this; } From stippi at mail.berlios.de Thu Sep 6 12:40:48 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 6 Sep 2007 12:40:48 +0200 Subject: [Haiku-commits] r22190 - haiku/trunk/src/kits/tracker Message-ID: <200709061040.l86Aem11026056@sheep.berlios.de> Author: stippi Date: 2007-09-06 12:40:47 +0200 (Thu, 06 Sep 2007) New Revision: 22190 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22190&view=rev Modified: haiku/trunk/src/kits/tracker/Pose.cpp haiku/trunk/src/kits/tracker/PoseView.cpp haiku/trunk/src/kits/tracker/TextWidget.cpp Log: * fixed tracker single click selection. If I may say so, I find this code extremely messy and in desperate need for refactoring. The bad news is that selection flickers now - the columns which don't need to be drawn at all. I printed some debugging info in BTextWidget::Draw() and it appears that for a single selection state change, at least four invokations of BTextWidget::Draw() will result. Sometimes many more. Since the code calculated the dirty rects wrongly in many places, it appears that this bug might not have shown before. Like I said, the code is a mess and there is not a single place for invalidating poses, so I am not surprised why tons of invalidations arrive. :-/ Maybe I should make myself more familiar with Tracker... or revert my text outline patch. :-P Modified: haiku/trunk/src/kits/tracker/Pose.cpp =================================================================== --- haiku/trunk/src/kits/tracker/Pose.cpp 2007-09-06 09:31:57 UTC (rev 22189) +++ haiku/trunk/src/kits/tracker/Pose.cpp 2007-09-06 10:40:47 UTC (rev 22190) @@ -581,7 +581,7 @@ widget->RecalculateText(poseView); bool selectDuringDraw = directDraw && selected - && (windowActive && !poseView->WidgetTextOutline()); + && windowActive; if (index == 0 && selectDuringDraw) { //draw with dark background to select text @@ -637,8 +637,7 @@ rect = widget->CalcRect(fLocation, 0, poseView); bool selectDuringDraw = directDraw && selected - && (poseView->IsDesktopWindow() - || (windowActive && !poseView->WidgetTextOutline())); + && (poseView->IsDesktopWindow() || windowActive); if (selectDuringDraw) { // draw with dark background to select text Modified: haiku/trunk/src/kits/tracker/PoseView.cpp =================================================================== --- haiku/trunk/src/kits/tracker/PoseView.cpp 2007-09-06 09:31:57 UTC (rev 22189) +++ haiku/trunk/src/kits/tracker/PoseView.cpp 2007-09-06 10:40:47 UTC (rev 22190) @@ -2873,11 +2873,7 @@ || bounds.Contains(poseRect.LeftBottom()) || bounds.Contains(poseRect.RightBottom()) || bounds.Contains(poseRect.RightTop())) { - if (!WidgetTextOutline() - || clipNode->moveMode == kMoveSelectionTo) - Invalidate(poseRect); - else - pose->Draw(poseRect, this, false); + Invalidate(poseRect); } } } @@ -3406,9 +3402,6 @@ void BPoseView::SelectPoses(int32 start, int32 end) { - BPoint loc(0, 0); - BRect bounds(Bounds()); - // clear selection list fSelectionList->MakeEmpty(); fMimeTypesInSelectionCache.MakeEmpty(); @@ -3416,6 +3409,8 @@ fRealPivotPose = NULL; bool iconMode = ViewMode() != kListMode; + BPoint loc(0, start * fListElemHeight); + BRect bounds(Bounds()); int32 count = fPoseList->CountItems(); for (int32 index = start; index < end && index < count; index++) { @@ -3429,14 +3424,10 @@ if (iconMode) poseRect = pose->CalcRect(this); else - poseRect = pose->CalcRect(loc, this); + poseRect = pose->CalcRect(loc, this, false); if (bounds.Intersects(poseRect)) { - if (WidgetTextOutline()) - Invalidate(poseRect); - else - pose->Draw(poseRect, this, false); - Flush(); + Invalidate(poseRect); } } @@ -5590,7 +5581,7 @@ fRealPivotPose = NULL; int32 startIndex = 0; - BPoint loc(0, 0); + BPoint loc(0, fListElemHeight * startIndex); bool iconMode = ViewMode() != kListMode; @@ -5634,7 +5625,7 @@ BRect bounds(Bounds()); int32 startIndex = 0; - BPoint loc(0, 0); + BPoint loc(0, fListElemHeight * startIndex); fMimeTypesInSelectionCache.MakeEmpty(); fSelectionPivotPose = NULL; @@ -6852,6 +6843,8 @@ BList *newList = new BList; BRect bounds(Bounds()); SetDrawingMode(B_OP_COPY); + // TODO: I _think_ there is no more synchronous drawing here, + // so this should be save to remove int32 startIndex = (int32)(selectionRect.top / fListElemHeight); if (startIndex < 0) @@ -6871,10 +6864,7 @@ // using a vector class instead of BList if ((selected != pose->IsSelected()) && poseRect.Intersects(bounds)) { - if (pose->IsSelected() || WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); + Invalidate(poseRect); } // First Pose selected gets to be the pivot. @@ -6900,10 +6890,7 @@ BRect poseRect(pose->CalcRect(loc, this)); if (poseRect.Intersects(bounds)) { - if (pose->IsSelected() || WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); + Invalidate(poseRect); } } } @@ -6938,11 +6925,9 @@ pose->Select(!fSelectionList->HasItem(pose)); newList->AddItem((void *)index); - if ((selected != pose->IsSelected()) && poseRect.Intersects(bounds)) { - if (pose->IsSelected() || WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); + if ((selected != pose->IsSelected()) + && poseRect.Intersects(bounds)) { + Invalidate(poseRect); } // First Pose selected gets to be the pivot. @@ -6966,12 +6951,8 @@ pose->Select(!pose->IsSelected()); BRect poseRect(pose->CalcRect(this)); - if (poseRect.Intersects(bounds)) { - if (pose->IsSelected() || WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); - } + if (poseRect.Intersects(bounds)) + Invalidate(poseRect); } } @@ -7051,6 +7032,7 @@ int32 count = fPoseList->CountItems(); for (int32 index = count - 1; index >= 0; index--) { BPose *currPose = fPoseList->ItemAt(index); + // TODO: works only in non-list mode? if (selection.Intersects(currPose->CalcRect(this))) AddRemovePoseFromSelection(currPose, index, select); } @@ -7724,11 +7706,7 @@ BPose *pose = fPoseList->ItemAt(index); if (pose->IsSelected()) { pose->Select(false); - BRect poseRect(pose->CalcRect(loc, this, false)); - if (WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); + Invalidate(pose->CalcRect(loc, this, false)); } loc.y += fListElemHeight; @@ -7743,11 +7721,7 @@ if (pose) { if (pose->IsSelected()) { pose->Select(false); - BRect poseRect(pose->CalcRect(this)); - if (WidgetTextOutline()) - pose->Draw(poseRect, this, false); - else - Invalidate(poseRect); + Invalidate(pose->CalcRect(this)); } if (pose->Location().y > bounds.bottom) @@ -7807,10 +7781,7 @@ if (pose->IsSelected() != show || fShowSelectionWhenInactive) { if (!fShowSelectionWhenInactive) pose->Select(show); - if (show && WidgetTextOutline()) - pose->Draw(pose->CalcRect(this), this, false); - else - Invalidate(pose->CalcRect(this)); + Invalidate(pose->CalcRect(this)); } if (pose->Location().y > bounds.bottom) @@ -7850,8 +7821,8 @@ pose->Select(select); // update display - if (WidgetTextOutline()) - DrawPose(pose, index, false); + if (ViewMode() == kListMode) + Invalidate(pose->CalcRect(BPoint(0, index * fListElemHeight), this, false)); else Invalidate(pose->CalcRect(this)); @@ -8887,7 +8858,8 @@ BPose *pose = fVSPoseList->ItemAt(index); if (pose) { if (pose == fDropTarget) { - if (!hiliteState && !WidgetTextOutline()) + // TODO: maybe leave just the else part + if (!hiliteState) // deselecting an icon with widget drawn over background // have to be a little tricky here - draw just the icon, // invalidate the widget @@ -9076,8 +9048,7 @@ BRect BPoseView::CalcPoseRect(BPose *pose, int32 index, bool min) const { - return pose->CalcRect(BPoint(0, index * fListElemHeight), - this, min); + return pose->CalcRect(BPoint(0, index * fListElemHeight), this, min); } Modified: haiku/trunk/src/kits/tracker/TextWidget.cpp =================================================================== --- haiku/trunk/src/kits/tracker/TextWidget.cpp 2007-09-06 09:31:57 UTC (rev 22189) +++ haiku/trunk/src/kits/tracker/TextWidget.cpp 2007-09-06 10:40:47 UTC (rev 22190) @@ -480,7 +480,7 @@ textRect.OffsetBy(offset); if (direct) { -#if __HAIKU__ +#ifdef __HAIKU__ // draw selection box if selected if (selected) { #else @@ -522,7 +522,7 @@ const char* fittingText = fText->FittingText(view); -#if __HAIKU__ +#ifdef __HAIKU__ if (!selected && view->WidgetTextOutline()) { // draw a halo around the text by using the "false bold" // feature for text rendering. Either black or white is used for From leavengood at gmail.com Thu Sep 6 15:37:58 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 6 Sep 2007 09:37:58 -0400 Subject: [Haiku-commits] r22190 - haiku/trunk/src/kits/tracker In-Reply-To: <200709061040.l86Aem11026056@sheep.berlios.de> References: <200709061040.l86Aem11026056@sheep.berlios.de> Message-ID: On 9/6/07, stippi at BerliOS wrote: > > If I may say so, I find this code extremely messy and in desperate need for > refactoring. I too think Tracker could use some refactoring. Maybe we should make a "tracker refactoring" branch in SVN and just go nuts, then have Axel or other Tracker "experts" take a look before merging it back in. Branches are good since they won't mess things up for everyone else while things are hacked up. I'll certainly help with this. BTW I've been reading up on AGG and other stuff. I want to join you in being a Haiku graphics and interface expert ;) I kind of need to anyhow with this WebKit port. Ryan From darkwyrm at gmail.com Thu Sep 6 17:35:09 2007 From: darkwyrm at gmail.com (DarkWyrm) Date: Thu, 06 Sep 2007 11:35:09 -0400 Subject: [Haiku-commits] r22190 - haiku/trunk/src/kits/tracker In-Reply-To: References: <200709061040.l86Aem11026056@sheep.berlios.de> Message-ID: <46E01E2D.7030101@gmail.com> Ryan Leavengood wrote: > On 9/6/07, stippi at BerliOS wrote: >> If I may say so, I find this code extremely messy and in desperate need for >> refactoring. > > I too think Tracker could use some refactoring. Maybe we should make a > "tracker refactoring" branch in SVN and just go nuts, then have Axel > or other Tracker "experts" take a look before merging it back in. > Branches are good since they won't mess things up for everyone else > while things are hacked up. This was something that I'd like to ideally wait until R2 for where there will be significant interface changes. It might be better to wait to avoid having to refactor now only to change again later. --DarkWyrm From leavengood at gmail.com Thu Sep 6 17:46:48 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 6 Sep 2007 11:46:48 -0400 Subject: [Haiku-commits] r22190 - haiku/trunk/src/kits/tracker In-Reply-To: <46E01E2D.7030101@gmail.com> References: <200709061040.l86Aem11026056@sheep.berlios.de> <46E01E2D.7030101@gmail.com> Message-ID: On 9/6/07, DarkWyrm wrote: > > This was something that I'd like to ideally wait until R2 for where > there will be significant interface changes. It might be better to wait > to avoid having to refactor now only to change again later. I would agree only if the current bugs can be fixed without too many ugly hacks. I certainly don't want a flickering Tracker or one which is slow because of excessive redrawing or whatever else is wrong. Plus refactoring which improves the code now will only make future refactoring easier. Ryan From laplace at mail.berlios.de Thu Sep 6 17:50:32 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Thu, 6 Sep 2007 17:50:32 +0200 Subject: [Haiku-commits] r22191 - haiku/trunk/src/tests/kits/interface/flatten_picture Message-ID: <200709061550.l86FoWAm025750@sheep.berlios.de> Author: laplace Date: 2007-09-06 17:50:31 +0200 (Thu, 06 Sep 2007) New Revision: 22191 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22191&view=rev Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/TestResultItem.cpp Log: Workaround for drawing issue in Haiku. It seems the initial drawing state when drawing a list item is different from BeOS. Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/TestResultItem.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/TestResultItem.cpp 2007-09-06 10:40:47 UTC (rev 22190) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/TestResultItem.cpp 2007-09-06 15:50:31 UTC (rev 22191) @@ -33,6 +33,7 @@ void TestResultItem::DrawItem(BView *owner, BRect itemRect, bool drawEverthing) { + owner->SetDrawingMode(B_OP_COPY); owner->PushState(); if (IsSelected()) { owner->SetHighColor(128, 128, 128); @@ -83,6 +84,7 @@ if (fErrorMessage.Length() == 0) return; + owner->PushState(); font.SetFace(B_ITALIC_FACE); owner->SetFont(&font); From laplace at mail.berlios.de Thu Sep 6 18:00:20 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Thu, 6 Sep 2007 18:00:20 +0200 Subject: [Haiku-commits] r22192 - haiku/trunk/src/tests/kits/interface/flatten_picture Message-ID: <200709061600.l86G0K0r026372@sheep.berlios.de> Author: laplace Date: 2007-09-06 18:00:20 +0200 (Thu, 06 Sep 2007) New Revision: 22192 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22192&view=rev Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp Log: * More error checking. * Added more bitmap test cases. Reveals a interface kit bug: the 1024x768 bitmap is not drawn at all! Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp 2007-09-06 15:50:31 UTC (rev 22191) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp 2007-09-06 16:00:20 UTC (rev 22192) @@ -16,7 +16,7 @@ #define TEST_AND_RETURN(condition, message, result) \ { \ if (condition) { \ - fErrorMessage = message; \ + SetErrorMessage(message); \ return result; \ } \ } @@ -173,6 +173,13 @@ fErrorMessage = ""; } +void +PictureTest::SetErrorMessage(const char *message) +{ + if (fErrorMessage.Length() == 0) + fErrorMessage = message; +} + bool PictureTest::Test(draw_func* func, BRect frame) { @@ -205,8 +212,7 @@ PictureTest::CreateBitmap(draw_func* func, BRect frame) { OffscreenBitmap bitmap(frame, fColorSpace); - if (bitmap.InitCheck() != B_OK) - return NULL; + TEST_AND_RETURN(bitmap.InitCheck() != B_OK, "Offscreen bitmap for direct drawing could not be created!" , NULL); func(bitmap.View(), frame); return bitmap.Copy(); } @@ -215,8 +221,7 @@ PictureTest::RecordPicture(draw_func* func, BRect frame) { OffscreenBitmap bitmap(frame, fColorSpace); - if (bitmap.InitCheck() != B_OK) - return NULL; + TEST_AND_RETURN(bitmap.InitCheck() != B_OK, "Offscreen bitmap for picture recording could not be created!" , NULL); BView *view = bitmap.View(); // record @@ -232,8 +237,7 @@ PictureTest::CreateBitmap(BPicture *picture, BRect frame) { OffscreenBitmap bitmap(frame, fColorSpace); - if (bitmap.InitCheck() != B_OK) - return NULL; + TEST_AND_RETURN(bitmap.InitCheck() != B_OK, "Offscreen bitmap for picture drawing could not be created!" , NULL); BView *view = bitmap.View(); view->DrawPicture(picture); @@ -265,15 +269,13 @@ { BMallocIO *data = new BMallocIO(); AutoDelete _data(data); - if (data == NULL) - return NULL; + TEST_AND_RETURN(data == NULL, "BMallocIO could not be allocated for flattening the picture!" , NULL); picture->Flatten(data); data->Seek(0, SEEK_SET); BPicture *archivedPicture = new BPicture(); - if (archivedPicture == NULL) - return NULL; + TEST_AND_RETURN(archivedPicture == NULL, "BPicture could not be allocated for unflattening the picture!" , NULL); archivedPicture->Unflatten(data); return archivedPicture; @@ -287,13 +289,16 @@ ArchivePictureTest::SaveAndRestore(BPicture *picture) { BMessage archive; - if (picture->Archive(&archive) != B_OK) - return NULL; + TEST_AND_RETURN(picture->Archive(&archive) != B_OK, "Picture could not be archived to BMessage", NULL); - BPicture *archivedPicture = new BPicture(&archive); - if (archivedPicture == NULL) - return NULL; + BArchivable *archivable = BPicture::Instantiate(&archive); + AutoDelete _archivable(archivable); + TEST_AND_RETURN(archivable == NULL, "Picture could not be instantiated from BMessage", NULL); + + BPicture *archivedPicture = dynamic_cast(archivable); + TEST_AND_RETURN(archivedPicture == NULL, "Picture could not be restored from BMessage", NULL); + _archivable.Release(); return archivedPicture; } Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h 2007-09-06 15:50:31 UTC (rev 22191) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h 2007-09-06 16:00:20 UTC (rev 22192) @@ -32,6 +32,7 @@ protected: virtual BPicture *SaveAndRestore(BPicture *picture) = 0; + void SetErrorMessage(const char* message); private: Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2007-09-06 15:50:31 UTC (rev 22191) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2007-09-06 16:00:20 UTC (rev 22192) @@ -315,22 +315,72 @@ view->InvertRect(frame); } -static void testBitmap(BView *view, BRect frame) { - BBitmap bitmap(frame, B_RGBA32); - for (int32 y = 0; y < bitmap.Bounds().IntegerHeight(); y ++) { - for (int32 x = 0; x < bitmap.Bounds().IntegerWidth(); x ++) { +static bool isBorder(int32 x, int32 y, int32 width, int32 height) { + return x == 0 || y == 0 || x == width - 1 || y == height - 1; +} + +static void fillBitmap(BBitmap &bitmap) { + int32 height = bitmap.Bounds().IntegerHeight()+1; + int32 width = bitmap.Bounds().IntegerWidth()+1; + for (int32 y = 0; y < height; y ++) { + for (int32 x = 0; x < width; x ++) { char *pixel = (char*)bitmap.Bits(); pixel += bitmap.BytesPerRow() * y + 4 * x; - // fill with blue - pixel[0] = 255; - pixel[1] = 0; - pixel[2] = 0; - pixel[3] = 255; + if (isBorder(x, y, width, height)) { + // fill with green + pixel[0] = 255; + pixel[1] = 0; + pixel[2] = 255; + pixel[3] = 0; + } else { + // fill with blue + pixel[0] = 255; + pixel[1] = 0; + pixel[2] = 0; + pixel[3] = 255; + } } } +} + +static void testDrawBitmap(BView *view, BRect frame) { + BBitmap bitmap(frame, B_RGBA32); + fillBitmap(bitmap); view->DrawBitmap(&bitmap, BPoint(0, 0)); } +static void testDrawBitmapAtPoint(BView *view, BRect frame) { + frame.InsetBy(2, 2); + + BRect bounds(frame); + bounds.OffsetTo(0, 0); + bounds.right /= 2; + bounds.bottom /= 2; + + BBitmap bitmap(bounds, B_RGBA32); + fillBitmap(bitmap); + view->DrawBitmap(&bitmap, centerPoint(frame)); +} + +static void testDrawBitmapAtRect(BView *view, BRect frame) { + BRect bounds(frame); + BBitmap bitmap(bounds, B_RGBA32); + fillBitmap(bitmap); + frame.InsetBy(2, 2); + view->DrawBitmap(&bitmap, frame); +} + +static void testDrawLargeBitmap(BView *view, BRect frame) { + BRect bounds(frame); + bounds.OffsetTo(0, 0); + bounds.left = 1024; + bounds.bottom = 767; + BBitmap bitmap(bounds, B_RGBA32); + fillBitmap(bitmap); + frame.InsetBy(2, 2); + view->DrawBitmap(&bitmap, frame); +} + static void testConstrainClippingRegion(BView *view, BRect frame) { frame.InsetBy(2, 2); @@ -672,7 +722,10 @@ { "Test AppendToPicture", testAppendToPicture }, { "Test LineArray", testLineArray }, { "Test InvertRect", testInvertRect }, - { "Test Bitmap", testBitmap }, + { "Test DrawBitmap", testDrawBitmap }, + { "Test DrawBitmapAtPoint", testDrawBitmapAtPoint }, + { "Test DrawBitmapAtRect", testDrawBitmapAtRect }, + { "Test DrawDrawLargeBitmap", testDrawLargeBitmap }, { "Test ConstrainClippingRegion", testConstrainClippingRegion }, { "Test ClipToPicture", testClipToPicture }, { "Test ClipToInversePicture", testClipToInversePicture }, From laplace at mail.berlios.de Thu Sep 6 18:17:08 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Thu, 6 Sep 2007 18:17:08 +0200 Subject: [Haiku-commits] r22193 - haiku/trunk/src/tests/kits/interface/flatten_picture Message-ID: <200709061617.l86GH8Fc027208@sheep.berlios.de> Author: laplace Date: 2007-09-06 18:17:08 +0200 (Thu, 06 Sep 2007) New Revision: 22193 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22193&view=rev Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp Log: Fixed typo Modified: haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp =================================================================== --- haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2007-09-06 16:00:20 UTC (rev 22192) +++ haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp 2007-09-06 16:17:08 UTC (rev 22193) @@ -725,7 +725,7 @@ { "Test DrawBitmap", testDrawBitmap }, { "Test DrawBitmapAtPoint", testDrawBitmapAtPoint }, { "Test DrawBitmapAtRect", testDrawBitmapAtRect }, - { "Test DrawDrawLargeBitmap", testDrawLargeBitmap }, + { "Test DrawLargeBitmap", testDrawLargeBitmap }, { "Test ConstrainClippingRegion", testConstrainClippingRegion }, { "Test ClipToPicture", testClipToPicture }, { "Test ClipToInversePicture", testClipToInversePicture }, From korli at mail.berlios.de Thu Sep 6 20:12:34 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 6 Sep 2007 20:12:34 +0200 Subject: [Haiku-commits] r22194 - in haiku/trunk/src: add-ons/kernel/bus_managers/firewire bin/fwcontrol Message-ID: <200709061812.l86ICYKm018954@sheep.berlios.de> Author: korli Date: 2007-09-06 20:12:33 +0200 (Thu, 06 Sep 2007) New Revision: 22194 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22194&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/00README.haiku haiku/trunk/src/bin/fwcontrol/fwcontrol.c Log: patch from JiSheng: fixed usage for option -M, added examples for testing Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/00README.haiku =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/00README.haiku 2007-09-06 16:17:08 UTC (rev 22193) +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/00README.haiku 2007-09-06 18:12:33 UTC (rev 22194) @@ -92,6 +92,27 @@ Physical layer chip - This does not matter, most physical layer chip should work +6. Example + fwcontrol + Output a list of devices that are connected to the bus + + fwcontrol -t + Show the topology map + + fwcontrol -c 0 + Show the config rom of node 0 + + fwcontrol -r + trigger bus reset + + fwcontrol -R mini.dv + Receive DV or MPEG TS stream and save it in mini.dv. Press Ctrl-C to + stop receiving data. + Note: the program will try to guess which mode first + + fwcontrol -M d -R mini.dv + Explicitly specify receiving via DV mode. + References: [1] IEEE 1394-1995 [2] IEEE 1394a-2000 Modified: haiku/trunk/src/bin/fwcontrol/fwcontrol.c =================================================================== --- haiku/trunk/src/bin/fwcontrol/fwcontrol.c 2007-09-06 16:17:08 UTC (rev 22193) +++ haiku/trunk/src/bin/fwcontrol/fwcontrol.c 2007-09-06 18:12:33 UTC (rev 22194) @@ -90,7 +90,7 @@ "fwcontrol [-u bus_num] [-rt] [-g gap_count] [-o node] " "[-b pri_req] [-c node] [-d node] [-l file] " #ifdef __HAIKU__ - "[-R file] [-S file] \n" + "[-M mode] [-R file] [-S file] \n" #else "[-R file] [-S file] [-m target]\n" #endif @@ -107,6 +107,7 @@ "\t-l: load and parse hex dump file of configuration ROM\n" "\t-R: Receive DV or MPEG TS stream\n" #ifdef __HAIKU__ + "\t-M: Specify either d for dv mode or m for mpeg mode\n" "\t-S: Send DV stream\n"); #else "\t-S: Send DV stream\n" From bonefish at mail.berlios.de Thu Sep 6 23:04:14 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Sep 2007 23:04:14 +0200 Subject: [Haiku-commits] r22195 - haiku/trunk/src/add-ons/kernel/file_systems/bfs Message-ID: <200709062104.l86L4ERJ029567@sheep.berlios.de> Author: bonefish Date: 2007-09-06 23:04:13 +0200 (Thu, 06 Sep 2007) New Revision: 22195 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22195&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp Log: Changes in BPlusTree::_SplitNode(): * Added check for invalid keyIndex parameter. * Removed superfluous break condition in the second loop. * Increment "out" in the second loop only when we have processed a key that will end up in the node. Thus, after the loop, the variable will contain the numbers of keys to be copied/moved, not that number + 1. Adjusted later use of "out" accordingly, save in one place where it was used incorrectly, which resulted in one key length and value to many to be copied, thus occasionally causing a page fault (bug #1363). Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2007-09-06 18:12:33 UTC (rev 22194) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp 2007-09-06 21:04:13 UTC (rev 22195) @@ -1001,6 +1001,12 @@ uint8 *outKeys = other->Keys(); int32 keyIndex = *_keyIndex; // can become less than zero! + if (keyIndex > node->NumKeys()) { + FATAL(("key index out of bounds: %d, num keys: %d\n", keyIndex, + node->NumKeys())); + return B_BAD_VALUE; + } + // how many keys will fit in one (half) page? // that loop will find the answer to this question and // change the key lengths indices for their new home @@ -1140,6 +1146,7 @@ bytesBefore = in > skip ? BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in - 1]) : 0; bytes = *_keyLength; + out++; } else { if (in < node->NumKeys()) { inKeyLengths[in] = HOST_ENDIAN_TO_BFS_INT16( @@ -1152,22 +1159,14 @@ bytesAfter = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - bytesBefore - bytes; } + out++; } in++; } - - out++; - - // break out when all keys are done - if (in > node->NumKeys() && keyIndex < in) - break; } // adjust the byte counts (since we were a bit lazy in the loop) - if (keyIndex >= in && keyIndex - skip < out) { - bytesAfter = BFS_ENDIAN_TO_HOST_INT16(inKeyLengths[in]) - - bytesBefore - total; - } else if (keyIndex < skip) + if (keyIndex < skip) bytesBefore = node->AllKeyLength() - total; if (bytesBefore < 0 || bytesAfter < 0) { @@ -1180,7 +1179,7 @@ // right link, and overflow link can stay the same node->all_key_length = HOST_ENDIAN_TO_BFS_INT16(bytes + bytesBefore + bytesAfter); - node->all_key_count = HOST_ENDIAN_TO_BFS_INT16(out - 1); + node->all_key_count = HOST_ENDIAN_TO_BFS_INT16(out); // array positions have changed outKeyLengths = node->KeyLengths(); @@ -1189,7 +1188,7 @@ // move the keys in the old node: the order is important here, // because we don't want to overwrite any contents - keys = keyIndex <= skip ? out - 1 : keyIndex - skip; + keys = keyIndex <= skip ? out : keyIndex - skip; keyIndex -= skip; in = out - keyIndex - 1; // Note: keyIndex and in will contain invalid values when the new key From stippi at mail.berlios.de Fri Sep 7 01:02:42 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 7 Sep 2007 01:02:42 +0200 Subject: [Haiku-commits] r22196 - haiku/trunk/src/apps/installer Message-ID: <200709062302.l86N2gNf022117@sheep.berlios.de> Author: stippi Date: 2007-09-07 01:02:41 +0200 (Fri, 07 Sep 2007) New Revision: 22196 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22196&view=rev Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp Log: * CopyEngine::Start() didn't return something at the end of the function * CopyEngine::CopyFolder() forgot to GetName(name) before using "name" in strcmp() * "delete" already checks for NULL Modified: haiku/trunk/src/apps/installer/CopyEngine.cpp =================================================================== --- haiku/trunk/src/apps/installer/CopyEngine.cpp 2007-09-06 21:04:13 UTC (rev 22195) +++ haiku/trunk/src/apps/installer/CopyEngine.cpp 2007-09-06 23:02:41 UTC (rev 22196) @@ -232,6 +232,8 @@ BMessage msg(INSTALL_FINISHED); BMessenger(fWindow).SendMessage(&msg); + + return B_OK; } @@ -247,8 +249,10 @@ Undo undo; if (S_ISDIR(statbuf.st_mode)) { char name[B_FILE_NAME_LENGTH]; - if (strcmp(name, PACKAGES_DIRECTORY) == 0) + if (entry.GetName(name) == B_OK + && strcmp(name, PACKAGES_DIRECTORY) == 0) { continue; + } err = FSCopyFolder(&entry, &targetDir, fControl, NULL, false, undo); } else { err = FSCopyFile(&entry, &statbuf, &targetDir, fControl, NULL, false, undo); @@ -281,8 +285,7 @@ void CopyEngine::SetPackagesList(BList *list) { - if (fPackages) - delete fPackages; + delete fPackages; fPackages = list; } From bonefish at mail.berlios.de Fri Sep 7 01:47:08 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 7 Sep 2007 01:47:08 +0200 Subject: [Haiku-commits] r22197 - haiku/trunk/src/system/kernel/disk_device_manager/jobs Message-ID: <200709062347.l86Nl8JO021767@sheep.berlios.de> Author: bonefish Date: 2007-09-07 01:47:07 +0200 (Fri, 07 Sep 2007) New Revision: 22197 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22197&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp Log: When avoiding to rescan a partition, we still have to recurse so that its unidentified children can be scanned, if necessary. Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-09-06 23:02:41 UTC (rev 22196) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-09-06 23:47:07 UTC (rev 22197) @@ -76,6 +76,8 @@ return B_BAD_VALUE; if (partition->DiskSystem() != NULL) { // TODO: this is more or less a hack to prevent rescanning a partition + for (int32 i = 0; KPartition *child = partition->ChildAt(i); i++) + _ScanPartition(child); return B_OK; } From bonefish at mail.berlios.de Fri Sep 7 02:05:07 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Fri, 7 Sep 2007 02:05:07 +0200 Subject: [Haiku-commits] r22198 - in haiku/trunk: headers/private/kernel/disk_device_manager src/system/kernel/disk_device_manager Message-ID: <200709070005.l87057cI022259@sheep.berlios.de> Author: bonefish Date: 2007-09-07 02:05:06 +0200 (Fri, 07 Sep 2007) New Revision: 22198 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22198&view=rev Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp Log: Partitions do now know whether they have already been published and avoid attempts to publish a second time. Modified: haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h =================================================================== --- haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-09-06 23:47:07 UTC (rev 22197) +++ haiku/trunk/headers/private/kernel/disk_device_manager/KPartition.h 2007-09-07 00:05:06 UTC (rev 22198) @@ -49,6 +49,7 @@ virtual status_t Open(int flags, int *fd); virtual status_t PublishDevice(); virtual status_t UnpublishDevice(); + bool IsPublished() const; void SetBusy(bool busy); bool IsBusy() const; @@ -234,6 +235,7 @@ uint32 fAlgorithmData; int32 fReferenceCount; bool fObsolete; + bool fPublished; static int32 fNextID; }; Modified: haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-09-06 23:47:07 UTC (rev 22197) +++ haiku/trunk/src/system/kernel/disk_device_manager/KDiskDevice.cpp 2007-09-07 00:05:06 UTC (rev 22198) @@ -31,6 +31,7 @@ { Unset(); fDevice = this; + fPublished = true; } // destructor Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-09-06 23:47:07 UTC (rev 22197) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPartition.cpp 2007-09-07 00:05:06 UTC (rev 22198) @@ -46,7 +46,8 @@ fChangeCounter(0), fAlgorithmData(0), fReferenceCount(0), - fObsolete(false) + fObsolete(false), + fPublished(false) { fPartitionData.id = (id >= 0 ? id : _NextID()); fPartitionData.offset = 0; @@ -164,6 +165,15 @@ return B_ERROR; } + +// IsPublished +bool +KPartition::IsPublished() const +{ + return fPublished; +} + + // SetBusy void KPartition::SetBusy(bool busy) Modified: haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp 2007-09-06 23:47:07 UTC (rev 22197) +++ haiku/trunk/src/system/kernel/disk_device_manager/KPhysicalPartition.cpp 2007-09-07 00:05:06 UTC (rev 22198) @@ -37,7 +37,6 @@ { } -// Register // PrepareForRemoval bool KPhysicalPartition::PrepareForRemoval() @@ -72,6 +71,9 @@ status_t KPhysicalPartition::PublishDevice() { + if (fPublished) + return B_OK; + // get the path KPath path; status_t error = GetPath(&path); @@ -90,20 +92,31 @@ return B_NAME_TOO_LONG; } - return devfs_publish_partition(path.Path() + 5, &info); + error = devfs_publish_partition(path.Path() + 5, &info); // we need to remove the "/dev/" part from the path + if (error != B_OK) + return error; + + fPublished = true; + + return B_OK; } // UnpublishDevice status_t KPhysicalPartition::UnpublishDevice() { + if (!fPublished) + return B_OK; + // get the path KPath path; status_t error = GetPath(&path); if (error != B_OK) return error; + fPublished = false; + return devfs_unpublish_partition(path.Path() + 5); // we need to remove the "/dev/" part from the path } From stippi at mail.berlios.de Fri Sep 7 12:23:13 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 7 Sep 2007 12:23:13 +0200 Subject: [Haiku-commits] r22199 - haiku/trunk/src/preferences/time Message-ID: <200709071023.l87ANDed031638@sheep.berlios.de> Author: stippi Date: 2007-09-07 12:23:12 +0200 (Fri, 07 Sep 2007) New Revision: 22199 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22199&view=rev Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp haiku/trunk/src/preferences/time/AnalogClock.h haiku/trunk/src/preferences/time/Jamfile haiku/trunk/src/preferences/time/SettingsView.cpp haiku/trunk/src/preferences/time/SettingsView.h haiku/trunk/src/preferences/time/TimeMessages.h haiku/trunk/src/preferences/time/TimeWindow.cpp haiku/trunk/src/preferences/time/TimeWindow.h haiku/trunk/src/preferences/time/ZoneView.cpp haiku/trunk/src/preferences/time/ZoneView.h Log: * applied another large patch to cleanup and refactor code by Julun (aka HOST) * Julun also fixed some font sensitivity issues * Julun already replaced the bitmap clock with resizable clock rendering, I took this as a base and tried to make it visually pleasing Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.cpp 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/AnalogClock.cpp 2007-09-07 10:23:12 UTC (rev 22199) @@ -4,169 +4,190 @@ * * Authors: * Mike Berg (inseculous) + * Julun + * Stephan A?mus */ -/*! Notes: OffscreenClock borrows heavily from the clock source. */ - - #include "AnalogClock.h" -#include "Bitmaps.h" #include "TimeMessages.h" -#include + #include -#include -#include -#include +#include class OffscreenClock : public BView { public: - OffscreenClock(BRect frame, const char *name); - virtual ~OffscreenClock(); + OffscreenClock(BRect frame, const char *name); + ~OffscreenClock(); - void DrawClock(); - BPoint Position(); + void SetTo(int32 hour, int32 minute, int32 second); + bool IsDirty() const + { return fDirty; } + void DrawClock(); - void SetTo(int32 hour, int32 minute, int32 second); - private: - BBitmap *fBitmap; - BBitmap *fCenterBitmap; - BBitmap *fCapBitmap; - BPoint fCenter; + void _DrawHands(float x, float y, float radius, + rgb_color hourMinuteColor, rgb_color secondsColor); - BPoint fMinutePoints[60]; - BPoint fHourPoints[60]; - short fHours; - short fMinutes; - short fSeconds; + int32 fHours; + int32 fMinutes; + int32 fSeconds; + bool fDirty; }; -const BRect kClockRect(0, 0, kClockFaceWidth -1, kClockFaceHeight -1); -const BRect kCenterRect(0, 0, kCenterWidth -1, kCenterHeight -1); -const BRect kCapRect(0, 0, kCapWidth -1, kCapHeight -1); -/*! - Analog Clock face rendering view. -*/ OffscreenClock::OffscreenClock(BRect frame, const char *name) - : BView(frame, name, B_NOT_RESIZABLE, B_WILL_DRAW) + : BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW), + fHours(0), + fMinutes(0), + fSeconds(0), + fDirty(true) { - fBitmap = new BBitmap(kClockRect, kClockFaceColorSpace); - fBitmap->SetBits(kClockFaceBits, (kClockFaceWidth) *(kClockFaceHeight +3), 0, kClockFaceColorSpace); - - ReplaceTransparentColor(fBitmap, ui_color(B_PANEL_BACKGROUND_COLOR)); - - fCenterBitmap = new BBitmap(kCenterRect, kCenterColorSpace); - fCenterBitmap->SetBits(kCenterBits, (kCenterWidth) *(kCenterHeight +1), 0, kCenterColorSpace); - - fCapBitmap = new BBitmap(kCapRect, kCapColorSpace); - fCapBitmap->SetBits(kCapBits, (kCapWidth +1) *(kCapHeight +1) +1, 0, kCapColorSpace); - - fCenter = BPoint(42, 42); - - float counter; - short index; - float x, y, mRadius, hRadius; - - mRadius = fCenter.x - 12; - hRadius = mRadius - 10; - index = 0; - - // - // Generate minutes/hours points array - // - for (counter = 90; counter >= 0; counter -= 6,index++) { - x = mRadius * cos(((360 - counter)/180.0) * 3.1415); - x += fCenter.x; - y = mRadius * sin(((360 - counter)/180.0) * 3.1415); - y += fCenter.x; - fMinutePoints[index].Set(x,y); - x = hRadius * cos(((360 - counter)/180.0) * 3.1415); - x += fCenter.x; - y = hRadius * sin(((360 - counter)/180.0) * 3.1415); - y += fCenter.x; - fHourPoints[index].Set(x,y); - } - - for (counter = 354; counter > 90; counter -= 6,index++) { - x = mRadius * cos(((360 - counter)/180.0) * 3.1415); - x += fCenter.x; - y = mRadius * sin(((360 - counter)/180.0) * 3.1415); - y += fCenter.x; - fMinutePoints[index].Set(x,y); - x = hRadius * cos(((360 - counter)/180.0) * 3.1415); - x += fCenter.x; - y = hRadius * sin(((360 - counter)/180.0) * 3.1415); - y += fCenter.x; - fHourPoints[index].Set(x,y); - } + SetFlags(Flags() | B_SUBPIXEL_PRECISE); } OffscreenClock::~OffscreenClock() -{ - delete fBitmap; - delete fCenterBitmap; - delete fCapBitmap; +{ } void OffscreenClock::SetTo(int32 hour, int32 minute, int32 second) { - if (fSeconds != second || fMinutes != minute || fHours != hour) { - fHours = hour; - fMinutes = minute; - fSeconds = second; - } + if (fHours == hour && fMinutes == minute && fSeconds == second) + return; + + fHours = hour; + fMinutes = minute; + fSeconds = second; + + fDirty = true; } void OffscreenClock::DrawClock() { - ASSERT(Window()->IsLocked()); + if (!LockLooper()) + return; - // draw clockface - SetDrawingMode(B_OP_COPY); - DrawBitmap(fBitmap, BPoint(0, 0)); + BRect bounds = Bounds(); + // clear background + rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); + SetHighColor(background); + FillRect(bounds); - SetHighColor(0, 0, 0, 255); + float radius = floorf((MIN(bounds.Width(), bounds.Height()) / 2.0)) - 2.5; + float x = floorf((bounds.left + bounds.right) / 2 + 0.5) + 0.5; + float y = floorf((bounds.top + bounds.bottom) / 2 + 0.5) + 0.5; + // + 0.5 is for the offset to pixel centers + // (important when drawing with B_SUBPIXEL_PRECISE) - short hours = fHours; - if (hours >= 12) - hours -= 12; + bounds.Set(x - radius, y - radius, x + radius, y + radius); - hours *= 5; - hours += (fMinutes / 12); + SetPenSize(2.0); - // draw center hub - SetDrawingMode(B_OP_OVER); - DrawBitmap(fCenterBitmap, fCenter - BPoint(kCenterWidth/2.0, kCenterHeight/2.0)); + SetHighColor(tint_color(background, B_DARKEN_1_TINT)); + StrokeEllipse(bounds.OffsetByCopy(-1, -1)); - // draw hands - StrokeLine(fCenter, fHourPoints[hours]); - StrokeLine(fCenter, fMinutePoints[fMinutes]); - SetHighColor(tint_color(HighColor(), B_LIGHTEN_1_TINT)); - StrokeLine(fCenter, fMinutePoints[fSeconds]); + SetHighColor(tint_color(background, B_LIGHTEN_2_TINT)); + StrokeEllipse(bounds.OffsetByCopy(1, 1)); - // draw center cap - DrawBitmap(fCapBitmap, fCenter -BPoint(kCapWidth/2.0, kCapHeight/2.0)); + SetHighColor(tint_color(background, B_DARKEN_3_TINT)); + StrokeEllipse(bounds); + SetLowColor(255, 255, 255); + FillEllipse(bounds, B_SOLID_LOW); + radius -= 3; + + SetHighColor(tint_color(HighColor(), B_DARKEN_2_TINT)); + + // minutes + SetPenSize(1.0); + SetLineMode(B_BUTT_CAP, B_MITER_JOIN); + for (int32 minute = 1; minute < 60; minute++) { + if (minute % 5 == 0) + continue; + float x1 = x + sinf(minute * PI / 30.0) * radius; + float y1 = y + cosf(minute * PI / 30.0) * radius; + float x2 = x + sinf(minute * PI / 30.0) * (radius * 0.95); + float y2 = y + cosf(minute * PI / 30.0) * (radius * 0.95); + StrokeLine(BPoint(x1, y1), BPoint(x2, y2)); + } + + SetHighColor(tint_color(HighColor(), B_DARKEN_1_TINT)); + + // hours + SetPenSize(2.0); + SetLineMode(B_ROUND_CAP, B_MITER_JOIN); + for (int32 hour = 0; hour < 12; hour++) { + float x1 = x + sinf(hour * PI / 6.0) * radius; + float y1 = y + cosf(hour * PI / 6.0) * radius; + float x2 = x + sinf(hour * PI / 6.0) * (radius * 0.9); + float y2 = y + cosf(hour * PI / 6.0) * (radius * 0.9); + StrokeLine(BPoint(x1, y1), BPoint(x2, y2)); + } + + rgb_color hourMinutColor = tint_color(HighColor(), B_DARKEN_2_TINT); + rgb_color secondsColor = (rgb_color){ 255, 0, 0, 255 }; + rgb_color shadowColor = tint_color(LowColor(), + (B_DARKEN_1_TINT + B_DARKEN_2_TINT) / 2); + + _DrawHands(x + 1.5, y + 1.5, radius, shadowColor, shadowColor); + _DrawHands(x, y, radius, hourMinutColor, secondsColor); + Sync(); + + UnlockLooper(); } +void +OffscreenClock::_DrawHands(float x, float y, float radius, + rgb_color hourMinuteColor, rgb_color secondsColor) +{ + SetHighColor(hourMinuteColor); + + float offsetX; + float offsetY; + + // calc, draw hour hand + SetPenSize(4.0); + float hours = fHours + float(fMinutes) / 60.0; + offsetX = (radius * 0.7) * sinf((hours * PI) / 6.0); + offsetY = (radius * 0.7) * cosf((hours * PI) / 6.0); + StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY)); + + // calc, draw minute hand + SetPenSize(3.0); + float minutes = fMinutes + float(fSeconds) / 60.0; + offsetX = (radius * 0.9) * sinf((minutes * PI) / 30.0); + offsetY = (radius * 0.9) * cosf((minutes * PI) / 30.0); + StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY)); + + SetHighColor(secondsColor); + + // calc, draw second hand + SetPenSize(1.0); + offsetX = (radius * 0.95) * sinf((fSeconds * PI) / 30.0); + offsetY = (radius * 0.95) * cosf((fSeconds * PI) / 30.0); + StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY)); + + // draw the center knob + SetHighColor(hourMinuteColor); + FillEllipse(BPoint(x, y), radius * 0.06, radius * 0.06); +} + + // #pragma mark - -/*! - BView to display clock face of current time. -*/ -TAnalogClock::TAnalogClock(BRect frame, const char *name, uint32 resizingmode, uint32 flags) - : BView(frame, name, resizingmode, flags | B_DRAW_ON_CHILDREN) +TAnalogClock::TAnalogClock(BRect frame, const char *name, uint32 resizeMask, uint32 flags) + : BView(frame, name, resizeMask, flags | B_DRAW_ON_CHILDREN), + fBitmap(NULL), + fClock(NULL) { _InitView(frame); } @@ -181,8 +202,8 @@ void TAnalogClock::_InitView(BRect rect) { - fClock = new OffscreenClock(kClockRect, "offscreen"); - fBitmap = new BBitmap(kClockRect, B_CMAP8, true); + fClock = new OffscreenClock(Bounds(), "offscreen"); + fBitmap = new BBitmap(Bounds(), B_RGB32, true); fBitmap->Lock(); fBitmap->AddChild(fClock); fBitmap->Unlock(); @@ -230,12 +251,10 @@ void TAnalogClock::Draw(BRect /*updateRect*/) { - SetHighColor(0, 100, 10); - - if (fBitmap->Lock()) { - fClock->DrawClock(); + if (fBitmap) { + if (fClock->IsDirty()) + fClock->DrawClock(); DrawBitmap(fBitmap, BPoint(0, 0)); - fBitmap->Unlock(); } } @@ -243,6 +262,9 @@ void TAnalogClock::SetTo(int32 hour, int32 minute, int32 second) { - fClock->SetTo(hour, minute, second); + if (fClock) + fClock->SetTo(hour, minute, second); + Invalidate(); } + Modified: haiku/trunk/src/preferences/time/AnalogClock.h =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.h 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/AnalogClock.h 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,34 +1,40 @@ /* - * Copyright 2004-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Mike Berg (inseculous) + * Julun */ #ifndef ANALOG_CLOCK_H #define ANALOG_CLOCK_H -#include + #include + +class BBitmap; class OffscreenClock; -class TAnalogClock: public BView { + +class TAnalogClock : public BView { public: - TAnalogClock(BRect frame, const char *name, uint32 resizingmode, uint32 flags); - virtual ~TAnalogClock(); + TAnalogClock(BRect frame, const char *name, + uint32 resizeMask, uint32 flags); + virtual ~TAnalogClock(); - virtual void AttachedToWindow(); - virtual void Draw(BRect updaterect); - virtual void MessageReceived(BMessage *); + virtual void AttachedToWindow(); + virtual void Draw(BRect updateRect); + virtual void MessageReceived(BMessage *message); - void SetTo(int32 hour, int32 minute, int32 second); + void SetTo(int32 hour, int32 minute, int32 second); private: - void _InitView(BRect frame); + void _InitView(BRect frame); - BBitmap *fBitmap; - OffscreenClock *fClock; + BBitmap *fBitmap; + OffscreenClock *fClock; }; #endif // ANALOG_CLOCK_H + Modified: haiku/trunk/src/preferences/time/Jamfile =================================================================== --- haiku/trunk/src/preferences/time/Jamfile 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/Jamfile 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,6 +1,7 @@ SubDir HAIKU_TOP src preferences time ; SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; Preference Time : AnalogClock.cpp @@ -20,3 +21,7 @@ : Time.rdef ; +if $(TARGET_PLATFORM) = libbe_test { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Time + : tests!apps ; +} Modified: haiku/trunk/src/preferences/time/SettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,6 +1,18 @@ /* - SettingsView.cpp -*/ + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + * Julun + */ + +#include "SettingsView.h" +#include "AnalogClock.h" +#include "CalendarView.h" +#include "DateTimeEdit.h" +#include "TimeMessages.h" + #include #include #include @@ -9,17 +21,12 @@ #include #include -#include "Bitmaps.h" -#include "SettingsView.h" -#include "TimeMessages.h" - -/*=====> TSettingsView <=====*/ - TSettingsView::TSettingsView(BRect frame) : BView(frame,"Settings", B_FOLLOW_ALL, - B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP) -{ + B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), + fGmtTime(NULL) +{ InitView(); } @@ -64,74 +71,100 @@ void +TSettingsView::GetPreferredSize(float *width, float *height) +{ + // hardcode in TimeWindow ... + *width = 361.0f; + *height = 227.0f; + + if (fGmtTime) { + // we are initialized + *width = Bounds().Width(); + *height = fGmtTime->Frame().bottom; + } +} + + +void TSettingsView::InitView() { - ReadFiles(); + ReadRTCSettings(); - font_height finfo; - be_plain_font->GetHeight(&finfo); - float text_height = finfo.descent +finfo.ascent +finfo.leading; + font_height fontHeight; + be_plain_font->GetHeight(&fontHeight); + float textHeight = fontHeight.descent + fontHeight.ascent + fontHeight.leading; - BRect bounds(Bounds()); - bounds.right = (bounds.Width()/2.0) -5; + // left side + BRect frameLeft(Bounds()); + frameLeft.right = frameLeft.Width() / 2; + frameLeft.InsetBy(10.0f, 10.0f); + frameLeft.bottom = frameLeft.top + textHeight +6; - BRect frame(bounds); - - // left side - frame.InsetBy(6, 6); - frame.bottom = frame.top +text_height +6; - f_dateedit = new TDateEdit(frame, "date_edit", 3); - - frame.top = f_dateedit->Frame().bottom; - frame.bottom = bounds.bottom; - frame.InsetBy(10, 8); - - f_calendar = new TCalendarView(frame, "calendar", B_FOLLOW_NONE, B_WILL_DRAW); - - AddChild(f_dateedit); - AddChild(f_calendar); - + fDateEdit = new TDateEdit(frameLeft, "date_edit", 3); + AddChild(fDateEdit); + + frameLeft.top = fDateEdit->Frame().bottom + 10; + frameLeft.bottom = Bounds().bottom - 10; + + fCalendar = new TCalendarView(frameLeft, "calendar", B_FOLLOW_NONE, B_WILL_DRAW); + AddChild(fCalendar); + + frameLeft.top = fCalendar->Frame().bottom + 10; + BStringView *text = new BStringView(frameLeft, "timezone", "Timezone:"); + AddChild(text); + text->ResizeToPreferred(); + + frameLeft.left += 20.0f; + frameLeft.top = text->Frame().bottom + 5; + + fTimeZone = new BStringView(frameLeft, "label", " "); + AddChild(fTimeZone); + // right side - bounds.OffsetBy(bounds.Width() +9, 0); - f_temp = bounds; - frame = bounds; - frame.InsetBy(26, 6); - frame.bottom = frame.top +text_height +6; - frame.right += 4; - f_timeedit = new TTimeEdit(frame, "time_edit", 4); - AddChild(f_timeedit); + BRect frameRight(Bounds()); + frameRight.left = frameRight.Width() / 2; + frameRight.InsetBy(10.0f, 10.0f); + frameRight.bottom = frameRight.top + textHeight +6; + + fTimeEdit = new TTimeEdit(frameRight, "time_edit", 4); + AddChild(fTimeEdit); + + frameRight.top = fTimeEdit->Frame().bottom + 10; + frameRight.bottom = Bounds().bottom - 10; + + float left = fTimeEdit->Frame().left; + float tmp = MIN(frameRight.Width(), frameRight.Height()); + frameRight.left = left + (fTimeEdit->Bounds().Width() - tmp) /2; + frameRight.bottom = frameRight.top + tmp; + frameRight.right = frameRight.left + tmp; - frame.top = f_timeedit->Frame().bottom; - frame.bottom = bounds.bottom -(text_height *3); - frame.InsetBy((frame.Width() - kClockFaceWidth + 1)/2.0, (frame.Height() - kClockFaceHeight + 1)/2.0); - f_clock = new TAnalogClock(frame, "analog clock", - B_FOLLOW_NONE, B_WILL_DRAW); - AddChild(f_clock); + fClock = new TAnalogClock(frameRight, "analog clock", B_FOLLOW_NONE, B_WILL_DRAW); + AddChild(fClock); // clock radio buttons - frame = bounds.InsetByCopy(6, 10); - frame.top = f_clock->Frame().bottom +12; - frame.bottom = frame.top +text_height +2; - BString label = "Clock set to:"; - float width = be_plain_font->StringWidth(label.String()); - frame.right = frame.left +width; - BStringView *text = new BStringView(frame, "clockis", "Clock set to:"); + frameRight.left = left; + frameRight.top = fClock->Frame().bottom + 10; + text = new BStringView(frameRight, "clockis", "Clock set to:"); AddChild(text); - - frame.OffsetBy(frame.Width() +9, -1); - frame.right = bounds.right-2; - - f_local = new BRadioButton(frame, "local", "Local time", new BMessage(H_RTC_CHANGE)); - AddChild(f_local); - - frame.OffsetBy(0, text_height +4); - f_gmt = new BRadioButton(frame, "gmt", "GMT", new BMessage(H_RTC_CHANGE)); - AddChild(f_gmt); - - if (f_islocal) - f_local->SetValue(1); + text->ResizeToPreferred(); + + frameRight.left += 20.0f; + frameRight.top = text->Frame().bottom + 5; + + fLocalTime = new BRadioButton(frameRight, "local", "Local time", new BMessage(H_RTC_CHANGE)); + AddChild(fLocalTime); + fLocalTime->ResizeToPreferred(); + + frameRight.left = fLocalTime->Frame().right +10.0f; + + fGmtTime = new BRadioButton(frameRight, "gmt", "GMT", new BMessage(H_RTC_CHANGE)); + AddChild(fGmtTime); + fGmtTime->ResizeToPreferred(); + + if (fIsLocalTime) + fLocalTime->SetValue(B_CONTROL_ON); else - f_gmt->SetValue(1); + fGmtTime->SetValue(B_CONTROL_ON); } @@ -145,8 +178,8 @@ rgb_color dark = tint_color(viewcolor, B_DARKEN_4_TINT); rgb_color light = tint_color(viewcolor, B_LIGHTEN_MAX_TINT); - BPoint start(bounds.Width()/2.0 +2.0, bounds.top +1); - BPoint end(bounds.Width()/2.0 +2.0, bounds.bottom -1); + BPoint start(bounds.Width() / 2.0f +2.0f, bounds.top +1.0f); + BPoint end(bounds.Width() / 2.0 +2.0f, bounds.bottom -1.0f); BeginLineArray(2); AddLine(start, end, dark); @@ -155,77 +188,80 @@ AddLine(start, end, light); EndLineArray(); - f_timeedit->Draw(bounds); - f_dateedit->Draw(bounds); + fTimeEdit->Draw(bounds); + fDateEdit->Draw(bounds); } bool TSettingsView::GMTime() { - return f_gmt->Value() == 1; + return fGmtTime->Value() == B_CONTROL_ON; } void +TSettingsView::SetTimeZone(const char *timezone) +{ + fTimeZone->SetText(timezone); + fTimeZone->ResizeToPreferred(); +} + + +void TSettingsView::UpdateDateTime(BMessage *message) { - int32 month, day, year, hour, minute, second; - + int32 day; + int32 month; + int32 year; if (message->FindInt32("month", &month) == B_OK && message->FindInt32("day", &day) == B_OK && message->FindInt32("year", &year) == B_OK) { - f_dateedit->SetTo(year, month, day); - f_calendar->SetTo(year, month, day); + fDateEdit->SetTo(year, month, day); + fCalendar->SetTo(year, month, day); } + int32 hour; + int32 minute; + int32 second; if (message->FindInt32("hour", &hour) == B_OK && message->FindInt32("minute", &minute) == B_OK && message->FindInt32("second", &second) == B_OK) { - f_timeedit->SetTo(hour, minute, second); - f_clock->SetTo(hour, minute, second); + fTimeEdit->SetTo(hour, minute, second); + fClock->SetTo(hour, minute, second); } } void -TSettingsView::ReadFiles() +TSettingsView::ReadRTCSettings() { - // do all file reading here - - // read RTC_time_settings - BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) { return; // NO USER SETTINGS DIRECTORY!!! } path.Append("RTC_time_settings"); + BFile file; BEntry entry(path.Path()); - BFile file; - if (entry.Exists()) { - //read file file.SetTo(&entry, B_READ_ONLY); - status_t err = file.InitCheck(); - if (err == B_OK) { + if (file.InitCheck() == B_OK) { char buff[6]; file.Read(buff, 6); - BString text; - text << buff; + BString text(buff); if (text.Compare("local\n", 5) == 0) - f_islocal = true; + fIsLocalTime = true; else - f_islocal = false; + fIsLocalTime = false; } } else { // create set to local - f_islocal = true; - file.SetTo(&entry, B_CREATE_FILE|B_READ_WRITE); + fIsLocalTime = true; + file.SetTo(&entry, B_CREATE_FILE | B_READ_WRITE); file.Write("local\n", 6); } - - // done reading RTC_time_settings } + Modified: haiku/trunk/src/preferences/time/SettingsView.h =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.h 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/SettingsView.h 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,43 +1,53 @@ /* - - SettingsView.h -*/ - + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + * Julun + */ #ifndef SETTINGS_VIEW_H #define SETTINGS_VIEW_H -#include + #include -#include "AnalogClock.h" -#include "CalendarView.h" -#include "DateTimeEdit.h" -class TSettingsView:public BView { +class TDateEdit; +class TTimeEdit; +class TCalendarView; +class TAnalogClock; +class BRadioButton; +class BStringView; + +class TSettingsView : public BView { public: - TSettingsView(BRect frame); - virtual ~TSettingsView(); + TSettingsView(BRect frame); + virtual ~TSettingsView(); - virtual void AttachedToWindow(); - virtual void Draw(BRect updaterect); - virtual void MessageReceived(BMessage *message); - - void ChangeRTCSetting(); - - bool GMTime(); + virtual void AttachedToWindow(); + virtual void Draw(BRect updaterect); + virtual void MessageReceived(BMessage *message); + virtual void GetPreferredSize(float *width, float *height); + + void ChangeRTCSetting(); + bool GMTime(); + void SetTimeZone(const char *timezone); + private: - void InitView(); - void ReadFiles(); // reads RTC_time_settings - void UpdateDateTime(BMessage *message); - - BRect f_temp; - BRadioButton *f_local; - BRadioButton *f_gmt; - TDateEdit *f_dateedit; - TTimeEdit *f_timeedit; - TCalendarView *f_calendar; - TAnalogClock *f_clock; - bool f_islocal; // local or gmt? + void InitView(); + void ReadRTCSettings(); + void UpdateDateTime(BMessage *message); + + BRadioButton *fLocalTime; + BRadioButton *fGmtTime; + TDateEdit *fDateEdit; + TTimeEdit *fTimeEdit; + TCalendarView *fCalendar; + TAnalogClock *fClock; + bool fIsLocalTime; + BStringView *fTimeZone; }; #endif + Modified: haiku/trunk/src/preferences/time/TimeMessages.h =================================================================== --- haiku/trunk/src/preferences/time/TimeMessages.h 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/TimeMessages.h 2007-09-07 10:23:12 UTC (rev 22199) @@ -39,3 +39,4 @@ const uint32 H_RTC_CHANGE = 'obRC'; #endif //TIME_MESSAGES_H + Modified: haiku/trunk/src/preferences/time/TimeWindow.cpp =================================================================== --- haiku/trunk/src/preferences/time/TimeWindow.cpp 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/TimeWindow.cpp 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,7 +1,10 @@ /* - * TTimeWindow.cpp - * Time mccall@@digitalparadise.co.uk - * + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * mccall@@digitalparadise.co.uk + * Julun */ #include @@ -19,7 +22,7 @@ #include "TimeSettings.h" #include "ZoneView.h" -#define TIME_WINDOW_RIGHT 361 //332 +#define TIME_WINDOW_RIGHT 400 //332 #define TIME_WINDOW_BOTTOM 227 //208 @@ -29,10 +32,13 @@ { MoveTo(dynamic_cast(be_app)->WindowCorner()); - BScreen screen; + BRect frame = Frame(); + BRect bounds = Bounds(); + BRect screenFrame = BScreen().Frame(); // Code to make sure that the window doesn't get drawn off screen... - if (!(screen.Frame().right >= Frame().right && screen.Frame().bottom >= Frame().bottom)) - MoveTo((screen.Frame().right-Bounds().right)*.5,(screen.Frame().bottom-Bounds().bottom)*.5); + if (!(screenFrame.right >= frame.right && screenFrame.bottom >= frame.bottom)) + MoveTo((screenFrame.right - bounds.right) * 0.5f, + (screenFrame.bottom - bounds.bottom) * 0.5f); InitWindow(); SetPulseRate(500000); @@ -99,7 +105,7 @@ fTimeZones = new TZoneView(bounds); if (fBaseView->StartWatchingAll(fTimeZones) != B_OK) printf("TimeZones->StartWatchingAll(TimeZone) failed!!!\n"); - + // add tabs BTab *tab = new BTab(); tabview->AddTab(fTimeSettings, tab); @@ -110,4 +116,11 @@ tab->SetLabel("Time Zone"); fBaseView->AddChild(tabview); + + float width; + float height; + fTimeSettings->GetPreferredSize(&width, &height); + // width/ height from settingsview + all InsetBy etc.. + ResizeTo(width +10, height + tabview->TabHeight() +25); } + Modified: haiku/trunk/src/preferences/time/TimeWindow.h =================================================================== --- haiku/trunk/src/preferences/time/TimeWindow.h 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/TimeWindow.h 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,3 +1,7 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef TIME_WINDOW_H #define TIME_WINDOW_H Modified: haiku/trunk/src/preferences/time/ZoneView.cpp =================================================================== --- haiku/trunk/src/preferences/time/ZoneView.cpp 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/ZoneView.cpp 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,12 +1,20 @@ /* - ZoneView.cpp - by Mike Berg (inseculous) - - Status: mimics original Time Zone tab of Time Pref App - Exceptions: doesn't calc "Time in" time. - Issues: After experimenting with both Time Prefs, it seems the original doesn't - use the link file in the users settings file to get the current Timezone. - Need to find the call it uses to get its inital info so I can get exact duplication. + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Mike Berg (inseculous) + * Julun + */ +/* + Exceptions: + doesn't calc "Time in" time. + + Issues: + After experimenting with both Time Prefs, it seems the original + doesn't use the link file in the users settings file to get the + current Timezone. Need to find the call it uses to get its + inital info so I can get exact duplication. */ #include @@ -144,6 +152,13 @@ } +const char* +TZoneView::TimeZone() +{ + return f_current->Text(); +} + + void TZoneView::UpdateDateTime(BMessage *message) { Modified: haiku/trunk/src/preferences/time/ZoneView.h =================================================================== --- haiku/trunk/src/preferences/time/ZoneView.h 2007-09-07 00:05:06 UTC (rev 22198) +++ haiku/trunk/src/preferences/time/ZoneView.h 2007-09-07 10:23:12 UTC (rev 22199) @@ -1,7 +1,11 @@ /* - ZoneView.h - Header file for the base class of the Time Zone tab in Time Pref App. -*/ + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Mike Berg (inseculous) + * Julun + */ #ifndef ZONE_VIEW_H #define ZONE_VIEW_H @@ -37,6 +41,9 @@ virtual void AttachedToWindow(); virtual void AllAttached(); virtual void MessageReceived(BMessage *message); + [... truncated: 6 lines follow ...] From HOST.HAIKU at gmx.de Fri Sep 7 12:51:10 2007 From: HOST.HAIKU at gmx.de (HOST Team) Date: Fri, 07 Sep 2007 12:51:10 +0200 Subject: [Haiku-commits] r22192 - haiku/trunk/src/tests/kits/interface/flatten_picture In-Reply-To: <200709061600.l86G0K0r026372@sheep.berlios.de> References: <200709061600.l86G0K0r026372@sheep.berlios.de> Message-ID: <46E12D1E.3080305@gmx.de> Hi, laplace at BerliOS schrieb: > Author: laplace > Date: 2007-09-06 18:00:20 +0200 (Thu, 06 Sep 2007) > New Revision: 22192 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22192&view=rev > > Modified: > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.cpp > Log: > * More error checking. > * Added more bitmap test cases. Reveals a interface kit bug: the > 1024x768 bitmap is not drawn at all! > +static void testDrawLargeBitmap(BView *view, BRect frame) { > + BRect bounds(frame); > + bounds.OffsetTo(0, 0); > + bounds.left = 1024; i may totally wrong but shouldn't it be like: bounds.right = 1023 Regards, Julun From bonefish at cs.tu-berlin.de Fri Sep 7 16:01:13 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Fri, 07 Sep 2007 16:01:13 +0200 Subject: [Haiku-commits] r22192 - haiku/trunk/src/tests/kits/interface/flatten_picture In-Reply-To: <46E12D1E.3080305@gmx.de> References: <200709061600.l86G0K0r026372@sheep.berlios.de> <46E12D1E.3080305@gmx.de> Message-ID: <20070907160113.1271.2@cs.tu-berlin.de> On 2007-09-07 at 12:51:10 [+0200], HOST Team wrote: > Hi, > > laplace at BerliOS schrieb: > > Author: laplace > > Date: 2007-09-06 18:00:20 +0200 (Thu, 06 Sep 2007) > > New Revision: 22192 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22192&view=rev > > > > Modified: > > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.cpp > > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h > > haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTestCases.c > > pp > > Log: > > * More error checking. > > * Added more bitmap test cases. Reveals a interface kit bug: the > > 1024x768 bitmap is not drawn at all! > > > +static void testDrawLargeBitmap(BView *view, BRect frame) { > > + BRect bounds(frame); > > + bounds.OffsetTo(0, 0); > > + bounds.left = 1024; > > i may totally wrong but shouldn't it be like: bounds.right = 1023 The bitmap's bounds initialization looks a bit weird anyway: BRect bounds(frame); bounds.OffsetTo(0, 0); bounds.left = 1024; bounds.bottom = 767; BBitmap bitmap(bounds, B_RGBA32); Even if it was "bounds.right = 1023", which is probably, what was intended, every member of the BRect would have been overwritten, which would make the four lines pretty much equivalent to just "BRect bounds(0, 0, 1023, 767)". CU, Ingo From michael.pfeiffer at utanet.at Fri Sep 7 18:57:55 2007 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Fri, 7 Sep 2007 18:57:55 +0200 Subject: [Haiku-commits] r22192 - haiku/trunk/src/tests/kits/interface/flatten_picture In-Reply-To: <46E12D1E.3080305@gmx.de> References: <200709061600.l86G0K0r026372@sheep.berlios.de> <46E12D1E.3080305@gmx.de> Message-ID: <3EF50E45-5037-410D-925A-87E859559C88@utanet.at> > Hi, > > laplace at BerliOS schrieb: >> Author: laplace >> Date: 2007-09-06 18:00:20 +0200 (Thu, 06 Sep 2007) >> New Revision: 22192 >> ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22192&view=rev >> >> Modified: >> haiku/trunk/src/tests/kits/interface/flatten_picture/ >> PictureTest.cpp >> haiku/trunk/src/tests/kits/interface/flatten_picture/PictureTest.h >> haiku/trunk/src/tests/kits/interface/flatten_picture/ >> PictureTestCases.cpp >> Log: >> * More error checking. >> * Added more bitmap test cases. Reveals a interface kit bug: the >> 1024x768 bitmap is not drawn at all! > >> +static void testDrawLargeBitmap(BView *view, BRect frame) { >> + BRect bounds(frame); >> + bounds.OffsetTo(0, 0); >> + bounds.left = 1024; > > i may totally wrong but shouldn't it be like: bounds.right = 1023 I noticed this after the checkin as well, but because this is just a test, I do not care that much about it being off by one. Maybe I will fix it, with a next check in, if any. - Michael From michael.pfeiffer at utanet.at Fri Sep 7 19:03:12 2007 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Fri, 7 Sep 2007 19:03:12 +0200 Subject: [Haiku-commits] r22192 - haiku/trunk/src/tests/kits/interface/flatten_picture In-Reply-To: <20070907160113.1271.2@cs.tu-berlin.de> References: <200709061600.l86G0K0r026372@sheep.berlios.de> <46E12D1E.3080305@gmx.de> <20070907160113.1271.2@cs.tu-berlin.de> Message-ID: <2AAB3EF9-C74B-46C4-89E3-CE7889649551@utanet.at> > The bitmap's bounds initialization looks a bit weird anyway: > > BRect bounds(frame); > bounds.OffsetTo(0, 0); > bounds.left = 1024; > bounds.bottom = 767; > BBitmap bitmap(bounds, B_RGBA32); > > Even if it was "bounds.right = 1023", which is probably, what was > intended, > every member of the BRect would have been overwritten, which would > make the > four lines pretty much equivalent to just "BRect bounds(0, 0, 1023, > 767)". That's correct. I guess it won't have hurt to reread the week(s) old code before checking it in :-) - Michael From stippi at mail.berlios.de Sat Sep 8 17:15:33 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 8 Sep 2007 17:15:33 +0200 Subject: [Haiku-commits] r22200 - haiku/trunk/src/apps/mail Message-ID: <200709081515.l88FFXdI007665@sheep.berlios.de> Author: stippi Date: 2007-09-08 17:15:32 +0200 (Sat, 08 Sep 2007) New Revision: 22200 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22200&view=rev Modified: haiku/trunk/src/apps/mail/MailApp.cpp Log: * fixed Mail startup, it would not open a window because of an uninitialized variable (#1459) Modified: haiku/trunk/src/apps/mail/MailApp.cpp =================================================================== --- haiku/trunk/src/apps/mail/MailApp.cpp 2007-09-07 10:23:12 UTC (rev 22199) +++ haiku/trunk/src/apps/mail/MailApp.cpp 2007-09-08 15:15:32 UTC (rev 22200) @@ -116,6 +116,7 @@ fSigWindow(NULL), fPrintSettings(NULL), + fPrintHelpAndExit(false), fWrapMode(true), fShowHeader(false), @@ -504,11 +505,10 @@ dataPath.Append("words"); // Only Load if Words Dictionary - if (BEntry(kWordsPath).Exists() || BEntry(dataPath.Path()).Exists()) - { - // If "/boot/optional/goodies/words" exists but there is no system dictionary, copy words - if (!BEntry(dataPath.Path()).Exists() && BEntry(kWordsPath).Exists()) - { + if (BEntry(kWordsPath).Exists() || BEntry(dataPath.Path()).Exists()) { + // If "/boot/optional/goodies/words" exists but there is no + // system dictionary, copy words + if (!BEntry(dataPath.Path()).Exists() && BEntry(kWordsPath).Exists()) { BFile words(kWordsPath, B_READ_ONLY); BFile copy(dataPath.Path(), B_WRITE_ONLY | B_CREATE_FILE); char buffer[4096]; @@ -522,8 +522,7 @@ // Create user dictionary if it does not exist dataPath = dictionaryDir; dataPath.Append("user"); - if (!BEntry(dataPath.Path()).Exists()) - { + if (!BEntry(dataPath.Path()).Exists()) { BFile user(dataPath.Path(), B_WRITE_ONLY | B_CREATE_FILE); BNodeInfo(&user).SetType("text/plain"); } @@ -535,13 +534,11 @@ gUserDict = -1; while (gDictCount < MAX_DICTIONARIES - && directory.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) - { + && directory.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) { dataPath.SetTo(&entry); // Identify the user dictionary - if (strcmp("user", dataPath.Leaf()) == 0) - { + if (strcmp("user", dataPath.Leaf()) == 0) { gUserDictFile = new BFile(dataPath.Path(), B_WRITE_ONLY | B_OPEN_AT_END); gUserDict = gDictCount; } @@ -563,8 +560,7 @@ // Create a new window if starting up without any extra arguments. - if (!fPrintHelpAndExit && !fWindowCount) - { + if (!fPrintHelpAndExit && !fWindowCount) { TMailWindow *window; window = NewWindow(); window->Show(); From bonefish at mail.berlios.de Sat Sep 8 18:14:46 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Sep 2007 18:14:46 +0200 Subject: [Haiku-commits] r22201 - haiku/trunk/src/system/kernel/disk_device_manager/jobs Message-ID: <200709081614.l88GEkUX010082@sheep.berlios.de> Author: bonefish Date: 2007-09-08 18:14:45 +0200 (Sat, 08 Sep 2007) New Revision: 22201 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22201&view=rev Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp Log: Missed to commit that change recently. Try to publish a partition only, if it hasn't been published yet. Modified: haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp =================================================================== --- haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-09-08 15:15:32 UTC (rev 22200) +++ haiku/trunk/src/system/kernel/disk_device_manager/jobs/KScanPartitionJob.cpp 2007-09-08 16:14:45 UTC (rev 22201) @@ -88,9 +88,12 @@ ) // publish the partition - status_t error = partition->PublishDevice(); - if (error != B_OK) - return error; + status_t error; + if (!partition->IsPublished()) { + error = partition->PublishDevice(); + if (error != B_OK) + return error; + } // find the disk system that returns the best priority for this partition float bestPriority = -1; From bonefish at mail.berlios.de Sat Sep 8 18:18:00 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Sep 2007 18:18:00 +0200 Subject: [Haiku-commits] r22202 - haiku/trunk/src/system/kernel/fs Message-ID: <200709081618.l88GI0JD010220@sheep.berlios.de> Author: bonefish Date: 2007-09-08 18:17:59 +0200 (Sat, 08 Sep 2007) New Revision: 22202 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22202&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Some cleanup. Fixed gcc 4 warning. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-08 16:14:45 UTC (rev 22201) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-08 16:17:59 UTC (rev 22202) @@ -9,12 +9,24 @@ /*! Virtual File System and File System Interface Layer */ -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include +#include +#include +#include + #include #include #include @@ -33,17 +45,7 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include //#define TRACE_VFS #ifdef TRACE_VFS @@ -133,50 +135,50 @@ static mutex sFileSystemsMutex; -/** \brief Guards sMountsTable. - * - * The holder is allowed to read/write access the sMountsTable. - * Manipulation of the fs_mount structures themselves - * (and their destruction) requires different locks though. - */ +/*! \brief Guards sMountsTable. + + The holder is allowed to read/write access the sMountsTable. + Manipulation of the fs_mount structures themselves + (and their destruction) requires different locks though. +*/ static mutex sMountMutex; -/** \brief Guards mount/unmount operations. - * - * The fs_mount() and fs_unmount() hold the lock during their whole operation. - * That is locking the lock ensures that no FS is mounted/unmounted. In - * particular this means that - * - sMountsTable will not be modified, - * - the fields immutable after initialization of the fs_mount structures in - * sMountsTable will not be modified, - * - vnode::covered_by of any vnode in sVnodeTable will not be modified. - * - * The thread trying to lock the lock must not hold sVnodeMutex or - * sMountMutex. - */ +/*! \brief Guards mount/unmount operations. + + The fs_mount() and fs_unmount() hold the lock during their whole operation. + That is locking the lock ensures that no FS is mounted/unmounted. In + particular this means that + - sMountsTable will not be modified, + - the fields immutable after initialization of the fs_mount structures in + sMountsTable will not be modified, + - vnode::covered_by of any vnode in sVnodeTable will not be modified. + + The thread trying to lock the lock must not hold sVnodeMutex or + sMountMutex. +*/ static recursive_lock sMountOpLock; -/** \brief Guards the vnode::covered_by field of any vnode - * - * The holder is allowed to read access the vnode::covered_by field of any - * vnode. Additionally holding sMountOpLock allows for write access. - * - * The thread trying to lock the must not hold sVnodeMutex. - */ +/*! \brief Guards the vnode::covered_by field of any vnode + + The holder is allowed to read access the vnode::covered_by field of any + vnode. Additionally holding sMountOpLock allows for write access. + + The thread trying to lock the must not hold sVnodeMutex. +*/ static mutex sVnodeCoveredByMutex; -/** \brief Guards sVnodeTable. - * - * The holder is allowed to read/write access sVnodeTable and to - * to any unbusy vnode in that table, save - * to the immutable fields (device, id, private_node, mount) to which - * only read-only access is allowed, and to the field covered_by, which is - * guarded by sMountOpLock and sVnodeCoveredByMutex. - * - * The thread trying to lock the mutex must not hold sMountMutex. - * You must not have this mutex held when calling create_sem(), as this - * might call vfs_free_unused_vnodes(). - */ +/*! \brief Guards sVnodeTable. + + The holder is allowed to read/write access sVnodeTable and to + any unbusy vnode in that table, save to the immutable fields (device, id, + private_node, mount) to which + only read-only access is allowed, and to the field covered_by, which is + guarded by sMountOpLock and sVnodeCoveredByMutex. + + The thread trying to lock the mutex must not hold sMountMutex. + You must not have this mutex held when calling create_sem(), as this + might call vfs_free_unused_vnodes(). +*/ static mutex sVnodeMutex; #define VNODE_HASH_TABLE_SIZE 1024 @@ -2606,25 +2608,26 @@ struct vnode *vnode; bool remove = false; - mutex_lock(&sVnodeMutex); + MutexLocker locker(sVnodeMutex); vnode = lookup_vnode(mountID, vnodeID); - if (vnode != NULL) { - if (vnode->covered_by != NULL) { - // this vnode is in use - mutex_unlock(&sVnodeMutex); - return B_BUSY; - } + if (vnode == NULL) + return B_ENTRY_NOT_FOUND; - vnode->remove = true; - if (vnode->unpublished) { - // prepare the vnode for deletion - vnode->busy = true; - remove = true; - } + if (vnode->covered_by != NULL) { + // this vnode is in use + mutex_unlock(&sVnodeMutex); + return B_BUSY; } - mutex_unlock(&sVnodeMutex); + vnode->remove = true; + if (vnode->unpublished) { + // prepare the vnode for deletion + vnode->busy = true; + remove = true; + } + + locker.Unlock(); if (remove) { // if the vnode hasn't been published yet, we delete it here @@ -2632,7 +2635,7 @@ free_vnode(vnode, true); } - return vnode != NULL ? B_OK : B_ENTRY_NOT_FOUND; + return B_OK; } From bonefish at mail.berlios.de Sat Sep 8 19:03:21 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Sep 2007 19:03:21 +0200 Subject: [Haiku-commits] r22203 - haiku/trunk/src/system/kernel/fs Message-ID: <200709081703.l88H3LY5030212@sheep.berlios.de> Author: bonefish Date: 2007-09-08 19:03:19 +0200 (Sat, 08 Sep 2007) New Revision: 22203 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22203&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: Fixed get_mount(). It must also acquire the vnode lock before trying to increment the root node vnode reference count. Otherwise it could race with fs_unmount(). Fixes bug #1438. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-08 16:17:59 UTC (rev 22202) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-08 17:03:19 UTC (rev 22203) @@ -474,27 +474,20 @@ struct fs_mount *mount; status_t status; - mutex_lock(&sMountMutex); + MutexLocker nodeLocker(sVnodeMutex); + MutexLocker mountLocker(sMountMutex); mount = find_mount(id); - if (mount) { - // ToDo: the volume is locked (against removal) by locking - // its root node - investigate if that's a good idea - if (mount->root_vnode) - inc_vnode_ref_count(mount->root_vnode); - else { - // might have been called during a mount operation in which - // case the root node may still be NULL - mount = NULL; - } - } else - status = B_BAD_VALUE; - - mutex_unlock(&sMountMutex); - if (mount == NULL) + return B_BAD_VALUE; + + struct vnode* rootNode = mount->root_vnode; + if (rootNode == NULL || rootNode->busy || rootNode->ref_count == 0) { + // might have been called during a mount/unmount operation return B_BUSY; + } + inc_vnode_ref_count(mount->root_vnode); *_mount = mount; return B_OK; } From stippi at mail.berlios.de Sat Sep 8 20:21:20 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 8 Sep 2007 20:21:20 +0200 Subject: [Haiku-commits] r22204 - in haiku/trunk/src/apps/icon-o-matic: . gui Message-ID: <200709081821.l88ILKi6031326@sheep.berlios.de> Author: stippi Date: 2007-09-08 20:21:20 +0200 (Sat, 08 Sep 2007) New Revision: 22204 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22204&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp haiku/trunk/src/apps/icon-o-matic/MainWindow.h haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp Log: * some fixes to the GUI on BeOS, avoid an app_server bug when resizing the window after creating the views, but before Show() * make the MenuFields in the Style section follow left/right Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-09-08 17:03:19 UTC (rev 22203) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-09-08 18:21:20 UTC (rev 22204) @@ -227,10 +227,10 @@ new BMessage(MSG_SAVE_AS)); // create main window - fMainWindow = new MainWindow(this, fDocument); + BMessage settings('stns'); + _RestoreSettings(settings); - _RestoreSettings(); - + fMainWindow = new MainWindow(this, fDocument, &settings); fMainWindow->Show(); _InstallDocumentMimeType(); @@ -566,16 +566,13 @@ // _RestoreSettings void -IconEditorApp::_RestoreSettings() +IconEditorApp::_RestoreSettings(BMessage& settings) { - BMessage settings('stns'); load_settings(&settings, "Icon-O-Matic"); int32 mode; if (settings.FindInt32("export mode", &mode) >= B_OK) fSavePanel->SetExportMode(mode); - - fMainWindow->RestoreSettings(&settings); } // _InstallDocumentMimeType Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-09-08 17:03:19 UTC (rev 22203) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-09-08 18:21:20 UTC (rev 22204) @@ -77,7 +77,7 @@ const char* _LastFilePath(path_kind which); void _StoreSettings(); - void _RestoreSettings(); + void _RestoreSettings(BMessage& settings); void _InstallDocumentMimeType(); MainWindow* fMainWindow; Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-08 17:03:19 UTC (rev 22203) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-08 18:21:20 UTC (rev 22204) @@ -18,7 +18,7 @@ #include #include -#if __HAIKU__ +#ifdef __HAIKU__ # include # include # include @@ -80,14 +80,16 @@ }; // constructor -MainWindow::MainWindow(IconEditorApp* app, Document* document) +MainWindow::MainWindow(IconEditorApp* app, Document* document, + const BMessage* settings) : BWindow(BRect(50, 50, 900, 750), "Icon-O-Matic", - B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, - B_ASYNCHRONOUS_CONTROLS), + B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), fApp(app), fDocument(document), fIcon(NULL) { + RestoreSettings(settings); + _Init(); } @@ -425,7 +427,7 @@ // RestoreSettings void -MainWindow::RestoreSettings(BMessage* archive) +MainWindow::RestoreSettings(const BMessage* archive) { BRect frame; if (archive->FindRect("main window frame", &frame) == B_OK) { @@ -489,7 +491,7 @@ void MainWindow::_CreateGUI(BRect bounds) { - const float splitWidth = 160; + const float splitWidth = 13 * be_plain_font->Size(); #ifdef __HAIKU__ @@ -676,7 +678,7 @@ topSideView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, swatchGroupView->MinSize().height)); -#else // __HAIKU__ +#else // !__HAIKU__ BView* bg = new BView(bounds, "bg", B_FOLLOW_ALL, 0); bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.h 2007-09-08 17:03:19 UTC (rev 22203) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.h 2007-09-08 18:21:20 UTC (rev 22204) @@ -46,7 +46,8 @@ public Observer { public: MainWindow(IconEditorApp* app, - Document* document); + Document* document, + const BMessage* settings); virtual ~MainWindow(); // BWindow interface @@ -65,7 +66,7 @@ void SetIcon(Icon* icon); void StoreSettings(BMessage* archive); - void RestoreSettings(BMessage* archive); + void RestoreSettings(const BMessage* archive); private: void _Init(); Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-08 17:03:19 UTC (rev 22203) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-08 18:21:20 UTC (rev 22204) @@ -88,6 +88,7 @@ fStyleType->MenuBar()->ResizeTo(width, height); fStyleType->ResizeTo(frame.Width(), height + 6); fStyleType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); + fStyleType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); #endif // __HAIKU__ // gradient type @@ -125,7 +126,7 @@ layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3); layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4); -#else // __HAIKU__ +#else // !__HAIKU__ frame.OffsetBy(0, fStyleType->Frame().Height() + 6); fGradientType = new BMenuField(frame, "gradient type", "Gradient Type", menu, true); @@ -135,6 +136,7 @@ fGradientType->MenuBar()->ResizeTo(width, height); fGradientType->ResizeTo(frame.Width(), height + 6); fGradientType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); + fGradientType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); // create gradient control frame.top = fGradientType->Frame().bottom + 8; @@ -142,7 +144,7 @@ fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this); - width = max_c(fGradientControl->Frame().Width(), frame.Width()); + width = frame.Width(); height = max_c(fGradientControl->Frame().Height(), 30); fGradientControl->ResizeTo(width, height); @@ -151,6 +153,13 @@ fGradientControl->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); AddChild(fGradientControl); + + // align label divider + float divider = fGradientType->StringWidth(fGradientType->Label()); + divider = max_c(divider, fStyleType->StringWidth(fStyleType->Label())); + fGradientType->SetDivider(divider + 8); + fStyleType->SetDivider(divider + 8); + #endif // __HAIKU__ fStyleType->SetEnabled(false); From stippi at mail.berlios.de Sat Sep 8 20:25:06 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 8 Sep 2007 20:25:06 +0200 Subject: [Haiku-commits] r22205 - in haiku/trunk/src/apps/icon-o-matic/import_export: . flat_icon Message-ID: <200709081825.l88IP6oY031611@sheep.berlios.de> Author: stippi Date: 2007-09-08 20:25:06 +0200 (Sat, 08 Sep 2007) New Revision: 22205 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22205&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp Log: * fixed two bugs related to #1445, on BeOS R5, BFS has a bug that prevents attributes to be written under a certain name when they already exist under the same name but with a different type * the code that did the saving to a temporary file, then copied the attributes of the original file, then clobbered the original file prevented saving the icon in the icon attribute reliably, disabled this code for now and added TODO how it should work better Modified: haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp 2007-09-08 18:21:20 UTC (rev 22204) +++ haiku/trunk/src/apps/icon-o-matic/import_export/Exporter.cpp 2007-09-08 18:25:06 UTC (rev 22205) @@ -127,30 +127,33 @@ Exporter::_Export(const Icon* icon, const entry_ref* docRef) { + // TODO: reenable the commented out code, but make it work + // the opposite direction, ie *copy* the file contents + BEntry entry(docRef, true); if (entry.IsDirectory()) return B_BAD_VALUE; const entry_ref* ref = docRef; - entry_ref tempRef; +// entry_ref tempRef; +// +// if (entry.Exists()) { +// // if the file exists create a temporary file in the same folder +// // and hope that it doesn't already exist... +// BPath tempPath(docRef); +// if (tempPath.GetParent(&tempPath) >= B_OK) { +// BString helper(docRef->name); +// helper << system_time(); +// if (tempPath.Append(helper.String()) >= B_OK +// && entry.SetTo(tempPath.Path()) >= B_OK +// && entry.GetRef(&tempRef) >= B_OK) { +// // have the output ref point to the temporary +// // file instead +// ref = &tempRef; +// } +// } +// } - if (entry.Exists()) { - // if the file exists create a temporary file in the same folder - // and hope that it doesn't already exist... - BPath tempPath(docRef); - if (tempPath.GetParent(&tempPath) >= B_OK) { - BString helper(docRef->name); - helper << system_time(); - if (tempPath.Append(helper.String()) >= B_OK - && entry.SetTo(tempPath.Path()) >= B_OK - && entry.GetRef(&tempRef) >= B_OK) { - // have the output ref point to the temporary - // file instead - ref = &tempRef; - } - } - } - status_t ret = B_BAD_VALUE; // do the actual save operation into a file @@ -175,44 +178,48 @@ } outFile.Unset(); - if (ret < B_OK && ref != docRef) { - // in case of failure, remove temporary file - entry.Remove(); - } +// if (ret < B_OK && ref != docRef) { +// // in case of failure, remove temporary file +// entry.Remove(); +// } +// +// if (ret >= B_OK && ref != docRef) { +// // move temp file overwriting actual document file +// BEntry docEntry(docRef, true); +// // copy attributes of previous document file +// BNode sourceNode(&docEntry); +// BNode destNode(&entry); +// if (sourceNode.InitCheck() >= B_OK && destNode.InitCheck() >= B_OK) { +// // lock the nodes +// if (sourceNode.Lock() >= B_OK) { +// if (destNode.Lock() >= B_OK) { +// // iterate over the attributes +// char attrName[B_ATTR_NAME_LENGTH]; +// while (sourceNode.GetNextAttrName(attrName) >= B_OK) { +//// // skip the icon, since we probably wrote that +//// // before +//// if (strcmp(attrName, "BEOS:ICON") == 0) +//// continue; +// attr_info info; +// if (sourceNode.GetAttrInfo(attrName, &info) >= B_OK) { +// char *buffer = new (nothrow) char[info.size]; +// if (buffer && sourceNode.ReadAttr(attrName, info.type, 0, +// buffer, info.size) == info.size) { +// destNode.WriteAttr(attrName, info.type, 0, +// buffer, info.size); +// } +// delete[] buffer; +// } +// } +// destNode.Unlock(); +// } +// sourceNode.Unlock(); +// } +// } +// // clobber the orginal file with the new temporary one +// ret = entry.Rename(docRef->name, true); +// } - if (ret >= B_OK && ref != docRef) { - // move temp file overwriting actual document file - BEntry docEntry(docRef, true); - // copy attributes of previous document file - BNode sourceNode(&docEntry); - BNode destNode(&entry); - if (sourceNode.InitCheck() >= B_OK && destNode.InitCheck() >= B_OK) { - // lock the nodes - if (sourceNode.Lock() >= B_OK) { - if (destNode.Lock() >= B_OK) { - // iterate over the attributes - char attrName[B_ATTR_NAME_LENGTH]; - while (sourceNode.GetNextAttrName(attrName) >= B_OK) { - attr_info info; - if (sourceNode.GetAttrInfo(attrName, &info) >= B_OK) { - char *buffer = new (nothrow) char[info.size]; - if (buffer && sourceNode.ReadAttr(attrName, info.type, 0, - buffer, info.size) == info.size) { - destNode.WriteAttr(attrName, info.type, 0, - buffer, info.size); - } - delete[] buffer; - } - } - destNode.Unlock(); - } - sourceNode.Unlock(); - } - } - // clobber the orginal file with the new temporary one - ret = entry.Rename(docRef->name, true); - } - if (ret >= B_OK && MIMEType()) { // set file type BNode node(docRef); Modified: haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp 2007-09-08 18:21:20 UTC (rev 22204) +++ haiku/trunk/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp 2007-09-08 18:25:06 UTC (rev 22205) @@ -105,15 +105,26 @@ // flatten icon status_t ret = _Export(buffer, icon); - if (ret < B_OK) + if (ret < B_OK) { + printf("failed to export to buffer: %s\n", strerror(ret)); return ret; + } +#ifndef __HAIKU__ + // work arround a BFS bug, attributes with the same name but different + // type fail to be written + node->RemoveAttr(attrName); +#endif + // write buffer to attribute ssize_t written = node->WriteAttr(attrName, B_VECTOR_ICON_TYPE, 0, buffer.Buffer(), buffer.SizeUsed()); if (written != (ssize_t)buffer.SizeUsed()) { - if (written < 0) + if (written < 0) { + printf("failed to write attribute: %s\n", strerror((status_t)written)); return (status_t)written; + } + printf("failed to write attribute\n"); return B_ERROR; } From bonefish at mail.berlios.de Sat Sep 8 22:47:38 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Sep 2007 22:47:38 +0200 Subject: [Haiku-commits] r22206 - haiku/trunk/src/system/kernel Message-ID: <200709082047.l88Klc9g006218@sheep.berlios.de> Author: bonefish Date: 2007-09-08 22:47:37 +0200 (Sat, 08 Sep 2007) New Revision: 22206 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22206&view=rev Modified: haiku/trunk/src/system/kernel/team.cpp Log: Fixed check I messed up recently. Modified: haiku/trunk/src/system/kernel/team.cpp =================================================================== --- haiku/trunk/src/system/kernel/team.cpp 2007-09-08 18:25:06 UTC (rev 22205) +++ haiku/trunk/src/system/kernel/team.cpp 2007-09-08 20:47:37 UTC (rev 22206) @@ -2600,7 +2600,7 @@ // the thread must be the team's main thread, as that // determines its process ID - if (thread == NULL && thread != thread->team->main_thread) + if (thread == NULL || thread != thread->team->main_thread) return B_BAD_THREAD_ID; // check if the thread is in a child team of the calling team and From stippi at mail.berlios.de Sun Sep 9 16:26:48 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 9 Sep 2007 16:26:48 +0200 Subject: [Haiku-commits] r22207 - haiku/trunk/src/apps/codycam Message-ID: <200709091426.l89EQmZO026899@sheep.berlios.de> Author: stippi Date: 2007-09-09 16:26:48 +0200 (Sun, 09 Sep 2007) New Revision: 22207 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22207&view=rev Modified: haiku/trunk/src/apps/codycam/CodyCam.rdef Log: * added icon, based on work by "Humdinger" and "genki" Modified: haiku/trunk/src/apps/codycam/CodyCam.rdef =================================================================== --- haiku/trunk/src/apps/codycam/CodyCam.rdef 2007-09-08 20:47:37 UTC (rev 22206) +++ haiku/trunk/src/apps/codycam/CodyCam.rdef 2007-09-09 14:26:48 UTC (rev 22207) @@ -1,6 +1,32 @@ resource(1, "BEOS:FILE_TYPES") message; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU + +resource vector_icon { + $"6E6369660B03010000020002023A00000000000000004000004BC00000000000" + $"010000FFFF01000000020006023CC0000000000000003D000048000048800040" + $"010101FFC1ACAC040168020106023A26EC38CA29B828213953DB48968D4B2BC6" + $"00434A68FF0F123805FF020016023BC7F2371D28B92B133DD8D84B27744904E3" + $"005CFFB802001602BAE67DB9EC7D3C3541BD43A4488A5D4BF80900C9FFFF0200" + $"1602BB2E08386BA4B96934BC3D914A06894B293B0079FFE404017E020106033C" + $"FC1C3C56E5BCB0CB3D6ECE49294C48048B2AFFFFFFC4959191FFB9B9B9090204" + $"4648C6FB48BD4C48305430C51430CA5B4660BD4C60C6FB605C545CCA5B5CC514" + $"04033E4C4C5646C6BB465A46604A584E604A0204B7E2C43CB8D9C34DB6EBC52C" + $"B893C86CB73BC70CB9EAC9CEBCBFC937BBC8CA27BDB5C848BC0FC507BD66C668" + $"BAB7C3A70604EE3355BC43C7D1BBDDC837BCA9C76B3851BC83C829BCE9C7C3BC" + $"1DC88F06069E0A3C422E5137502E5154425E50504D420A044244425E50504D42" + $"0A042E54425E425A2E510604EB425A425A495348473C422E5137502E5102043E" + $"22C35A22BA8D222A362AB75D2AC02A3E4ABA8D4AC35A4A523652C02A52B75D0C" + $"0A030100000A0101011001178400040A0001041001178400040A060105000A07" + $"0106000A080107000A0001081001178400040A0A0108000A020102123FF03D3D" + $"7A6FBD81013FE8DA4915DDC9C96A01178400040A040102023FF03D3D7A6FBD81" + $"013FE8DA495AD5C9C96A0A05010202B8804D3ACA6FBACFB4B87B9D49F517489E" + $"8A0A050103023FF03D3D7A6FBD81013FE8DA495AD5C9C96A" +}; + +#else // HAIKU_TARGET_PLATFORM_HAIKU + resource(101, "BEOS:L:STD_ICON") #'ICON' array { $"FFFFFFFFFFFFFFFFFFFFFFFF01010101010101FFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -57,6 +83,8 @@ $"FFFFFFFFFFFFFFFF0101FFFFFFFFFFFF" }; +#endif // HAIKU_TARGET_PLATFORM_HAIKU + resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.Be.CodyCam"; resource(1, "BEOS:APP_VERSION") #'APPV' array From bonefish at mail.berlios.de Sun Sep 9 16:36:11 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Sep 2007 16:36:11 +0200 Subject: [Haiku-commits] r22208 - in haiku/trunk: headers/private/kernel src/system/kernel/vm Message-ID: <200709091436.l89EaBks027316@sheep.berlios.de> Author: bonefish Date: 2007-09-09 16:36:10 +0200 (Sun, 09 Sep 2007) New Revision: 22208 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22208&view=rev Modified: haiku/trunk/headers/private/kernel/vm_cache.h haiku/trunk/src/system/kernel/vm/vm_cache.cpp haiku/trunk/src/system/kernel/vm/vm_daemons.cpp Log: * The method vm_cache_remove_consumer() and the page daemon used to get a reference to a by them not yet referenced cache was not correct. They only incremented the reference count, but a vnode cache reference includes also a vnode reference. In case of the page daemon this would cause vnode references to be lost (causing bug #1465). * The page daemon used an unsafe method to access a yet unreferenced page cache. There was nothing that prevented the cache from being deleted while the page daemon tried to get a reference. The vm_page::cache field is now protected by the page cache table spinlock, too, which the new function vm_cache_acquire_page_cache_ref(), used by the page daemon, also acquires while trying to get the reference. Modified: haiku/trunk/headers/private/kernel/vm_cache.h =================================================================== --- haiku/trunk/headers/private/kernel/vm_cache.h 2007-09-09 14:26:48 UTC (rev 22207) +++ haiku/trunk/headers/private/kernel/vm_cache.h 2007-09-09 14:36:10 UTC (rev 22208) @@ -23,6 +23,7 @@ vm_cache *vm_cache_create(vm_store *store); void vm_cache_acquire_ref(vm_cache *cache); void vm_cache_release_ref(vm_cache *cache); +vm_cache *vm_cache_acquire_page_cache_ref(vm_page *page); vm_page *vm_cache_lookup_page(vm_cache *cache, off_t page); void vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset); void vm_cache_remove_page(vm_cache *cache, vm_page *page); Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-09 14:26:48 UTC (rev 22207) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-09 14:36:10 UTC (rev 22208) @@ -11,6 +11,9 @@ #include #include +#include +#include + #include #include #include @@ -18,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -80,6 +82,28 @@ } +/*! Acquires a pseudo reference to a cache yet unreferenced by the caller. The + caller must make sure, that the cache is not deleted, e.g. by holding the + cache's source cache lock or by holding the page cache table lock while the + cache is still referred to by a page. To get a real reference, the caller + must subsequently call vm_cache_acquire_ref() and decrement the cache's ref + count manually afterwards. + Returns \c true, if the pseudo reference could be acquired. +*/ +static inline bool +acquire_unreferenced_cache_pseudo_ref(vm_cache* cache) +{ + while (true) { + int32 count = cache->ref_count; + if (count == 0) + return false; + + if (atomic_test_and_set(&cache->ref_count, count + 1, count) == count) + return true; + } +} + + status_t vm_cache_init(kernel_args *args) { @@ -275,6 +299,29 @@ } +vm_cache* +vm_cache_acquire_page_cache_ref(vm_page* page) +{ + InterruptsSpinLocker locker(sPageCacheTableLock); + + vm_cache* cache = page->cache; + if (cache == NULL) + return NULL; + + // get a pseudo reference + if (!acquire_unreferenced_cache_pseudo_ref(cache)) + return NULL; + + locker.Unlock(); + + // turn it into a real reference + vm_cache_acquire_ref(cache); + atomic_add(&cache->ref_count, -1); + + return cache; +} + + vm_page * vm_cache_lookup_page(vm_cache *cache, off_t offset) { @@ -326,12 +373,13 @@ cache->page_list = page; cache->page_count++; - page->cache = cache; page->usage_count = 2; state = disable_interrupts(); acquire_spinlock(&sPageCacheTableLock); + page->cache = cache; + #if KDEBUG struct page_lookup_key key; key.offset = (uint32)(offset >> PAGE_SHIFT); @@ -373,6 +421,7 @@ acquire_spinlock(&sPageCacheTableLock); hash_remove(sPageCacheTable, page); + page->cache = NULL; release_spinlock(&sPageCacheTableLock); restore_interrupts(state); @@ -388,7 +437,6 @@ page->cache_next->cache_prev = page->cache_prev; } cache->page_count--; - page->cache = NULL; } @@ -499,27 +547,23 @@ && cache->consumers.link.next == cache->consumers.link.prev) { // The cache is not really needed anymore - it can be merged with its only // consumer left. - bool merge = false; consumer = (vm_cache *)list_get_first_item(&cache->consumers); - // Our cache doesn't have a ref to its consumer (only the other way around), - // so we cannot just acquire it here; it might be deleted right now - while (true) { - int32 count = consumer->ref_count; - if (count == 0) - break; - - if (atomic_test_and_set(&consumer->ref_count, count + 1, count) == count) { - // We managed to grab a reference to the consumerRef. - // Since this doesn't guarantee that we get the cache we wanted - // to, we need to check if this cache is really the last - // consumer of the cache we want to merge it with. - merge = true; - break; - } + bool merge = acquire_unreferenced_cache_pseudo_ref(consumer); + if (merge) { + // We managed to increment the reference count, but that's not a + // full reference. We get a real one now and decrement the ref count + // again. + vm_cache_acquire_ref(consumer); + atomic_add(&consumer->ref_count, -1); } + // In case we managed to grab a reference to the consumerRef, + // this doesn't guarantee that we get the cache we wanted + // to, so we need to check if this cache is really the last + // consumer of the cache we want to merge it with. + ConditionVariable busyCondition; if (merge) { Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-09-09 14:26:48 UTC (rev 22207) +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp 2007-09-09 14:36:10 UTC (rev 22208) @@ -70,21 +70,8 @@ if (_IgnorePage(page)) return false; - vm_cache* cache = page->cache; - - // Grab a reference to this cache - the page does not own a reference - // to its cache, so we can't just acquire it the easy way - while (true) { - int32 count = cache->ref_count; - if (count == 0) { - cache = NULL; - break; - } - - if (atomic_test_and_set(&cache->ref_count, count + 1, count) == count) - break; - } - + // Grab a reference to this cache. + vm_cache* cache = vm_cache_acquire_page_cache_ref(page); if (cache == NULL) return false; From bonefish at mail.berlios.de Sun Sep 9 16:38:58 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Sep 2007 16:38:58 +0200 Subject: [Haiku-commits] r22209 - haiku/trunk/src/system/kernel/fs Message-ID: <200709091438.l89EcwKQ027480@sheep.berlios.de> Author: bonefish Date: 2007-09-09 16:38:58 +0200 (Sun, 09 Sep 2007) New Revision: 22209 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22209&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp Log: * Added a clarifying comment to free_vnode() and prevented the vnode reference count to drop below 0 there. * Added TODO describing a serious race condition between free_vnode() and the page daemon. Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-09 14:36:10 UTC (rev 22208) +++ haiku/trunk/src/system/kernel/fs/vfs.cpp 2007-09-09 14:38:58 UTC (rev 22209) @@ -664,7 +664,7 @@ static void free_vnode(struct vnode *vnode, bool reenter) { - ASSERT(vnode->ref_count == 0 && vnode->busy); + ASSERT_PRINT(vnode->ref_count == 0 && vnode->busy, "vnode: %p\n", vnode); // write back any changes in this vnode's cache -- but only // if the vnode won't be deleted, in which case the changes @@ -673,6 +673,24 @@ if (!vnode->remove && FS_CALL(vnode, fsync) != NULL) FS_CALL(vnode, fsync)(vnode->mount->cookie, vnode->private_node); + // Note: If this vnode has a cache attached, there will still be two + // references to that cache at this point. The last one belongs to the vnode + // itself (cf. vfs_get_vnode_cache()) and one belongs to the node's file + // cache. Each but the last reference to a cache also includes a reference + // to the vnode. The file cache, however, released its reference (cf. + // file_cache_create()), so that this vnode's ref count has the chance to + // ever drop to 0. Deleting the file cache now, will cause the next to last + // cache reference to be released, which will also release a (no longer + // existing) vnode reference. To avoid problems, we set the vnode's ref + // count, so that it will neither become negative nor 0. + vnode->ref_count = 2; + + // TODO: Usually, when the vnode is unreferenced, no one can get hold of the + // cache either (i.e. no one can get a cache reference while we're deleting + // the vnode).. This is, however, not the case for the page daemon. It gets + // its cache references via the pages it scans, so it can in fact get a + // vnode reference while we're deleting the vnode. + if (!vnode->unpublished) { if (vnode->remove) FS_CALL(vnode, remove_vnode)(vnode->mount->cookie, vnode->private_node, reenter); @@ -718,6 +736,8 @@ int32 oldRefCount = atomic_add(&vnode->ref_count, -1); + ASSERT_PRINT(oldRefCount > 0, "vnode %p\n", vnode); + TRACE(("dec_vnode_ref_count: vnode %p, ref now %ld\n", vnode, vnode->ref_count)); if (oldRefCount == 1) { From bonefish at mail.berlios.de Sun Sep 9 19:19:53 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Sep 2007 19:19:53 +0200 Subject: [Haiku-commits] r22210 - in haiku/trunk: headers/private/kernel/util src/system/kernel/util Message-ID: <200709091719.l89HJrP5020400@sheep.berlios.de> Author: bonefish Date: 2007-09-09 19:19:52 +0200 (Sun, 09 Sep 2007) New Revision: 22210 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22210&view=rev Modified: haiku/trunk/headers/private/kernel/util/khash.h haiku/trunk/src/system/kernel/util/khash.c Log: * Added hash_count_elements() and hash_count_used_slots() (mainly for diagnostic purposes). * hash_init() adjusts the table size to a prime number, which should result in a better element distribution, particularly since usually a power of two is passed. Modified: haiku/trunk/headers/private/kernel/util/khash.h =================================================================== --- haiku/trunk/headers/private/kernel/util/khash.h 2007-09-09 14:38:58 UTC (rev 22209) +++ haiku/trunk/headers/private/kernel/util/khash.h 2007-09-09 17:19:52 UTC (rev 22210) @@ -38,6 +38,8 @@ void hash_close(struct hash_table *table, struct hash_iterator *i, bool free_iterator); void *hash_next(struct hash_table *table, struct hash_iterator *i); void hash_rewind(struct hash_table *table, struct hash_iterator *i); +uint32 hash_count_elements(struct hash_table *table); +uint32 hash_count_used_slots(struct hash_table *table); /* function pointers must look like this: * Modified: haiku/trunk/src/system/kernel/util/khash.c =================================================================== --- haiku/trunk/src/system/kernel/util/khash.c 2007-09-09 14:38:58 UTC (rev 22209) +++ haiku/trunk/src/system/kernel/util/khash.c 2007-09-09 17:19:52 UTC (rev 22210) @@ -43,6 +43,27 @@ #define PUT_IN_NEXT(t, e, val) (*(unsigned long *)NEXT_ADDR(t, e) = (long)(val)) +const uint32 kPrimes [] = { + 13, 31, 61, 127, 251, + 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, + 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, + 134217689, 268435399, 536870909, 1073741789, 2147483647, 0 +}; + + +static uint32 +get_prime_table_size(uint32 size) +{ + int i; + for (i = 0; kPrimes[i] != 0; i++) { + if (kPrimes[i] > size) + return kPrimes[i]; + } + + return kPrimes[i - 1]; +} + + static inline void * next_element(hash_table *table, void *element) { @@ -59,6 +80,8 @@ struct hash_table *t; unsigned int i; + table_size = get_prime_table_size(table_size); + if (compare_func == NULL || hash_func == NULL) { dprintf("hash_init() called with NULL function pointer\n"); return NULL; @@ -303,3 +326,23 @@ return hash; } + +uint32 +hash_count_elements(struct hash_table *table) +{ + return table->num_elements; +} + + +uint32 +hash_count_used_slots(struct hash_table *table) +{ + uint32 usedSlots = 0; + uint32 i; + for (i = 0; i < table->table_size; i++) { + if (table->table[i] != NULL) + usedSlots++; + } + + return usedSlots; +} From bonefish at mail.berlios.de Sun Sep 9 19:36:13 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Sep 2007 19:36:13 +0200 Subject: [Haiku-commits] r22211 - haiku/trunk/src/system/kernel/vm Message-ID: <200709091736.l89HaDhU020947@sheep.berlios.de> Author: bonefish Date: 2007-09-09 19:36:13 +0200 (Sun, 09 Sep 2007) New Revision: 22211 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22211&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp Log: * The page cache hash table size was fixed to 1024 slots, but even when freshly booted, it would already contain > 20000 pages. The size is now initialized to half of the available pages. Ideally it would grow/shrink dynamically, though. * Changed the hash function to yield a better distribution. Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-09 17:19:52 UTC (rev 22210) +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp 2007-09-09 17:36:13 UTC (rev 22211) @@ -34,9 +34,6 @@ #endif -/* hash table of pages keyed by cache they're in and offset */ -#define PAGE_TABLE_SIZE 1024 /* TODO: make this dynamic */ - static hash_table *sPageCacheTable; static spinlock sPageCacheTableLock; @@ -73,7 +70,8 @@ vm_page *page = (vm_page *)_p; const struct page_lookup_key *key = (page_lookup_key *)_key; -#define HASH(offset, ref) ((offset) ^ ((uint32)(ref) >> 4)) + #define HASH(offset, ref) ((offset) + ((uint32)(ref) >> 6) * 997) + // sizeof(vm_cache) >= 64, hence (uint32)(ref) >> 6 is still unique if (page) return HASH(page->cache_offset, page->cache) % range; @@ -107,8 +105,9 @@ status_t vm_cache_init(kernel_args *args) { - sPageCacheTable = hash_init(PAGE_TABLE_SIZE, offsetof(vm_page, hash_next), - &page_compare_func, &page_hash_func); + // TODO: The table should grow/shrink dynamically. + sPageCacheTable = hash_init(vm_page_num_pages() / 2, + offsetof(vm_page, hash_next), &page_compare_func, &page_hash_func); if (sPageCacheTable == NULL) panic("vm_cache_init: no memory\n"); From laplace at mail.berlios.de Sun Sep 9 22:06:08 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 9 Sep 2007 22:06:08 +0200 Subject: [Haiku-commits] r22212 - haiku/trunk/src/apps/sudoku Message-ID: <200709092006.l89K68SB030174@sheep.berlios.de> Author: laplace Date: 2007-09-09 22:06:07 +0200 (Sun, 09 Sep 2007) New Revision: 22212 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22212&view=rev Added: haiku/trunk/src/apps/sudoku/CenteredViewContainer.cpp haiku/trunk/src/apps/sudoku/CenteredViewContainer.h Modified: haiku/trunk/src/apps/sudoku/Jamfile haiku/trunk/src/apps/sudoku/SudokuGenerator.cpp haiku/trunk/src/apps/sudoku/SudokuView.cpp haiku/trunk/src/apps/sudoku/SudokuView.h haiku/trunk/src/apps/sudoku/SudokuWindow.cpp Log: Ceneter SudokuView and keep it square. Avoid flickering when resizing. R5 build fixes. Added: haiku/trunk/src/apps/sudoku/CenteredViewContainer.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/CenteredViewContainer.cpp 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/CenteredViewContainer.cpp 2007-09-09 20:06:07 UTC (rev 22212) @@ -0,0 +1,44 @@ +/* + * Copyright 2007, Michael Pfeiffer, laplace at users.sourceforge.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#include "CenteredViewContainer.h" + +CenteredViewContainer::CenteredViewContainer(BView *target, BRect frame, const char* name, uint32 resizingMode) + : BView(frame, name, resizingMode, B_WILL_DRAW | B_FRAME_EVENTS) + , fTarget(target) +{ + SetViewColor(B_TRANSPARENT_COLOR); + // to avoid flickering + AddChild(fTarget); + _CenterTarget(frame.Width(), frame.Height()); +} + +CenteredViewContainer::~CenteredViewContainer() +{ +} + +void +CenteredViewContainer::Draw(BRect updateRect) +{ + FillRect(updateRect); +} + +void +CenteredViewContainer::FrameResized(float width, float height) +{ + BView::FrameResized(width, height); + _CenterTarget(width, height); +} + +void CenteredViewContainer::_CenterTarget(float width, float height) +{ + float size = width < height ? width : height; + float left = floor((width - size) / 2); + float top = floor((height - size) / 2); + fTarget->MoveTo(left, top); + fTarget->ResizeTo(size, size); + fTarget->FrameResized(size, size); + // in BeOS R5 BView::FrameResized is not (always) called automatically + // after ResizeTo() +} Added: haiku/trunk/src/apps/sudoku/CenteredViewContainer.h =================================================================== --- haiku/trunk/src/apps/sudoku/CenteredViewContainer.h 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/CenteredViewContainer.h 2007-09-09 20:06:07 UTC (rev 22212) @@ -0,0 +1,27 @@ +/* + * Copyright 2007, Michael Pfeiffer, laplace at users.sourceforge.net. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef CENTERED_VIEW_CONTAINER_H +#define CENTERED_VIEW_CONTAINER_H + + +#include + + + +class CenteredViewContainer : public BView { +public: + CenteredViewContainer(BView *target, BRect frame, const char* name, uint32 resizingMode); + virtual ~CenteredViewContainer(); + + void Draw(BRect updateRect); + void FrameResized(float width, float height); + +private: + void _CenterTarget(float width, float height); + + BView *fTarget; +}; + +#endif // CENTERED_VIEW_CONTAINER_H \ No newline at end of file Modified: haiku/trunk/src/apps/sudoku/Jamfile =================================================================== --- haiku/trunk/src/apps/sudoku/Jamfile 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/Jamfile 2007-09-09 20:06:07 UTC (rev 22212) @@ -3,6 +3,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; Application Sudoku : + CenteredViewContainer.cpp ProgressWindow.cpp Sudoku.cpp SudokuField.cpp Modified: haiku/trunk/src/apps/sudoku/SudokuGenerator.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuGenerator.cpp 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/SudokuGenerator.cpp 2007-09-09 20:06:07 UTC (rev 22212) @@ -10,6 +10,7 @@ #include "SudokuField.h" #include "SudokuSolver.h" +#include SudokuGenerator::SudokuGenerator() { Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/SudokuView.cpp 2007-09-09 20:06:07 UTC (rev 22212) @@ -55,8 +55,11 @@ if (settings.FindBool("show cursor", &fShowCursor) != B_OK) fShowCursor = false; - SetViewColor(255, 255, 240); - SetLowColor(ViewColor()); + SetViewColor(B_TRANSPARENT_COLOR); + // to avoid flickering + rgb_color color = { 255, 255, 240 }; + fBackgroundColor = color; + SetLowColor(color); FrameResized(0, 0); } @@ -99,7 +102,7 @@ continue; if (!_ValidCharacter(data[i])) { - return B_BAD_DATA; + return B_BAD_VALUE; } buffer[out++] = data[i]; @@ -737,6 +740,11 @@ void SudokuView::Draw(BRect /*updateRect*/) { + // draw one pixel border otherwise not covered + // by lines and fields + SetLowColor(fBackgroundColor); + StrokeRect(Bounds(), B_SOLID_LOW); + // draw lines uint32 size = fField->Size(); @@ -778,9 +786,11 @@ //SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); SetLowColor(255, 255, 210); FillRect(_Frame(x, y), B_SOLID_LOW); - } else - SetLowColor(ViewColor()); - + } else { + SetLowColor(fBackgroundColor); + FillRect(_Frame(x, y), B_SOLID_LOW); + } + if (fShowKeyboardFocus && x == fKeyboardX && y == fKeyboardY) _DrawKeyboardFocus(); Modified: haiku/trunk/src/apps/sudoku/SudokuView.h =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuView.h 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/SudokuView.h 2007-09-09 20:06:07 UTC (rev 22212) @@ -75,6 +75,7 @@ void _DrawKeyboardFocus(); void _DrawHints(uint32 x, uint32 y); + rgb_color fBackgroundColor; SudokuField* fField; uint32 fBlockSize; float fWidth, fHeight, fBaseline; Modified: haiku/trunk/src/apps/sudoku/SudokuWindow.cpp =================================================================== --- haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-09-09 17:36:13 UTC (rev 22211) +++ haiku/trunk/src/apps/sudoku/SudokuWindow.cpp 2007-09-09 20:06:07 UTC (rev 22212) @@ -6,6 +6,7 @@ #include "SudokuWindow.h" +#include "CenteredViewContainer.h" #include "ProgressWindow.h" #include "Sudoku.h" #include "SudokuField.h" @@ -156,9 +157,13 @@ top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); - fSudokuView = new SudokuView(top->Bounds().InsetByCopy(10, 10), - "sudoku view", settings, B_FOLLOW_ALL); - top->AddChild(fSudokuView); + fSudokuView = new SudokuView(top->Bounds().InsetByCopy(10, 10).OffsetToSelf(0, 0), + "sudoku view", settings, B_FOLLOW_NONE); + CenteredViewContainer * container = new CenteredViewContainer(fSudokuView, + top->Bounds().InsetByCopy(10, 10), + "center", B_FOLLOW_ALL); + container->SetHighColor(top->ViewColor()); + top->AddChild(container); // add menu From jackburton at mail.berlios.de Mon Sep 10 11:43:03 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 10 Sep 2007 11:43:03 +0200 Subject: [Haiku-commits] r22213 - haiku/trunk/src/servers/app Message-ID: <200709100943.l8A9h3oV031898@sheep.berlios.de> Author: jackburton Date: 2007-09-10 11:43:02 +0200 (Mon, 10 Sep 2007) New Revision: 22213 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22213&view=rev Modified: haiku/trunk/src/servers/app/ServerPicture.cpp Log: Use DrawState::PenSize() to set the drawing engine pen size, since it returns the scaled value. Modified: haiku/trunk/src/servers/app/ServerPicture.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-09 20:06:07 UTC (rev 22212) +++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-10 09:43:02 UTC (rev 22213) @@ -541,7 +541,9 @@ set_pen_size(ViewLayer *view, float size) { view->CurrentState()->SetPenSize(size); - view->Window()->GetDrawingEngine()->SetPenSize(size); + view->Window()->GetDrawingEngine()->SetPenSize(view->CurrentState()->PenSize()); + // DrawState::PenSize() returns the scaled pen size, so we need to + // use that value to set the drawing engine pen size. } @@ -576,6 +578,8 @@ // the DrawingEngine/Painter does not need to be updated, since this // effects only the view->screen coord conversion, which is handled // by the view only + // TODO: (JackBurton) What about the pen size ? Since it depends on the scale, + // Don't we need to tell the drawing engine about it ? } From superstippi at gmx.de Mon Sep 10 12:16:31 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 10 Sep 2007 12:16:31 +0200 Subject: [Haiku-commits] r22213 - haiku/trunk/src/servers/app In-Reply-To: <200709100943.l8A9h3oV031898@sheep.berlios.de> References: <200709100943.l8A9h3oV031898@sheep.berlios.de> Message-ID: <20070910121631.3155.3@stippis.WG> Hi Stefano, > @@ -576,6 +578,8 @@ > // the DrawingEngine/Painter does not need to be updated, since this > // effects only the view->screen coord conversion, which is handled > // by the view only > + // TODO: (JackBurton) What about the pen size ? Since it depends on > the scale, > + // Don't we need to tell the drawing engine about it ? > } That observation is correct. Have you had a look at ServerWindow, does it update the pensize as well? It should. Best regards, -Stephan From jackburton at mail.berlios.de Mon Sep 10 12:20:26 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 10 Sep 2007 12:20:26 +0200 Subject: [Haiku-commits] r22214 - in haiku/trunk: headers/private/interface src/kits/interface src/servers/app Message-ID: <200709101020.l8AAKQYK005792@sheep.berlios.de> Author: jackburton Date: 2007-09-10 12:20:26 +0200 (Mon, 10 Sep 2007) New Revision: 22214 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22214&view=rev Modified: haiku/trunk/headers/private/interface/PictureDataWriter.h haiku/trunk/src/kits/interface/PictureDataWriter.cpp haiku/trunk/src/servers/app/ServerPicture.cpp Log: Setting the font shear in a BPicture didn't work, because the value was treated as uint32 in some places, when it's a float. Modified: haiku/trunk/headers/private/interface/PictureDataWriter.h =================================================================== --- haiku/trunk/headers/private/interface/PictureDataWriter.h 2007-09-10 09:43:02 UTC (rev 22213) +++ haiku/trunk/headers/private/interface/PictureDataWriter.h 2007-09-10 10:20:26 UTC (rev 22214) @@ -45,7 +45,7 @@ status_t WriteSetFontRotation(const float &rotation); status_t WriteSetFontEncoding(const int32 &encoding); status_t WriteSetFontFlags(const int32 &flags); - status_t WriteSetFontShear(const int32 &shear); + status_t WriteSetFontShear(const float &shear); status_t WriteSetFontFace(const int32 &face); status_t WriteStrokeLine(const BPoint &start, const BPoint &end); Modified: haiku/trunk/src/kits/interface/PictureDataWriter.cpp =================================================================== --- haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-09-10 09:43:02 UTC (rev 22213) +++ haiku/trunk/src/kits/interface/PictureDataWriter.cpp 2007-09-10 10:20:26 UTC (rev 22214) @@ -524,11 +524,11 @@ status_t -PictureDataWriter::WriteSetFontShear(const int32 &shear) +PictureDataWriter::WriteSetFontShear(const float &shear) { try { BeginOp(B_PIC_SET_FONT_SHEAR); - Write(shear); + Write(shear); EndOp(); } catch (status_t &status) { return status; Modified: haiku/trunk/src/servers/app/ServerPicture.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-10 09:43:02 UTC (rev 22213) +++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-10 10:20:26 UTC (rev 22214) @@ -858,10 +858,8 @@ if (mask & B_FONT_SHEAR) { float shear; - link.Read(&shear); - // TODO: For some reason writing the font shear - // results in missing font in Chart's BPictureButtons. Investigate. - //WriteSetFontShear(shear); + link.Read(&shear); + WriteSetFontShear(shear); } if (mask & B_FONT_ROTATION) { From stefano.ceccherini at gmail.com Mon Sep 10 12:31:34 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 10 Sep 2007 12:31:34 +0200 Subject: [Haiku-commits] r22213 - haiku/trunk/src/servers/app In-Reply-To: <20070910121631.3155.3@stippis.WG> References: <200709100943.l8A9h3oV031898@sheep.berlios.de> <20070910121631.3155.3@stippis.WG> Message-ID: <894b9700709100331k3269cf5ic4e1a5147bc23924@mail.gmail.com> 2007/9/10, Stephan Assmus : Hi Stephan, > > } > > That observation is correct. Have you had a look at ServerWindow, does it > update the pensize as well? It should. > After setting the scale, ServerWindow calls _UpdateDrawState(), which sync painter with the current drawing state from the view. And DrawState::PenSize() returns the correctly scaled pen size. So I guess we should do something similar in there. From superstippi at gmx.de Mon Sep 10 12:46:13 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 10 Sep 2007 12:46:13 +0200 Subject: [Haiku-commits] r22213 - haiku/trunk/src/servers/app In-Reply-To: <894b9700709100331k3269cf5ic4e1a5147bc23924@mail.gmail.com> References: <200709100943.l8A9h3oV031898@sheep.berlios.de> <20070910121631.3155.3@stippis.WG> <894b9700709100331k3269cf5ic4e1a5147bc23924@mail.gmail.com> Message-ID: <20070910124613.3313.4@stippis.WG> Stefano Ceccherini wrote (2007-09-10, 12:31:34 [+0200]): > 2007/9/10, Stephan Assmus : > > Hi Stephan, > > > > } > > > > That observation is correct. Have you had a look at ServerWindow, does > > it update the pensize as well? It should. > > > > After setting the scale, ServerWindow calls _UpdateDrawState(), which > sync painter with the current drawing state from the view. And > DrawState::PenSize() returns the correctly scaled pen size. So I guess we > should do something similar in there. _UpdateDrawState() is like the failsafe fallback. If a quicker way to sync the draw state is known, it can be used instead. Since the scale is usually not changed very frequently, using _UpdateDrawState() is not an issue though. Best regards, -Stephan From jackburton at mail.berlios.de Mon Sep 10 13:56:28 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 10 Sep 2007 13:56:28 +0200 Subject: [Haiku-commits] r22215 - haiku/trunk/src/servers/app Message-ID: <200709101156.l8ABuSBc027647@sheep.berlios.de> Author: jackburton Date: 2007-09-10 13:56:28 +0200 (Mon, 10 Sep 2007) New Revision: 22215 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22215&view=rev Modified: haiku/trunk/src/servers/app/ServerPicture.cpp Log: Sync the drawing engine state in set_scale. The pen size, for example, needs to be recalculated when the scale changes. Also call ResyncDrawingState() in exit_state_change(). This fixes the pen size test in FlattenTestPicture. Modified: haiku/trunk/src/servers/app/ServerPicture.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-10 10:20:26 UTC (rev 22214) +++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-09-10 11:56:28 UTC (rev 22215) @@ -485,6 +485,7 @@ static void exit_state_change(ViewLayer *view) { + view->Window()->ServerWindow()->ResyncDrawState(); } @@ -575,11 +576,10 @@ set_scale(ViewLayer *view, float scale) { view->CurrentState()->SetScale(scale); - // the DrawingEngine/Painter does not need to be updated, since this - // effects only the view->screen coord conversion, which is handled - // by the view only - // TODO: (JackBurton) What about the pen size ? Since it depends on the scale, - // Don't we need to tell the drawing engine about it ? + view->Window()->ServerWindow()->ResyncDrawState(); + + // Update the drawing engine draw state, since some stuff (for example + // the pen size) needs to be recalculated. } From michael.pfeiffer at utanet.at Mon Sep 10 14:08:40 2007 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Mon, 10 Sep 2007 14:08:40 +0200 Subject: [Haiku-commits] r22212 - haiku/trunk/src/apps/sudoku In-Reply-To: <200709092006.l89K68SB030174@sheep.berlios.de> References: <200709092006.l89K68SB030174@sheep.berlios.de> Message-ID: <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> > Center SudokuView and keep it square. Avoid flickering when > resizing. R5 build fixes. My checkin broke drawing under Haiku, the field background rectangles overwrite portions of the lines. Under BeOS this does not happen (Sorry had no time yesterday to test it under Haiku). My first guess is, that Haiku rounds coordinates not in the same way than BeOS, when filling a rectangle or there is an off by one bug. - Michael From superstippi at gmx.de Mon Sep 10 14:20:51 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 10 Sep 2007 14:20:51 +0200 Subject: [Haiku-commits] r22212 - haiku/trunk/src/apps/sudoku In-Reply-To: <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> References: <200709092006.l89K68SB030174@sheep.berlios.de> <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> Message-ID: <20070910142051.4326.10@stippis.WG> Michael Pfeiffer wrote (2007-09-10, 14:08:40 [+0200]): > > Center SudokuView and keep it square. Avoid flickering when resizing. > > R5 build fixes. > > My checkin broke drawing under Haiku, the field background rectangles > overwrite portions of the lines. > Under BeOS this does not happen (Sorry had no time yesterday to test it > under Haiku). My first guess is, that Haiku rounds coordinates not in the > same way than BeOS, when filling a rectangle or there is an off by one > bug. Could well be. Nice to have a reproducable test case. I will check. Best regards, -Stephan From jackburton at mail.berlios.de Mon Sep 10 16:55:43 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 10 Sep 2007 16:55:43 +0200 Subject: [Haiku-commits] r22216 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200709101455.l8AEthub006244@sheep.berlios.de> Author: jackburton Date: 2007-09-10 16:55:42 +0200 (Mon, 10 Sep 2007) New Revision: 22216 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22216&view=rev Modified: haiku/trunk/headers/os/interface/Picture.h haiku/trunk/src/kits/interface/Picture.cpp haiku/trunk/src/kits/interface/View.cpp Log: renamed private members of BPicture to fit our coding guidelines Modified: haiku/trunk/headers/os/interface/Picture.h =================================================================== --- haiku/trunk/headers/os/interface/Picture.h 2007-09-10 11:56:28 UTC (rev 22215) +++ haiku/trunk/headers/os/interface/Picture.h 2007-09-10 14:55:42 UTC (rev 22216) @@ -28,22 +28,12 @@ #ifndef _PICTURE_H #define _PICTURE_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include #include #include #include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - class BView; struct _BPictureExtent_; @@ -83,7 +73,10 @@ void _ImportData(const void *data, int32 size, BPicture **subs, int32 subCount); void _ImportOldData(const void *data, int32 size); + void SetToken(int32 token); + int32 Token() const; + bool _AssertLocalCopy(); bool _AssertOldLocalCopy(); bool _AssertServerCopy(); @@ -98,10 +91,12 @@ void Usurp(BPicture *lameDuck); BPicture *StepDown(); + - int32 token; - _BPictureExtent_ *extent; - BPicture *usurped; + int32 fToken; + _BPictureExtent_ *fExtent; + BPicture *fUsurped; + uint32 _reserved[3]; }; //------------------------------------------------------------------------------ Modified: haiku/trunk/src/kits/interface/Picture.cpp =================================================================== --- haiku/trunk/src/kits/interface/Picture.cpp 2007-09-10 11:56:28 UTC (rev 22215) +++ haiku/trunk/src/kits/interface/Picture.cpp 2007-09-10 14:55:42 UTC (rev 22216) @@ -62,9 +62,9 @@ BPicture::BPicture() : - token(-1), - extent(NULL), - usurped(NULL) + fToken(-1), + fExtent(NULL), + fUsurped(NULL) { _InitData(); } @@ -72,31 +72,31 @@ BPicture::BPicture(const BPicture &otherPicture) : - token(-1), - extent(NULL), - usurped(NULL) + fToken(-1), + fExtent(NULL), + fUsurped(NULL) { _InitData(); - if (otherPicture.token != -1) { + if (otherPicture.fToken != -1) { BPrivate::AppServerLink link; link.StartMessage(AS_CLONE_PICTURE); - link.Attach(otherPicture.token); + link.Attach(otherPicture.fToken); status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) - link.Read(&token); + link.Read(&fToken); if (status < B_OK) return; } - if (otherPicture.extent->Size() > 0) { - extent->ImportData(otherPicture.extent->Data(), otherPicture.extent->Size()); + if (otherPicture.fExtent->Size() > 0) { + fExtent->ImportData(otherPicture.fExtent->Data(), otherPicture.fExtent->Size()); - for (int32 i = 0; i < otherPicture.extent->CountPictures(); i++) { - BPicture *picture = new BPicture(*otherPicture.extent->PictureAt(i)); - extent->AddPicture(picture); + for (int32 i = 0; i < otherPicture.fExtent->CountPictures(); i++) { + BPicture *picture = new BPicture(*otherPicture.fExtent->PictureAt(i)); + fExtent->AddPicture(picture); } } } @@ -104,9 +104,9 @@ BPicture::BPicture(BMessage *archive) : - token(-1), - extent(NULL), - usurped(NULL) + fToken(-1), + fExtent(NULL), + fUsurped(NULL) { _InitData(); @@ -128,28 +128,28 @@ int32 i = 0; while (archive->FindMessage("piclib", i++, &picMsg) == B_OK) { BPicture *pic = new BPicture(&picMsg); - extent->AddPicture(pic); + fExtent->AddPicture(pic); } if (version == 0) { // TODO: For now. We'll see if it's worth to support old style data debugger("old style BPicture data is not supported"); } else if (version == 1) { - extent->ImportData(data, size); + fExtent->ImportData(data, size); -// swap_data(extent->fNewData, extent->fNewSize); +// swap_data(fExtent->fNewData, fExtent->fNewSize); - if (extent->Size() > 0) + if (fExtent->Size() > 0) _AssertServerCopy(); } // Do we just free the data now? - if (extent->Size() > 0) - extent->SetSize(0); + if (fExtent->Size() > 0) + fExtent->SetSize(0); // What with the sub pictures? - for (i = extent->CountPictures() - 1; i >= 0; i--) - extent->DeletePicture(i); + for (i = fExtent->CountPictures() - 1; i >= 0; i--) + fExtent->DeletePicture(i); } @@ -164,10 +164,10 @@ void BPicture::_InitData() { - token = -1; - usurped = NULL; + fToken = -1; + fUsurped = NULL; - extent = new (std::nothrow) _BPictureExtent_; + fExtent = new (std::nothrow) _BPictureExtent_; } @@ -180,17 +180,17 @@ void BPicture::_DisposeData() { - if (token != -1) { + if (fToken != -1) { BPrivate::AppServerLink link; link.StartMessage(AS_DELETE_PICTURE); - link.Attach(token); + link.Attach(fToken); link.Flush(); SetToken(-1); } - delete extent; - extent = NULL; + delete fExtent; + fExtent = NULL; } @@ -222,14 +222,14 @@ if (err != B_OK) return err; - err = archive->AddData("_data", B_RAW_TYPE, extent->Data(), extent->Size()); + err = archive->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size()); if (err != B_OK) return err; - for (int32 i = 0; i < extent->CountPictures(); i++) { + for (int32 i = 0; i < fExtent->CountPictures(); i++) { BMessage picMsg; - extent->PictureAt(i)->Archive(&picMsg, deep); + fExtent->PictureAt(i)->Archive(&picMsg, deep); err = archive->AddMessage("piclib", &picMsg); if (err != B_OK) break; @@ -252,7 +252,7 @@ if (!_AssertLocalCopy()) return B_ERROR; - BPrivate::PicturePlayer player(extent->Data(), extent->Size(), extent->Pictures()); + BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(), fExtent->Pictures()); return player.Play(callBackTable, tableEntries, user); } @@ -273,7 +273,7 @@ if (bytesWritten != (ssize_t)sizeof(header)) return B_IO_ERROR; - int32 count = extent->CountPictures(); + int32 count = fExtent->CountPictures(); bytesWritten = stream->Write(&count, sizeof(count)); if (bytesWritten < B_OK) return bytesWritten; @@ -281,19 +281,19 @@ return B_IO_ERROR; for (int32 i = 0; i < count; i++) { - status_t status = extent->PictureAt(i)->Flatten(stream); + status_t status = fExtent->PictureAt(i)->Flatten(stream); if (status < B_OK) return status; } - int32 size = extent->Size(); + int32 size = fExtent->Size(); bytesWritten = stream->Write(&size, sizeof(size)); if (bytesWritten < B_OK) return bytesWritten; if (bytesWritten != (ssize_t)sizeof(size)) return B_IO_ERROR; - bytesWritten = stream->Write(extent->Data(), size); + bytesWritten = stream->Write(fExtent->Data(), size); if (bytesWritten < B_OK) return bytesWritten; if (bytesWritten != size) @@ -329,21 +329,21 @@ if (status < B_OK) return status; - extent->AddPicture(picture); + fExtent->AddPicture(picture); } - status_t status = extent->ImportData(stream); + status_t status = fExtent->ImportData(stream); if (status < B_OK) return status; -// swap_data(extent->fNewData, extent->fNewSize); +// swap_data(fExtent->fNewData, fExtent->fNewSize); if (!_AssertServerCopy()) return B_ERROR; // Data is now kept server side, remove the local copy - if (extent->Data() != NULL) - extent->SetSize(0); + if (fExtent->Data() != NULL) + fExtent->SetSize(0); return status; } @@ -364,7 +364,7 @@ link.Attach(subCount); for (int32 i = 0; i < subCount; i++) - link.Attach(subs[i]->token); + link.Attach(subs[i]->fToken); link.Attach(size); link.Attach(data, size); @@ -372,7 +372,7 @@ status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) - link.Read(&token);*/ + link.Read(&fToken);*/ } @@ -384,19 +384,26 @@ void -BPicture::SetToken(int32 _token) +BPicture::SetToken(int32 token) { - token = _token; + fToken = token; } +int32 +BPicture::Token() const +{ + return fToken; +} + + bool BPicture::_AssertLocalCopy() { - if (extent->Data() != NULL) + if (fExtent->Data() != NULL) return true; - if (token == -1) + if (fToken == -1) return false; return _Download() == B_OK; @@ -415,14 +422,14 @@ bool BPicture::_AssertServerCopy() { - if (token != -1) + if (fToken != -1) return true; - if (extent->Data() == NULL) + if (fExtent->Data() == NULL) return false; - for (int32 i = 0; i < extent->CountPictures(); i++) - extent->PictureAt(i)->_AssertServerCopy(); + for (int32 i = 0; i < fExtent->CountPictures(); i++) + fExtent->PictureAt(i)->_AssertServerCopy(); return _Upload() == B_OK; } @@ -431,26 +438,26 @@ status_t BPicture::_Upload() { - ASSERT((token == -1)); - ASSERT((extent->Data() != NULL)); + ASSERT((fToken == -1)); + ASSERT((fExtent->Data() != NULL)); BPrivate::AppServerLink link; link.StartMessage(AS_CREATE_PICTURE); - link.Attach(extent->CountPictures()); + link.Attach(fExtent->CountPictures()); - for (int32 i = 0; i < extent->CountPictures(); i++) { - BPicture *picture = extent->PictureAt(i); + for (int32 i = 0; i < fExtent->CountPictures(); i++) { + BPicture *picture = fExtent->PictureAt(i); if (picture) - link.Attach(picture->token); + link.Attach(picture->fToken); } - link.Attach(extent->Size()); - link.Attach(extent->Data(), extent->Size()); + link.Attach(fExtent->Size()); + link.Attach(fExtent->Data(), fExtent->Size()); status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) - link.Read(&token); + link.Read(&fToken); return status; } @@ -459,13 +466,13 @@ status_t BPicture::_Download() { - ASSERT((extent->Data() == NULL)); - ASSERT((token != -1)); + ASSERT((fExtent->Data() == NULL)); + ASSERT((fToken != -1)); BPrivate::AppServerLink link; link.StartMessage(AS_DOWNLOAD_PICTURE); - link.Attach(token); + link.Attach(fToken); status_t status = B_ERROR; if (link.FlushWithReply(status) == B_OK && status == B_OK) { @@ -475,15 +482,15 @@ // Read sub picture tokens for (int32 i = 0; i < count; i++) { BPicture *pic = new BPicture; - link.Read(&pic->token); - extent->AddPicture(pic); + link.Read(&pic->fToken); + fExtent->AddPicture(pic); } int32 size; link.Read(&size); - status = extent->SetSize(size); + status = fExtent->SetSize(size); if (status == B_OK) - link.Read(const_cast(extent->Data()), size); + link.Read(const_cast(fExtent->Data()), size); } return status; @@ -493,20 +500,20 @@ const void * BPicture::Data() const { - if (extent->Data() == NULL) + if (fExtent->Data() == NULL) const_cast(this)->_AssertLocalCopy(); - return extent->Data(); + return fExtent->Data(); } int32 BPicture::DataSize() const { - if (extent->Data() == NULL) + if (fExtent->Data() == NULL) const_cast(this)->_AssertLocalCopy(); - return extent->Size(); + return fExtent->Size(); } @@ -519,15 +526,15 @@ _InitData(); // Do the Usurping - usurped = lameDuck; + fUsurped = lameDuck; } BPicture * BPicture::StepDown() { - BPicture *lameDuck = usurped; - usurped = NULL; + BPicture *lameDuck = fUsurped; + fUsurped = NULL; return lameDuck; } Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-09-10 11:56:28 UTC (rev 22215) +++ haiku/trunk/src/kits/interface/View.cpp 2007-09-10 14:55:42 UTC (rev 22216) @@ -3091,7 +3091,7 @@ void BView::BeginPicture(BPicture *picture) { - if (do_owner_check() && picture && picture->usurped == NULL) { + if (do_owner_check() && picture && picture->fUsurped == NULL) { picture->Usurp(cpicture); cpicture = picture; @@ -3105,8 +3105,8 @@ { check_lock(); - if (picture && picture->usurped == NULL) { - int32 token = picture->token; + if (picture && picture->fUsurped == NULL) { + int32 token = picture->Token(); if (token == -1) { BeginPicture(picture); @@ -3277,9 +3277,9 @@ if (picture == NULL) return; - if (do_owner_check() && picture->token > 0) { + if (do_owner_check() && picture->Token() > 0) { fOwner->fLink->StartMessage(AS_LAYER_DRAW_PICTURE); - fOwner->fLink->Attach(picture->token); + fOwner->fLink->Attach(picture->Token()); fOwner->fLink->Attach(where); _FlushIfNotInTransaction(); @@ -4286,7 +4286,7 @@ if (do_owner_check()) { fOwner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE); - fOwner->fLink->Attach(picture->token); + fOwner->fLink->Attach(picture->Token()); fOwner->fLink->Attach(where); fOwner->fLink->Attach(invert); From korli at mail.berlios.de Mon Sep 10 21:32:36 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 10 Sep 2007 21:32:36 +0200 Subject: [Haiku-commits] r22217 - in haiku/trunk/src/add-ons: accelerants/via kernel/drivers/graphics/via Message-ID: <200709101932.l8AJWaBX012981@sheep.berlios.de> Author: korli Date: 2007-09-10 21:32:34 +0200 (Mon, 10 Sep 2007) New Revision: 22217 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22217&view=rev Modified: haiku/trunk/src/add-ons/accelerants/via/Jamfile haiku/trunk/src/add-ons/kernel/drivers/graphics/via/Jamfile Log: renamed via.driver to via Modified: haiku/trunk/src/add-ons/accelerants/via/Jamfile =================================================================== --- haiku/trunk/src/add-ons/accelerants/via/Jamfile 2007-09-10 14:55:42 UTC (rev 22216) +++ haiku/trunk/src/add-ons/accelerants/via/Jamfile 2007-09-10 19:32:34 UTC (rev 22217) @@ -25,6 +25,6 @@ via.accelerant : boot home config add-ons accelerants ; -Depends via.accelerant : via.driver ; +Depends via.accelerant : via ; SubInclude HAIKU_TOP src add-ons accelerants via engine ; Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/via/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/via/Jamfile 2007-09-10 14:55:42 UTC (rev 22216) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/via/Jamfile 2007-09-10 19:32:34 UTC (rev 22217) @@ -5,16 +5,16 @@ UsePrivateHeaders graphics ; UsePrivateHeaders [ FDirName graphics via ] ; -KernelAddon via.driver : +KernelAddon via : driver.c ; Package haiku-via_gfx-cvs : README.html UPDATE.html ; Package haiku-via_gfx-cvs : - via.driver : + via : boot home config add-ons kernel drivers bin ; -PackageDriverSymLink haiku-via_gfx-cvs : graphics via.driver ; +PackageDriverSymLink haiku-via_gfx-cvs : graphics via ; Package haiku-via_gfx-cvs : via.settings : boot home config settings kernel drivers ; From korli at mail.berlios.de Mon Sep 10 21:33:32 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Mon, 10 Sep 2007 21:33:32 +0200 Subject: [Haiku-commits] r22218 - haiku/trunk/build/jam Message-ID: <200709101933.l8AJXWuE013044@sheep.berlios.de> Author: korli Date: 2007-09-10 21:33:32 +0200 (Mon, 10 Sep 2007) New Revision: 22218 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22218&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: added via driver and accelerant to the image Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-09-10 19:32:34 UTC (rev 22217) +++ haiku/trunk/build/jam/HaikuImage 2007-09-10 19:33:32 UTC (rev 22218) @@ -78,6 +78,7 @@ BEOS_ADD_ONS_ACCELERANTS = $(X86_ONLY)radeon.accelerant $(X86_ONLY)nvidia.accelerant $(X86_ONLY)matrox.accelerant $(X86_ONLY)neomagic.accelerant $(X86_ONLY)intel_extreme.accelerant $(X86_ONLY)s3savage.accelerant vesa.accelerant + $(X86_ONLY)via.accelerant #$(X86_ONLY)vmware.accelerant ; BEOS_ADD_ONS_TRANSLATORS = BMPTranslator GIFTranslator JPEGTranslator @@ -111,7 +112,7 @@ BEOS_ADD_ONS_DRIVERS_AUDIO = auich auvia 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)s3savage vesa #$(X86_ONLY)vmware + $(X86_ONLY)s3savage $(X86_ONLY)via vesa #$(X86_ONLY)vmware ; BEOS_ADD_ONS_DRIVERS_MIDI = emuxki ; BEOS_ADD_ONS_DRIVERS_NET = etherpci ipro1000 rtl8139 rtl8169 sis900 From korli at mail.berlios.de Tue Sep 11 18:43:57 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 11 Sep 2007 18:43:57 +0200 Subject: [Haiku-commits] r22219 - in haiku/trunk/src/add-ons: accelerants/nvidia/engine kernel/drivers/graphics/nvidia Message-ID: <200709111643.l8BGhvSj000714@sheep.berlios.de> Author: korli Date: 2007-09-11 18:43:49 +0200 (Tue, 11 Sep 2007) New Revision: 22219 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22219&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/driver.c Log: added the pci id for GeForce 6100 nForce 405, bug #1472 Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-10 19:33:32 UTC (rev 22218) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-11 16:43:49 UTC (rev 22219) @@ -765,6 +765,7 @@ status = nvxx_general_powerup(); break; case 0x024210de: /* Nvidia GeForce 6100 (NFORCE4 Integr.GPU) */ + case 0x03d110de: /* Nvidia GeForce 6100 nForce 405 */ si->ps.card_type = NV44; si->ps.card_arch = NV40A; sprintf(si->adi.name, "Nvidia GeForce 6100"); Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/driver.c 2007-09-10 19:33:32 UTC (rev 22218) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/driver.c 2007-09-11 16:43:49 UTC (rev 22219) @@ -302,6 +302,7 @@ 0x0392, /* Nvidia GeForce 7600 GS */ 0x0393, /* Nvidia GeForce 7300 GT */ 0x0398, /* Nvidia GeForce 7600 GO */ + 0x03d1, /* Nvidia GeForce 6100 nForce 405 */ 0 }; /* From stippi at mail.berlios.de Tue Sep 11 23:23:08 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 11 Sep 2007 23:23:08 +0200 Subject: [Haiku-commits] r22220 - in haiku/trunk/src: kits/interface servers/app Message-ID: <200709112123.l8BLN8F9020240@sheep.berlios.de> Author: stippi Date: 2007-09-11 23:23:07 +0200 (Tue, 11 Sep 2007) New Revision: 22220 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22220&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/servers/app/ServerWindow.cpp Log: * transmit correct type in BView::BeginRectTracking() * put message codes for Begin/EndRectTracking() into giant switch... not actually implemented though Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-09-11 16:43:49 UTC (rev 22219) +++ haiku/trunk/src/kits/interface/View.cpp 2007-09-11 21:23:07 UTC (rev 22220) @@ -1274,7 +1274,7 @@ if (do_owner_check()) { fOwner->fLink->StartMessage(AS_LAYER_BEGIN_RECT_TRACK); fOwner->fLink->Attach(startRect); - fOwner->fLink->Attach(style); + fOwner->fLink->Attach(style); } } Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-09-11 16:43:49 UTC (rev 22219) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-09-11 21:23:07 UTC (rev 22220) @@ -1934,6 +1934,27 @@ break; } + case AS_LAYER_BEGIN_RECT_TRACK: + { + DTRACE(("ServerWindow %s: Message AS_LAYER_BEGIN_RECT_TRACK\n", Title())); + BRect dragRect; + uint32 style; + + link.Read(&dragRect); + link.Read(&style); + + // TODO: implement rect tracking (used sometimes for selecting + // a group of things, also sometimes used to appear to drag something, + // but without real drag message) + break; + } + case AS_LAYER_END_RECT_TRACK: + { + DTRACE(("ServerWindow %s: Message AS_LAYER_END_RECT_TRACK\n", Title())); + // TODO: implement rect tracking + break; + } + case AS_LAYER_BEGIN_PICTURE: { DTRACE(("ServerWindow %s: Message AS_LAYER_BEGIN_PICTURE\n", Title())); @@ -2337,8 +2358,10 @@ } default: - printf("ServerWindow %s received unexpected code - message offset %ld\n", - Title(), code - B_OK); + BString codeString; + string_for_message_code(code, codeString); + printf("ServerWindow %s received unexpected code: %s\n", + Title(), codeString.String()); if (link.NeedsReply()) { // the client is now blocking and waiting for a reply! From marcusoverhagen at mail.berlios.de Wed Sep 12 00:09:13 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 12 Sep 2007 00:09:13 +0200 Subject: [Haiku-commits] r22221 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709112209.l8BM9DXB024293@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-12 00:09:13 +0200 (Wed, 12 Sep 2007) New Revision: 22221 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22221&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h Log: correct port number handling allocate memory for command list and fis Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-11 21:23:07 UTC (rev 22220) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-11 22:09:13 UTC (rev 22221) @@ -21,8 +21,8 @@ , fPCIVendorID(0xffff) , fPCIDeviceID(0xffff) , fCommandSlotCount(0) - , fPortCount(0) - , fPortMax(0) + , fPortCountMax(0) + , fPortCountAvail(0) , fIRQ(0) , fInstanceCheck(-1) { @@ -90,15 +90,13 @@ } fCommandSlotCount = 1 + ((fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); - fPortCount = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + fPortCountMax = 1 + ((fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); + fPortCountAvail = count_bits_set(fRegs->pi); if (fRegs->pi == 0) { TRACE("controller doesn't implement any ports\n"); goto err; } - fPortMax = 31; - while ((fRegs->pi & (1 << fPortMax)) == 0) - fPortMax--; fIRQ = gPCI->read_pci_config(fPCIDevice, PCI_interrupt_line, 1); if (fIRQ == 0 || fIRQ == 0xff) { @@ -108,7 +106,7 @@ TRACE("cap: Interface Speed Support: generation %lu\n", (fRegs->cap >> CAP_ISS_SHIFT) & CAP_ISS_MASK); TRACE("cap: Number of Command Slots: %d (raw %#lx)\n", fCommandSlotCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); - TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCount, (fRegs->cap >> CAP_NCS_SHIFT) & CAP_NCS_MASK); + TRACE("cap: Number of Ports: %d (raw %#lx)\n", fPortCountMax, (fRegs->cap >> CAP_NP_SHIFT) & CAP_NP_MASK); TRACE("cap: Supports Port Multiplier: %s\n", (fRegs->cap & CAP_SPM) ? "yes" : "no"); TRACE("cap: Supports External SATA: %s\n", (fRegs->cap & CAP_SXS) ? "yes" : "no"); TRACE("cap: Enclosure Management Supported: %s\n", (fRegs->cap & CAP_EMS) ? "yes" : "no"); @@ -121,8 +119,8 @@ TRACE("cap: Supports AHCI mode only: %s\n", (fRegs->cap & CAP_SAM) ? "yes" : "no"); TRACE("ghc: AHCI Enable: %s\n", (fRegs->ghc & GHC_AE) ? "yes" : "no"); - TRACE("Ports Implemented: %08lx\n", fRegs->pi); - TRACE("Highest port Number: %d\n", fPortMax); + TRACE("Ports Implemented Mask: %#08lx\n", fRegs->pi); + TRACE("Number of Available Ports: %d\n", fPortCountAvail); TRACE("AHCI Version %lu.%lu\n", fRegs->vs >> 16, fRegs->vs & 0xff); TRACE("Interrupt %u\n", fIRQ); @@ -132,7 +130,7 @@ goto err; } - for (int i = 0; i <= fPortMax; i++) { + for (int i = 0; i <= fPortCountMax; i++) { if (fRegs->pi & (1 << i)) { fPort[i] = new (std::nothrow)AHCIPort(this, i); if (!fPort[i]) { @@ -166,7 +164,7 @@ { TRACE("AHCIController::Uninit\n"); - for (int i = 0; i <= fPortMax; i++) { + for (int i = 0; i <= fPortCountMax; i++) { if (fPort[i]) { fPort[i]->Uninit(); delete fPort[i]; @@ -233,7 +231,7 @@ if (int_stat == 0) return B_UNHANDLED_INTERRUPT; - for (int i = 0; i < self->fPortMax; i++) { + for (int i = 0; i < self->fPortCountMax; i++) { if (int_stat & (1 << i)) { if (self->fPort[i]) { self->fPort[i]->Interrupt(); Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-11 21:23:07 UTC (rev 22220) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h 2007-09-11 22:09:13 UTC (rev 22221) @@ -44,8 +44,8 @@ volatile ahci_hba * fRegs; area_id fRegsArea; int fCommandSlotCount; - int fPortCount; - int fPortMax; + int fPortCountMax; + int fPortCountAvail; uint8 fIRQ; AHCIPort * fPort[32]; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-11 21:23:07 UTC (rev 22220) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-11 22:09:13 UTC (rev 22221) @@ -47,10 +47,37 @@ }; +enum { + INT_CPD = (1 << 31), // Cold Port Detect Status/Enable + INT_TFE = (1 << 30), // Task File Error Status/Enable + INT_HBF = (1 << 29), // Host Bus Fatal Error Status/Enable + INT_HBD = (1 << 28), // Host Bus Data Error Status/Enable + INT_IF = (1 << 27), // Interface Fatal Error Status/Enable + INT_INF = (1 << 26), // Interface Non-fatal Error Status/Enable + INT_OF = (1 << 24), // Overflow Status/Enable + INT_IPM = (1 << 23), // Incorrect Port Multiplier Status/Enable + INT_PRC = (1 << 22), // PhyRdy Change Status/Enable + INT_DMP = (1 << 7), // Device Mechanical Presence Status/Enable + INT_PC = (1 << 6), // Port Change Interrupt Status/Enable + INT_DP = (1 << 5), // Descriptor Processed Interrupt/Enable + INT_UF = (1 << 4), // Unknown FIS Interrupt/Enable + INT_SDB = (1 << 3), // Set Device Bits Interrupt/Enable + INT_DS = (1 << 2), // DMA Setup FIS Interrupt/Enable + INT_PS = (1 << 1), // PIO Setup FIS Interrupt/Enable + INT_DHR = (1 << 0), // Device to Host Register FIS Interrupt/Enable +}; + + +enum { + AHCI_CLB_SIZE = 1024, + AHCI_FIS_SIZE = 256, +}; + + typedef struct { - uint32 clb; // Command List Base Address + uint32 clb; // Command List Base Address (alignment 1024 byte) uint32 clbu; // Command List Base Address Upper 32-Bits - uint32 fb; // FIS Base Address + uint32 fb; // FIS Base Address (alignment 256 byte) uint32 fbu; // FIS Base Address Upper 32-Bits uint32 is; // Interrupt Status uint32 ie; // Interrupt Enable @@ -91,4 +118,22 @@ extern pci_device_module_info *gPCI; extern scsi_for_sim_interface *gSCSI; +#define LO32(val) ((uint32)(val)) +#define HI32(val) (((uint64)(val)) >> 32) + +#ifdef __cplusplus + +template +int count_bits_set(T value) +{ + int count = 0; + for (T mask = 1; mask; mask <<= 1) + if (value & mask) + count++; + return count; +} + +#endif /* __cplusplus */ + + #endif /* _AHCI_DEFS_H */ Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-11 21:23:07 UTC (rev 22220) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-11 22:09:13 UTC (rev 22221) @@ -5,6 +5,7 @@ #include "ahci_port.h" #include "ahci_controller.h" +#include "util.h" #include #include @@ -16,6 +17,7 @@ AHCIPort::AHCIPort(AHCIController *controller, int index) : fIndex(index) , fRegs(&controller->fRegs->port[index]) + , fArea(-1) { } @@ -29,6 +31,29 @@ AHCIPort::Init() { TRACE("AHCIPort::Init port %d\n", fIndex); + + size_t size = 999; + + void *virtAddr; + void *physAddr; + + fArea = alloc_mem(&virtAddr, &physAddr, size, 0, "some AHCI port"); + if (fArea < B_OK) { + TRACE("failed allocating memory for port %d\n", fIndex); + return fArea; + } + + void *virtClbAddr; + void *physClbAddr = physAddr; + void *virtFisAddr; + void *physFisAddr = (char *)physAddr + 1024; + + + fRegs->clb = LO32(physClbAddr); + fRegs->clbu = HI32(physClbAddr); + fRegs->fb = LO32(physFisAddr); + fRegs->fbu = HI32(physFisAddr); + return B_OK; } @@ -37,6 +62,20 @@ AHCIPort::Uninit() { TRACE("AHCIPort::Uninit port %d\n", fIndex); + + // disable interrupts + fRegs->ie = 0; + + // clear pending interrupts + fRegs->is = fRegs->is; + + // invalidate DMA addresses + fRegs->clb = 0; + fRegs->clbu = 0; + fRegs->fb = 0; + fRegs->fbu = 0; + + delete_area(fArea); } Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-11 21:23:07 UTC (rev 22220) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-11 22:09:13 UTC (rev 22221) @@ -25,10 +25,12 @@ uchar TerminateRequest(scsi_ccb *request); uchar ResetDevice(); +private: private: int fIndex; volatile ahci_port * fRegs; +area_id fArea; }; #endif // _AHCI_PORT_H From stippi at mail.berlios.de Wed Sep 12 08:08:43 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 12 Sep 2007 08:08:43 +0200 Subject: [Haiku-commits] r22222 - haiku/trunk/src/preferences/time Message-ID: <200709120608.l8C68hnh032247@sheep.berlios.de> Author: stippi Date: 2007-09-12 08:08:42 +0200 (Wed, 12 Sep 2007) New Revision: 22222 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22222&view=rev Modified: haiku/trunk/src/preferences/time/BaseView.cpp haiku/trunk/src/preferences/time/BaseView.h haiku/trunk/src/preferences/time/Bitmaps.cpp haiku/trunk/src/preferences/time/Bitmaps.h haiku/trunk/src/preferences/time/CalendarView.cpp haiku/trunk/src/preferences/time/SectionEdit.cpp haiku/trunk/src/preferences/time/SettingsView.cpp haiku/trunk/src/preferences/time/SettingsView.h haiku/trunk/src/preferences/time/Time.cpp haiku/trunk/src/preferences/time/Time.h haiku/trunk/src/preferences/time/TimeMessages.h haiku/trunk/src/preferences/time/TimeSettings.cpp haiku/trunk/src/preferences/time/TimeSettings.h haiku/trunk/src/preferences/time/TimeWindow.cpp haiku/trunk/src/preferences/time/TimeWindow.h haiku/trunk/src/preferences/time/ZoneView.cpp haiku/trunk/src/preferences/time/ZoneView.h Log: patch by Julun: * further cleanup of code to apply style guide * removed now obsolete clock bitmaps * some restructuring of the code * adjusted layout of the time zone pane Modified: haiku/trunk/src/preferences/time/BaseView.cpp =================================================================== --- haiku/trunk/src/preferences/time/BaseView.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/BaseView.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,26 +1,30 @@ /* - BaseView.cpp - by Mike Berg (inseculous) -*/ + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Mike Berg (inseculous) + * Julun + */ -#include -#include - #include "BaseView.h" #include "TimeMessages.h" +#include +#include + + TTimeBaseView::TTimeBaseView(BRect frame, const char *name) : BView(frame, name, B_FOLLOW_ALL_SIDES, B_PULSE_NEEDED), - fMessage(NULL) + fIsGMT(false), + fMessage(H_TIME_UPDATE) { - fMessage = new BMessage(H_TIME_UPDATE); } TTimeBaseView::~TTimeBaseView() { - delete fMessage; } @@ -47,76 +51,71 @@ void -TTimeBaseView::DispatchMessage() -{ - if (fMessage == NULL) - return; - - time_t current = time(NULL); - - struct tm *ltime; - - if (fIsGMT) - ltime = gmtime(¤t); - else - ltime = localtime(¤t); - - int32 month = ltime->tm_mon; - int32 day = ltime->tm_mday; - int32 year = ltime->tm_year; - int32 hour = ltime->tm_hour; - int32 minute = ltime->tm_min; - int32 second = ltime->tm_sec; - - fMessage->MakeEmpty(); - fMessage->AddInt32("month", month); - fMessage->AddInt32("day", day); - fMessage->AddInt32("year", year); - fMessage->AddInt32("hour", hour); - fMessage->AddInt32("minute", minute); - fMessage->AddInt32("second", second); - - SendNotices(H_TM_CHANGED, fMessage); -} - - -void TTimeBaseView::ChangeTime(BMessage *message) { - bool istime; - if (message->FindBool("time", &istime) != B_OK) + bool isTime; + if (message->FindBool("time", &isTime) != B_OK) return; - time_t atime = time(NULL); - struct tm *_tm = localtime(&atime); + time_t tmp = time(NULL); + struct tm *tm_struct = localtime(&tmp); - int32 hour = 0; - int32 minute = 0; - int32 second = 0; - int32 month = 0; - int32 day = 0; - int32 year = 0; - bool isam = false; - if (istime) { + if (isTime) { + int32 hour = 0; if (message->FindInt32("hour", &hour) == B_OK) - _tm->tm_hour = hour; + tm_struct->tm_hour = hour; + + int32 minute = 0; if (message->FindInt32("minute", &minute) == B_OK) - _tm->tm_min = minute; + tm_struct->tm_min = minute; + + int32 second = 0; if (message->FindInt32("second", &second) == B_OK) - _tm->tm_sec = second; - if (message->FindBool("isam", &isam) == B_OK) { - if (!isam) - _tm->tm_hour += 12; + tm_struct->tm_sec = second; + + bool isAM = false; + if (message->FindBool("isam", &isAM) == B_OK) { + if (!isAM) + tm_struct->tm_hour += 12; } } else { + int32 month = 0; if (message->FindInt32("month", &month) == B_OK) - _tm->tm_mon = month; + tm_struct->tm_mon = month; + + int32 day = 0; if (message->FindInt32("day", &day) == B_OK) - _tm->tm_mday = day; + tm_struct->tm_mday = day; + + int32 year = 0; if (message->FindInt32("year", &year) == B_OK) - _tm->tm_year = year; + tm_struct->tm_year = year; } - time_t atime2 = mktime(_tm); - set_real_time_clock(atime2); + tmp = mktime(tm_struct); + set_real_time_clock(tmp); } + + +void +TTimeBaseView::DispatchMessage() +{ + time_t tmp = time(NULL); + struct tm *tm_struct = localtime(&tmp); + + if (fIsGMT) + tm_struct = gmtime(&tmp); + + fMessage.MakeEmpty(); + + fMessage.AddInt32("month", tm_struct->tm_mon); + fMessage.AddInt32("day", tm_struct->tm_mday); + fMessage.AddInt32("year", tm_struct->tm_year); + + fMessage.AddInt32("hour", tm_struct->tm_hour); + fMessage.AddInt32("minute", tm_struct->tm_min); + fMessage.AddInt32("second", tm_struct->tm_sec); + + SendNotices(H_TM_CHANGED, &fMessage); +} + Modified: haiku/trunk/src/preferences/time/BaseView.h =================================================================== --- haiku/trunk/src/preferences/time/BaseView.h 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/BaseView.h 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,25 +1,37 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Mike Berg (inseculous) + * Julun + */ #ifndef TIMEBASE_H #define TIMEBASE_H + +#include #include -#include class TTimeBaseView: public BView { public: - TTimeBaseView(BRect frmae, const char *name); - virtual ~TTimeBaseView(); + TTimeBaseView(BRect frame, const char *name); + virtual ~TTimeBaseView(); - virtual void Pulse(); - virtual void AttachedToWindow(); + virtual void Pulse(); + virtual void AttachedToWindow(); - void ChangeTime(BMessage *); - void SetGMTime(bool); + void SetGMTime(bool gmtTime); + void ChangeTime(BMessage *message); + protected: - virtual void DispatchMessage(); + virtual void DispatchMessage(); + private: - BMessage *fMessage; - bool fIsGMT; + bool fIsGMT; + BMessage fMessage; }; -#endif //TIMEBASE_H +#endif // TIMEBASE_H + Modified: haiku/trunk/src/preferences/time/Bitmaps.cpp =================================================================== --- haiku/trunk/src/preferences/time/Bitmaps.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/Bitmaps.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,13 +1,23 @@ -#include +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Julun + */ + +#include "Bitmaps.h" + + #include #include -#include "Bitmaps.h" void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with) { - ASSERT(bitmap->ColorSpace() == B_COLOR_8_BIT); // other color spaces not implemented yet + // other color spaces not implemented yet + ASSERT(bitmap->ColorSpace() == B_COLOR_8_BIT); BScreen screen(B_MAIN_SCREEN_ID); uint32 withIndex = screen.IndexForColor(with); Modified: haiku/trunk/src/preferences/time/Bitmaps.h =================================================================== --- haiku/trunk/src/preferences/time/Bitmaps.h 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/Bitmaps.h 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,510 +1,19 @@ -void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with); +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Julun + */ +#ifndef ANALOG_CLOCK_H +#define ANALOG_CLOCK_H -const int32 kClockFaceWidth = 85; -const int32 kClockFaceHeight = 85; -const color_space kClockFaceColorSpace = B_CMAP8; -const unsigned char kClockFaceBits [] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x3f,0x3f,0x1e,0xff,0x18,0x16,0x13,0x12,0x11, - 0x10,0x10,0x10,0x10,0x10,0x11,0x12,0x13,0x16,0x18,0x1a,0x1d,0x3f,0x1d,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x3f,0x1e,0x1a,0x17, - 0x13,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x13,0x17,0x19,0x1e,0x1d,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x1e,0x3f,0x3f,0x1a,0x16,0x12,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x12, - 0x16,0x19,0x1e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x1e,0x18,0x13,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x13,0x16,0x1c,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1e,0x3f,0x1e,0x18, - 0x12,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x0d,0x0b,0x09,0x07,0x06,0x05,0x04, - 0x03,0x03,0x03,0x04,0x05,0x06,0x07,0x09,0x0b,0x0d,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x12,0x15,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0x1d,0x3f,0x3f,0x19,0x13,0x10,0x10,0x10,0x10,0x10,0x10,0x0e,0x0b,0x08, - 0x05,0x03,0x05,0x08,0x0c,0x11,0x15,0x19,0x1c,0x1e,0x3f,0x1e,0x1c,0x19,0x15,0x11, - 0x0c,0x08,0x08,0x08,0x0b,0x0e,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x13,0x15, - 0x1d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x1b,0x14,0x10,0x10,0x10, - 0x10,0x10,0x10,0x0c,0x08,0x05,0x04,0x08,0x0f,0x17,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x17,0x0f,0x0b,0x0a,0x0c, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x12,0x17,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1c, - 0x3f,0x3f,0x18,0x11,0x10,0x10,0x10,0x10,0x0f,0x0b,0x07,0x03,0x06,0x0f,0x19,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x19,0x0f,0x0c,0x0b,0x0f,0x10,0x10,0x10,0x10,0x10, - 0x10,0x11,0x14,0x1c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x1d,0x15,0x10,0x10,0x10,0x10,0x10,0x0b, - 0x07,0x03,0x08,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x13,0x0e,0x0c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x12,0x18,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x1b, - 0x13,0x10,0x10,0x10,0x10,0x0d,0x08,0x03,0x08,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x0e,0x0d,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x16,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0x1e,0x3f,0x1a,0x12,0x10,0x10,0x10,0x10,0x0a,0x05,0x05,0x10, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b, - 0x3f,0x3f,0xda,0x2b,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x13,0x0e,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x14,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1e,0x3f,0x19,0x11,0x10, - 0x10,0x10,0x0e,0x08,0x03,0x0a,0x18,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x10, - 0x0e,0x10,0x10,0x10,0x10,0x10,0x0f,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0x1d,0x3f,0x19,0x11,0x10,0x10,0x10,0x0d,0x07,0x04,0x0f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b, - 0x3f,0x3f,0x3f,0x3f,0x1d,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x13,0x0f,0x10,0x10,0x10,0x10,0x10,0x0f, - 0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x1a,0x11,0x10,0x10,0x10, - 0x0c,0x06,0x06,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x2b,0xda,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x16,0x10,0x10,0x10,0x10,0x10,0x10,0x0e,0x13,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x1c,0x3f,0x1b,0x12,0x10,0x10,0x10,0x0c,0x05,0x06,0x16,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b, - 0x3f,0x3f,0x3f,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x10,0x10,0x10,0x10,0x10, - 0x10,0x0e,0x14,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x1d,0x13,0x10,0x10,0x10,0x0c,0x05, - 0x07,0x18,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0xda,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x1a,0x11,0x10,0x10,0x10,0x10,0x10,0x0e,0x16,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f, - 0x3f,0x15,0x10,0x10,0x10,0x0d,0x06,0x06,0x18,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x2b, - 0x2b,0x3f,0x2b,0x2b,0x2b,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xad, - 0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1a,0x11,0x10,0x10, - 0x10,0x10,0x10,0x0e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x3f,0x18,0x10,0x10,0x10,0x0e,0x07,0x06,0x16, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x19,0x11,0x10,0x10,0x10,0x10,0x0d,0x10,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x1b, - 0x11,0x10,0x10,0x10,0x08,0x04,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xad, - 0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x17,0x11, - 0x10,0x10,0x10,0x10,0x0d,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0x1e,0x3f,0x14,0x10,0x10,0x10,0x0a,0x03,0x0f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x15,0x10,0x10,0x10,0x10,0x10,0x0d,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0x3f,0x19,0x10, - 0x10,0x10,0x0d,0x05,0x0a,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x13,0x10,0x10,0x10,0x10,0x0c,0x10,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0x3f,0x1e,0x13,0x10,0x10,0x10,0x08,0x05,0x18,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1a,0x12,0x10,0x10,0x10,0x10,0x0c,0x17, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0x3f,0x18,0x10,0x10, - 0x10,0x0b,0x03,0x10,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x16,0x10,0x10,0x10,0x10,0x0d,0x0e,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0x1e,0x1e,0x12,0x10,0x10,0x0f,0x07,0x08,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1e,0x14,0x10,0x10,0x10,0x10,0x0b, - 0x17,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0x3f,0x18,0x10,0x10,0x10, - 0x0b,0x03,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x18,0x10,0x10,0x10,0x10,0x0c,0x0e,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0x1d,0x3f,0x13,0x10,0x10,0x10,0x07,0x08,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x15,0x10,0x10,0x10,0x10, - 0x0a,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0x3f,0x1a,0x10,0x10,0x10,0x0c, - 0x03,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x18,0x10,0x10,0x10,0x10,0x0a,0x11,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0x3f,0x16,0x10,0x10,0x10,0x08,0x06,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x13,0x10,0x10,0x10, - 0x0d,0x0b,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0x1d,0x1e,0x12,0x10,0x10,0x0e,0x05, - 0x0f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x17,0x10,0x10,0x10,0x10,0x09,0x18,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0x3f,0x1a,0x10,0x10,0x10,0x0b,0x04,0x19,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x11,0x10,0x10, - 0x10,0x09,0x11,0xff,0xff,0x3f,0x3f,0x3f,0xff,0x3f,0x17,0x10,0x10,0x10,0x08,0x08, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x0c,0x0b,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0x3f,0x13,0x10,0x10,0x10,0x05,0x0f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x10,0x10, - 0x10,0x0e,0x08,0xff,0xff,0x3f,0x3f,0x3f,0xff,0x1e,0x10,0x10,0x10,0x0d,0x03,0x17, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x10,0x10,0x10,0x10,0x07,0x17,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0x10,0x10,0x10,0x0b,0x05,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x11,0x10, - 0x10,0x10,0x08,0x12,0xff,0x3f,0x3f,0x3f,0xff,0x18,0x10,0x10,0x10,0x09,0x08,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x0a,0x0d,0xff,0x3f,0x3f,0x3f, - 0xff,0x16,0x10,0x10,0x10,0x07,0x0c,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x17,0x10, - 0x10,0x10,0x0b,0x0a,0xff,0x3f,0x3f,0x3f,0xff,0x13,0x10,0x10,0x10,0x06,0x11,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x19,0x10,0x10,0x10,0x0d,0x08,0xff,0x3f,0x3f,0x3f, - 0xff,0x12,0x10,0x10,0x10,0x05,0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x10, - 0x10,0x10,0x0e,0x06,0xff,0x3f,0x3f,0x3f,0xff,0x11,0x10,0x10,0x10,0x04,0x19,0x3f, - 0x3f,0x3f,0x3f,0xda,0x2b,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xda,0x2b, - 0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x1d,0x10,0x10,0x10,0x0f,0x05,0xff,0x3f,0x3f,0x3f, - 0xff,0x10,0x10,0x10,0x10,0x03,0x1c,0x3f,0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x1e,0x10, - 0x10,0x10,0x0f,0x03,0xff,0x3f,0x3f,0x3f,0xff,0x10,0x10,0x10,0x10,0x03,0x1e,0x3f, - 0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x10,0x10,0x10,0x10,0x03,0xff,0x3f,0x3f,0x3f, - 0xff,0x10,0x10,0x10,0x10,0x03,0x3f,0x3f,0x3f,0x3f,0x3f,0xda,0x2b,0x2b,0x2b,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x10, - 0x10,0x10,0x0f,0x03,0xff,0x3f,0x3f,0x3f,0xff,0x10,0x10,0x10,0x10,0x04,0x1e,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0xda,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x10,0x10,0x10,0x0f,0x03,0xff,0x3f,0x3f,0x3f, - 0xff,0x10,0x10,0x10,0x10,0x05,0x1c,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0xda,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x1e,0x10, - 0x10,0x10,0x0e,0x03,0xff,0x3f,0x3f,0x3f,0xff,0x11,0x10,0x10,0x10,0x06,0x19,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xda,0x2b, - 0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x1d,0x10,0x10,0x10,0x0d,0x05,0xff,0x3f,0x3f,0x3f, - 0xff,0x12,0x10,0x10,0x10,0x07,0x15,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x10, - 0x10,0x10,0x0b,0x06,0xff,0x3f,0x3f,0x3f,0xff,0x13,0x10,0x10,0x10,0x09,0x11,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x19,0x10,0x10,0x10,0x0a,0x08,0xff,0x3f,0x3f,0x3f, - 0xff,0x16,0x10,0x10,0x10,0x0b,0x0c,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x17,0x10, - 0x10,0x10,0x08,0x0a,0xff,0x3f,0x3f,0x3f,0xff,0x18,0x10,0x10,0x10,0x0d,0x08,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x06,0x0d,0xff,0x3f,0x3f,0x3f, - 0xff,0x1a,0x10,0x10,0x10,0x10,0x08,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x11,0x10, - 0x10,0x0e,0x04,0x12,0xff,0x3f,0x3f,0x3f,0xff,0x1d,0x10,0x10,0x10,0x10,0x08,0x17, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x10,0x10,0x10,0x0c,0x04,0x17,0xff,0x3f,0x3f,0x3f, - 0xff,0x3f,0x13,0x10,0x10,0x10,0x0b,0x0f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x10,0x10, - 0x10,0x09,0x07,0xff,0xff,0x3f,0x3f,0x3f,0xff,0x1d,0x17,0x10,0x10,0x10,0x0e,0x0b, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x06,0x0b,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0x19,0x10,0x10,0x10,0x10,0x0a,0x19,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1d,0x11,0x10,0x10, - 0x0d,0x04,0x11,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0x1e,0x12,0x10,0x10,0x10,0x0c, - 0x0f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x18,0x10,0x10,0x10,0x0a,0x05,0x18,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0x1d,0x16,0x10,0x10,0x10,0x10,0x0c,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x13,0x10,0x10,0x10, - 0x06,0x0a,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0x19,0x10,0x10,0x10,0x10, - 0x0b,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x1a,0x10,0x10,0x10,0x0c,0x03,0x11,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0x1e,0x13,0x10,0x10,0x10,0x0f,0x0e,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x08, - 0x07,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0x16,0x10,0x10,0x10, - 0x10,0x0c,0x14,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x1a,0x10,0x10,0x10,0x0d,0x04,0x0e,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0x1c,0x12,0x10,0x10,0x10,0x10,0x0e,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x14,0x10,0x10,0x10,0x08,0x06, - 0x17,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0x15,0x10,0x10, - 0x10,0x10,0x0d,0x13,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x18,0x10,0x10,0x10,0x0c,0x04,0x0d,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0x13,0x10,0x10,0x10,0x10,0x0e,0x18,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x12,0x10,0x10,0x10,0x07,0x06,0x17, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0x15,0x10, - 0x10,0x10,0x10,0x10,0x10,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x15,0x10,0x10,0x10,0x0b,0x03,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0x12,0x10,0x10,0x10,0x10,0x0e,0x13,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x10,0x10,0x10,0x0d,0x06,0x09,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x17, - 0x11,0x10,0x10,0x10,0x10,0x0f,0x16,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xad, - 0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1a,0x11, - 0x10,0x10,0x10,0x08,0x05,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x14,0x10,0x10,0x10,0x10,0x10,0x10,0x18, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x24,0x24,0x24,0x60,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x12,0x10,0x10,0x10,0x0a,0x03,0x0d,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x1c,0x12,0x10,0x10,0x10,0x10,0x10,0x10,0x1a,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0xad,0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0xda,0x2b,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xad, - 0x24,0xad,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x13,0x10,0x10, - 0x10,0x0c,0x05,0x0a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x18,0x10,0x10,0x10,0x10,0x10,0x10, - 0x11,0x1a,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xda,0x2b,0xda,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x60,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x1c,0x13,0x10,0x10,0x10,0x0d,0x06,0x07,0x16,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0x16,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x19,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1b,0x13,0x10,0x10,0x10,0x0d, - 0x07,0x06,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x14,0x0f,0x10,0x10,0x10, - 0x10,0x10,0x11,0x17,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x2b,0x2b,0xda,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x1a,0x12,0x10,0x10,0x10,0x0e,0x07,0x05,0x10,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0x13,0x0f,0x10,0x10,0x10,0x10,0x10,0x11,0x15,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x2b,0x3f,0x3f,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x11,0x10,0x10,0x10,0x0d,0x07,0x05, - 0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x13,0x0e,0x10, - 0x10,0x10,0x10,0x10,0x10,0x13,0x1a,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x2b,0x1d,0x3f,0x2b,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x15, - 0x10,0x10,0x10,0x10,0x0d,0x07,0x05,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0x13,0x0e,0x10,0x10,0x10,0x10,0x10,0x10,0x12,0x16, - 0x1e,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0xda,0x2b,0x2b,0xda,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x18,0x12,0x10,0x10,0x10,0x10,0x0c,0x06,0x06,0x10,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x14, - 0x0e,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x14,0x18,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1a,0x14,0x10,0x10,0x10, - 0x10,0x10,0x0a,0x05,0x07,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x16,0x0e,0x0d,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x15,0x18,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x1a,0x14,0x10,0x10,0x10,0x10,0x10,0x0d,0x08,0x03,0x0a,0x16,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0x10,0x0d,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x13,0x17,0x1c,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1d,0x18,0x13,0x10,0x10,0x10,0x10,0x10,0x10,0x0b, - 0x06,0x05,0x0d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x13,0x0d,0x0c,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x14,0x18,0x1b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f, - 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1c,0x18,0x14,0x11,0x10, - 0x10,0x10,0x10,0x10,0x10,0x0c,0x07,0x03,0x09,0x13,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x10,0x0c,0x0d,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x11,0x14,0x17,0x19,0x1b,0x1d,0x1e,0x3f,0x3f,0x3f,0x1e,0x1d,0x1b,0x19, - 0x17,0x14,0x11,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x0d,0x08,0x04,0x06,0x0f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x17,0x0e, - 0x0b,0x0c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x0c,0x08,0x04,0x06,0x0d,0x17,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x17,0x0e,0x0a,0x0a,0x0d,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x0d,0x0a,0x06,0x03,0x07,0x0e,0x17,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0x11,0x0b,0x09,0x09,0x0c,0x0e,0x10,0x10,0x10,0x10,0x10,0x10,0x10, - 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x0e,0x0c,0x09,0x06,0x04,0x05, - 0x0a,0x11,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x18,0x11,0x0b, - 0x08,0x07,0x08,0x0a,0x0b,0x0d,0x0e,0x0f,0x0f,0x10,0x0f,0x0f,0x0e,0x0d,0x0b,0x0a, - 0x08,0x06,0x04,0x04,0x07,0x0b,0x11,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x17,0x12,0x0d,0x0a,0x08,0x06,0x05, - 0x03,0x03,0x03,0x03,0x03,0x05,0x06,0x08,0x0a,0x0d,0x12,0x17,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f,0x3f -}; +#include -const int32 kCenterWidth = 7; -const int32 kCenterHeight = 7; -const color_space kCenterColorSpace = B_CMAP8; -const unsigned char kCenterBits [] = { - 0x3f,0x3f,0x0a,0x0a,0x0a,0x3f,0x3f,0x3f, - 0x3f,0x0a,0x15,0x15,0x15,0x0a,0x3f,0x0a, - 0x0a,0x15,0x0a,0x0a,0x0a,0x15,0x0a,0x0a, - 0x0a,0x15,0x0a,0x00,0x0a,0x15,0x0a,0x0a, - 0x0a,0x15,0x0a,0x0a,0x0a,0x15,0x0a,0x0a, - 0x3f,0x0a,0x15,0x15,0x15,0x0a,0x3f,0x3f, - 0x3f,0x3f,0x0a,0x0a,0x0a,0x3f,0x3f}; +void ReplaceTransparentColor(BBitmap *bitmap, rgb_color with); -const int32 kCapWidth = 5; -const int32 kCapHeight = 5; -const color_space kCapColorSpace = B_CMAP8; - -const unsigned char kCapBits [] = { - 0x0a, 0x15, 0x15, 0x15, 0x0a, 0x00, 0x00, 0x00, - 0x15, 0x0a, 0x0a, 0x0a, 0x15, 0x00, 0x00, 0x00, - 0x15, 0x0a, 0x00, 0x0a, 0x15, 0x00, 0x00, 0x00, - 0x15, 0x0a, 0x0a, 0x0a, 0x15, 0x00, 0x00, 0x00, - 0x0a, 0x15, 0x15, 0x15, 0x0a, 0x00, 0x00, 0x00 -}; - const int32 kUpArrowWidth = 16; const int32 kUpArrowHeight = 7; const color_space kUpArrowColorSpace = B_CMAP8; @@ -533,3 +42,5 @@ 0xff,0xff,0xff,0xff,0xff,0x13,0xff,0xff,0xff,0xff,0xff,0xff,0x18,0x3f,0xff,0xff }; +#endif // ANALOG_CLOCK_H + Modified: haiku/trunk/src/preferences/time/CalendarView.cpp =================================================================== --- haiku/trunk/src/preferences/time/CalendarView.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/CalendarView.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,12 +1,11 @@ /* - * Copyright 2004-2005, Haiku. + * Copyright 2004-2007, Haiku. * Distributed under the terms of the MIT License. * * Authors: * Michael Berg */ - #include #include @@ -455,12 +454,14 @@ TCalendarView::DispatchMessage() { // send message to update timedate - BMessage *msg = new BMessage(H_USER_CHANGE); - msg->AddBool("time", false); - msg->AddInt32("month", f_month); + BMessage msg(H_USER_CHANGE); + msg.AddBool("time", false); + msg.AddInt32("month", f_month); + msg.AddInt32("year", f_year); + if (f_cday != NULL) - msg->AddInt32("day", f_cday->Day()); - msg->AddInt32("year", f_year); + msg.AddInt32("day", f_cday->Day()); - Window()->PostMessage(msg); + Window()->PostMessage(&msg); } + Modified: haiku/trunk/src/preferences/time/SectionEdit.cpp =================================================================== --- haiku/trunk/src/preferences/time/SectionEdit.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/SectionEdit.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -299,5 +299,3 @@ { } - -//---// Modified: haiku/trunk/src/preferences/time/SettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -13,6 +13,7 @@ #include "DateTimeEdit.h" #include "TimeMessages.h" + #include #include #include @@ -25,7 +26,7 @@ TSettingsView::TSettingsView(BRect frame) : BView(frame,"Settings", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), - fGmtTime(NULL) + fGmtTime(NULL) { InitView(); } @@ -109,17 +110,6 @@ fCalendar = new TCalendarView(frameLeft, "calendar", B_FOLLOW_NONE, B_WILL_DRAW); AddChild(fCalendar); - frameLeft.top = fCalendar->Frame().bottom + 10; - BStringView *text = new BStringView(frameLeft, "timezone", "Timezone:"); - AddChild(text); - text->ResizeToPreferred(); - - frameLeft.left += 20.0f; - frameLeft.top = text->Frame().bottom + 5; - - fTimeZone = new BStringView(frameLeft, "label", " "); - AddChild(fTimeZone); - // right side BRect frameRight(Bounds()); frameRight.left = frameRight.Width() / 2; @@ -144,14 +134,15 @@ // clock radio buttons frameRight.left = left; frameRight.top = fClock->Frame().bottom + 10; - text = new BStringView(frameRight, "clockis", "Clock set to:"); + BStringView *text = new BStringView(frameRight, "clockis", "Clock set to:"); AddChild(text); text->ResizeToPreferred(); - frameRight.left += 20.0f; + frameRight.left += 10.0f; frameRight.top = text->Frame().bottom + 5; - fLocalTime = new BRadioButton(frameRight, "local", "Local time", new BMessage(H_RTC_CHANGE)); + fLocalTime = new BRadioButton(frameRight, "local", "Local time", + new BMessage(H_RTC_CHANGE)); AddChild(fLocalTime); fLocalTime->ResizeToPreferred(); @@ -201,14 +192,6 @@ void -TSettingsView::SetTimeZone(const char *timezone) -{ - fTimeZone->SetText(timezone); - fTimeZone->ResizeToPreferred(); -} - - -void TSettingsView::UpdateDateTime(BMessage *message) { int32 day; @@ -239,9 +222,9 @@ TSettingsView::ReadRTCSettings() { BPath path; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) { - return; // NO USER SETTINGS DIRECTORY!!! - } + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + return; + path.Append("RTC_time_settings"); BFile file; @@ -249,9 +232,9 @@ if (entry.Exists()) { file.SetTo(&entry, B_READ_ONLY); if (file.InitCheck() == B_OK) { - char buff[6]; - file.Read(buff, 6); - BString text(buff); + char localTime[6]; + file.Read(localTime, 6); + BString text(localTime); if (text.Compare("local\n", 5) == 0) fIsLocalTime = true; else Modified: haiku/trunk/src/preferences/time/SettingsView.h =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.h 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/SettingsView.h 2007-09-12 06:08:42 UTC (rev 22222) @@ -18,8 +18,8 @@ class TCalendarView; class TAnalogClock; class BRadioButton; -class BStringView; + class TSettingsView : public BView { public: TSettingsView(BRect frame); @@ -32,7 +32,6 @@ void ChangeRTCSetting(); bool GMTime(); - void SetTimeZone(const char *timezone); private: void InitView(); @@ -46,8 +45,7 @@ TCalendarView *fCalendar; TAnalogClock *fClock; bool fIsLocalTime; - BStringView *fTimeZone; }; -#endif +#endif // SETTINGS_VIEW_H Modified: haiku/trunk/src/preferences/time/Time.cpp =================================================================== --- haiku/trunk/src/preferences/time/Time.cpp 2007-09-11 22:09:13 UTC (rev 22221) +++ haiku/trunk/src/preferences/time/Time.cpp 2007-09-12 06:08:42 UTC (rev 22222) @@ -1,31 +1,34 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2007, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * Andrew McCall, mccall at digitalparadise.co.uk - * Mike Berg + * Mike Berg (inseculous) + * Julun */ - #include "Time.h" -#include "TimeSettings.h" #include "TimeMessages.h" +#include "TimeSettings.h" [... truncated: 1212 lines follow ...] From stippi at mail.berlios.de Wed Sep 12 10:18:10 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 12 Sep 2007 10:18:10 +0200 Subject: [Haiku-commits] r22223 - in haiku/trunk/src/servers/app/drawing: . Painter Message-ID: <200709120818.l8C8IA6g007219@sheep.berlios.de> Author: stippi Date: 2007-09-12 10:18:09 +0200 (Wed, 12 Sep 2007) New Revision: 22223 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22223&view=rev Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp haiku/trunk/src/servers/app/drawing/Painter/Painter.h Log: * fractional rects need to be aligned if not drawing in subpixel precise mode, by now, I feel there is too much code involved in this... I guess I should really move this to stuff to ViewLayer::ConvertToScreenForDrawing()... Modified: haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-09-12 06:08:42 UTC (rev 22222) +++ haiku/trunk/src/servers/app/drawing/DrawingEngine.cpp 2007-09-12 08:18:09 UTC (rev 22223) @@ -792,7 +792,7 @@ CRASH_IF_NOT_LOCKED make_rect_valid(r); - r = fPainter->ClipRect(r); + r = fPainter->AlignAndClipRect(r); if (r.IsValid()) { bool cursorTouched = fGraphicsCard->HideSoftwareCursor(r); Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-09-12 06:08:42 UTC (rev 22222) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.cpp 2007-09-12 08:18:09 UTC (rev 22223) @@ -561,9 +561,8 @@ { CHECK_CLIPPING - // support invalid rects - BPoint a(min_c(r.left, r.right), min_c(r.top, r.bottom)); - BPoint b(max_c(r.left, r.right), max_c(r.top, r.bottom)); + BPoint a(r.left, r.top); + BPoint b(r.right, r.bottom); _Transform(&a, false); _Transform(&b, false); Modified: haiku/trunk/src/servers/app/drawing/Painter/Painter.h =================================================================== --- haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-09-12 06:08:42 UTC (rev 22222) +++ haiku/trunk/src/servers/app/drawing/Painter/Painter.h 2007-09-12 08:18:09 UTC (rev 22223) @@ -192,7 +192,9 @@ BRect InvertRect( const BRect& r) const; inline BRect ClipRect( BRect rect) const; + inline BRect AlignAndClipRect(BRect rect) const; + private: void _Transform(BPoint* point, bool centerOffset = true) const; @@ -290,7 +292,22 @@ return _Clipped(rect); } +inline BRect +Painter::AlignAndClipRect(BRect rect) const +{ + rect.left = floorf(rect.left); + rect.top = floorf(rect.top); + if (fSubpixelPrecise) { + rect.right = ceilf(rect.right); + rect.bottom = ceilf(rect.bottom); + } else { + rect.right = floorf(rect.right); + rect.bottom = floorf(rect.bottom); + } + return _Clipped(rect); +} + #endif // PAINTER_H From superstippi at gmx.de Wed Sep 12 10:18:21 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Wed, 12 Sep 2007 10:18:21 +0200 Subject: [Haiku-commits] r22212 - haiku/trunk/src/apps/sudoku In-Reply-To: <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> References: <200709092006.l89K68SB030174@sheep.berlios.de> <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> Message-ID: <20070912101821.4951.1@stippis.WG> Michael Pfeiffer wrote (2007-09-10, 14:08:40 [+0200]): > > Center SudokuView and keep it square. Avoid flickering when resizing. > > R5 build fixes. > > My checkin broke drawing under Haiku, the field background rectangles > overwrite portions of the lines. > Under BeOS this does not happen (Sorry had no time yesterday to test it > under Haiku). My first guess is, that Haiku rounds coordinates not in the > same way than BeOS, when filling a rectangle or there is an off by one > bug. Rounding was different. Fixed. Best regards, -Stephan From michael.pfeiffer at utanet.at Wed Sep 12 10:51:54 2007 From: michael.pfeiffer at utanet.at (Michael Pfeiffer) Date: Wed, 12 Sep 2007 10:51:54 +0200 Subject: [Haiku-commits] r22212 - haiku/trunk/src/apps/sudoku In-Reply-To: <20070912101821.4951.1@stippis.WG> References: <200709092006.l89K68SB030174@sheep.berlios.de> <41D4CA2F-9CC1-49B8-B4C4-AEE22EACFEE5@utanet.at> <20070912101821.4951.1@stippis.WG> Message-ID: Am 12.09.2007 um 10:18 schrieb Stephan Assmus: > > Michael Pfeiffer wrote (2007-09-10, 14:08:40 [+0200]): >>> Center SudokuView and keep it square. Avoid flickering when >>> resizing. >>> R5 build fixes. >> >> My checkin broke drawing under Haiku, the field background rectangles >> overwrite portions of the lines. >> Under BeOS this does not happen (Sorry had no time yesterday to >> test it >> under Haiku). My first guess is, that Haiku rounds coordinates not >> in the >> same way than BeOS, when filling a rectangle or there is an off by >> one >> bug. > > Rounding was different. Fixed. Thank you! - Michael From bonefish at mail.berlios.de Wed Sep 12 15:51:49 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 12 Sep 2007 15:51:49 +0200 Subject: [Haiku-commits] r22224 - haiku/trunk/src/kits/storage Message-ID: <200709121351.l8CDpnJZ017091@sheep.berlios.de> Author: bonefish Date: 2007-09-12 15:51:48 +0200 (Wed, 12 Sep 2007) New Revision: 22224 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22224&view=rev Modified: haiku/trunk/src/kits/storage/Node.cpp Log: R5's WriteAttrString() also writes the terminating null. So does ours now. Modified: haiku/trunk/src/kits/storage/Node.cpp =================================================================== --- haiku/trunk/src/kits/storage/Node.cpp 2007-09-12 08:18:09 UTC (rev 22223) +++ haiku/trunk/src/kits/storage/Node.cpp 2007-09-12 13:51:48 UTC (rev 22224) @@ -525,7 +525,7 @@ { status_t error = (!name || !data) ? B_BAD_VALUE : B_OK; if (error == B_OK) { - int32 len = data->Length(); + int32 len = data->Length() + 1; ssize_t sizeWritten = WriteAttr(name, B_STRING_TYPE, 0, data->String(), len); if (sizeWritten != len) From korli at users.berlios.de Wed Sep 12 15:57:21 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Wed, 12 Sep 2007 15:57:21 +0200 Subject: [Haiku-commits] r22224 - haiku/trunk/src/kits/storage In-Reply-To: <200709121351.l8CDpnJZ017091@sheep.berlios.de> References: <200709121351.l8CDpnJZ017091@sheep.berlios.de> Message-ID: 2007/9/12, bonefish at BerliOS : > > Modified: > haiku/trunk/src/kits/storage/Node.cpp > Log: > R5's WriteAttrString() also writes the terminating null. So does ours now. Does this need to be ported to src/build/libbe/storage/Node.cpp ? Bye, J?r?me -------------- next part -------------- An HTML attachment was scrubbed... URL: From bonefish at mail.berlios.de Wed Sep 12 16:13:43 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 12 Sep 2007 16:13:43 +0200 Subject: [Haiku-commits] r22225 - haiku/trunk/src/kits/tracker Message-ID: <200709121413.l8CEDhU7018420@sheep.berlios.de> Author: bonefish Date: 2007-09-12 16:13:42 +0200 (Wed, 12 Sep 2007) New Revision: 22225 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22225&view=rev Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp Log: Tracker never copied zero-sized attributes. Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp =================================================================== --- haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-09-12 13:51:48 UTC (rev 22224) +++ haiku/trunk/src/kits/tracker/FSUtils.cpp 2007-09-12 14:13:42 UTC (rev 22225) @@ -1146,6 +1146,11 @@ continue; } + // Special case for a size 0 attribute. It wouldn't be written at all + // otherwise. + if (info.size == 0) + destNode->WriteAttr(name, info.type, 0, buffer, 0); + ssize_t bytes; ssize_t numToRead = (ssize_t)info.size; for (off_t offset = 0; numToRead > 0; offset += bytes) { From bonefish at cs.tu-berlin.de Wed Sep 12 16:16:09 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Wed, 12 Sep 2007 16:16:09 +0200 Subject: [Haiku-commits] r22224 - haiku/trunk/src/kits/storage In-Reply-To: References: <200709121351.l8CDpnJZ017091@sheep.berlios.de> Message-ID: <20070912161609.11977.4@cs.tu-berlin.de> On 2007-09-12 at 15:57:21 [+0200], J?r?me Duval wrote: > 2007/9/12, bonefish at BerliOS : > > > > Modified: > > haiku/trunk/src/kits/storage/Node.cpp > > Log: > > R5's WriteAttrString() also writes the terminating null. So does ours now. > > > Does this need to be ported to src/build/libbe/storage/Node.cpp ? Good point. I don't really think it's used anywhere, but it wouldn't harm at least. CU, Ingo From bonefish at mail.berlios.de Wed Sep 12 16:18:02 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 12 Sep 2007 16:18:02 +0200 Subject: [Haiku-commits] r22226 - haiku/trunk/src/build/libbe/storage Message-ID: <200709121418.l8CEI2Cr018672@sheep.berlios.de> Author: bonefish Date: 2007-09-12 16:18:01 +0200 (Wed, 12 Sep 2007) New Revision: 22226 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22226&view=rev Modified: haiku/trunk/src/build/libbe/storage/Node.cpp Log: Copy change r22224: WriteAttrString() should write the terminating null. Modified: haiku/trunk/src/build/libbe/storage/Node.cpp =================================================================== --- haiku/trunk/src/build/libbe/storage/Node.cpp 2007-09-12 14:13:42 UTC (rev 22225) +++ haiku/trunk/src/build/libbe/storage/Node.cpp 2007-09-12 14:18:01 UTC (rev 22226) @@ -492,7 +492,7 @@ { status_t error = (!name || !data) ? B_BAD_VALUE : B_OK; if (error == B_OK) { - int32 len = data->Length(); + int32 len = data->Length() + 1; ssize_t sizeWritten = WriteAttr(name, B_STRING_TYPE, 0, data->String(), len); if (sizeWritten != len) From stippi at mail.berlios.de Thu Sep 13 13:49:39 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 13 Sep 2007 13:49:39 +0200 Subject: [Haiku-commits] r22227 - haiku/trunk/src/apps/icon-o-matic/gui Message-ID: <200709131149.l8DBndLB004014@sheep.berlios.de> Author: stippi Date: 2007-09-13 13:49:38 +0200 (Thu, 13 Sep 2007) New Revision: 22227 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22227&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h Log: * take care of invalidating resized menufields on BeOS Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-12 14:18:01 UTC (rev 22226) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-13 11:49:38 UTC (rev 22227) @@ -48,13 +48,14 @@ #ifdef __HAIKU__ : BView("style view", 0), #else - : BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, 0), + : BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS), #endif fCommandStack(NULL), fCurrentColor(NULL), fStyle(NULL), fGradient(NULL), - fIgnoreCurrentColorNotifications(false) + fIgnoreCurrentColorNotifications(false), + fPreviousBounds(frame.OffsetToCopy(B_ORIGIN)) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -184,6 +185,25 @@ fGradientType->Menu()->SetTargetForItems(this); } +// FrameResized +void +StyleView::FrameResized(float width, float height) +{ + BRect bounds = Bounds(); + +#ifndef __HAIKU__ + // Grrr, babysit the menubars... + BRect dirty = bounds; + dirty.left = min_c(bounds.right, fPreviousBounds.right) - 25; + fStyleType->ConvertFromParent(&dirty); + fStyleType->MenuBar()->ConvertFromParent(&dirty); + fStyleType->MenuBar()->Invalidate(dirty); + fGradientType->MenuBar()->Invalidate(dirty); +#endif // !__HAIKU__ + + fPreviousBounds = bounds; +} + // MessageReceived void StyleView::MessageReceived(BMessage* message) Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h 2007-09-12 14:18:01 UTC (rev 22226) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h 2007-09-13 11:49:38 UTC (rev 22227) @@ -42,6 +42,7 @@ // BView interface virtual void AttachedToWindow(); + virtual void FrameResized(float width, float height); virtual void MessageReceived(BMessage* message); #if __HAIKU__ @@ -77,6 +78,8 @@ GradientControl* fGradientControl; BMenuField* fStyleType; BMenuField* fGradientType; + + BRect fPreviousBounds; }; #endif // STYLE_VIEW_H From stippi at mail.berlios.de Thu Sep 13 17:02:29 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 13 Sep 2007 17:02:29 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface Message-ID: <200709131502.l8DF2TRY020836@sheep.berlios.de> Author: stippi Date: 2007-09-13 17:02:29 +0200 (Thu, 13 Sep 2007) New Revision: 22228 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22228&view=rev Modified: haiku/trunk/src/kits/interface/View.cpp Log: * added NOTE on why having mouse coords in screen space until the very last moment is so nice Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-09-13 11:49:38 UTC (rev 22227) +++ haiku/trunk/src/kits/interface/View.cpp 2007-09-13 15:02:29 UTC (rev 22228) @@ -1470,6 +1470,11 @@ ConvertFromScreen(location); // TODO: in beos R5, location is already converted to the view local coordinate system, // so if an app checks the window message queue by itself, it might not find what it expects. + // NOTE: the fact that we have mouse coords in screen space in our queue avoids the problem + // that messages already in the queue will be outdated as soon as a window or even the + // view moves. The second situation being quite common actually, also with regards to + // scrolling. An app reading these messages would have to know the locations of the window + // and view for each message... otherwise it is potentially broken anyways. } else *buttons = 0; } From stippi at mail.berlios.de Thu Sep 13 17:04:38 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 13 Sep 2007 17:04:38 +0200 Subject: [Haiku-commits] r22229 - haiku/trunk/src/kits/interface Message-ID: <200709131504.l8DF4cs8021045@sheep.berlios.de> Author: stippi Date: 2007-09-13 17:04:38 +0200 (Thu, 13 Sep 2007) New Revision: 22229 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22229&view=rev Modified: haiku/trunk/src/kits/interface/BMCPrivate.cpp Log: * make absolutely sure there is no cyclic resizing Modified: haiku/trunk/src/kits/interface/BMCPrivate.cpp =================================================================== --- haiku/trunk/src/kits/interface/BMCPrivate.cpp 2007-09-13 15:02:29 UTC (rev 22228) +++ haiku/trunk/src/kits/interface/BMCPrivate.cpp 2007-09-13 15:04:38 UTC (rev 22229) @@ -266,8 +266,8 @@ } } - if (!fFixedSize) { - // we have been shrinked or enlarged and need to take + if (!fFixedSize && ResizingMode() == (B_FOLLOW_LEFT | B_FOLLOW_TOP)) { + // we have been shrinked or enlarged and need to take care // of the size of the parent menu field as well // NOTE: no worries about follow mode, we follow left and top // in autosize mode From stippi at mail.berlios.de Thu Sep 13 17:08:48 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Thu, 13 Sep 2007 17:08:48 +0200 Subject: [Haiku-commits] r22230 - haiku/trunk/src/kits/interface Message-ID: <200709131508.l8DF8mmq021345@sheep.berlios.de> Author: stippi Date: 2007-09-13 17:08:48 +0200 (Thu, 13 Sep 2007) New Revision: 22230 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22230&view=rev Modified: haiku/trunk/src/kits/interface/MenuField.cpp Log: * make sure that the menu bar is still aligned with the right side if in fixed size mode in ResizeToPreferred, this fixes the menu bars going out of view bounds in a lot of apps using fixed size fields, like Screen Modified: haiku/trunk/src/kits/interface/MenuField.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuField.cpp 2007-09-13 15:04:38 UTC (rev 22229) +++ haiku/trunk/src/kits/interface/MenuField.cpp 2007-09-13 15:08:48 UTC (rev 22230) @@ -586,6 +586,17 @@ fMenuBar->ResizeToPreferred(); BView::ResizeToPreferred(); + + if (fFixedSizeMB) { + // we have let the menubar resize itsself, but + // in fixed size mode, the menubar is supposed to + // be at the right end of the view always. Since + // the menu bar is in follow left/right mode then, + // resizing ourselfs might have caused the menubar + // to be outside now + fMenuBar->ResizeTo(Bounds().Width() - fDivider - 2, + fMenuBar->Frame().Height()); + } } From revol at free.fr Thu Sep 13 17:45:27 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 13 Sep 2007 17:45:27 +0200 CEST Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <200709131502.l8DF2TRY020836@sheep.berlios.de> Message-ID: <3255104931-BeMail@laptop> > * added NOTE on why having mouse coords in screen space until the > very last > moment is so nice Can't we put the screen-based coords along with the view-based ones, with a separate name ? So apps really wanting to find coords would find something more likely to work even if not up to date, but we'd have the screen coords to use at that point. Fran?ois. From superstippi at gmx.de Thu Sep 13 20:25:06 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Thu, 13 Sep 2007 20:25:06 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <3255104931-BeMail@laptop> References: <3255104931-BeMail@laptop> Message-ID: <20070913202506.389.1@stippis.WG> Fran?ois Revol wrote (2007-09-13, 17:45:27 [+0200]): > > * added NOTE on why having mouse coords in screen space until the > > very last > > moment is so nice > > Can't we put the screen-based coords along with the view-based ones, with > a separate name ? We could. > So apps really wanting to find coords would find something more likely to > work even if not up to date, but we'd have the screen coords to use at > that point. On the other hand, which apps are out there that do this? I mean, wouldn't every app use BView::GetMouse() anyways? I am currently not aware of any app which is broken because of this. Instead of doing the extra work and overhead to send mouse coords in view space, we could also simply wait for a bug report "App X is broken because mouse coords are in screen space in the BWindow message queue". Best regards, -Stephan From marcusoverhagen at arcor.de Thu Sep 13 20:38:11 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 13 Sep 2007 20:38:11 +0200 (CEST) Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <20070913202506.389.1@stippis.WG> References: <20070913202506.389.1@stippis.WG> <3255104931-BeMail@laptop> Message-ID: <8337964.1189708691659.JavaMail.ngmail@webmail10> Hi Stephan, with Media Player it is possible to move the windows by clicking somewhere into the video view and moving the mouse. This doesn't use GetMouse. This works well on R5 and Zeta, but very erratic in Haiku. Please have a look at the implementation and comments in MainWin::_MouseMoved(BMessage *msg, BView* originalHandler) at http://svn.berlios.de/viewcvs/haiku/haiku/trunk/src/apps/mediaplayer/MainWin.cpp?rev=21335&view=markup regards Marcus ----- Original Nachricht ---- Von: Stephan Assmus An: SVN commits to the Haiku source repository Datum: 13.09.2007 20:25 Betreff: Re: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface > > Fran?ois Revol wrote (2007-09-13, 17:45:27 [+0200]): > > > * added NOTE on why having mouse coords in screen space until the > > > very last > > > moment is so nice > > > > Can't we put the screen-based coords along with the view-based ones, with > > > a separate name ? > > We could. > > > So apps really wanting to find coords would find something more likely to > > > work even if not up to date, but we'd have the screen coords to use at > > that point. > > On the other hand, which apps are out there that do this? I mean, wouldn't > every app use BView::GetMouse() anyways? I am currently not aware of any > app which is broken because of this. Instead of doing the extra work and > overhead to send mouse coords in view space, we could also simply wait for > a bug report "App X is broken because mouse coords are in screen space in > the BWindow message queue". > > Best regards, > -Stephan > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits > Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket f?r clevere Doppel-Sparer, nur 34,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From jackburton at mail.berlios.de Thu Sep 13 23:39:03 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 13 Sep 2007 23:39:03 +0200 Subject: [Haiku-commits] r22231 - haiku/trunk/src/apps/terminal Message-ID: <200709132139.l8DLd3uN029264@sheep.berlios.de> Author: jackburton Date: 2007-09-13 23:39:02 +0200 (Thu, 13 Sep 2007) New Revision: 22231 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22231&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Simplified a bit some code Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-09-13 15:08:48 UTC (rev 22230) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-09-13 21:39:02 UTC (rev 22231) @@ -135,6 +135,7 @@ : BView(frame, "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -184,6 +185,7 @@ : BView(BRect(0, 0, 0, 0), "termview", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE| B_PULSE_NEEDED), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -234,6 +236,7 @@ : BView(archive), fShell(NULL), + fWinchRunner(NULL), fFontWidth(0), fFontHeight(0), fFontAscent(0), @@ -1166,42 +1169,7 @@ float scr_start, scr_end, scr_pos; while(!fQuitting) { - if (1) { - #ifdef CHANGE_CURSOR_IMAGE - if (!has_data(find_thread(NULL))) { - BRect r; - - if (_HasSelection() - && (modifiers() & B_CONTROL_KEY)) { - - if (LockLooper()) { - GetMouse(&stpoint, &button); - r = Bounds(); - UnlockLooper(); - } - if (r.Contains(stpoint)) { - CurPos tmppos = _BPointToCurPos(stpoint); - if (fSelStart > fSelEnd) { - stpos = fSelEnd; - edpos = fSelStart; - } else { - stpos = fSelStart; - edpos = fSelEnd; - } - - if (tmppos > stpos && tmppos < edpos) - SetViewCursor(M_ADD_CURSOR); - else - SetViewCursor(B_HAND_CURSOR); - } - } - snooze(50 * 1000); - continue; - } else { -#endif - code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint)); - } - + code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint)); if (code != MOUSE_THR_CODE) continue; @@ -1211,9 +1179,8 @@ stpos = _BPointToCurPos(stpoint); do { + snooze(40000); - snooze(40 * 1000); - if (LockLooper()) { GetMouse(&edpoint, &button); UnlockLooper(); @@ -2019,19 +1986,8 @@ Window()->CurrentMessage()->FindInt32("clicks", &clicks); if (_HasSelection()) { - CurPos inPos, stPos, edPos; - if (fSelStart < fSelEnd) { - stPos = fSelStart; - edPos = fSelEnd; - } else { - stPos = fSelEnd; - edPos = fSelStart; - } - - inPos = _BPointToCurPos(where); - - // If mouse pointer is avove selected Region, start Drag'n Copy. - if (inPos > stPos && inPos < edPos) { + CurPos inPos = _BPointToCurPos(where); + if (_CheckSelectedRegion(inPos)) { if (mod & B_CONTROL_KEY) { BPoint p; uint32 bt; @@ -2043,34 +1999,12 @@ return; } - snooze(40 * 1000); + snooze(40000); } while (abs((int)(where.x - p.x)) < 4 && abs((int)(where.y - p.y)) < 4); - BString copyStr(""); - fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd); - - BMessage msg(B_MIME_TYPE); - msg.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length()); - - BPoint st = _CurPosToBPoint(stPos); - BPoint ed = _CurPosToBPoint(edPos); - BRect r; - - if (stPos.y == edPos.y) { - r.Set(st.x, st.y - fTop, - ed.x + fFontWidth, ed.y + fFontHeight - fTop); - - } else { - - r.Set(0, st.y - fTop, - fTermColumns * fFontWidth, ed.y + fFontHeight - fTop); - } - - r = r & Bounds(); - - DragMessage(&msg, r); + InitiateDrag(); return; } } @@ -2114,6 +2048,7 @@ BView::MouseDown(where); } + void TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) { @@ -2537,6 +2472,35 @@ } +void +TermView::InitiateDrag() +{ + BString copyStr(""); + fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd); + + BMessage message(B_MIME_TYPE); + message.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length()); + + BPoint start = _CurPosToBPoint(fSelStart); + BPoint end = _CurPosToBPoint(fSelEnd); + + BRect rect; + if (fSelStart.y == fSelEnd.y) { + rect.Set(start.x, start.y - fTop, end.x + fFontWidth, + end.y + fFontHeight - fTop); + + } else { + + rect.Set(0, start.y - fTop, fTermColumns * fFontWidth, + end.y + fFontHeight - fTop); + } + + rect = rect & Bounds(); + + DragMessage(&message, rect); +} + + inline void TermView::_Redraw(int x1, int y1, int x2, int y2) { Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-09-13 15:08:48 UTC (rev 22230) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-09-13 21:39:02 UTC (rev 22231) @@ -42,8 +42,8 @@ void SetTermFont(const BFont *halfFont, const BFont *fullFont); void GetFontSize(int *width, int *height); + BRect SetTermSize(int rows, int cols, bool resize); - BRect SetTermSize(int rows, int cols, bool resize); void SetTextColor(rgb_color fore, rgb_color back); void SetSelectColor(rgb_color fore, rgb_color back); void SetCursorColor(rgb_color fore, rgb_color back); @@ -117,6 +117,8 @@ void CheckShellGone(); + void InitiateDrag(); + protected: virtual void AttachedToWindow(); virtual void DetachedFromWindow(); @@ -139,7 +141,7 @@ private: status_t _InitObject(int32 argc, const char **argv); - status_t _InitMouseThread(void); + status_t _InitMouseThread(); status_t _AttachShell(Shell *shell); void _DetachShell(); @@ -164,9 +166,9 @@ // void _DoIMChange (BMessage* message); // void _DoIMLocation (BMessage* message); // void _DoIMConfirm (void); - void _ConfirmString (const char *, int32); - int32 _GetCharFromUTF8String (const char *, char *); - int32 _GetWidthFromUTF8String (const char *); + void _ConfirmString(const char *, int32); + int32 _GetCharFromUTF8String(const char *, char *); + int32 _GetWidthFromUTF8String(const char *); // Mouse select void _Select(CurPos start, CurPos end); @@ -186,7 +188,6 @@ bool _CheckSelectedRegion(const CurPos &pos); - void _UpdateSIGWINCH(); static void _FixFontAttributes(BFont &font); From revol at free.fr Fri Sep 14 10:35:41 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 14 Sep 2007 10:35:41 +0200 CEST Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <20070913202506.389.1@stippis.WG> Message-ID: <304860049-BeMail@laptop> > > Fran?ois Revol wrote (2007-09-13, 17:45:27 [+0200]): > > > * added NOTE on why having mouse coords in screen space until the > > > very last > > > moment is so nice > > > > Can't we put the screen-based coords along with the view-based > > ones, with > > a separate name ? > > We could. > > > So apps really wanting to find coords would find something more > > likely to > > work even if not up to date, but we'd have the screen coords to use > > at > > that point. > > On the other hand, which apps are out there that do this? I mean, > wouldn't > every app use BView::GetMouse() anyways? I am currently not aware of > any > app which is broken because of this. Instead of doing the extra work > and > overhead to send mouse coords in view space, we could also simply > wait for > a bug report "App X is broken because mouse coords are in screen > space in > the BWindow message queue". Right. Some apps that want to get full control (VNCViewer for ex, maybe SDL) usually override DispatchMessage(), and do tricky stuff, but I don't know if they touch the mouse. Fran?ois. From superstippi at gmx.de Fri Sep 14 10:46:03 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 14 Sep 2007 10:46:03 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <304860049-BeMail@laptop> References: <304860049-BeMail@laptop> Message-ID: <20070914104603.3804.4@stippis.WG> Fran?ois Revol wrote (2007-09-14, 10:35:41 [+0200]): > > > > Fran?ois Revol wrote (2007-09-13, 17:45:27 [+0200]): > > > > * added NOTE on why having mouse coords in screen space until the > > > > very last > > > > moment is so nice > > > > > > Can't we put the screen-based coords along with the view-based ones, > > > with > > > a separate name ? > > > > We could. > > > > > So apps really wanting to find coords would find something more > > > likely to > > > work even if not up to date, but we'd have the screen coords to use > > > at > > > that point. > > > > On the other hand, which apps are out there that do this? I mean, > > wouldn't > > every app use BView::GetMouse() anyways? I am currently not aware of > > any > > app which is broken because of this. Instead of doing the extra work > > and > > overhead to send mouse coords in view space, we could also simply wait > > for > > a bug report "App X is broken because mouse coords are in screen space > > in > > the BWindow message queue". > > Right. > Some apps that want to get full control (VNCViewer for ex, maybe SDL) > usually override DispatchMessage(), and do tricky stuff, but I don't know > if they touch the mouse. I too remember weird behaviour of MediaPlayer being dragged by clicking somewhere inside between the controls. So I tried this yesterday again, both in the test environment and under Haiku on real hardware. To my surprise, it worked perfectly. Maybe Axel's recent changes have fixed this. I have not yet looked closer into which code path is truely used in MediaPlayer. The funny thing is, the code first tries to find a coordinate "screen_where" in the message, which appearantly ZETA provides. The comment there says "screen_where is the only reliable coordinate under ZETA". When the code does not find "screen_where", it goes on to try and find the "normal" mouse coord field and translates that to screen space using the original handler for the mouse message. I presume that this is the code path which works under Haiku. So because this works like a charm, I assume that the "sanitizing" of messages (ie filtering them before the application sees them) so that they are compatible with R5 messages, works, even if an application overrides DispatchMessage(). I think the only time an application would see the orignal messages is when it directly uses the message queue. Best regards, -Stephan From stippi at mail.berlios.de Fri Sep 14 11:04:04 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 14 Sep 2007 11:04:04 +0200 Subject: [Haiku-commits] r22232 - haiku/trunk/src/preferences/time Message-ID: <200709140904.l8E944gX025173@sheep.berlios.de> Author: stippi Date: 2007-09-14 11:04:03 +0200 (Fri, 14 Sep 2007) New Revision: 22232 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22232&view=rev Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp haiku/trunk/src/preferences/time/AnalogClock.h haiku/trunk/src/preferences/time/Bitmaps.cpp haiku/trunk/src/preferences/time/Bitmaps.h haiku/trunk/src/preferences/time/CalendarView.cpp haiku/trunk/src/preferences/time/CalendarView.h haiku/trunk/src/preferences/time/DateTimeEdit.cpp haiku/trunk/src/preferences/time/DateTimeEdit.h haiku/trunk/src/preferences/time/DateUtils.cpp haiku/trunk/src/preferences/time/DateUtils.h haiku/trunk/src/preferences/time/SectionEdit.cpp haiku/trunk/src/preferences/time/SectionEdit.h haiku/trunk/src/preferences/time/SettingsView.cpp haiku/trunk/src/preferences/time/SettingsView.h haiku/trunk/src/preferences/time/TZDisplay.cpp haiku/trunk/src/preferences/time/TZDisplay.h haiku/trunk/src/preferences/time/Time.cpp haiku/trunk/src/preferences/time/Time.h haiku/trunk/src/preferences/time/TimeMessages.h haiku/trunk/src/preferences/time/TimeSettings.cpp haiku/trunk/src/preferences/time/TimeSettings.h haiku/trunk/src/preferences/time/TimeWindow.cpp haiku/trunk/src/preferences/time/TimeWindow.h haiku/trunk/src/preferences/time/ZoneView.cpp haiku/trunk/src/preferences/time/ZoneView.h Log: patch by Julun: * fixed more style issues * fixed small memory leaks * refactoring + some small changes by myself, added back Michael Berg and Andrew McCall as likely authors of most files which had no author information Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.cpp 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/AnalogClock.cpp 2007-09-14 09:04:03 UTC (rev 22232) @@ -21,9 +21,8 @@ OffscreenClock(BRect frame, const char *name); ~OffscreenClock(); - void SetTo(int32 hour, int32 minute, int32 second); - bool IsDirty() const - { return fDirty; } + void SetTime(int32 hour, int32 minute, int32 second); + bool IsDirty() const { return fDirty; } void DrawClock(); private: @@ -54,7 +53,7 @@ void -OffscreenClock::SetTo(int32 hour, int32 minute, int32 second) +OffscreenClock::SetTime(int32 hour, int32 minute, int32 second) { if (fHours == hour && fMinutes == minute && fSeconds == second) return; @@ -233,7 +232,7 @@ if (message->FindInt32("hour", &hour) == B_OK && message->FindInt32("minute", &minute) == B_OK && message->FindInt32("second", &second) == B_OK) - SetTo(hour, minute, second); + SetTime(hour, minute, second); break; } default: @@ -260,10 +259,10 @@ void -TAnalogClock::SetTo(int32 hour, int32 minute, int32 second) +TAnalogClock::SetTime(int32 hour, int32 minute, int32 second) { if (fClock) - fClock->SetTo(hour, minute, second); + fClock->SetTime(hour, minute, second); Invalidate(); } Modified: haiku/trunk/src/preferences/time/AnalogClock.h =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.h 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/AnalogClock.h 2007-09-14 09:04:03 UTC (rev 22232) @@ -27,7 +27,7 @@ virtual void Draw(BRect updateRect); virtual void MessageReceived(BMessage *message); - void SetTo(int32 hour, int32 minute, int32 second); + void SetTime(int32 hour, int32 minute, int32 second); private: void _InitView(BRect frame); Modified: haiku/trunk/src/preferences/time/Bitmaps.cpp =================================================================== --- haiku/trunk/src/preferences/time/Bitmaps.cpp 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/Bitmaps.cpp 2007-09-14 09:04:03 UTC (rev 22232) @@ -3,6 +3,8 @@ * Distributed under the terms of the MIT License. * * Authors: + * probably Mike Berg + * and/or Andrew McCall * Julun */ Modified: haiku/trunk/src/preferences/time/Bitmaps.h =================================================================== --- haiku/trunk/src/preferences/time/Bitmaps.h 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/Bitmaps.h 2007-09-14 09:04:03 UTC (rev 22232) @@ -3,6 +3,8 @@ * Distributed under the terms of the MIT License. * * Authors: + * probably Mike Berg + * and/or Andrew McCall * Julun */ #ifndef ANALOG_CLOCK_H Modified: haiku/trunk/src/preferences/time/CalendarView.cpp =================================================================== --- haiku/trunk/src/preferences/time/CalendarView.cpp 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/CalendarView.cpp 2007-09-14 09:04:03 UTC (rev 22232) @@ -146,7 +146,7 @@ SetHighColor(bgcolor); FillRect(bounds); - if (f_day> 0) { + if (f_day > 0) { if (!(Value() == 1)) SetHighColor(0, 0, 0, 255); else @@ -207,7 +207,7 @@ f_day = day; SetValue(selected); if (Value() == 1) { - SetFlags(Flags()|B_NAVIGABLE); + SetFlags(Flags() | B_NAVIGABLE); } else { SetFlags(Flags() & ~B_NAVIGABLE); } @@ -224,7 +224,7 @@ , f_firstday(0) , f_month(0) , f_day(0) - ,f_year(0) + , f_year(0) { InitView(); } @@ -338,20 +338,19 @@ { BRect bounds(0.0, 0.0, f_dayrect.Width(), f_dayrect.Height()); - float width = 0; - float x = bounds.Width()/2.0; - BPoint drawpt; - BString day; SetLowColor(ViewColor()); SetHighColor(0, 0, 0); - float offset = FontHeight(this, true); + BPoint drawpt; + drawpt.y = (bounds.top + bounds.bottom + FontHeight(this, true)) / 2.0; + float width = 0; + float x = bounds.Width() / 2.0; + BString day; for (int i = 0; i < 7; i++) { day = BString(&kDays[i], 1); width = be_plain_font->StringWidth(day.String()); drawpt.x = bounds.left + (x - width / 2.0 + 2); - drawpt.y = bounds.bottom - offset / 2.0; DrawString(day.String(), drawpt); bounds.OffsetBy(bounds.Width() + 1, 0); } Modified: haiku/trunk/src/preferences/time/CalendarView.h =================================================================== --- haiku/trunk/src/preferences/time/CalendarView.h 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/CalendarView.h 2007-09-14 09:04:03 UTC (rev 22232) @@ -1,9 +1,20 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * probably Mike Berg + * and/or Andrew McCall + * Julun + */ #ifndef CALENDAR_VIEW_H #define CALENDAR_VIEW_H + #include #include + class TDay: public BControl { public: TDay(BRect frame, int day); Modified: haiku/trunk/src/preferences/time/DateTimeEdit.cpp =================================================================== --- haiku/trunk/src/preferences/time/DateTimeEdit.cpp 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/DateTimeEdit.cpp 2007-09-14 09:04:03 UTC (rev 22232) @@ -1,39 +1,40 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * probably Mike Berg + * and/or Andrew McCall + * Julun + * + */ + #include "DateTimeEdit.h" #include "DateUtils.h" + +#include #include -#include + #define YEAR_DELTA_MAX 110 #define YEAR_DELTA_MIN 64 -TDateTimeSection::TDateTimeSection(BRect frame, uint32 data) - : TSection(frame), - fData(data) -{ -} +class TDateTimeSection : public TSection { + public: + TDateTimeSection(BRect frame, uint32 data = 0) + : TSection(frame), fData(data) { } + ~TDateTimeSection(); + + uint32 Data() const { return fData; } + void SetData(uint32 data) { fData = data; } + private: + uint32 fData; +}; -TDateTimeSection::~TDateTimeSection() -{ -} - -uint32 -TDateTimeSection::Data() const -{ - return fData; -} - - -void -TDateTimeSection::SetData(uint32 data) -{ - fData = data; -} - - // #pragma mark - @@ -46,32 +47,25 @@ TTimeEdit::~TTimeEdit() { - TSection *section; - if (f_sections->CountItems() > 0) { - for (int32 idx = 0; (section = (TSection *)f_sections->ItemAt(idx)); idx++) - delete section; - } - delete f_sections; } void TTimeEdit::InitView() { + // make sure we call the base class method, as it + // will create the arrow bitmaps and the section list TSectionEdit::InitView(); - SetSections(f_sectionsarea); + SetSections(fSectionArea); } void TTimeEdit::DrawSection(uint32 index, bool hasFocus) { - if (f_sections->CountItems() == 0) - printf("No Sections!!!\n"); - // user defined section drawing TDateTimeSection *section; - section = (TDateTimeSection *)f_sections->ItemAt(index); + section = (TDateTimeSection *)fSectionList->ItemAt(index); BRect bounds = section->Frame(); @@ -81,7 +75,7 @@ if (hasFocus) { SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); - value = f_holdvalue; + value = fHoldValue; } else { SetLowColor(ViewColor()); value = section->Data(); @@ -112,7 +106,7 @@ break; case 3: // am/pm - value = ((TDateTimeSection *)f_sections->ItemAt(0))->Data(); + value = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data(); if (value >= 12) text << "PM"; else @@ -125,10 +119,9 @@ } // calc and center text in section rect - float width = be_plain_font->StringWidth(text.String()); - BPoint offset(-(bounds.Width()/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0); + BPoint offset(-(bounds.Width() / 2.0 -width / 2.0) -1.0, bounds.Height() / 2.0 -6.0); BPoint drawpt(bounds.LeftBottom() -offset); @@ -138,27 +131,31 @@ } +/* + DrawSeperator(uint32 index) user drawn seperator. Section is the + index of the section in fSectionList or the section to the seps left +*/ void TTimeEdit::DrawSeperator(uint32 index) { - /* user drawn seperator. section is the index of the section - in f_sections or the section to the seps left - */ + if (index == 3) + return; + + TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(index); - if (index >= 2) - return; // no seperator for am/pm - BString text(":"); - uint32 sep; - GetSeperatorWidth(&sep); - - TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(index); BRect bounds = section->Frame(); + float sepWidth = SeperatorWidth(); + + char* sep = ":"; + if (index == 2) + sep = "-"; + + float width = be_plain_font->StringWidth(sep); - float width = be_plain_font->StringWidth(text.String()); - BPoint offset(-(sep/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0); + BPoint offset(-(sepWidth / 2.0 - width / 2.0) -1.0, bounds.Height() / 2.0 -6.0); BPoint drawpt(bounds.RightBottom() -offset); - DrawString(text.String(), drawpt); + DrawString(sep, drawpt); } @@ -169,67 +166,63 @@ BRect bounds(area); // no comp for sep width - uint32 sep_width; - GetSeperatorWidth(&sep_width); + float sepWidth = SeperatorWidth(); - float sep_2 = ceil(sep_width/f_sectioncount +1); - float width = bounds.Width()/f_sectioncount -sep_2; - bounds.right = bounds.left +(width -sep_width/f_sectioncount); + float sep_2 = ceil(sepWidth / fSectionCount +1); + float width = bounds.Width() / fSectionCount -sep_2; + bounds.right = bounds.left + (width -sepWidth / fSectionCount); - TDateTimeSection *section; - - for (uint32 idx = 0; idx < f_sectioncount; idx++) { - section = new TDateTimeSection(bounds); - f_sections->AddItem(section); + for (uint32 idx = 0; idx < fSectionCount; idx++) { + fSectionList->AddItem(new TDateTimeSection(bounds)); - bounds.left = bounds.right +sep_width; - if (idx == f_sectioncount -2) + bounds.left = bounds.right + sepWidth; + if (idx == fSectionCount -2) bounds.right = area.right -1; else - bounds.right = bounds.left +(width -sep_2); + bounds.right = bounds.left + (width -sep_2); } } -void -TTimeEdit::GetSeperatorWidth(uint32 *width) +float +TTimeEdit::SeperatorWidth() const { - *width = 8; + return 8.0f; } void TTimeEdit::SectionFocus(uint32 index) { - f_focus = index; + fFocus = index; // update hold value - f_holdvalue = ((TDateTimeSection *)f_sections->ItemAt(f_focus))->Data(); + fHoldValue = ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->Data(); Draw(Bounds()); } void -TTimeEdit::SetTo(uint32 hour, uint32 minute, uint32 second) +TTimeEdit::SetTime(uint32 hour, uint32 minute, uint32 second) { - if (f_sections->CountItems()> 0) + if (fSectionList->CountItems()> 0) { bool update = false; - TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(0); + TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(0); if (section->Data() != hour) { section->SetData(hour); update = true; } - section = (TDateTimeSection *)f_sections->ItemAt(1); + section = (TDateTimeSection *)fSectionList->ItemAt(1); if (section->Data() != minute) { section->SetData(minute); update = true; } - section = (TDateTimeSection *)f_sections->ItemAt(2); + section = (TDateTimeSection *)fSectionList->ItemAt(2); if (section->Data() != second) { section->SetData(second); update = true; @@ -244,11 +237,11 @@ void TTimeEdit::DoUpPress() { - if (f_focus == -1) + if (fFocus == -1) SectionFocus(0); // update displayed value - f_holdvalue += 1; + fHoldValue += 1; CheckRange(); @@ -260,11 +253,11 @@ void TTimeEdit::DoDownPress() { - if (f_focus == -1) + if (fFocus == -1) SectionFocus(0); // update display value - f_holdvalue -= 1; + fHoldValue -= 1; CheckRange(); @@ -276,20 +269,18 @@ void TTimeEdit::BuildDispatch(BMessage *message) { - static const char *fields[4] = {"hour", "minute", "second", "isam"}; + const char *fields[4] = {"hour", "minute", "second", "isam"}; message->AddBool("time", true); - for (int32 idx = 0; idx < f_sections->CountItems() -1; idx++) { - uint32 data; + for (int32 idx = 0; idx < fSectionList->CountItems() -1; idx++) { + uint32 data = ((TDateTimeSection *)fSectionList->ItemAt(idx))->Data(); - if (f_focus == idx) - data = f_holdvalue; - else - data = ((TDateTimeSection *)f_sections->ItemAt(idx))->Data(); + if (fFocus == idx) + data = fHoldValue; if (idx == 3) // isam - message->AddBool("isam", data == 1); + message->AddBool(fields[idx], data == 1); else message->AddInt32(fields[idx], data); } @@ -299,12 +290,12 @@ void TTimeEdit::CheckRange() { - int32 value = f_holdvalue; - switch (f_focus) { + int32 value = fHoldValue; + switch (fFocus) { case 0: // hour if (value> 23) value = 0; - else if (value < 0) + else if (value < 0) value = 23; break; @@ -325,22 +316,22 @@ case 3: // modify hour value to reflect change in am/pm - value = ((TDateTimeSection *)f_sections->ItemAt(0))->Data(); + value = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data(); if (value < 13) value += 12; else value -= 12; if (value == 24) value = 0; - ((TDateTimeSection *)f_sections->ItemAt(0))->SetData(value); + ((TDateTimeSection *)fSectionList->ItemAt(0))->SetData(value); break; default: return; } - ((TDateTimeSection *)f_sections->ItemAt(f_focus))->SetData(value); - f_holdvalue = value; + ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->SetData(value); + fHoldValue = value; Invalidate(Bounds()); } @@ -348,12 +339,7 @@ // #pragma mark - -const char *months[] = { - "January", "Febuary", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" -}; - - + TDateEdit::TDateEdit(BRect frame, const char *name, uint32 sections) : TSectionEdit(frame, name, sections) { @@ -363,32 +349,25 @@ TDateEdit::~TDateEdit() { - TSection *section; - if (f_sections->CountItems() > 0) { - for (int32 idx = 0; (section = (TSection *)f_sections->ItemAt(idx)); idx++) - delete section; - } - delete f_sections; } void TDateEdit::InitView() { + // make sure we call the base class method, as it + // will create the arrow bitmaps and the section list TSectionEdit::InitView(); - SetSections(f_sectionsarea); + SetSections(fSectionArea); } void TDateEdit::DrawSection(uint32 index, bool hasFocus) { - if (f_sections->CountItems() == 0) - printf("No Sections!!!\n"); - // user defined section drawing TDateTimeSection *section; - section = (TDateTimeSection *)f_sections->ItemAt(index); + section = (TDateTimeSection *)fSectionList->ItemAt(index); BRect bounds = section->Frame(); @@ -398,147 +377,141 @@ if (hasFocus) { SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); - value = f_holdvalue; + value = fHoldValue; } else { SetLowColor(ViewColor()); value = section->Data(); } - char text[64]; - // format value (new method?) + BString text; switch (index) { - case 0: // month + case 0: + { // month struct tm tm; tm.tm_mon = value; - strftime(text, sizeof(text), "%B", &tm); - break; + char buffer[64]; + memset(buffer, 0, sizeof(buffer)); + strftime(buffer, sizeof(buffer), "%B", &tm); + text.SetTo(buffer); + } break; + case 1: // day - snprintf(text, sizeof(text), "%lu", value); + text << value; break; case 2: // year - snprintf(text, sizeof(text), "%lu", value + 1900); + text << (value + 1900); break; default: return; } + // calc and center text in section rect + float width = StringWidth(text.String()); + BPoint offset(-(bounds.Width() - width) / 2.0 - 1.0, (bounds.Height() / 2.0 - 6.0)); - float width = StringWidth(text); - - BPoint offset(-(bounds.Width() - width) /2.0 - 1.0, (bounds.Height() / 2.0 - 6.0)); - if (index == 0) offset.x = -(bounds.Width() - width) ; SetHighColor(0, 0, 0, 255); FillRect(bounds, B_SOLID_LOW); - DrawString(text, bounds.LeftBottom() - offset); + DrawString(text.String(), bounds.LeftBottom() - offset); } +/* + DrawSeperator(uint32 index) user drawn seperator. Section is the + index of the section in fSectionList or the section to the seps left +*/ void TDateEdit::DrawSeperator(uint32 index) { - /* user drawn seperator. section is the index of the section - in f_sections or the section to the seps left - */ - - if (index == 3) { - // no seperator for am/pm + if (index == 3) return; - } - BString text("/"); - uint32 sep; - GetSeperatorWidth(&sep); - - TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(index); + TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(index); BRect bounds = section->Frame(); - float width = be_plain_font->StringWidth(text.String()); - BPoint offset(-(sep/2.0 -width/2.0) -1.0, bounds.Height()/2.0 -6.0); - BPoint drawpt(bounds.RightBottom() -offset); + float sepWidth = SeperatorWidth(); + float width = be_plain_font->StringWidth("/"); - DrawString(text.String(), drawpt); + BPoint offset(-(sepWidth / 2.0 - width / 2.0) -1.0, bounds.Height() / 2.0 -6.0); + BPoint drawpt(bounds.RightBottom() - offset); + + DrawString("/", drawpt); } void TDateEdit::SetSections(BRect area) { - TDateTimeSection *section; // create sections - for (uint32 idx = 0; idx < f_sectioncount; idx++) { - section = new TDateTimeSection(area); - f_sections->AddItem(section); - } + for (uint32 idx = 0; idx < fSectionCount; idx++) + fSectionList->AddItem(new TDateTimeSection(area)); BRect bounds(area); - float width; // year - width = be_plain_font->StringWidth("0000") +6; + float width = be_plain_font->StringWidth("0000") +6; bounds.right = area.right; bounds.left = bounds.right -width; - ((TDateTimeSection *)f_sections->ItemAt(2))->SetBounds(bounds); + ((TDateTimeSection *)fSectionList->ItemAt(2))->SetFrame(bounds); - uint32 sep; - GetSeperatorWidth(&sep); + float sepWidth = SeperatorWidth(); // day width = be_plain_font->StringWidth("00") +6; - bounds.right = bounds.left -sep; + bounds.right = bounds.left -sepWidth; bounds.left = bounds.right -width; - ((TDateTimeSection *)f_sections->ItemAt(1))->SetBounds(bounds); + ((TDateTimeSection *)fSectionList->ItemAt(1))->SetFrame(bounds); // month - bounds.right = bounds.left -sep; + bounds.right = bounds.left - sepWidth; bounds.left = area.left; - ((TDateTimeSection *)f_sections->ItemAt(0))->SetBounds(bounds); + ((TDateTimeSection *)fSectionList->ItemAt(0))->SetFrame(bounds); } -void -TDateEdit::GetSeperatorWidth(uint32 *width) +float +TDateEdit::SeperatorWidth() const { - *width = 8; + return 8.0f; } void TDateEdit::SectionFocus(uint32 index) { - f_focus = index; + fFocus = index; // update hold value - f_holdvalue = ((TDateTimeSection *)f_sections->ItemAt(f_focus))->Data(); + fHoldValue = ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->Data(); Draw(Bounds()); } void -TDateEdit::SetTo(uint32 year, uint32 month, uint32 day) +TDateEdit::SetDate(uint32 year, uint32 month, uint32 day) { - if (f_sections->CountItems() > 0) { + if (fSectionList->CountItems() > 0) { bool update = false; - TDateTimeSection *section = (TDateTimeSection *)f_sections->ItemAt(0); + TDateTimeSection *section = (TDateTimeSection *)fSectionList->ItemAt(0); if (section->Data() != month) { section->SetData(month); update = true; } - section = (TDateTimeSection *)f_sections->ItemAt(1); + section = (TDateTimeSection *)fSectionList->ItemAt(1); if (section->Data() != day) { section->SetData(day); update = true; } - section = (TDateTimeSection *)f_sections->ItemAt(2); + section = (TDateTimeSection *)fSectionList->ItemAt(2); if (section->Data() != year) { section->SetData(year); update = true; @@ -553,11 +526,11 @@ void TDateEdit::DoUpPress() { - if (f_focus == -1) + if (fFocus == -1) SectionFocus(0); // update displayed value - f_holdvalue += 1; + fHoldValue += 1; CheckRange(); @@ -569,11 +542,11 @@ void TDateEdit::DoDownPress() { - if (f_focus == -1) + if (fFocus == -1) SectionFocus(0); // update display value - f_holdvalue -= 1; + fHoldValue -= 1; CheckRange(); @@ -585,17 +558,15 @@ void TDateEdit::BuildDispatch(BMessage *message) { - static const char *fields[3] = {"month", "day", "year"}; + const char *fields[3] = {"month", "day", "year"}; message->AddBool("time", false); - for (int32 idx = 0; idx < f_sections->CountItems(); idx++) { - uint32 data; + for (int32 idx = 0; idx < fSectionList->CountItems(); idx++) { + uint32 data = ((TDateTimeSection *)fSectionList->ItemAt(idx))->Data(); - if (f_focus == idx) - data = f_holdvalue; - else - data = ((TDateTimeSection *)f_sections->ItemAt(idx))->Data(); + if (fFocus == idx) + data = fHoldValue; message->AddInt32(fields[idx], data); } @@ -605,9 +576,9 @@ void TDateEdit::CheckRange() { - int32 value = f_holdvalue; + int32 value = fHoldValue; - switch (f_focus) { + switch (fFocus) { case 0: // month { if (value > 11) @@ -619,8 +590,8 @@ case 1: //day { - uint32 month = ((TDateTimeSection *)f_sections->ItemAt(0))->Data(); - uint32 year = ((TDateTimeSection *)f_sections->ItemAt(2))->Data(); + uint32 month = ((TDateTimeSection *)fSectionList->ItemAt(0))->Data(); + uint32 year = ((TDateTimeSection *)fSectionList->ItemAt(2))->Data(); int daycnt = getDaysInMonth(month, year); if (value > daycnt) @@ -643,8 +614,8 @@ return; } - ((TDateTimeSection *)f_sections->ItemAt(f_focus))->SetData(value); - f_holdvalue = value; + ((TDateTimeSection *)fSectionList->ItemAt(fFocus))->SetData(value); + fHoldValue = value; Draw(Bounds()); } Modified: haiku/trunk/src/preferences/time/DateTimeEdit.h =================================================================== --- haiku/trunk/src/preferences/time/DateTimeEdit.h 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/DateTimeEdit.h 2007-09-14 09:04:03 UTC (rev 22232) @@ -1,66 +1,66 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * probably Mike Berg + * and/or Andrew McCall + * Julun + * + */ #ifndef DATETIME_H #define DATETIME_H + #include "SectionEdit.h" -// TSection descendent to hold uint32 value -class TDateTimeSection : public TSection { - public: - TDateTimeSection(BRect frame, uint32 data = 0); - ~TDateTimeSection(); - - uint32 Data() const; - void SetData(uint32 data); - private: - uint32 fData; -}; -// TSectionEdit descendent to edit time class TTimeEdit : public TSectionEdit { public: - TTimeEdit(BRect frame, const char *name, uint32 sections); - ~TTimeEdit(); + TTimeEdit(BRect frame, const char *name, uint32 sections); + virtual ~TTimeEdit(); - virtual void InitView(); - virtual void DrawSection(uint32 index, bool isfocus); - virtual void DrawSeperator(uint32 index); + virtual void InitView(); + virtual void DrawSection(uint32 index, bool isfocus); + virtual void DrawSeperator(uint32 index); - virtual void SetSections(BRect area); - virtual void SectionFocus(uint32 index); - virtual void GetSeperatorWidth(uint32 *width); + virtual void SetSections(BRect area); + virtual void SectionFocus(uint32 index); + virtual float SeperatorWidth() const; - void CheckRange(); + void CheckRange(); - virtual void DoUpPress(); - virtual void DoDownPress(); + virtual void DoUpPress(); + virtual void DoDownPress(); - virtual void BuildDispatch(BMessage *message); + virtual void BuildDispatch(BMessage *message); - void SetTo(uint32 hour, uint32 minute, uint32 second); + void SetTime(uint32 hour, uint32 minute, uint32 second); }; -// TSectionEdit descendent to edit Date + class TDateEdit : public TSectionEdit { public: - TDateEdit(BRect frame, const char *name, uint32 sections); - ~TDateEdit(); + TDateEdit(BRect frame, const char *name, uint32 sections); + virtual ~TDateEdit(); - virtual void InitView(); - virtual void DrawSection(uint32 index, bool isfocus); - virtual void DrawSeperator(uint32 index); + virtual void InitView(); + virtual void DrawSection(uint32 index, bool isfocus); + virtual void DrawSeperator(uint32 index); - virtual void SetSections(BRect area); - virtual void SectionFocus(uint32 index); - virtual void GetSeperatorWidth(uint32 *width); + virtual void SetSections(BRect area); + virtual void SectionFocus(uint32 index); + virtual float SeperatorWidth() const; - void CheckRange(); + void CheckRange(); - virtual void DoUpPress(); - virtual void DoDownPress(); + virtual void DoUpPress(); + virtual void DoDownPress(); - virtual void BuildDispatch(BMessage *message); + virtual void BuildDispatch(BMessage *message); - void SetTo(uint32 hour, uint32 minute, uint32 second); + void SetDate(uint32 year, uint32 month, uint32 day); }; #endif // DATETIME_H + Modified: haiku/trunk/src/preferences/time/DateUtils.cpp =================================================================== --- haiku/trunk/src/preferences/time/DateUtils.cpp 2007-09-13 21:39:02 UTC (rev 22231) +++ haiku/trunk/src/preferences/time/DateUtils.cpp 2007-09-14 09:04:03 UTC (rev 22232) @@ -1,3 +1,11 @@ +/* + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * probably Mike Berg + * and/or Andrew McCall + */ #include "DateUtils.h" #include "math.h" @@ -7,16 +15,15 @@ [... truncated: 1070 lines follow ...] From stippi at mail.berlios.de Fri Sep 14 11:15:31 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 14 Sep 2007 11:15:31 +0200 Subject: [Haiku-commits] r22233 - haiku/trunk/src/preferences/time Message-ID: <200709140915.l8E9FVHj025507@sheep.berlios.de> Author: stippi Date: 2007-09-14 11:15:30 +0200 (Fri, 14 Sep 2007) New Revision: 22233 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22233&view=rev Modified: haiku/trunk/src/preferences/time/CalendarView.h Log: * I was a bit too ambitious, this file was not touched by Julun yet it appears Modified: haiku/trunk/src/preferences/time/CalendarView.h =================================================================== --- haiku/trunk/src/preferences/time/CalendarView.h 2007-09-14 09:04:03 UTC (rev 22232) +++ haiku/trunk/src/preferences/time/CalendarView.h 2007-09-14 09:15:30 UTC (rev 22233) @@ -5,7 +5,6 @@ * Authors: * probably Mike Berg * and/or Andrew McCall - * Julun */ #ifndef CALENDAR_VIEW_H #define CALENDAR_VIEW_H From revol at free.fr Fri Sep 14 13:39:31 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 14 Sep 2007 13:39:31 +0200 CEST Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <20070914104603.3804.4@stippis.WG> Message-ID: <374484810-BeMail@laptop> > > Right. > > Some apps that want to get full control (VNCViewer for ex, maybe > > SDL) > > usually override DispatchMessage(), and do tricky stuff, but I > > don't know > > if they touch the mouse. > > I too remember weird behaviour of MediaPlayer being dragged by > clicking > somewhere inside between the controls. So I tried this yesterday > again, > both in the test environment and under Haiku on real hardware. To my > surprise, it worked perfectly. Maybe Axel's recent changes have fixed > this. > I have not yet looked closer into which code path is truely used in > MediaPlayer. The funny thing is, the code first tries to find a > coordinate > "screen_where" in the message, which appearantly ZETA provides. The > comment > there says "screen_where is the only reliable coordinate under ZETA". > When > the code does not find "screen_where", it goes on to try and find the > "normal" mouse coord field and translates that to screen space using > the > original handler for the mouse message. I presume that this is the > code > path which works under Haiku. So because this works like a charm, I > assume > that the "sanitizing" of messages (ie filtering them before the > application > sees them) so that they are compatible with R5 messages, works, even > if an > application overrides DispatchMessage(). I think the only time an > application would see the orignal messages is when it directly uses > the > message queue. I remember Marcus ranting about it in zeta, yes :) Now, maybe for correctness we should name it screen_where when sending, and using the other name after converting. It would be cleaner, and an app really digging the message queue would just not work instead of doing nasty things like orbitting the window off-screen like I've seen with some apps using that kind of mouse tricks. Fran?ois. From superstippi at gmx.de Fri Sep 14 13:52:58 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 14 Sep 2007 13:52:58 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <374484810-BeMail@laptop> References: <374484810-BeMail@laptop> Message-ID: <20070914135258.842.3@stippis.WG> Hi Fran?ois, Fran?ois Revol wrote (2007-09-14, 13:39:31 [+0200]): > I remember Marcus ranting about it in zeta, yes :) Now, maybe for > correctness we should name it screen_where when sending, and using the > other name after converting. It would be cleaner, and an app really > digging the message queue would just not work instead of doing nasty > things like orbitting the window off-screen like I've seen with some apps > using that kind of mouse tricks. Yeah, that's a good idea! Best regards, -Stephan From superstippi at gmx.de Fri Sep 14 14:03:16 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Fri, 14 Sep 2007 14:03:16 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <20070914135258.842.3@stippis.WG> References: <374484810-BeMail@laptop> <20070914135258.842.3@stippis.WG> Message-ID: <20070914140316.1019.4@stippis.WG> Stephan Assmus wrote (2007-09-14, 13:52:58 [+0200]): > Hi Fran?ois, > > Fran?ois Revol wrote (2007-09-14, 13:39:31 [+0200]): > > I remember Marcus ranting about it in zeta, yes :) Now, maybe for > > correctness we should name it screen_where when sending, and using the > > other name after converting. It would be cleaner, and an app really > > digging the message queue would just not work instead of doing nasty > > things like orbitting the window off-screen like I've seen with some > > apps using that kind of mouse tricks. > > Yeah, that's a good idea! I just had a look, and this is exactly how it already works. Doh. :-) So the code path the MediaPlayer uses is the same as under ZETA. And the message won't have a "where" field until they were filtered in BWindow (and then it will be in view space). Best regards, -Stephan From bonefish at mail.berlios.de Sat Sep 15 21:52:13 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 15 Sep 2007 21:52:13 +0200 Subject: [Haiku-commits] r22234 - haiku/trunk/src/kits/interface Message-ID: <200709151952.l8FJqDsr004222@sheep.berlios.de> Author: bonefish Date: 2007-09-15 21:52:13 +0200 (Sat, 15 Sep 2007) New Revision: 22234 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22234&view=rev Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp Log: SplitLayout.h is a local header. Modified: haiku/trunk/src/kits/interface/SplitLayout.cpp =================================================================== --- haiku/trunk/src/kits/interface/SplitLayout.cpp 2007-09-14 09:15:30 UTC (rev 22233) +++ haiku/trunk/src/kits/interface/SplitLayout.cpp 2007-09-15 19:52:13 UTC (rev 22234) @@ -3,7 +3,7 @@ * All rights reserved. Distributed under the terms of the MIT License. */ -#include +#include "SplitLayout.h" #include From bonefish at mail.berlios.de Sat Sep 15 22:04:21 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 15 Sep 2007 22:04:21 +0200 Subject: [Haiku-commits] r22235 - in haiku/trunk: build/jam src/kits src/kits/interface src/kits/interface/layouter src/libs src/libs/qoca Message-ID: <200709152004.l8FK4LGr004940@sheep.berlios.de> Author: bonefish Date: 2007-09-15 22:04:20 +0200 (Sat, 15 Sep 2007) New Revision: 22235 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22235&view=rev Added: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.h haiku/trunk/src/libs/qoca/ Removed: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.cpp haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h haiku/trunk/src/kits/interface/qoca/ Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/kits/Jamfile haiku/trunk/src/kits/interface/Jamfile haiku/trunk/src/libs/Jamfile haiku/trunk/src/libs/qoca/Jamfile Log: * Moved qoca to src/libs/qoca. * Made use of qoca opt-in. You have to set the jam/environment variable LAYOUT_CONSTRAINT_SOLVER to "qoca" to do that. Unfortunately it turned the latest version of qoca is GPL (only earlier version were LGPL; the license included in the downloadable archive was misleading), so we can't use it. Complex layouts constraints that would require constraint solver support are ignored until I've found a replacement. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-09-15 19:52:13 UTC (rev 22234) +++ haiku/trunk/build/jam/HaikuImage 2007-09-15 20:04:20 UTC (rev 22235) @@ -63,7 +63,9 @@ libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so libdevice.so libgame.so libscreensaver.so libroot.so - $(X86_ONLY)libGL.so libfluidsynth.so libqoca.so + $(X86_ONLY)libGL.so libfluidsynth.so + # constraint solver lib + lib$(LAYOUT_CONSTRAINT_SOLVER).so ; BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server net_server media_addon_server input_server app_server fake_app_server Modified: haiku/trunk/src/kits/Jamfile =================================================================== --- haiku/trunk/src/kits/Jamfile 2007-09-15 19:52:13 UTC (rev 22234) +++ haiku/trunk/src/kits/Jamfile 2007-09-15 20:04:20 UTC (rev 22235) @@ -32,7 +32,7 @@ storage_kit.o support_kit.o - libqoca.so + lib$(LAYOUT_CONSTRAINT_SOLVER).so libicon.a libagg.a @@ -68,7 +68,7 @@ storage_kit.o support_kit.o - libqoca.so + lib$(LAYOUT_CONSTRAINT_SOLVER).so libicon.a libagg.a Modified: haiku/trunk/src/kits/interface/Jamfile =================================================================== --- haiku/trunk/src/kits/interface/Jamfile 2007-09-15 19:52:13 UTC (rev 22234) +++ haiku/trunk/src/kits/interface/Jamfile 2007-09-15 20:04:20 UTC (rev 22235) @@ -28,11 +28,23 @@ UsePrivateHeaders app input interface shared tracker ; UseLibraryHeaders icon ; -# qoca headers -SubDirSysHdrs $(SUBDIR) ; -SubDirHdrs [ FDirName $(SUBDIR) qoca ] ; +# constraint solver to use +local constraintSolverSources = ; +switch $(LAYOUT_CONSTRAINT_SOLVER) { + case qoca : + { + DEFINES += USE_QOCA_CONSTRAINT_SOLVER ; + constraintSolverSources = QocaConstraintSolverLayouter.cpp ; + SubDirSysHdrs [ FDirName $(HAIKU_TOP) src libs ] ; + SubDirHdrs [ FDirName $(HAIKU_TOP) src libs qoca ] ; + } + case * : + { + } +} + SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; @@ -126,10 +138,9 @@ WidthBuffer.cpp # layouter - ConstraintSolverLayouter.cpp Layouter.cpp OneElementLayouter.cpp SimpleLayouter.cpp + + $(constraintSolverSources) ; - -SubInclude HAIKU_TOP src kits interface qoca ; Deleted: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.cpp Deleted: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h Added: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h =================================================================== --- haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h 2007-09-15 19:52:13 UTC (rev 22234) +++ haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h 2007-09-15 20:04:20 UTC (rev 22235) @@ -0,0 +1,18 @@ +/* + * Copyright 2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ +#ifndef CONSTRAINT_SOLVER_LAYOUTER_H +#define CONSTRAINT_SOLVER_LAYOUTER_H + + +#ifdef USE_QOCA_CONSTRAINT_SOLVER +# include "QocaConstraintSolverLayouter.h" + typedef QocaConstraintSolverLayouter ConstraintSolverLayouter; +#else +# include "SimpleLayouter.h" + typedef SimpleLayouter ConstraintSolverLayouter; +#endif + + +#endif // CONSTRAINT_SOLVER_LAYOUTER_H Copied: haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp (from rev 22233, haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.cpp) =================================================================== --- haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.cpp 2007-09-14 09:15:30 UTC (rev 22233) +++ haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp 2007-09-15 20:04:20 UTC (rev 22235) @@ -0,0 +1,1682 @@ +/* + * Copyright 2006-2007, Ingo Weinhold . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "QocaConstraintSolverLayouter.h" + +#include +#include + +#include +#include +#include + +#include + +#include "SimpleLayouter.h" + +// Since the qoca headers are DEBUG and NDEBUG conditional, we get +// incompatibilities when compiling this file with debugging and qoca +// without. So we consistently don't allow qoca to be compiled with +// debugging and undefine the macros before using the includes. +#undef DEBUG +#undef NDEBUG + +#include +#include +#include +#include + + +// This monster is a Layouter implementation similar to SimpleLayouter with +// the difference that it accepts min/max constraints over several elements, +// i.e. not only constraints of the form x_i <=/>= a, but also of the form +// x_i + x_{i+1} + ... x_{i+m} <=/>= a. This adds significant complexity, +// hence we employ a constraint solver, QOCA's QcLinInEqSolver, to find +// solutions. +// +// Two main problems remain, though: +// 1) QOCA supplies us with a real value solution, while we actually need an +// integer solution. Generally finding an optimal integer solution for +// a inequation system is at least NP hard (AFAIK even undecidable, if +// the variables are not restricted to >= 0). Fortunately our system has +// special properties that make things less complex. I haven't found +// anything related in the literature, but I've designed an algorithm that +// derives an integer solution from a real value solution. I wasn't able +// to prove, that there's always an integer solution given there's a +// real value solution (though I've the feeling that this is the case), +// but if there is one, the algorithm should be able to find it. +// 2) Constraints given to the layouter may be contradictory. If that is the +// case, we try to relax constraints such that they become +// non-contradictory again. We use heuristics to do this, like preferring +// min constraints over max constraints, ones with few involved variables +// over ones with many involved variables. + + +//#define ERROR_MESSAGE(message...) {} +#define ERROR_MESSAGE(message...) { printf(message); } + + +// no lround() under BeOS R5 x86 +#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST +# define lround(x) (long)floor((x) + 0.5) +#endif + + +// Set +class QocaConstraintSolverLayouter::Set { +public: + Set() + : fElements() + { + } + + BList& ToList() + { + return fElements; + } + + const BList& ToList() const + { + return fElements; + } + + bool Add(void* element) + { + if (fElements.HasItem(element)) + return false; + + fElements.AddItem(element); + return true; + } + + void AddAll(const Set& other) + { + AddAll(other.ToList()); + } + + void AddAll(const BList& other) + { + int32 count = other.CountItems(); + for (int32 i = 0; i < count; i++) + Add(other.ItemAt(i)); + } + + bool Remove(void* element) + { + return fElements.RemoveItem(element); + } + + void MakeEmpty() + { + fElements.MakeEmpty(); + } + + bool Contains(void* element) const + { + return fElements.HasItem(element); + } + + int32 Size() const + { + return fElements.CountItems(); + } + + bool IsEmpty() const + { + return fElements.IsEmpty(); + } + + void* Get(int32 index) const + { + return fElements.ItemAt(index); + } + +private: + BList fElements; +}; + + +// Variable +class QocaConstraintSolverLayouter::Variable { +public: + Variable() + : fQocaVariable(NULL), + fValue(0), + fIndex(-1) + { + } + + Variable(const char* name) + : fQocaVariable(new QcFloat(name, true)), + fValue(0), + fIndex(-1) + { + } + + Variable(int32 index) + : fQocaVariable(NULL), + fValue(0), + fIndex(index) + { + Init(index); + } + + ~Variable() + { + delete fQocaVariable; + } + + void Init(int32 index) + { + delete fQocaVariable; + + fIndex = index; + + BString name("x"); + name << index; + fQocaVariable = new QcFloat(name.String(), true); + } + + int32 Index() const + { + return fIndex; + } + + QcFloat* QocaVariable() const + { + return fQocaVariable; + } + + double SolvedValue() const + { + return fQocaVariable->Value(); + } + + int32 IntValue() const + { + return fValue; + } + + void SetIntValue(int32 value) + { + fValue = value; + } + +private: + QcFloat* fQocaVariable; + int32 fValue; + int32 fIndex; +}; + + +// Constraint +class QocaConstraintSolverLayouter::Constraint { +public: + Constraint(QocaConstraintSolverLayouter* layouter, + int32 first, int32 last, int32 value) + : fLayouter(layouter), + fFirst(first), + fLast(last), + fOriginalValue(-1), // so SetOriginalValue() detects a difference + fValue(-1), // so SetValue() detects a difference + fPolynom(NULL), + fQocaConstraint(NULL), + fAdded(false), + fAlgorithmData(0) + + { + fPolynom = new QcLinPoly(); + for (int i = first; i <= last; i++) + fPolynom->Push(1, *fLayouter->fVariables[i].QocaVariable()); + fQocaConstraint = new QcConstraint(); + } + + + virtual ~Constraint() + { + delete fPolynom; + delete fQocaConstraint; + } + + virtual Constraint* CloneConstraint( + QocaConstraintSolverLayouter* layouter) = 0; + + int32 First() const + { + return fFirst; + } + + int32 Last() const + { + return fLast; + } + + int32 OriginalValue() const + { + return fOriginalValue; + } + + void SetOriginalValue(int32 value) + { + if (value != fOriginalValue) { + fOriginalValue = value; + SetValue(value); + } + } + + virtual void RestrictOriginalValue(int32 value) = 0; + + int32 Value() const + { + return fValue; + } + + void SetValue(int32 value) + { + if (value == fValue) + return; + + fValue = value; + + UpdateQocaConstraint(); + } + + int32 AlgorithmData() const + { + return fAlgorithmData; + } + + void SetAlgorithmData(int32 algorithmData) + { + fAlgorithmData = algorithmData; + } + + QcConstraint* QocaConstraint() const + { + return fQocaConstraint; + } + + bool IsAdded() const + { + return fAdded; + } + + void SetAdded(bool added) + { + fAdded = added; + } + + bool IsSatisfied() const + { + return (ComputeSatisfactionDistance() <= 0); + } + + /** + * Returns the distance the sum value need to change for the constraint to + * get satisfied. + * + * A negative return value means that the constraint is satisfied and its + * absolute value is the distance the sum can change to be still satisfied. + * + * @return the distance the sum value need to change for the constraint to + * get satisfied. + */ + virtual int32 ComputeSatisfactionDistance() const = 0; + + virtual void UpdateQocaConstraint() = 0; + + int32 ComputeVariableSum() const + { + int sum = 0; + for (int i = fFirst; i <= fLast; i++) + sum += fLayouter->fVariables[i].IntValue(); + + return sum; + } + + +protected: + QocaConstraintSolverLayouter* fLayouter; + + int32 fFirst; + int32 fLast; + int32 fOriginalValue; // The value the user set. + int32 fValue; // The value we inferred (addConstraints()). + // Might be more restrictive or lax. + + QcLinPoly* fPolynom; + QcConstraint* fQocaConstraint; + + bool fAdded; + +private: + int32 fAlgorithmData; +}; + + +// MinConstraint +class QocaConstraintSolverLayouter::MinConstraint : public Constraint { +public: + MinConstraint(QocaConstraintSolverLayouter* layouter, int32 first, + int32 last, int32 value) + : Constraint(layouter, first, last, value) + { + SetOriginalValue(value); + } + + virtual Constraint* CloneConstraint(QocaConstraintSolverLayouter* layouter) + { + Constraint* constraint = new MinConstraint(layouter, fFirst, fLast, + fOriginalValue); + + constraint->SetValue(fValue); + + return constraint; + } + + virtual void RestrictOriginalValue(int32 value) + { + SetOriginalValue(max_c(fOriginalValue, value)); + } + + virtual void UpdateQocaConstraint() + { + fQocaConstraint->makeGe(fPolynom, fValue); + } + + virtual int32 ComputeSatisfactionDistance() const + { + return fValue - ComputeVariableSum(); + } + +// public String toString() { +// return "Constraint[sum (x" + fFirst + " ... x" + fLast + ") >= " + fValue + "]"; +// } +}; + + +// MaxConstraint +class QocaConstraintSolverLayouter::MaxConstraint : public Constraint { +public: + MaxConstraint(QocaConstraintSolverLayouter* layouter, int32 first, + int32 last, int32 value) + : Constraint(layouter, first, last, value) + { + SetOriginalValue(value); + } + + virtual Constraint* CloneConstraint(QocaConstraintSolverLayouter* layouter) + { + Constraint* constraint = new MaxConstraint(layouter, fFirst, fLast, + fOriginalValue); + + constraint->SetValue(fValue); + + return constraint; + } + + virtual void RestrictOriginalValue(int32 value) + { + SetOriginalValue(min_c(fOriginalValue, value)); + } + + virtual void UpdateQocaConstraint() + { + fQocaConstraint->makeLe(fPolynom, fValue); + } + + virtual int32 ComputeSatisfactionDistance() const + { + return ComputeVariableSum() - fValue; + } + +// public String toString() { +// return "Constraint[sum (x" + fFirst + " ... x" + fLast + ") <= " + fValue + "]"; +// } +}; + + +// MinMaxEntry +class QocaConstraintSolverLayouter::MinMaxEntry { +public: + Constraint* minConstraint; + Constraint* maxConstraint; + int32 min; + int32 max; + int32 requiredMax; + + MinMaxEntry() + : minConstraint(NULL), + maxConstraint(NULL), + min(0), + max(B_SIZE_UNLIMITED), + requiredMax(0) + { + } + + void SetMinConstraint(Constraint* minConstraint) + { + this->minConstraint = minConstraint; + if (minConstraint != NULL) + min = minConstraint->OriginalValue(); + } + + void SetMaxConstraint(Constraint* maxConstraint) + { + this->maxConstraint = maxConstraint; + if (maxConstraint != NULL) + max = max_c(min, maxConstraint->OriginalValue()); + } +}; + + +// MinMaxMatrix +class QocaConstraintSolverLayouter::MinMaxMatrix { +public: + MinMaxMatrix(int size) + : fSize(size), + fEntries(NULL) + { + int count = size * (size + 1) / 2; + fEntries = new MinMaxEntry[count]; + } + + ~MinMaxMatrix() + { + delete[] fEntries; + } + + MinMaxEntry& Entry(int32 first, int32 last) + { + return fEntries[first * (2 * fSize - first + 1) / 2 + (last - first)]; + } + +private: + int32 fSize; + MinMaxEntry* fEntries; +}; + + +// MyLayoutInfo +class QocaConstraintSolverLayouter::MyLayoutInfo : public LayoutInfo { +public: + MyLayoutInfo(int32 elementCount) + : fCount(elementCount) + { + fLocations = new int32[elementCount]; + fSizes = new int32[elementCount]; + } + + ~MyLayoutInfo() + { + delete fLocations; + delete fSizes; + } + + virtual float ElementLocation(int32 element) + { + if (element < 0 || element >= fCount) + return 0; + + return fLocations[element]; + } + + virtual float ElementSize(int32 element) + { + if (element < 0 || element >= fCount) + return -1; + + return fSizes[element] - 1; + } + + void Dump() + { + printf("QocaConstraintSolverLayouter::MyLayoutInfo(): %ld elements:\n", + fCount); + for (int32 i = 0; i < fCount; i++) { + printf(" %2ld: location: %4ld, size: %4ld\n", i, fLocations[i], + fSizes[i]); + } + } + +public: + int32 fCount; + int32* fLocations; + int32* fSizes; +}; + + +// #pragma mark - QocaConstraintSolverLayouter + + +// constructor +QocaConstraintSolverLayouter::QocaConstraintSolverLayouter(int32 elementCount, + int32 spacing) + : fElementCount(elementCount), + fWeights(NULL), + fBasicMinConstraints(NULL), + fBasicMaxConstraints(NULL), + fComplexMinConstraints(), + fComplexMaxConstraints(), + fVariables(NULL), + fSizeVariable(NULL), + fSolver(NULL), + fSizeSumConstraint(NULL), + fSetSizeConstraint(NULL), + fConstraintsAdded(false), + fSetSizeConstraintAdded(false), + fSpacing(spacing), + fMin(0), + fMax(B_SIZE_UNLIMITED), + fMinMaxValid(false), + fLayoutInfo(NULL) +{ + fWeights = new float[fElementCount]; + for (int32 i = 0; i < fElementCount; i++) + fWeights[i] = 1; + + fBasicMinConstraints = new Constraint*[fElementCount]; + fBasicMaxConstraints = new Constraint*[fElementCount]; + + memset(fBasicMinConstraints, 0, sizeof(Constraint*) * fElementCount); + memset(fBasicMaxConstraints, 0, sizeof(Constraint*) * fElementCount); + + fSolver = new QcLinInEqSolver(); + + fVariables = new Variable[fElementCount]; + for (int i = 0; i < fElementCount; i++) { + fVariables[i].Init(i); + fSolver->AddVar(*fVariables[i].QocaVariable()); + } + + fSizeVariable = new Variable("size"); + fSolver->AddVar(*fSizeVariable->QocaVariable()); + + // create size sum constraint (x1 + x2 + ... xn == size) + QcLinPoly* polynom = new QcLinPoly(); + for (int i = 0; i < fElementCount; i++) + polynom->Push(1, *fVariables[i].QocaVariable()); + polynom->Push(-1, *fSizeVariable->QocaVariable()); + + fSizeSumConstraint = new QcConstraint(); + fSizeSumConstraint->makeEq(polynom, 0); + + // create set size constraint (size == ) + polynom = new QcLinPoly(); + polynom->Push(1, *fSizeVariable->QocaVariable()); + + fSetSizeConstraint = new QcConstraint(); + fSetSizeConstraint->makeEq(polynom, 0); +} + +// destructor +QocaConstraintSolverLayouter::~QocaConstraintSolverLayouter() +{ + delete fSetSizeConstraint; + delete fSizeSumConstraint; + delete fSizeVariable; + delete[] fVariables; + delete fSolver; + + delete[] fWeights; + delete[] fBasicMinConstraints; + delete[] fBasicMaxConstraints; +} + +// AddConstraints +void +QocaConstraintSolverLayouter::AddConstraints(int32 element, int32 length, + float _min, float _max, float _preferred) +{ + if (length <= 0 || length > fElementCount) + return; + if (element < 0 || element + length > fElementCount) + return; + + int32 min = (int32)_min + 1; + int32 max = (int32)_max + 1; +// int32 preferred = (int32)_preferred + 1; + + int32 last = element + length - 1; + int32 spacing = (length - 1) * fSpacing; + _AddMinConstraint(element, last, min - spacing); + _AddMaxConstraint(element, last, max - spacing); + + fMinMaxValid = false; +} + +// SetWeight +void +QocaConstraintSolverLayouter::SetWeight(int32 element, float weight) +{ + if (element < 0 || element >= fElementCount) + return; + + fWeights[element] = max_c(weight, 0); +} + +// MinSize +float +QocaConstraintSolverLayouter::MinSize() +{ + _ValidateMinMax(); + return fMin - 1; +} + +// MaxSize +float +QocaConstraintSolverLayouter::MaxSize() +{ + _ValidateMinMax(); + return fMax - 1; +} + +// PreferredSize +float +QocaConstraintSolverLayouter::PreferredSize() +{ + _ValidateMinMax(); + return fMin - 1; +} + +// CreateLayoutInfo +LayoutInfo* +QocaConstraintSolverLayouter::CreateLayoutInfo() +{ + return new MyLayoutInfo(fElementCount); +} + +// Layout +void +QocaConstraintSolverLayouter::Layout(LayoutInfo* layoutInfo, float _size) +{ +//printf("QocaConstraintSolverLayouter::Layout(%p, %.1f): min: %ld, max: %ld\n", +//layoutInfo, _size, fMin, fMax); + int32 size = (int32)_size + 1; + + fLayoutInfo = (MyLayoutInfo*)layoutInfo; + + _ValidateMinMax(); + + if (fElementCount == 0) + return; + + if (size < fMin) + size = fMin; + + int32 additionalSpace = max_c(size - fMax, 0); + size -= additionalSpace; + int32 spacing = (fElementCount - 1) * fSpacing; + if (!_ComputeSolution(size - spacing)) { + ERROR_MESSAGE("QocaConstraintSolverLayouter::Layout(): no solution\n"); + // no solution + return; + } + + // If there is additional space, distribute it according to the elements' + // weights. + if (additionalSpace > 0) { +// Mmh, distributing according to the weights doesn't look that good. +// int[] sizes = new int[fElementCount]; +// SimpleLayouter.distributeSize(additionalSpace, fWeights, sizes); +// +// for (int i = 0; i < fElementCount; i++) { +// Variable var = fVariables[i]; +// var.setIntValue(var.getIntValue() + sizes[i]); +// } + + // distribute the additional space equally + int64 sumSize = 0; + for (int i = 0; i < fElementCount; i++) { + Variable& var = fVariables[i]; + int64 oldSumSize = sumSize; + sumSize = (i + 1) * additionalSpace / fElementCount; + var.SetIntValue(var.IntValue() + (int32)(sumSize - oldSumSize)); + } + } + + // compute locations + int location = 0; + for (int i = 0; i < fElementCount; i++) { + fLayoutInfo->fLocations[i] = location; + fLayoutInfo->fSizes[i] = fVariables[i].IntValue(); + location += fSpacing + fLayoutInfo->fSizes[i]; + } + +//fLayoutInfo->Dump(); +} + +// CloneLayouter +Layouter* +QocaConstraintSolverLayouter::CloneLayouter() +{ + QocaConstraintSolverLayouter* layouter + = new QocaConstraintSolverLayouter(fElementCount, fSpacing); + + memcpy(layouter->fWeights, fWeights, sizeof(float) * fElementCount); + + for (int i = 0; i < fElementCount; i++) { + Constraint* constraint = fBasicMinConstraints[i]; + if (constraint != NULL) { + layouter->fBasicMinConstraints[i] + = constraint->CloneConstraint(layouter); + } + + constraint = fBasicMaxConstraints[i]; + if (constraint != NULL) { + layouter->fBasicMaxConstraints[i] + = constraint->CloneConstraint(layouter); + } + } + + int32 count = fComplexMinConstraints.CountItems(); + for (int32 i = 0; i < count; i++) { + Constraint* constraint = (Constraint*)fComplexMinConstraints.ItemAt(i); + layouter->fComplexMinConstraints.AddItem( + constraint->CloneConstraint(layouter)); + } + + count = fComplexMaxConstraints.CountItems(); + for (int32 i = 0; i < count; i++) { + Constraint* constraint = (Constraint*)fComplexMaxConstraints.ItemAt(i); + layouter->fComplexMaxConstraints.AddItem( + constraint->CloneConstraint(layouter)); + } + + return layouter; +} + +// _ValidateMinMax +void +QocaConstraintSolverLayouter::_ValidateMinMax() +{ + if (fMinMaxValid) + return; + + if (fElementCount == 0) { + fMin = 0; + fMax = B_SIZE_UNLIMITED; + } else { + int32 spacing = (fElementCount - 1) * fSpacing; + fMin = BLayoutUtils::AddSizesInt32(_ComputeMin(), spacing); + fMax = BLayoutUtils::AddSizesInt32(_ComputeMax(), spacing); + } + + fMinMaxValid = true; +} + +// _AddMinConstraint +void +QocaConstraintSolverLayouter::_AddMinConstraint(int32 first, int32 last, + int32 value) +{ + if (first == last) { + _SetConstraint(MIN_CONSTRAINT, fBasicMinConstraints, first, value, + true); + } else { + _SetConstraint(MIN_CONSTRAINT, fComplexMinConstraints, first, last, + value, true); + } +} + +// _AddMaxConstraint +void +QocaConstraintSolverLayouter::_AddMaxConstraint(int32 first, int32 last, + int32 value) +{ + if (first == last) { + _SetConstraint(MAX_CONSTRAINT, fBasicMaxConstraints, first, value, + true); + } else { + _SetConstraint(MAX_CONSTRAINT, fComplexMaxConstraints, first, last, + value, true); + } +} + +// _ComputeMin +int32 +QocaConstraintSolverLayouter::_ComputeMin() +{ + _RemoveSetSizeConstraint(); + _AddConstraints(); + + // suggest 0 values for the variables + for (int32 i = 0; i < fElementCount; i++) + fSolver->SuggestValue(*fVariables[i].QocaVariable(), 0); + fSolver->SuggestValue(*fSizeVariable->QocaVariable(), 0); + + // solve + fSolver->Solve(); + + int32 size = lround(fSizeVariable->SolvedValue()); + + bool success = _FindIntegerSolution(size); + if (!success) { + ERROR_MESSAGE( + "QocaConstraintSolverLayouter::_ComputeMin(): no int solution\n"); + return 0; + } + + return size; +} + +// _ComputeMax +int32 +QocaConstraintSolverLayouter::_ComputeMax() +{ + _RemoveSetSizeConstraint(); + _AddConstraints(); + + // Try adding the size constraint with max possible value. If that works + // out, there's no limit on the maximal size. + if (_AddSetSizeConstraint(B_SIZE_UNLIMITED)) + return B_SIZE_UNLIMITED; + + // suggest 0 values for the element variables and the maximal possible + // value for the size + for (int32 i = 0; i < fElementCount; i++) + fSolver->SuggestValue(*fVariables[i].QocaVariable(), 0); + fSolver->SuggestValue(*fSizeVariable->QocaVariable(), B_SIZE_UNLIMITED); + + // solve [... truncated: 976 lines follow ...] From leavengood at mail.berlios.de Sun Sep 16 20:52:00 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sun, 16 Sep 2007 20:52:00 +0200 Subject: [Haiku-commits] r22236 - haiku/trunk/src/apps/terminal Message-ID: <200709161852.l8GIq0eu007073@sheep.berlios.de> Author: leavengood Date: 2007-09-16 20:51:59 +0200 (Sun, 16 Sep 2007) New Revision: 22236 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22236&view=rev Modified: haiku/trunk/src/apps/terminal/TermConst.h haiku/trunk/src/apps/terminal/TermWindow.cpp Log: Applied patch from Bek of the HOST team: allow the Terminal to be resized to one line. Modified: haiku/trunk/src/apps/terminal/TermConst.h =================================================================== --- haiku/trunk/src/apps/terminal/TermConst.h 2007-09-15 20:04:20 UTC (rev 22235) +++ haiku/trunk/src/apps/terminal/TermConst.h 2007-09-16 18:51:59 UTC (rev 22236) @@ -141,6 +141,8 @@ #define MIN_COLS 10 #define MAX_COLS 256 +#define MIN_ROWS 1 +#define MAX_ROWS 256 // Insert mode flag #define MODE_OVER 0 Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-09-15 20:04:20 UTC (rev 22235) +++ haiku/trunk/src/apps/terminal/TermWindow.cpp 2007-09-16 18:51:59 UTC (rev 22236) @@ -389,8 +389,14 @@ int width, height; _ActiveTermView()->GetFontSize(&width, &height); + float minimumHeight = 0; + if (fMenubar) + minimumHeight += fMenubar->Bounds().Height(); + if (fTabView && fTabView->CountTabs() > 1) + minimumHeight += fTabView->TabHeight(); SetSizeLimits (MIN_COLS * width, MAX_COLS * width, - MIN_COLS * height, MAX_COLS * height); + minimumHeight + MIN_ROWS * height, + minimumHeight + MAX_ROWS * height); ResizeTo(rect.Width()+ B_V_SCROLL_BAR_WIDTH + kViewOffset * 2, rect.Height()+fMenubar->Bounds().Height() + kViewOffset * 2); @@ -623,13 +629,22 @@ _SetTermColors(view); + if (fTabView->CountTabs() >= 1) { + int width, height; + view->GetFontSize(&width, &height); + + float minimumHeight = 0; + if (fMenubar) + minimumHeight += fMenubar->Bounds().Height(); + if (fTabView && fTabView->CountTabs() > 1) + minimumHeight += fTabView->TabHeight(); + SetSizeLimits (MIN_COLS * width, MAX_COLS * width, + minimumHeight + MIN_ROWS * height, + minimumHeight + MAX_ROWS * height); + } + // If it's the first time we're called, setup the window if (fTabView->CountTabs() == 1) { - int width, height; - view->GetFontSize(&width, &height); - SetSizeLimits(MIN_COLS * width, MAX_COLS * width, - MIN_COLS * height, MAX_COLS * height); - float fWidth, fHeight; view->GetPreferredSize(&fWidth, &fHeight); From soapdog at mail.berlios.de Mon Sep 17 04:38:12 2007 From: soapdog at mail.berlios.de (soapdog at BerliOS) Date: Mon, 17 Sep 2007 04:38:12 +0200 Subject: [Haiku-commits] r22237 - haiku/trunk/src/preferences/network Message-ID: <200709170238.l8H2cCfT017701@sheep.berlios.de> Author: soapdog Date: 2007-09-17 04:38:11 +0200 (Mon, 17 Sep 2007) New Revision: 22237 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22237&view=rev Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp Log: solved bug that prevented setting interface back to DHCP. Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-16 18:51:59 UTC (rev 22236) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-17 02:38:11 UTC (rev 22237) @@ -166,8 +166,8 @@ modemenu->AddItem(staticitem); BMenuItem* dhcpitem = new BMenuItem("DHCP", NULL); modemenu->AddItem(dhcpitem); - BMenuItem* offitem = new BMenuItem("Disconnected", NULL); - modemenu->AddItem(offitem); + //BMenuItem* offitem = new BMenuItem("Disconnected", NULL); + //modemenu->AddItem(offitem); fDeviceMenuField = new BMenuField(frame, "networkcards", "Adapter:", devmenu); fDeviceMenuField->SetDivider( @@ -298,32 +298,36 @@ EthernetSettingsView::_ApplyControlsToConfiguration() { - if (strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "Static") == 0) { - int i; - for (i = 0; i < fSettings.CountItems(); i++) { + int i; + for (i = 0; i < fSettings.CountItems(); i++) { - if (strcmp(fSettings.ItemAt(i)-> - GetName(), fDeviceMenuField->Menu()->FindMarked()->Label()) == 0) { + if (strcmp(fSettings.ItemAt(i)-> + GetName(), fDeviceMenuField->Menu()->FindMarked()->Label()) == 0) { + fSettings.ItemAt(i)-> + SetIP(fIPTextControl->Text()); + fSettings.ItemAt(i)-> + SetNetmask(fNetMaskTextControl->Text()); fSettings.ItemAt(i)-> - SetIP(fIPTextControl->Text()); - fSettings.ItemAt(i)-> - SetNetmask(fNetMaskTextControl->Text()); - fSettings.ItemAt(i)-> - SetGateway(fGatewayTextControl->Text()); + SetGateway(fGatewayTextControl->Text()); + if (strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP") + == 0) + fSettings.ItemAt(i)->SetAutoConfigure(true); + else fSettings.ItemAt(i)->SetAutoConfigure(false); + - fSettings.ItemAt(i)->fNameservers.MakeEmpty(); - fSettings.ItemAt(i)->fNameservers.AddItem(new BString( - fPrimaryDNSTextControl->Text())); - fSettings.ItemAt(i)->fNameservers.AddItem(new BString( - fSecondaryDNSTextControl->Text())); - - } + fSettings.ItemAt(i)->fNameservers.MakeEmpty(); + fSettings.ItemAt(i)->fNameservers.AddItem(new BString( + fPrimaryDNSTextControl->Text())); + fSettings.ItemAt(i)->fNameservers.AddItem(new BString( + fSecondaryDNSTextControl->Text())); + } - } -} + } +} + void EthernetSettingsView::_SaveConfiguration() { @@ -364,12 +368,14 @@ return; FILE* fp = NULL; + bool allDHCP = true; // loop over all adapters. open the settings file only once, // append the settins of each non-autoconfiguring adapter for (int i = 0; i < fSettings.CountItems(); i++) { if (fSettings.ItemAt(i)->GetAutoConfigure()) continue; - + + allDHCP = false; if (fp == NULL) { fp = fopen(path.Path(), "w"); if (fp == NULL) { @@ -393,7 +399,12 @@ if (fp) { printf("%s saved.\n", path.Path()); fclose(fp); - } + } + + if (allDHCP) { + // all configuration is DHCP, so delete interfaces file. + remove(path.Path()); + } } status_t From stippi at mail.berlios.de Mon Sep 17 16:05:07 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 17 Sep 2007 16:05:07 +0200 Subject: [Haiku-commits] r22238 - haiku/trunk/src/preferences/network Message-ID: <200709171405.l8HE57Oo027678@sheep.berlios.de> Author: stippi Date: 2007-09-17 16:05:06 +0200 (Mon, 17 Sep 2007) New Revision: 22238 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22238&view=rev Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp haiku/trunk/src/preferences/network/EthernetSettingsView.h haiku/trunk/src/preferences/network/Jamfile Log: a bit of cleanup * Network can only be built for Haiku, so no package and no BeOS compatible declaration in Jamfile * some style cleanup in EthernetSettingsView * fixed EthernetSettingsView::AttachedToWindow(): fixed leaking of the initial message, fixed potential crashing bug when no device was present on the system Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-17 02:38:11 UTC (rev 22237) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-17 14:05:06 UTC (rev 22238) @@ -118,12 +118,13 @@ fApplyButton->SetTarget(this); fDeviceMenuField->Menu()->SetTargetForItems(this); - // Display first adapter by default. - - BMessage* info = new BMessage(kMsgInfo); - info->AddString("interface", fSettings.ItemAt(0)->GetName()); - _ShowConfiguration(info); - + // display settigs of first adapter on startup + Settings* settings = fSettings.ItemAt(0); + if (settings) { + BMessage info(kMsgInfo); + info.AddString("interface", settings->GetName()); + _ShowConfiguration(&info); + } } @@ -133,21 +134,19 @@ } -EthernetSettingsView::EthernetSettingsView(BRect rect) -: BView(rect, "EthernetSettingsView", B_FOLLOW_ALL, B_WILL_DRAW) +EthernetSettingsView::EthernetSettingsView(BRect frame) + : BView(frame, "EthernetSettingsView", B_FOLLOW_ALL, B_WILL_DRAW) { - float defaultWidth = 190; float inset = ceilf(be_plain_font->Size() * 0.8); - BRect frame(inset,inset, defaultWidth, 50); + frame.OffsetTo(B_ORIGIN); + frame.InsetBy(inset, inset); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - fSettings.MakeEmpty(); fSocket = socket(AF_INET, SOCK_DGRAM, 0); _GatherInterfaces(); - BPopUpMenu* devmenu = new BPopUpMenu("devices"); - + BPopUpMenu* devmenu = new BPopUpMenu("devices"); for (int32 i = 0; i < fInterfaces.CountItems(); i++) { BString& name = *fInterfaces.ItemAt(i); BString label = name; @@ -155,12 +154,8 @@ info->AddString("interface", name.String()); BMenuItem* item = new BMenuItem(label.String(), info); devmenu->AddItem(item); - - } - - BPopUpMenu* modemenu = new BPopUpMenu("modes"); BMenuItem* staticitem = new BMenuItem("Static", NULL); modemenu->AddItem(staticitem); @@ -174,7 +169,6 @@ fDeviceMenuField->StringWidth(fDeviceMenuField->Label()) + 8); AddChild(fDeviceMenuField); fDeviceMenuField->ResizeToPreferred(); - fTypeMenuField = new BMenuField(frame, "type", "Mode:", modemenu); fTypeMenuField->SetDivider( @@ -233,8 +227,6 @@ fApplyButton->MoveTo( fSecondaryDNSTextControl->Frame().LeftBottom() + BPoint(0,10)); AddChild(fApplyButton); - - } EthernetSettingsView::~EthernetSettingsView() @@ -243,11 +235,8 @@ } void -EthernetSettingsView::_ShowConfiguration(BMessage* message) +EthernetSettingsView::_ShowConfiguration(const BMessage* message) { - - - // Clear the inputs. fIPTextControl->SetText(""); fGatewayTextControl->SetText(""); @@ -260,37 +249,34 @@ if (message->FindString("interface", &name) != B_OK) return; - int i; - for (i=0; iGetName(), name) == 0) { - fDeviceMenuField->Menu()->FindItem(name)->SetMarked(true); - fIPTextControl->SetText(fSettings.ItemAt(i)->GetIP()); - fGatewayTextControl->SetText(fSettings.ItemAt(i)->GetGateway()); - fNetMaskTextControl->SetText(fSettings.ItemAt(i)->GetNetmask()); - - if (fSettings.ItemAt(i)->GetAutoConfigure() == true) { - fTypeMenuField->Menu()->FindItem("DHCP")->SetMarked(true); - fTypeMenuField->Menu()->FindItem("Static")->SetMarked(false); + for (int32 i = 0; i < fSettings.CountItems(); i++) { + Settings* settings = fSettings.ItemAt(i); + if (strcmp(settings->GetName(), name) != 0) + continue; - } else { - fTypeMenuField->Menu()->FindItem("Static")->SetMarked(true); - fTypeMenuField->Menu()->FindItem("DHCP")->SetMarked(false); + fDeviceMenuField->Menu()->FindItem(name)->SetMarked(true); - } - fTypeMenuField->Menu()->SetLabelFromMarked(true); - fDeviceMenuField->Menu()->SetLabelFromMarked(true); + fIPTextControl->SetText(settings->GetIP()); + fGatewayTextControl->SetText(settings->GetGateway()); + fNetMaskTextControl->SetText(settings->GetNetmask()); + + if (settings->GetAutoConfigure() == true) + fTypeMenuField->Menu()->FindItem("DHCP")->SetMarked(true); + else + fTypeMenuField->Menu()->FindItem("Static")->SetMarked(true); - - if (fSettings.ItemAt(i)->fNameservers.CountItems() == 2) { - fSecondaryDNSTextControl->SetText( - fSettings.ItemAt(i)->fNameservers.ItemAt(1)->String()); - } - - if (fSettings.ItemAt(i)->fNameservers.CountItems() >= 1) { - fPrimaryDNSTextControl->SetText( - fSettings.ItemAt(i)->fNameservers.ItemAt(0)->String()); - } +// fTypeMenuField->Menu()->SetLabelFromMarked(true); +// fDeviceMenuField->Menu()->SetLabelFromMarked(true); + + if (settings->fNameservers.CountItems() >= 2) { + fSecondaryDNSTextControl->SetText( + settings->fNameservers.ItemAt(1)->String()); } + + if (settings->fNameservers.CountItems() >= 1) { + fPrimaryDNSTextControl->SetText( + settings->fNameservers.ItemAt(0)->String()); + } } } Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-09-17 02:38:11 UTC (rev 22237) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-09-17 14:05:06 UTC (rev 22238) @@ -26,7 +26,7 @@ class EthernetSettingsView : public BView { public: - EthernetSettingsView(BRect rect); + EthernetSettingsView(BRect frame); virtual ~EthernetSettingsView(); virtual void MessageReceived(BMessage* message); @@ -53,7 +53,7 @@ int fSocket; void _GatherInterfaces(); bool _PrepareRequest(struct ifreq& request, const char* name); - void _ShowConfiguration(BMessage* message); + void _ShowConfiguration(const BMessage* message); void _SaveConfiguration(); void _SaveDNSConfiguration(); void _SaveAdaptersConfiguration(); Modified: haiku/trunk/src/preferences/network/Jamfile =================================================================== --- haiku/trunk/src/preferences/network/Jamfile 2007-09-17 02:38:11 UTC (rev 22237) +++ haiku/trunk/src/preferences/network/Jamfile 2007-09-17 14:05:06 UTC (rev 22238) @@ -1,7 +1,5 @@ SubDir HAIKU_TOP src preferences network ; -SetSubDirSupportedPlatformsBeOSCompatible ; - UsePrivateHeaders shared ; Preference Network : @@ -12,7 +10,3 @@ : be root $(HAIKU_NETWORK_LIBS) ; -Package haiku-networksettings : - Network : - boot home Desktop haiku-networksettings ; - From stippi at mail.berlios.de Mon Sep 17 19:50:07 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Mon, 17 Sep 2007 19:50:07 +0200 Subject: [Haiku-commits] r22239 - haiku/trunk/src/preferences/network Message-ID: <200709171750.l8HHo7ug025163@sheep.berlios.de> Author: stippi Date: 2007-09-17 19:50:06 +0200 (Mon, 17 Sep 2007) New Revision: 22239 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22239&view=rev Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp haiku/trunk/src/preferences/network/EthernetSettingsView.h haiku/trunk/src/preferences/network/NetworkWindow.cpp Log: * some more cleanup and refactoring in EthernetSettingsView * added Revert button * added enabling/disabling of text controls according to Mode setting Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-17 14:05:06 UTC (rev 22238) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp 2007-09-17 17:50:06 UTC (rev 22239) @@ -53,9 +53,9 @@ #include #include +#include "AutoDeleter.h" - bool EthernetSettingsView::_PrepareRequest(struct ifreq& request, const char* name) { @@ -69,8 +69,10 @@ return true; } + void -EthernetSettingsView::_GatherInterfaces() { +EthernetSettingsView::_GatherInterfaces() +{ // iterate over all interfaces and retrieve minimal status ifconf config; @@ -82,33 +84,30 @@ if (count == 0) return; - void *buffer = malloc(count * sizeof(struct ifreq)); + void* buffer = malloc(count * sizeof(struct ifreq)); if (buffer == NULL) return; + MemoryDeleter deleter(buffer); + config.ifc_len = count * sizeof(struct ifreq); config.ifc_buf = buffer; if (ioctl(fSocket, SIOCGIFCONF, &config, sizeof(struct ifconf)) < 0) return; - ifreq* interface = (ifreq *)buffer; + ifreq* interface = (ifreq*)buffer; fInterfaces.MakeEmpty(); for (uint32 i = 0; i < count; i++) { - if (strncmp(interface->ifr_name, "loop", 4) && interface->ifr_name[0]) - { + if (strncmp(interface->ifr_name, "loop", 4) && interface->ifr_name[0]) { fInterfaces.AddItem(new BString(interface->ifr_name)); fSettings.AddItem(new Settings(interface->ifr_name)); - } - interface = (ifreq *)((addr_t)interface + IF_NAMESIZE + interface = (ifreq*)((addr_t)interface + IF_NAMESIZE + interface->ifr_addr.sa_len); } - - free(buffer); - } @@ -116,15 +115,12 @@ EthernetSettingsView::AttachedToWindow() { fApplyButton->SetTarget(this); + fRevertButton->SetTarget(this); fDeviceMenuField->Menu()->SetTargetForItems(this); + fTypeMenuField->Menu()->SetTargetForItems(this); // display settigs of first adapter on startup - Settings* settings = fSettings.ItemAt(0); - if (settings) { - BMessage info(kMsgInfo); - info.AddString("interface", settings->GetName()); - _ShowConfiguration(&info); - } + _ShowConfiguration(fSettings.ItemAt(0)); } @@ -136,10 +132,15 @@ EthernetSettingsView::EthernetSettingsView(BRect frame) : BView(frame, "EthernetSettingsView", B_FOLLOW_ALL, B_WILL_DRAW) + , fInterfaces() + , fSettings() + , fCurrentSettings(NULL) { float inset = ceilf(be_plain_font->Size() * 0.8); - frame.OffsetTo(B_ORIGIN); - frame.InsetBy(inset, inset); + frame.OffsetTo(inset, inset); + frame.right = StringWidth("IP Address XXX.XXX.XXX.XXX") + 50; + frame.bottom = frame.top + 15; // just a starting point + BPoint spacing(0, inset); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -157,76 +158,93 @@ } BPopUpMenu* modemenu = new BPopUpMenu("modes"); - BMenuItem* staticitem = new BMenuItem("Static", NULL); - modemenu->AddItem(staticitem); - BMenuItem* dhcpitem = new BMenuItem("DHCP", NULL); - modemenu->AddItem(dhcpitem); + modemenu->AddItem(new BMenuItem("Static", new BMessage(kMsgMode))); + modemenu->AddItem(new BMenuItem("DHCP", new BMessage(kMsgMode))); //BMenuItem* offitem = new BMenuItem("Disconnected", NULL); //modemenu->AddItem(offitem); fDeviceMenuField = new BMenuField(frame, "networkcards", "Adapter:", devmenu); - fDeviceMenuField->SetDivider( - fDeviceMenuField->StringWidth(fDeviceMenuField->Label()) + 8); AddChild(fDeviceMenuField); fDeviceMenuField->ResizeToPreferred(); fTypeMenuField = new BMenuField(frame, "type", "Mode:", modemenu); - fTypeMenuField->SetDivider( - fTypeMenuField->StringWidth(fTypeMenuField->Label()) + 8); - fTypeMenuField->MoveTo(fDeviceMenuField->Frame().LeftBottom() + BPoint(0,10)); + fTypeMenuField->MoveTo(fDeviceMenuField->Frame().LeftBottom() + spacing); AddChild(fTypeMenuField); fTypeMenuField->ResizeToPreferred(); - fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL, - B_FOLLOW_TOP, B_WILL_DRAW ); - fIPTextControl->SetDivider( - fIPTextControl->StringWidth(fIPTextControl->Label()) + 8); - fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + BPoint(0,10)); + fIPTextControl = new BTextControl(frame, "ip", "IP Address:", "", NULL); + fIPTextControl->MoveTo(fTypeMenuField->Frame().LeftBottom() + spacing); fIPTextControl->ResizeToPreferred(); AddChild(fIPTextControl); - fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL, - B_FOLLOW_TOP, B_WILL_DRAW ); - fNetMaskTextControl->SetDivider( - fNetMaskTextControl->StringWidth(fNetMaskTextControl->Label()) + 8); + fNetMaskTextControl = new BTextControl(frame, "mask", "Netmask:", "", NULL); fNetMaskTextControl->MoveTo( - fIPTextControl->Frame().LeftBottom() + BPoint(0,10)); + fIPTextControl->Frame().LeftBottom() + spacing); AddChild(fNetMaskTextControl); fNetMaskTextControl->ResizeToPreferred(); fGatewayTextControl = new BTextControl(frame, "gateway", "Gateway:", "", - NULL, B_FOLLOW_TOP, B_WILL_DRAW ); - fGatewayTextControl->SetDivider( - fGatewayTextControl->StringWidth(fGatewayTextControl->Label()) + 8); + NULL); fGatewayTextControl->MoveTo( - fNetMaskTextControl->Frame().LeftBottom() + BPoint(0,10)); + fNetMaskTextControl->Frame().LeftBottom() + spacing); AddChild(fGatewayTextControl); fGatewayTextControl->ResizeToPreferred(); - fPrimaryDNSTextControl = new BTextControl( - frame, "dns1", "DNS #1:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); - fPrimaryDNSTextControl->SetDivider( - fPrimaryDNSTextControl->StringWidth(fPrimaryDNSTextControl->Label()) + 8); + fPrimaryDNSTextControl = new BTextControl(frame, "dns1", "DNS #1:", "", + NULL); fPrimaryDNSTextControl->MoveTo( - fGatewayTextControl->Frame().LeftBottom() + BPoint(0,10)); + fGatewayTextControl->Frame().LeftBottom() + spacing); AddChild(fPrimaryDNSTextControl); fPrimaryDNSTextControl->ResizeToPreferred(); - fSecondaryDNSTextControl = new BTextControl( - frame, "dns2", "DNS #2:", "", NULL, B_FOLLOW_TOP, B_WILL_DRAW ); - fSecondaryDNSTextControl->SetDivider( - fSecondaryDNSTextControl->StringWidth( - fSecondaryDNSTextControl->Label()) + 8); + fSecondaryDNSTextControl = new BTextControl(frame, "dns2", "DNS #2:", "", + NULL); fSecondaryDNSTextControl->MoveTo( - fPrimaryDNSTextControl->Frame().LeftBottom() + BPoint(0,10)); + fPrimaryDNSTextControl->Frame().LeftBottom() + spacing); AddChild(fSecondaryDNSTextControl); fSecondaryDNSTextControl->ResizeToPreferred(); + fRevertButton = new BButton(frame, "revert", "Revert", + new BMessage(kMsgRevert)); + fRevertButton->ResizeToPreferred(); + fRevertButton->MoveTo( + fSecondaryDNSTextControl->Frame().LeftBottom() + spacing); + AddChild(fRevertButton); + fApplyButton = new BButton(frame, "apply", "Apply", new BMessage(kMsgApply)); fApplyButton->ResizeToPreferred(); fApplyButton->MoveTo( - fSecondaryDNSTextControl->Frame().LeftBottom() + BPoint(0,10)); + fSecondaryDNSTextControl->Frame().RightBottom() + spacing + + BPoint(-fApplyButton->Frame().Width(), 0)); AddChild(fApplyButton); + + ResizeTo(frame.Width() + 2 * inset, fApplyButton->Frame().bottom + inset); + + // take care of label alignment + float maxLabelWidth + = fDeviceMenuField->StringWidth(fDeviceMenuField->Label()); + maxLabelWidth = max_c(maxLabelWidth, + fTypeMenuField->StringWidth(fTypeMenuField->Label())); + maxLabelWidth = max_c(maxLabelWidth, + fIPTextControl->StringWidth(fIPTextControl->Label())); + maxLabelWidth = max_c(maxLabelWidth, + fNetMaskTextControl->StringWidth(fNetMaskTextControl->Label())); + maxLabelWidth = max_c(maxLabelWidth, + fGatewayTextControl->StringWidth(fGatewayTextControl->Label())); + maxLabelWidth = max_c(maxLabelWidth, + fPrimaryDNSTextControl->StringWidth(fPrimaryDNSTextControl->Label())); + maxLabelWidth = max_c(maxLabelWidth, + fSecondaryDNSTextControl->StringWidth( + fSecondaryDNSTextControl->Label())); + + fDeviceMenuField->SetDivider(maxLabelWidth + 8); + fTypeMenuField->SetDivider(maxLabelWidth + 8); + + fIPTextControl->SetDivider(maxLabelWidth + 8); + fNetMaskTextControl->SetDivider(maxLabelWidth + 8); + fGatewayTextControl->SetDivider(maxLabelWidth + 8); + fPrimaryDNSTextControl->SetDivider(maxLabelWidth + 8); + fSecondaryDNSTextControl->SetDivider(maxLabelWidth + 8); } EthernetSettingsView::~EthernetSettingsView() @@ -235,85 +253,86 @@ } void -EthernetSettingsView::_ShowConfiguration(const BMessage* message) +EthernetSettingsView::_ShowConfiguration(Settings* settings) { + fCurrentSettings = settings; + // Clear the inputs. fIPTextControl->SetText(""); fGatewayTextControl->SetText(""); fNetMaskTextControl->SetText(""); fPrimaryDNSTextControl->SetText(""); fSecondaryDNSTextControl->SetText(""); - - - const char* name; - if (message->FindString("interface", &name) != B_OK) - return; - - for (int32 i = 0; i < fSettings.CountItems(); i++) { - Settings* settings = fSettings.ItemAt(i); - if (strcmp(settings->GetName(), name) != 0) - continue; - fDeviceMenuField->Menu()->FindItem(name)->SetMarked(true); + bool enableControls = false; + fTypeMenuField->SetEnabled(settings != NULL); + if (settings) { + BMenuItem* item = fDeviceMenuField->Menu()->FindItem( + settings->GetName()); + if (item) + item->SetMarked(true); + fIPTextControl->SetText(settings->GetIP()); fGatewayTextControl->SetText(settings->GetGateway()); fNetMaskTextControl->SetText(settings->GetNetmask()); - + if (settings->GetAutoConfigure() == true) - fTypeMenuField->Menu()->FindItem("DHCP")->SetMarked(true); + item = fTypeMenuField->Menu()->FindItem("DHCP"); else - fTypeMenuField->Menu()->FindItem("Static")->SetMarked(true); + item = fTypeMenuField->Menu()->FindItem("Static"); + if (item) + item->SetMarked(true); -// fTypeMenuField->Menu()->SetLabelFromMarked(true); -// fDeviceMenuField->Menu()->SetLabelFromMarked(true); + enableControls = settings->GetAutoConfigure() == false; if (settings->fNameservers.CountItems() >= 2) { fSecondaryDNSTextControl->SetText( settings->fNameservers.ItemAt(1)->String()); } - + if (settings->fNameservers.CountItems() >= 1) { fPrimaryDNSTextControl->SetText( settings->fNameservers.ItemAt(0)->String()); } - } + } + + _EnableTextControls(enableControls); } + void +EthernetSettingsView::_EnableTextControls(bool enable) +{ + fIPTextControl->SetEnabled(enable); + fGatewayTextControl->SetEnabled(enable); + fNetMaskTextControl->SetEnabled(enable); + fPrimaryDNSTextControl->SetEnabled(enable); + fSecondaryDNSTextControl->SetEnabled(enable); +} + + +void EthernetSettingsView::_ApplyControlsToConfiguration() { - - int i; - for (i = 0; i < fSettings.CountItems(); i++) { - + if (!fCurrentSettings) + return; - if (strcmp(fSettings.ItemAt(i)-> - GetName(), fDeviceMenuField->Menu()->FindMarked()->Label()) == 0) { - fSettings.ItemAt(i)-> - SetIP(fIPTextControl->Text()); - fSettings.ItemAt(i)-> - SetNetmask(fNetMaskTextControl->Text()); - fSettings.ItemAt(i)-> - SetGateway(fGatewayTextControl->Text()); - if (strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP") - == 0) - fSettings.ItemAt(i)->SetAutoConfigure(true); - else - fSettings.ItemAt(i)->SetAutoConfigure(false); + fCurrentSettings->SetIP(fIPTextControl->Text()); + fCurrentSettings->SetNetmask(fNetMaskTextControl->Text()); + fCurrentSettings->SetGateway(fGatewayTextControl->Text()); - - fSettings.ItemAt(i)->fNameservers.MakeEmpty(); - fSettings.ItemAt(i)->fNameservers.AddItem(new BString( - fPrimaryDNSTextControl->Text())); - fSettings.ItemAt(i)->fNameservers.AddItem(new BString( - fSecondaryDNSTextControl->Text())); - - } - } -} + fCurrentSettings->SetAutoConfigure( + strcmp(fTypeMenuField->Menu()->FindMarked()->Label(), "DHCP") == 0); + fCurrentSettings->fNameservers.MakeEmpty(); + fCurrentSettings->fNameservers.AddItem(new BString( + fPrimaryDNSTextControl->Text())); + fCurrentSettings->fNameservers.AddItem(new BString( + fSecondaryDNSTextControl->Text())); +} + void EthernetSettingsView::_SaveConfiguration() { @@ -322,29 +341,29 @@ _SaveAdaptersConfiguration(); } + void EthernetSettingsView::_SaveDNSConfiguration() { - FILE* fp; - if ((fp = fopen("/etc/resolv.conf", "w")) != NULL) { - fprintf(fp, "# Generated by Network Preflet\n"); - int i; - for (i = 0; i < fSettings.CountItems(); i++) { - // loop all the adapters. - int j; - for (j = 0; j < fSettings.ItemAt(i)->fNameservers.CountItems(); j++) { - if (strcmp( - fSettings.ItemAt(i)->fNameservers.ItemAt(j)->String(), "") != 0) { - fprintf(fp, "nameserver\t%s\n", - fSettings.ItemAt(i)->fNameservers.ItemAt(j)->String()); - } - } + FILE* fp = fopen("/etc/resolv.conf", "w"); + if (fp == NULL) + return; + + fprintf(fp, "# Generated by Network Preflet\n"); + // loop over all adapters + for (int i = 0; i < fSettings.CountItems(); i++) { + Settings* settings = fSettings.ItemAt(i); + for (int j = 0; j < settings->fNameservers.CountItems(); j++) { + if (settings->fNameservers.ItemAt(j)->Length() > 0) { + fprintf(fp, "nameserver\t%s\n", + settings->fNameservers.ItemAt(j)->String()); } - fclose(fp); + } } - + fclose(fp); } + void EthernetSettingsView::_SaveAdaptersConfiguration() { @@ -354,14 +373,12 @@ return; FILE* fp = NULL; - bool allDHCP = true; // loop over all adapters. open the settings file only once, // append the settins of each non-autoconfiguring adapter for (int i = 0; i < fSettings.CountItems(); i++) { if (fSettings.ItemAt(i)->GetAutoConfigure()) continue; - - allDHCP = false; + if (fp == NULL) { fp = fopen(path.Path(), "w"); if (fp == NULL) { @@ -385,14 +402,13 @@ if (fp) { printf("%s saved.\n", path.Path()); fclose(fp); - } - - if (allDHCP) { + } else { // all configuration is DHCP, so delete interfaces file. remove(path.Path()); } } + status_t EthernetSettingsView::_GetPath(const char* name, BPath& path) { @@ -407,13 +423,31 @@ return B_OK; } + void EthernetSettingsView::MessageReceived(BMessage* message) { switch (message->what) { - case kMsgInfo: - _ShowConfiguration(message); + case kMsgMode: + if (BMenuItem* item = fTypeMenuField->Menu()->FindMarked()) + _EnableTextControls(strcmp(item->Label(), "DHCP") != 0); break; + case kMsgInfo: { + const char* name; + if (message->FindString("interface", &name) != B_OK) + break; + for (int32 i = 0; i < fSettings.CountItems(); i++) { + Settings* settings = fSettings.ItemAt(i); + if (strcmp(settings->GetName(), name) == 0) { + _ShowConfiguration(settings); + break; + } + } + break; + } + case kMsgRevert: + _ShowConfiguration(fCurrentSettings); + break; case kMsgApply: _SaveConfiguration(); break; Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.h =================================================================== --- haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-09-17 14:05:06 UTC (rev 22238) +++ haiku/trunk/src/preferences/network/EthernetSettingsView.h 2007-09-17 17:50:06 UTC (rev 22239) @@ -20,9 +20,11 @@ class BTextControl; static const uint32 kMsgApply = 'aply'; +static const uint32 kMsgRevert = 'rvrt'; static const uint32 kMsgClose = 'clse'; static const uint32 kMsgField = 'fild'; static const uint32 kMsgInfo = 'info'; +static const uint32 kMsgMode = 'mode'; class EthernetSettingsView : public BView { public: @@ -37,8 +39,8 @@ void LoadProfile(BString profileName); private: - BButton* fCloseButton; BButton* fApplyButton; + BButton* fRevertButton; BMenuField* fDeviceMenuField; BMenuField* fTypeMenuField; BTextControl* fIPTextControl; @@ -48,19 +50,19 @@ BTextControl* fSecondaryDNSTextControl; BObjectList fInterfaces; BObjectList fSettings; + Settings* fCurrentSettings; int32 fStatus; int fSocket; void _GatherInterfaces(); bool _PrepareRequest(struct ifreq& request, const char* name); - void _ShowConfiguration(const BMessage* message); + void _ShowConfiguration(Settings* settings); + void _EnableTextControls(bool enable); void _SaveConfiguration(); void _SaveDNSConfiguration(); void _SaveAdaptersConfiguration(); void _ApplyControlsToConfiguration(); status_t _GetPath(const char* name, BPath& path); - - }; #endif /* ETHERNET_SETTINGS_VIEW_H */ Modified: haiku/trunk/src/preferences/network/NetworkWindow.cpp =================================================================== --- haiku/trunk/src/preferences/network/NetworkWindow.cpp 2007-09-17 14:05:06 UTC (rev 22238) +++ haiku/trunk/src/preferences/network/NetworkWindow.cpp 2007-09-17 17:50:06 UTC (rev 22239) @@ -16,15 +16,14 @@ NetworkWindow::NetworkWindow() -: BWindow(BRect(50, 50, 269, 302), "Network", -B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS -| B_NOT_ZOOMABLE) + : BWindow(BRect(50, 50, 269, 302), "Network", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) { fEthView = new EthernetSettingsView(Bounds()); - + ResizeTo(fEthView->Frame().Width(), fEthView->Frame().Height()); + AddChild(fEthView); - } From axeld at pinc-software.de Mon Sep 17 22:59:40 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 17 Sep 2007 22:59:40 +0200 CEST Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <20070914140316.1019.4@stippis.WG> Message-ID: <3780415743-BeMail@zon> Stephan Assmus wrote: > > Yeah, that's a good idea! > I just had a look, and this is exactly how it already works. Doh. :-) > > So the code path the MediaPlayer uses is the same as under ZETA. And > the > message won't have a "where" field until they were filtered in > BWindow (and > then it will be in view space). Which is not too surprising, as that feature was introduced with Dano - which I used while writing that stuff :-) I only later found out that BeOS does not provide it :-) (back from Italy!) Bye, Axel. From superstippi at gmx.de Mon Sep 17 23:05:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Mon, 17 Sep 2007 23:05:52 +0200 Subject: [Haiku-commits] r22228 - haiku/trunk/src/kits/interface In-Reply-To: <3780415743-BeMail@zon> References: <3780415743-BeMail@zon> Message-ID: <20070917230552.58495.8@stippis.WG> Axel D?rfler wrote (2007-09-17, 22:59:40 [+0200]): > Stephan Assmus wrote: > > > Yeah, that's a good idea! > > I just had a look, and this is exactly how it already works. Doh. :-) > > > > So the code path the MediaPlayer uses is the same as under ZETA. And > > the > > message won't have a "where" field until they were filtered in BWindow > > (and > > then it will be in view space). > > Which is not too surprising, as that feature was introduced with Dano - > which I used while writing that stuff :-) > I only later found out that BeOS does not provide it :-) Since when is this working like it is? Or to reword this... since when is MediaPlayer supposed to be working, and since when is it really working and if those are different times, why? :-) On the other hand, we could forget about this and be happy. > (back from Italy!) Welcome back! Looking forward to your travel stories when we meet... Best regards, -Stephan From nielx at mail.berlios.de Mon Sep 17 23:33:25 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Mon, 17 Sep 2007 23:33:25 +0200 Subject: [Haiku-commits] r22240 - haiku/trunk/docs/user/app Message-ID: <200709172133.l8HLXPKt005224@sheep.berlios.de> Author: nielx Date: 2007-09-17 23:33:24 +0200 (Mon, 17 Sep 2007) New Revision: 22240 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22240&view=rev Added: haiku/trunk/docs/user/app/_app_messaging.dox Modified: haiku/trunk/docs/user/app/_app_intro.dox Log: First part of the messaging overview Modified: haiku/trunk/docs/user/app/_app_intro.dox =================================================================== --- haiku/trunk/docs/user/app/_app_intro.dox 2007-09-17 17:50:06 UTC (rev 22239) +++ haiku/trunk/docs/user/app/_app_intro.dox 2007-09-17 21:33:24 UTC (rev 22240) @@ -17,15 +17,16 @@ documents referenced before going to any other part of the API. We can divide the classes in the application kit up in two categories. The - biggest part of the classes are in the 'messaging' classes. The following - are part of it: + biggest part of the classes are in the 'messaging' classes. Have a look at + the \link app_messaging Introduction to Messaging \endlink for more + information. The following classes are part of it: - BHandler - BInvoker - BLooper - BMessage - BMessageFilter - BMessageQueue - - BMessageRUnner + - BMessageRunner - BMessenger The second category is the 'system interaction' category. These classes Added: haiku/trunk/docs/user/app/_app_messaging.dox =================================================================== --- haiku/trunk/docs/user/app/_app_messaging.dox 2007-09-17 17:50:06 UTC (rev 22239) +++ haiku/trunk/docs/user/app/_app_messaging.dox 2007-09-17 21:33:24 UTC (rev 22240) @@ -0,0 +1,152 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Niels Sascha Reedijk, niels.reedijk at gmail.com + */ + + +/*! + \page app_messaging Messaging Foundations + + One of the foundations of the Haiku API is the messaging system. This + framework is the basis for the efficient multithreaded Haiku applications, + because it solves one of the fundamental issues of multithreading: it + allows you to easily and securely communicate between threads. But the + framework goes even further: it allows inter-application communication! + + This page will introduce you to the subject of messaging. It is meant as a + broad overview to the classes, rather than a tutorial. If you are looking + for effective messaging techniques or a tutorial on messaging, have a look + at the developer section of the Haiku website. + + Table of contents + - Overview of the Messaging Classes + - Receiving and Handling Messages + - Sending messages + + \section app_messaging_overview Overview of the Messaging Classes + + \subsection app_messaging_overview_bmessage BMessage + + The BMessage class is the class that is in the center of all the messenger + operations, because it represents a message. A message is nothing more than + an object that contains: + - The \c what member, an \c uint32 that determines the type of message. + Some constants are defined by the Haiku API, for example B_MOUSE_DOWN or + B_QUIT_REQUESTED. + - Zero or more data objects. BMessage is a powerful data container that + keeps track of different sorts of data. BMessage provides many convenient + Add*() methods, for example BMessage::AddBool(). With the corresponding + Find*() method (in this example, FindBook()) you can retrieve the data. + + BMessage itself is generic, its syntax and semantics are determined by the + context. The Haiku API defines several messages and their required data + members. Several applications provide a scripting interface with defined + message syntax. You can do the same for your application. + + \subsection app_messaging_overview_blooper BLooper + + Objects of the BLooper type are objects that run message loops. Every + object runs in its own thread. The BLooper objects continually check for + incoming messages, and they try to find a BHandler to actually handle the + messages within their thread context. Message handling within a thread is + synchronous. + + BLooper inherits BHandler, the base class for message handling. However, it + is possible to chain additional handlers to the object. For example, if you + have an application that understands different networking protocols, and + you support extensions that understand the base protocol, these extensions + can provide handlers that you can chain in your general message parser + thread. See AddHandler() and SetPreferredHandler() for information on + handlers. + + Messages can be posted to the looper by using the object's PostMessage() + method. This method puts the message in the BMessageQueue of the looper. + Since PostMessage() is asynchronous, the message might not be handled + immediately. See \link app_messaging_overview_bmessenger BMessenger + \endlink for a synchronous implementation. + + Loopers can have a generic filter that discards messages based on + user-definable characteristics. The BMessageFilter class provides the + foundation for the qualifying of messages. See AddCommonFilterList() and + SetCommonFilterList() for more information. + + To get the most out of the functionality of BLooper, it is usually + subclassed to create a self-contained event 'machine'. Most of the time, + these subclasses also perform the message handling, which is possible + due to the fact that it is also a subclass of BHandler. + + In the Haiku API, there are two major classes that inherit BLooper: + the base application class, BApplication, and the window class, BWindow. + Because they inherit BLooper, each application and each window has its + own message loop. This makes every window quick and responsive. To keep + your applications running smoothly, it is advisable to make sure that + event handling that requires more processing power, is done within its own + BLooper context. Networking usually qualifies as a candidate for its own + thread. + + \section app_messaging_overview_bhandler BHandler + + Objects of the BHandler type are associated to BLoopers. When they are + created, they should be passed to the BLooper::AddHandler() method of the + looper they want to handle messages for. They can then either be set as + preferred handlers (by chaining them with BLooper::SetPreferredHandler()), + or they can be added to other BHandlers with the SetNextHandler() method. + + The magic of the class happens in the MessageReceived() method. In your + subclasses you override this method, to check the incoming BMessage. + Usually, you check the \c what member of the message in a switch statement. + If your handler cannot handle the object, it will pass the message on to + the parent class. + + \warning Don't forget to actuall call + baseclass::MessageReceived(). Failing to do this will mean + that the message chain will not completely be followed, which can lead + to unhandled messages. There might be some internal system messages + that the Haiku API classes handle, and not actually handling these + messages could lead to inconsistent internal behavior. + + \section app_messaging-overview-bmessenger BMessenger + + BMessenger objects can send messages to both local and remote targets. For + local targets, a BMessenger provides an advantage over directly calling + the BLooper::PostMessage() method: some variants of the + BMessenger::SendMessage() methods allow for synchronous replies. So, the + call will actually verify the handling thread processes the message, and + reply to the sender. + + The other feature of BMessenger is that it is able to be constructed with + the signature of another application as argument. This allows the messenger + to pass messages to other applications. It facilitates inter-application + communication. + + \section app_messaging-overview-other Other messaging classes + + There are several convenience classes supplied with the application kit, + which can make your life easier in some specific cases. + + * BInvoker binds together a message and a target. By calling + BInvoker::Invoke(), the message will be sent. This class is inherited by + the controls in the interface kit, such as BButton. + * A BMessageRunner object will send messages to a specified target with + specified intervals in between. + * BMessageQueue is a class that is also internally used by BLooper. It + provides a queue of messages, with convenience functions of managing + this queue. + * BMessageFilter is the base class of the filters. Filters can be applied + to BLoopers to filter all incoming messages, or to BHandlers to filter + messages that could be handled by that object. The filter object can be + subclassed and extended by overriding the Filter() method. + + \section app-messaging-receiving Receiving Messages + + To do... + + \section app-messaging-sending Sending Messages + + To do... + +*/ + \ No newline at end of file From axeld at pinc-software.de Tue Sep 18 12:38:04 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 18 Sep 2007 12:38:04 +0200 CEST Subject: [Haiku-commits] r22190 - haiku/trunk/src/kits/tracker In-Reply-To: <200709061040.l86Aem11026056@sheep.berlios.de> Message-ID: <630310662-BeMail@zon> stippi at BerliOS wrote: > Like I said, the code is > a mess and there is not a single place for invalidating poses, so I > am not > surprised why tons of invalidations arrive. :-/ Maybe I should make > myself > more familiar with Tracker... or revert my text outline patch. :-P In any case, the BeOS Tracker is still broken: the symlink underline is still wrong (not dashed), and the column texts are overwritten when "late" results come in in list view mode (ie. you don't follow the order BFS returns the entries). I would guess that at least the latter will also happen in Haiku. So for now, I would really consider to revert the patch for now, and play with it (and the invalidation) in a branch, as suggested by Ryan. Bye, Axel. From korli at mail.berlios.de Tue Sep 18 21:17:13 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:17:13 +0200 Subject: [Haiku-commits] r22241 - haiku/trunk/src/add-ons/kernel/drivers/bus/firewire Message-ID: <200709181917.l8IJHDWC031057@sheep.berlios.de> Author: korli Date: 2007-09-18 21:17:13 +0200 (Tue, 18 Sep 2007) New Revision: 22241 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22241&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c Log: release module on error in init_driver() free devices pointer in uninit_driver() Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c 2007-09-17 21:33:24 UTC (rev 22240) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c 2007-09-18 19:17:13 UTC (rev 22241) @@ -991,8 +991,10 @@ devices_count++; } - if (devices_count <= 0) + if (devices_count <= 0) { + put_module(FIREWIRE_MODULE_NAME); return ENODEV; + } devices = malloc(sizeof(char *) * (devices_count+1)); for (i=0; i Author: rudolfc Date: 2007-09-18 21:21:36 +0200 (Tue, 18 Sep 2007) New Revision: 22242 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22242&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c Log: fixed shared_info problem occuring with the 3D accelerant: the TVencoder list definition is now outside of the definition of shared_info. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-18 19:17:13 UTC (rev 22241) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-18 19:21:36 UTC (rev 22242) @@ -1,7 +1,7 @@ /* Authors: Mark Watson 12/1999, Apsed, - Rudolf Cornelissen 10/2002-4/2006 + Rudolf Cornelissen 10/2002-9/2007 */ #define MODULE_BIT 0x00008000 @@ -91,7 +91,7 @@ { status_t status; - LOG(1,("POWERUP: Haiku nVidia Accelerant 0.81 running.\n")); + LOG(1,("POWERUP: Haiku nVidia Accelerant 0.82 running.\n")); /* log VBLANK INT usability status */ if (si->ps.int_assigned) From rudolfc at mail.berlios.de Tue Sep 18 21:22:08 2007 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Tue, 18 Sep 2007 21:22:08 +0200 Subject: [Haiku-commits] r22243 - haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia Message-ID: <200709181922.l8IJM8A0031711@sheep.berlios.de> Author: rudolfc Date: 2007-09-18 21:22:08 +0200 (Tue, 18 Sep 2007) New Revision: 22243 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22243&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html Log: fixed shared_info problem occuring with the 3D accelerant: updated docs, bumped version to 0.82 Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html 2007-09-18 19:21:36 UTC (rev 22242) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/nvidia/UPDATE.html 2007-09-18 19:22:08 UTC (rev 22243) @@ -4,9 +4,10 @@

Changes done for each driverversion:

-

head (SVN 0.81, Rudolf)

+

head (SVN 0.82, Rudolf)

  • Fixed driver assuming enabling AGP mode succeeded on some occasions if it did not block it itself. Blocking AGP mode completely via the AGP busmanager (option 'block_agp') resulted in a crashing acceleration engine because it was setup for AGP transfers instead of using PCI transfers. Error was solved with help from user kraton. +
  • Fixed shared_info struct problem occuring when 3D 'accelerant' is used (tested Alpha 4.1): the TVencoder type definition list apparantly gets some memory assigned these days when done inside the definition of shared_info. Moved encoder list outside the shared_info definition.

nv_driver 0.80 (Rudolf)

    From rudolfc at mail.berlios.de Tue Sep 18 21:22:44 2007 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Tue, 18 Sep 2007 21:22:44 +0200 Subject: [Haiku-commits] r22244 - haiku/trunk/headers/private/graphics/nvidia Message-ID: <200709181922.l8IJMiE0031752@sheep.berlios.de> Author: rudolfc Date: 2007-09-18 21:22:44 +0200 (Tue, 18 Sep 2007) New Revision: 22244 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22244&view=rev Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h Log: fixed shared_info problem occuring with the 3D accelerant: the TVencoder list definition is now outside of the definition of shared_info. Greetings.. :-) Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-09-18 19:22:08 UTC (rev 22243) +++ haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-09-18 19:22:44 UTC (rev 22244) @@ -5,7 +5,7 @@ Other authors: Mark Watson; Apsed; - Rudolf Cornelissen 10/2002-4/2006. + Rudolf Cornelissen 10/2002-9/2007. */ #ifndef DRIVERINTERFACE_H @@ -117,6 +117,27 @@ NV40A }; +/* card info - information gathered from PINS (and other sources) */ +enum +{ // tv_encoder_type in order of capability (more or less) + NONE = 0, + CH7003, + CH7004, + CH7005, + CH7006, + CH7007, + CH7008, + SAA7102, + SAA7103, + SAA7104, + SAA7105, + BT868, + BT869, + CX25870, + CX25871, + NVIDIA +}; + /* handles to pre-defined engine commands */ #define NV_ROP5_SOLID 0x00000000 /* 2D */ #define NV_IMAGE_BLACK_RECTANGLE 0x00000001 /* 2D/3D */ @@ -301,27 +322,6 @@ } threeD; } engine; - /* card info - information gathered from PINS (and other sources) */ - enum - { // tv_encoder_type in order of capability (more or less) - NONE = 0, - CH7003, - CH7004, - CH7005, - CH7006, - CH7007, - CH7008, - SAA7102, - SAA7103, - SAA7104, - SAA7105, - BT868, - BT869, - CX25870, - CX25871, - NVIDIA - }; - struct { /* specialised registers for card initialisation read from NV BIOS (pins) */ From korli at users.berlios.de Tue Sep 18 21:23:52 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Tue, 18 Sep 2007 21:23:52 +0200 Subject: [Haiku-commits] r22242 - haiku/trunk/src/add-ons/accelerants/nvidia/engine In-Reply-To: <200709181921.l8IJLaiN031540@sheep.berlios.de> References: <200709181921.l8IJLaiN031540@sheep.berlios.de> Message-ID: 2007/9/18, rudolfc at BerliOS : > > Author: rudolfc > Date: 2007-09-18 21:21:36 +0200 (Tue, 18 Sep 2007) > New Revision: 22242 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22242&view=rev > > Modified: > haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c > Welcome back Rudolf ! J?r?me -------------- next part -------------- An HTML attachment was scrubbed... URL: From korli at mail.berlios.de Tue Sep 18 21:26:00 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:26:00 +0200 Subject: [Haiku-commits] r22245 - haiku/trunk/src/add-ons/kernel/drivers/bus/usb Message-ID: <200709181926.l8IJQ0Ti031973@sheep.berlios.de> Author: korli Date: 2007-09-18 21:25:59 +0200 (Tue, 18 Sep 2007) New Revision: 22245 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22245&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp Log: destroy benaphore lock on error in init_driver() Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp 2007-09-18 19:22:44 UTC (rev 22244) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp 2007-09-18 19:25:59 UTC (rev 22245) @@ -590,6 +590,7 @@ result = get_module(B_USB_MODULE_NAME, (module_info **)&gUSBModule); if (result < B_OK) { TRACE((DRIVER_NAME": getting module failed 0x%08lx\n", result)); + benaphore_destroy(&gDeviceListLock); return result; } From korli at mail.berlios.de Tue Sep 18 21:30:21 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:30:21 +0200 Subject: [Haiku-commits] r22246 - haiku/trunk/src/add-ons/kernel/drivers/bus/pcmcia Message-ID: <200709181930.l8IJUKi8032244@sheep.berlios.de> Author: korli Date: 2007-09-18 21:30:20 +0200 (Tue, 18 Sep 2007) New Revision: 22246 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22246&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/pcmcia/ds.c Log: release modules on error in init_driver() free devices pointer in uninit_driver() Modified: haiku/trunk/src/add-ons/kernel/drivers/bus/pcmcia/ds.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/bus/pcmcia/ds.c 2007-09-18 19:25:59 UTC (rev 22245) +++ haiku/trunk/src/add-ons/kernel/drivers/bus/pcmcia/ds.c 2007-09-18 19:30:20 UTC (rev 22246) @@ -23,7 +23,7 @@ #define copy_to_user memcpy #define CardServices gPcmciaCs->_CardServices -const char sockname[] = "bus/pcmcia/sock/%d"; +const char sockname[] = "bus/pcmcia/sock/%ld"; static char ** devices; uint32 devices_count = 0; @@ -369,8 +369,11 @@ devices_count++; } - if (devices_count <= 0) + if (devices_count <= 0) { + put_module(CS_CLIENT_MODULE_NAME); + put_module(DS_MODULE_NAME); return ENODEV; + } devices = malloc(sizeof(char *) * (devices_count+1)); for (i=0; i References: <200709181921.l8IJLaiN031540@sheep.berlios.de> Message-ID: <20070918213642.752.1@cs.tu-berlin.de> On 2007-09-18 at 21:23:52 [+0200], J?r?me Duval wrote: > 2007/9/18, rudolfc at BerliOS : > > > > Author: rudolfc > > Date: 2007-09-18 21:21:36 +0200 (Tue, 18 Sep 2007) > > New Revision: 22242 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22242&view=rev > > > > Modified: > > haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c > > > > Welcome back Rudolf ! Yippie! :-) Welcome back! CU, Ingo From korli at mail.berlios.de Tue Sep 18 21:40:32 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:40:32 +0200 Subject: [Haiku-commits] r22247 - haiku/trunk/src/add-ons/kernel/drivers/misc Message-ID: <200709181940.l8IJeWwW000025@sheep.berlios.de> Author: korli Date: 2007-09-18 21:40:32 +0200 (Tue, 18 Sep 2007) New Revision: 22247 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22247&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/misc/config.c haiku/trunk/src/add-ons/kernel/drivers/misc/poke.c haiku/trunk/src/add-ons/kernel/drivers/misc/test.c Log: remove executable bit on test.c clean up poke.c don't need to check the module in uninit_driver() Modified: haiku/trunk/src/add-ons/kernel/drivers/misc/config.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/misc/config.c 2007-09-18 19:30:20 UTC (rev 22246) +++ haiku/trunk/src/add-ons/kernel/drivers/misc/config.c 2007-09-18 19:40:32 UTC (rev 22247) @@ -159,7 +159,6 @@ void uninit_driver() { - if (gConfigManager != NULL) - put_module(B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME); + put_module(B_CONFIG_MANAGER_FOR_DRIVER_MODULE_NAME); } Modified: haiku/trunk/src/add-ons/kernel/drivers/misc/poke.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/misc/poke.c 2007-09-18 19:30:20 UTC (rev 22246) +++ haiku/trunk/src/add-ons/kernel/drivers/misc/poke.c 2007-09-18 19:40:32 UTC (rev 22247) @@ -31,8 +31,8 @@ device_hooks poke_hooks = { poke_open, - poke_close, - poke_free, + poke_close, + poke_free, poke_control, poke_read, poke_write, @@ -51,14 +51,14 @@ status_t init_hardware(void) { - return B_OK; + return B_OK; } status_t init_driver(void) { - open_count = 0; + open_count = 0; if (get_module(B_ISA_MODULE_NAME, (module_info**)&isa) < B_OK) return ENOSYS; @@ -68,7 +68,7 @@ return ENOSYS; } - return B_OK; + return B_OK; } @@ -83,7 +83,7 @@ const char** publish_devices(void) { - return poke_name; + return poke_name; } @@ -101,29 +101,29 @@ status_t poke_open(const char* name, uint32 flags, void** cookie) { - *cookie = NULL; + *cookie = NULL; - if (atomic_add(&open_count, 1) != 0) { - atomic_add(&open_count, -1); - return B_BUSY; - } + if (atomic_add(&open_count, 1) != 0) { + atomic_add(&open_count, -1); + return B_BUSY; + } - return B_OK; + return B_OK; } status_t poke_close(void* cookie) { - return B_OK; + return B_OK; } status_t poke_free(void* cookie) { - atomic_add(&open_count, -1); - return B_OK; + atomic_add(&open_count, -1); + return B_OK; } Property changes on: haiku/trunk/src/add-ons/kernel/drivers/misc/test.c ___________________________________________________________________ Name: svn:executable - * From korli at mail.berlios.de Tue Sep 18 21:51:27 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:51:27 +0200 Subject: [Haiku-commits] r22248 - haiku/trunk/src/add-ons/kernel/drivers/audio/echo Message-ID: <200709181951.l8IJpRFf000789@sheep.berlios.de> Author: korli Date: 2007-09-18 21:51:27 +0200 (Tue, 18 Sep 2007) New Revision: 22248 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22248&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp Log: clean up Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2007-09-18 19:40:32 UTC (rev 22247) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/echo/echo.cpp 2007-09-18 19:51:27 UTC (rev 22248) @@ -68,7 +68,6 @@ }; #else // CARDBUS -static char pci_name[] = B_PCI_MODULE_NAME; static pci_module_info *pci; int32 num_cards; echo_dev cards[NUM_CARDS]; @@ -470,7 +469,7 @@ PRINT(("init_hardware()\n")); - if (get_module(pci_name, (module_info **)&pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -508,7 +507,7 @@ ix++; } - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); if(err!=B_OK) { PRINT(("no card found\n")); @@ -560,31 +559,27 @@ // Get card services client module if (get_module(CB_ENABLER_MODULE_NAME, (module_info **)&cbemi) != B_OK) { dprintf(DRIVER_NAME ": cardbus enabler module error\n"); - goto cb_error; + return B_ERROR; } // Create the devices lock device_lock = create_sem(1, DRIVER_NAME " device"); if (device_lock < B_OK) { dprintf(DRIVER_NAME ": create device semaphore error 0x%.8x\n", device_lock); - put_module(CB_ENABLER_MODULE_NAME); - goto cb_error; + put_module(CB_ENABLER_MODULE_NAME); + return B_ERROR; } - // Register driver - cbemi->register_driver(DRIVER_NAME, descriptors, COUNT_DESCRIPTOR); - cbemi->install_notify(DRIVER_NAME, &cardbus_hooks); - LIST_INIT(&(devices)); - return B_OK; - -cb_error: - put_module(B_PCI_MODULE_NAME); - return B_ERROR; + // Register driver + cbemi->register_driver(DRIVER_NAME, descriptors, COUNT_DESCRIPTOR); + cbemi->install_notify(DRIVER_NAME, &cardbus_hooks); + LIST_INIT(&(devices)); + return B_OK; #else int ix=0; pci_info info; num_cards = 0; - if (get_module(pci_name, (module_info **) &pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -635,7 +630,7 @@ } if (!num_cards) { PRINT(("no cards\n")); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); PRINT(("no suitable cards found\n")); return ENODEV; } @@ -922,7 +917,7 @@ } memset(&cards, 0, sizeof(cards)); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); #endif } From korli at mail.berlios.de Tue Sep 18 21:54:13 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 18 Sep 2007 21:54:13 +0200 Subject: [Haiku-commits] r22249 - haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki Message-ID: <200709181954.l8IJsDbQ000948@sheep.berlios.de> Author: korli Date: 2007-09-18 21:54:12 +0200 (Tue, 18 Sep 2007) New Revision: 22249 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22249&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c Log: clean up Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-09-18 19:51:27 UTC (rev 22248) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-09-18 19:54:12 UTC (rev 22249) @@ -66,9 +66,7 @@ const char ** publish_devices(void); device_hooks * find_device(const char *); -static char pci_name[] = B_PCI_MODULE_NAME; pci_module_info *pci; -static char mpu401_name[] = B_MPU_401_MODULE_NAME; generic_mpu401_module * mpu401; @@ -1996,7 +1994,7 @@ PRINT(("init_hardware()\n")); - if (get_module(pci_name, (module_info **)&pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -2011,7 +2009,7 @@ ix++; } - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); return err; } @@ -2776,11 +2774,11 @@ unload_driver_settings (settings_handle); } - if (get_module(pci_name, (module_info **) &pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci)) return ENOSYS; - if (get_module(mpu401_name, (module_info **) &mpu401)) { - put_module(pci_name); + if (get_module(B_MPU_401_MODULE_NAME, (module_info **) &mpu401)) { + put_module(B_PCI_MODULE_NAME); return ENOSYS; } @@ -2807,8 +2805,8 @@ ix++; } if (!num_cards) { - put_module(mpu401_name); - put_module(pci_name); + put_module(B_MPU_401_MODULE_NAME); + put_module(B_PCI_MODULE_NAME); PRINT(("emuxki: no suitable cards found\n")); return ENODEV; } @@ -2895,8 +2893,8 @@ emuxki_shutdown(&cards[ix]); } memset(&cards, 0, sizeof(cards)); - put_module(mpu401_name); - put_module(pci_name); + put_module(B_MPU_401_MODULE_NAME); + put_module(B_PCI_MODULE_NAME); num_cards = 0; } From superstippi at gmx.de Tue Sep 18 23:05:19 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Tue, 18 Sep 2007 23:05:19 +0200 Subject: [Haiku-commits] r22242 - haiku/trunk/src/add-ons/accelerants/nvidia/engine In-Reply-To: <20070918213642.752.1@cs.tu-berlin.de> References: <200709181921.l8IJLaiN031540@sheep.berlios.de> <20070918213642.752.1@cs.tu-berlin.de> Message-ID: <20070918230519.7694.1@stippis2.1190139993.fake> Ingo Weinhold wrote (2007-09-18, 21:36:42 [+0200]): > > On 2007-09-18 at 21:23:52 [+0200], J?r?me Duval > wrote: > > 2007/9/18, rudolfc at BerliOS : > > > > > > Author: rudolfc > > > Date: 2007-09-18 21:21:36 +0200 (Tue, 18 Sep 2007) New Revision: 22242 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22242&view=rev > > > > > > Modified: > > > haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c > > > > > > > Welcome back Rudolf ! > > Yippie! :-) > Welcome back! Awesome! Welcome back, Rudolf! -Stephan From jackburton at mail.berlios.de Tue Sep 18 23:19:55 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 18 Sep 2007 23:19:55 +0200 Subject: [Haiku-commits] r22250 - haiku/trunk/src/apps/terminal Message-ID: <200709182119.l8ILJt0K005680@sheep.berlios.de> Author: jackburton Date: 2007-09-18 23:19:54 +0200 (Tue, 18 Sep 2007) New Revision: 22250 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22250&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Finally got rid of the mouse tracking thread. Put the code inside MouseMoved(). Everything _seems_ to work like it did before, but there might be some regressions... Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-09-18 19:54:12 UTC (rev 22249) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-09-18 21:19:54 UTC (rev 22250) @@ -101,8 +101,6 @@ }; - -#define MOUSE_THR_CODE 'mtcd' #define ROWS_DEFAULT 25 #define COLUMNS_DEFAULT 80 @@ -173,8 +171,6 @@ fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), - fMouseThread(-1), - fQuitting(false), fIMflag(false) { _InitObject(argc, argv); @@ -223,8 +219,6 @@ fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), - fMouseThread(-1), - fQuitting(false), fIMflag(false) { _InitObject(argc, argv); @@ -274,8 +268,6 @@ fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), - fMouseThread(-1), - fQuitting(false), fIMflag(false) { if (archive->FindInt32("encoding", (int32 *)&fEncoding) < B_OK) @@ -322,8 +314,6 @@ SetTermSize(fTermRows, fTermColumns, false); //SetIMAware(false); - - _InitMouseThread(); return B_OK; } @@ -338,9 +328,6 @@ delete fTextBuffer; delete shell; - - fQuitting = true; - kill_thread(fMouseThread); } @@ -1135,120 +1122,6 @@ } -status_t -TermView::_InitMouseThread() -{ - // spawn Mouse Tracking thread. - if (fMouseThread < 0) { - fMouseThread = spawn_thread(_MouseTrackingEntryFunction, "MouseTracking", - B_NORMAL_PRIORITY,this); - } else - return B_BAD_THREAD_ID; - - return resume_thread(fMouseThread); -} - - -/* static */ -int32 -TermView::_MouseTrackingEntryFunction(void *data) -{ - return static_cast(data)->_MouseTracking(); -} - - -//! Thread for tracking mouse. -int32 -TermView::_MouseTracking() -{ - int32 code, selected = false; - uint32 button; - thread_id sender; - CurPos stpos, edpos; - BPoint stpoint, edpoint; - float scr_start, scr_end, scr_pos; - - while(!fQuitting) { - code = receive_data(&sender,(void *)&stpoint, sizeof(BPoint)); - if (code != MOUSE_THR_CODE) - continue; - - selected = _HasSelection(); - edpoint.Set(-1, -1); - - stpos = _BPointToCurPos(stpoint); - - do { - snooze(40000); - - if (LockLooper()) { - GetMouse(&edpoint, &button); - UnlockLooper(); - } - - edpos = _BPointToCurPos(edpoint); - if (edpos.y < 0) - continue; - - if (stpoint == edpoint) { - continue; - } else { - if (!selected) { - _Select(stpos, edpos); - selected = true; - } else { - - // Align cursor point to text. - if (stpos == edpos) - continue; - - if (edpos > stpos) { - edpoint.x -= fFontWidth / 2; - edpos = _BPointToCurPos(edpoint); - //edpos.x--; - if (edpos.x < 0) - edpos.x = 0; - } - else - if (edpos < stpos) { - edpoint.x += fFontWidth / 2; - edpos = _BPointToCurPos(edpoint); - //edpos.x++; - if (edpos.x > fTermColumns) - edpos.x = fTermColumns; - } - - // Scroll check - if (fScrollBar != NULL && LockLooper()) { - // Get now scroll point - fScrollBar->GetRange(&scr_start, &scr_end); - scr_pos = fScrollBar->Value(); - - if (edpoint.y < Bounds().LeftTop().y ) - - // mouse point left of window - if (scr_pos != scr_start) - ScrollTo(0, edpoint.y); - - if (edpoint.y > Bounds().LeftBottom().y) { - - // mouse point left of window - if (scr_pos != scr_end) - ScrollTo(0, edpoint.y); - } - UnlockLooper(); - } - _ResizeSelectRegion(edpos); - } - } - } while(button); - fMouseTracking = false; - } - - return 0; -} - - //! Draw character on offscreen bitmap. void TermView::_DrawLines(int x1, int y1, ushort attr, uchar *buf, @@ -2011,10 +1884,14 @@ } // If mouse has a lot of movement, disable double/triple click. - BPoint inPoint = fPreviousMousePoint - where; + /*BPoint inPoint = fPreviousMousePoint - where; if (abs((int)inPoint.x) > 16 || abs((int)inPoint.y) > 16) clicks = 1; - + */ + + SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, + B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); + fPreviousMousePoint = where; if (mod & B_SHIFT_KEY) @@ -2031,7 +1908,6 @@ switch (clicks) { case 1: fMouseTracking = true; - send_data(fMouseThread, MOUSE_THR_CODE, (void *)&where, sizeof(BPoint)); break; case 2: @@ -2053,13 +1929,70 @@ TermView::MouseMoved(BPoint where, uint32 transit, const BMessage *message) { BView::MouseMoved(where, transit, message); + if (!fMouseTracking) + return; + + bool selected = _HasSelection(); + + //int32 button; + //Window()->CurrentMessage()->FindInt32("buttons", &button); + + CurPos startPos = _BPointToCurPos(fPreviousMousePoint); + CurPos endPos = _BPointToCurPos(where); + if (endPos.y < 0) + return; + + if (!selected) { + _Select(startPos, endPos); + selected = true; + } else { + // Align cursor point to text. + if (startPos == endPos) + return; + + if (endPos > startPos) { + where.x -= fFontWidth / 2; + endPos = _BPointToCurPos(where); + //edpos.x--; + if (endPos.x < 0) + endPos.x = 0; + } else if (endPos < startPos) { + where.x += fFontWidth / 2; + endPos = _BPointToCurPos(where); + //edpos.x++; + if (endPos.x > fTermColumns) + endPos.x = fTermColumns; + } + + // Scroll check + if (fScrollBar != NULL) { + // Get now scroll point + float scrollStart, scrollEnd; + fScrollBar->GetRange(&scrollStart, &scrollEnd); + float scrollPos = fScrollBar->Value(); + + if (where.y < Bounds().LeftTop().y ) { + // mouse point left of window + if (scrollPos != scrollStart) + ScrollTo(0, where.y); + } + + if (where.y > Bounds().LeftBottom().y) { + // mouse point left of window + if (scrollPos != scrollEnd) + ScrollTo(0, where.y); + } + } + _ResizeSelectRegion(endPos); + } } void TermView::MouseUp(BPoint where) { - + BView::MouseUp(where); + fMouseTracking = false; } Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-09-18 19:54:12 UTC (rev 22249) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-09-18 21:19:54 UTC (rev 22250) @@ -192,9 +192,6 @@ static void _FixFontAttributes(BFont &font); - static int32 _MouseTrackingEntryFunction(void *); - int32 _MouseTracking(); - Shell *fShell; BMessageRunner *fWinchRunner; @@ -269,10 +266,6 @@ CurPos fSelEnd; bool fMouseTracking; - // thread ID / flags. - thread_id fMouseThread; - bool fQuitting; - // Input Method parameter. int fIMViewPtr; CurPos fIMStartPos; From stippi at mail.berlios.de Wed Sep 19 09:12:10 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 19 Sep 2007 09:12:10 +0200 Subject: [Haiku-commits] r22251 - haiku/trunk/src/preferences/time Message-ID: <200709190712.l8J7CAOs001813@sheep.berlios.de> Author: stippi Date: 2007-09-19 09:12:08 +0200 (Wed, 19 Sep 2007) New Revision: 22251 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22251&view=rev Modified: haiku/trunk/src/preferences/time/SettingsView.cpp haiku/trunk/src/preferences/time/SettingsView.h Log: patch by Julun: * write the RTC settings (GMT versus Local time) * small cleanups Modified: haiku/trunk/src/preferences/time/SettingsView.cpp =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-18 21:19:54 UTC (rev 22250) +++ haiku/trunk/src/preferences/time/SettingsView.cpp 2007-09-19 07:12:08 UTC (rev 22251) @@ -23,18 +23,21 @@ #include #include +#include +#include TSettingsView::TSettingsView(BRect frame) - : BView(frame,"Settings", B_FOLLOW_ALL, + : BView(frame,"Settings", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP), fGmtTime(NULL) -{ +{ InitView(); } - + TSettingsView::~TSettingsView() { + WriteRTCSettings(); } @@ -58,13 +61,13 @@ case H_TM_CHANGED: UpdateDateTime(message); break; - + default: BView::MessageReceived(message); break; } break; - + default: BView::MessageReceived(message); break; @@ -91,7 +94,7 @@ TSettingsView::InitView() { ReadRTCSettings(); - + font_height fontHeight; be_plain_font->GetHeight(&fontHeight); float textHeight = fontHeight.descent + fontHeight.ascent + fontHeight.leading; @@ -125,13 +128,13 @@ float left = fTimeEdit->Frame().left; float tmp = MIN(frameRight.Width(), frameRight.Height()); - frameRight.left = left + (fTimeEdit->Bounds().Width() - tmp) /2; + frameRight.left = left + (fTimeEdit->Bounds().Width() - tmp) /2; frameRight.bottom = frameRight.top + tmp; frameRight.right = frameRight.left + tmp; - + fClock = new TAnalogClock(frameRight, "analog clock", B_FOLLOW_NONE, B_WILL_DRAW); AddChild(fClock); - + // clock radio buttons frameRight.left = left; frameRight.top = fClock->Frame().bottom + 10; @@ -139,7 +142,7 @@ AddChild(text); text->ResizeToPreferred(); - frameRight.left += 10.0f; + frameRight.left += 10.0f; frameRight.top = text->Frame().bottom + 5; fLocalTime = new BRadioButton(frameRight, "local", "Local time", @@ -165,21 +168,21 @@ { //draw a separator line BRect bounds(Bounds()); - + rgb_color viewcolor = ViewColor(); rgb_color dark = tint_color(viewcolor, B_DARKEN_4_TINT); rgb_color light = tint_color(viewcolor, B_LIGHTEN_MAX_TINT); BPoint start(bounds.Width() / 2.0f +2.0f, bounds.top +1.0f); BPoint end(bounds.Width() / 2.0 +2.0f, bounds.bottom -1.0f); - + BeginLineArray(2); AddLine(start, end, dark); start.x++; end.x++; AddLine(start, end, light); EndLineArray(); - + fTimeEdit->Draw(bounds); fDateEdit->Draw(bounds); } @@ -195,7 +198,7 @@ void TSettingsView::UpdateDateTime(BMessage *message) { - int32 day; + int32 day; int32 month; int32 year; if (message->FindInt32("month", &month) == B_OK @@ -205,7 +208,7 @@ fDateEdit->SetDate(year, month, day); fCalendar->SetTo(year, month, day); } - + int32 hour; int32 minute; int32 second; @@ -227,7 +230,7 @@ return; path.Append("RTC_time_settings"); - + BFile file; BEntry entry(path.Path()); if (entry.Exists()) { @@ -236,7 +239,7 @@ char localTime[6]; file.Read(localTime, 6); BString text(localTime); - if (text.Compare("local\n", 5) == 0) + if (text.Compare("local", 4) == 0) fIsLocalTime = true; else fIsLocalTime = false; @@ -245,7 +248,25 @@ // create set to local fIsLocalTime = true; file.SetTo(&entry, B_CREATE_FILE | B_READ_WRITE); - file.Write("local\n", 6); + file.Write("local", 5); } } + +void +TSettingsView::WriteRTCSettings() +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + return; + + path.Append("RTC_time_settings"); + + BFile file(path.Path(), B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY); + if (file.InitCheck() == B_OK) { + if (fLocalTime->Value() == B_CONTROL_ON) + file.Write("local", 5); + else + file.Write("gmt", 3); + } +} Modified: haiku/trunk/src/preferences/time/SettingsView.h =================================================================== --- haiku/trunk/src/preferences/time/SettingsView.h 2007-09-18 21:19:54 UTC (rev 22250) +++ haiku/trunk/src/preferences/time/SettingsView.h 2007-09-19 07:12:08 UTC (rev 22251) @@ -25,18 +25,18 @@ public: TSettingsView(BRect frame); virtual ~TSettingsView(); - + virtual void AttachedToWindow(); virtual void Draw(BRect updaterect); virtual void MessageReceived(BMessage *message); virtual void GetPreferredSize(float *width, float *height); - void ChangeRTCSetting(); bool GMTime(); private: void InitView(); void ReadRTCSettings(); + void WriteRTCSettings(); void UpdateDateTime(BMessage *message); BRadioButton *fLocalTime; From rudolfc at mail.berlios.de Wed Sep 19 09:16:07 2007 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Wed, 19 Sep 2007 09:16:07 +0200 Subject: [Haiku-commits] r22252 - haiku/trunk/src/add-ons/accelerants/nvidia/engine Message-ID: <200709190716.l8J7G7G3002013@sheep.berlios.de> Author: rudolfc Date: 2007-09-19 09:16:07 +0200 (Wed, 19 Sep 2007) New Revision: 22252 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22252&view=rev Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c Log: changed listing order of two recently added cards for me to keep oversight. No functional change. Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-19 07:12:08 UTC (rev 22251) +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_general.c 2007-09-19 07:16:07 UTC (rev 22252) @@ -765,7 +765,6 @@ status = nvxx_general_powerup(); break; case 0x024210de: /* Nvidia GeForce 6100 (NFORCE4 Integr.GPU) */ - case 0x03d110de: /* Nvidia GeForce 6100 nForce 405 */ si->ps.card_type = NV44; si->ps.card_arch = NV40A; sprintf(si->adi.name, "Nvidia GeForce 6100"); @@ -845,6 +844,13 @@ sprintf(si->adi.chipset, "XBOX, NV20"); status = nvxx_general_powerup(); break; + case 0x02e110de: + si->ps.card_type = G73; + si->ps.card_arch = NV40A; + sprintf(si->adi.name, "Nvidia GeForce 7600 GS"); + sprintf(si->adi.chipset, "G73"); + status = nvxx_general_powerup(); + break; case 0x030110de: /* Nvidia GeForce FX 5800 Ultra */ case 0x030210de: /* Nvidia GeForce FX 5800 */ si->ps.card_type = NV30; @@ -1121,7 +1127,6 @@ status = nvxx_general_powerup(); break; case 0x039210de: /* Nvidia GeForce 7600 GS */ - case 0x02e110de: si->ps.card_type = G73; si->ps.card_arch = NV40A; sprintf(si->adi.name, "Nvidia GeForce 7600 GS"); @@ -1143,6 +1148,13 @@ sprintf(si->adi.chipset, "G73"); status = nvxx_general_powerup(); break; + case 0x03d110de: /* Nvidia GeForce 6100 nForce 405 */ + si->ps.card_type = NV44; + si->ps.card_arch = NV40A; + sprintf(si->adi.name, "Nvidia GeForce 6100"); + sprintf(si->adi.chipset, "NV44"); + status = nvxx_general_powerup(); + break; /* Vendor Elsa GmbH */ case 0x0c601048: /* Elsa Gladiac Geforce2 MX */ si->ps.card_type = NV11; From axeld at mail.berlios.de Wed Sep 19 17:07:59 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 19 Sep 2007 17:07:59 +0200 Subject: [Haiku-commits] r22253 - haiku/trunk/src/add-ons/accelerants/intel_extreme Message-ID: <200709191507.l8JF7xAt000880@sheep.berlios.de> Author: axeld Date: 2007-09-19 17:07:58 +0200 (Wed, 19 Sep 2007) New Revision: 22253 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22253&view=rev Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp Log: * No longer switch between divisor register set 0 and 1; it doesn't really make any sense. * "pll" might have been set incorrectly on i8xx chips. Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp 2007-09-19 07:16:07 UTC (rev 22252) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp 2007-09-19 15:07:58 UTC (rev 22253) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -109,6 +109,9 @@ enable_display_plane(false); enable_display_pipe(false); } + + read32(INTEL_DISPLAY_A_BASE); + // flush the eventually cached PCI bus writes } Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-09-19 07:16:07 UTC (rev 22252) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-09-19 15:07:58 UTC (rev 22253) @@ -432,24 +432,17 @@ pll_divisors divisors; compute_pll_divisors(target, divisors); - // switch divisor register with every mode change (not required) - uint32 divisorRegister; - if (gInfo->shared_info->pll_info.divisor_register == INTEL_DISPLAY_A_PLL_DIVISOR_0) - divisorRegister = INTEL_DISPLAY_A_PLL_DIVISOR_1; - else - divisorRegister = INTEL_DISPLAY_A_PLL_DIVISOR_0; - - write32(divisorRegister, + write32(INTEL_DISPLAY_A_PLL_DIVISOR_0, (((divisors.n - 2) << DISPLAY_PLL_N_DIVISOR_SHIFT) & DISPLAY_PLL_N_DIVISOR_MASK) | (((divisors.m1 - 2) << DISPLAY_PLL_M1_DIVISOR_SHIFT) & DISPLAY_PLL_M1_DIVISOR_MASK) | (((divisors.m2 - 2) << DISPLAY_PLL_M2_DIVISOR_SHIFT) & DISPLAY_PLL_M2_DIVISOR_MASK)); uint32 pll = DISPLAY_PLL_ENABLED | DISPLAY_PLL_NO_VGA_CONTROL; if ((gInfo->shared_info->device_type & INTEL_TYPE_9xx) != 0) { -// pll |= ((1 << (divisors.post1 - 1)) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) -// & DISPLAY_PLL_9xx_POST1_DIVISOR_MASK; - pll |= ((divisors.post1 - 1) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) + pll |= ((1 << (divisors.post1 - 1)) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) & DISPLAY_PLL_9xx_POST1_DIVISOR_MASK; +// pll |= ((divisors.post1 - 1) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) +// & DISPLAY_PLL_9xx_POST1_DIVISOR_MASK; if (divisors.post2_high) pll |= DISPLAY_PLL_DIVIDE_HIGH; @@ -460,13 +453,16 @@ } else { if (divisors.post2_high) pll |= DISPLAY_PLL_DIVIDE_4X; + pll |= DISPLAY_PLL_2X_CLOCK; - pll |= (((divisors.post1 - 2) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) - & DISPLAY_PLL_POST1_DIVISOR_MASK); + + if (divisors.post1 > 2) { + pll |= (((divisors.post1 - 2) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) + & DISPLAY_PLL_POST1_DIVISOR_MASK); + } else + pll |= DISPLAY_PLL_POST1_DIVIDE_2; } - pll |= (divisorRegister == INTEL_DISPLAY_A_PLL_DIVISOR_1 ? DISPLAY_PLL_DIVISOR_1 : 0); - debug_printf("PLL is %#lx, write: %#lx\n", read32(INTEL_DISPLAY_A_PLL), pll); write32(INTEL_DISPLAY_A_PLL, pll); #if 0 From rudolfc at mail.berlios.de Wed Sep 19 19:17:31 2007 From: rudolfc at mail.berlios.de (rudolfc at BerliOS) Date: Wed, 19 Sep 2007 19:17:31 +0200 Subject: [Haiku-commits] r22254 - haiku/trunk/headers/private/graphics/nvidia Message-ID: <200709191717.l8JHHVh1016955@sheep.berlios.de> Author: rudolfc Date: 2007-09-19 19:17:22 +0200 (Wed, 19 Sep 2007) New Revision: 22254 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22254&view=rev Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h haiku/trunk/headers/private/graphics/nvidia/nv_acc.h Log: added some defines for NV50 arch, G8x. Removed the comment indicating difference between TNT and GF style setup for 3D: that's not really there. Judging from Nouveau it's still the same setup (more or less), there are just some new commands including TNL. Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-09-19 15:07:58 UTC (rev 22253) +++ haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h 2007-09-19 17:17:22 UTC (rev 22254) @@ -105,7 +105,10 @@ G70, G71, G72, - G73 + G73, + G80, + G84, + G86 }; /* card_arch in order of date of NV chip design */ @@ -114,7 +117,8 @@ NV10A, NV20A, NV30A, - NV40A + NV40A, + NV50A }; /* card info - information gathered from PINS (and other sources) */ Modified: haiku/trunk/headers/private/graphics/nvidia/nv_acc.h =================================================================== --- haiku/trunk/headers/private/graphics/nvidia/nv_acc.h 2007-09-19 15:07:58 UTC (rev 22253) +++ haiku/trunk/headers/private/graphics/nvidia/nv_acc.h 2007-09-19 17:17:22 UTC (rev 22254) @@ -299,17 +299,13 @@ #define NV_SCALED_IMAGE_FROM_MEMORY_SOURCESIZE 0x0400 -/***************************************** - * 3D specific commands, TNT style setup * - *****************************************/ +/************************ + * 3D specific commands * + ************************/ #define NV4_DX5_TEXTURE_TRIANGLE_COLORKEY 0x0300 #define NV4_DX5_TEXTURE_TRIANGLE_TLVERTEX(i) 0x0400 + (i << 5) #define NV4_DX5_TEXTURE_TRIANGLE_TLVDRAWPRIM(i) 0x0600 + (i << 2) #define NV4_CONTEXT_SURFACES_ARGB_ZS_PITCH 0x0308 -/********************************************* - * 3D specific commands, GeForce style setup * - *********************************************/ - #endif From axeld at mail.berlios.de Wed Sep 19 20:52:55 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 19 Sep 2007 20:52:55 +0200 Subject: [Haiku-commits] r22255 - haiku/trunk/headers/private/graphics/intel_extreme Message-ID: <200709191852.l8JIqt3B005159@sheep.berlios.de> Author: axeld Date: 2007-09-19 20:52:55 +0200 (Wed, 19 Sep 2007) New Revision: 22255 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22255&view=rev Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h Log: Forgot to commit the header... Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h =================================================================== --- haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-09-19 17:17:22 UTC (rev 22254) +++ haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-09-19 18:52:55 UTC (rev 22255) @@ -223,6 +223,7 @@ #define DISPLAY_PLL_MODE_ANALOG (1UL << 26) #define DISPLAY_PLL_DIVIDE_HIGH (1UL << 24) #define DISPLAY_PLL_DIVIDE_4X (1UL << 23) +#define DISPLAY_PLL_POST1_DIVIDE_2 (1UL << 21) #define DISPLAY_PLL_POST1_DIVISOR_MASK 0x001f0000 #define DISPLAY_PLL_9xx_POST1_DIVISOR_MASK 0x00ff0000 #define DISPLAY_PLL_POST1_DIVISOR_SHIFT 16 From bonefish at mail.berlios.de Wed Sep 19 22:14:51 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 19 Sep 2007 22:14:51 +0200 Subject: [Haiku-commits] r22256 - haiku/trunk/src/tools/fs_shell Message-ID: <200709192014.l8JKEpC3014349@sheep.berlios.de> Author: bonefish Date: 2007-09-19 22:14:50 +0200 (Wed, 19 Sep 2007) New Revision: 22256 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22256&view=rev Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp Log: Stricter limit for the number of unused vnodes. The fs_shell doesn't really manage memory, so one could easily run out of memory when copying large files. Modified: haiku/trunk/src/tools/fs_shell/vfs.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/vfs.cpp 2007-09-19 18:52:55 UTC (rev 22255) +++ haiku/trunk/src/tools/fs_shell/vfs.cpp 2007-09-19 20:14:50 UTC (rev 22256) @@ -49,7 +49,7 @@ namespace FSShell { -const static uint32_t kMaxUnusedVnodes = 1024; +const static uint32_t kMaxUnusedVnodes = 16; // This is the maximum number of unused vnodes that the system // will keep around (weak limit, if there is enough memory left, // they won't get flushed even when hitting that limit). From marcusoverhagen at mail.berlios.de Wed Sep 19 22:21:32 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 19 Sep 2007 22:21:32 +0200 Subject: [Haiku-commits] r22257 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709192021.l8JKLWTF014822@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-19 22:21:31 +0200 (Wed, 19 Sep 2007) New Revision: 22257 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22257&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c Log: Setup command list, command table, FIS and PRDT pointers. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-19 20:14:50 UTC (rev 22256) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-19 20:21:31 UTC (rev 22257) @@ -113,6 +113,62 @@ } ahci_hba; +typedef struct { + uint8 dsfis[0x1c]; // DMA Setup FIS + uint8 res1[0x04]; + uint8 psfis[0x14]; // PIO Setup FIS + uint8 res2[0x0c]; + uint8 rfis[0x20]; // D2H Register FIS + uint8 res3[0x04]; + uint8 sdbfis[0x08]; // Set Device Bits FIS + uint8 ufis[0x40]; // Unknown FIS + uint8 res4[0x60]; +} fis; + + +typedef struct { + union { + struct { + uint16 prdtl; // physical region description table length; + uint16 pmp : 4; // Port Multiplier Port + uint16 : 1; + uint16 c : 1; // Clear Busy upon R_OK + uint16 b : 1; // Build In Self Test + uint16 r : 1; // Reset + uint16 p : 1; // Prefetchable + uint16 w : 1; // Write + uint16 a : 1;// ATAPI + uint16 cfl : 5; // command FIS length + }; + uint32 prdtl_flags_cfl; + }; + uint32 ctba; // command table desciptor base address (alignment 128 byte) + uint32 ctbau; // command table desciptor base address upper + uint8 res1[0x10]; +} command_list_entry; + +#define COMMAND_LIST_ENTRY_COUNT 32 + +typedef struct { + uint32 dba; // Data Base Address (2-byte aligned) + uint32 dbau; // Data Base Address Upper + uint32 res; + uint32 dbc; // Bytecount (0-based, even, max 4MB) + #define DBC_I 0x80000000 /* Interrupt on completition */ +} prd; + + +typedef struct { + uint8 cfis[0x40]; // command FIS + uint8 acmd[0x20]; // ATAPI command + uint8 res[0x20]; // reserved +} command_table; + + +#define PRD_TABLE_ENTRY_COUNT 168 + + + extern scsi_sim_interface gAHCISimInterface; extern device_manager_info *gDeviceManager; extern pci_device_module_info *gPCI; Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-19 20:14:50 UTC (rev 22256) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-19 20:21:31 UTC (rev 22257) @@ -9,6 +9,7 @@ #include #include +#include #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a) #define FLOW(a...) dprintf("ahci: " a) @@ -32,28 +33,36 @@ { TRACE("AHCIPort::Init port %d\n", fIndex); - size_t size = 999; + size_t size = sizeof(command_list_entry) * COMMAND_LIST_ENTRY_COUNT + sizeof(fis) + sizeof(command_table) + sizeof(prd) * PRD_TABLE_ENTRY_COUNT; - void *virtAddr; - void *physAddr; + char *virtAddr; + char *physAddr; - fArea = alloc_mem(&virtAddr, &physAddr, size, 0, "some AHCI port"); + fArea = alloc_mem((void **)&virtAddr, (void **)&physAddr, size, 0, "some AHCI port"); if (fArea < B_OK) { TRACE("failed allocating memory for port %d\n", fIndex); return fArea; } + memset(virtAddr, 0, size); - void *virtClbAddr; - void *physClbAddr = physAddr; - void *virtFisAddr; - void *physFisAddr = (char *)physAddr + 1024; + fCommandList = (command_list_entry *)virtAddr; + virtAddr += sizeof(command_list_entry) * COMMAND_LIST_ENTRY_COUNT; + fFIS = (fis *)virtAddr; + virtAddr += sizeof(fis); + fCommandTable = (command_table *)virtAddr; + virtAddr += sizeof(command_table); + fPRDTable = (prd *)virtAddr; + + fRegs->clb = LO32(physAddr); + fRegs->clbu = HI32(physAddr); + physAddr += sizeof(command_list_entry) * COMMAND_LIST_ENTRY_COUNT; + fRegs->fb = LO32(physAddr); + fRegs->fbu = HI32(physAddr); + physAddr += sizeof(fis); + fCommandList[0].ctba = LO32(physAddr); + fCommandList[0].ctbau = HI32(physAddr); + // prdt follows after command table - - fRegs->clb = LO32(physClbAddr); - fRegs->clbu = HI32(physClbAddr); - fRegs->fb = LO32(physFisAddr); - fRegs->fbu = HI32(physFisAddr); - return B_OK; } Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-19 20:14:50 UTC (rev 22256) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h 2007-09-19 20:21:31 UTC (rev 22257) @@ -30,7 +30,12 @@ private: int fIndex; volatile ahci_port * fRegs; -area_id fArea; + area_id fArea; + + volatile fis * fFIS; + volatile command_list_entry * fCommandList; + volatile command_table * fCommandTable; + volatile prd * fPRDTable; }; #endif // _AHCI_PORT_H Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2007-09-19 20:14:50 UTC (rev 22256) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c 2007-09-19 20:21:31 UTC (rev 22257) @@ -40,7 +40,6 @@ ERROR("couldn't get mapping for %s\n", name); return B_ERROR; } - memset(virtadr, 0, size); if (virt) *virt = virtadr; if (phy) From korli at mail.berlios.de Wed Sep 19 23:43:42 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 19 Sep 2007 23:43:42 +0200 Subject: [Haiku-commits] r22258 - in haiku/trunk/src/add-ons/kernel/drivers/graphics: neomagic s3savage Message-ID: <200709192143.l8JLhg6A021006@sheep.berlios.de> Author: korli Date: 2007-09-19 23:43:42 +0200 (Wed, 19 Sep 2007) New Revision: 22258 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22258&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/neomagic/driver.c haiku/trunk/src/add-ons/kernel/drivers/graphics/s3savage/driver.c Log: style fix Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/neomagic/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/neomagic/driver.c 2007-09-19 20:21:31 UTC (rev 22257) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/neomagic/driver.c 2007-09-19 21:43:42 UTC (rev 22258) @@ -266,8 +266,7 @@ return B_ERROR; /* get a handle for the isa bus */ - if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa_bus) != B_OK) - { + if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa_bus) != B_OK) { put_module(B_PCI_MODULE_NAME); return B_ERROR; } Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/s3savage/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/s3savage/driver.c 2007-09-19 20:21:31 UTC (rev 22257) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/s3savage/driver.c 2007-09-19 21:43:42 UTC (rev 22258) @@ -293,7 +293,7 @@ void - uninit_driver(void) +uninit_driver(void) { /* free the driver data */ DELETE_BEN(pd->kernel); From korli at mail.berlios.de Wed Sep 19 23:44:41 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 19 Sep 2007 23:44:41 +0200 Subject: [Haiku-commits] r22259 - in haiku/trunk/src/add-ons/kernel/drivers/graphics: intel_extreme radeon via Message-ID: <200709192144.l8JLifIK021066@sheep.berlios.de> Author: korli Date: 2007-09-19 23:44:40 +0200 (Wed, 19 Sep 2007) New Revision: 22259 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22259&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/driver.c haiku/trunk/src/add-ons/kernel/drivers/graphics/via/driver.c Log: put modules on error Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp 2007-09-19 21:43:42 UTC (rev 22258) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp 2007-09-19 21:44:40 UTC (rev 22259) @@ -131,8 +131,10 @@ } status = init_lock(&gLock, "intel extreme ksync"); - if (status < B_OK) + if (status < B_OK) { + put_module(B_PCI_MODULE_NAME); return status; + } // find devices Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/driver.c 2007-09-19 21:43:42 UTC (rev 22258) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/radeon/driver.c 2007-09-19 21:44:40 UTC (rev 22259) @@ -155,6 +155,8 @@ devices = (radeon_devices *)calloc( 1, sizeof( radeon_devices )); if( devices == NULL ) { put_module(B_PCI_MODULE_NAME); + if (agp_bus != NULL) + put_module(B_AGP_MODULE_NAME); return B_ERROR; } @@ -177,7 +179,8 @@ put_module( B_PCI_MODULE_NAME ); /* put the agp module away if it's there */ - if (agp_bus) put_module(B_AGP_MODULE_NAME); + if (agp_bus) + put_module(B_AGP_MODULE_NAME); } Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/via/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/via/driver.c 2007-09-19 21:43:42 UTC (rev 22258) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/via/driver.c 2007-09-19 21:44:40 UTC (rev 22259) @@ -284,6 +284,9 @@ /* driver private data */ pd = (DeviceData *)calloc(1, sizeof(DeviceData)); if (!pd) { + if (agp_bus) + put_module(B_AGP_MODULE_NAME); + put_module(B_ISA_MODULE_NAME); put_module(B_PCI_MODULE_NAME); return B_ERROR; } @@ -324,7 +327,8 @@ put_module(B_ISA_MODULE_NAME); /* put the agp module away if it's there */ - if (agp_bus) put_module(B_AGP_MODULE_NAME); + if (agp_bus) + put_module(B_AGP_MODULE_NAME); } static status_t map_device(device_info *di) From korli at mail.berlios.de Wed Sep 19 23:46:09 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 19 Sep 2007 23:46:09 +0200 Subject: [Haiku-commits] r22260 - in haiku/trunk/src/add-ons/kernel/drivers/graphics: vesa vmware Message-ID: <200709192146.l8JLk9Bj021153@sheep.berlios.de> Author: korli Date: 2007-09-19 23:46:08 +0200 (Wed, 19 Sep 2007) New Revision: 22260 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22260&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/driver.c Log: free ressources on error or uninit for vmware, actually checks if the device was found Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp 2007-09-19 21:44:40 UTC (rev 22259) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vesa/driver.cpp 2007-09-19 21:46:08 UTC (rev 22260) @@ -100,6 +100,7 @@ if (status == B_OK) return B_OK; + free(gDeviceNames[0]); put_module(B_ISA_MODULE_NAME); err1: free(gDeviceInfo[0]); Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/driver.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/driver.c 2007-09-19 21:44:40 UTC (rev 22259) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/driver.c 2007-09-19 21:46:08 UTC (rev 22260) @@ -54,7 +54,7 @@ status_t init_driver(void) { - status_t ret = B_OK; + status_t ret = ENODEV; int i; TRACE("init_driver\n"); @@ -73,9 +73,17 @@ /* Remember the PCI information */ for (i = 0; (*gPciBus->get_nth_pci_info)(i, &gPd->pcii) == B_OK; i++) if (gPd->pcii.vendor_id == PCI_VENDOR_ID_VMWARE && - gPd->pcii.device_id == PCI_DEVICE_ID_VMWARE_SVGA2) + gPd->pcii.device_id == PCI_DEVICE_ID_VMWARE_SVGA2) { + ret = B_OK; break; + } + if (ret != B_OK) { + free(gPd); + put_module(B_PCI_MODULE_NAME); + goto done; + } + /* Create a benaphore for exclusive access in OpenHook/FreeHook */ INIT_BEN(gPd->kernel); @@ -116,6 +124,8 @@ uninit_driver() { TRACE("uninit_driver\n"); + DELETE_BEN(gPd->kernel); + free(gPd->names[0]); free(gPd); put_module(B_PCI_MODULE_NAME); } From korli at mail.berlios.de Wed Sep 19 23:47:00 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Wed, 19 Sep 2007 23:47:00 +0200 Subject: [Haiku-commits] r22261 - in haiku/trunk/src/add-ons/kernel/drivers/audio/ac97: auich auvia Message-ID: <200709192147.l8JLl02G021208@sheep.berlios.de> Author: korli Date: 2007-09-19 23:47:00 +0200 (Wed, 19 Sep 2007) New Revision: 22261 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22261&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/auvia.c Log: clean up Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2007-09-19 21:46:08 UTC (rev 22260) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2007-09-19 21:47:00 UTC (rev 22261) @@ -56,7 +56,6 @@ int32 auich_int(void *arg); status_t auich_init(auich_dev * card); -static char pci_name[] = B_PCI_MODULE_NAME; pci_module_info *pci; int32 num_cards; @@ -528,7 +527,7 @@ PRINT(("init_hardware()\n")); - if (get_module(pci_name, (module_info **)&pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -567,7 +566,7 @@ ix++; } - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); return err; } @@ -773,7 +772,7 @@ unload_driver_settings (settings_handle); } - if (get_module(pci_name, (module_info **) &pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -823,7 +822,7 @@ } if (!num_cards) { PRINT(("no cards\n")); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); PRINT(("no suitable cards found\n")); return ENODEV; } @@ -867,7 +866,7 @@ auich_shutdown(&cards[ix]); } memset(&cards, 0, sizeof(cards)); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/auvia.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/auvia.c 2007-09-19 21:46:08 UTC (rev 22260) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/auvia.c 2007-09-19 21:47:00 UTC (rev 22261) @@ -413,7 +413,7 @@ PRINT(("init_hardware()\n")); - if (get_module(pci_name, (module_info **)&pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -426,7 +426,7 @@ ix++; } - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); return err; } @@ -575,7 +575,7 @@ PRINT(("init_driver()\n")); load_driver_symbols("auvia"); - if (get_module(pci_name, (module_info **) &pci)) + if (get_module(B_PCI_MODULE_NAME, (module_info **) &pci)) return ENOSYS; while ((*pci->get_nth_pci_info)(ix, &info) == B_OK) { @@ -600,7 +600,7 @@ } if (!num_cards) { PRINT(("no cards\n")); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); PRINT(("no suitable cards found\n")); return ENODEV; } @@ -634,7 +634,7 @@ auvia_shutdown(&cards[ix]); } memset(&cards, 0, sizeof(cards)); - put_module(pci_name); + put_module(B_PCI_MODULE_NAME); } From korli at mail.berlios.de Thu Sep 20 00:07:13 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 20 Sep 2007 00:07:13 +0200 Subject: [Haiku-commits] r22262 - haiku/trunk/src/add-ons/kernel/drivers/network/bcm440x Message-ID: <200709192207.l8JM7DJk022064@sheep.berlios.de> Author: korli Date: 2007-09-20 00:07:13 +0200 (Thu, 20 Sep 2007) New Revision: 22262 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22262&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/bcm440x/b44um.c Log: correctly release resources on error in init, or on uninit checks if pci module is present Modified: haiku/trunk/src/add-ons/kernel/drivers/network/bcm440x/b44um.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/bcm440x/b44um.c 2007-09-19 21:47:00 UTC (rev 22261) +++ haiku/trunk/src/add-ons/kernel/drivers/network/bcm440x/b44um.c 2007-09-19 22:07:13 UTC (rev 22262) @@ -87,8 +87,8 @@ int i = 0; pci_info dev_info; - if (pci == NULL) - get_module(B_PCI_MODULE_NAME,(module_info **)&pci); + if (get_module(B_PCI_MODULE_NAME,(module_info **)&pci) < B_OK) + return ENOSYS; while (pci->get_nth_pci_info(i++, &dev_info) == 0) { if (dev_info.class_base != PCI_network @@ -116,8 +116,14 @@ be_b44_dev_cards[sCardsFound].linkChangeSem = -1; #endif - if (b44_LM_GetAdapterInfo(&be_b44_dev_cards[sCardsFound].lm_dev) != LM_STATUS_SUCCESS) + if (b44_LM_GetAdapterInfo(&be_b44_dev_cards[sCardsFound].lm_dev) != LM_STATUS_SUCCESS) { + for (i = 0; i < sCardsFound; i++) { + free((void *)sDeviceNames[i]); + delete_sem(be_b44_dev_cards[i].packet_release_sem); + } + put_module(B_PCI_MODULE_NAME); return ENODEV; + } QQ_InitQueue(&be_b44_dev_cards[sCardsFound].RxPacketReadQ.Container, MAX_RX_PACKET_DESC_COUNT); @@ -147,6 +153,7 @@ delete_area(pUmDevice->mem_base); + delete_sem(be_b44_dev_cards[j].packet_release_sem); free((void *)sDeviceNames[j]); } From korli at mail.berlios.de Thu Sep 20 00:14:22 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 20 Sep 2007 00:14:22 +0200 Subject: [Haiku-commits] r22263 - haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x Message-ID: <200709192214.l8JMEM9w022364@sheep.berlios.de> Author: korli Date: 2007-09-20 00:14:21 +0200 (Thu, 20 Sep 2007) New Revision: 22263 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22263&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x/b57um.c Log: correctly release resources on error in init, or on uninit Modified: haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x/b57um.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x/b57um.c 2007-09-19 22:07:13 UTC (rev 22262) +++ haiku/trunk/src/add-ons/kernel/drivers/network/bcm570x/b57um.c 2007-09-19 22:14:21 UTC (rev 22263) @@ -333,6 +333,10 @@ #endif if (LM_GetAdapterInfo(&be_b57_dev_cards[cards_found].lm_dev) != LM_STATUS_SUCCESS) { + for (j = 0; j < cards_found; j++) { + free(dev_list[j]); + delete_sem(be_b57_dev_cards[j].packet_release_sem); + } put_module(B_PCI_MODULE_NAME); return ENODEV; } @@ -364,6 +368,7 @@ delete_area(pUmDevice->lockmem_list[i]); delete_area(pUmDevice->mem_base); + delete_sem(be_b57_dev_cards[j].packet_release_sem); free((void *)dev_list[j]); } From nielx at mail.berlios.de Thu Sep 20 00:22:41 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Thu, 20 Sep 2007 00:22:41 +0200 Subject: [Haiku-commits] r22264 - haiku/trunk/docs/user/app Message-ID: <200709192222.l8JMMfJj022814@sheep.berlios.de> Author: nielx Date: 2007-09-20 00:22:41 +0200 (Thu, 20 Sep 2007) New Revision: 22264 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22264&view=rev Modified: haiku/trunk/docs/user/app/_app_messaging.dox Log: Minor fixes. Finishes the first version. Modified: haiku/trunk/docs/user/app/_app_messaging.dox =================================================================== --- haiku/trunk/docs/user/app/_app_messaging.dox 2007-09-19 22:14:21 UTC (rev 22263) +++ haiku/trunk/docs/user/app/_app_messaging.dox 2007-09-19 22:22:41 UTC (rev 22264) @@ -87,7 +87,7 @@ BLooper context. Networking usually qualifies as a candidate for its own thread. - \section app_messaging_overview_bhandler BHandler + \subsection app_messaging_overview_bhandler BHandler Objects of the BHandler type are associated to BLoopers. When they are created, they should be passed to the BLooper::AddHandler() method of the @@ -108,7 +108,7 @@ that the Haiku API classes handle, and not actually handling these messages could lead to inconsistent internal behavior. - \section app_messaging-overview-bmessenger BMessenger + \subsection app_messaging-overview-bmessenger BMessenger BMessenger objects can send messages to both local and remote targets. For local targets, a BMessenger provides an advantage over directly calling @@ -122,20 +122,20 @@ to pass messages to other applications. It facilitates inter-application communication. - \section app_messaging-overview-other Other messaging classes + \subsection app_messaging-overview-other Other messaging classes There are several convenience classes supplied with the application kit, which can make your life easier in some specific cases. - * BInvoker binds together a message and a target. By calling + - BInvoker binds together a message and a target. By calling BInvoker::Invoke(), the message will be sent. This class is inherited by the controls in the interface kit, such as BButton. - * A BMessageRunner object will send messages to a specified target with + - A BMessageRunner object will send messages to a specified target with specified intervals in between. - * BMessageQueue is a class that is also internally used by BLooper. It + - BMessageQueue is a class that is also internally used by BLooper. It provides a queue of messages, with convenience functions of managing this queue. - * BMessageFilter is the base class of the filters. Filters can be applied + - BMessageFilter is the base class of the filters. Filters can be applied to BLoopers to filter all incoming messages, or to BHandlers to filter messages that could be handled by that object. The filter object can be subclassed and extended by overriding the Filter() method. From axeld at mail.berlios.de Thu Sep 20 00:36:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 20 Sep 2007 00:36:57 +0200 Subject: [Haiku-commits] r22265 - in haiku/trunk: headers/private/graphics/common src/add-ons/accelerants/common src/add-ons/accelerants/radeon Message-ID: <200709192236.l8JMavTJ008483@sheep.berlios.de> Author: axeld Date: 2007-09-20 00:36:55 +0200 (Thu, 20 Sep 2007) New Revision: 22265 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22265&view=rev Modified: haiku/trunk/headers/private/graphics/common/ddc.h haiku/trunk/headers/private/graphics/common/i2c.h haiku/trunk/src/add-ons/accelerants/common/ddc.c haiku/trunk/src/add-ons/accelerants/common/i2c.c haiku/trunk/src/add-ons/accelerants/radeon/monitor_detection.c Log: * Separated I2C from DDC a bit more. * i2c_bus now contains a i2c_timing structure, so that you don't need both to talk to the I2C bus. * Therefore, there is now a void ddc2_init_timing() function to get the the timing DDC needs. * Cleanup in radeon's monitor_detection.c, and updated it to work with the DDC/I2C changes. Modified: haiku/trunk/headers/private/graphics/common/ddc.h =================================================================== --- haiku/trunk/headers/private/graphics/common/ddc.h 2007-09-19 22:22:41 UTC (rev 22264) +++ haiku/trunk/headers/private/graphics/common/ddc.h 2007-09-19 22:36:55 UTC (rev 22265) @@ -1,21 +1,20 @@ /* - Copyright (c) 2003, Thomas Kurschel - - - Part of DDC driver - - Main DDC communication + * Copyright (c) 2003, Thomas Kurschel + * Distributed under the terms of the MIT License. */ - #ifndef _DDC_H #define _DDC_H + #include "i2c.h" #include "edid.h" + +void ddc2_init_timing(i2c_bus *bus); + // read EDID and VDIF from monitor via ddc2 // (currently, *vdif and *vdif_len is always set to null) -status_t ddc2_read_edid1( const i2c_bus *bus, edid1_info *edid, - void **vdif, size_t *vdif_len ); +status_t ddc2_read_edid1(const i2c_bus *bus, edid1_info *edid, + void **vdif, size_t *vdifLength); -#endif +#endif /* _DDC_H */ Modified: haiku/trunk/headers/private/graphics/common/i2c.h =================================================================== --- haiku/trunk/headers/private/graphics/common/i2c.h 2007-09-19 22:22:41 UTC (rev 22264) +++ haiku/trunk/headers/private/graphics/common/i2c.h 2007-09-19 22:36:55 UTC (rev 22265) @@ -1,17 +1,14 @@ /* - Copyright (c) 2003, Thomas Kurschel - - - Part of DDC driver - - I2C protocoll -*/ - + * Copyright 2003, Thomas Kurschel. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _I2C_H #define _I2C_H + #include + // timing for i2c bus typedef struct i2c_timing { // general timing as defined by standard @@ -39,31 +36,29 @@ // set signals on bus -typedef status_t (*i2c_set_signals)( void *cookie, int scl, int sda ); +typedef status_t (*i2c_set_signals)(void *cookie, int clock, int data); // read signals from bus -typedef status_t (*i2c_get_signals)( void *cookie, int *scl, int *sda ); +typedef status_t (*i2c_get_signals)(void *cookie, int *clock, int *data); - // i2c bus definition typedef struct i2c_bus { void *cookie; // user-defined cookie + i2c_timing timing; i2c_set_signals set_signals; // callback to set signals i2c_get_signals get_signals; // callback to detect signals } i2c_bus; // send and receive data via i2c bus -status_t i2c_send_receive( const i2c_bus *bus, const i2c_timing *timing, - int slave_address, - const uint8 *write_buffer, size_t write_len, - uint8 *read_buffer, size_t read_len ); +status_t i2c_send_receive(const i2c_bus *bus, int slave_address, + const uint8 *writeBuffer, size_t writeLength, uint8 *readBuffer, + size_t readLength); - // fill with standard 100kHz bus timing -void i2c_get100k_timing( i2c_timing *timing ); +void i2c_get100k_timing(i2c_timing *timing); // fill with standard 400kHz bus timing // (as timing resolution is 1 microsecond, we cannot reach full speed!) -void i2c_get400k_timing( i2c_timing *timing ); +void i2c_get400k_timing(i2c_timing *timing); -#endif +#endif /* _I2C_H */ Modified: haiku/trunk/src/add-ons/accelerants/common/ddc.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-09-19 22:22:41 UTC (rev 22264) +++ haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-09-19 22:36:55 UTC (rev 22265) @@ -3,10 +3,8 @@ * Distributed under the terms of the MIT License. */ - /*! - Part of DDC driver - Main DDC communication + DDC communication */ @@ -56,36 +54,26 @@ //! Read ddc2 data from monitor static status_t -ddc2_read(const i2c_bus *bus, int start, uint8 *buffer, size_t len) +ddc2_read(const i2c_bus *bus, int start, uint8 *buffer, size_t length) { - uint8 write_buffer[2]; - i2c_timing timing; + status_t status = B_OK; + uint8 writeBuffer[2]; int i; - status_t res = B_OK; - write_buffer[0] = start & 0xff; - write_buffer[1] = (start >> 8) & 0xff; + writeBuffer[0] = start & 0xff; + writeBuffer[1] = (start >> 8) & 0xff; - i2c_get100k_timing(&timing); - - timing.start_timeout = 550; - timing.byte_timeout = 2200; - timing.bit_timeout = 40; - timing.ack_start_timeout = 40; - timing.ack_timeout = 40; - for (i = 0; i < READ_RETRIES; ++i) { - res = i2c_send_receive(bus, &timing, - 0xa0, write_buffer, start < 0x100 ? 1 : 2, - buffer, len); + status = i2c_send_receive(bus, 0xa0, writeBuffer, + start < 0x100 ? 1 : 2, buffer, length); // don't verify checksum - it's often broken - if (res == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/) + if (status == B_OK /*&& verify_checksum( buffer, len ) == B_OK*/) break; - res = B_ERROR; + status = B_ERROR; } - return res; + return status; } @@ -133,30 +121,42 @@ #endif +void +ddc2_init_timing(i2c_bus *bus) +{ + i2c_get100k_timing(&bus->timing); + + // VESA standard + bus->timing.start_timeout = 550; + bus->timing.byte_timeout = 2200; + bus->timing.bit_timeout = 40; + bus->timing.ack_start_timeout = 40; + bus->timing.ack_timeout = 40; +} + + //! Read EDID and VDIF from monitor via ddc2 status_t ddc2_read_edid1(const i2c_bus *bus, edid1_info *edid, - void **vdif, size_t *vdif_len) + void **vdif, size_t *vdifLength) { - status_t res; edid1_raw raw; + status_t status = ddc2_read(bus, 0, (uint8 *)&raw, sizeof(raw)); + if (status != B_OK) + return status; - res = ddc2_read(bus, 0, (uint8 *)&raw, sizeof(raw)); - if (res != B_OK) - return res; - edid_decode(edid, &raw); *vdif = NULL; - *vdif_len = 0; + *vdifLength = 0; // skip vdif as long as it's not tested #if 0 - res = ddc2_read_vdif(bus, sizeof(raw) * (edid->num_sections + 1), + status = ddc2_read_vdif(bus, sizeof(raw) * (edid->num_sections + 1), vdif, vdif_len); - if (res != B_OK) - return res; + if (status != B_OK) + return status; #endif - + return B_OK; } Modified: haiku/trunk/src/add-ons/accelerants/common/i2c.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/i2c.c 2007-09-19 22:22:41 UTC (rev 22264) +++ haiku/trunk/src/add-ons/accelerants/common/i2c.c 2007-09-19 22:36:55 UTC (rev 22265) @@ -1,21 +1,72 @@ /* + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. * Copyright 2003, Thomas Kurschel. All Rights Reserved. * Distributed under the terms of the MIT License. */ - /*! - Part of DDC driver - I2C protocoll + I2C protocol */ -#include "ddc_int.h" #include "i2c.h" #include #include +//#define TRACE_I2C +#ifdef TRACE_I2C +extern "C" void _sPrintf(const char *format, ...); +# define TRACE(x...) _sPrintf("I2C: " x) +#else +# define TRACE(x...) ; +#endif + + +//! Timining for 100kHz bus (fractional parts are rounded up) +const static i2c_timing kTiming100k = { + buf : 5, + hd_sta : 4, + low : 5, + high : 4, + su_sta : 5, + hd_dat : 0, + su_dat : 1, + r : 1, + f : 1, + su_sto : 4, + + // as these are unspecified, we use half a clock cycle as a safe guess + start_timeout : 5, + byte_timeout : 5, + bit_timeout : 5, + ack_start_timeout : 5, + ack_timeout : 5 +}; + +// timing for 400 kHz bus +// (argh! heavy up-rounding here) +const static i2c_timing kTiming400k = { + buf : 2, + hd_sta : 1, + low : 2, + high : 1, + su_sta : 1, + hd_dat : 0, + su_dat : 1, + r : 1, + f : 1, + su_sto : 1, + + // see kTiming100k + start_timeout : 2, + byte_timeout : 2, + bit_timeout : 2, + ack_start_timeout : 2, + ack_timeout : 2 +}; + + /*! There's no spin in user space, but we need it to wait a couple of microseconds only @@ -24,59 +75,58 @@ void spin(bigtime_t delay) { - bigtime_t start_time = system_time(); - - while (system_time() - start_time < delay) + bigtime_t startTime = system_time(); + + while (system_time() - startTime < delay) ; } //! Wait until slave releases clock signal ("clock stretching") static status_t -wait_for_clk(const i2c_bus *bus, const i2c_timing *timing, - bigtime_t timeout) +wait_for_clk(const i2c_bus *bus, bigtime_t timeout) { - bigtime_t start_time; - + bigtime_t startTime; + // wait for clock signal to raise - spin(timing->r); + spin(bus->timing.r); - start_time = system_time(); + startTime = system_time(); - while (1) { + while (true) { int clk, data; - + bus->get_signals(bus->cookie, &clk, &data); if (clk != 0) return B_OK; - if (system_time() - start_time > timeout) + if (system_time() - startTime > timeout) return B_TIMEOUT; - spin(timing->r); + spin(bus->timing.r); } } //! Send start or repeated start condition static status_t -send_start_condition(const i2c_bus *bus, const i2c_timing *timing) +send_start_condition(const i2c_bus *bus) { - status_t res; + status_t status; bus->set_signals(bus->cookie, 1, 1); - res = wait_for_clk(bus, timing, timing->start_timeout); - if (res != B_OK) { - SHOW_FLOW0(3, "Timeout sending start condition"); - return res; + status = wait_for_clk(bus, bus->timing.start_timeout); + if (status != B_OK) { + TRACE("send_start_condition(): Timeout sending start condition\n"); + return status; } - spin(timing->su_sta); + spin(bus->timing.su_sta); bus->set_signals(bus->cookie, 1, 0); - spin(timing->hd_sta); + spin(bus->timing.hd_sta); bus->set_signals(bus->cookie, 0, 0); - spin(timing->f); + spin(bus->timing.f); return B_OK; } @@ -84,53 +134,51 @@ //! Send stop condition static status_t -send_stop_condition(const i2c_bus *bus, const i2c_timing *timing) +send_stop_condition(const i2c_bus *bus) { - status_t res; + status_t status; bus->set_signals(bus->cookie, 0, 0); - spin(timing->r); + spin(bus->timing.r); bus->set_signals(bus->cookie, 1, 0); // a slave may wait for us, so let elapse the acknowledge timeout // to make the slave release bus control - res = wait_for_clk(bus, timing, timing->ack_timeout); - if (res != B_OK) { - SHOW_FLOW0(3, "Timeout sending stop condition"); - return res; + status = wait_for_clk(bus, bus->timing.ack_timeout); + if (status != B_OK) { + TRACE("send_stop_condition(): Timeout sending stop condition\n"); + return status; } - spin(timing->su_sto); + spin(bus->timing.su_sto); bus->set_signals(bus->cookie, 1, 1); - spin(timing->buf); + spin(bus->timing.buf); - SHOW_FLOW0(3, ""); - return B_OK; } //! Send one bit static status_t -send_bit(const i2c_bus *bus, const i2c_timing *timing, bool bit, int timeout) +send_bit(const i2c_bus *bus, bool bit, int timeout) { - status_t res; + status_t status; - //SHOW_FLOW( 3, "%d", bit & 1 ); + //TRACE("send_bit(bit = %d)\n", bit & 1); bus->set_signals(bus->cookie, 0, bit & 1); - spin(timing->su_dat); + spin(bus->timing.su_dat); bus->set_signals(bus->cookie, 1, bit & 1); - res = wait_for_clk(bus, timing, timeout); - if (res != B_OK) { - SHOW_FLOW0(3, "Timeout when sending next bit"); - return res; + status = wait_for_clk(bus, timeout); + if (status != B_OK) { + TRACE("send_bit(): Timeout when sending next bit\n"); + return status; } - - spin(timing->high); + + spin(bus->timing.high); bus->set_signals(bus->cookie, 0, bit & 1); - spin(timing->f + timing->low); + spin(bus->timing.f + bus->timing.low); return B_OK; } @@ -138,27 +186,27 @@ //! Send acknowledge and wait for reply static status_t -send_acknowledge(const i2c_bus *bus, const i2c_timing *timing) +send_acknowledge(const i2c_bus *bus) { - status_t res; - bigtime_t start_time; + status_t status; + bigtime_t startTime; // release data so slave can modify it bus->set_signals(bus->cookie, 0, 1); - spin(timing->su_dat); + spin(bus->timing.su_dat); bus->set_signals(bus->cookie, 1, 1); - res = wait_for_clk(bus, timing, timing->ack_start_timeout); - if (res != B_OK) { - SHOW_FLOW0(3, "Timeout when sending acknowledge"); - return res; + status = wait_for_clk(bus, bus->timing.ack_start_timeout); + if (status != B_OK) { + TRACE("send_acknowledge(): Timeout when sending acknowledge\n"); + return status; } // data and clock is high, now wait for slave to pull data low // (according to spec, this can happen any time once clock is high) - start_time = system_time(); + startTime = system_time(); - while (1) { + while (true) { int clk, data; bus->get_signals(bus->cookie, &clk, &data); @@ -166,21 +214,21 @@ if (data == 0) break; - if (system_time() - start_time > timing->ack_timeout) { - SHOW_FLOW0(3, "Slave didn't acknowledge byte"); + if (system_time() - startTime > bus->timing.ack_timeout) { + TRACE("send_acknowledge(): Slave didn't acknowledge byte\n"); return B_TIMEOUT; } - - spin(timing->r); + + spin(bus->timing.r); } - SHOW_FLOW0(4, "Success!"); + TRACE("send_acknowledge(): Success!\n"); // make sure we've waited at least t_high - spin(timing->high); + spin(bus->timing.high); bus->set_signals(bus->cookie, 0, 1); - spin(timing->f + timing->low); + spin(bus->timing.f + bus->timing.low); return B_OK; } @@ -188,40 +236,36 @@ //! Send byte and wait for acknowledge if is true static status_t -send_byte(const i2c_bus *bus, const i2c_timing *timing, - uint8 byte, bool acknowledge) +send_byte(const i2c_bus *bus, uint8 byte, bool acknowledge) { int i; - SHOW_FLOW( 3, "%x ", byte ); + //TRACE("send_byte(byte = %x)\n", byte); for (i = 7; i >= 0; --i) { - status_t res; - - res = send_bit(bus, timing, byte >> i, - i == 7 ? timing->byte_timeout : timing->bit_timeout); - if (res != B_OK) - return res; + status_t status = send_bit(bus, byte >> i, + i == 7 ? bus->timing.byte_timeout : bus->timing.bit_timeout); + if (status != B_OK) + return status; } if (acknowledge) - return send_acknowledge(bus, timing); - else - return B_OK; + return send_acknowledge(bus); + + return B_OK; } //! Send slave address, obeying 10-bit addresses and general call addresses static status_t -send_slave_address( const i2c_bus *bus, const i2c_timing *timing, - int slave_address, bool is_write ) +send_slave_address(const i2c_bus *bus, int slaveAddress, bool isWrite) { - status_t res; - - res = send_byte(bus, timing, (slave_address & 0xfe) | !is_write, true); - if (res != B_OK) - return res; + status_t status; + status = send_byte(bus, (slaveAddress & 0xfe) | !isWrite, true); + if (status != B_OK) + return status; + // there are the following special cases if the first byte looks like: // - 0000 0000 - general call address (second byte with address follows) // - 0000 0001 - start byte @@ -233,42 +277,41 @@ // - 1111 0xxx - 10 bit address (second byte contains remaining 8 bits) // the lsb is 0 for write and 1 for read (except for general call address) - if ((slave_address & 0xff) != 0 && (slave_address & 0xf8) != 0xf0) + if ((slaveAddress & 0xff) != 0 && (slaveAddress & 0xf8) != 0xf0) return B_OK; - return send_byte(bus, timing, slave_address >> 8, true); + return send_byte(bus, slaveAddress >> 8, true); // send second byte if required } //! Receive one bit static status_t -receive_bit(const i2c_bus *bus, const i2c_timing *timing, - bool *bit, int timeout) +receive_bit(const i2c_bus *bus, bool *bit, int timeout) { - status_t res; + status_t status; int clk, data; bus->set_signals(bus->cookie, 1, 1); // release clock // wait for slave to raise clock - res = wait_for_clk(bus, timing, timeout); - if (res != B_OK) { - SHOW_FLOW0(3, "Timeout waiting for bit sent by slave"); - return res; + status = wait_for_clk(bus, timeout); + if (status != B_OK) { + TRACE("receive_bit(): Timeout waiting for bit sent by slave\n"); + return status; } bus->get_signals(bus->cookie, &clk, &data); // sample data - spin(timing->high); + spin(bus->timing.high); // leave clock high for minimal time bus->set_signals(bus->cookie, 0, 1); // pull clock low so slave waits for us before next bit - spin(timing->f + timing->low); + spin(bus->timing.f + bus->timing.low); // let it settle and leave it low for minimal time // to make sure slave has finished bit transmission too @@ -277,13 +320,12 @@ } -/*! receive byte +/*! Send positive acknowledge afterwards if is true, else send negative one */ static status_t -receive_byte(const i2c_bus *bus, const i2c_timing *timing, - uint8 *res_byte, bool acknowledge) +receive_byte(const i2c_bus *bus, uint8 *resultByte, bool acknowledge) { uint8 byte = 0; int i; @@ -291,39 +333,35 @@ // pull clock low to let slave wait for us bus->set_signals(bus->cookie, 0, 1); - for (i = 7; i >= 0; --i) { - status_t res; + for (i = 7; i >= 0; i--) { bool bit; - res = receive_bit(bus, timing, &bit, - i == 7 ? timing->byte_timeout : timing->bit_timeout); - if (res != B_OK) - return res; + status_t status = receive_bit(bus, &bit, + i == 7 ? bus->timing.byte_timeout : bus->timing.bit_timeout); + if (status != B_OK) + return status; byte = (byte << 1) | bit; } - //SHOW_FLOW( 3, "%x ", byte ); + //SHOW_FLOW(3, "%x ", byte); - *res_byte = byte; + *resultByte = byte; - return send_bit(bus, timing, acknowledge ? 0 : 1, timing->bit_timeout); + return send_bit(bus, acknowledge ? 0 : 1, bus->timing.bit_timeout); } //! Send multiple bytes static status_t -send_bytes(const i2c_bus *bus, const i2c_timing *timing, - const uint8 *write_buffer, ssize_t write_len) +send_bytes(const i2c_bus *bus, const uint8 *writeBuffer, ssize_t writeLength) { - SHOW_FLOW( 3, "len=%ld", write_len ); + TRACE("send_bytes(length = %ld)\n", writeLength); - for (; write_len > 0; --write_len, ++write_buffer) { - status_t res; - - res = send_byte(bus, timing, *write_buffer, true); - if (res != B_OK) - return res; + for (; writeLength > 0; --writeLength, ++writeBuffer) { + status_t status = send_byte(bus, *writeBuffer, true); + if (status != B_OK) + return status; } return B_OK; @@ -332,118 +370,70 @@ //! Receive multiple bytes static status_t -receive_bytes(const i2c_bus *bus, const i2c_timing *timing, - uint8 *read_buffer, ssize_t read_len) +receive_bytes(const i2c_bus *bus, uint8 *readBuffer, ssize_t readLength) { - SHOW_FLOW(3, "len=%ld", read_len); + TRACE("receive_bytes(length = %ld)\n", writeLength); - for (; read_len > 0; --read_len, ++read_buffer) { - status_t res; - - res = receive_byte(bus, timing, read_buffer, read_len > 1); - if (res != B_OK) - return res; + for (; readLength > 0; --readLength, ++readBuffer) { + status_t status = receive_byte(bus, readBuffer, readLength > 1); + if (status != B_OK) + return status; } return B_OK; } +// #pragma mark - exported functions + + //! Combined i2c send+receive format status_t -i2c_send_receive(const i2c_bus *bus, const i2c_timing *timing, - int slave_address, const uint8 *write_buffer, size_t write_len, - uint8 *read_buffer, size_t read_len) +i2c_send_receive(const i2c_bus *bus, int slaveAddress, const uint8 *writeBuffer, + size_t writeLength, uint8 *readBuffer, size_t readLength) { - status_t res; + status_t status = send_start_condition(bus); + if (status != B_OK) + return status; - res = send_start_condition(bus, timing); - if (res != B_OK) - return res; - - res = send_slave_address(bus, timing, slave_address, true); - if (res != B_OK) + status = send_slave_address(bus, slaveAddress, true); + if (status != B_OK) goto err; - res = send_bytes(bus, timing, write_buffer, write_len); - if (res != B_OK) + status = send_bytes(bus, writeBuffer, writeLength); + if (status != B_OK) goto err; - res = send_start_condition(bus, timing); - if (res != B_OK) - return res; + status = send_start_condition(bus); + if (status != B_OK) + return status; - res = send_slave_address(bus, timing, slave_address, false); - if (res != B_OK) + status = send_slave_address(bus, slaveAddress, false); + if (status != B_OK) goto err; - res = receive_bytes(bus, timing, read_buffer, read_len); - if (res != B_OK) + status = receive_bytes(bus, readBuffer, readLength); + if (status != B_OK) goto err; - res = send_stop_condition(bus, timing); - return res; + return send_stop_condition(bus); err: - SHOW_FLOW0(3, "Cancelling transmission"); - send_stop_condition(bus, timing); - return res; + TRACE("i2c_send_receive(): Cancelling transmission\n"); + send_stop_condition(bus); + return status; } -//! Timining for 100kHz bus (fractional parts are rounded up) -i2c_timing i2c_timing_100k = { - buf : 5, - hd_sta : 4, - low : 5, - high : 4, - su_sta : 5, - hd_dat : 0, - su_dat : 1, - r : 1, - f : 1, - su_sto : 4, - - // as these are unspecified, we use half a clock cycle as a safe guess - start_timeout : 5, - byte_timeout : 5, - bit_timeout : 5, - ack_start_timeout : 5, - ack_timeout : 5 -}; - -// timing for 400 kHz bus -// (argh! heavy up-rounding here) -i2c_timing i2c_timing_400k = { - buf : 2, - hd_sta : 1, - low : 2, - high : 1, - su_sta : 1, - hd_dat : 0, - su_dat : 1, - r : 1, - f : 1, - su_sto : 1, - - // see i2c_timing_100k - start_timeout : 2, - byte_timeout : 2, - bit_timeout : 2, - ack_start_timeout : 2, - ack_timeout : 2 -}; - - void i2c_get100k_timing(i2c_timing *timing) { - *timing = i2c_timing_100k; + *timing = kTiming100k; } void i2c_get400k_timing(i2c_timing *timing) { - *timing = i2c_timing_400k; + *timing = kTiming400k; } Modified: haiku/trunk/src/add-ons/accelerants/radeon/monitor_detection.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/radeon/monitor_detection.c 2007-09-19 22:22:41 UTC (rev 22264) +++ haiku/trunk/src/add-ons/accelerants/radeon/monitor_detection.c 2007-09-19 22:36:55 UTC (rev 22265) @@ -1,12 +1,15 @@ /* - Copyright (c) 2002-2004 Thomas Kurschel - + * Copyright 2002-2004, Thomas Kurschel. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ - Part of Radeon accelerant - - Monitor detection +/*! + Radeon monitor detection */ +#include +#include + #include "radeon_accelerant.h" #include "mmio.h" #include "crtc_regs.h" @@ -21,489 +24,480 @@ #include "theatre_regs.h" #include "set_mode.h" #include "ddc.h" -#include -#include "string.h" + typedef struct { accelerator_info *ai; uint32 port; } ddc_port_info; -// get I2C signals -static status_t get_signals( void *cookie, int *clk, int *data ) +//! Get I2C signals +static status_t +get_signals(void *cookie, int *clk, int *data) { ddc_port_info *info = (ddc_port_info *)cookie; vuint8 *regs = info->ai->regs; uint32 value; - - value = INREG( regs, info->port ); - + + value = INREG(regs, info->port); *clk = (value >> RADEON_GPIO_Y_SHIFT_1) & 1; *data = (value >> RADEON_GPIO_Y_SHIFT_0) & 1; - + return B_OK; } -// set I2C signals -static status_t set_signals( void *cookie, int clk, int data ) +//! Set I2C signals +static status_t +set_signals(void *cookie, int clk, int data) { ddc_port_info *info = (ddc_port_info *)cookie; vuint8 *regs = info->ai->regs; uint32 value; - value = INREG( regs, info->port ); + value = INREG(regs, info->port); value &= ~(RADEON_GPIO_A_1 | RADEON_GPIO_A_0); value &= ~(RADEON_GPIO_EN_0 | RADEON_GPIO_EN_1); - value |= ((1-clk) << RADEON_GPIO_EN_SHIFT_1) | ((1-data) << RADEON_GPIO_EN_SHIFT_0); + value |= ((1-clk) << RADEON_GPIO_EN_SHIFT_1) + | ((1-data) << RADEON_GPIO_EN_SHIFT_0); - OUTREG( regs, info->port, value ); - + OUTREG(regs, info->port, value); return B_OK; } -// read EDID information from monitor -// ddc_port - register to use for DDC2 communication -bool Radeon_ReadEDID( accelerator_info *ai, uint32 ddc_port, edid1_info *edid ) +/*! Read EDID information from monitor + ddc_port - register to use for DDC2 communication +*/ +bool +Radeon_ReadEDID(accelerator_info *ai, uint32 ddcPort, edid1_info *edid) { i2c_bus bus; ddc_port_info info; void *vdif; - size_t vdif_len; - status_t res; - + size_t vdifLength; + info.ai = ai; - info.port = ddc_port; - + info.port = ddcPort; + + ddc2_init_timing(&bus); bus.cookie = &info; bus.set_signals = &set_signals; bus.get_signals = &get_signals; - res = ddc2_read_edid1( &bus, edid, &vdif, &vdif_len ); - if( res != B_OK ) + if (ddc2_read_edid1(&bus, edid, &vdif, &vdifLength) != B_OK) return false; - - SHOW_FLOW( 2, "Found DDC-capable monitor @0x%04x", ddc_port ); - if( vdif != NULL ) - free( vdif ); - + SHOW_FLOW(2, "Found DDC-capable monitor @0x%04x", ddcPort); + + free(vdif); return true; } // search for display connect to CRT DAC // colour - true, if only a colour monitor is to be accepted -static bool Radeon_DetectCRTInt( accelerator_info *ai, bool colour ) +static bool +Radeon_DetectCRTInt(accelerator_info *ai, bool colour) { vuint8 *regs = ai->regs; - uint32 old_crtc_ext_cntl, old_dac_ext_cntl, old_dac_cntl, tmp; + uint32 old_crtc_ext_cntl, old_dac_ext_cntl, old_dac_cntl, value; bool found; // makes sure there is a signal - old_crtc_ext_cntl = INREG( regs, RADEON_CRTC_EXT_CNTL ); + old_crtc_ext_cntl = INREG(regs, RADEON_CRTC_EXT_CNTL); [... truncated: 1548 lines follow ...] From korli at mail.berlios.de Thu Sep 20 00:39:12 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Thu, 20 Sep 2007 00:39:12 +0200 Subject: [Haiku-commits] r22266 - haiku/trunk/src/apps/aboutsystem Message-ID: <200709192239.l8JMdCvS013942@sheep.berlios.de> Author: korli Date: 2007-09-20 00:39:10 +0200 (Thu, 20 Sep 2007) New Revision: 22266 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22266&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: added JiSheng as contributor Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-09-19 22:36:55 UTC (rev 22265) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-09-19 22:39:10 UTC (rev 22266) @@ -434,6 +434,7 @@ "Gabe Yoder\n" "Gerald Zajac\n" "?ukasz Zemczak\n" + "JiSheng Zhang\n" "\n" B_UTF8_ELLIPSIS " and probably some more we forgot to mention (sorry!)" "\n\n"); From stippi at mail.berlios.de Fri Sep 21 10:40:01 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 21 Sep 2007 10:40:01 +0200 Subject: [Haiku-commits] r22267 - in haiku/trunk/src/apps/icon-o-matic: . generic/gui/scrollview generic/property/view gui Message-ID: <200709210840.l8L8e1wn010200@sheep.berlios.de> Author: stippi Date: 2007-09-21 10:40:00 +0200 (Fri, 21 Sep 2007) New Revision: 22267 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22267&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.h haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.cpp haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.h Log: * the main window is now using the min/max size from the layout system * added Min/MaxSize() implementations to PropertyListView and ScrollView, which fixes the instable layout (upper list views shrinking towards the top whenever views are added/removed in the property list) Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-21 08:40:00 UTC (rev 22267) @@ -83,7 +83,12 @@ MainWindow::MainWindow(IconEditorApp* app, Document* document, const BMessage* settings) : BWindow(BRect(50, 50, 900, 750), "Icon-O-Matic", +#ifdef __HAIKU__ + B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), +#else B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), +#endif fApp(app), fDocument(document), fIcon(NULL) Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp 2007-09-21 08:40:00 UTC (rev 22267) @@ -1,10 +1,10 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: + * Ingo Weinhold * Stephan A?mus - * Ingo Weinhold */ #include "ScrollView.h" @@ -14,6 +14,9 @@ #include #include +#ifdef __HAIKU__ +# include +#endif #include #include #include @@ -22,7 +25,7 @@ #include "ScrollCornerBitmaps.h" -// InternalScrollBar +// #pragma mark - InternalScrollBar class InternalScrollBar : public BScrollBar { public: @@ -60,10 +63,8 @@ fScrollView->_ScrollValueChanged(this, value); } +// #pragma mark -ScrollCorner - -// ScrollCorner - class ScrollCorner : public BView { public: ScrollCorner(ScrollView* scrollView); @@ -255,10 +256,8 @@ } } +// #pragma mark - ScrollView - -// ScrollView - // constructor ScrollView::ScrollView(BView* child, uint32 scrollingFlags, BRect frame, const char *name, uint32 resizingMode, uint32 flags) @@ -390,6 +389,49 @@ Invalidate(); } +#ifdef __HAIKU__ + +// MinSize +BSize +ScrollView::MinSize() +{ + BSize size = (fChild ? fChild->MinSize() : BSize(-1, -1)); + + if (fVVisible) + size.width += B_V_SCROLL_BAR_WIDTH; + if (fHVisible) + size.height += B_H_SCROLL_BAR_HEIGHT; + + float borderSize = BorderSize(); + size.width += 2 * borderSize; + size.height += 2 * borderSize; + + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); +} + +// PreferredSize +BSize +ScrollView::PreferredSize() +{ +// TODO: This is not yet correct. + BSize size = (fChild ? fChild->PreferredSize() : BSize(-1, -1)); + + if (fVVisible) + size.width += B_V_SCROLL_BAR_WIDTH; + if (fHVisible) + size.height += B_H_SCROLL_BAR_HEIGHT; + + float borderSize = BorderSize(); + size.width += 2 * borderSize; + size.height += 2 * borderSize; + + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); +} + +#endif // __HAIKU__ + +// #pragma mark - + // ScrollingFlags uint32 ScrollView::ScrollingFlags() const @@ -459,6 +501,17 @@ return fScrollCorner; } +// BorderSize +float +ScrollView::BorderSize() const +{ + if (fScrollingFlags & SCROLL_NO_FRAME) + return 0.0; + return 2.0; +} + +// #pragma mark - + // SetHSmallStep void ScrollView::SetHSmallStep(float hStep) @@ -506,6 +559,8 @@ return fVSmallStep; } +// #pragma mark - + // DataRectChanged void ScrollView::DataRectChanged(BRect /*oldDataRect*/, BRect /*newDataRect*/) @@ -586,6 +641,8 @@ SetScrollOffset(offset); } +// #pragma mark - + // _Layout // // Relayouts all children (fChild, scroll bars). Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h 2007-09-21 08:40:00 UTC (rev 22267) @@ -41,6 +41,12 @@ virtual void FrameResized(float width, float height); virtual void WindowActivated(bool activated); +#ifdef __HAIKU__ + virtual BSize MinSize(); + virtual BSize PreferredSize(); +#endif + + uint32 ScrollingFlags() const; void SetVisibleRectIsChildBounds(bool flag); bool VisibleRectIsChildBounds() const; @@ -60,6 +66,8 @@ float HSmallStep() const; float VSmallStep() const; + float BorderSize() const; + protected: virtual void DataRectChanged(BRect oldDataRect, BRect newDataRect); Modified: haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp 2007-09-21 08:40:00 UTC (rev 22267) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,6 +13,9 @@ #include #include +#ifdef __HAIKU__ +# include +#endif #include #include #include @@ -250,6 +253,34 @@ } } +#ifdef __HAIKU__ + +BSize +PropertyListView::MinSize() +{ + // We need a stable min size: the BView implementation uses + // GetPreferredSize(), which by default just returns the current size. + return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(10, 10)); +} + + +BSize +PropertyListView::MaxSize() +{ + return BView::MaxSize(); +} + + +BSize +PropertyListView::PreferredSize() +{ + // We need a stable preferred size: the BView implementation uses + // GetPreferredSize(), which by default just returns the current size. + return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), BSize(100, 50)); +} + +#endif // __HAIKU__ + // #pragma mark - // TabFocus Modified: haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.h 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.h 2007-09-21 08:40:00 UTC (rev 22267) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -42,6 +42,12 @@ virtual void MouseDown(BPoint where); virtual void MessageReceived(BMessage* message); +#ifdef __HAIKU__ + virtual BSize MinSize(); + virtual BSize MaxSize(); + virtual BSize PreferredSize(); +#endif + // Scrollable interface virtual void ScrollOffsetChanged(BPoint oldOffset, BPoint newOffset); Modified: haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.cpp 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.cpp 2007-09-21 08:40:00 UTC (rev 22267) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: Modified: haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.h 2007-09-19 22:39:10 UTC (rev 22266) +++ haiku/trunk/src/apps/icon-o-matic/gui/IconObjectListView.h 2007-09-21 08:40:00 UTC (rev 22267) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -22,9 +22,10 @@ IconObjectListView(); virtual ~IconObjectListView(); - // PropertyListView interface + // BView interface virtual void Draw(BRect updateRect); + // PropertyListView interface virtual void PropertyChanged(const Property* previous, const Property* current); virtual void PasteProperties(const PropertyObject* object); From stippi at mail.berlios.de Fri Sep 21 15:04:06 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 21 Sep 2007 15:04:06 +0200 Subject: [Haiku-commits] r22268 - in haiku/trunk/src/apps/icon-o-matic: . generic/gui/scrollview Message-ID: <200709211304.l8LD46xO012674@sheep.berlios.de> Author: stippi Date: 2007-09-21 15:04:06 +0200 (Fri, 21 Sep 2007) New Revision: 22268 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22268&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp haiku/trunk/src/apps/icon-o-matic/MainWindow.h haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h Log: * the custom ScrollView supports B_NO_BORDER, B_PLAIN_BORDER and B_FANCY_BORDER and each side of the border can be turned off or on individually * -> cosmetic improvements Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-21 08:40:00 UTC (rev 22267) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-21 13:04:06 UTC (rev 22268) @@ -451,6 +451,12 @@ // create the GUI _CreateGUI(Bounds()); + // fix up scrollbar layout in listviews + _ImproveScrollBarLayout(fPathListView); + _ImproveScrollBarLayout(fStyleListView); + _ImproveScrollBarLayout(fShapeListView); + _ImproveScrollBarLayout(fTransformerListView); + // TODO: move this to CanvasView? fState = new MultipleManipulatorState(fCanvasView); fCanvasView->SetState(fState); @@ -615,11 +621,9 @@ // scroll view around property list view ScrollView* propScrollView = new ScrollView(fPropertyListView, - SCROLL_VERTICAL | SCROLL_NO_FRAME, - BRect(0, 0, splitWidth, 100), - "property scroll view", - B_FOLLOW_NONE, - B_WILL_DRAW | B_FRAME_EVENTS); + SCROLL_VERTICAL, BRect(0, 0, splitWidth, 100), "property scroll view", + B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER, + BORDER_RIGHT); leftSideView->AddChild(propScrollView); BGroupLayout* topSide = new BGroupLayout(B_HORIZONTAL); @@ -635,9 +639,9 @@ canvasBounds.right += B_V_SCROLL_BAR_WIDTH; ScrollView* canvasScrollView = new ScrollView(fCanvasView, SCROLL_VERTICAL | SCROLL_HORIZONTAL - | SCROLL_NO_FRAME | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS, + | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS, canvasBounds, "canvas scroll view", - B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS); + B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER); layout->AddView(canvasScrollView, 1, 1); // views along the top @@ -730,12 +734,10 @@ bounds.bottom += B_H_SCROLL_BAR_HEIGHT; bounds.right += B_V_SCROLL_BAR_WIDTH; ScrollView* canvasScrollView - = new ScrollView(fCanvasView, - SCROLL_HORIZONTAL | SCROLL_VERTICAL - | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS - | SCROLL_NO_FRAME, - bounds, "canvas scroll view", - B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS); + = new ScrollView(fCanvasView, SCROLL_HORIZONTAL | SCROLL_VERTICAL + | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS, bounds, + "canvas scroll view", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, + B_NO_BORDER); // icon previews bounds.left = 5; @@ -902,11 +904,9 @@ // scroll view around property list view bounds.top = menuBar->Frame().bottom + 1; bounds.bottom = bg->Bounds().bottom; - bg->AddChild(new ScrollView(fPropertyListView, - SCROLL_VERTICAL | SCROLL_NO_FRAME, - bounds, "property scroll view", - B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, - B_WILL_DRAW | B_FRAME_EVENTS)); + bg->AddChild(new ScrollView(fPropertyListView, SCROLL_VERTICAL, + bounds, "property scroll view", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, + B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER, BORDER_RIGHT)); bg->AddChild(canvasScrollView); @@ -1063,3 +1063,20 @@ // PathManipulator* pathManipulator = new PathManipulator(path); // fState->AddManipulator(pathManipulator); //} + +// _ImproveScrollBarLayout +void +MainWindow::_ImproveScrollBarLayout(BView* target) +{ + // NOTE: The BListViews for which this function is used + // are directly below a BMenuBar. If the BScrollBar and + // the BMenuBar share bottom/top border respectively, the + // GUI looks a little more polished. This trick can be + // removed if/when the BScrollViews are embedded in a + // surounding border like in WonderBrush. + + if (BScrollBar* scrollBar = target->ScrollBar(B_VERTICAL)) { + scrollBar->MoveBy(0, -1); + scrollBar->ResizeBy(0, 1); + } +} Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.h 2007-09-21 08:40:00 UTC (rev 22267) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.h 2007-09-21 13:04:06 UTC (rev 22268) @@ -73,6 +73,8 @@ void _CreateGUI(BRect frame); BMenuBar* _CreateMenuBar(BRect frame); + void _ImproveScrollBarLayout(BView* target); + IconEditorApp* fApp; Document* fDocument; Icon* fIcon; Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp 2007-09-21 08:40:00 UTC (rev 22267) +++ haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.cpp 2007-09-21 13:04:06 UTC (rev 22268) @@ -260,22 +260,30 @@ // constructor ScrollView::ScrollView(BView* child, uint32 scrollingFlags, BRect frame, - const char *name, uint32 resizingMode, uint32 flags) - : BView(frame, name, resizingMode, flags | B_FRAME_EVENTS | B_WILL_DRAW - | B_FULL_UPDATE_ON_RESIZE), + const char *name, uint32 resizingMode, uint32 viewFlags, + uint32 borderStyle, uint32 borderFlags) + : BView(frame, name, resizingMode, viewFlags | B_FRAME_EVENTS | B_WILL_DRAW + | B_FULL_UPDATE_ON_RESIZE), Scroller(), fChild(NULL), fScrollingFlags(scrollingFlags), + fHScrollBar(NULL), fVScrollBar(NULL), fScrollCorner(NULL), + fHVisible(true), fVVisible(true), fCornerVisible(true), + fWindowActive(false), fChildFocused(false), + fHSmallStep(1), - fVSmallStep(1) + fVSmallStep(1), + + fBorderStyle(borderStyle), + fBorderFlags(borderFlags) { // Set transparent view color -- our area is completely covered by // our children. @@ -321,6 +329,9 @@ // Draw void ScrollView::Draw(BRect updateRect) { + if (fBorderStyle == B_NO_BORDER) + return; + rgb_color keyboardFocus = keyboard_navigation_color(); rgb_color light = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT); @@ -328,50 +339,37 @@ B_DARKEN_1_TINT); rgb_color darkShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT); - rgb_color darkerShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DARKEN_3_TINT); - float left = Bounds().left, right = Bounds().right; - float top = Bounds().top, bottom = Bounds().bottom; + + BRect r = Bounds(); + if (fChildFocused && fWindowActive) { - BeginLineArray(4); - AddLine(BPoint(left, bottom), - BPoint(left, top), keyboardFocus); - AddLine(BPoint(left + 1.0, top), - BPoint(right, top), keyboardFocus); - AddLine(BPoint(right, top + 1.0), - BPoint(right, bottom), keyboardFocus); - AddLine(BPoint(right - 1.0, bottom), - BPoint(left + 1.0, bottom), keyboardFocus); - EndLineArray(); + SetHighColor(keyboardFocus); + StrokeRect(r); } else { - BeginLineArray(4); - AddLine(BPoint(left, bottom), - BPoint(left, top), shadow); - AddLine(BPoint(left + 1.0, top), - BPoint(right, top), shadow); - AddLine(BPoint(right, top + 1.0), - BPoint(right, bottom), light); - AddLine(BPoint(right - 1.0, bottom), - BPoint(left + 1.0, bottom), light); - EndLineArray(); + if (fBorderStyle == B_PLAIN_BORDER) { + SetHighColor(darkShadow); + StrokeRect(r); + } else { + BeginLineArray(4); + AddLine(BPoint(r.left, r.bottom), + BPoint(r.left, r.top), shadow); + AddLine(BPoint(r.left + 1.0, r.top), + BPoint(r.right, r.top), shadow); + AddLine(BPoint(r.right, r.top + 1.0), + BPoint(r.right, r.bottom), light); + AddLine(BPoint(r.right - 1.0, r.bottom), + BPoint(r.left + 1.0, r.bottom), light); + EndLineArray(); + } } + if (fBorderStyle == B_PLAIN_BORDER) + return; + // The right and bottom lines will be hidden if the scroll views are // visible. But that doesn't harm. - BRect innerRect(_InnerRect()); - left = innerRect.left; - top = innerRect.top; - right = innerRect.right; - bottom = innerRect.bottom; - BeginLineArray(4); - AddLine(BPoint(left, bottom), - BPoint(left, top), darkerShadow); - AddLine(BPoint(left + 1.0, top), - BPoint(right, top), darkShadow); - AddLine(BPoint(right, top + 1.0), - BPoint(right, bottom), darkShadow); - AddLine(BPoint(right - 1.0, bottom), - BPoint(left + 1.0, bottom), darkShadow); - EndLineArray(); + r.InsetBy(1, 1); + SetHighColor(darkShadow); + StrokeRect(r); } // FrameResized @@ -396,36 +394,15 @@ ScrollView::MinSize() { BSize size = (fChild ? fChild->MinSize() : BSize(-1, -1)); - - if (fVVisible) - size.width += B_V_SCROLL_BAR_WIDTH; - if (fHVisible) - size.height += B_H_SCROLL_BAR_HEIGHT; - - float borderSize = BorderSize(); - size.width += 2 * borderSize; - size.height += 2 * borderSize; - - return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); + return _Size(size); } // PreferredSize BSize ScrollView::PreferredSize() { -// TODO: This is not yet correct. BSize size = (fChild ? fChild->PreferredSize() : BSize(-1, -1)); - - if (fVVisible) - size.width += B_V_SCROLL_BAR_WIDTH; - if (fHVisible) - size.height += B_H_SCROLL_BAR_HEIGHT; - - float borderSize = BorderSize(); - size.width += 2 * borderSize; - size.height += 2 * borderSize; - - return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); + return _Size(size); } #endif // __HAIKU__ @@ -501,15 +478,6 @@ return fScrollCorner; } -// BorderSize -float -ScrollView::BorderSize() const -{ - if (fScrollingFlags & SCROLL_NO_FRAME) - return 0.0; - return 2.0; -} - // #pragma mark - // SetHSmallStep @@ -659,14 +627,11 @@ float innerWidth = childRect.Width(); float innerHeight = childRect.Height(); BPoint scrollLT(_InnerRect().LeftTop()); + scrollLT.x--; + scrollLT.y--; + BPoint scrollRB(childRect.RightBottom() + BPoint(1.0f, 1.0f)); - if (fScrollingFlags & SCROLL_NO_FRAME) { - // cut off the top line and left line of the - // scroll bars, otherwise they are used for the - // frame appearance - scrollLT.x--; - scrollLT.y--; - } + // layout scroll bars and scroll corner if (corner) { // In this case the scrollbars overlap one pixel. @@ -849,9 +814,28 @@ BRect ScrollView::_InnerRect() const { - if (fScrollingFlags & SCROLL_NO_FRAME) - return Bounds(); - return Bounds().InsetBySelf(1.0f, 1.0f); + BRect r = Bounds(); + float borderWidth = 0; + switch (fBorderStyle) { + case B_NO_BORDER: + break; + case B_PLAIN_BORDER: + borderWidth = 1; + break; + case B_FANCY_BORDER: + default: + borderWidth = 2; + break; + } + if (fBorderFlags & BORDER_LEFT) + r.left += borderWidth; + if (fBorderFlags & BORDER_TOP) + r.top += borderWidth; + if (fBorderFlags & BORDER_RIGHT) + r.right -= borderWidth; + if (fBorderFlags & BORDER_BOTTOM) + r.bottom -= borderWidth; + return r; } // _ChildRect @@ -874,18 +858,11 @@ ScrollView::_ChildRect(bool hbar, bool vbar) const { BRect rect(_InnerRect()); - float frameWidth = (fScrollingFlags & SCROLL_NO_FRAME) ? 0.0 : 1.0; + if (vbar) + rect.right -= B_V_SCROLL_BAR_WIDTH; + if (hbar) + rect.bottom -= B_H_SCROLL_BAR_HEIGHT; - if (hbar) - rect.bottom -= B_H_SCROLL_BAR_HEIGHT + frameWidth; - else - rect.bottom -= frameWidth; - if (vbar) - rect.right -= B_V_SCROLL_BAR_WIDTH + frameWidth; - else - rect.right -= frameWidth; - rect.top += frameWidth; - rect.left += frameWidth; return rect; } @@ -915,4 +892,51 @@ return _GuessVisibleRect(true, true); } +#ifdef __HAIKU__ +BSize +ScrollView::_Size(BSize size) +{ + if (fVVisible) + size.width += B_V_SCROLL_BAR_WIDTH; + if (fHVisible) + size.height += B_H_SCROLL_BAR_HEIGHT; + switch (fBorderStyle) { + case B_NO_BORDER: + // one line of pixels from scrollbar possibly hidden + if (fBorderFlags & BORDER_RIGHT) + size.width += fVVisible ? -1 : 0; + if (fBorderFlags & BORDER_BOTTOM) + size.height += fHVisible ? -1 : 0; + break; + + case B_PLAIN_BORDER: + if (fBorderFlags & BORDER_LEFT) + size.width += 1; + if (fBorderFlags & BORDER_TOP) + size.height += 1; + // one line of pixels in frame possibly from scrollbar + if (fBorderFlags & BORDER_RIGHT) + size.width += fVVisible ? 0 : 1; + if (fBorderFlags & BORDER_BOTTOM) + size.height += fHVisible ? 0 : 1; + break; + + case B_FANCY_BORDER: + default: + if (fBorderFlags & BORDER_LEFT) + size.width += 2; + if (fBorderFlags & BORDER_TOP) + size.height += 2; + // one line of pixels in frame possibly from scrollbar + if (fBorderFlags & BORDER_RIGHT) + size.width += fVVisible ? 1 : 2; + if (fBorderFlags & BORDER_BOTTOM) + size.height += fHVisible ? 1 : 2; + break; + } + + return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); +} +#endif // __HAIKU__ + Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h 2007-09-21 08:40:00 UTC (rev 22267) +++ haiku/trunk/src/apps/icon-o-matic/generic/gui/scrollview/ScrollView.h 2007-09-21 13:04:06 UTC (rev 22268) @@ -23,17 +23,25 @@ SCROLL_VERTICAL = 0x02, SCROLL_HORIZONTAL_MAGIC = 0x04, SCROLL_VERTICAL_MAGIC = 0x08, - SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS = 0x10, - SCROLL_NO_FRAME = 0x20, + SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS = 0x10 }; +enum { + BORDER_LEFT = 0x01, + BORDER_TOP = 0x02, + BORDER_RIGHT = 0x04, + BORDER_BOTTOM = 0x08, + BORDER_ALL = BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM +}; + + class ScrollView : public BView, public Scroller { public: - ScrollView(BView* child, - uint32 scrollingFlags, - BRect frame, - const char *name, - uint32 resizingMode, uint32 flags); + ScrollView(BView* child, uint32 scrollingFlags, + BRect frame, const char *name, + uint32 resizingMode, uint32 viewFlags, + uint32 borderStyle = B_FANCY_BORDER, + uint32 borderFlags = BORDER_ALL); virtual ~ScrollView(); virtual void AllAttached(); @@ -66,8 +74,6 @@ float HSmallStep() const; float VSmallStep() const; - float BorderSize() const; - protected: virtual void DataRectChanged(BRect oldDataRect, BRect newDataRect); @@ -94,6 +100,9 @@ float fHSmallStep; float fVSmallStep; + uint32 fBorderStyle; + uint32 fBorderFlags; + void _ScrollValueChanged( InternalScrollBar* scrollBar, float value); @@ -111,6 +120,9 @@ BRect _ChildRect(bool hbar, bool vbar) const; BRect _GuessVisibleRect(bool hbar, bool vbar) const; BRect _MaxVisibleRect() const; +#ifdef __HAIKU__ + virtual BSize _Size(BSize childSize); +#endif friend class InternalScrollBar; friend class ScrollCorner; From stippi at mail.berlios.de Fri Sep 21 17:21:39 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Fri, 21 Sep 2007 17:21:39 +0200 Subject: [Haiku-commits] r22269 - in haiku/trunk/src: apps/icon-o-matic apps/icon-o-matic/document apps/icon-o-matic/generic/gui apps/icon-o-matic/gui apps/icon-o-matic/shape/commands libs/icon/style Message-ID: <200709211521.l8LFLdwn020664@sheep.berlios.de> Author: stippi Date: 2007-09-21 17:21:38 +0200 (Fri, 21 Sep 2007) New Revision: 22269 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22269&view=rev Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp haiku/trunk/src/apps/icon-o-matic/document/Document.cpp haiku/trunk/src/apps/icon-o-matic/document/Document.h haiku/trunk/src/apps/icon-o-matic/generic/gui/ListViews.cpp haiku/trunk/src/apps/icon-o-matic/gui/PathListView.cpp haiku/trunk/src/apps/icon-o-matic/gui/ShapeListView.cpp haiku/trunk/src/apps/icon-o-matic/gui/StyleListView.cpp haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h haiku/trunk/src/apps/icon-o-matic/shape/commands/AddShapesCommand.cpp haiku/trunk/src/libs/icon/style/Gradient.cpp haiku/trunk/src/libs/icon/style/Gradient.h Log: * fixed quite a few selections bugs, most were caused by cyclic notifications, and the mechanism to prevent them not working... * could have fixed the "there are still listeners attached" bug (debugger drop) on exit, I have not seen it again, but I am not sure if it is really fixed * introduced a way to ask the user, if changes should be saved and then pick up the line of thought after saving Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -62,7 +62,9 @@ fLastOpenPath(""), fLastSavePath(""), - fLastExportPath("") + fLastExportPath(""), + + fMessageAfterSave(NULL) { } @@ -76,6 +78,8 @@ delete fOpenPanel; delete fSavePanel; + + delete fMessageAfterSave; } // #pragma mark - @@ -84,7 +88,9 @@ bool IconEditorApp::QuitRequested() { - // TODO: ask main window if quitting is ok + if (!_CheckSaveIcon(CurrentMessage())) + return false; + _StoreSettings(); fMainWindow->Lock(); @@ -103,14 +109,12 @@ _MakeIconEmpty(); break; case MSG_OPEN: { -// fOpenPanel->Refresh(); BMessage openMessage(B_REFS_RECEIVED); fOpenPanel->SetMessage(&openMessage); fOpenPanel->Show(); break; } case MSG_APPEND: { -// fOpenPanel->Refresh(); BMessage openMessage(B_REFS_RECEIVED); openMessage.AddBool("append", true); fOpenPanel->SetMessage(&openMessage); @@ -126,6 +130,7 @@ saver = fDocument->ExportSaver(); if (saver) { saver->Save(fDocument); + _PickUpActionBeforeSave(); break; } // else fall through } @@ -153,6 +158,7 @@ else fDocument->SetExportSaver(saver); saver->Save(fDocument); + _PickUpActionBeforeSave(); } } _SyncPanels(fSavePanel, fOpenPanel); @@ -267,9 +273,61 @@ // #pragma mark - +// _CheckSaveIcon +bool +IconEditorApp::_CheckSaveIcon(const BMessage* currentMessage) +{ + if (fDocument->IsEmpty() || fDocument->CommandStack()->IsSaved()) + return true; + + BAlert* alert = new BAlert("save", "Save changes to current icon?", + "Discard", "Cancel", "Save"); + int32 choice = alert->Go(); + switch (choice) { + case 0: + // discard + return true; + case 1: + // cancel + return false; + case 2: + default: + // cancel (save first) but pick what we were doing before + PostMessage(MSG_SAVE); + if (currentMessage) { + delete fMessageAfterSave; + fMessageAfterSave = new BMessage(*currentMessage); + } + return false; + } +} + +// _PickUpActionBeforeSave void +IconEditorApp::_PickUpActionBeforeSave() +{ + if (fDocument->WriteLock()) { + fDocument->CommandStack()->Save(); + fDocument->WriteUnlock(); + } + + if (!fMessageAfterSave) + return; + + PostMessage(fMessageAfterSave); + delete fMessageAfterSave; + fMessageAfterSave = NULL; +} + +// #pragma mark - + +// _MakeIconEmpty +void IconEditorApp::_MakeIconEmpty() { + if (!_CheckSaveIcon(CurrentMessage())) + return; + bool mainWindowLocked = fMainWindow && fMainWindow->Lock(); AutoWriteLocker locker(fDocument); @@ -289,6 +347,9 @@ void IconEditorApp::_Open(const entry_ref& ref, bool append) { + if (!_CheckSaveIcon(CurrentMessage())) + return; + BFile file(&ref, B_READ_ONLY); if (file.InitCheck() < B_OK) return; @@ -390,6 +451,9 @@ IconEditorApp::_Open(const BMessenger& externalObserver, const uint8* data, size_t size) { + if (!_CheckSaveIcon(CurrentMessage())) + return; + if (!externalObserver.IsValid()) return; Modified: haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/IconEditorApp.h 2007-09-21 15:21:38 UTC (rev 22269) @@ -63,6 +63,9 @@ // IconEditorApp private: + bool _CheckSaveIcon(const BMessage* currentMessage); + void _PickUpActionBeforeSave(); + void _MakeIconEmpty(); void _Open(const entry_ref& ref, bool append = false); @@ -89,6 +92,8 @@ BString fLastOpenPath; BString fLastSavePath; BString fLastExportPath; + + BMessage* fMessageAfterSave; }; #endif // ICON_EDITOR_APP_H Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -215,6 +215,10 @@ VectorPath* path; if (message->FindPointer("path", (void**)&path) < B_OK) path = NULL; + + fPathListView->SetCurrentShape(NULL); + fStyleListView->SetCurrentShape(NULL); + fTransformerListView->SetShape(NULL); fState->DeleteManipulators(); if (fDocument->Icon()->Paths()->HasPath(path)) { @@ -223,7 +227,8 @@ } break; } -case MSG_STYLE_SELECTED: { +case MSG_STYLE_SELECTED: +case MSG_STYLE_TYPE_CHANGED: { Style* style; if (message->FindPointer("style", (void**)&style) < B_OK) style = NULL; @@ -231,14 +236,13 @@ style = NULL; fStyleView->SetStyle(style); - break; -} -case MSG_GRADIENT_SELECTED: { - // if there is a gradient, add a transform box around it - Gradient* gradient; - if (message->FindPointer("gradient", (void**)&gradient) < B_OK) - gradient = NULL; + fPathListView->SetCurrentShape(NULL); + fStyleListView->SetCurrentShape(NULL); + fTransformerListView->SetShape(NULL); + fState->DeleteManipulators(); + Gradient* gradient = style ? style->Gradient() : NULL; + if (gradient) { TransformGradientBox* transformBox = new (nothrow) TransformGradientBox(fCanvasView, Modified: haiku/trunk/src/apps/icon-o-matic/document/Document.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/document/Document.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/document/Document.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -12,7 +12,10 @@ #include "CommandStack.h" #include "DocumentSaver.h" #include "Icon.h" +#include "PathContainer.h" #include "Selection.h" +#include "ShapeContainer.h" +#include "StyleContainer.h" #include @@ -112,4 +115,12 @@ } } +// IsEmpty +bool +Document::IsEmpty() const +{ + return fIcon->Styles()->CountStyles() == 0 + && fIcon->Paths()->CountPaths() == 0 + && fIcon->Shapes()->CountShapes() == 0; +} Modified: haiku/trunk/src/apps/icon-o-matic/document/Document.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/document/Document.h 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/document/Document.h 2007-09-21 15:21:38 UTC (rev 22269) @@ -57,6 +57,8 @@ void MakeEmpty(bool includingSavers = true); + bool IsEmpty() const; + private: BPrivate::Icon::Icon* fIcon; ::CommandStack* fCommandStack; Modified: haiku/trunk/src/apps/icon-o-matic/generic/gui/ListViews.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/generic/gui/ListViews.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/generic/gui/ListViews.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -533,9 +533,10 @@ void DragSortableListView::ObjectChanged(const Observable* object) { - if (object != fSelection || fModifyingSelection) + if (object != fSelection || fModifyingSelection || fSyncingToSelection) return; +//printf("%s - syncing start\n", Name()); fSyncingToSelection = true; // try to sync to Selection @@ -567,6 +568,7 @@ } fSyncingToSelection = false; +//printf("%s - done\n", Name()); } // #pragma mark - @@ -813,7 +815,7 @@ { //printf("%s::SelectionChanged()", typeid(*this).name()); // modify global Selection - if (!fSelection) + if (!fSelection || fSyncingToSelection) return; fModifyingSelection = true; Modified: haiku/trunk/src/apps/icon-o-matic/gui/PathListView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/PathListView.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/gui/PathListView.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -623,7 +623,7 @@ return; if (_AddPath(path, index)) - Select(CountItems() - 1); + Select(index); UnlockLooper(); } Modified: haiku/trunk/src/apps/icon-o-matic/gui/ShapeListView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/ShapeListView.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/gui/ShapeListView.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -129,7 +129,6 @@ void ShapeListView::SelectionChanged() { - SimpleListView::SelectionChanged(); if (!fSyncingToSelection) { @@ -387,7 +386,8 @@ if (!LockLooper()) return; - _AddShape(shape, index); + if (_AddShape(shape, index)) + Select(index); UnlockLooper(); } Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleListView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleListView.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleListView.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -555,10 +555,8 @@ if (!LockLooper()) return; - // NOTE: shapes are always added at the end - // of the list, so the sorting is synced... if (_AddStyle(style, index)) - Select(CountItems() - 1); + Select(index); UnlockLooper(); } Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -267,7 +267,7 @@ // TODO: is this really necessary? controlGradient->SetTransform(*fGradient); - if (*fGradient != *controlGradient) { + if (!fGradient->ColorStepsAreEqual(*controlGradient)) { if (fCommandStack) { fCommandStack->Perform( new (nothrow) SetGradientCommand( @@ -279,7 +279,7 @@ _TransferGradientStopColor(); } } else if (object == fGradient) { - if (*fGradient != *controlGradient) { + if (!fGradient->ColorStepsAreEqual(*controlGradient)) { fGradientControl->SetGradient(fGradient); _MarkType(fGradientType->Menu(), fGradient->Type()); // transfer the current gradient color to the current color @@ -288,7 +288,7 @@ } else if (object == fStyle) { // maybe the gradient was added or removed // or the color changed - _SetGradient(fStyle->Gradient()); + _SetGradient(fStyle->Gradient(), false, true); if (fCurrentColor && !fStyle->Gradient()) fCurrentColor->SetColor(fStyle->Color()); } else if (object == fCurrentColor) { @@ -361,7 +361,7 @@ // _SetGradient void -StyleView::_SetGradient(Gradient* gradient, bool forceControlUpdate) +StyleView::_SetGradient(Gradient* gradient, bool forceControlUpdate, bool sendMessage) { if (!forceControlUpdate && fGradient == gradient) return; @@ -387,9 +387,9 @@ _MarkType(fGradientType->Menu(), -1); } - if (Window()) { - BMessage message(MSG_GRADIENT_SELECTED); - message.AddPointer("gradient", (void*)fGradient); + if (sendMessage) { + BMessage message(MSG_STYLE_TYPE_CHANGED); + message.AddPointer("style", fStyle); Window()->PostMessage(&message); } } Modified: haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h =================================================================== --- haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/gui/StyleView.h 2007-09-21 15:21:38 UTC (rev 22269) @@ -31,7 +31,7 @@ // TODO: write lock the document when changing something... enum { - MSG_GRADIENT_SELECTED = 'grsl', + MSG_STYLE_TYPE_CHANGED = 'stch', }; class StyleView : public BView, @@ -59,7 +59,8 @@ private: void _SetGradient(Gradient* gradient, - bool forceControlUpdate = false); + bool forceControlUpdate = false, + bool sendMessage = false); void _MarkType(BMenu* menu, int32 type) const; void _SetStyleType(int32 type); Modified: haiku/trunk/src/apps/icon-o-matic/shape/commands/AddShapesCommand.cpp =================================================================== --- haiku/trunk/src/apps/icon-o-matic/shape/commands/AddShapesCommand.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/apps/icon-o-matic/shape/commands/AddShapesCommand.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -72,8 +72,6 @@ fContainer->RemoveShape(fShapes[j]); break; } - if (fSelection) - fSelection->Select(fShapes[i], i > 0); index++; } fShapesAdded = true; Modified: haiku/trunk/src/libs/icon/style/Gradient.cpp =================================================================== --- haiku/trunk/src/libs/icon/style/Gradient.cpp 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/libs/icon/style/Gradient.cpp 2007-09-21 15:21:38 UTC (rev 22269) @@ -227,25 +227,8 @@ bool Gradient::operator==(const Gradient& other) const { - if (Transformable::operator==(other)) { - int32 count = CountColors(); - if (count == other.CountColors() && - fType == other.fType && - fInterpolation == other.fInterpolation && - fInheritTransformation == other.fInheritTransformation) { - - bool equal = true; - for (int32 i = 0; i < count; i++) { - color_step* ourStep = ColorAtFast(i); - color_step* otherStep = other.ColorAtFast(i); - if (*ourStep != *otherStep) { - equal = false; - break; - } - } - return equal; - } - } + if (Transformable::operator==(other)) + return ColorStepsAreEqual(other); return false; } @@ -256,6 +239,30 @@ return !(*this == other); } +// ColorStepsAreEqual +bool +Gradient::ColorStepsAreEqual(const Gradient& other) const +{ + int32 count = CountColors(); + if (count == other.CountColors() && + fType == other.fType && + fInterpolation == other.fInterpolation && + fInheritTransformation == other.fInheritTransformation) { + + bool equal = true; + for (int32 i = 0; i < count; i++) { + color_step* ourStep = ColorAtFast(i); + color_step* otherStep = other.ColorAtFast(i); + if (*ourStep != *otherStep) { + equal = false; + break; + } + } + return equal; + } + return false; +} + // SetColors void Gradient::SetColors(const Gradient& other) Modified: haiku/trunk/src/libs/icon/style/Gradient.h =================================================================== --- haiku/trunk/src/libs/icon/style/Gradient.h 2007-09-21 13:04:06 UTC (rev 22268) +++ haiku/trunk/src/libs/icon/style/Gradient.h 2007-09-21 15:21:38 UTC (rev 22269) @@ -78,6 +78,8 @@ bool operator==(const Gradient& other) const; bool operator!=(const Gradient& other) const; + bool ColorStepsAreEqual( + const Gradient& other) const; void SetColors(const Gradient& other); From axeld at mail.berlios.de Fri Sep 21 18:59:43 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 21 Sep 2007 18:59:43 +0200 Subject: [Haiku-commits] r22270 - haiku/trunk/src/add-ons/accelerants/common Message-ID: <200709211659.l8LGxh8U007414@sheep.berlios.de> Author: axeld Date: 2007-09-21 18:59:43 +0200 (Fri, 21 Sep 2007) New Revision: 22270 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22270&view=rev Modified: haiku/trunk/src/add-ons/accelerants/common/ddc.c Log: Made providing a place for vdif and vdifLength optional in ddc2_read_edid1(). Modified: haiku/trunk/src/add-ons/accelerants/common/ddc.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-09-21 15:21:38 UTC (rev 22269) +++ haiku/trunk/src/add-ons/accelerants/common/ddc.c 2007-09-21 16:59:43 UTC (rev 22270) @@ -147,13 +147,15 @@ edid_decode(edid, &raw); - *vdif = NULL; - *vdifLength = 0; + if (vdif != NULL) + *vdif = NULL; + if (vdifLength != NULL) + *vdifLength = 0; // skip vdif as long as it's not tested #if 0 status = ddc2_read_vdif(bus, sizeof(raw) * (edid->num_sections + 1), - vdif, vdif_len); + vdif, vdifLength); if (status != B_OK) return status; #endif From axeld at mail.berlios.de Fri Sep 21 19:33:36 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 21 Sep 2007 19:33:36 +0200 Subject: [Haiku-commits] r22271 - haiku/trunk/headers/private/graphics/common Message-ID: <200709211733.l8LHXa48014758@sheep.berlios.de> Author: axeld Date: 2007-09-21 19:33:35 +0200 (Fri, 21 Sep 2007) New Revision: 22271 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22271&view=rev Modified: haiku/trunk/headers/private/graphics/common/ddc.h haiku/trunk/headers/private/graphics/common/i2c.h Log: Made i2c.h and ddc.h C++ safe. Modified: haiku/trunk/headers/private/graphics/common/ddc.h =================================================================== --- haiku/trunk/headers/private/graphics/common/ddc.h 2007-09-21 16:59:43 UTC (rev 22270) +++ haiku/trunk/headers/private/graphics/common/ddc.h 2007-09-21 17:33:35 UTC (rev 22271) @@ -10,6 +10,10 @@ #include "edid.h" +#ifdef __cplusplus +extern "C" { +#endif + void ddc2_init_timing(i2c_bus *bus); // read EDID and VDIF from monitor via ddc2 @@ -17,4 +21,8 @@ status_t ddc2_read_edid1(const i2c_bus *bus, edid1_info *edid, void **vdif, size_t *vdifLength); +#ifdef __cplusplus +} +#endif + #endif /* _DDC_H */ Modified: haiku/trunk/headers/private/graphics/common/i2c.h =================================================================== --- haiku/trunk/headers/private/graphics/common/i2c.h 2007-09-21 16:59:43 UTC (rev 22270) +++ haiku/trunk/headers/private/graphics/common/i2c.h 2007-09-21 17:33:35 UTC (rev 22271) @@ -49,6 +49,10 @@ } i2c_bus; +#ifdef __cplusplus +extern "C" { +#endif + // send and receive data via i2c bus status_t i2c_send_receive(const i2c_bus *bus, int slave_address, const uint8 *writeBuffer, size_t writeLength, uint8 *readBuffer, @@ -61,4 +65,8 @@ // (as timing resolution is 1 microsecond, we cannot reach full speed!) void i2c_get400k_timing(i2c_timing *timing); +#ifdef __cplusplus +} +#endif + #endif /* _I2C_H */ From axeld at mail.berlios.de Fri Sep 21 20:06:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Fri, 21 Sep 2007 20:06:57 +0200 Subject: [Haiku-commits] r22272 - in haiku/trunk: headers/private/graphics/intel_extreme src/add-ons/accelerants/intel_extreme Message-ID: <200709211806.l8LI6vTK017002@sheep.berlios.de> Author: axeld Date: 2007-09-21 20:06:56 +0200 (Fri, 21 Sep 2007) New Revision: 22272 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22272&view=rev Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h haiku/trunk/src/add-ons/accelerants/intel_extreme/Jamfile haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp Log: Implemented I2C support to get the DDC EDID info from the monitor - it's working as is, but nothing is done with the data yet (besides dumping them to the serial output). Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h =================================================================== --- haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-09-21 17:33:35 UTC (rev 22271) +++ haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-09-21 18:06:56 UTC (rev 22272) @@ -308,6 +308,29 @@ #define COMMAND_MODE_RGB16 0x01 #define COMMAND_MODE_RGB32 0x03 +// i2c + +#define INTEL_I2C_IO_A 0x5010 +#define INTEL_I2C_IO_B 0x5014 +#define INTEL_I2C_IO_C 0x5018 +#define INTEL_I2C_IO_D 0x501c +#define INTEL_I2C_IO_E 0x5020 +#define INTEL_I2C_IO_F 0x5024 +#define INTEL_I2C_IO_G 0x5028 +#define INTEL_I2C_IO_H 0x502c + +#define I2C_CLOCK_DIRECTION_MASK (1 << 0) +#define I2C_CLOCK_DIRECTION_OUT (1 << 1) +#define I2C_CLOCK_VALUE_MASK (1 << 2) +#define I2C_CLOCK_VALUE_OUT (1 << 3) +#define I2C_CLOCK_VALUE_IN (1 << 4) +#define I2C_DATA_DIRECTION_MASK (1 << 8) +#define I2C_DATA_DIRECTION_OUT (1 << 9) +#define I2C_DATA_VALUE_MASK (1 << 10) +#define I2C_DATA_VALUE_OUT (1 << 11) +#define I2C_DATA_VALUE_IN (1 << 12) +#define I2C_RESERVED ((1 << 13) | (1 << 5)) + // overlay #define INTEL_OVERLAY_UPDATE 0x30000 Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/Jamfile =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/Jamfile 2007-09-21 17:33:35 UTC (rev 22271) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/Jamfile 2007-09-21 18:06:56 UTC (rev 22272) @@ -15,7 +15,7 @@ memory.cpp mode.cpp overlay.cpp - : be + : be libaccelerantscommon.a ; Package haiku-intel_extreme-cvs : Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-09-21 17:33:35 UTC (rev 22271) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-09-21 18:06:56 UTC (rev 22272) @@ -18,6 +18,10 @@ #include #include +#include +#include + + #define TRACE_MODE #ifdef TRACE_MODE extern "C" void _sPrintf(const char *format, ...); @@ -107,6 +111,51 @@ static const uint32 kMaxNumModes = kNumBaseModes * 4; +static status_t +get_i2c_signals(void* cookie, int* _clock, int* _data) +{ + uint32 ioRegister = (uint32)cookie; + uint32 value = read32(ioRegister); + + *_clock = (value & I2C_CLOCK_VALUE_IN) != 0; + *_data = (value & I2C_DATA_VALUE_IN) != 0; + + return B_OK; +} + + +static status_t +set_i2c_signals(void* cookie, int clock, int data) +{ + uint32 ioRegister = (uint32)cookie; + uint32 value; + + if (gInfo->shared_info->device_type == (INTEL_TYPE_8xx | INTEL_TYPE_83x)) { + // on these chips, the reserved values are fixed + value = 0; + } else { + // on all others, we have to preserve them manually + value = read32(ioRegister) & I2C_RESERVED; + } + + if (data != 0) + value |= I2C_DATA_DIRECTION_MASK; + else + value |= I2C_DATA_DIRECTION_MASK | I2C_DATA_DIRECTION_OUT | I2C_DATA_VALUE_MASK; + + if (clock != 0) + value |= I2C_CLOCK_DIRECTION_MASK; + else + value |= I2C_CLOCK_DIRECTION_MASK | I2C_CLOCK_DIRECTION_OUT | I2C_CLOCK_VALUE_MASK; + + write32(ioRegister, value); + read32(ioRegister); + // make sure the PCI bus has flushed the write + + return B_OK; +} + + /*! Creates the initial mode list of the primary accelerant. It's called from intel_init_accelerant(). @@ -143,6 +192,19 @@ gInfo->shared_info->mode_list_area = gInfo->mode_list_area; gInfo->shared_info->mode_count = count; + edid1_info edid; + i2c_bus bus; + bus.cookie = (void*)INTEL_I2C_IO_A; + bus.set_signals = &set_i2c_signals; + bus.get_signals = &get_i2c_signals; + ddc2_init_timing(&bus); + + if (ddc2_read_edid1(&bus, &edid, NULL, NULL) == B_OK) { + edid_dump(&edid); + } else { + TRACE(("intel_extreme: getting EDID failed!\n")); + } + return B_OK; } From stippi at mail.berlios.de Sat Sep 22 10:41:17 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 22 Sep 2007 10:41:17 +0200 Subject: [Haiku-commits] r22273 - haiku/trunk/src/apps/deskcalc Message-ID: <200709220841.l8M8fHRM027637@sheep.berlios.de> Author: stippi Date: 2007-09-22 10:41:16 +0200 (Sat, 22 Sep 2007) New Revision: 22273 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22273&view=rev Modified: haiku/trunk/src/apps/deskcalc/CalcOptionsWindow.cpp Log: * the "auto numlock" option is now off by default, for all the notebook users (this had irritated me myself when I first used DeskCalc on a notebook) Modified: haiku/trunk/src/apps/deskcalc/CalcOptionsWindow.cpp =================================================================== --- haiku/trunk/src/apps/deskcalc/CalcOptionsWindow.cpp 2007-09-21 18:06:56 UTC (rev 22272) +++ haiku/trunk/src/apps/deskcalc/CalcOptionsWindow.cpp 2007-09-22 08:41:16 UTC (rev 22273) @@ -19,7 +19,7 @@ CalcOptions::CalcOptions() - : auto_num_lock(true), + : auto_num_lock(false), audio_feedback(false), show_keypad(true) { From leavengood at mail.berlios.de Sat Sep 22 18:30:23 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sat, 22 Sep 2007 18:30:23 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread Message-ID: <200709221630.l8MGUNwK011028@sheep.berlios.de> Author: leavengood Date: 2007-09-22 18:30:22 +0200 (Sat, 22 Sep 2007) New Revision: 22274 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22274&view=rev Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c haiku/trunk/src/system/libroot/posix/pthread/pthread_condattr.c Modified: haiku/trunk/headers/posix/pthread.h haiku/trunk/src/system/libroot/posix/pthread/Jamfile haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h Log: I needed Pthread condition variables for WebKit, so I implemented them. I have tested this with a simple test program I downloaded from the internet. We get the same result as on Linux, so I think this is good. I will test it more with WebKit later. Our Pthreads implementation is still missing some stuff, but this adds a good chunk. Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2007-09-22 08:41:16 UTC (rev 22273) +++ haiku/trunk/headers/posix/pthread.h 2007-09-22 16:30:22 UTC (rev 22274) @@ -12,7 +12,7 @@ typedef struct _pthread_mutex *pthread_mutex_t; typedef struct _pthread_mutexattr *pthread_mutexattr_t; typedef struct _pthread_cond *pthread_cond_t; -typedef struct _pthread_cond_attr *pthread_condattr_t; +typedef struct _pthread_condattr *pthread_condattr_t; typedef int pthread_key_t; typedef struct _pthread_once pthread_once_t; typedef struct _pthread_rwlock *pthread_rwlock_t; @@ -42,10 +42,10 @@ /* * Flags for threads and thread attributes. */ -#define PTHREAD_DETACHED 0x1 +#define PTHREAD_DETACHED 0x1 #define PTHREAD_SCOPE_SYSTEM 0x2 #define PTHREAD_INHERIT_SCHED 0x4 -#define PTHREAD_NOFLOAT 0x8 +#define PTHREAD_NOFLOAT 0x8 #define PTHREAD_CREATE_DETACHED PTHREAD_DETACHED #define PTHREAD_CREATE_JOINABLE 0 @@ -61,14 +61,12 @@ #define PTHREAD_CANCEL_ASYNCHRONOUS 2 #define PTHREAD_CANCELED ((void *) 1) -#define PTHREAD_COND_INITIALIZER NULL - #define PTHREAD_NEEDS_INIT 0 #define PTHREAD_DONE_INIT 1 #define PTHREAD_ONCE_INIT { PTHREAD_NEEDS_INIT, NULL } #define PTHREAD_BARRIER_SERIAL_THREAD -1 -#define PTHREAD_PRIO_NONE 0 +#define PTHREAD_PRIO_NONE 0 #define PTHREAD_PRIO_INHERIT 1 #define PTHREAD_PRIO_PROTECT 2 @@ -84,6 +82,9 @@ #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER \ pthread_recursive_mutex_static_initializer(); +extern pthread_cond_t _pthread_cond_static_initializer(void); +#define PTHREAD_COND_INITIALIZER _pthread_cond_static_initializer(); + /* mutex functions */ extern int pthread_mutex_destroy(pthread_mutex_t *mutex); extern int pthread_mutex_getprioceiling(pthread_mutex_t *mutex, int *_priorityCeiling); @@ -107,6 +108,21 @@ extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *mutexAttr, int processShared); extern int pthread_mutexattr_settype(pthread_mutexattr_t *mutexAttr, int type); +/* condition variable functions */ +extern int pthread_cond_destroy(pthread_cond_t *cond); +extern int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); +extern int pthread_cond_broadcast(pthread_cond_t *cond); +extern int pthread_cond_signal(pthread_cond_t *cond); +extern int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime); +extern int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); + +/* condition variable attribute functions */ +extern int pthread_condattr_destroy(pthread_condattr_t *condAttr); +extern int pthread_condattr_init(pthread_condattr_t *condAttr); +extern int pthread_condattr_getpshared(const pthread_condattr_t *condAttr, int *processShared); +extern int pthread_condattr_setpshared(pthread_condattr_t *condAttr, int processShared); + /* misc. functions */ extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); Modified: haiku/trunk/src/system/libroot/posix/pthread/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2007-09-22 08:41:16 UTC (rev 22273) +++ haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2007-09-22 16:30:22 UTC (rev 22274) @@ -6,6 +6,8 @@ pthread.c pthread_atfork.c pthread_attr.c + pthread_cond.c + pthread_condattr.c pthread_key.c pthread_mutex.c pthread_mutexattr.c Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-22 08:41:16 UTC (rev 22273) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-22 16:30:22 UTC (rev 22274) @@ -0,0 +1,183 @@ +/* + * Copyright 2007, Ryan Leavengood, leavengood at gmail.com. + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include +#include "pthread_private.h" + +#include +#include +#include + + +static const pthread_condattr pthread_condattr_default = { + false +}; + + +pthread_cond_t +_pthread_cond_static_initializer(void) +{ + pthread_cond_t cond; + if (pthread_cond_init(&cond, NULL) == B_OK) + return cond; + + return NULL; +} + + +int +pthread_cond_init(pthread_cond_t *_cond, const pthread_condattr_t *_attr) +{ + pthread_cond *cond; + const pthread_condattr *attr = NULL; + + if (_cond == NULL) + return B_BAD_VALUE; + + cond = (pthread_cond *)malloc(sizeof(pthread_cond)); + if (cond == NULL) + return B_NO_MEMORY; + + if (_attr != NULL) + attr = *_attr; + else + attr = &pthread_condattr_default; + + // TODO: What about the process_shared attribute? + cond->sem = create_sem(0, "pthread_cond"); + if (cond->sem < B_OK) { + free(cond); + return B_WOULD_BLOCK; + // stupid error code (EAGAIN) but demanded by POSIX + } + + cond->mutex = NULL; + cond->waiter_count = 0; + memcpy(&cond->attr, attr, sizeof(pthread_condattr)); + + *_cond = cond; + return B_OK; +} + + +int +pthread_cond_destroy(pthread_cond_t *_cond) +{ + pthread_cond *cond; + + if (_cond == NULL || (cond = *_cond) == NULL) + return B_BAD_VALUE; + + delete_sem(cond->sem); + *_cond = NULL; + free(cond); + + return B_OK; +} + + +static status_t +cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) +{ + status_t status = B_OK; + + if (cond == NULL || *_mutex == NULL) + return B_BAD_VALUE; + + if ((*_mutex)->owner != find_thread(NULL)) + // POSIX suggests EPERM (= B_NOT_ALLOWED) to be returned + // if this thread does not own the mutex + return B_NOT_ALLOWED; + + if (cond->mutex && cond->mutex != _mutex) + // POSIX suggests EINVAL (= B_BAD_VALUE) to be returned if + // the same condition variable is used with multiple mutexes + return B_BAD_VALUE; + + cond->mutex = _mutex; + cond->waiter_count++; + pthread_mutex_unlock(_mutex); + status = acquire_sem_etc(cond->sem, 1, timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); + pthread_mutex_lock(_mutex); + cond->waiter_count--; + // If there are no more waiters, we can change mutexes + if (cond->waiter_count == 0) + cond->mutex = NULL; + + return status; +} + +static status_t +cond_signal(pthread_cond *cond, bool broadcast) +{ + if (cond == NULL) + return B_BAD_VALUE; + + return release_sem_etc(cond->sem, broadcast ? cond->waiter_count : 1, 0); +} + +int +pthread_cond_wait(pthread_cond_t *_cond, pthread_mutex_t *_mutex) +{ + if (_cond == NULL || _mutex == NULL) + return B_BAD_VALUE; + + if (*_cond == NULL) + pthread_cond_init(_cond, NULL); + + return cond_wait(*_cond, _mutex, B_INFINITE_TIMEOUT); +} + + +int +pthread_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, + const struct timespec *tv) +{ + bool invalidTime = false; + status_t status; + + bigtime_t timeout = 0; + if (tv && tv->tv_nsec < 1000*1000*1000 && tv->tv_nsec >= 0) + timeout = tv->tv_sec * 1000000LL + tv->tv_nsec / 1000LL; + else + invalidTime = true; + + if (_cond == NULL || _mutex == NULL) + return B_BAD_VALUE; + + if (*_cond == NULL) + pthread_cond_init(_cond, NULL); + + status = cond_wait(*_cond, _mutex, timeout); + if (status != B_OK && invalidTime) { + // POSIX requires EINVAL (= B_BAD_VALUE) to be returned + // if the timespec structure was invalid + return B_BAD_VALUE; + } + + return status; +} + + +int +pthread_cond_broadcast(pthread_cond_t *_cond) +{ + if (_cond == NULL) + return B_BAD_VALUE; + + return cond_signal(*_cond, true); +} + + +int +pthread_cond_signal(pthread_cond_t *_cond) +{ + if (_cond == NULL) + return B_BAD_VALUE; + + return cond_signal(*_cond, false); +} + Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_condattr.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_condattr.c 2007-09-22 08:41:16 UTC (rev 22273) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_condattr.c 2007-09-22 16:30:22 UTC (rev 22274) @@ -0,0 +1,73 @@ +/* + * Copyright 2007, Ryan Leavengood, leavengood at gmail.com. + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include +#include "pthread_private.h" + +#include + + +int +pthread_condattr_init(pthread_condattr_t *_condAttr) +{ + pthread_condattr *attr; + + if (_condAttr == NULL) + return B_BAD_VALUE; + + attr = (pthread_condattr *)malloc(sizeof(pthread_condattr)); + if (attr == NULL) + return B_NO_MEMORY; + + attr->process_shared = false; + + *_condAttr = attr; + return B_OK; +} + + +int +pthread_condattr_destroy(pthread_condattr_t *_condAttr) +{ + pthread_condattr *attr; + + if (_condAttr == NULL || (attr = *_condAttr) == NULL) + return B_BAD_VALUE; + + *_condAttr = NULL; + free(attr); + + return B_OK; +} + + +int +pthread_condattr_getpshared(const pthread_condattr_t *_condAttr, int *_processShared) +{ + pthread_condattr *attr; + + if (_condAttr == NULL || (attr = *_condAttr) == NULL || _processShared == NULL) + return B_BAD_VALUE; + + *_processShared = attr->process_shared ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE; + return B_OK; +} + + +int +pthread_condattr_setpshared(pthread_condattr_t *_condAttr, int processShared) +{ + pthread_condattr *attr; + + if (_condAttr == NULL || (attr = *_condAttr) == NULL + || processShared < PTHREAD_PROCESS_PRIVATE + || processShared > PTHREAD_PROCESS_SHARED) + return B_BAD_VALUE; + + attr->process_shared = processShared == PTHREAD_PROCESS_SHARED ? true : false; + return B_OK; +} + Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2007-09-22 08:41:16 UTC (rev 22273) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2007-09-22 16:30:22 UTC (rev 22274) @@ -1,9 +1,10 @@ #ifndef _PTHREAD_PRIVATE_H_ #define _PTHREAD_PRIVATE_H_ /* -** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003, Axel D?rfler, axeld at pinc-software.de. + * Copyright 2007, Ryan Leavengood, leavengood at gmail.com. + * All rights reserved. Distributed under the terms of the MIT License. + */ #include @@ -12,6 +13,17 @@ // necessary in the future (not only due to the incomplete implementation // at this point). +typedef struct _pthread_condattr { + bool process_shared; +} pthread_condattr; + +typedef struct _pthread_cond { + sem_id sem; + pthread_mutex_t *mutex; + int32 waiter_count; + pthread_condattr attr; +} pthread_cond; + typedef struct _pthread_mutexattr { int32 type; bool process_shared; From axeld at mail.berlios.de Sat Sep 22 18:44:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 22 Sep 2007 18:44:28 +0200 Subject: [Haiku-commits] r22275 - in haiku/vendor: . atftp atftp/current atftp/current/debian atftp/current/debian/po atftp/current/docs atftp/current/redhat atftp/current/test Message-ID: <200709221644.l8MGiSQL011271@sheep.berlios.de> Author: axeld Date: 2007-09-22 18:44:17 +0200 (Sat, 22 Sep 2007) New Revision: 22275 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22275&view=rev Added: haiku/vendor/atftp/ haiku/vendor/atftp/current/ haiku/vendor/atftp/current/BUGS haiku/vendor/atftp/current/Changelog haiku/vendor/atftp/current/FAQ haiku/vendor/atftp/current/INSTALL haiku/vendor/atftp/current/LICENSE haiku/vendor/atftp/current/Makefile.am haiku/vendor/atftp/current/Makefile.in haiku/vendor/atftp/current/README haiku/vendor/atftp/current/README.CVS haiku/vendor/atftp/current/README.MCAST haiku/vendor/atftp/current/README.PCRE haiku/vendor/atftp/current/TODO haiku/vendor/atftp/current/aclocal.m4 haiku/vendor/atftp/current/argz.c haiku/vendor/atftp/current/argz.h haiku/vendor/atftp/current/atftp.1 haiku/vendor/atftp/current/atftpd.8 haiku/vendor/atftp/current/autogen.sh haiku/vendor/atftp/current/config.guess haiku/vendor/atftp/current/config.h.in haiku/vendor/atftp/current/config.sub haiku/vendor/atftp/current/configure haiku/vendor/atftp/current/configure.ac haiku/vendor/atftp/current/debian/ haiku/vendor/atftp/current/debian/atftp.docs haiku/vendor/atftp/current/debian/atftp.files haiku/vendor/atftp/current/debian/atftpd.README.Debian haiku/vendor/atftp/current/debian/atftpd.conffiles haiku/vendor/atftp/current/debian/atftpd.config haiku/vendor/atftp/current/debian/atftpd.docs haiku/vendor/atftp/current/debian/atftpd.files haiku/vendor/atftp/current/debian/atftpd.init.d haiku/vendor/atftp/current/debian/atftpd.postinst haiku/vendor/atftp/current/debian/atftpd.postrm haiku/vendor/atftp/current/debian/atftpd.prerm haiku/vendor/atftp/current/debian/atftpd.templates haiku/vendor/atftp/current/debian/changelog haiku/vendor/atftp/current/debian/control haiku/vendor/atftp/current/debian/copyright haiku/vendor/atftp/current/debian/po/ haiku/vendor/atftp/current/debian/po/POTFILES.in haiku/vendor/atftp/current/debian/po/de.po haiku/vendor/atftp/current/debian/po/es.po haiku/vendor/atftp/current/debian/po/fr.po haiku/vendor/atftp/current/debian/po/sv.po haiku/vendor/atftp/current/debian/po/templates.pot haiku/vendor/atftp/current/debian/rules haiku/vendor/atftp/current/depcomp haiku/vendor/atftp/current/docs/ haiku/vendor/atftp/current/docs/pxespec.txt haiku/vendor/atftp/current/install-sh haiku/vendor/atftp/current/logger.c haiku/vendor/atftp/current/logger.h haiku/vendor/atftp/current/missing haiku/vendor/atftp/current/mkinstalldirs haiku/vendor/atftp/current/options.c haiku/vendor/atftp/current/options.h haiku/vendor/atftp/current/redhat/ haiku/vendor/atftp/current/redhat/README haiku/vendor/atftp/current/redhat/atftp.spec haiku/vendor/atftp/current/redhat/atftp.spec.in haiku/vendor/atftp/current/stats.c haiku/vendor/atftp/current/stats.h haiku/vendor/atftp/current/test/ haiku/vendor/atftp/current/test/Makefile haiku/vendor/atftp/current/test/Makefile.am haiku/vendor/atftp/current/test/Makefile.in haiku/vendor/atftp/current/test/load.sh haiku/vendor/atftp/current/test/mtftp.conf haiku/vendor/atftp/current/test/pcre_pattern.txt haiku/vendor/atftp/current/test/test.sh haiku/vendor/atftp/current/test/test_suite.txt haiku/vendor/atftp/current/tftp.c haiku/vendor/atftp/current/tftp.h haiku/vendor/atftp/current/tftp_def.c haiku/vendor/atftp/current/tftp_def.h haiku/vendor/atftp/current/tftp_file.c haiku/vendor/atftp/current/tftp_io.c haiku/vendor/atftp/current/tftp_io.h haiku/vendor/atftp/current/tftp_mtftp.c haiku/vendor/atftp/current/tftpd.c haiku/vendor/atftp/current/tftpd.h haiku/vendor/atftp/current/tftpd_file.c haiku/vendor/atftp/current/tftpd_list.c haiku/vendor/atftp/current/tftpd_mcast.c haiku/vendor/atftp/current/tftpd_mtftp.c haiku/vendor/atftp/current/tftpd_mtftp.h haiku/vendor/atftp/current/tftpd_pcre.c haiku/vendor/atftp/current/tftpd_pcre.h Log: Import of atftp 0.7 into the vendor branch. We're only using the atftpd part from it (in src/bin/network/). Added: haiku/vendor/atftp/current/BUGS =================================================================== --- haiku/vendor/atftp/current/BUGS 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/BUGS 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,12 @@ +If you find some bugs, please send us a detailed description of the +problem observed. Please include the logfile and a full description of +your setup. + +To get a detailed log, use --verbose=7 and --logfile /var/log/tftpd to +generate a separate logfile. Please include the number of machines +that were booting of the server, the type of server (single or dual +processor, processor speed, etc.) and the type of network you have +(10Mbit, 100Mbit or 1Gbit). + +Jean-Pierre Lefebvre +Remi Lefebvre \ No newline at end of file Added: haiku/vendor/atftp/current/Changelog =================================================================== --- haiku/vendor/atftp/current/Changelog 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/Changelog 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,38 @@ +atftp (0.7) + * Fixed typo (Debian bug: #147218). + * Fixed French translations for real this time (Debian bug: #136339). + * Add DESTDIR to install rules in Makefile.am, used when building RPM. + (from Jose Pedro Oliveira) + * Fix make dist problem where not all files get in the archives + (from Joshua Aune) + * add dist-hook to remove CVS files + * Fix bad timeout behaviour. (Debian bug: #155300) (Debian bug: #180461) + * Fix description in control file (Debian bug: #162836) + * Client can now compile without libreadline. This is also a configure + option (based on Leif Lindholm patch) + * Copy argz function from libc (provided by Leif Lindholm). Configure + use this local copy if argz functions not found in libc. + * Incorporate proposed enhencement (failing multicast client and fixes) + from Leif Lindholm and Bojan Pisler, with some modifications in the + implementation. + * Incorporate PCRE support from Jeff Miller. + * Add mtftp support (as defined in PXE specification) + * Fixed type (Debian bug: #181796) + * Fix (from Steve Kemp) security issue reported here: + http://www.securitytracker.com/alerts/2002/Sep/1005231.html + http://www.netric.org/advisories/netric-adv010.txt + * Make atftp reply on the same interface as the received request + * Add --bind-address option for atftpd to bind to a particular IP + address only (from Thomas Anders ) + * Implement netascii support + * Implement --pidfile option (see man page) + * Update debian files + + -- J-P Fri, 21 Feb 2003 00:17:31 -0500 + + +Prior versions of atftp where using the Debian changelog as the main +changelog file. This was easier since my brother was the maintainer. +From now on, I'm using a separate file (this file). Debian related +changes will be maintained by the maintainer and not reflected in this +source tree. Added: haiku/vendor/atftp/current/FAQ =================================================================== --- haiku/vendor/atftp/current/FAQ 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/FAQ 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,127 @@ +1) What are the best values for --tftpd-timeout, --retry-timeout and + --max-thread ? + +There is no absolute answer to that question. It is highly dependent +of your personnal setup. Here's an explanation of what they mean and +how to tune them. + +--tftpd-timeout controls how much time the server will wait for an +incomming connection before killing the main thread. If you use small +number, the server will be respawned by inetd when a new query +arrives. If number is high, atftpd will behave more like a standalone +server in that it will always receive queries directly. When booting a +whole cluster, the first tftp request will start the daemon and have +higher latency. All other clients will be handled directly by the tftp +server. It is a good idea to set the timeout high enough so that the +main thread won't hog your system killing itself and respawning all +the time. + +--retry-timeout controls how much time the server waits before +retransmitting a packet. If you expect some lag on the network (when +the network is under high load), it is a good idea to increase that +value. Note that the client's delay must be taken into +consideration. The client can set the server delay too, and it +overides the --retry-timeout value. + +--max-thread controls how many simultaneous client may be served. This +limit depends on your server's performance. It also depends on the +maximum load you are willing to put on the server. For exemple, this +server may have other things to do, and you want to limit the number +of clients booting at the same time to 10. The maximum number of +threads is also throttled by the available bandwidth of the network +and server, because packet cannot be processed fast enough and there is +a maximum rate at which servers may be started. But this is not a desirable +condition and --maxthread should be set to avoid that. + +2) Why do I get "recvfrom: Connection refused" in my log file? + +That indicates that either your server or network can't handle all the +packets fast enough. What happens is the following: + - client sends a RRQ (read request) + - server starts a thread (A) that sends a DATA packet + - the client times out and sends a second RRQ + - server A sends the whole file + - client and server thread A both exit normally + - server finally starts a second thread (B) for the second RRQ + - the server thread sends a DATA packet to the client + - the client isn't listenning anymore, we got a connection refused. + +Solution: + a) increase timeout on client and server side + b) reduce the number of concurrent thread allowed + c) do nothing, it's not harmfull at all. + +3) How can I boot a simple image from the network? + +A boot from LAN setup requires the following on the server side: a dhcp +server, a tftp server (atftpd), a working pxelinux config, a kernel image +and a root file system image. + +You can get documentation on how to configure the dhcp server to work with +pxelinux from the pxelinux and dhcp documentation. + +For atftp to work out of the box, be sure to have the following line in your +inetd.conf and to restart the inetd daemon: + tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot + +You also need to have /tftpboot world readable. + +The pxelinux configuration is the same as syslinux. Documentation for it can +be found in the syslinux package. + +The configuration file for pxelinux will tell it the name of the kernel and +file system images to download. It is very important that you tell the kernel +image where to get its root file system with rdev like this for example: + + rdev image /dev/ramdisk + +You can find detailed information on how to create a filesystem image in the +Bootdisk HOWTO (www.linuxdoc.org). + +On the client side, you need to have a boot ROM. Have a look at Etherboot +(www.etherboot.org), NetTools and Nilo (www.nilo.org) to find out more +information about this if you need to burn one. + +After you got all of these setup, you should see the client attempt to get +an IP address on boot, download pxelinux.bin, then download the kernel and +filesystem images and boot from it. + + +4) I followed the above steps and it still fails to boot! + +Try putting log verbosity at high in the concerned programs on the server side +and see if something fails or if you get the requests at all. You should see +dhcpd give a lease to the client, if it doesn't, your dhcp configuration is +faulty. You can also monitor the activity on the network to track down the +problem using tools like tcpdump or ethereal. + +5) How do I setup multicast stuff? + + - Make sure your client and server support multicast. + - Make sure you server routing table know what to do with multicast addresses. + You need to do something like this: + route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0 + - Make sure your network is working by testing with atftp client against + atftpd server + +That's currently all that I've made working folks. I've never tried a multicast +boot ROM or boot loader yet. + +6) What inetd or xinetd configuration should I use? + +Something like that for inetd in /etc/inetd.conf: +tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd + +For xinetd, in /etc/xinetd.conf: +service tftp +{ + socket_type = dgram + protocol = udp + wait = no + user = nobody + server = /usr/sbin/in.tftpd + server_args = +} + +This is the basic stuff. Read inetd or xinetd man page for more specialised +configuration. \ No newline at end of file Added: haiku/vendor/atftp/current/INSTALL =================================================================== --- haiku/vendor/atftp/current/INSTALL 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/INSTALL 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,84 @@ +The simplest way to install atftp is using either the Debian package +or one provided by your distribution if any. If you need to install +atftp from source, here's the procedure. + + +1) Needed libraries + ---------------- + + libpthread Needed for the atftpd server. + libwrap Optional if you need host access control. + libpcre Optional if you want to perform file name + substitution. See README.PCRE. + libreadline Optional. Used by the atftp client for better command + line input and history. + + +2) Needed tools + ------------ + + At least, you need these programs: + make + gcc + You may also need these: + cvs + automake (tested using version 1.7 and 1.8) + autoconf (tested with version 2.50) + + +3) How to compile + -------------- + + 3.1) From tarball + + ./configure [options] (this generates makefiles) + make (actually build the programs) + su -c 'make install' (install files (default location is /usr) + + 3.2) From cvs checkout + + ./autogen.sh (this generate the configure script) + ./configure [options] (this generate makefiles) + make (actually build the programs) + su -c 'make install' (install files (default location is /usr) + + +4) How to start atftpd server + -------------------------- + +4.1) Using the inetd super server + + Add this line to the /etc/inetd.conf file: + + tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot + + You can add needed option to atftpd as you which at the end of the + line. + +4.2) Using xinetd + + Add this to the /etc/xinetd.conf file, or create /etc/xinetd.d/tftp-udp file + with the following content: + + # tftp-udp + service tftp + { + id = tftp-udp + disable = no + socket_type = dgram + protocol = udp + wait = no + user = nobody + nice = 5 + server = /usr/local/sbin/atftpd + server_args = /tftpboot # add other server argument as necessary + } + # eof + +4.3) As a stand alone server from init.d scripts + + You need to add the proper init script in you boot sequence. The + Debian package automatically does that. I'm not aware if any rpm based + distribution include init scripts. If you absolutely need this on rpm + based distribution or on other systems, start with the Debian + scripts and adapt it to your particular system. Added: haiku/vendor/atftp/current/LICENSE =================================================================== --- haiku/vendor/atftp/current/LICENSE 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/LICENSE 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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/atftp/current/Makefile.am =================================================================== --- haiku/vendor/atftp/current/Makefile.am 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/Makefile.am 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,50 @@ +# Makefile.am +# Automake makefile for atftp +# +# $Id: Makefile.am,v 1.15 2004/03/16 01:37:24 jp Exp $ +# +# Copyright (c) 2001 Jean-Pierre Lefebvre +# and Remi Lefebvre +# +# atftp is free software; you can redistribute them and/or modify them +# 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 + +AUTOMAKE_OPTIONS = foreign +SUBDIRS = . test +DIST_SUBDIRS = $(SUBDIRS) +CLEANFILES = *~ +DISTCLEANFILES = libtool config.status + +man_MANS = atftp.1 atftpd.8 +dist_scripts = autogen.sh +dist_docs = BUGS Changelog FAQ LICENSE README.CVS README.MCAST README.PCRE +dist_dirs = test redhat docs debian +EXTRA_DIST = $(dist_docs) $(dist_dirs) $(man_MANS) $(dist_scripts) + +noinst_HEADERS = argz.h logger.h options.h stats.h tftp.h tftp_def.h tftp_io.h \ + tftpd.h tftpd_pcre.h tftpd_mtftp.h + +bin_PROGRAMS = atftp +atftp_LDADD = $(LIBTERMCAP) $(LIBREADLINE) +atftp_SOURCES = tftp.c tftp_io.c logger.c options.c tftp_def.c tftp_file.c \ + argz.c tftp_mtftp.c + +sbin_PROGRAMS = atftpd +atftpd_LDADD = $(LIBPTHREAD) $(LIBWRAP) $(LIBPCRE) +atftpd_SOURCES = tftpd.c logger.c options.c stats.c tftp_io.c tftp_def.c \ + tftpd_file.c tftpd_list.c tftpd_mcast.c argz.c tftpd_pcre.c \ + tftpd_mtftp.c + +install-exec-hook: + (cd $(DESTDIR)$(sbindir) && ln -s atftpd in.tftpd) + +install-data-hook: + (cd $(DESTDIR)$(mandir)/man8 && ln -s atftpd.8 in.tftpd.8) + +uninstall-local: + rm -f $(DESTDIR)$(sbindir)/in.tftpd $(DESTDIR)$(mandir)/man8/in.tftpd.8 + +dist-hook: + cd $(distdir) && rm -rf `find . -type d -name CVS` Added: haiku/vendor/atftp/current/Makefile.in =================================================================== --- haiku/vendor/atftp/current/Makefile.in 2007-09-22 16:30:22 UTC (rev 22274) +++ haiku/vendor/atftp/current/Makefile.in 2007-09-22 16:44:17 UTC (rev 22275) @@ -0,0 +1,863 @@ +# Makefile.in generated by automake 1.8.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + at SET_MAKE@ + +# Makefile.am +# Automake makefile for atftp +# +# $Id: Makefile.am,v 1.15 2004/03/16 01:37:24 jp Exp $ +# +# Copyright (c) 2001 Jean-Pierre Lefebvre +# and Remi Lefebvre +# +# atftp is free software; you can redistribute them and/or modify them +# 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 + + +SOURCES = $(atftp_SOURCES) $(atftpd_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_triplet = @host@ +bin_PROGRAMS = atftp$(EXEEXT) +sbin_PROGRAMS = atftpd$(EXEEXT) +DIST_COMMON = README $(am__configure_deps) $(noinst_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(top_srcdir)/configure \ + $(top_srcdir)/redhat/atftp.spec.in INSTALL TODO config.guess \ + config.sub depcomp install-sh missing mkinstalldirs +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = redhat/atftp.spec +am__installdirs = $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir) $(DESTDIR)$(man1dir) $(DESTDIR)$(man8dir) +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) +am_atftp_OBJECTS = tftp.$(OBJEXT) tftp_io.$(OBJEXT) logger.$(OBJEXT) \ + options.$(OBJEXT) tftp_def.$(OBJEXT) tftp_file.$(OBJEXT) \ + argz.$(OBJEXT) tftp_mtftp.$(OBJEXT) +atftp_OBJECTS = $(am_atftp_OBJECTS) +am__DEPENDENCIES_1 = +atftp_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am_atftpd_OBJECTS = tftpd.$(OBJEXT) logger.$(OBJEXT) options.$(OBJEXT) \ + stats.$(OBJEXT) tftp_io.$(OBJEXT) tftp_def.$(OBJEXT) \ + tftpd_file.$(OBJEXT) tftpd_list.$(OBJEXT) \ + tftpd_mcast.$(OBJEXT) argz.$(OBJEXT) tftpd_pcre.$(OBJEXT) \ + tftpd_mtftp.$(OBJEXT) +atftpd_OBJECTS = $(am_atftpd_OBJECTS) +atftpd_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles + at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/argz.Po ./$(DEPDIR)/logger.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/options.Po ./$(DEPDIR)/stats.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftp.Po ./$(DEPDIR)/tftp_def.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftp_file.Po ./$(DEPDIR)/tftp_io.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftp_mtftp.Po ./$(DEPDIR)/tftpd.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftpd_file.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftpd_list.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftpd_mcast.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftpd_mtftp.Po \ + at AMDEP_TRUE@ ./$(DEPDIR)/tftpd_pcre.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(atftp_SOURCES) $(atftpd_SOURCES) +DIST_SOURCES = $(atftp_SOURCES) $(atftpd_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +man1dir = $(mandir)/man1 +man8dir = $(mandir)/man8 +NROFF = nroff +MANS = $(man_MANS) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +ISODATE = @ISODATE@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBPCRE = @LIBPCRE@ +LIBPTHREAD = @LIBPTHREAD@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBTERMCAP = @LIBTERMCAP@ +LIBWRAP = @LIBWRAP@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PLATFORM = @PLATFORM@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +AUTOMAKE_OPTIONS = foreign +SUBDIRS = . test +DIST_SUBDIRS = $(SUBDIRS) +CLEANFILES = *~ +DISTCLEANFILES = libtool config.status +man_MANS = atftp.1 atftpd.8 +dist_scripts = autogen.sh +dist_docs = BUGS Changelog FAQ LICENSE README.CVS README.MCAST README.PCRE +dist_dirs = test redhat docs debian +EXTRA_DIST = $(dist_docs) $(dist_dirs) $(man_MANS) $(dist_scripts) +noinst_HEADERS = argz.h logger.h options.h stats.h tftp.h tftp_def.h tftp_io.h \ + tftpd.h tftpd_pcre.h tftpd_mtftp.h + +atftp_LDADD = $(LIBTERMCAP) $(LIBREADLINE) +atftp_SOURCES = tftp.c tftp_io.c logger.c options.c tftp_def.c tftp_file.c \ + argz.c tftp_mtftp.c + +atftpd_LDADD = $(LIBPTHREAD) $(LIBWRAP) $(LIBPCRE) +atftpd_SOURCES = tftpd.c logger.c options.c stats.c tftp_io.c tftp_def.c \ + tftpd_file.c tftpd_list.c tftpd_mcast.c argz.c tftpd_pcre.c \ + tftpd_mtftp.c + +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +redhat/atftp.spec: $(top_builddir)/config.status $(top_srcdir)/redhat/atftp.spec.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkdir_p) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ + else :; fi; \ + done [... truncated: 26779 lines follow ...] From axeld at mail.berlios.de Sat Sep 22 18:51:33 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 22 Sep 2007 18:51:33 +0200 Subject: [Haiku-commits] r22276 - haiku/vendor/atftp Message-ID: <200709221651.l8MGpXul018242@sheep.berlios.de> Author: axeld Date: 2007-09-22 18:51:30 +0200 (Sat, 22 Sep 2007) New Revision: 22276 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22276&view=rev Added: haiku/vendor/atftp/0.7/ Log: Tagged version 0.7 of atftp. Copied: haiku/vendor/atftp/0.7 (from rev 22275, haiku/vendor/atftp/current) From axeld at pinc-software.de Sat Sep 22 18:54:20 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 22 Sep 2007 18:54:20 +0200 CEST Subject: [Haiku-commits] r22171 - in haiku/trunk/src/bin/network: . atftpd In-Reply-To: <20070905001903.3929.12@cs.tu-berlin.de> Message-ID: <29618309184-BeMail@zon> Ingo Weinhold wrote: > On 2007-09-04 at 23:36:00 [+0200], axeld at BerliOS < > axeld at mail.berlios.de> > wrote: > > Author: axeld > > Date: 2007-09-04 23:35:58 +0200 (Tue, 04 Sep 2007) > > New Revision: 22171 > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22171&view=rev > [...] > > Log: > > Ported over atftpd from Linux - should work on BSD as well, now. > You're not overly fond of vendor branches, are you? They are > extremely useful > when trying to keep ports up to date in the future. It would be nice, > if you > could add the vendor version, too. At least I've added most of the vendor branches to our repository now : -) But anyway, thanks for the hint, I probably would have forgotten about it. Bye, Axel. From bonefish at cs.tu-berlin.de Sat Sep 22 19:09:10 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sat, 22 Sep 2007 19:09:10 +0200 Subject: [Haiku-commits] r22171 - in haiku/trunk/src/bin/network: . atftpd In-Reply-To: <29618309184-BeMail@zon> References: <29618309184-BeMail@zon> Message-ID: <20070922190910.3786.1@cs.tu-berlin.de> On 2007-09-22 at 18:54:20 [+0200], Axel D?rfler wrote: > Ingo Weinhold wrote: > > On 2007-09-04 at 23:36:00 [+0200], axeld at BerliOS < > > axeld at mail.berlios.de> > > wrote: > > > Author: axeld > > > Date: 2007-09-04 23:35:58 +0200 (Tue, 04 Sep 2007) > > > New Revision: 22171 > > > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22171&view=rev > > [...] > > > Log: > > > Ported over atftpd from Linux - should work on BSD as well, now. > > You're not overly fond of vendor branches, are you? They are > > extremely useful > > when trying to keep ports up to date in the future. It would be nice, > > if you > > could add the vendor version, too. > > At least I've added most of the vendor branches to our repository now : > -) > But anyway, thanks for the hint, I probably would have forgotten about > it. Thanks. CU, Ingo From bonefish at cs.tu-berlin.de Sat Sep 22 19:23:10 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sat, 22 Sep 2007 19:23:10 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: <200709221630.l8MGUNwK011028@sheep.berlios.de> References: <200709221630.l8MGUNwK011028@sheep.berlios.de> Message-ID: <20070922192310.3440.3@cs.tu-berlin.de> On 2007-09-22 at 18:30:23 [+0200], leavengood at BerliOS wrote: [...] > +static status_t > +cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) > +{ > + status_t status = B_OK; > + > + if (cond == NULL || *_mutex == NULL) > + return B_BAD_VALUE; > + > + if ((*_mutex)->owner != find_thread(NULL)) > + // POSIX suggests EPERM (= B_NOT_ALLOWED) to be returned > + // if this thread does not own the mutex > + return B_NOT_ALLOWED; > + > + if (cond->mutex && cond->mutex != _mutex) > + // POSIX suggests EINVAL (= B_BAD_VALUE) to be returned if > + // the same condition variable is used with multiple mutexes > + return B_BAD_VALUE; > + > + cond->mutex = _mutex; > + cond->waiter_count++; > + pthread_mutex_unlock(_mutex); > + status = acquire_sem_etc(cond->sem, 1, timeout == B_INFINITE_TIMEOUT ? > 0 : B_ABSOLUTE_TIMEOUT, timeout); > + pthread_mutex_lock(_mutex); > + cond->waiter_count--; > + // If there are no more waiters, we can change mutexes > + if (cond->waiter_count == 0) > + cond->mutex = NULL; > + > + return status; > +} > + > +static status_t > +cond_signal(pthread_cond *cond, bool broadcast) > +{ > + if (cond == NULL) > + return B_BAD_VALUE; > + > + return release_sem_etc(cond->sem, broadcast ? cond->waiter_count : 1, > 0); > +} Two problems: * The sequence (acquire_sem_etc() completion ... cond->waiter_count--) is not atomic. A cond_signal(,true) inbetween will screw the semaphore count. The simple solution is to pass the (Haiku only) B_RELEASE_ALL flag to release_sem_etc() (the count argument will be ignored). * pthread_cond_signal() is supposed to be a no-op, when there are no threads waiting on the condition variable, but this implementation always releases the semaphore. The solution here is to use the (also Haiku only) B_RELEASE_IF_WAITING_ONLY release_sem_etc() flag. IOW, the release_sem_etc() call in cond_signal() should read: return release_sem_etc(cond->sem, 1, broadcast ? B_RELEASE_ALL : B_RELEASE_IF_WAITING_ONLY); CU, Ingo From leavengood at gmail.com Sat Sep 22 20:17:24 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 22 Sep 2007 14:17:24 -0400 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: <20070922192310.3440.3@cs.tu-berlin.de> References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> Message-ID: On 9/22/07, Ingo Weinhold wrote: > > Two problems: > > * The sequence (acquire_sem_etc() completion ... cond->waiter_count--) is not > atomic. A cond_signal(,true) inbetween will screw the semaphore count. The > simple solution is to pass the (Haiku only) B_RELEASE_ALL flag to > release_sem_etc() (the count argument will be ignored). Using B_RELEASE_ALL may be a good idea in general, but what you are saying can't happen if the client is using the library right. The mutex passed to cond_wait must be locked by whatever thread calls cond_signal. Since that mutex is locked before the waiter_count is decremented in cond_wait, what you are describing can't happen: Start: waiter_count = 0 Thread 1: locks mutex, calls cond_wait, waiter_count = 1, unlocks mutex, blocks on sem Thread 2: locks mutex, calls cond_wait, waiter_count = 2, unlocks mutex, blocks on sem Thread 3: locks mutex, calls cond_notify(, true), sem released twice, context switch Thread 1: unblocks, tries to lock mutex, has to wait since Thread 3 still has it Thread 2: unblocks, tries to lock mutex, has to wait since Thread 3 still has it Thread 3: returns from cond_notify, unlocks mutex Thread 1: unblocks, gets mutex, waiter_count = 1, returns from cond_wait, unlocks mutex Thread 2: unblocks, gets mutex, waiter_count = 0, returns from cond_wait, unlocks mutex waiter_count = 0, program continues Given that threads just block waiting on the mutex after the release_sem, using the B_DO_NOT_RESCHEDULE flag might be smart. I wasn't sure before, but after creating the above, I think it would be good. > * pthread_cond_signal() is supposed to be a no-op, when there are no threads > waiting on the condition variable, but this implementation always releases > the semaphore. The solution here is to use the (also Haiku only) > B_RELEASE_IF_WAITING_ONLY release_sem_etc() flag. Yeah this is true. Another option is just to check the waiter_count, which is still safe because of what I mentioned above. Assuming you agree with my "proof" above, which would you prefer? Does using these B_RELEASE flags have any performance consequences? Ryan From leavengood at gmail.com Sat Sep 22 20:27:36 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 22 Sep 2007 14:27:36 -0400 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> Message-ID: Responding to myself, I think I see where the problem is now: On 9/22/07, Ryan Leavengood wrote: > > Start: waiter_count = 0 > Thread 1: locks mutex, calls cond_wait, waiter_count = 1, unlocks > mutex, blocks on sem > Thread 2: locks mutex, calls cond_wait, waiter_count = 2, unlocks > mutex, blocks on sem > Thread 3: locks mutex, calls cond_notify(, true), sem released twice, > context switch Thread 4: tries to lock mutex (to call cond_notify), has to wait since Thread 3 has it, blocks > Thread 1: unblocks, tries to lock mutex, has to wait since Thread 3 still has it > Thread 2: unblocks, tries to lock mutex, has to wait since Thread 3 still has it > Thread 3: returns from cond_notify, unlocks mutex Thread 4: unblocks, locks mutex, calls calls cond_notify(, true), sem released twice (erroneously) > Thread 1: unblocks, gets mutex, waiter_count = 1, returns from > cond_wait, unlocks mutex > Thread 2: unblocks, gets mutex, waiter_count = 0, returns from > cond_wait, unlocks mutex > waiter_count = 0, program continues But the sems thread count is now -2, oops. I guess this is what you are saying Ingo? Ryan From bonefish at cs.tu-berlin.de Sat Sep 22 20:56:42 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sat, 22 Sep 2007 20:56:42 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> Message-ID: <20070922205642.13411.4@cs.tu-berlin.de> On 2007-09-22 at 20:17:24 [+0200], Ryan Leavengood wrote: > On 9/22/07, Ingo Weinhold wrote: > > > > Two problems: > > > > * The sequence (acquire_sem_etc() completion ... cond->waiter_count--) is > > not > > atomic. A cond_signal(,true) inbetween will screw the semaphore count. The > > simple solution is to pass the (Haiku only) B_RELEASE_ALL flag to > > release_sem_etc() (the count argument will be ignored). > > Using B_RELEASE_ALL may be a good idea in general, but what you are > saying can't happen if the client is using the library right. The > mutex passed to cond_wait must be locked by whatever thread calls > cond_signal. That's not correct. Quoting the Open Group Base Specs (http://www.opengroup.org/onlinepubs/009695399/toc.htm): "The pthread_cond_broadcast() or pthread_cond_signal() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()." But whether or not the thread calling pthread_cond_broadcast() holds the mutex is actually pretty irrelevant for the race condition, since the threads blocking don't get the mutex atomically with the completion of acquire_sem_etc(). E.g. the sequence lock mutex broadcast broadcast unlock mutex increases the semaphore count by 2 * waiter_count, which is obviously not correct. [...] > Given that threads just block waiting on the mutex after the > release_sem, using the B_DO_NOT_RESCHEDULE flag might be smart. I > wasn't sure before, but after creating the above, I think it would be > good. > > > * pthread_cond_signal() is supposed to be a no-op, when there are no > > threads > > waiting on the condition variable, but this implementation always releases > > the semaphore. The solution here is to use the (also Haiku only) > > B_RELEASE_IF_WAITING_ONLY release_sem_etc() flag. > > Yeah this is true. Another option is just to check the waiter_count, > which is still safe because of what I mentioned above. Assuming you > agree with my "proof" above, which would you prefer? Does using these > B_RELEASE flags have any performance consequences? Since your "proof" has ... uh ... some issues, only one option remains. :-) CU, Ingo From bonefish at cs.tu-berlin.de Sat Sep 22 20:57:04 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sat, 22 Sep 2007 20:57:04 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> Message-ID: <20070922205704.13528.5@cs.tu-berlin.de> On 2007-09-22 at 20:27:36 [+0200], Ryan Leavengood wrote: > Responding to myself, I think I see where the problem is now: > > On 9/22/07, Ryan Leavengood wrote: > > > > Start: waiter_count = 0 > > Thread 1: locks mutex, calls cond_wait, waiter_count = 1, unlocks > > mutex, blocks on sem > > Thread 2: locks mutex, calls cond_wait, waiter_count = 2, unlocks > > mutex, blocks on sem > > Thread 3: locks mutex, calls cond_notify(, true), sem released twice, > > context switch > Thread 4: tries to lock mutex (to call cond_notify), has to wait since > Thread 3 has it, blocks > > Thread 1: unblocks, tries to lock mutex, has to wait since Thread 3 still > > has it > > Thread 2: unblocks, tries to lock mutex, has to wait since Thread 3 still > > has it > > Thread 3: returns from cond_notify, unlocks mutex > Thread 4: unblocks, locks mutex, calls calls cond_notify(, true), sem > released twice (erroneously) > > Thread 1: unblocks, gets mutex, waiter_count = 1, returns from > > cond_wait, unlocks mutex > > Thread 2: unblocks, gets mutex, waiter_count = 0, returns from > > cond_wait, unlocks mutex > > waiter_count = 0, program continues > > But the sems thread count is now -2, oops. I guess this is what you > are saying Ingo? Actually +2, but yes, that's exactly the problem. CU, Ingo From leavengood at gmail.com Sat Sep 22 21:14:19 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 22 Sep 2007 15:14:19 -0400 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: <20070922205704.13528.5@cs.tu-berlin.de> References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> <20070922205704.13528.5@cs.tu-berlin.de> Message-ID: On 9/22/07, Ingo Weinhold wrote: > > Actually +2, but yes, that's exactly the problem. Yeah I wondered about the sign of it after I wrote that. Also I thought of a problem with using B_RELEASE_IF_WAITING_ONLY and I need your expertise to solve it. Let's assume the condition that the condition variable is for is ABOUT to come true when a thread starts to wait (like a counter is almost to the required value.) So the thread calls cond_wait (through pthread_cond_wait of course) and right after it unlocks the mutex the context switches (likely since the mutex releases a semaphore to unlock.) Because of this it hasn't yet acquired the semaphore for the condition variable. The thread that gets control next changes the condition so it is satisfied and calls pthread_cond_signal on the condition variable. Since no one is waiting and we use the B_RELEASE_IF_WAITING_ONLY flag, the thread count is not incremented. Therefore when the first thread gets control back and acquires the semaphore, it will block, possibly forever, if no one else calls cond_signal. If there was no B_RELEASE_IF_WAITING_ONLY flag, the thread count would go to 1 and the first thread would acquire the semaphore without blocking and continue (as it should.) Any ideas for this? Ryan From bonefish at cs.tu-berlin.de Sat Sep 22 22:10:22 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sat, 22 Sep 2007 22:10:22 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> <20070922205704.13528.5@cs.tu-berlin.de> Message-ID: <20070922221022.14052.6@cs.tu-berlin.de> On 2007-09-22 at 21:14:19 [+0200], Ryan Leavengood wrote: > On 9/22/07, Ingo Weinhold wrote: > > > > Actually +2, but yes, that's exactly the problem. > > Yeah I wondered about the sign of it after I wrote that. > > Also I thought of a problem with using B_RELEASE_IF_WAITING_ONLY and I > need your expertise to solve it. > > Let's assume the condition that the condition variable is for is ABOUT > to come true when a thread starts to wait (like a counter is almost to > the required value.) So the thread calls cond_wait (through > pthread_cond_wait of course) and right after it unlocks the mutex the > context switches (likely since the mutex releases a semaphore to > unlock.) Because of this it hasn't yet acquired the semaphore for the > condition variable. The thread that gets control next changes the > condition so it is satisfied and calls pthread_cond_signal on the > condition variable. Since no one is waiting and we use the > B_RELEASE_IF_WAITING_ONLY flag, the thread count is not incremented. > Therefore when the first thread gets control back and acquires the > semaphore, it will block, possibly forever, if no one else calls > cond_signal. If there was no B_RELEASE_IF_WAITING_ONLY flag, the > thread count would go to 1 and the first thread would acquire the > semaphore without blocking and continue (as it should.) > > Any ideas for this? I suppose adding an event counter to the condition variable structure would solve the original problems just as well: static status_t cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) { ... cond->mutex = _mutex; cond->waiter_count++; int32 event = atomic_get(&cond->event_counter); pthread_mutex_unlock(_mutex); do { status = acquire_sem_etc(cond->sem, 1, timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); } while (status == B_OK && atomic_get(&cond->event_counter) == event); pthread_mutex_lock(_mutex); cond->waiter_count--; ... } static status_t cond_signal(pthread_cond *cond, bool broadcast) { if (cond == NULL) return B_BAD_VALUE; atomic_add(&cond->event_counter, 1); return release_sem_etc(cond->sem, broadcast ? cond->waiter_count : 1, 0); } There's a new race condition: Threads entering cond_wait() while another thread is between atomic_add() and release_sem_etc() in cond_signal() would not be unblocked by that cond_signal() invocation, but I guess that's quite OK, since there would even be a race condition even if the whole cond_signal() would be atomic. I guess this is the kind of case the specs are referring to by "however, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()." CU, Ingo From marcusoverhagen at mail.berlios.de Sun Sep 23 00:09:58 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 23 Sep 2007 00:09:58 +0200 Subject: [Haiku-commits] r22277 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709222209.l8MM9wmP011322@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-23 00:09:58 +0200 (Sun, 23 Sep 2007) New Revision: 22277 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22277&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h Log: Fixed memory allocation and field alignment. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-22 16:51:30 UTC (rev 22276) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp 2007-09-22 22:09:58 UTC (rev 22277) @@ -27,6 +27,13 @@ , fInstanceCheck(-1) { memset(fPort, 0, sizeof(fPort)); + + ASSERT(sizeof(ahci_port) == 120); + ASSERT(sizeof(ahci_hba) == 4096); + ASSERT(sizeof(fis) == 256); + ASSERT(sizeof(command_list_entry) == 32); + ASSERT(sizeof(command_table) == 128); + ASSERT(sizeof(prd) == 16); } Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-22 16:51:30 UTC (rev 22276) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-22 22:09:58 UTC (rev 22277) @@ -68,12 +68,6 @@ }; -enum { - AHCI_CLB_SIZE = 1024, - AHCI_FIS_SIZE = 256, -}; - - typedef struct { uint32 clb; // Command List Base Address (alignment 1024 byte) uint32 clbu; // Command List Base Address Upper 32-Bits @@ -94,7 +88,7 @@ uint32 res2; // Reserved for FIS-based Switching Definition uint32 res[11]; // Reserved uint32 vendor[2]; // Vendor Specific -} ahci_port; +} _PACKED ahci_port; typedef struct { @@ -110,7 +104,7 @@ uint32 res[31]; // Reserved uint32 vendor[24]; // Vendor Specific registers ahci_port port[32]; -} ahci_hba; +} _PACKED ahci_hba; typedef struct { @@ -118,12 +112,12 @@ uint8 res1[0x04]; uint8 psfis[0x14]; // PIO Setup FIS uint8 res2[0x0c]; - uint8 rfis[0x20]; // D2H Register FIS + uint8 rfis[0x14]; // D2H Register FIS uint8 res3[0x04]; uint8 sdbfis[0x08]; // Set Device Bits FIS uint8 ufis[0x40]; // Unknown FIS uint8 res4[0x60]; -} fis; +} _PACKED fis; typedef struct { @@ -137,38 +131,38 @@ uint16 r : 1; // Reset uint16 p : 1; // Prefetchable uint16 w : 1; // Write - uint16 a : 1;// ATAPI + uint16 a : 1; // ATAPI uint16 cfl : 5; // command FIS length - }; + } _PACKED; uint32 prdtl_flags_cfl; - }; + } _PACKED; + uint32 prdbc; // PRD Byte Count uint32 ctba; // command table desciptor base address (alignment 128 byte) uint32 ctbau; // command table desciptor base address upper uint8 res1[0x10]; -} command_list_entry; +} _PACKED command_list_entry; #define COMMAND_LIST_ENTRY_COUNT 32 -typedef struct { - uint32 dba; // Data Base Address (2-byte aligned) - uint32 dbau; // Data Base Address Upper - uint32 res; - uint32 dbc; // Bytecount (0-based, even, max 4MB) - #define DBC_I 0x80000000 /* Interrupt on completition */ -} prd; - typedef struct { uint8 cfis[0x40]; // command FIS uint8 acmd[0x20]; // ATAPI command uint8 res[0x20]; // reserved -} command_table; +} _PACKED command_table; +typedef struct { + uint32 dba; // Data Base Address (2-byte aligned) + uint32 dbau; // Data Base Address Upper + uint32 res; + uint32 dbc; // Bytecount (0-based, even, max 4MB) + #define DBC_I 0x80000000 /* Interrupt on completition */ +} _PACKED prd; + #define PRD_TABLE_ENTRY_COUNT 168 - extern scsi_sim_interface gAHCISimInterface; extern device_manager_info *gDeviceManager; extern pci_device_module_info *gPCI; @@ -176,6 +170,7 @@ #define LO32(val) ((uint32)(val)) #define HI32(val) (((uint64)(val)) >> 32) +#define ASSERT(expr) if (expr) {} else panic(#expr) #ifdef __cplusplus From marcusoverhagen at mail.berlios.de Sun Sep 23 01:43:26 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 23 Sep 2007 01:43:26 +0200 Subject: [Haiku-commits] r22278 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709222343.l8MNhQdG032006@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-23 01:43:25 +0200 (Sun, 23 Sep 2007) New Revision: 22278 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22278&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp Log: Start and stop DMA engine and FIS receive, enable port interrupts. Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-22 22:09:58 UTC (rev 22277) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-22 23:43:25 UTC (rev 22278) @@ -91,6 +91,45 @@ } _PACKED ahci_port; +enum { + PORT_CMD_ICC_ACTIVE = (1 << 28), // Interface Communication control + PORT_CMD_ICC_SLUMBER = (6 << 28), // Interface Communication control + PORT_CMD_CR = (1 << 15), // Command List Running (DMA active) + PORT_CMD_FR = (1 << 14), // FIS Receive Running + PORT_CMD_FER = (1 << 4), // FIS Receive Enable + PORT_CMD_CLO = (1 << 3), // Command List Override + PORT_CMD_POD = (1 << 2), // Power On Device + PORT_CMD_SUD = (1 << 1), // Spin-up Device + PORT_CMD_ST = (1 << 0), // Start DMA +}; + + +enum { + PORT_INT_CPD = (1 << 31), // Cold Presence Detect Status/Enable + PORT_INT_TFE = (1 << 30), // Task File Error Status/Enable + PORT_INT_HBF = (1 << 29), // Host Bus Fatal Error Status/Enable + PORT_INT_HBD = (1 << 28), // Host Bus Data Error Status/Enable + PORT_INT_IF = (1 << 27), // Interface Fatal Error Status/Enable + PORT_INT_INF = (1 << 26), // Interface Non-fatal Error Status/Enable + PORT_INT_OF = (1 << 24), // Overflow Status/Enable + PORT_INT_IPM = (1 << 23), // Incorrect Port Multiplier Status/Enable + PORT_INT_PRCE = (1 << 22), // PhyRdy Change Status/Enable + PORT_INT_DI = (1 << 7), // Device Interlock Status/Enable + PORT_INT_PC = (1 << 6), // Port Change Status/Enable + PORT_INT_DP = (1 << 5), // Descriptor Processed Interrupt + PORT_INT_UF = (1 << 4), // Unknown FIS Interrupt + PORT_INT_SDB = (1 << 3), // Set Device Bits FIS Interrupt + PORT_INT_DS = (1 << 2), // DMA Setup FIS Interrupt + PORT_INT_PS = (1 << 1), // PIO Setup FIS Interrupt + PORT_INT_DHR = (1 << 0), // Device to Host Register FIS Interrupt +}; + +#define PORT_INT_FATAL (PORT_INT_HBF | PORT_INT_IF | PORT_INT_IPM | PORT_INT_UF) +#define PORT_INT_ERROR (PORT_INT_TFE | PORT_INT_HBD) +#define PORT_INT_MASK (PORT_INT_FATAL | PORT_INT_ERROR | PORT_INT_DP |\ + PORT_INT_SDB | PORT_INT_DS | PORT_INT_PS | PORT_INT_DHR) + + typedef struct { uint32 cap; // Host Capabilities uint32 ghc; // Global Host Control Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-22 22:09:58 UTC (rev 22277) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-22 23:43:25 UTC (rev 22278) @@ -63,6 +63,21 @@ fCommandList[0].ctbau = HI32(physAddr); // prdt follows after command table + // clear IRQ status bits + fRegs->is = fRegs->is; + + // clear error bits + fRegs->serr = fRegs->serr; + + // enable FIS receive + fRegs->cmd |= PORT_CMD_FER; + + // start DMA engine + fRegs->cmd |= PORT_CMD_ST; + + // enable interrupts + fRegs->ie = PORT_INT_MASK; + return B_OK; } @@ -72,6 +87,34 @@ { TRACE("AHCIPort::Uninit port %d\n", fIndex); + // disable FIS receive + fRegs->cmd &= ~PORT_CMD_FER; + + // wait for receive completition, up to 500ms + for (int i = 0; i < 15; i++) { + if (!(fRegs->cmd & PORT_CMD_FR)) + break; + snooze(50000); + } + + if (fRegs->cmd & PORT_CMD_FR) { + TRACE("AHCIPort::Uninit port %d error FIS rx still running\n", fIndex); + } + + // stop DMA engine + fRegs->cmd &= ~PORT_CMD_ST; + + // wait for DMA completition + for (int i = 0; i < 15; i++) { + if (!(fRegs->cmd & PORT_CMD_CR)) + break; + snooze(50000); + } + + if (fRegs->cmd & PORT_CMD_CR) { + TRACE("AHCIPort::Uninit port %d error DMA engine still running\n", fIndex); + } + // disable interrupts fRegs->ie = 0; @@ -91,7 +134,11 @@ void AHCIPort::Interrupt() { - TRACE("AHCIPort::Interrupt port %d\n", fIndex); + uint32 is = fRegs->is; + TRACE("AHCIPort::Interrupt port %d, status %#08x\n", fIndex, is); + + // clear interrupts + fRegs->is = is; } From leavengood at gmail.com Sun Sep 23 01:57:12 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 22 Sep 2007 19:57:12 -0400 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: <20070922221022.14052.6@cs.tu-berlin.de> References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> <20070922205704.13528.5@cs.tu-berlin.de> <20070922221022.14052.6@cs.tu-berlin.de> Message-ID: On 9/22/07, Ingo Weinhold wrote: > > I suppose adding an event counter to the condition variable structure would > solve the original problems just as well: [code snipped] Maybe I'm just tired and have been thinking about this too long, but I don't see how this fixes it. If you consider my scenario earlier with the 4 threads (which even do the "proper" locking of the mutex), the end result would still be the semaphore with a +2 thread count: Start: waiter_count = 0 Thread 1: locks mutex, calls cond_wait, event = 0, waiter_count = 1, unlocks mutex, blocks on sem Thread 2: locks mutex, calls cond_wait, event = 0, waiter_count = 2, unlocks mutex, blocks on sem Thread 3: locks mutex, calls cond_notify(, true), event_counter = 1, sem released twice, context switch Thread 4: tries to lock mutex (to call cond_notify), has to wait since Thread 3 has it, blocks Thread 1: unblocks, event (0) != event_counter (1), leaves loop, tries to lock mutex, has to wait since Thread 3 still has it Thread 2: unblocks, event (0) != event_counter (1), leaves loop, tries to lock mutex, has to wait since Thread 3 still has it Thread 3: returns from cond_notify, unlocks mutex Thread 4: unblocks, locks mutex, calls cond_notify(, true), event_counter = 2, sem released twice (erroneously) Thread 1: unblocks, gets mutex, waiter_count = 1, returns from cond_wait, unlocks mutex Thread 2: unblocks, gets mutex, waiter_count = 0, returns from cond_wait, unlocks mutex waiter_count = 0, event_counter = 2, program continues sem has incorrect +2 thread count If you don't think so please explain how. > There's a new race condition: Threads entering cond_wait() while another > thread is between atomic_add() and release_sem_etc() in cond_signal() would > not be unblocked by that cond_signal() invocation, but I guess that's quite > OK, since there would even be a race condition even if the whole > cond_signal() would be atomic. This would only happen because of the loop, right? Because without the loop it seems like it would work fine. I am starting to see why people complain about threading, because thinking about it stresses your mind quite a bit. But I think before I'm done with this I will be less stressed than most ;) Ryan From bonefish at cs.tu-berlin.de Sun Sep 23 03:09:49 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sun, 23 Sep 2007 03:09:49 +0200 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> <20070922205704.13528.5@cs.tu-berlin.de> <20070922221022.14052.6@cs.tu-berlin.de> Message-ID: <20070923030949.18575.8@cs.tu-berlin.de> On 2007-09-23 at 01:57:12 [+0200], Ryan Leavengood wrote: > On 9/22/07, Ingo Weinhold wrote: > > > > I suppose adding an event counter to the condition variable structure > > would > > solve the original problems just as well: > [code snipped] > > Maybe I'm just tired and have been thinking about this too long, but I > don't see how this fixes it. If you consider my scenario earlier with > the 4 threads (which even do the "proper" locking of the mutex), the > end result would still be the semaphore with a +2 thread count: [...] > sem has incorrect +2 thread count > > If you don't think so please explain how. Looks correct. Nevertheless the original problem won't occur anymore. With your original implementation a thread calling cond_wait() after this sequence would immediately successfully acquire the semaphore and return, although it shouldn't. With the event counter version the thread will acquire the semaphore, but not leave the loop. The general idea is that a thread won't leave the loop until the event counter actually changes. > > There's a new race condition: Threads entering cond_wait() while another > > thread is between atomic_add() and release_sem_etc() in cond_signal() > > would > > not be unblocked by that cond_signal() invocation, but I guess that's > > quite > > OK, since there would even be a race condition even if the whole > > cond_signal() would be atomic. > > This would only happen because of the loop, right? Because without the > loop it seems like it would work fine. Yep, but removing the loop basically reverts the code to the original version, since the event counter would never be checked. BTW, there's a second race condition, which could cause cond_signal(,false) to unblock two threads in cond_wait(), given that the previous semaphore count was erroneously greater than 0 and the thread calling cond_signal() would not hold the mutex (the detailed analysis be left as exercise for the motivated reader ;-)), but since that is standard conforming behavior, it doesn't matter anyway. > I am starting to see why people complain about threading, because > thinking about it stresses your mind quite a bit. But I think before > I'm done with this I will be less stressed than most ;) Keeps the mind flexible, eh? :-P CU, Ingo From leavengood at gmail.com Sun Sep 23 04:34:25 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Sat, 22 Sep 2007 22:34:25 -0400 Subject: [Haiku-commits] r22274 - in haiku/trunk: headers/posix src/system/libroot/posix/pthread In-Reply-To: <20070923030949.18575.8@cs.tu-berlin.de> References: <200709221630.l8MGUNwK011028@sheep.berlios.de> <20070922192310.3440.3@cs.tu-berlin.de> <20070922205704.13528.5@cs.tu-berlin.de> <20070922221022.14052.6@cs.tu-berlin.de> <20070923030949.18575.8@cs.tu-berlin.de> Message-ID: On 9/22/07, Ingo Weinhold wrote: > > Looks correct. Nevertheless the original problem won't occur anymore. With > your original implementation a thread calling cond_wait() after this > sequence would immediately successfully acquire the semaphore and return, > although it shouldn't. With the event counter version the thread will > acquire the semaphore, but not leave the loop. The general idea is that a > thread won't leave the loop until the event counter actually changes. Ah yes, I get it. I didn't keep going with my example to notice this ;) > BTW, there's a second race condition, which could cause cond_signal(,false) > to unblock two threads in cond_wait(), given that the previous semaphore > count was erroneously greater than 0 and the thread calling cond_signal() > would not hold the mutex (the detailed analysis be left as exercise for the > motivated reader ;-)), but since that is standard conforming behavior, it > doesn't matter anyway. For now I'm just going to take your word for it and consider this implementation "good enough for now" :) > Keeps the mind flexible, eh? :-P Oh yes indeed. Ryan From leavengood at mail.berlios.de Sun Sep 23 04:48:32 2007 From: leavengood at mail.berlios.de (leavengood at BerliOS) Date: Sun, 23 Sep 2007 04:48:32 +0200 Subject: [Haiku-commits] r22279 - haiku/trunk/src/system/libroot/posix/pthread Message-ID: <200709230248.l8N2mWCq008626@sheep.berlios.de> Author: leavengood Date: 2007-09-23 04:48:30 +0200 (Sun, 23 Sep 2007) New Revision: 22279 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22279&view=rev Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h Log: Implemented Ingo's suggestions to avoid the situation that condition variables don't block when they should because the semaphore sometimes gets released too much. One day I'll try to add some tests, though this seems like something you can't exactly unit test. Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-22 23:43:25 UTC (rev 22278) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-23 02:48:30 UTC (rev 22279) @@ -56,6 +56,7 @@ cond->mutex = NULL; cond->waiter_count = 0; + cond->event_counter = 0; memcpy(&cond->attr, attr, sizeof(pthread_condattr)); *_cond = cond; @@ -99,9 +100,18 @@ cond->mutex = _mutex; cond->waiter_count++; + + int32 event = atomic_get(&cond->event_counter); + pthread_mutex_unlock(_mutex); - status = acquire_sem_etc(cond->sem, 1, timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); + + do { + status = acquire_sem_etc(cond->sem, 1, + timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); + } while (status == B_OK && atomic_get(&cond->event_counter) == event); + pthread_mutex_lock(_mutex); + cond->waiter_count--; // If there are no more waiters, we can change mutexes if (cond->waiter_count == 0) @@ -116,6 +126,7 @@ if (cond == NULL) return B_BAD_VALUE; + atomic_add(&cond->event_counter, 1); return release_sem_etc(cond->sem, broadcast ? cond->waiter_count : 1, 0); } Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2007-09-22 23:43:25 UTC (rev 22278) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h 2007-09-23 02:48:30 UTC (rev 22279) @@ -21,6 +21,7 @@ sem_id sem; pthread_mutex_t *mutex; int32 waiter_count; + int32 event_counter; pthread_condattr attr; } pthread_cond; From marcusoverhagen at mail.berlios.de Sun Sep 23 11:24:06 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 23 Sep 2007 11:24:06 +0200 Subject: [Haiku-commits] r22280 - haiku/trunk/src/add-ons/kernel/busses/scsi/ahci Message-ID: <200709230924.l8N9O6Jw004032@sheep.berlios.de> Author: marcusoverhagen Date: 2007-09-23 11:24:06 +0200 (Sun, 23 Sep 2007) New Revision: 22280 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22280&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp Log: try to activate link and spin up the device Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-23 02:48:30 UTC (rev 22279) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h 2007-09-23 09:24:06 UTC (rev 22280) @@ -94,6 +94,7 @@ enum { PORT_CMD_ICC_ACTIVE = (1 << 28), // Interface Communication control PORT_CMD_ICC_SLUMBER = (6 << 28), // Interface Communication control + PORT_CMD_ICC_MASK = (0xf<<28), // Interface Communication control PORT_CMD_CR = (1 << 15), // Command List Running (DMA active) PORT_CMD_FR = (1 << 14), // FIS Receive Running PORT_CMD_FER = (1 << 4), // FIS Receive Enable Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-23 02:48:30 UTC (rev 22279) +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp 2007-09-23 09:24:06 UTC (rev 22280) @@ -68,6 +68,12 @@ // clear error bits fRegs->serr = fRegs->serr; + + // spin up device + fRegs->cmd |= PORT_CMD_SUD; + + // activate link + fRegs->cmd = (fRegs->cmd & ~PORT_CMD_ICC_MASK) | PORT_CMD_ICC_ACTIVE; // enable FIS receive fRegs->cmd |= PORT_CMD_FER; @@ -135,7 +141,7 @@ AHCIPort::Interrupt() { uint32 is = fRegs->is; - TRACE("AHCIPort::Interrupt port %d, status %#08x\n", fIndex, is); + TRACE("AHCIPort::Interrupt port %d, status %#08lx\n", fIndex, is); // clear interrupts fRegs->is = is; From axeld at mail.berlios.de Sun Sep 23 19:21:42 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 23 Sep 2007 19:21:42 +0200 Subject: [Haiku-commits] r22281 - haiku/trunk/src/system/libroot/posix/pthread Message-ID: <200709231721.l8NHLg6j006820@sheep.berlios.de> Author: axeld Date: 2007-09-23 19:21:41 +0200 (Sun, 23 Sep 2007) New Revision: 22281 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22281&view=rev Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c Log: * Fixed build for GCC 2.95.3 - it does not support newer C syntax. * Minor cleanup (there shall be 2 lines of space between functions). Modified: haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-23 09:24:06 UTC (rev 22280) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c 2007-09-23 17:21:41 UTC (rev 22281) @@ -83,7 +83,8 @@ static status_t cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) { - status_t status = B_OK; + status_t status; + int32 event; if (cond == NULL || *_mutex == NULL) return B_BAD_VALUE; @@ -101,7 +102,7 @@ cond->mutex = _mutex; cond->waiter_count++; - int32 event = atomic_get(&cond->event_counter); + event = atomic_get(&cond->event_counter); pthread_mutex_unlock(_mutex); @@ -120,6 +121,7 @@ return status; } + static status_t cond_signal(pthread_cond *cond, bool broadcast) { @@ -130,6 +132,7 @@ return release_sem_etc(cond->sem, broadcast ? cond->waiter_count : 1, 0); } + int pthread_cond_wait(pthread_cond_t *_cond, pthread_mutex_t *_mutex) { From bonefish at cs.tu-berlin.de Sun Sep 23 19:35:21 2007 From: bonefish at cs.tu-berlin.de (Ingo Weinhold) Date: Sun, 23 Sep 2007 19:35:21 +0200 Subject: [Haiku-commits] r22281 - haiku/trunk/src/system/libroot/posix/pthread In-Reply-To: <200709231721.l8NHLg6j006820@sheep.berlios.de> References: <200709231721.l8NHLg6j006820@sheep.berlios.de> Message-ID: <20070923193521.7512.1@cs.tu-berlin.de> On 2007-09-23 at 19:21:42 [+0200], axeld at BerliOS wrote: > Author: axeld > Date: 2007-09-23 19:21:41 +0200 (Sun, 23 Sep 2007) > New Revision: 22281 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22281&view=rev > > Modified: > haiku/trunk/src/system/libroot/posix/pthread/pthread_cond.c > Log: > * Fixed build for GCC 2.95.3 - it does not support newer C syntax. > * Minor cleanup (there shall be 2 lines of space between functions). I'd rather see those source files be renamed to *.cpp. No need to uglify them unnecessarily. CU, Ingo From korli at mail.berlios.de Sun Sep 23 20:17:31 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 23 Sep 2007 20:17:31 +0200 Subject: [Haiku-commits] r22282 - haiku/trunk/src/data/etc/timezones Message-ID: <200709231817.l8NIHVC2002238@sheep.berlios.de> Author: korli Date: 2007-09-23 20:17:31 +0200 (Sun, 23 Sep 2007) New Revision: 22282 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22282&view=rev Modified: haiku/trunk/src/data/etc/timezones/africa haiku/trunk/src/data/etc/timezones/antarctica haiku/trunk/src/data/etc/timezones/australasia haiku/trunk/src/data/etc/timezones/europe haiku/trunk/src/data/etc/timezones/leapseconds haiku/trunk/src/data/etc/timezones/northamerica haiku/trunk/src/data/etc/timezones/zone.tab Log: update to tzdata2007g Modified: haiku/trunk/src/data/etc/timezones/africa =================================================================== --- haiku/trunk/src/data/etc/timezones/africa 2007-09-23 17:21:41 UTC (rev 22281) +++ haiku/trunk/src/data/etc/timezones/africa 2007-09-23 18:17:31 UTC (rev 22282) @@ -1,4 +1,4 @@ -# @(#)africa 8.8 +# @(#)africa 8.9 #
     
     # This data is by no means authoritative; if you think you know better,
    @@ -218,7 +218,15 @@
     # after observing the daylight saving time since May.
     # http://news.gom.com.eg/gazette/pdf/2006/09/18/01.pdf
     Rule	Egypt	2006	only	-	Sep	21	23:00s	0	-
    -Rule	Egypt	2007	max	-	Sep	lastThu	23:00s	0	-
    +# From Dirk Losch (2007-08-14):
    +# I received a mail from an airline which says that the daylight
    +# saving time in Egypt will end in the night of 2007-09-06 to 2007-09-07.
    +# From Jesper Norgaard Welen (2007-08-15): [The following agree:]
    +# http://www.nentjes.info/Bill/bill5.htm 
    +# http://www.timeanddate.com/worldclock/city.html?n=53
    +# From Paul Eggert (2007-08-17):
    +# For lack of better info, assume the new rule is first Thursday.
    +Rule	Egypt	2007	max	-	Sep	Thu>=1	23:00s	0	-
     
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     Zone	Africa/Cairo	2:05:00 -	LMT	1900 Oct
    
    Modified: haiku/trunk/src/data/etc/timezones/antarctica
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/antarctica	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/antarctica	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)antarctica	8.3
    +# @(#)antarctica	8.4
     # 
     
     # From Paul Eggert (1999-11-15):
    @@ -191,10 +191,12 @@
     Rule	NZAQ	1974	only	-	Nov	 3	2:00s	1:00	D
     Rule	NZAQ	1975	1988	-	Oct	lastSun	2:00s	1:00	D
     Rule	NZAQ	1989	only	-	Oct	 8	2:00s	1:00	D
    -Rule	NZAQ	1990	max	-	Oct	Sun>=1	2:00s	1:00	D
    +Rule	NZAQ	1990	2006	-	Oct	Sun>=1	2:00s	1:00	D
     Rule	NZAQ	1975	only	-	Feb	23	2:00s	0	S
     Rule	NZAQ	1976	1989	-	Mar	Sun>=1	2:00s	0	S
    -Rule	NZAQ	1990	max	-	Mar	Sun>=15	2:00s	0	S
    +Rule	NZAQ	1990	2007	-	Mar	Sun>=15	2:00s	0	S
    +Rule	NZAQ	2007	max	-	Sep	lastSun	2:00s	1:00	D
    +Rule	NZAQ	2008	max	-	Apr	Sun>=1	2:00s	0	S
     
     # Norway - territories
     # Bouvet (never inhabited)
    
    Modified: haiku/trunk/src/data/etc/timezones/australasia
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/australasia	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/australasia	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)australasia	8.7
    +# @(#)australasia	8.8
     # 
     
     # This file also includes Pacific islands.
    @@ -79,7 +79,7 @@
     # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
     Rule	AS	1971	1985	-	Oct	lastSun	2:00s	1:00	-
     Rule	AS	1986	only	-	Oct	19	2:00s	1:00	-
    -Rule	AS	1987	max	-	Oct	lastSun	2:00s	1:00	-
    +Rule	AS	1987	2007	-	Oct	lastSun	2:00s	1:00	-
     Rule	AS	1972	only	-	Feb	27	2:00s	0	-
     Rule	AS	1973	1985	-	Mar	Sun>=1	2:00s	0	-
     Rule	AS	1986	1989	-	Mar	Sun>=15	2:00s	0	-
    @@ -90,7 +90,9 @@
     Rule	AS	1994	only	-	Mar	Sun>=18	2:00s	0	-
     Rule	AS	1995	2005	-	Mar	lastSun	2:00s	0	-
     Rule	AS	2006	only	-	Apr	Sun>=1	2:00s	0	-
    -Rule	AS	2007	max	-	Mar	lastSun	2:00s	0	-
    +Rule	AS	2007	only	-	Mar	lastSun	2:00s	0	-
    +Rule	AS	2008	max	-	Apr	Sun>=1	2:00s	0	-
    +Rule	AS	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     Zone Australia/Adelaide	9:14:20 -	LMT	1895 Feb
     			9:00	-	CST	1899 May
    @@ -121,7 +123,8 @@
     Rule	AT	2000	only	-	Aug	lastSun	2:00s	1:00	-
     Rule	AT	2001	max	-	Oct	Sun>=1	2:00s	1:00	-
     Rule	AT	2006	only	-	Apr	Sun>=1	2:00s	0	-
    -Rule	AT	2007	max	-	Mar	lastSun	2:00s	0	-
    +Rule	AT	2007	only	-	Mar	lastSun	2:00s	0	-
    +Rule	AT	2008	max	-	Apr	Sun>=1	2:00s	0	-
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     Zone Australia/Hobart	9:49:16	-	LMT	1895 Sep
     			10:00	-	EST	1916 Oct 1 2:00
    @@ -145,9 +148,11 @@
     Rule	AV	1991	1994	-	Mar	Sun>=1	2:00s	0	-
     Rule	AV	1995	2005	-	Mar	lastSun	2:00s	0	-
     Rule	AV	2000	only	-	Aug	lastSun	2:00s	1:00	-
    -Rule	AV	2001	max	-	Oct	lastSun	2:00s	1:00	-
    +Rule	AV	2001	2007	-	Oct	lastSun	2:00s	1:00	-
     Rule	AV	2006	only	-	Apr	Sun>=1	2:00s	0	-
    -Rule	AV	2007	max	-	Mar	lastSun	2:00s	0	-
    +Rule	AV	2007	only	-	Mar	lastSun	2:00s	0	-
    +Rule	AV	2008	max	-	Apr	Sun>=1	2:00s	0	-
    +Rule	AV	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     Zone Australia/Melbourne 9:39:52 -	LMT	1895 Feb
     			10:00	Aus	EST	1971
    @@ -166,9 +171,11 @@
     Rule	AN	1990	1995	-	Mar	Sun>=1	2:00s	0	-
     Rule	AN	1996	2005	-	Mar	lastSun	2:00s	0	-
     Rule	AN	2000	only	-	Aug	lastSun	2:00s	1:00	-
    -Rule	AN	2001	max	-	Oct	lastSun	2:00s	1:00	-
    +Rule	AN	2001	2007	-	Oct	lastSun	2:00s	1:00	-
     Rule	AN	2006	only	-	Apr	Sun>=1	2:00s	0	-
    -Rule	AN	2007	max	-	Mar	lastSun	2:00s	0	-
    +Rule	AN	2007	only	-	Mar	lastSun	2:00s	0	-
    +Rule	AN	2008	max	-	Apr	Sun>=1	2:00s	0	-
    +Rule	AN	2008	max	-	Oct	Sun>=1	2:00s	1:00	-
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     Zone Australia/Sydney	10:04:52 -	LMT	1895 Feb
     			10:00	Aus	EST	1971
    @@ -191,9 +198,11 @@
     Rule	LH	1990	1995	-	Mar	Sun>=1	2:00	0	-
     Rule	LH	1996	2005	-	Mar	lastSun	2:00	0	-
     Rule	LH	2000	only	-	Aug	lastSun	2:00	0:30	-
    -Rule	LH	2001	max	-	Oct	lastSun	2:00	0:30	-
    +Rule	LH	2001	2007	-	Oct	lastSun	2:00	0:30	-
     Rule	LH	2006	only	-	Apr	Sun>=1	2:00	0	-
    -Rule	LH	2007	max	-	Mar	lastSun	2:00	0	-
    +Rule	LH	2007	only	-	Mar	lastSun	2:00	0	-
    +Rule	LH	2008	max	-	Apr	Sun>=1	2:00	0	-
    +Rule	LH	2008	max	-	Oct	Sun>=1	2:00	0:30	-
     Zone Australia/Lord_Howe 10:36:20 -	LMT	1895 Feb
     			10:00	-	EST	1981 Mar
     			10:30	LH	LHST
    @@ -453,11 +462,20 @@
     # US minor outlying islands
     
     # Howland, Baker
    -# uninhabited since World War II
    -# no information; was probably like Pacific/Pago_Pago
    +# Howland was mined for guano by American companies 1857-1878 and British
    +# 1886-1891; Baker was similar but exact dates are not known.
    +# Inhabited by civilians 1935-1942; U.S. military bases 1943-1944;
    +# uninhabited thereafter.
    +# Howland observed Hawaii Standard Time (UTC-10:30) in 1937;
    +# see page 206 of Elgen M. Long and Marie K. Long,
    +# Amelia Earhart: the Mystery Solved, Simon & Schuster (2000).
    +# So most likely Howland and Baker observed Hawaii Time from 1935
    +# until they were abandoned after the war.
     
     # Jarvis
    -# uninhabited since 1958
    +# Mined for guano by American companies 1857-1879 and British 1883?-1891?.
    +# Inhabited by civilians 1935-1942; IGY scientific base 1957-1958;
    +# uninhabited thereafter.
     # no information; was probably like Pacific/Kiritimati
     
     # Johnston
    @@ -866,33 +884,13 @@
     # introduction of standard time in 1895.
     
     
    -# South Australia, Tasmania, Victoria
    -
    -# From Arthur David Olson (1992-03-08):
    -# The rules from version 7.1 follow.
    -# There are lots of differences between these rules and
    -# the Shepherd et al. rules.  Since the Shepherd et al. rules
    -# and Bradley White's newspaper article are in agreement on
    -# current DST ending dates, no worries.
    +# southeast Australia
     #
    -# Rule	Oz	1971	1985	-	Oct	lastSun	2:00	1:00	-
    -# Rule	Oz	1986	max	-	Oct	Sun>=18	2:00	1:00	-
    -# Rule	Oz	1972	only	-	Feb	27	3:00	0	-
    -# Rule	Oz	1973	1986	-	Mar	Sun>=1	3:00	0	-
    -# Rule	Oz	1987	max	-	Mar	Sun>=15	3:00	0	-
    -# Zone	Australia/Tasmania	10:00	Oz	EST
    -# Zone	Australia/South		9:30	Oz	CST
    -# Zone	Australia/Victoria	10:00	Oz	EST	1985 Oct lastSun 2:00
    -#				10:00	1:00	EST	1986 Mar Sun>=15 3:00
    -#				10:00	Oz	EST
    +# From Paul Eggert (2007-07-23):
    +# Starting autumn 2008 Victoria, NSW, South Australia, Tasmania and the ACT
    +# end DST the first Sunday in April and start DST the first Sunday in October.
    +# http://www.theage.com.au/news/national/daylight-savings-to-span-six-months/2007/06/27/1182623966703.html
     
    -# From Robert Elz (1991-03-06):
    -# I believe that the current start date for DST is "lastSun" in Oct...
    -# that changed Oct 89.  That is, we're back to the
    -# original rule, and that rule currently applies in all the states
    -# that have dst, incl Qld.  (Certainly it was true in Vic).
    -# The file I'm including says that happened in 1988, I think
    -# that's incorrect, but I'm not 100% certain.
     
     # South Australia
     
    @@ -938,6 +936,9 @@
     # was gazetted in the Government Hansard on Sep 26 1994....
     # start on last Sunday in October and end in last sunday in March.
     
    +# From Paul Eggert (2007-07-23):
    +# See "southeast Australia" above for 2008 and later.
    +
     # Tasmania
     
     # The rules for 1967 through 1991 were reported by George Shepherd
    @@ -960,6 +961,9 @@
     # Sim Alam (2000-07-03) reported a legal citation for the 2000/2001 rules:
     # http://www.thelaw.tas.gov.au/fragview/42++1968+GS3A at EN+2000070300
     
    +# From Paul Eggert (2007-07-23):
    +# See "southeast Australia" above for 2008 and later.
    +
     # Victoria
     
     # The rules for 1971 through 1991 were reported by George Shepherd
    @@ -989,6 +993,9 @@
     # [1] http://www.hup.harvard.edu/catalog/HEISUN.html
     # [2] http://www.shrine.org.au
     
    +# From Paul Eggert (2007-07-23):
    +# See "southeast Australia" above for 2008 and later.
    +
     # New South Wales
     
     # From Arthur David Olson:
    @@ -1055,6 +1062,9 @@
     # The Queensland Premier Peter Beattie is encouraging northern NSW
     # towns to use Queensland time.
     
    +# From Paul Eggert (2007-07-23):
    +# See "southeast Australia" above for 2008 and later.
    +
     # Yancowinna
     
     # From John Mackin (1989-01-04):
    @@ -1106,6 +1116,9 @@
     # For Lord Howe dates we use Shanks & Pottenger through 1989, and
     # Lonergan thereafter.  For times we use Lonergan.
     
    +# From Paul Eggert (2007-07-23):
    +# See "southeast Australia" above for 2008 and later.
    +
     ###############################################################################
     
     # New Zealand
    
    Modified: haiku/trunk/src/data/etc/timezones/europe
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/europe	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/europe	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)europe	8.10
    +# @(#)europe	8.11
     # 
     
     # This data is by no means authoritative; if you think you know better,
    @@ -444,7 +444,7 @@
     
     ###############################################################################
     
    -# Continental Europe
    +# Europe
     
     # EU rules are for the European Union, previously known as the EC, EEC,
     # Common Market, etc.
    @@ -2386,6 +2386,8 @@
     
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
     # Most of Ukraine since 1970 has been like Kiev.
    +# "Kyiv" is the transliteration of the Ukrainian name, but
    +# "Kiev" is more common in English.
     Zone Europe/Kiev	2:02:04 -	LMT	1880
     			2:02:04	-	KMT	1924 May  2 # Kiev Mean Time
     			2:00	-	EET	1930 Jun 21
    @@ -2397,6 +2399,8 @@
     			2:00	E-Eur	EE%sT	1995
     			2:00	EU	EE%sT
     # Ruthenia used CET 1990/1991.
    +# "Uzhhorod" is the transliteration of the Ukrainian name, but
    +# "Uzhgorod" is more common in English.
     Zone Europe/Uzhgorod	1:29:12 -	LMT	1890 Oct
     			1:00	-	CET	1940
     			1:00	C-Eur	CE%sT	1944 Oct
    @@ -2409,7 +2413,10 @@
     			2:00	E-Eur	EE%sT	1995
     			2:00	EU	EE%sT
     # Zaporozh'ye and eastern Lugansk oblasts observed DST 1990/1991.
    -# Zaporozh'ye has an apostrophe, but Posix file names can't have apostrophes.
    +# "Zaporizhia" is the transliteration of the Ukrainian name, but
    +# "Zaporozh'ye" is more common in English.  Use the common English
    +# spelling, except omit the apostrophe as it is not allowed in
    +# portable Posix file names.
     Zone Europe/Zaporozhye	2:20:40 -	LMT	1880
     			2:20	-	CUT	1924 May  2 # Central Ukraine T
     			2:00	-	EET	1930 Jun 21
    
    Modified: haiku/trunk/src/data/etc/timezones/leapseconds
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/leapseconds	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/leapseconds	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)leapseconds	8.3
    +# @(#)leapseconds	8.4
     
     # Allowance for leapseconds added to each timezone file.
     
    @@ -45,38 +45,38 @@
     Leap	1998	Dec	31	23:59:60	+	S
     Leap	2005	Dec	31	23:59:60	+	S
     
    -# ...
    -# Sent: Thursday, February 01, 2007 9:49 AM
    -# ...
    -# Subject: Bulletin C number 33
    -#
    -# 	INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
    -#
    +# INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
     # SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE
     #
     # SERVICE DE LA ROTATION TERRESTRE
     # OBSERVATOIRE DE PARIS
     # 61, Av. de l'Observatoire 75014 PARIS (France)
    -# ...
    +# Tel.      : 33 (0) 1 40 51 22 26
    +# FAX       : 33 (0) 1 40 51 22 91
    +# Internet  : services.iers at obspm.fr
     #
    -#                                                Paris, 1 February 2007
    -#                                                Bulletin C 33
    -#                                                To authorities responsible
    -#                                                for the measurement and
    -#                                                distribution of time
    +# Paris, 28 June 2007
     #
    -#                           INFORMATION ON UTC - TAI
    +# Bulletin C 34
     #
    -# NO positive leap second will be introduced at the end of June 2007.
    +# To authorities responsible
    +# for the measurement and
    +# distribution of time
    +#
    +# INFORMATION ON UTC - TAI
    +#
    +# NO positive leap second will be introduced at the end of December 2007.
     # The difference between Coordinated Universal Time UTC and the
    -# International Atomic Time TAI is:
    -#      from 2006 January 1, 0h UTC, until further notice : UTC-TAI = -33 s
    -# Leap seconds can be introduced in UTC at the end of the months of
    -# December  or June,  depending on the evolution of UT1-TAI. Bulletin C is
    -# mailed every  six months, either to announce a time step in UTC, or to
    -# confirm that there  will be no time step at the next possible date.
    +# International Atomic Time TAI is :		
     #
    -# 				Daniel GAMBIS
    -# 				Director
    -# 				Earth Orientation Center of IERS
    -# 				Observatoire de Paris, France
    +# from 2006 January 1, 0h UTC, until further notice : UTC-TAI = -33 s
    +#
    +# Leap seconds can be introduced in UTC at the end of the months of December
    +# or June,  depending on the evolution of UT1-TAI. Bulletin C is mailed every
    +# six months, either to announce a time step in UTC, or to confirm that there
    +# will be no time step at the next possible date.
    +#
    +# Daniel GAMBIS
    +# Director			
    +# Earth Orientation Center of IERS
    +# Observatoire de Paris, France
    
    Modified: haiku/trunk/src/data/etc/timezones/northamerica
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/northamerica	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/northamerica	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)northamerica	8.17
    +# @(#)northamerica	8.18
     # 
     
     # also includes Central America and the Caribbean
    @@ -348,7 +348,7 @@
     #
     # Colorado, far western Kansas, Montana, western
     # Nebraska, Nevada border (Jackpot, Owyhee, and Mountain City),
    -# New Mexico, southwestern North Dakota, far eastern Oregon,
    +# New Mexico, southwestern North Dakota,
     # western South Dakota, far western Texas (El Paso County, Hudspeth County,
     # and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming
     #
    @@ -369,7 +369,8 @@
     # US Pacific time, represented by Los Angeles
     #
     # California, northern Idaho (Benewah, Bonner, Boundary, Clearwater,
    -# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties),
    +# Idaho, Kootenai, Latah, Lewis, Nez Perce, and Shoshone counties,
    +# and the northern three-quarters of Idaho county),
     # most of Nevada, most of Oregon, and Washington
     #
     # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
    @@ -527,7 +528,8 @@
     # Boise, Bonneville, Butte, Camas, Canyon, Caribou, Cassia, Clark,
     # Custer, Elmore, Franklin, Fremont, Gem, Gooding, Jefferson, Jerome,
     # Lemhi, Lincoln, Madison, Minidoka, Oneida, Owyhee, Payette, Power,
    -# Teton, Twin Falls, Valley, Washington counties) and eastern Oregon
    +# Teton, Twin Falls, Valley, Washington counties, and the southern
    +# quarter of Idaho county) and eastern Oregon (most of Malheur County)
     # switched four weeks late in 1974.
     #
     # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
    @@ -544,7 +546,7 @@
     # What time is it in Indiana?
     #  (2006-03-01)
     #
    -# From Paul Eggert (2006-03-22):
    +# From Paul Eggert (2007-08-17):
     # Since 1970, most of Indiana has been like America/Indiana/Indianapolis,
     # with the following exceptions:
     #
    @@ -556,12 +558,9 @@
     # - Clark, Floyd, and Harrison counties have been like
     #   America/Kentucky/Louisville.
     #
    -# - Daviess, Dubois, Knox, Martin, Perry, and Pulaski counties
    -#   have been like America/Indiana/Vincennes.
    +# - Crawford, Daviess, Dubois, Knox, Martin, Perry, Pike, Pulaski, Starke,
    +#   and Switzerland counties have their own time zone histories as noted below.
     #
    -# - Crawford, Pike, Starke, and Switzerland counties have their own time zone
    -#   histories as noted below.
    -#
     # Shanks partitioned Indiana into 345 regions, each with its own time history,
     # and wrote ``Even newspaper reports present contradictory information.''
     # Those Hoosiers!  Such a flighty and changeable people!
    @@ -628,8 +627,9 @@
     			-5:00	-	EST	2006
     			-5:00	US	E%sT
     #
    -# Daviess, Dubois, Knox, Martin, and Perry Counties, Indiana,
    -# switched from eastern to central time in April 2006.
    +# Daviess, Dubois, Knox, and Martin Counties, Indiana,
    +# switched from eastern to central time in April 2006, then switched back
    +# in November 2007.
     # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
     Rule Vincennes	1946	only	-	Apr	lastSun	2:00	1:00	D
     Rule Vincennes	1946	only	-	Sep	lastSun	2:00	0	S
    @@ -647,10 +647,31 @@
     			-5:00	-	EST	1969
     			-5:00	US	E%sT	1971
     			-5:00	-	EST	2006 Apr  2 2:00
    +			-6:00	US	C%sT	2007 Nov  4 2:00
    +			-5:00	US	E%sT
    +#
    +# Perry County, Indiana, switched from eastern to central time in April 2006.
    +# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
    +Rule Perry	1946	only	-	Apr	lastSun	2:00	1:00	D
    +Rule Perry	1946	only	-	Sep	lastSun	2:00	0	S
    +Rule Perry	1953	1954	-	Apr	lastSun	2:00	1:00	D
    +Rule Perry	1953	1959	-	Sep	lastSun	2:00	0	S
    +Rule Perry	1955	only	-	May	 1	0:00	1:00	D
    +Rule Perry	1956	1963	-	Apr	lastSun	2:00	1:00	D
    +Rule Perry	1960	only	-	Oct	lastSun	2:00	0	S
    +Rule Perry	1961	only	-	Sep	lastSun	2:00	0	S
    +Rule Perry	1962	1963	-	Oct	lastSun	2:00	0	S
    +# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
    +Zone America/Indiana/Tell_City -5:47:03 - LMT	1883 Nov 18 12:12:57
    +			-6:00	US	C%sT	1946
    +			-6:00 Perry	C%sT	1964 Apr 26 2:00
    +			-5:00	-	EST	1969
    +			-5:00	US	E%sT	1971
    +			-5:00	-	EST	2006 Apr  2 2:00
     			-6:00	US	C%sT
     #
     # Pike County, Indiana moved from central to eastern time in 1977,
    -# then switched back in 2006.
    +# then switched back in 2006, then switched back again in 2007.
     # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER
     Rule	Pike	1955	only	-	May	 1	0:00	1:00	D
     Rule	Pike	1955	1960	-	Sep	lastSun	2:00	0	S
    @@ -663,7 +684,8 @@
     			-5:00	-	EST	1966 Oct 30 2:00
     			-6:00	US	C%sT	1977 Oct 30 2:00
     			-5:00	-	EST	2006 Apr  2 2:00
    -			-6:00	US	C%sT
    +			-6:00	US	C%sT	2007 Nov  4 2:00
    +			-5:00	US	E%sT
     #
     # Starke County, Indiana moved from central to eastern time in 1991,
     # then switched back in 2006.
    
    Modified: haiku/trunk/src/data/etc/timezones/zone.tab
    ===================================================================
    --- haiku/trunk/src/data/etc/timezones/zone.tab	2007-09-23 17:21:41 UTC (rev 22281)
    +++ haiku/trunk/src/data/etc/timezones/zone.tab	2007-09-23 18:17:31 UTC (rev 22282)
    @@ -1,4 +1,4 @@
    -# @(#)zone.tab	8.10
    +# @(#)zone.tab	8.11
     #
     # TZ zone descriptions
     #
    @@ -39,7 +39,7 @@
     AQ	-6835+07758	Antarctica/Davis	Davis Station, Vestfold Hills
     AQ	-6617+11031	Antarctica/Casey	Casey Station, Bailey Peninsula
     AQ	-7824+10654	Antarctica/Vostok	Vostok Station, S Magnetic Pole
    -AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Base, Terre Adelie
    +AQ	-6640+14001	Antarctica/DumontDUrville	Dumont-d'Urville Station, Terre Adelie
     AQ	-690022+0393524	Antarctica/Syowa	Syowa Station, E Ongul I
     AR	-3436-05827	America/Argentina/Buenos_Aires	Buenos Aires (BA, CF)
     AR	-3124-06411	America/Argentina/Cordoba	most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF, SL)
    @@ -65,7 +65,7 @@
     AU	-1228+13050	Australia/Darwin	Northern Territory
     AU	-3157+11551	Australia/Perth	Western Australia - most locations
     AU	-3143+12852	Australia/Eucla	Western Australia - Eucla area
    -AW	+1230-06858	America/Aruba
    +AW	+1230-06958	America/Aruba
     AX	+6006+01957	Europe/Mariehamn
     AZ	+4023+04951	Asia/Baku
     BA	+4352+01825	Europe/Sarajevo
    @@ -117,10 +117,10 @@
     CA	+624900-0920459	America/Rankin_Inlet	Central Time - central Nunavut
     CA	+4953-09709	America/Winnipeg	Central Time - Manitoba & west Ontario
     CA	+4843-09434	America/Rainy_River	Central Time - Rainy River & Fort Frances, Ontario
    -CA	+6903-10505	America/Cambridge_Bay	Central Time - west Nunavut
     CA	+5024-10439	America/Regina	Central Standard Time - Saskatchewan - most locations
     CA	+5017-10750	America/Swift_Current	Central Standard Time - Saskatchewan - midwest
     CA	+5333-11328	America/Edmonton	Mountain Time - Alberta, east British Columbia & west Saskatchewan
    +CA	+690650-1050310	America/Cambridge_Bay	Mountain Time - west Nunavut
     CA	+6227-11421	America/Yellowknife	Mountain Time - central Northwest Territories
     CA	+682059-1334300	America/Inuvik	Mountain Time - west Northwest Territories
     CA	+5946-12014	America/Dawson_Creek	Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia
    @@ -175,7 +175,7 @@
     FO	+6201-00646	Atlantic/Faroe
     FR	+4852+00220	Europe/Paris
     GA	+0023+00927	Africa/Libreville
    -GB	+512830-0001845	Europe/London
    +GB	+513030-0000731	Europe/London
     GD	+1203-06145	America/Grenada
     GE	+4143+04449	Asia/Tbilisi
     GF	+0456-05220	America/Cayenne
    @@ -369,10 +369,10 @@
     TZ	-0648+03917	Africa/Dar_es_Salaam
     UA	+5026+03031	Europe/Kiev	most locations
     UA	+4837+02218	Europe/Uzhgorod	Ruthenia
    -UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye, E Lugansk
    +UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk
     UA	+4457+03406	Europe/Simferopol	central Crimea
     UG	+0019+03225	Africa/Kampala
    -UM	+1700-16830	Pacific/Johnston	Johnston Atoll
    +UM	+1645-16931	Pacific/Johnston	Johnston Atoll
     UM	+2813-17722	Pacific/Midway	Midway Islands
     UM	+1917+16637	Pacific/Wake	Wake Island
     US	+404251-0740023	America/New_York	Eastern Time
    @@ -380,12 +380,13 @@
     US	+381515-0854534	America/Kentucky/Louisville	Eastern Time - Kentucky - Louisville area
     US	+364947-0845057	America/Kentucky/Monticello	Eastern Time - Kentucky - Wayne County
     US	+394606-0860929	America/Indiana/Indianapolis	Eastern Time - Indiana - most locations
    +US	+384038-0873143	America/Indiana/Vincennes	Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties
     US	+411745-0863730	America/Indiana/Knox	Eastern Time - Indiana - Starke County
     US	+410305-0863611	America/Indiana/Winamac	Eastern Time - Indiana - Pulaski County
     US	+382232-0862041	America/Indiana/Marengo	Eastern Time - Indiana - Crawford County
     US	+384452-0850402	America/Indiana/Vevay	Eastern Time - Indiana - Switzerland County
     US	+415100-0873900	America/Chicago	Central Time
    -US	+384038-0873143	America/Indiana/Vincennes	Central Time - Indiana - Daviess, Dubois, Knox, Martin & Perry Counties
    +US	+375711-0864541	America/Indiana/Tell_City	Central Time - Indiana - Perry County
     US	+382931-0871643	America/Indiana/Petersburg	Central Time - Indiana - Pike County
     US	+450628-0873651	America/Menominee	Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties
     US	+470659-1011757	America/North_Dakota/Center	Central Time - North Dakota - Oliver County
    
    
    
    From korli at mail.berlios.de  Sun Sep 23 20:23:55 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Sun, 23 Sep 2007 20:23:55 +0200
    Subject: [Haiku-commits] r22283 - haiku/trunk/src/preferences/devices
    Message-ID: <200709231823.l8NINt4Y002462@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-23 20:23:54 +0200 (Sun, 23 Sep 2007)
    New Revision: 22283
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22283&view=rev
    
    Modified:
       haiku/trunk/src/preferences/devices/pci.ids
    Log:
    update pci ids
    
    
    Modified: haiku/trunk/src/preferences/devices/pci.ids
    ===================================================================
    --- haiku/trunk/src/preferences/devices/pci.ids	2007-09-23 18:17:31 UTC (rev 22282)
    +++ haiku/trunk/src/preferences/devices/pci.ids	2007-09-23 18:23:54 UTC (rev 22283)
    @@ -11,7 +11,7 @@
     #	This file can be distributed under either the GNU General Public License
     #	(version 2 or higher) or the 3-clause BSD License.
     #
    -#	Daily snapshot on Wed 2007-08-15 01:05:02
    +#	Daily snapshot on Sun 2007-09-23 01:05:01
     #
     
     # Vendors, devices and subsystems. Please keep sorted.
    @@ -108,8 +108,8 @@
     0842  NPG, Personal Grand Technology
     08ff  AuthenTec
     	afe4  [Anchor] AF-S2 FingerLoc Sensor Module
    -# Wrong ID used in subsystem ID of VIA USB controllers.
    -0925  VIA Technologies, Inc. (Wrong ID)
    +0925  First International Computer, Inc.
    +	1234  VA-502 Mainboard
     093a  PixArt Imaging Inc.
     	010e  Innovage Mini Digital Camera
     	010f  SDC-300 Webcam
    @@ -609,9 +609,9 @@
     	4380  SB600 Non-Raid-5 SATA
     	4381  SB600 Raid-5 SATA
     	4382  SB600 AC97 Audio
    -	4383  SB600 Azalia
    -	4384  SB600 PCI to PCI Bridge
    -	4385  SB600 SMBus
    +	4383  SBx00 Azalia
    +	4384  SBx00 PCI to PCI Bridge
    +	4385  SBx00 SMBus Controller
     	4386  SB600 USB Controller (EHCI)
     	4387  SB600 USB (OHCI0)
     	4388  SB600 USB (OHCI1)
    @@ -626,7 +626,7 @@
     	4392  SB700 SATA Controller [Non-RAID5 mode]
     	4393  SB700 SATA Controller [RAID5 mode]
     	4394  SB700 SATA Controller [SATA and FC Enabled]
    -	4395  SB700 SMBus
    +	4395  SB SATA Controller [AHCI mode with HyperFlash-PCIE]
     	4396  SB700 USB EHCI Controller
     	4397  SB700 USB OHCI0 Controller
     	4398  SB700 USB OHCI1 Controller
    @@ -774,7 +774,6 @@
     		1014 0154  ThinkPad A20m/A21m
     		1028 00aa  Latitude CPt
     		1028 00bb  Latitude CPx
    -		10e1 10cf  Fujitsu Siemens LifeBook C Series
     		1179 ff00  Satellite 1715XCDS laptop
     		13bd 1019  PC-AR10
     	4c4e  Rage Mobility L AGP 2x
    @@ -1307,10 +1306,14 @@
     	7916  RS690 PCI to PCI Bridge (PCI Express Port 2)
     	7917  RS690 PCI to PCI Bridge (PCI Express Port 3)
     	7919  Radeon X1200 Series Audio Controller
    -	791e  Radeon X1200 Series
    -	791f  Radeon X1200 Series
    -	793f  Radeon X1200 Series (Secondary)
    +	791e  RS690 [Radeon X1200 Series]
    +	791f  RS690M [Radeon X1200 Series]
    +	793f  RS600 [Radeon Xpress 1200 Series]
    +	7941  RS600 [Radeon Xpress 1200 Series]
    +	7942  Radeon Xpress 1250
     	7c37  RV350 AQ [Radeon 9600 SE]
    +	9589  RV630 [Radeon HD 2600 Series]
    +	aa08  RV630 audio device [Radeon HD 2600 Series]
     	cab0  AGP Bridge [IGP 320M]
     	cab2  RS200/RS200M AGP Bridge [IGP 340M]
     	cab3  R200 AGP Bridge [Mobility Radeon 7000 IGP]
    @@ -1888,7 +1891,6 @@
     	9470  TGUI 9470
     	9520  Cyber 9520
     	9525  Cyber 9525
    -		10cf 1094  Lifebook C6155
     	9540  Cyber 9540
     	9660  TGUI 9660/938x/968x
     	9680  TGUI 9680
    @@ -1908,6 +1910,7 @@
     		1023 9880  Blade 3D
     	9910  CyberBlade/XP
     	9930  CyberBlade/XPm
    +	9960  CyberBlade XP2
     1024  Zenith Data Systems
     1025  Acer Incorporated [ALI]
     	0090  BCM440x 100Base-TX Fast Ethernet
    @@ -2417,6 +2420,7 @@
     		1462 7010  MS-6701 motherboard
     		1734 1095  D2030-A1 Motherboard
     	7002  USB 2.0 Controller
    +		1462 5470  K7SOM+ 5.2C Motherboard
     		1462 7010  MS-6701 motherboard
     		1509 7002  Onboard USB Controller
     		1734 1095  D2030-A1
    @@ -2744,6 +2748,7 @@
     		1028 0139  Latitude D400
     		1028 014e  PCI7410,7510,7610 OHCI-Lynx Controller (Latitude D800)
     	802e  PCI7x20 1394a-2000 OHCI Two-Port PHY/Link-Layer Controller
    +		1028 018d  Inspiron 700m/710m
     	8031  PCIxx21/x515 Cardbus Controller
     		1025 0080  Aspire 5024WLMi
     		103c 0934  HP Compaq nw8240 Mobile Workstation
    @@ -2802,6 +2807,7 @@
     		13d1 aba0  SWLMP-54108 108Mbps Wireless mini PCI card 802.11g+
     		16ec 010d  USR5416 802.11g Wireless Turbo PCI Adapter
     		1737 0033  WPC54G Ver.2 802.11G PC Card
    +		17cf 0033  Z-Com XG650 Wireless miniPCI 802.11b/g
     	a001  TDC1570
     	a100  TDC1561
     	a102  TNETA1575 HyperSAR Plus w/PCI Host i/f & UTOPIA i/f
    @@ -2861,7 +2867,6 @@
     		1028 00b1  Latitude C600
     		1028 012a  Latitude C640
     		1033 80cd  Versa Note VXi
    -		1095 10cf  Fujitsu-Siemens LifeBook C Series
     		10cf 1095  Lifebook S-4510/C6155
     		e4bf 1000  CP2-2-HIPHOP
     	ac52  PCI1451 PC card Cardbus Controller
    @@ -2881,8 +2886,9 @@
     		175c 8800  ASI88xx Audio Adapter
     	ac8d  PCI 7620
     	ac8e  PCI7420 CardBus Controller
    +		1028 018d  Inspiron 700m/710m
     	ac8f  PCI7420/7620 Combo CardBus, 1394a-2000 OHCI and SD/MS-Pro Controller
    -		1028 018d  Inspiron 700m
    +		1028 018d  Inspiron 700m/710m
     	fe00  FireWire Host Controller
     	fe03  12C01A FireWire Host Controller
     104d  Sony Corporation
    @@ -3089,8 +3095,12 @@
     	8650  81348 [SuperTrak EX4650/EX8650/EX8654/EX4650EL]
     		105a 4600  SuperTrak EX4650
     		105a 4610  SuperTrak EX4650EL
    +		105a 8600  SuperTrak EX8650EL
     		105a 8601  SuperTrak EX8650
     		105a 8602  SuperTrak EX8654
    +		105a 8603  SuperTrak EX8658
    +		105a 8610  SuperTrak EX8650M
    +		105a b600  SuperTrak EX16650
     	c350  80333 [SuperTrak EX12350]
     	e350  80333 [SuperTrak EX24350]
     105b  Foxconn International, Inc.
    @@ -3346,6 +3356,7 @@
     	5432  SP232-based 4Gb Fibre Channel to PCI Express HBA
     	6312  SP202-based 2Gb Fibre Channel to PCI-X HBA
     	6322  SP212-based 2Gb Fibre Channel to PCI-X HBA
    +	7220  IBA7220 InfiniBand HCA
     1078  Cyrix Corporation
     	0000  5510 [Grappa]
     	0001  PCI Master
    @@ -3799,6 +3810,7 @@
     	0001  i960 PCI bus interface
     	1024  Acromag, Inc. IndustryPack Carrier Card
     	1042  Brandywine / jxi2, Inc. - PMC-SyncClock32, IRIG A & B, Nasa 36
    +	106a  Dual OX16C952 4 port serial adapter [Megawolf Romulus/4]
     	1076  VScom 800 8 port serial adaptor
     	1077  VScom 400 4 port serial adaptor
     	1078  VScom 210 2 port serial and 1 port parallel adaptor
    @@ -4139,6 +4151,7 @@
     	1543  M1543
     	1563  M1563 HyperTransport South Bridge
     		10b9 1563  ASRock 939Dual-SATA2 Motherboard
    +		1849 1563  ASRock 939Dual-SATA2 Motherboard
     	1573  PCI to LPC Controller
     	1621  M1621
     	1631  ALI M1631 PCI North Bridge Aladdin Pro III
    @@ -4182,6 +4195,7 @@
     		103c 0024  Pavilion ze4400 builtin USB
     		104d 810f  VAIO PCG-U1 USB/OHCI Revision 1.0
     		10b9 5237  ASRock 939Dual-SATA2 Motherboard
    +		1849 5237  ASRock 939Dual-SATA2 Motherboard
     	5239  USB 2.0 Controller
     		10b9 5239  ASRock 939Dual-SATA2 Motherboard
     	5243  M1541 PCI to AGP Controller
    @@ -4209,6 +4223,7 @@
     	5453  M5453 PCI AC-Link Controller Modem Device
     	5455  M5455 PCI AC-Link Controller Audio Device
     		10b9 5455  ASRock 939Dual-SATA2 Motherboard
    +		1849 0850  ASRock 939Dual-SATA2 Motherboard
     	5457  M5457 AC'97 Modem Controller
     		1014 0535  ThinkPad R40e (2684-HVG) builtin modem
     		103c 0024  Pavilion ze4400 builtin Modem Device
    @@ -4457,46 +4472,55 @@
     		1458 0c11  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	0051  CK804 ISA Bridge
     	0052  CK804 SMBus
     		1043 815a  K8N4-E or A8N-E Mainboard
     		1458 0c11  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	0053  CK804 IDE
     		1043 815a  K8N4-E or A8N-E Mainboard
     		1458 5002  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	0054  CK804 Serial ATA Controller
     		1043 815a  A8N-E Mainboard
     		1458 b003  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 5401  NF4 AM2L Mainboard
     	0055  CK804 Serial ATA Controller
     		1043 815a  K8N4-E or A8N-E Mainboard
     		1458 b003  GA-K8N Ultra-9 Mainboard
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 5401  NF4 AM2L Mainboard
     	0056  CK804 Ethernet Controller
     	0057  CK804 Ethernet Controller
     		1043 8141  K8N4-E or A8N-E Mainboard
     		1458 e000  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 2501  NF4 AM2L Mainboard
     	0058  CK804 AC'97 Modem
     	0059  CK804 AC'97 Audio Controller
     		1043 812a  K8N4-E or A8N-E Mainboard
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 8211  NF4 AM2L Mainboard
     	005a  CK804 USB Controller
     		1043 815a  K8N4-E or A8N-E Mainboard
     		1458 5004  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	005b  CK804 USB Controller
     		1043 815a  K8N4-E or A8N-E Mainboard
     		1458 5004  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	005c  CK804 PCI Bridge
     	005d  CK804 PCIE Bridge
     	005e  CK804 Memory Controller
    @@ -4505,6 +4529,7 @@
     		1458 5000  GA-K8N Ultra-9 Mainboard
     		1462 7100  MSI K8N Diamond
     		147b 1c1a  KN8-Ultra Mainboard
    +		1565 3402  NF4 AM2L Mainboard
     	005f  CK804 Memory Controller
     	0060  nForce2 ISA Bridge
     		1043 80ad  A7N8X Mainboard
    @@ -4865,6 +4890,7 @@
     	0251  NV25 [GeForce4 Ti 4400]
     		1043 8023  v8440 GeForce 4 Ti4400
     		10de 0251  PNY GeForce4 Ti 4400
    +		1462 8710  PNY GeForce4 Ti 4400
     	0252  NV25 [GeForce4 Ti]
     	0253  NV25 [GeForce4 Ti 4200]
     		107d 2896  WinFast A250 LE TD (Dual VGA/TV-out/DVI)
    @@ -4965,8 +4991,12 @@
     	02e0  GeForce 7600 GT
     		02e0 2249  GF 7600GT 560M 256MB DDR3 DUAL DVI TV
     	02e1  G73 [GeForce 7600 GS]
    +		1682 222b  PV-T73K-UAL3 (256MB)
     	02e2  GeForce 7300 GT
     	02e3  GeForce 7900 GS
    +# An oddball 7950 that doesn't show up on any official NVIDIA lists but was seen in the wild
    +	02e4  GeForce 7950 GT AGP
    +		1682 2271  PV-T71A-YDF3 (512MB)
     	02f0  C51 Host Bridge
     		103c 30b7  Presario V6133CL
     		1043 81cd  A8N-VM CSM Mainboard
    @@ -5115,6 +5145,7 @@
     		1462 0622  NX7600GS-T2D256EH
     	0393  G70 [GeForce 7300 GT]
     		10de 0412  NX7300GT-TD256EH
    +		1462 0412  NX7300GT-TD256EH
     	0394  G70 [GeForce 7600 LE]
     	0395  G70 [GeForce 7300 GT]
     	0397  GeForce Go 7700
    @@ -5122,6 +5153,7 @@
     		1025 006c  Acer 9814 WKMI
     	039b  GeForce Go 7900 SE
     	039c  Quadro FX 550M
    +		10de 039c  Quadro FX 560M
     	039e  G73GL [Quadro FX 560]
     	03a0  C55 Host Bridge
     	03a1  C55 Host Bridge
    @@ -5151,11 +5183,13 @@
     	03b9  C55 PCI Express bridge
     	03ba  C55 Memory Controller
     	03bb  C55 PCI Express bridge
    +	03bc  C55 Memory Controller
     	03d0  GeForce 6100 nForce 430
     	03d1  GeForce 6100 nForce 405
     	03d2  GeForce 6100 nForce 400
     	03d5  GeForce 6100 nForce 420
     	03e0  MCP61 LPC Bridge
    +		1849 03e0  939NF6G-VSTA Board
     	03e1  MCP61 LPC Bridge
     	03e2  MCP61 LPC Bridge
     	03e3  MCP61 LPC Bridge
    @@ -5166,24 +5200,34 @@
     	03e8  MCP61 PCI Express bridge
     	03e9  MCP61 PCI Express bridge
     	03ea  MCP61 Memory Controller
    +		1849 03ea  939NF6G-VSTA Board
     	03eb  MCP61 SMBus
    +		1849 03eb  939NF6G-VSTA Board
     	03ec  MCP61 IDE
     	03ee  MCP61 Ethernet
     	03ef  MCP61 Ethernet
     	03f0  MCP61 High Definition Audio
     	03f1  MCP61 USB Controller
    +		1849 03f1  939NF6G-VSTA Board
     	03f2  MCP61 USB Controller
    +		1849 03f2  939NF6G-VSTA Board
     	03f3  MCP61 PCI bridge
     	03f4  MCP61 SMU
     	03f5  MCP61 Memory Controller
    +		1849 03eb  939NF6G-VSTA Board
     	03f6  MCP61 SATA Controller
    +		1849 03f6  939NF6G-VSTA Board
     	03f7  MCP61 SATA Controller
     	0400  GeForce 8600 GTS
     	0402  GeForce 8600 GT
     	0407  GeForce 8600M GT
    +	0409  GeForce 8700M GT
    +	040a  Quadro FX 370
     	040b  Quadro NVS 320M
     	040c  Quadro FX 570M
     	040d  Quadro FX 1600M
    +	040e  Quadro FX 570
    +	040f  Quadro FX 1700
     	0421  GeForce 8500 GT
     	0422  GeForce 8400 GS
     	0423  GeForce 8300 GS
    @@ -5195,6 +5239,7 @@
     	042a  Quadro NVS 130M
     	042b  Quadro NVS 135M
     	042d  Quadro FX 360M
    +	042f  Quadro NVS 290
     	0440  MCP65 LPC Bridge
     	0441  MCP65 LPC Bridge
     	0442  MCP65 LPC Bridge
    @@ -5226,8 +5271,14 @@
     	045d  MCP65 SATA Controller
     	045e  MCP65 SATA Controller
     	045f  MCP65 SATA Controller
    +	0533  GeForce 7000M (rev a2)
    +	053e  GeForce 7025
    +	0554  MCP67 AHCI Controller
     	055c  MCP67 High Definition Audio
     	055d  MCP67 High Definition Audio
    +	055e  MCP67 OHCI USB 1.1 Controller
    +	055f  MCP67 EHCI USB 2.0 Controller
    +	0560  MCP67 IDE Controller
     	c615  G70 [GeForce 7600 GT]
     10df  Emulex Corporation
     	1ae5  LP6000 Fibre Channel Host Adapter
    @@ -5357,6 +5408,7 @@
     		1259 2400  AT-2400
     	8129  RTL-8129
     		10ec 8129  RT8129 Fast Ethernet Adapter
    +		11ec 8129  RT8129 Fast Ethernet Adapter
     	8136  RTL8101E PCI Express Fast Ethernet controller
     	8138  RT8139 (B/C) Cardbus Fast Ethernet Adapter
     		10ec 8138  RT8139 (B/C) Fast Ethernet Adapter
    @@ -5549,7 +5601,6 @@
     	0003  HPT343/345/346/363
     	0004  HPT366/368/370/370A/372/372N
     		1103 0001  HPT370A
    -		1103 0003  HPT343 / HPT345 / HPT363 UDMA33
     		1103 0004  HPT366 UDMA66 (r1) / HPT368 UDMA66 (r2) / HPT370 UDMA100 (r3) / HPT370 UDMA100 RAID (r4)
     		1103 0005  HPT370 UDMA100
     		1103 0006  HPT302/302N
    @@ -5714,7 +5765,7 @@
     	287e  VT8251 Ultra VLINK Controller
     	3022  CLE266
     	3038  VT82xxxxx UHCI USB 1.1 Controller
    -		0925 1234  USB Controller
    +		0925 1234  VA-502 Mainboard
     		1019 0985  P6VXA Motherboard
     		1019 0a81  L7VTA v1.0 Motherboard (KT400-8235)
     		1043 8080  A7V333 motherboard
    @@ -5828,6 +5879,7 @@
     		1849 3104  K7VT6 motherboard
     	3106  VT6105 [Rhine-III]
     		1186 1403  DFE-530TX rev C
    +		1186 1407  DFE-538TX
     	3108  S3 Unichrome Pro VGA Adapter
     	3109  VT8233C PCI to ISA Bridge
     	3112  VT8361 [KLE133] Host Bridge
    @@ -6901,6 +6953,7 @@
     	4b00  DGE-560T PCI Express Gigabit Ethernet Adapter
     	4b01  DGE-530T Gigabit Ethernet Adapter (rev 11)
     	4b02  DGE-560SX PCI Express Gigabit Ethernet Adapter
    +	4b03  DGE-550T Gigabit Ethernet Adapter V.B1
     	4c00  Gigabit Ethernet Adapter
     		1186 4c00  DGE-530T Gigabit Ethernet Adapter
     	8400  D-Link DWL-650+ CardBus PC Card
    @@ -7062,7 +7115,9 @@
     		1854 0020  Marvell 88E8036 Fast Ethernet Controller (LGE)
     	4352  88E8038 PCI-E Fast Ethernet Controller
     	4353  88E8039 PCI-E Fast Ethernet Controller
    +	4354  88E8040 PCI-E Fast Ethernet Controller
     	4356  88EC033 Ethernet Controller
    +	435a  88E8048 PCI-E Fast Ethernet Controller
     	4360  88E8052 PCI-E ASF Gigabit Ethernet Controller
     		1043 8134  Marvell 88E8052 Gigabit Ethernet Controller (Asus)
     		107b 4009  Marvell 88E8052 Gigabit Ethernet Controller (Wistron)
    @@ -7119,6 +7174,7 @@
     		a0a0 0506  Marvell 88E8053 Gigabit Ethernet Controller (Aopen)
     	4363  88E8055 PCI-E Gigabit Ethernet Controller
     	4364  88E8056 PCI-E Gigabit Ethernet Controller
    +	4365  88E8070 based Ethernet Controller
     	4366  88EC036 PCI-E Gigabit Ethernet Controller
     	4367  88EC032 Ethernet Controller
     	4368  88EC034 Ethernet Controller
    @@ -7283,7 +7339,6 @@
     		1033 80a8  Versa Note Vxi
     		144f 4005  Magnia SG20
     		1468 0450  Evo N600c
    -		4005 144f  LifeBook C Series
     	0451  LT WinModem
     	0452  LT WinModem
     	0453  LT WinModem
    @@ -8962,9 +9017,25 @@
     		1043 8077  CMI8738 6-channel audio controller
     		1043 80e2  CMI8738 6ch-MX
     		13f6 0111  CMI8738/C3DX PCI Audio Device
    +		13f6 9761  Theatron Agrippa
    +		153b 1144  Aureon 5.1
    +		153b 1170  Aureon 7.1
     		1681 a000  Gamesurround MUSE XL
     		270f 1103  CT-7NJS Ultra motherboard
    +		584d 3731  Digital X-Mystique
    +		584d 3741  X-Plosion 7.1
    +		584d 3751  X-Raider 7.1
    +		584d 3761  X-Mystique 7.1 LP
    +		584d 3771  X-Mystique 7.1 LP Value
    +		7284 8384  Striker 7.1
     	0211  CM8738
    +	8788  CMI8788 [Oxygen HD Audio]
    +		1043 8269  Virtuoso 200 (Xonar D2)
    +		14c3 1710  HIFIER
    +		1a58 0910  Barracuda AC-1
    +		415a 5431  X-Meridian 7.1
    +		584d 3781  HDA X-Purity 7.1 Platinum
    +		7284 9761  CLARO
     	9880  CM9880
     13f7  Wildfire Communications
     13f8  Ad Lib Multimedia Inc
    @@ -8981,6 +9052,8 @@
     # This board has two PCI functions, appears as two PCI devices
     		1602 0002  PCI-1602 2-port isolated RS-422/485
     		1612 0004  PCI-1612 4-port RS-232/422/485
    +	1603  PCI-1603 2-port isolated RS-232/current loop
    +	1604  PCI-1604 2-port RS-232
     	16ff  PCI-16xx series PCI multiport serial board (function 1: RX/TX steering CPLD)
     		1601 0000  PCI-1601 2-port unisolated RS-422/485 PCI communications card
     		1602 0000  PCI-1602 2-port isolated RS-422/485
    @@ -9120,6 +9193,10 @@
     1425  Chelsio Communications Inc
     	000b  T210 Protocol Engine
     	000c  T204 Protocol Engine
    +	0030  T310 10GbE Single Port Protocol Engine Ethernet Adapter
    +	0031  T320 10GbE Dual Port Protocol Engine Ethernet Adapter
    +	0032  T302 1GbE Dual Port Protocol Engine Ethernet adapter
    +	0033  T304 1GbE Quad Port Protocol Engine Ethernet adapter
     1426  Storage Technology Corp.
     1427  Better On-Line Solutions
     1428  Edec Co Ltd
    @@ -9500,6 +9577,7 @@
     		0e11 00cf  NC7772 Gigabit Server Adapter (PCI-X, 10,100,1000-T)
     		0e11 00d0  NC7782 Gigabit Server Adapter (PCI-X, 10,100,1000-T)
     		0e11 00d1  NC7783 Gigabit Server Adapter (PCI-X, 10,100,1000-T)
    +		103c 310f  NC7782 Gigabit Server Adapter (PCI-X, 10,100,1000-T)
     		10a9 8013  Dual Port Gigabit Ethernet (PCI-X,Copper)
     		10a9 8018  Dual Port Gigabit Ethernet (A330)
     		10a9 801a  Dual Port Gigabit Ethernet (IA-blade)
    @@ -9599,6 +9677,7 @@
     	16aa  NetXtreme II BCM5706S Gigabit Ethernet
     		103c 3102  NC370F MultifuNCtion Gigabit Server Adapter
     	16ac  NetXtreme II BCM5708S Gigabit Ethernet
    +		1014 0304  NetXtreme II BCM5708S Gigabit Ethernet
     		103c 1706  NC373m Multifunction Gigabit Server Adapter
     		103c 7038  NC373i PCI Express Multifunction Gigabit Server Adapter
     		103c 703b  NC373i Integrated Multifunction Gigabit Server Adapter
    @@ -9620,6 +9699,7 @@
     	16fe  NetXtreme BCM5753F Fast Ethernet PCI Express
     	170c  BCM4401-B0 100Base-TX
     		1028 0188  Inspiron 6000 laptop
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		1028 01af  Inspiron 6400
     		103c 099c  NX6110/NC6120
    @@ -9682,6 +9762,9 @@
     		1414 0003  Wireless Notebook Adapter MN-720
     		1414 0004  Wireless PCI Adapter MN-730
     	4326  BCM4307 Chipcommon I/O Controller?
    +# This should be the correct naming
    +	4328  BCM4328 802.11a/b/g/n
    +		1028 000a  Wireless 1500 Draft 802.11n WLAN Mini-card
     	4329  BCM43XG
     	4344  EDGE/GPRS data and 802.11b/g combo cardbus [GC89]
     	4401  BCM4401 100Base-T
    @@ -10466,7 +10549,7 @@
     	0007  AR5000 802.11a Wireless Adapter
     	0011  AR5210 802.11a NIC
     	0012  AR5211 802.11ab NIC
    -	0013  AR5212 802.11abg NIC
    +	0013  AR5212/AR5213 Multiprotocol MAC/baseband processor
     		1113 d301  Philips CPWNA100 Wireless CardBus adapter
     		1186 3202  D-link DWL-G650 (Rev B3,B5) Wireless cardbus adapter
     		1186 3203  DWL-G520 Wireless PCI Adapter
    @@ -10481,12 +10564,14 @@
     		1186 3ab0  Allnet ALL0281 Wireless PCI Card
     		1385 4d00  Netgear WG311T Wireless PCI Adapter
     		1458 e911  Gigabyte GN-WIAG02
    +		1468 0408  ThinkPad 11b/g Wireless LAN Mini PCI Adapter
     		14b7 0a60  8482-WD ORiNOCO 11a/b/g Wireless PCI Adapter
     		1668 1026  IBM HighRate 11 a/b/g Wireless CardBus Adapter
     		168c 0013  AirPlus XtremeG DWL-G650 Wireless PCMCIA Adapter
     		168c 1025  DWL-G650B2 Wireless CardBus Adapter
     		168c 1027  Engenius NL-3054CB ARIES b/g CardBus Adapter
     		168c 1042  Ubiquiti Networks SuperRange a/b/g Cardbus Adapter
    +		168c 1051  EZ Connect g 802.11g 108Mbps Wireless PCI Adapter
     		168c 2026  Netgate 5354MP ARIES a(108Mb turbo)/b/g MiniPCI Adapter
     		168c 2041  Engenius 5354MP Plus ARIES2 b/g MiniPCI Adapter
     		168c 2042  Engenius 5354MP Plus ARIES2 a/b/g MiniPCI Adapter
    @@ -10495,7 +10580,8 @@
     		17cf 0042  Z-COMAX Highpower XG-622H (400mw) 802.11b/g mini-PCI Adapter
     		185f 1012  CM9 Wireless a/b/g MiniPCI Adapter
     		185f 2012  Wistron NeWeb WLAN a+b+g model CB9
    -	001a  AR5005G 802.11abg NIC
    +# the name AR5005G is used for the reference design using AR2413
    +	001a  AR2413 802.11bg NIC
     		1052 168c  Sweex Wireless Lan PC Card 54Mbps
     		1113 ee20  SMC Wireless CardBus Adapter 802.11g (SMCWCB-G EU)
     		1113 ee24  SMC Wireless PCI Card WPCI-G
    @@ -10507,7 +10593,8 @@
     		168c 001a  Belkin FD7000
     		168c 1052  TP-Link TL-WN510G Wireless CardBus Adapter
     		168c 2052  Compex Wireless 802.11 b/g  MiniPCI Adapter, Rev A1 [WLM54G]
    -	001b  AR5006X 802.11abg NIC
    +# the name AR5006X is used for the reference design using AR5413
    +	001b  AR5413 802.11abg NIC
     		1186 3a19  D-Link AirPremier AG DWL-AG660 Wireless Cardbus Adapter
     		1186 3a22  D-Link AirPremier AG DWL-AG530 Wireless PCI Adapter
     		1458 e901  GN-WI01HT Wireless a/b/g MiniPCI Adapter
    @@ -10517,6 +10604,10 @@
     		185f 1600  DCMA-82 High Power WLAN 802.11a/b/g mini-PCI Module (Super A/G, eXtended Range, 400mW)
     		a727 6804  Wireless 11a/b/g PC Card with XJACK(r) Antenna
     	001c  AR5006EG 802.11 b/g Wireless PCI Express Adapter
    +		168c 3061  AR5006EGS 802.11bg NIC (2.4GHz, PCI Express)
    +		168c 3062  AR5006EXS 802.11abg NIC (2.4/5.0GHz, PCI Express)
    +		168c 3063  AR5006EX 802.11abg NIC (2.4/5.0GHz, PCI Express)
    +		168c 3065  AR5006EG 802.11bg NIC (2.4GHz, PCI Express)
     	0020  AR5005VL 802.11bg Wireless NIC
     	0023  AR5416 802.11a/b/g/n Wireless PCI Adapter
     	0024  AR5418 802.11a/b/g/n Wireless PCI Express Adapter
    @@ -10678,6 +10769,7 @@
     	8033  GL880S USB 1.1 controller
     	8034  GL880S USB 2.0 controller
     17aa  Lenovo
    +17ab  Phillips Components
     17af  Hightech Information System Ltd.
     17b3  Hawking Technologies
     	ab08  PN672TX 10/100 Ethernet
    @@ -10780,6 +10872,10 @@
     	9790  WL-121 Wireless Network Adapter 100g+ [Ver.3]
     182e  Raza Microelectronics, Inc.
     	0008  XLR516 Processor
    +# Strange vendor ID used by BCM5785 when in RAID mode
    +182f  Broadcom
    +# HT1000 uses 3 IDs 1166:024a (Native SATA Mode), 1166:024b (PATA/IDE Mode), 182f:000b (RAID Mode) depends on SATA BIOS setting
    +	000b  BCM5785 [HT1000] SATA (RAID Mode)
     1830  Credence Systems Corporation
     183b  MikroM GmbH
     	08a7  MVC100 DVI
    @@ -10912,8 +11008,10 @@
     	0021  MPC8568
     	0022  MPC8567E
     	0023  MPC8567
    -	0030  MPC8544
    -	0031  MPC8544E
    +	0030  MPC8533E
    +	0031  MPC8533
    +	0032  MPC8544E
    +	0033  MPC8544
     	0080  MPC8349E
     	0081  MPC8349
     	0082  MPC8347E TBGA
    @@ -10984,7 +11082,9 @@
     1a22  Ambric Inc.
     1a29  Fortinet, Inc.
     1a51  Hectronic AB
    +1a58  Razer USA Ltd.
     1a5d  Celoxica
    +1a68  VirtenSys Limited
     1a71  XenSource, Inc.
     1a73  Violin Memory, Inc
     	0001  Mozart [Memory Appliance 1010]
    @@ -11123,6 +11223,8 @@
     	1360  RTL8139 Ethernet
     4040  NetXen Incorporated
     	0001  NXB-10GXSR 10 Gigabit Ethernet PCIe Adapter with SR-XFP optical interface
    +		103c 7047  NC510F PCIe 10 Gigabit Server Adapter
    +		103c 7048  NC510C PCIe 10 Gigabit Server Adapter
     	0002  NXB-10GCX4 10 Gigabit Ethernet PCIe Adapter with CX4 copper interface
     	0003  NXB-4GCU Quad Gigabit Ethernet PCIe Adapter with 1000-BASE-T interface
     	0004  BladeCenter-H 10 Gigabit Ethernet High Speed Daughter Card
    @@ -11410,7 +11512,9 @@
     	0309  80303 I/O Processor PCI-to-PCI Bridge
     	030d  80312 I/O Companion Chip PCI-to-PCI Bridge
     	0326  6700/6702PXH I/OxAPIC Interrupt Controller A
    +		1775 1100  CR11/VR11 Single Board Computer
     	0327  6700PXH I/OxAPIC Interrupt Controller B
    +		1775 1100  CR11/VR11 Single Board Computer
     	0329  6700PXH PCI Express-to-PCI Bridge A
     	032a  6700PXH PCI Express-to-PCI Bridge B
     	032c  6702PXH PCI Express-to-PCI Bridge A
    @@ -11467,7 +11571,7 @@
     	0960  80960RP (i960RP) Microprocessor/Bridge
     	0962  80960RM (i960RM) Bridge
     	0964  80960RP (i960RP) Microprocessor/Bridge
    -	1000  82542 Gigabit Ethernet Controller
    +	1000  82542 Gigabit Ethernet Controller (Fiber)
     		0e11 b0df  NC6132 Gigabit Ethernet Adapter (1000-SX)
     		0e11 b0e0  NC6133 Gigabit Ethernet Adapter (1000-LX)
     		0e11 b123  NC6134 Gigabit Ethernet Adapter (1000-LX)
    @@ -11628,7 +11732,7 @@
     		8086 2527  MIM2000/Centrino
     		8086 2561  Dell Latitude D800
     		8086 2581  Toshiba Satellite M10
    -	1048  PRO/10GbE LR Server Adapter
    +	1048  82597EX 10GbE Ethernet Controller
     		8086 a01f  PRO/10GbE LR Server Adapter
     		8086 a11f  PRO/10GbE LR Server Adapter
     	1049  82566MM Gigabit Network Connection
    @@ -11722,9 +11826,11 @@
     		8086 1476  PRO/1000 GT Desktop Adapter
     	107d  82572EI Gigabit Ethernet Controller (Copper)
     		8086 1082  PRO/1000 PT Server Adapter
    +		8086 1084  PRO/1000 PT Server Adapter
     		8086 1092  PRO/1000 PT Server Adapter
     	107e  82572EI Gigabit Ethernet Controller (Fiber)
     		8086 1084  PRO/1000 PF Server Adapter
    +		8086 1085  PRO/1000 PF Server Adapter
     		8086 1094  PRO/1000 PF Server Adapter
     	107f  82572EI Gigabit Ethernet Controller
     	1080  FA82537EP 56K V.92 Data/Fax Modem PCI
    @@ -11768,7 +11874,12 @@
     	10a4  82571EB Gigabit Ethernet Controller
     		8086 10a4  PRO/1000 PT Quad Port Server Adapter
     		8086 11a4  PRO/1000 PT Quad Port Server Adapter
    -	10a5  82571EB PRO/1000 PF Quad Port Server Adapter
    +	10a5  82571EB Gigabit Ethernet Controller (Fiber)
    +		8086 10a5  PRO/1000 PF Quad Port Server Adapter
    +		8086 10a6  PRO/1000 PF Quad Port Server Adapter
    +	10a7  82575EB Gigabit Network Connection
    +		8086 10a8  82575EB Gigabit Riser Card
    +	10a9  82575EB Gigabit Backplane Connection
     	10b0  82573L PRO/1000 PL Network Connection
     	10b2  82573V PRO/1000 PM Network Connection
     	10b3  82573E PRO/1000 PM Network Connection
    @@ -11794,13 +11905,24 @@
     	10c3  82562GT-2 10/100 Network Connection
     	10c4  82562GT 10/100 Network Connection
     	10c5  82562G 10/100 Network Connection
    -	10c6  82598AF DUAL PORT 10GbE PCI-Express Ethernet Controller
    -	10c7  82598AF SINGLE PORT 10GbE PCI-Express Ethernet Controller
    -	10d6  82575 Gigabit VT Quad Port Server Adapter
    +	10c6  82598EB 10 Gigabit AF Dual Port Network Connection
    +		8086 a05f  10 Gigabit XF SR Dual Port Server Adapter
    +		8086 a15f  10 Gigabit XF SR Dual Port Server Adapter
    +	10c7  82598EB 10 Gigabit AF Network Connection
    +		8086 a05f  10 Gigabit XF SR Server Adapter
    +		8086 a15f  10 Gigabit XF SR Server Adapter
    +		8086 a16f  10 Gigabit XF SR Server Adapter
    +	10d5  82571PT Gigabit PT Quad Port Server ExpressModule
    +	10d6  82575GB Gigabit Network Connection
    +		8086 10d6  Gigabit VT Quad Port Server Adapter
    +		8086 145a  Gigabit VT Quad Port Server Adapter
     	10d9  82571EB Dual Port Gigabit Mezzanine Adapter
    -		103c 1716  HP 360m Dual Port 1GbE BL-c Adapter
    +		103c 1716  NC360m Dual Port 1GbE BL-c Adapter
     	10da  82571EB Quad Port Gigabit Mezzanine Adapter
    -		103c 1717  HP 364m Quad Port 1GbE BL-c Adapter
    +		103c 1717  NC364m Quad Port 1GbE BL-c Adapter
    +	10dd  82598EB 10 Gigabit AT CX4 Network Connection
    +	10e2  82575GB Gigabit Network Connection
    +		8086 10e2  Gigabit VT Quad Port Server Adapter
     	1107  PRO/1000 MF Server Adapter (LX)
     	1130  82815 815 Chipset Host Bridge and Memory Controller Hub
     		1025 1016  Travelmate 612 TX
    @@ -11811,6 +11933,7 @@
     	1131  82815 815 Chipset AGP Bridge
     	1132  82815 Chipset Graphics Controller (CGC)
     		1025 1016  Travelmate 612 TX
    +		103c 2001  e-pc 40
     		104d 80df  Vaio PCG-FX403
     		8086 4532  D815EEA2 Mainboard
     		8086 4541  D815EEA Motherboard
    @@ -12047,9 +12170,12 @@
     	1a24  82840 840 [Carmel] Chipset PCI Bridge (Hub B)
     	1a30  82845 845 [Brookdale] Chipset Host Bridge
     		1028 010e  Optiplex GX240
    +		15d9 3280  Supermicro P4SBE Mainboard
     	1a31  82845 845 [Brookdale] Chipset AGP Bridge
     	1a38  5000 Series Chipset DMA Engine
    -	1a48  PRO/10GbE SR Server Adapter
    +	1a48  82597EX 10GbE Ethernet Controller
    +		8086 a01f  PRO/10GbE SR Server Adapter
    +		8086 a11f  PRO/10GbE SR Server Adapter
     	1b48  82597EX 10GbE Ethernet Controller
     		8086 a01f  PRO/10GbE LR Server Adapter
     		8086 a11f  PRO/10GbE LR Server Adapter
    @@ -12083,6 +12209,7 @@
     		1025 1016  Travelmate 612 TX
     		1028 00c7  Dimension 8100
     		1028 010e  Optiplex GX240
    +		103c 126f  e-pc 40
     		1043 8027  TUSL2-C Mainboard
     		104d 80df  Vaio PCG-FX403
     		147b 0507  TH7II-RAID
    @@ -12094,9 +12221,11 @@
     		1025 1016  Travelmate 612 TX
     		1028 00c7  Dimension 8100
     		1028 010e  Optiplex GX240
    +		103c 126f  e-pc 40
     		1043 8027  TUSL2-C Mainboard
     		104d 80df  Vaio PCG-FX403
     		147b 0507  TH7II-RAID
    +		15d9 3280  Supermicro P4SBE Mainboard
     		8086 4532  D815EEA2 mainboard
     		8086 4557  D815EGEW Mainboard
     		8086 5744  S845WD1-E mainboard
    @@ -12104,6 +12233,7 @@
     		1025 1016  Travelmate 612 TX
     		1028 00c7  Dimension 8100
     		1028 010e  Optiplex GX240
    +		103c 126f  e-pc 40
     		1043 8027  TUSL2-C Mainboard
     		104d 80df  Vaio PCG-FX403
     		147b 0507  TH7II-RAID
    @@ -12114,6 +12244,7 @@
     		0e11 0088  Evo D500
     		1014 01c6  Netvista A40/A40p
     		1025 1016  Travelmate 612 TX
    +		103c 126f  e-pc 40
     		104d 80df  Vaio PCG-FX403
     		1462 3370  STAC9721 AC
     		147b 0507  TH7II-RAID
    @@ -12125,6 +12256,7 @@
     # (rev d3) (prog-if (rev d3) (prog-if 01 [Subtractive decode])
     		103c 0934  HP Compaq nw8240 Mobile Workstation
     		103c 099c  NX6110/NC6120
    +		103c 30a3  Compaq nw8440
     		144d c00c  P30 notebook
     		1734 1055  Amilo M1420
     	2449  82801BA/BAM/CA/CAM Ethernet Controller
    @@ -12165,8 +12297,10 @@
     		1014 01c6  Netvista A40/A40p
     		1028 00c7  Dimension 8100
     		1028 010e  Optiplex GX240
    +		103c 126f  e-pc 40
     		1043 8027  TUSL2-C Mainboard
     		147b 0507  TH7II-RAID
    +		15d9 3280  Supermicro P4SBE Mainboard
     		8086 4532  D815EEA2 mainboard
     		8086 4557  D815EGEW Mainboard
     		8086 5744  S845WD1-E mainboard
    @@ -12244,6 +12378,7 @@
     		1025 005a  TravelMate 290
     		1028 0126  Optiplex GX260
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12265,6 +12400,7 @@
     		1025 005a  TravelMate 290
     		1028 0126  Optiplex GX260
     		1028 014f  Latitude X300
    +		1028 018d  Inspiron 700m/710m
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
     		103c 08b0  tc1100 tablet
    @@ -12284,6 +12420,7 @@
     		1025 005a  TravelMate 290
     		1028 0126  Optiplex GX260
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12307,6 +12444,7 @@
     		1028 0139  Latitude D400
     		1028 014f  Latitude X300
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m [SigmaTel STAC9750,51]
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12333,12 +12471,15 @@
     		1071 8160  MIM2000
     		144d 2115  Samsung X10 Laptop
     		144d c00c  P30/P35 notebook
    +# Conexant HSF Softmodem (CXT22)
    +		14f1 5422  D480 MDC V.9x Modem
     	24c7  82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3
     		1014 0267  NetVista A30p
     		1014 052d  ThinkPad
     		1025 005a  TravelMate 290
     		1028 0126  Optiplex GX260
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12358,6 +12499,7 @@
     		1025 005a  TravelMate 290
     		1028 014f  Latitude X300
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12386,6 +12528,7 @@
     		1028 0126  Optiplex GX260
     		1028 0139  Latitude D400
     		1028 0163  Latitude D505
    +		1028 018d  Inspiron 700m/710m
     		1028 0196  Inspiron 5160
     		103c 088c  NC8000 laptop
     		103c 0890  NC6000 laptop
    @@ -12972,8 +13115,10 @@
     	27a0  Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		17aa 2017  Thinkpad R60e model 0657
     	27a1  Mobile 945GM/PM/GMS, 943/940GML and 945GT Express PCI Express Root Port
    +		103c 30a3  Compaq nw8440
     	27a2  Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller
     		103c 30a1  NC2400
     		17aa 201a  Thinkpad R60e model 0657
    @@ -12990,6 +13135,7 @@
     		8086 544e  DeskTop Board D945GTP
     	27b9  82801GBM (ICH7-M) LPC Interface Bridge
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		10f7 8338  Panasonic CF-Y5 laptop
     		17aa 2009  ThinkPad T60/R60 series
     	27bd  82801GHM (ICH7-M DH) LPC Interface Bridge
    @@ -13004,44 +13150,54 @@
     	27c4  82801GBM/GHM (ICH7 Family) SATA IDE Controller
     		1025 006c  9814 WKMI
     	27c5  82801GBM/GHM (ICH7 Family) SATA AHCI Controller
    +		103c 30a3  Compaq nw8440
     		17aa 200d  Thinkpad R60e model 0657
     	27c6  82801GHM (ICH7-M DH) SATA RAID Controller
     	27c8  82801G (ICH7 Family) USB UHCI Controller #1
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		107b 5048  E4500
     		17aa 200a  ThinkPad T60/R60 series
     		8086 544e  DeskTop Board D945GTP
     	27c9  82801G (ICH7 Family) USB UHCI Controller #2
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		107b 5048  E4500
     		17aa 200a  ThinkPad T60/R60 series
     		8086 544e  DeskTop Board D945GTP
     	27ca  82801G (ICH7 Family) USB UHCI Controller #3
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		107b 5048  E4500
     		17aa 200a  ThinkPad T60/R60 series
     		8086 544e  DeskTop Board D945GTP
     	27cb  82801G (ICH7 Family) USB UHCI Controller #4
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		107b 5048  E4500
     		17aa 200a  ThinkPad T60/R60 series
     		8086 544e  DeskTop Board D945GTP
     	27cc  82801G (ICH7 Family) USB2 EHCI Controller
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		17aa 200b  ThinkPad T60/R60 series
     		8086 544e  DeskTop Board D945GTP
     	27d0  82801G (ICH7 Family) PCI Express Port 1
    +		103c 30a3  Compaq nw8440
     	27d2  82801G (ICH7 Family) PCI Express Port 2
    +		103c 30a3  Compaq nw8440
     	27d4  82801G (ICH7 Family) PCI Express Port 3
     	27d6  82801G (ICH7 Family) PCI Express Port 4
    +		103c 30a3  Compaq nw8440
     	27d8  82801G (ICH7 Family) High Definition Audio Controller
     		1025 006c  9814 WKMI
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		1043 13c4  Asus G2P
     		107b 5048  E4500
     		10f7 8338  Panasonic CF-Y5 laptop
    @@ -13063,6 +13219,7 @@
     		1462 7267  Realtek ALC883 Audio Controller
     	27df  82801G (ICH7 Family) IDE Controller
     		103c 30a1  NC2400
    +		103c 30a3  Compaq nw8440
     		107b 5048  E4500
     		10f7 8338  Panasonic CF-Y5 laptop
     		17aa 200c  Thinkpad R60e model 0657
    @@ -13110,9 +13267,8 @@
     		17aa 20ac  Lenovo Thinkpad T61
     	284f  82801H (ICH8 Family) Thermal Reporting Device
     	2850  82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
    -	2911  LPC Interface Controller
     	2912  82801IH (ICH9DH) LPC Interface Controller
    -	2914  LPC Interface Controller
    +	2914  82801IO (ICH9DO) LPC Interface Controller
     	2916  82801IR (ICH9R) LPC Interface Controller
     	2917  Mobile LPC Controller
     	2918  82801IB (ICH9) LPC Interface Controller
    @@ -13121,7 +13277,7 @@
     	2921  82801IB (ICH9) 2 port SATA IDE Controller
     	2922  82801IR/IO/IH (ICH9R/DO/DH) 6 port SATA AHCI Controller
     	2923  82801IB (ICH9) 4 port SATA AHCI Controller
    -	2925  82801IR/IO (ICH9R//DO) SATA RAID Controller
    +	2925  82801IR/IO (ICH9R/DO) SATA RAID Controller
     	2926  82801I (ICH9 Family) 2 port SATA IDE Controller
     	2928  Mobile 2 port SATA IDE Controller
     	2929  Mobile SATA AHCI Controller
    @@ -13154,9 +13310,11 @@
     	2975  82946GZ/GL HECI Controller
     	2976  82946GZ/GL PT IDER Controller
     	2977  82946GZ/GL KT Controller
    -	2980  965 G1 Memory Controller Hub
    -	2981  965 G1 PCI Express Root Port
    -	2982  965 G1 Integrated Graphics Controller
    +	2980  82G35 Express DRAM Controller
    +	2981  82G35 Express PCI Express Root Port
    +	2982  82G35 Express Integrated Graphics Controller
    +	2983  82G35 Express Integrated Graphics Controller
    +	2984  82G35 Express HECI Controller
     	2990  82Q963/Q965 Memory Controller Hub
     	2991  82Q963/Q965 PCI Express Root Port
     	2992  82Q963/Q965 Integrated Graphics Controller
    @@ -13175,14 +13333,14 @@
     	29a5  82P965/G965 HECI Controller
     	29a6  82P965/G965 PT IDER Controller
     	29a7  82P965/G965 KT Controller
    -	29b0  DRAM Controller
    -	29b1  PCI Express Root Port
    -	29b2  Integrated Graphics Controller
    -	29b3  Integrated Graphics Controller
    -	29b4  MEI Controller
    -	29b5  MEI Controller
    -	29b6  PT IDER Controller
    -	29b7  Serial KT Controller
    +	29b0  82Q35 Express DRAM Controller
    +	29b1  82Q35 Express PCI Express Root Port
    +	29b2  82Q35 Express Integrated Graphics Controller
    +	29b3  82Q35 Express Integrated Graphics Controller
    +	29b4  82Q35 Express MEI Controller
    +	29b5  82Q35 Express MEI Controller
    +	29b6  82Q35 Express PT IDER Controller
    +	29b7  82Q35 Express Serial KT Controller
     	29c0  82G33/G31/P35/P31 Express DRAM Controller
     	29c1  82G33/G31/P35/P31 Express PCI Express Root Port
     	29c2  82G33/G31 Express Integrated Graphics Controller
    @@ -13192,14 +13350,14 @@
     	29c6  82G33/G31/P35/P31 Express PT IDER Controller
     	29c7  82G33/G31/P35/P31 Express Serial KT Controller
     	29cf  Virtual HECI Controller
    -	29d0  DRAM Controller
    -	29d1  PCI Express Root Port
    -	29d2  Integrated Graphics Controller
    -	29d3  Integrated Graphics Controller
    -	29d4  MEI Controller
    -	29d5  MEI Controller
    -	29d6  PT IDER Controller
    -	29d7  Serial KT Controller
    +	29d0  82Q33 Express DRAM Controller
    +	29d1  82Q33 Express PCI Express Root Port
    +	29d2  82Q33 Express Integrated Graphics Controller
    +	29d3  82Q33 Express Integrated Graphics Controller
    +	29d4  82Q33 Express MEI Controller
    +	29d5  82Q33 Express MEI Controller
    +	29d6  82Q33 Express PT IDER Controller
    +	29d7  82Q33 Express Serial KT Controller
     	29e0  DRAM Controller
     	29e1  Host-Primary PCI Express Bridge
     	29e4  MEI Controller
    @@ -13223,6 +13381,14 @@
     	2a05  Mobile PM965/GM965 MEI Controller
    
    [... truncated: 97 lines follow ...]
    
    
    From axeld at pinc-software.de  Sun Sep 23 21:48:56 2007
    From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=)
    Date: Sun, 23 Sep 2007 21:48:56 +0200 CEST
    Subject: [Haiku-commits] r22281 -
     haiku/trunk/src/system/libroot/posix/pthread
    In-Reply-To: <20070923193521.7512.1@cs.tu-berlin.de>
    Message-ID: <38685864716-BeMail@zon>
    
    Ingo Weinhold  wrote:
    > > Log:
    > > * Fixed build for GCC 2.95.3 - it does not support newer C syntax.
    > I'd rather see those source files be renamed to *.cpp. No need to 
    > uglify 
    > them unnecessarily.
    
    Well, that was a one liner - changing it to *.cpp would probably have 
    required a lot more changes...
    
    Bye,
       Axel.
    
    
    
    From leavengood at gmail.com  Sun Sep 23 22:50:23 2007
    From: leavengood at gmail.com (Ryan Leavengood)
    Date: Sun, 23 Sep 2007 16:50:23 -0400
    Subject: [Haiku-commits] r22281 -
    	haiku/trunk/src/system/libroot/posix/pthread
    In-Reply-To: <38685864716-BeMail@zon>
    References: <20070923193521.7512.1@cs.tu-berlin.de> <38685864716-BeMail@zon>
    Message-ID: 
    
    On 9/23/07, Axel D?rfler  wrote:
    >
    > Well, that was a one liner - changing it to *.cpp would probably have
    > required a lot more changes...
    
    Yeah, I don't think it is that hard to keep the C style, especially
    since pthreads is a C API anyhow. I only deviated because I used
    Ingo's patch verbatim (and didn't test with GCC2.) Ingo, you really
    don't like old school C, eh? ;)
    
    Ryan
    
    
    From korli at mail.berlios.de  Sun Sep 23 22:57:01 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Sun, 23 Sep 2007 22:57:01 +0200
    Subject: [Haiku-commits] r22284 -
    	haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich
    Message-ID: <200709232057.l8NKv18E010399@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-23 22:57:00 +0200 (Sun, 23 Sep 2007)
    New Revision: 22284
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22284&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
       haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.h
       haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
       haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/config.h
    Log:
    patch from H?\195?\188seyin Erdemir: his laptops HP nx8220 didn't have Headphone Jacksense working as is. Thanks!
    Some other HP laptops have this problem.
    Maybe we should have ac97 export quirks and the driver uses them.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2007-09-23 18:23:54 UTC (rev 22283)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2007-09-23 20:57:00 UTC (rev 22284)
    @@ -95,12 +95,14 @@
     
     void default_init(device_config *);
     void ad1886_init(device_config *);
    +void ad1981b_init(device_config *);
     
     void default_amp_enable(device_config *, bool);
     void cs4299_amp_enable(device_config *, bool);
     
     codec_ops default_ops = { default_init, default_amp_enable };
     codec_ops ad1886_ops = { ad1886_init, default_amp_enable };
    +codec_ops ad1981b_ops = { ad1981b_init, default_amp_enable };
     codec_ops cs4299_ops = { default_init, cs4299_amp_enable };
     
     codec_table codecs[] = 
    @@ -150,6 +152,7 @@
     	{ 0x41445363, 0xffffffff, &default_ops, "Analog Devices AD1886A SoundMAX"B_UTF8_REGISTERED },
     	{ 0x41445371, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED },
     	{ 0x41445372, 0xffffffff, &default_ops, "Analog Devices AD1981A SoundMAX"B_UTF8_REGISTERED },
    +	{ 0x41445374, 0xffffffff, &ad1981b_ops, "Analog Devices AD1981B SoundMAX"B_UTF8_REGISTERED },
     	{ 0x414c4320, 0xfffffff0, &default_ops, "Avance Logic (Realtek) ALC100/ALC100P, RL5383/RL5522" },
     	{ 0x414c4730, 0xffffffff, &default_ops, "Avance Logic (Realtek) ALC101" },
     #if 0
    @@ -251,9 +254,20 @@
     void ad1886_init(device_config *config)
     {
     	LOG(("ad1886_init\n"));
    -	auich_codec_write(config, 0x72, 0x0010);
    +	auich_codec_write(config, AC97_AD_JACKSENSE, 0x0010);
     }
     
    +void ad1981b_init(device_config *config)
    +{
    +	uint32 id;
    +	LOG(("ad1981b_init\n"));
    +	id = (config->subvendor_id << 16) | config->subsystem_id;
    +	if (id == 0x103c0934) {
    +		auich_codec_write(config, AC97_AD_JACKSENSE,
    +			auich_codec_read(config, AC97_AD_JACKSENSE) | 0x0800);
    +	}
    +}
    +
     void default_amp_enable(device_config *config, bool yesno)
     {
     	LOG(("default_amp_enable\n"));
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.h	2007-09-23 18:23:54 UTC (rev 22283)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.h	2007-09-23 20:57:00 UTC (rev 22284)
    @@ -64,6 +64,7 @@
     	AC97_CENTER_LFE_VOLUME	= 0x36,
     	AC97_SURROUND_VOLUME	= 0x38,
     	AC97_SPDIF_CONTROL		= 0x3A,
    +	AC97_AD_JACKSENSE		= 0x72,
     	AC97_VENDOR_ID1			= 0x7C,
     	AC97_VENDOR_ID2			= 0x7E
     };
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2007-09-23 18:23:54 UTC (rev 22283)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c	2007-09-23 20:57:00 UTC (rev 22284)
    @@ -607,6 +607,8 @@
     
     	make_device_names(card);
     	
    +	card->config.subvendor_id = card->info.u.h0.subsystem_vendor_id;
    +	card->config.subsystem_id = card->info.u.h0.subsystem_id;
     	card->config.nabmbar = card->info.u.h0.base_registers[0];
     	card->config.irq = card->info.u.h0.interrupt_line;
     	card->config.type = 0;
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/config.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/config.h	2007-09-23 18:23:54 UTC (rev 22283)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/config.h	2007-09-23 20:57:00 UTC (rev 22284)
    @@ -46,6 +46,9 @@
     	void *	log_mbbar; // ich4
     	area_id area_mmbar; // ich4
     	area_id area_mbbar; // ich4
    +
    +	ushort	subvendor_id;
    +	ushort	subsystem_id;
     } device_config;
     
     #define TYPE_ICH4			0x01
    
    
    
    From korli at mail.berlios.de  Sun Sep 23 23:52:54 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Sun, 23 Sep 2007 23:52:54 +0200
    Subject: [Haiku-commits] r22285 -
    	haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich
    Message-ID: <200709232152.l8NLqs3t012847@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-23 23:52:54 +0200 (Sun, 23 Sep 2007)
    New Revision: 22285
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22285&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
    Log:
    added some other ids for HP laptops with Headphone jack sense quirk
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2007-09-23 20:57:00 UTC (rev 22284)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/ac97.c	2007-09-23 21:52:54 UTC (rev 22285)
    @@ -262,7 +262,14 @@
     	uint32 id;
     	LOG(("ad1981b_init\n"));
     	id = (config->subvendor_id << 16) | config->subsystem_id;
    -	if (id == 0x103c0934) {
    +	if (id == 0x103c0934
    +		|| id == 0x103c006d
    +		|| id == 0x103c088c
    +		|| id == 0x103c0890
    +		|| id == 0x103c0934
    +		|| id == 0x103c0938
    +		|| id == 0x103c0944
    +		|| id == 0x103c099c) {
     		auich_codec_write(config, AC97_AD_JACKSENSE,
     			auich_codec_read(config, AC97_AD_JACKSENSE) | 0x0800);
     	}
    
    
    
    From bonefish at mail.berlios.de  Mon Sep 24 01:32:04 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Mon, 24 Sep 2007 01:32:04 +0200
    Subject: [Haiku-commits] r22286 - haiku/trunk/src/kits/interface
    Message-ID: <200709232332.l8NNW4lc004413@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-24 01:32:03 +0200 (Mon, 24 Sep 2007)
    New Revision: 22286
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22286&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/RegionSupport.cpp
    Log:
    Fixed assert macro.
    
    
    Modified: haiku/trunk/src/kits/interface/RegionSupport.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/RegionSupport.cpp	2007-09-23 21:52:54 UTC (rev 22285)
    +++ haiku/trunk/src/kits/interface/RegionSupport.cpp	2007-09-23 23:32:03 UTC (rev 22286)
    @@ -85,7 +85,7 @@
     #ifdef DEBUG
     #include 
     #define assert(expr) {if (!(expr)) fprintf(stderr,\
    -"Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__); }
    +"Assertion failed file %s, line %d: " #expr "\n", __FILE__, __LINE__); }
     #else
     #define assert(expr)
     #endif
    
    
    
    From bonefish at mail.berlios.de  Mon Sep 24 01:35:21 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Mon, 24 Sep 2007 01:35:21 +0200
    Subject: [Haiku-commits] r22287 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709232335.l8NNZLHp008489@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-24 01:35:20 +0200 (Mon, 24 Sep 2007)
    New Revision: 22287
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22287&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp
    Log:
    Use delete[] for array deletions.
    
    
    Modified: haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp	2007-09-23 23:32:03 UTC (rev 22286)
    +++ haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp	2007-09-23 23:35:20 UTC (rev 22287)
    @@ -511,8 +511,8 @@
     
     	~MyLayoutInfo()
     	{
    -		delete fLocations;
    -		delete fSizes;
    +		delete[] fLocations;
    +		delete[] fSizes;
     	}
     
     	virtual float ElementLocation(int32 element)
    
    
    
    From bonefish at mail.berlios.de  Mon Sep 24 02:04:09 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Mon, 24 Sep 2007 02:04:09 +0200
    Subject: [Haiku-commits] r22288 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709240004.l8O049rZ006115@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-24 02:03:57 +0200 (Mon, 24 Sep 2007)
    New Revision: 22288
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22288&view=rev
    
    Added:
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
       haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp
       haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.h
    Log:
    Implemented a ComplexLayouter class which is going to replace the Layouter
    implementation which used the qoca constraint solver. It does the min/max
    computation itself -- thanks to Peter Moulder for hinting that we're actually
    dealing with separation constraints and proposing an algorithm. The actual
    layout is done with the help of an active set method based optimizer.
    The test results look very good so far. The code needs some cleanup (debug
    output, math comments, special handling for some cases) and is therefore not
    yet enabled by default.
    
    
    Added: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-23 23:35:20 UTC (rev 22287)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-24 00:03:57 UTC (rev 22288)
    @@ -0,0 +1,846 @@
    +/*
    + * Copyright 2007, Ingo Weinhold .
    + * All rights reserved. Distributed under the terms of the MIT License.
    + */
    +
    +#include "ComplexLayouter.h"
    +
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +
    +#include 
    +#include 
    +
    +#include 
    +
    +#include "LayoutOptimizer.h"
    +#include "SimpleLayouter.h"
    +
    +
    +using std::nothrow;
    +
    +
    +// MyLayoutInfo
    +class ComplexLayouter::MyLayoutInfo : public LayoutInfo {
    +public:
    +	MyLayoutInfo(int32 elementCount, int32 spacing)
    +		: fCount(elementCount),
    +		  fSpacing(spacing)
    +	{
    +		// We also store the location of the virtual elementCountth element.
    +		// Thus fLocation[i + 1] - fLocation[i] is the size of the ith element
    +		// (not considering spacing).
    +		fLocations = new(nothrow) int32[elementCount + 1];
    +	}
    +
    +	~MyLayoutInfo()
    +	{
    +		delete[] fLocations;
    +	}
    +
    +	virtual float ElementLocation(int32 element)
    +	{
    +		if (element < 0 || element >= fCount)
    +			return 0;
    +
    +		return fLocations[element];
    +	}
    +
    +	virtual float ElementSize(int32 element)
    +	{
    +		if (element < 0 || element >= fCount)
    +			return -1;
    +
    +		return fLocations[element + 1] - fLocations[element] - 1
    +			- fSpacing;
    +	}
    +
    +	virtual float ElementRangeSize(int32 position, int32 length)
    +	{
    +		if (position < 0 || length < 0 || position + length > fCount)
    +			return -1;
    +
    +		return fLocations[position + length] - fLocations[position] - 1
    +			- fSpacing;
    +	}
    +
    +	void Dump()
    +	{
    +		printf("ComplexLayouter::MyLayoutInfo(): %ld elements:\n", fCount);
    +		for (int32 i = 0; i < fCount + 1; i++)
    +			printf("  %2ld: location: %4ld\n", i, fLocations[i]);
    +	}
    +
    +public:
    +	int32	fCount;
    +	int32	fSpacing;
    +	int32*	fLocations;
    +};
    +
    +
    +// Constraint
    +struct ComplexLayouter::Constraint {
    +	Constraint(int32 start, int32 end, int32 min, int32 max)
    +		: start(start),
    +		  end(end),
    +		  min(min),
    +		  max(max),
    +		  next(NULL)
    +	{
    +		if (min > max)
    +			max = min;
    +		effectiveMax = max;
    +	}
    +
    +	void Restrict(int32 newMin, int32 newMax)
    +	{
    +		if (newMin > min)
    +			min = newMin;
    +		if (newMax < max)
    +			max = newMax;
    +		if (min > max)
    +			max = min;
    +		effectiveMax = max;
    +	}
    +
    +	int32		start;
    +	int32		end;
    +	int32		min;
    +	int32		max;
    +	int32		effectiveMax;
    +	Constraint*	next;
    +};
    +
    +
    +// SumItem
    +struct ComplexLayouter::SumItem {
    +	int32	min;
    +	int32	max;
    +	bool	minDirty;
    +	bool	maxDirty;
    +};
    +
    +
    +// SumItemBackup
    +struct ComplexLayouter::SumItemBackup {
    +	int32	min;
    +	int32	max;
    +};
    +
    +
    +// #pragma mark - ComplexLayouter
    +
    +
    +// constructor
    +ComplexLayouter::ComplexLayouter(int32 elementCount, int32 spacing)
    +	: fElementCount(elementCount),
    +	  fSpacing(spacing),
    +	  fConstraints(new(nothrow) Constraint*[elementCount]),
    +	  fWeights(new(nothrow) float[elementCount]),
    +	  fSums(new(nothrow) SumItem[elementCount + 1]),
    +	  fSumBackups(new(nothrow) SumItemBackup[elementCount + 1]),
    +	  fOptimizer(new(nothrow) LayoutOptimizer(elementCount)),
    +	  fLayoutValid(false)
    +{
    +// TODO: Check initialization!
    +	if (fConstraints)
    +		memset(fConstraints, 0, sizeof(Constraint*) * fElementCount);
    +
    +	if (fWeights) {
    +		for (int32 i = 0; i < fElementCount; i++)
    +			fWeights[i] = 1.0f;
    +	}
    +}
    +
    +
    +// destructor
    +ComplexLayouter::~ComplexLayouter()
    +{
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		Constraint* constraint = fConstraints[i];
    +		fConstraints[i] = NULL;
    +		while (constraint != NULL) {
    +			Constraint* next = constraint->next;
    +			delete constraint;
    +			constraint = next;
    +		}
    +	}
    +
    +	delete[] fConstraints;
    +	delete[] fWeights;
    +	delete[] fSums;
    +	delete[] fSumBackups;
    +  	delete fOptimizer;
    +}
    +
    +
    +// InitCheck
    +status_t
    +ComplexLayouter::InitCheck() const
    +{
    +	if (!fConstraints || !fWeights || !fSums || !fSumBackups || !fOptimizer)
    +		return B_NO_MEMORY;
    +	return fOptimizer->InitCheck();
    +}
    +
    +
    +// AddConstraints
    +void
    +ComplexLayouter::AddConstraints(int32 element, int32 length,
    +	float _min, float _max, float _preferred)
    +{
    +	if (element < 0 || length <= 0 || element + length > fElementCount)
    +		return;
    +
    +//printf("%p->ComplexLayouter::AddConstraints(%ld, %ld, %ld, %ld, %ld)\n",
    +//this, element, length, (int32)_min, (int32)_max, (int32)_preferred);
    +
    +	int32 spacing = fSpacing * (length - 1);
    +	int32 min = (int32)_min + 1 - spacing;
    +	int32 max = (int32)_max + 1 - spacing;
    +
    +	if (min < 0)
    +		min = 0;
    +	if (max > B_SIZE_UNLIMITED)
    +		max = B_SIZE_UNLIMITED;
    +
    +	int32 end = element + length - 1;
    +	Constraint** slot = fConstraints + end;
    +	while (*slot != NULL && (*slot)->start > element)
    +		slot = &(*slot)->next;
    +
    +	if (*slot != NULL && (*slot)->start == element) {
    +		// previous constraint exists -- use stricter values
    +		(*slot)->Restrict(min, max);
    +	} else {
    +		// no previous constraint -- create new one
    +		Constraint* constraint = new(nothrow) Constraint(element, end, min,
    +			max);
    +		if (!constraint)
    +			return;
    +		constraint->next = *slot;
    +		*slot = constraint;
    +	}
    +}
    +
    +
    +// SetWeight
    +void
    +ComplexLayouter::SetWeight(int32 element, float weight)
    +{
    +	if (element < 0 || element >= fElementCount)
    +		return;
    +
    +	fWeights[element] = max_c(weight, 0);
    +}
    +
    +
    +// MinSize
    +float
    +ComplexLayouter::MinSize()
    +{
    +	_ValidateLayout();
    +	return fMin;
    +}
    +
    +
    +// MaxSize
    +float
    +ComplexLayouter::MaxSize()
    +{
    +	_ValidateLayout();
    +	return fMax;
    +}
    +
    +
    +// PreferredSize
    +float
    +ComplexLayouter::PreferredSize()
    +{
    +	return fMin;
    +}
    +
    +
    +// CreateLayoutInfo
    +LayoutInfo*
    +ComplexLayouter::CreateLayoutInfo()
    +{
    +	MyLayoutInfo* layoutInfo = new(nothrow) MyLayoutInfo(fElementCount,
    +		fSpacing);
    +	if (layoutInfo && !layoutInfo->fLocations) {
    +		delete layoutInfo;
    +		return NULL;
    +	}
    +
    +	return layoutInfo;
    +}
    +
    +
    +// Layout
    +void
    +ComplexLayouter::Layout(LayoutInfo* _layoutInfo, float _size)
    +{
    +//printf("%p->ComplexLayouter::Layout(%ld)\n", this, (int32)_size);
    +	if (fElementCount == 0)
    +		return;
    +
    +	_ValidateLayout();
    +
    +	MyLayoutInfo* layoutInfo = (MyLayoutInfo*)_layoutInfo;
    +
    +	int32 min = fSums[fElementCount].min;
    +	int32 max = fSums[fElementCount].max;
    +
    +	int32 size = (int32)_size + 1 - (fElementCount - 1) * fSpacing;
    +	if (size < min)
    +		size = min;
    +	if (size > max)
    +		size = max;
    +
    +	SumItem sums[fElementCount + 1];
    +	memcpy(sums, fSums, (fElementCount + 1) * sizeof(SumItem));
    +
    +	sums[fElementCount].min = size;
    +	sums[fElementCount].max = size;
    +	sums[fElementCount].minDirty = (size != min);
    +	sums[fElementCount].maxDirty = (size != max);
    +
    +	// propagate the size
    +	_PropagateChangesBack(sums, fElementCount - 1, NULL);
    +	_PropagateChanges(sums, fElementCount - 1, NULL);
    +
    +printf("Layout(%ld)\n", size);
    +for (int32 i = 0; i < fElementCount; i++) {
    +SumItem& sum = sums[i + 1];
    +printf("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    +}
    +
    +// TODO: Test whether the desired solution already satisfies all constraints.
    +// If so, we can skip the constraint solving part.
    +
    +
    +// TODO: We should probably already setup the constraints in _ValidateLayout().
    +// This way we might not be able to skip as many redundant constraints, but
    +// supposedly it doesn't matter all that much, since those constraints
    +// wouldn't make it into the active set anyway.
    +	fOptimizer->RemoveAllConstraints();
    +
    +	// add constraints
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = fSums[i + 1];
    +
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			SumItem& base = fSums[constraint->start];
    +			int32 sumMin = base.min + constraint->min;
    +			int32 baseMax = sum.max - constraint->min;
    +			bool minRedundant = (sumMin < sum.min && baseMax > base.max);
    +
    +			int32 sumMax = base.max + constraint->effectiveMax;
    +			int32 baseMin = sum.min - constraint->effectiveMax;
    +			bool maxRedundant = (sumMax > sum.max && baseMin < base.min);
    +
    +			if (!minRedundant || !maxRedundant) {
    +				bool success = true;
    +				if (constraint->min == constraint->effectiveMax) {
    +					// min and max equal -- add an equality constraint
    +					success = fOptimizer->AddConstraint(constraint->start - 1,
    +						constraint->end, constraint->min, true);
    +				} else {
    +					// min and max not equal -- add them individually,
    +					// unless redundant
    +					if (!minRedundant) {
    +						success |= fOptimizer->AddConstraint(
    +							constraint->start - 1, constraint->end,
    +							constraint->min, false);
    +					}
    +					if (!maxRedundant) {
    +						success |= fOptimizer->AddConstraint(constraint->end,
    +							constraint->start - 1,
    +							-constraint->effectiveMax, false);
    +					}
    +				}
    +			}
    +
    +			constraint = constraint->next;
    +		}
    +	}
    +
    +	// prepare a feasible solution (the minimum)
    +	double values[fElementCount];
    +	for (int32 i = 0; i < fElementCount; i++)
    +		values[i] = sums[i + 1].min - sums[i].min;
    +
    +	// prepare the desired solution
    +	int32 sizes[fElementCount];
    +	SimpleLayouter::DistributeSize(size, fWeights, sizes, fElementCount);
    +	double realSizes[fElementCount];
    +	for (int32 i = 0; i < fElementCount; i++)
    +		realSizes[i] = sizes[i];
    +
    +printf("feasible solution vs. desired solution:\n");
    +for (int32 i = 0; i < fElementCount; i++)
    +printf("%8.4f   %8.4f\n", values[i], realSizes[i]);
    +
    +	// solve
    +bigtime_t time = system_time();
    +	if (!fOptimizer->Solve(realSizes, size, values))
    +		return;
    +time = system_time() - time;
    +
    +	// compute integer solution
    +	// The basic strategy is to floor() the sums. This guarantees that the
    +	// difference between two rounded sums remains in the range of floor()
    +	// and ceil() of their real value difference. Since the constraints have
    +	// integer values, the integer solution will satisfy all constraints the
    +	// real solution satisfied.
    +printf("computed solution in %lld us:\n", time);
    +	double realSum = 0;
    +	int32 spacing = 0;
    +	layoutInfo->fLocations[0] = 0;
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		realSum += values[i];
    +		double roundedRealSum = floor(realSum);
    +		if (fuzzy_equals(realSum, roundedRealSum + 1))
    +			realSum = roundedRealSum + 1;
    +		layoutInfo->fLocations[i + 1] = (int32)roundedRealSum + spacing;
    +		spacing += fSpacing;
    +
    +printf("x[%ld] = %8.4f   %4ld\n", i, values[i], layoutInfo->fLocations[i + 1] - layoutInfo->fLocations[i]);
    +	}
    +}
    +
    +
    +// CloneLayouter
    +Layouter*
    +ComplexLayouter::CloneLayouter()
    +{
    +	ComplexLayouter* layouter
    +		= new(nothrow) ComplexLayouter(fElementCount, fSpacing);
    +	ObjectDeleter layouterDeleter(layouter);
    +	if (!layouter || layouter->InitCheck() != B_OK
    +		|| !layouter->fOptimizer->AddConstraintsFrom(fOptimizer)) {
    +		return NULL;
    +	}
    +
    +	// clone the constraints
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		Constraint* constraint = fConstraints[i];
    +		Constraint** end = layouter->fConstraints + i;
    +		while (constraint) {
    +			*end = new(nothrow) Constraint(constraint->start, constraint->end,
    +				constraint->min, constraint->max);
    +			if (!*end)
    +				return NULL;
    +
    +			end = &(*end)->next;
    +			constraint = constraint->next;
    +		}
    +	}
    +
    +	// copy the other stuff
    +	memcpy(layouter->fWeights, fWeights, fElementCount * sizeof(float));
    +	memcpy(layouter->fSums, fSums, (fElementCount + 1) * sizeof(SumItem));
    +	memcpy(layouter->fSumBackups, fSumBackups,
    +		(fElementCount + 1) * sizeof(SumItemBackup));
    +	layouter->fMin = fMin;
    +	layouter->fMax = fMax;
    +	layouter->fLayoutValid = fLayoutValid;
    +
    +	return layouterDeleter.Detach();
    +}
    +
    +
    +// _ValidateLayout
    +void
    +ComplexLayouter::_ValidateLayout()
    +{
    +	if (fLayoutValid)
    +		return;
    +
    +	fSums[0].min = 0;
    +	fSums[0].max = 0;
    +
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = fSums[i + 1];
    +		sum.min = 0;
    +		sum.max = B_SIZE_UNLIMITED;
    +		sum.minDirty = false;
    +		sum.maxDirty = false;
    +	}
    +
    +	// apply min constraints forward:
    +	//   minc[k] >= minc[i-1] + min[i,j]
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = fSums[i + 1];
    +
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			int32 minSum = fSums[constraint->start].min + constraint->min;
    +			if (minSum > sum.min)
    +				sum.min = minSum;
    +else {
    +printf("min constraint is redundant: x%ld + ... + x%ld >= %ld\n",
    +constraint->start, constraint->end, constraint->min);
    +}
    +
    +			constraint = constraint->next;
    +		}
    +	}
    +
    +	// apply min constraints backwards:
    +	//   maxc[i-1] <= maxc[k] - min[i,j]
    +	for (int32 i = fElementCount - 1; i >= 0; i--) {
    +		SumItem& sum = fSums[i + 1];
    +
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			SumItem& base = fSums[constraint->start];
    +			int32 baseMax = sum.max - constraint->min;
    +			if (baseMax < base.max)
    +				base.max = baseMax;
    +
    +			constraint = constraint->next;
    +		}
    +	}
    +
    +	// apply max constraints
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			_ApplyMaxConstraint(constraint, i);
    +
    +			constraint = constraint->next;
    +		}
    +//printf("fSums[%ld] = {%ld, %ld}\n", i + 1, sum.min, sum.max);
    +	}
    +
    +for (int32 i = 0; i < fElementCount; i++) {
    +SumItem& sum = fSums[i + 1];
    +printf("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    +}
    +
    +	if (fElementCount == 0) {
    +		fMin = -1;
    +		fMax = B_SIZE_UNLIMITED;
    +	} else {
    +		int32 spacing = (fElementCount - 1) * fSpacing;
    +		fMin = fSums[fElementCount].min + spacing - 1;
    +		fMax = fSums[fElementCount].max + spacing - 1;
    +	}
    +
    +	fLayoutValid = true;
    +}
    +
    +/*
    +		x[i] + ... + x[i+j] >= min[i,j]
    +		x[i] + ... + x[i+j] <= max[i,j]
    +	with
    +		1 <= i <= n
    +		0 <= j <= n - i
    +		0 <= min[i,j] <= max[i,j]
    +
    +	Let
    +
    +		c[0] = 0
    +		c[k] = x[1] + ... + x[k]	for 1 <= k <= n
    +
    +	it follows
    +
    +		x[i] + ... + x[i+j] = c[i+j] - c[i-1]
    +
    +	and thus the constraints can be rewritten as
    +
    +		c[i+j] - c[i-1] >= min[i,j]
    +		c[i+j] - c[i-1] <= max[i,j]
    +
    +	or	
    +
    +		c[i+j] >= c[i-1] + min[i,j]
    +		c[i+j] <= c[i-1] + max[i,j]
    +
    +	We're looking for minimal minc[] and maximal maxc[] such that
    +
    +		minc[i+j] >= minc[i-1] + min[i,j]
    +		maxc[i+j] <= maxc[i-1] + max[i,j]
    +
    +		minc[i+j] <= minc[i-1] + max[i,j]
    +		maxc[i+j] >= maxc[i-1] + min[i,j]
    +
    +	holds for all i and j. The latter two kinds of constraints have to be
    +	enforced backwards:
    +
    +		minc[i-1] >= minc[i+j] - max[i,j]
    +		maxc[i-1] <= maxc[i+j] - min[i,j]
    +
    +
    +
    +-----------------
    +
    +	// (1) maxc[k] <= maxc[i-1] + max[i,j]
    +	// (2) minc[i-1] >= minc[k] - max[i,j]
    +
    +	Modifying maxc[k] according to (1) potentially invalidates constraints of
    +	these forms:
    +
    +		(i)  maxc[i'-1] <= maxc[k] - min[i',j']
    +		(ii) maxc[k+1+j'] <= maxc[k] + max[k+1,j']
    +
    +	After propagating (i) constraints backwards, all of them will be hold,
    +	though more (ii) constraints might have been invalidated, though.
    +	Propagating (ii) constraints forward afterwards, will make them all hold.
    +	Since the min[i,j] and max[i,j] constraints are separation constraints and
    +	the CSP not including the newly added constraint was conflict-free,
    +	propagating the (i) and (ii) constraints won't change the maxc[i], i < k by
    +	more than what maxc[k] changed. If afterwards the constraint (1) doesn't
    +	hold, it apparently conflicts with the other constraints.
    +*/
    +
    +
    +// _ApplyMaxConstraint
    +void
    +ComplexLayouter::_ApplyMaxConstraint(Constraint* currentConstraint, int32 index)
    +{
    +	SumItem& sum = fSums[index + 1];
    +	SumItem& base = fSums[currentConstraint->start];
    +
    +	// We want to apply:
    +	//   c[i+j] <= c[i-1] + max[i,j]
    +	//
    +	// This has the following direct consequences (let k = i + j):
    +	// (1) maxc[k] <= maxc[i-1] + max[i,j]
    +	// (2) minc[i-1] >= minc[k] - max[i,j]
    +	//
    +	// If maxc[k] or minc[i-i] changed, those changes have to be propagated
    +	// back.
    +
    +	// apply (1) maxc[k] <= maxc[i-1] + max[i,j]
    +	int32 max = currentConstraint->effectiveMax;
    +	int32 sumMax = base.max + max;
    +
    +	// enforce maxc[i+j] >= minc[i+j]
    +	if (sumMax < sum.min) {
    +		sumMax = sum.min;
    +		max = sumMax - base.max;
    +	}
    +
    +	// apply (2) minc[i-1] >= minc[k] - max[i,j]
    +	// and check minc[i-1] <= maxc[i-1]
    +	int32 baseMin = sum.min - max;
    +	if (baseMin > base.max) {
    +		baseMin = base.max;
    +		max = sum.min - baseMin;
    +		sumMax = base.max + max;
    +	}
    +
    +	// apply changes
    +
    +if (currentConstraint->effectiveMax != max) {
    +printf("relaxing conflicting max constraint (1): x%ld + ... + x%ld <= %ld -> %ld\n",
    +currentConstraint->start, currentConstraint->end,
    +currentConstraint->effectiveMax, max);
    +}
    +	currentConstraint->effectiveMax = max;
    +
    +	if (baseMin <= base.min && sumMax >= sum.max)
    +{
    +printf("max constraint is redundant: x%ld + ... + x%ld <= %ld\n",
    +currentConstraint->start, currentConstraint->end, currentConstraint->effectiveMax);
    +		return;
    +}
    +
    +	// backup old values, in case we detect a conflict later
    +	_BackupValues(index);
    +
    +	int32 diff;
    +	do {
    +		// apply the changes
    +		int32 changedIndex = currentConstraint->start;
    +
    +		if (baseMin > base.min) {
    +			base.min = baseMin;
    +			base.minDirty = true;
    +		}
    +
    +		if (sumMax < sum.max) {
    +			changedIndex = index;
    +			sum.max = sumMax;
    +			sum.maxDirty = true;
    +		}
    +
    +		// propagate the changes
    +		_PropagateChangesBack(fSums, changedIndex, currentConstraint);
    +		_PropagateChanges(fSums, index, currentConstraint);
    +
    +		// check the new constraint again -- if it doesn't hold, it
    +		// conflicts with the other constraints
    +		diff = 0;
    +
    +		// check (1) maxc[k] <= maxc[i-1] + max[i,j]
    +		max = currentConstraint->effectiveMax;
    +		sumMax = base.max + max;
    +		if (sumMax < sum.max)
    +			diff = sum.max - sumMax;
    +
    +		// check (2) minc[i-1] >= minc[k] - max[i,j]
    +		baseMin = sum.min - max;
    +		if (baseMin > base.min)
    +			diff = max_c(diff, baseMin - base.min);
    +
    +		// clear the dirty flags
    +		for (int32 i = 0; i <= changedIndex; i++) {
    +			SumItem& sum = fSums[i + 1];
    +			sum.minDirty = false;
    +			sum.maxDirty = false;
    +		}
    +
    +		// if we've got a conflict, we relax the constraint and try again
    +		if (diff > 0) {
    +			max += diff;
    +printf("relaxing conflicting max constraint (2): x%ld + ... + x%ld <= %ld -> %ld\n",
    +currentConstraint->start, currentConstraint->end,
    +currentConstraint->effectiveMax, max);
    +			currentConstraint->effectiveMax = max;
    +
    +			_RestoreValues(index);
    +
    +			sumMax = base.max + max;
    +			baseMin = sum.min - max;
    +
    +			if (baseMin <= base.min && sumMax >= sum.max)
    +				return;
    +		}
    +	} while (diff > 0);
    +}
    +
    +
    +// _PropagateChanges
    +/*!	Propagate changes forward using min and max constraints. Max constraints
    +	Beyond \a toIndex or at \a to toIndex after (and including)
    +	\a lastMaxConstraint will be ignored. To have all constraints be
    +	considered pass \c fElementCount and \c NULL.
    +*/
    +void
    +ComplexLayouter::_PropagateChanges(SumItem* sums, int32 toIndex,
    +	Constraint* lastMaxConstraint)
    +{
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = sums[i + 1];
    +
    +		bool ignoreMaxConstraints = (i > toIndex);
    +
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			SumItem& base = sums[constraint->start];
    +
    +			if (constraint == lastMaxConstraint)
    +				ignoreMaxConstraints = true;
    +
    +			// minc[k] >= minc[i-1] + min[i,j]
    +			if (base.minDirty) {
    +				int32 sumMin = base.min + constraint->min;
    +				if (sumMin > sum.min) {
    +					sum.min = sumMin;
    +					sum.minDirty = true;
    +				}
    +			}
    +
    +			// maxc[k] <= maxc[i-1] + max[i,j]
    +			if (base.maxDirty && !ignoreMaxConstraints) {
    +				int32 sumMax = base.max + constraint->effectiveMax;
    +				if (sumMax < sum.max) {
    +					sum.max = sumMax;
    +					sum.maxDirty = true;
    +				}
    +			}
    +
    +			constraint = constraint->next;
    +		}
    +
    +		if (sum.minDirty || sum.maxDirty) {
    +			if (sum.min > sum.max) {
    +// TODO: Can this actually happen?
    +printf("adjusted max in propagation phase: index: %ld: %ld -> %ld\n", i, sum.max, sum.min);
    +				sum.max = sum.min;
    +				sum.maxDirty = true;
    +			}
    +		}
    +	}
    +}
    +
    +
    +// _PropagateChangesBack
    +void
    +ComplexLayouter::_PropagateChangesBack(SumItem* sums, int32 changedIndex,
    +	Constraint* lastMaxConstraint)
    +{
    +	for (int32 i = changedIndex; i >= 0; i--) {
    +		SumItem& sum = sums[i + 1];
    +
    +		bool ignoreMaxConstraints = false;
    +
    +		Constraint* constraint = fConstraints[i];
    +		while (constraint != NULL) {
    +			SumItem& base = sums[constraint->start];
    +
    +			if (constraint == lastMaxConstraint)
    +				ignoreMaxConstraints = true;
    +
    +			// minc[i-1] >= minc[k] - max[i,j]
    +			if (sum.minDirty && !ignoreMaxConstraints) {
    +				int32 baseMin = sum.min - constraint->effectiveMax;
    +				if (baseMin > base.min) {
    +if (baseMin > base.max) {
    +printf("min above max in back propagation phase: index: (%ld -> %ld), "
    +"min: %ld, max: %ld\n", i, constraint->start, baseMin, base.max);
    +}
    +					base.min = baseMin;
    +					base.minDirty = true;
    +				}
    +			}
    +
    +			// maxc[i-1] <= maxc[k] - min[i,j]
    +			if (sum.maxDirty) {
    +				int32 baseMax = sum.max - constraint->min;
    +				if (baseMax < base.max) {
    +if (baseMax < base.min) {
    +printf("max below min in back propagation phase: index: (%ld -> %ld), "
    +"max: %ld, min: %ld\n", i, constraint->start, baseMax, base.min);
    +}
    +					base.max = baseMax;
    +					base.maxDirty = true;
    +				}
    +			}
    +
    +			constraint = constraint->next;
    +		}
    +	}
    +}
    +
    +
    +// _BackupValues
    +void
    +ComplexLayouter::_BackupValues(int32 maxIndex)
    +{
    +	for (int32 i = 0; i <= maxIndex; i++) {
    +		SumItem& sum = fSums[i + 1];
    +		fSumBackups[i + 1].min = sum.min;
    +		fSumBackups[i + 1].max = sum.max;
    +	}
    +}
    +
    +
    +// _RestoreValues
    +void
    +ComplexLayouter::_RestoreValues(int32 maxIndex)
    +{
    +	for (int32 i = 0; i <= maxIndex; i++) {
    +		SumItem& sum = fSums[i + 1];
    +		sum.min = fSumBackups[i + 1].min;
    +		sum.max = fSumBackups[i + 1].max;
    +	}
    +}
    +
    
    Added: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-23 23:35:20 UTC (rev 22287)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-24 00:03:57 UTC (rev 22288)
    @@ -0,0 +1,78 @@
    +/*
    + * Copyright 2007, Ingo Weinhold .
    + * All rights reserved. Distributed under the terms of the MIT License.
    + */
    +#ifndef COMPLEX_LAYOUTER_H
    +#define COMPLEX_LAYOUTER_H
    +
    +#include 
    +
    +#include "Layouter.h"
    +
    +
    +namespace BPrivate {
    +namespace Layout {
    +
    +class LayoutOptimizer;
    +
    +class ComplexLayouter : public Layouter {
    +public:
    +								ComplexLayouter(int32 elementCount,
    +									int32 spacing);
    +	virtual						~ComplexLayouter();
    +
    +	virtual	status_t			InitCheck() const;
    +
    +	virtual	void				AddConstraints(int32 element, int32 length,
    +									float min, float max, float preferred);
    +	virtual	void				SetWeight(int32 element, float weight);
    +
    +	virtual	float				MinSize();
    +	virtual	float				MaxSize();
    +	virtual	float				PreferredSize();
    +
    +	virtual	LayoutInfo*			CreateLayoutInfo();
    +	
    +	virtual	void				Layout(LayoutInfo* layoutInfo, float size);
    +
    +	virtual	Layouter*			CloneLayouter();
    +
    +private:
    +			class MyLayoutInfo;
    +			struct Constraint;
    +			struct SumItem;
    +			struct SumItemBackup;
    +
    +
    +			void				_ValidateLayout();
    +			void				_ApplyMaxConstraint(
    +									Constraint* currentConstraint, int32 index);
    +			void				_PropagateChanges(SumItem* sums, int32 toIndex,
    +									Constraint* lastMaxConstraint);
    +			void				_PropagateChangesBack(SumItem* sums,
    +									int32 changedIndex,
    +									Constraint* lastMaxConstraint);
    +		
    +			void				_BackupValues(int32 maxIndex);
    +			void				_RestoreValues(int32 maxIndex);
    +
    +private:
    +			int32				fElementCount;
    +			int32				fSpacing;
    +			Constraint**		fConstraints;
    +			float*				fWeights;
    +			SumItem*			fSums;
    +			SumItemBackup*		fSumBackups;
    +			LayoutOptimizer*	fOptimizer;
    +			float				fMin;
    +			float				fMax;
    +			bool				fLayoutValid;
    +};
    +
    +}	// namespace Layout
    +}	// namespace BPrivate
    +
    +using BPrivate::Layout::ComplexLayouter;
    +
    +
    +#endif	// COMPLEX_LAYOUTER_H
    
    Added: haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp	2007-09-23 23:35:20 UTC (rev 22287)
    +++ haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp	2007-09-24 00:03:57 UTC (rev 22288)
    @@ -0,0 +1,982 @@
    +/*
    + * Copyright 2007, Ingo Weinhold .
    + * All rights reserved. Distributed under the terms of the MIT License.
    + */
    +
    +#include "LayoutOptimizer.h"
    +
    +#include 
    +#include 
    +
    +#include 
    +
    +#include 
    +
    +
    +using std::nothrow;
    +
    +
    +// #pragma mark - vector and matrix operations
    +
    +
    +// is_zero
    +static inline bool
    +is_zero(double* x, int n)
    +{
    +	for (int i = 0; i < n; i++) {
    +		if (!fuzzy_equals(x[i], 0))
    +			return false;
    +	}
    +
    +	return true;
    +}
    +
    +
    +// add_vectors
    +static inline void
    +add_vectors(double* x, const double* y, int n)
    +{
    +	for (int i = 0; i < n; i++)
    +		x[i] += y[i];
    +}
    +
    +
    +// add_vectors_scaled
    +static inline void
    +add_vectors_scaled(double* x, const double* y, double scalar, int n)
    +{
    +	for (int i = 0; i < n; i++)
    +		x[i] += y[i] * scalar;
    +}
    +
    +
    +// negate_vector
    +static inline void
    +negate_vector(double* x, int n)
    +{
    +	for (int i = 0; i < n; i++)
    +		x[i] = -x[i];
    +}
    
    [... truncated: 998 lines follow ...]
    
    
    From axeld at mail.berlios.de  Mon Sep 24 11:02:36 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Mon, 24 Sep 2007 11:02:36 +0200
    Subject: [Haiku-commits] r22289 - in haiku/trunk:
    	headers/private/graphics/intel_extreme
    	src/add-ons/accelerants/intel_extreme
    Message-ID: <200709240902.l8O92aPA016627@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-24 11:02:35 +0200 (Mon, 24 Sep 2007)
    New Revision: 22289
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22289&view=rev
    
    Modified:
       haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h
       haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.h
       haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant_protos.h
       haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp
       haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp
    Log:
    * Fixed PLL timing computation for the i9xx chips - I mixed post2 min/max values, and did
      not take the VCO limits into account; both could (and would during testing) create invalid
      frequencies.
    * Also reverted the order in which the PLL divisors are traversed to match the order of what
      is used in the X driver to create comparable output (our error computation is based on float,
      though, and should therefore create more accurate values).
    * The i965 introduced a special register for the surface; the former display base register
      is now only used for the view offset. Instead of setting the base manually here and there,
      there is now a set_frame_buffer_base() function.
    * The DPMS code will now also turn off/on the PLL clock generator.
    * The code needs some more cleanup, and while the driver now produces the correct timing on
      my i965 system, I'm now greeted by a black screen after startup.
    
    
    Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h
    ===================================================================
    --- haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h	2007-09-24 00:03:57 UTC (rev 22288)
    +++ haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h	2007-09-24 09:02:35 UTC (rev 22289)
    @@ -194,6 +194,7 @@
     #define INTEL_DISPLAY_A_CONTROL			0x70180
     #define INTEL_DISPLAY_A_BASE			0x70184
     #define INTEL_DISPLAY_A_BYTES_PER_ROW	0x70188
    +#define INTEL_DISPLAY_A_SURFACE			0x7019c	// i965 and up only
     #define DISPLAY_CONTROL_ENABLED			(1UL << 31)
     #define DISPLAY_CONTROL_GAMMA			(1UL << 30)
     #define DISPLAY_CONTROL_COLOR_MASK		(0x0fUL << 26)
    @@ -238,6 +239,7 @@
     
     #define INTEL_DISPLAY_A_ANALOG_PORT		0x61100
     #define DISPLAY_MONITOR_PORT_ENABLED	(1UL << 31)
    +#define DISPLAY_MONITOR_PIPE_B			(1UL << 30)
     #define DISPLAY_MONITOR_VGA_POLARITY	(1UL << 15)
     #define DISPLAY_MONITOR_MODE_MASK		(3UL << 10)
     #define DISPLAY_MONITOR_ON				0
    @@ -257,6 +259,7 @@
     #define INTEL_DISPLAY_B_CONTROL			0x71180
     #define INTEL_DISPLAY_B_BASE			0x71184
     #define INTEL_DISPLAY_B_BYTES_PER_ROW	0x71188
    +#define INTEL_DISPLAY_B_SURFACE			0x7119c	// i965 and up only
     
     #define INTEL_DISPLAY_B_PALETTE			0x0a800
     
    
    Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.h
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.h	2007-09-24 00:03:57 UTC (rev 22288)
    +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant.h	2007-09-24 09:02:35 UTC (rev 22289)
    @@ -86,6 +86,7 @@
     
     // modes.cpp
     extern void wait_for_vblank(void);
    +extern void set_frame_buffer_base(void);
     extern status_t create_mode_list(void);
     
     // memory.cpp
    
    Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant_protos.h
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant_protos.h	2007-09-24 00:03:57 UTC (rev 22288)
    +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/accelerant_protos.h	2007-09-24 09:02:35 UTC (rev 22289)
    @@ -17,6 +17,8 @@
     extern "C" {
     #endif
     
    +void spin(bigtime_t delay);
    +
     // general
     status_t intel_init_accelerant(int fd);
     ssize_t intel_accelerant_clone_info_size(void);
    
    Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp	2007-09-24 00:03:57 UTC (rev 22288)
    +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/dpms.cpp	2007-09-24 09:02:35 UTC (rev 22289)
    @@ -32,17 +32,18 @@
     			write32(INTEL_DISPLAY_A_CONTROL, planeAControl | DISPLAY_CONTROL_ENABLED);
     		if (gInfo->head_mode & HEAD_MODE_B_DIGITAL)
     			write32(INTEL_DISPLAY_B_CONTROL, planeBControl | DISPLAY_CONTROL_ENABLED);
    +
    +		read32(INTEL_DISPLAY_A_BASE);
    +			// flush the eventually cached PCI bus writes
     	} else {
     		// when disabling it, we have to trigger the update using a write to
     		// the display base address
    -		if (gInfo->head_mode & HEAD_MODE_A_ANALOG) {
    +		if (gInfo->head_mode & HEAD_MODE_A_ANALOG)
     			write32(INTEL_DISPLAY_A_CONTROL, planeAControl & ~DISPLAY_CONTROL_ENABLED);
    -			write32(INTEL_DISPLAY_A_BASE, gInfo->shared_info->frame_buffer_offset);
    -		}
    -		if (gInfo->head_mode & HEAD_MODE_B_DIGITAL) {
    +		if (gInfo->head_mode & HEAD_MODE_B_DIGITAL)
     			write32(INTEL_DISPLAY_B_CONTROL, planeBControl & ~DISPLAY_CONTROL_ENABLED);
    -			write32(INTEL_DISPLAY_B_BASE, gInfo->shared_info->frame_buffer_offset);
    -		}
    +
    +		set_frame_buffer_base();
     	}
     }
     
    @@ -64,6 +65,9 @@
     		if (gInfo->head_mode & HEAD_MODE_B_DIGITAL)
     			write32(INTEL_DISPLAY_B_PIPE_CONTROL, pipeBControl & ~DISPLAY_PIPE_ENABLED);
     	}
    +
    +	read32(INTEL_DISPLAY_A_BASE);
    +		// flush the eventually cached PCI bus writes
     }
     
     
    @@ -73,6 +77,20 @@
     	uint32 monitorMode = 0;
     
     	if (mode == B_DPMS_ON) {
    +		uint32 pll = read32(INTEL_DISPLAY_A_PLL);
    +		if ((pll & DISPLAY_PLL_ENABLED) == 0) {
    +			// reactivate PLL
    +			write32(INTEL_DISPLAY_A_PLL, pll);
    +			read32(INTEL_DISPLAY_A_PLL);
    +			spin(150);
    +			write32(INTEL_DISPLAY_A_PLL, pll | DISPLAY_PLL_ENABLED);
    +			read32(INTEL_DISPLAY_A_PLL);
    +			spin(150);
    +			write32(INTEL_DISPLAY_A_PLL, pll | DISPLAY_PLL_ENABLED);
    +			read32(INTEL_DISPLAY_A_PLL);
    +			spin(150);
    +		}
    +
     		enable_display_pipe(true);
     		enable_display_plane(true);
     	}
    @@ -107,9 +125,16 @@
     
     	if (mode != B_DPMS_ON) {
     		enable_display_plane(false);
    +		wait_for_vblank();
     		enable_display_pipe(false);
     	}
     
    +	if (mode == B_DPMS_OFF) {
    +		write32(INTEL_DISPLAY_A_PLL, read32(INTEL_DISPLAY_A_PLL) | DISPLAY_PLL_ENABLED);
    +		read32(INTEL_DISPLAY_A_PLL);
    +		spin(150);
    +	}
    +
     	read32(INTEL_DISPLAY_A_BASE);
     		// flush the eventually cached PCI bus writes
     }
    
    Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp	2007-09-24 00:03:57 UTC (rev 22288)
    +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp	2007-09-24 09:02:35 UTC (rev 22289)
    @@ -68,7 +68,9 @@
     struct pll_limits {
     	pll_divisors	min;
     	pll_divisors	max;
    -	float			min_post2_frequency;
    +	uint32			min_post2_frequency;
    +	uint32			min_vco;
    +	uint32			max_vco;
     };
     
     static const display_mode kBaseModeList[] = {
    @@ -156,6 +158,37 @@
     }
     
     
    +void
    +set_frame_buffer_base()
    +{
    +	intel_shared_info &sharedInfo = *gInfo->shared_info;
    +	display_mode &mode = sharedInfo.current_mode;
    +	uint32 baseRegister;
    +	uint32 surfaceRegister;
    +
    +	if (gInfo->head_mode & HEAD_MODE_A_ANALOG) {
    +		baseRegister = INTEL_DISPLAY_A_BASE;
    +		surfaceRegister = INTEL_DISPLAY_A_SURFACE;
    +	} else {
    +		baseRegister = INTEL_DISPLAY_B_BASE;
    +		surfaceRegister = INTEL_DISPLAY_B_SURFACE;
    +	}
    +
    +	if (sharedInfo.device_type == (INTEL_TYPE_9xx | INTEL_TYPE_965)) {
    +		write32(baseRegister, mode.v_display_start * sharedInfo.bytes_per_row
    +			+ mode.h_display_start * (sharedInfo.bits_per_pixel + 7) / 8);
    +		read32(baseRegister);
    +		write32(surfaceRegister, sharedInfo.frame_buffer_offset);
    +		read32(surfaceRegister);
    +	} else {
    +		write32(baseRegister, sharedInfo.frame_buffer_offset
    +			+ mode.v_display_start * sharedInfo.bytes_per_row
    +			+ mode.h_display_start * (sharedInfo.bits_per_pixel + 7) / 8);
    +		read32(baseRegister);
    +	}
    +}
    +
    +
     /*!
     	Creates the initial mode list of the primary accelerant.
     	It's called from intel_init_accelerant().
    @@ -227,18 +260,18 @@
     		// TODO: support LVDS output limits as well
     		static const pll_limits kLimits = {
     			// p, p1, p2, high,   n,   m, m1, m2
    -			{  5,  1,  5, false,  5,  70, 12,  7},	// min
    -			{ 80,  8, 10, true,  10, 120, 22, 11},	// max
    -			200000
    +			{  5,  1, 10, false,  5,  70, 12,  7},	// min
    +			{ 80,  8,  5, true,  10, 120, 22, 11},	// max
    +			200000, 1400000, 2800000
     		};
     		limits = kLimits;
     	} else {
     		// TODO: support LVDS output limits as well
     		static const pll_limits kLimits = {
     			// p, p1, p2, high,   n,   m, m1, m2
    -			{  4,  2,  2, false,  5,  96, 20,  8},
    -			{128, 33,  4, true,  18, 140, 28, 18},
    -			165000
    +			{  4,  2,  4, false,  5,  96, 20,  8},
    +			{128, 33,  2, true,  18, 140, 28, 18},
    +			165000, 930000, 1400000
     		};
     		limits = kLimits;
     	}
    @@ -261,6 +294,7 @@
     
     	if (divisors.post < limits.min.post || divisors.post > limits.max.post
     		|| divisors.m < limits.min.m || divisors.m > limits.max.m
    +		|| vco < limits.min_vco || vco > limits.max_vco
     		|| frequency < info.min_frequency || frequency > info.max_frequency)
     		return false;
     
    @@ -279,9 +313,11 @@
     	TRACE(("required MHz: %g\n", requestedPixelClock));
     
     	if (current.timing.pixel_clock < limits.min_post2_frequency) {
    +		// slow DAC timing
     	    divisors.post2 = limits.min.post2;
     	    divisors.post2_high = limits.min.post2_high;
     	} else {
    +		// fast DAC timing
     	    divisors.post2 = limits.max.post2;
     	    divisors.post2_high = limits.max.post2_high;
     	}
    @@ -289,13 +325,13 @@
     	float best = requestedPixelClock;
     	pll_divisors bestDivisors;
     
    -	for (divisors.post1 = limits.min.post1; divisors.post1 <= limits.max.post1;
    -			divisors.post1++) {
    -		for (divisors.n = limits.min.n; divisors.n <= limits.max.n; divisors.n++) {
    -			for (divisors.m1 = limits.min.m1; divisors.m1 <= limits.max.m1;
    -					divisors.m1++) {
    -				for (divisors.m2 = limits.min.m2; divisors.m2 < divisors.m1
    -						&& divisors.m2 <= limits.max.m2; divisors.m2++) {
    +	for (divisors.m1 = limits.min.m1; divisors.m1 <= limits.max.m1; divisors.m1++) {
    +		for (divisors.m2 = limits.min.m2; divisors.m2 < divisors.m1
    +				&& divisors.m2 <= limits.max.m2; divisors.m2++) {
    +			for (divisors.n = limits.min.n; divisors.n <= limits.max.n;
    +					divisors.n++) {
    +				for (divisors.post1 = limits.min.post1;
    +						divisors.post1 <= limits.max.post1; divisors.post1++) {
     					divisors.m = 5 * divisors.m1 + divisors.m2;
     					divisors.post = divisors.post1 * divisors.post2;
     
    @@ -455,7 +491,7 @@
     				* sharedInfo.bytes_per_row, gInfo->frame_buffer_handle,
     				offset) == B_OK) {
     			sharedInfo.frame_buffer_offset = offset;
    -			write32(INTEL_DISPLAY_A_BASE, offset);
    +			set_frame_buffer_base();
     		}
     
     		return B_NO_MEMORY;
    @@ -464,33 +500,13 @@
     	sharedInfo.frame_buffer_offset = offset;
     
     	// make sure VGA display is disabled
    -	write32(INTEL_VGA_DISPLAY_CONTROL, read32(INTEL_VGA_DISPLAY_CONTROL)
    -		| VGA_DISPLAY_DISABLED);
    +	write32(INTEL_VGA_DISPLAY_CONTROL, VGA_DISPLAY_DISABLED);
    +	read32(INTEL_VGA_DISPLAY_CONTROL);
     
    +	if (gInfo->shared_info->device_type != (INTEL_TYPE_8xx | INTEL_TYPE_85x)) {
    +	}
    +
     	if (gInfo->head_mode & HEAD_MODE_A_ANALOG) {
    -		// update timing parameters
    -		write32(INTEL_DISPLAY_A_HTOTAL, ((uint32)(target.timing.h_total - 1) << 16)
    -			| ((uint32)target.timing.h_display - 1));
    -		write32(INTEL_DISPLAY_A_HBLANK, ((uint32)(target.timing.h_total - 1) << 16)
    -			| ((uint32)target.timing.h_display - 1));
    -		write32(INTEL_DISPLAY_A_HSYNC, ((uint32)(target.timing.h_sync_end - 1) << 16)
    -			| ((uint32)target.timing.h_sync_start - 1));
    -
    -		write32(INTEL_DISPLAY_A_VTOTAL, ((uint32)(target.timing.v_total - 1) << 16)
    -			| ((uint32)target.timing.v_display - 1));
    -		write32(INTEL_DISPLAY_A_VBLANK, ((uint32)(target.timing.v_total - 1) << 16)
    -			| ((uint32)target.timing.v_display - 1));
    -		write32(INTEL_DISPLAY_A_VSYNC, ((uint32)(target.timing.v_sync_end - 1) << 16)
    -			| ((uint32)target.timing.v_sync_start - 1));
    -
    -		write32(INTEL_DISPLAY_A_IMAGE_SIZE, ((uint32)(target.timing.h_display - 1) << 16)
    -			| ((uint32)target.timing.v_display - 1));
    -
    -		write32(INTEL_DISPLAY_A_ANALOG_PORT, (read32(INTEL_DISPLAY_A_ANALOG_PORT)
    -			& ~(DISPLAY_MONITOR_POLARITY_MASK | DISPLAY_MONITOR_VGA_POLARITY))
    -			| ((target.timing.flags & B_POSITIVE_HSYNC) != 0 ? DISPLAY_MONITOR_POSITIVE_HSYNC : 0)
    -			| ((target.timing.flags & B_POSITIVE_VSYNC) != 0 ? DISPLAY_MONITOR_POSITIVE_VSYNC : 0));
    -
     		pll_divisors divisors;
     		compute_pll_divisors(target, divisors);
     
    @@ -527,12 +543,39 @@
     
     		debug_printf("PLL is %#lx, write: %#lx\n", read32(INTEL_DISPLAY_A_PLL), pll);
     		write32(INTEL_DISPLAY_A_PLL, pll);
    +		read32(INTEL_DISPLAY_A_PLL);
    +		spin(150);
    +		write32(INTEL_DISPLAY_A_PLL, pll);
    +		read32(INTEL_DISPLAY_A_PLL);
    +		spin(150);
     #if 0
     		write32(INTEL_DISPLAY_A_PLL, DISPLAY_PLL_ENABLED | DISPLAY_PLL_2X_CLOCK
     			| DISPLAY_PLL_NO_VGA_CONTROL | DISPLAY_PLL_DIVIDE_4X
     			| (((divisors.post1 - 2) << DISPLAY_PLL_POST1_DIVISOR_SHIFT) & DISPLAY_PLL_POST1_DIVISOR_MASK)
     			| (divisorRegister == INTEL_DISPLAY_A_PLL_DIVISOR_1 ? DISPLAY_PLL_DIVISOR_1 : 0));
     #endif
    +		// update timing parameters
    +		write32(INTEL_DISPLAY_A_HTOTAL, ((uint32)(target.timing.h_total - 1) << 16)
    +			| ((uint32)target.timing.h_display - 1));
    +		write32(INTEL_DISPLAY_A_HBLANK, ((uint32)(target.timing.h_total - 1) << 16)
    +			| ((uint32)target.timing.h_display - 1));
    +		write32(INTEL_DISPLAY_A_HSYNC, ((uint32)(target.timing.h_sync_end - 1) << 16)
    +			| ((uint32)target.timing.h_sync_start - 1));
    +
    +		write32(INTEL_DISPLAY_A_VTOTAL, ((uint32)(target.timing.v_total - 1) << 16)
    +			| ((uint32)target.timing.v_display - 1));
    +		write32(INTEL_DISPLAY_A_VBLANK, ((uint32)(target.timing.v_total - 1) << 16)
    +			| ((uint32)target.timing.v_display - 1));
    +		write32(INTEL_DISPLAY_A_VSYNC, ((uint32)(target.timing.v_sync_end - 1) << 16)
    +			| ((uint32)target.timing.v_sync_start - 1));
    +
    +		write32(INTEL_DISPLAY_A_IMAGE_SIZE, ((uint32)(target.timing.h_display - 1) << 16)
    +			| ((uint32)target.timing.v_display - 1));
    +
    +		write32(INTEL_DISPLAY_A_ANALOG_PORT, (read32(INTEL_DISPLAY_A_ANALOG_PORT)
    +			& ~(DISPLAY_MONITOR_POLARITY_MASK | DISPLAY_MONITOR_VGA_POLARITY))
    +			| ((target.timing.flags & B_POSITIVE_HSYNC) != 0 ? DISPLAY_MONITOR_POSITIVE_HSYNC : 0)
    +			| ((target.timing.flags & B_POSITIVE_VSYNC) != 0 ? DISPLAY_MONITOR_POSITIVE_VSYNC : 0));
     	}
     
     	// These two have to be set for display B, too - this obviously means
    @@ -553,17 +596,14 @@
     
     	// changing bytes per row seems to be ignored if the plane/pipe is turned off
     
    -	if (gInfo->head_mode & HEAD_MODE_A_ANALOG) {
    +	if (gInfo->head_mode & HEAD_MODE_A_ANALOG)
     		write32(INTEL_DISPLAY_A_BYTES_PER_ROW, bytesPerRow);
    -		write32(INTEL_DISPLAY_A_BASE, sharedInfo.frame_buffer_offset);
    -			// triggers writing back double-buffered registers
    -	}
    -	if (gInfo->head_mode & HEAD_MODE_B_DIGITAL) {
    +	if (gInfo->head_mode & HEAD_MODE_B_DIGITAL)
     		write32(INTEL_DISPLAY_B_BYTES_PER_ROW, bytesPerRow);
    -		write32(INTEL_DISPLAY_B_BASE, sharedInfo.frame_buffer_offset);
    -			// triggers writing back double-buffered registers
    -	}
     
    +	set_frame_buffer_base();
    +		// triggers writing back double-buffered registers
    +
     	// update shared info
     	sharedInfo.bytes_per_row = bytesPerRow;
     	sharedInfo.current_mode = target;
    @@ -727,16 +767,7 @@
     	mode.h_display_start = horizontalStart;
     	mode.v_display_start = verticalStart;
     
    -	if (gInfo->head_mode & HEAD_MODE_A_ANALOG) {
    -		write32(INTEL_DISPLAY_A_BASE, sharedInfo.frame_buffer_offset
    -			+ verticalStart * sharedInfo.bytes_per_row
    -			+ horizontalStart * (sharedInfo.bits_per_pixel + 7) / 8);
    -	}
    -	if (gInfo->head_mode & HEAD_MODE_B_DIGITAL) {
    -		write32(INTEL_DISPLAY_B_BASE, sharedInfo.frame_buffer_offset
    -			+ verticalStart * sharedInfo.bytes_per_row
    -			+ horizontalStart * (sharedInfo.bits_per_pixel + 7) / 8);
    -	}
    +	set_frame_buffer_base();
     
     	return B_OK;
     }
    
    
    
    From rudolfc at mail.berlios.de  Mon Sep 24 16:11:54 2007
    From: rudolfc at mail.berlios.de (rudolfc at BerliOS)
    Date: Mon, 24 Sep 2007 16:11:54 +0200
    Subject: [Haiku-commits] r22290 -
    	haiku/trunk/src/add-ons/accelerants/nvidia/engine
    Message-ID: <200709241411.l8OEBs2r022664@sheep.berlios.de>
    
    Author: rudolfc
    Date: 2007-09-24 16:11:53 +0200 (Mon, 24 Sep 2007)
    New Revision: 22290
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22290&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_acc_dma.c
    Log:
    added engine command fifo setup for TCL_PRIMITIVE_3D for NV15 only for now (testing). Over here the NV15 keeps running and the command seems responsive. I hope this doesn't crash other NV15's outthere.
    
    Modified: haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_acc_dma.c
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_acc_dma.c	2007-09-24 09:02:35 UTC (rev 22289)
    +++ haiku/trunk/src/add-ons/accelerants/nvidia/engine/nv_acc_dma.c	2007-09-24 14:11:53 UTC (rev 22290)
    @@ -1,7 +1,7 @@
     /* NV Acceleration functions */
     
     /* Author:
    -   Rudolf Cornelissen 8/2003-4/2006.
    +   Rudolf Cornelissen 8/2003-9/2007.
     
        This code was possible thanks to:
         - the Linux XFree86 NV driver,
    @@ -269,6 +269,14 @@
     
     		ACCW(HT_HANDL_13, (0x80000000 | NV_SCALED_IMAGE_FROM_MEMORY)); /* 32bit handle */
     		ACCW(HT_VALUE_13, 0x8001114b); /* instance $114b, engine = acc engine, CHID = $00 */
    +
    +		//2007 3D tests..
    +		if (si->ps.card_type == NV15)
    +		{
    +			ACCW(HT_HANDL_14, (0x80000000 | NV_TCL_PRIMITIVE_3D)); /* 32bit handle */
    +			ACCW(HT_VALUE_14, 0x8001114d); /* instance $114d, engine = acc engine, CHID = $00 */
    +		}
    +
     	}
     
     	/* program CTX registers: CTX1 is mostly done later (colorspace dependant) */
    @@ -468,23 +476,34 @@
     		ACCW(PR_CTX1_A, 0x00000000); /* colorspace not set, notify instance invalid (b16-31) */
     		ACCW(PR_CTX2_A, 0x11401140); /* DMA0, DMA1 instance = $1140 */
     		ACCW(PR_CTX3_A, 0x00000000); /* method traps disabled */
    +		//2007 3D tests..
    +		/* setup set 'B' ... */
    +		if (si->ps.card_type == NV15)
    +		{
    +			/* ... for cmd NV11_TCL_PRIMITIVE_3D */
    +			ACCW(PR_CTX0_B, 0x0300a096); /* NVclass $096, patchcfg ROP_AND, userclip enable,
    +										  * context surface0 valid, nv10+: little endian */
    +			ACCW(PR_CTX1_B, 0x00000000); /* colorspace not set, notify instance invalid (b16-31) */
    +			ACCW(PR_CTX2_B, 0x11401140); /* DMA0, DMA1 instance = $1140 */
    +			ACCW(PR_CTX3_B, 0x00000000); /* method traps disabled */
    +		}
     		/* setup DMA set pointed at by PF_CACH1_DMAI */
     		if (si->engine.agp_mode)
     		{
     			/* DMA page table present and of linear type;
     			 * DMA class is $002 (b0-11);
     			 * DMA target node is AGP */
    -			ACCW(PR_CTX0_B, 0x00033002);
    +			ACCW(PR_CTX0_C, 0x00033002);
     		}
     		else
     		{
     			/* DMA page table present and of linear type;
     			 * DMA class is $002 (b0-11);
     			 * DMA target node is PCI */
    -			ACCW(PR_CTX0_B, 0x00023002);
    +			ACCW(PR_CTX0_C, 0x00023002);
     		}
    -		ACCW(PR_CTX1_B, 0x000fffff); /* DMA limit: tablesize is 1M bytes */
    -		ACCW(PR_CTX2_B, (((uint32)((uint8 *)(si->dma_buffer_pci))) | 0x00000002));
    +		ACCW(PR_CTX1_C, 0x000fffff); /* DMA limit: tablesize is 1M bytes */
    +		ACCW(PR_CTX2_C, (((uint32)((uint8 *)(si->dma_buffer_pci))) | 0x00000002));
     									 /* DMA access type is READ_AND_WRITE;
     									  * table is located in main system RAM (b12-31):
     									  * It's adress needs to be at a 4kb boundary! */
    @@ -935,7 +954,8 @@
     	if (si->ps.card_arch >= NV40A)
     		ACCW(PF_CACH1_DMAI, 0x00001150);
     	else
    -		ACCW(PF_CACH1_DMAI, 0x0000114d);
    +		//2007 3d test..
    +		ACCW(PF_CACH1_DMAI, 0x0000114e);
     	/* cache0 push0 access disabled */
     	ACCW(PF_CACH0_PSH0, 0x00000000);
     	/* cache0 pull0 access disabled */
    
    
    
    From rudolfc at mail.berlios.de  Mon Sep 24 16:12:19 2007
    From: rudolfc at mail.berlios.de (rudolfc at BerliOS)
    Date: Mon, 24 Sep 2007 16:12:19 +0200
    Subject: [Haiku-commits] r22291 - haiku/trunk/headers/private/graphics/nvidia
    Message-ID: <200709241412.l8OECJVj022703@sheep.berlios.de>
    
    Author: rudolfc
    Date: 2007-09-24 16:12:18 +0200 (Mon, 24 Sep 2007)
    New Revision: 22291
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22291&view=rev
    
    Modified:
       haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h
    Log:
    added engine command fifo setup for TCL_PRIMITIVE_3D for NV15 only for now (testing). Over here the NV15 keeps running and the command seems responsive. I hope this doesn't crash other NV15's outthere.
    
    Modified: haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h
    ===================================================================
    --- haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h	2007-09-24 14:11:53 UTC (rev 22290)
    +++ haiku/trunk/headers/private/graphics/nvidia/DriverInterface.h	2007-09-24 14:12:18 UTC (rev 22291)
    @@ -147,6 +147,7 @@
     #define NV_IMAGE_BLACK_RECTANGLE		0x00000001 /* 2D/3D */
     #define NV_IMAGE_PATTERN				0x00000002 /* 2D */
     #define NV_SCALED_IMAGE_FROM_MEMORY		0x00000003 /* 2D */
    +#define NV_TCL_PRIMITIVE_3D				0x00000004 /* 3D */ //2007
     #define NV4_SURFACE						0x00000010 /* 2D */
     #define NV10_CONTEXT_SURFACES_2D		0x00000010 /* 2D */
     #define NV_IMAGE_BLIT					0x00000011 /* 2D */
    
    
    
    From marcusoverhagen at mail.berlios.de  Mon Sep 24 21:08:22 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Mon, 24 Sep 2007 21:08:22 +0200
    Subject: [Haiku-commits] r22292 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709241908.l8OJ8M6d023932@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-24 21:08:22 +0200 (Mon, 24 Sep 2007)
    New Revision: 22292
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22292&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    Log:
    fixed wrong port definition
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-24 14:12:18 UTC (rev 22291)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-24 19:08:22 UTC (rev 22292)
    @@ -87,7 +87,7 @@
     	uint32		sntf;			// SNotification
     	uint32		res2;			// Reserved for FIS-based Switching Definition
     	uint32		res[11];		// Reserved
    -	uint32		vendor[2];		// Vendor Specific
    +	uint32		vendor[4];		// Vendor Specific
     } _PACKED ahci_port;
     
     
    @@ -95,6 +95,7 @@
     	PORT_CMD_ICC_ACTIVE	 = (1 << 28),	// Interface Communication control
     	PORT_CMD_ICC_SLUMBER = (6 << 28),	// Interface Communication control
     	PORT_CMD_ICC_MASK    = (0xf<<28),	// Interface Communication control
    +	PORT_CMD_ATAPI	= (1 << 24),	// Device is ATAPI
     	PORT_CMD_CR		= (1 << 15),	// Command List Running (DMA active)
     	PORT_CMD_FR		= (1 << 14),	// FIS Receive Running
     	PORT_CMD_FER	= (1 << 4),		// FIS Receive Enable
    @@ -130,7 +131,13 @@
     #define PORT_INT_MASK	(PORT_INT_FATAL | PORT_INT_ERROR | PORT_INT_DP |\
     						 PORT_INT_SDB | PORT_INT_DS | PORT_INT_PS | PORT_INT_DHR)
     
    +enum {
    +	ATA_BUSY 		= 0x80,
    +	ATA_DRQ			= 0x08,
    +	ATA_ERR			= 0x01,
    +};
     
    +
     typedef struct {
     	uint32		cap;			// Host Capabilities
     	uint32		ghc;			// Global Host Control
    @@ -224,6 +231,32 @@
     	return count;
     }
     
    +inline
    +status_t
    +wait_until_set(volatile uint32 *reg, uint32 bits, bigtime_t timeout)
    +{
    +	int trys = (timeout + 9999) / 10000;
    +	while (trys--) {
    +		if ((*reg & bits) == bits)
    +			return B_OK;
    +		snooze(10000);
    +	}
    +	return B_TIMED_OUT;
    +}
    +
    +inline
    +status_t
    +wait_until_clear(volatile uint32 *reg, uint32 bits, bigtime_t timeout)
    +{
    +	int trys = (timeout + 9999) / 10000;
    +	while (trys--) {
    +		if ((*reg & bits) == 0)
    +			return B_OK;
    +		snooze(10000);
    +	}
    +	return B_TIMED_OUT;
    +}
    +
     #endif	/* __cplusplus */
     
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Mon Sep 24 23:32:32 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Mon, 24 Sep 2007 23:32:32 +0200
    Subject: [Haiku-commits] r22293 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709242132.l8OLWWb5001270@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-24 23:32:32 +0200 (Mon, 24 Sep 2007)
    New Revision: 22293
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22293&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    perform port reset and wait for devices to be detected
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-24 19:08:22 UTC (rev 22292)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-24 21:32:32 UTC (rev 22293)
    @@ -28,8 +28,8 @@
     {
     	memset(fPort, 0, sizeof(fPort));
     
    -	ASSERT(sizeof(ahci_port) == 120);
    -	ASSERT(sizeof(ahci_hba) == 4096);
    +	ASSERT(sizeof(ahci_port) == 128);
    +	ASSERT(sizeof(ahci_hba) == 4352);
     	ASSERT(sizeof(fis) == 256);
     	ASSERT(sizeof(command_list_entry) == 32);
     	ASSERT(sizeof(command_table) == 128);
    @@ -144,20 +144,32 @@
     				TRACE("out of memory creating port %d", i);
     				break;
     			}
    -			status_t status = fPort[i]->Init();
    +			status_t status = fPort[i]->Init1();
     			if (status < B_OK) {
    -				TRACE("init port %d failed", i);
    +				TRACE("init-1 port %d failed", i);
     				delete fPort[i];
     				fPort[i] = NULL;
    -				break;
     			}
     		}
     	}
     
     	// enable interrupts
     	fRegs->ghc |= GHC_IE;
    -	RegsFlush();
    +	FlushPostedWrites();
     
    +	for (int i = 0; i <= fPortCountMax; i++) {
    +		if (fPort[i]) {
    +			status_t status = fPort[i]->Init2();
    +			if (status < B_OK) {
    +				TRACE("init-2 port %d failed", i);
    +				fPort[i]->Uninit();
    +				delete fPort[i];
    +				fPort[i] = NULL;
    +			}
    +		}
    +	}
    +
    +
     	return B_OK;
     
     err:
    @@ -180,11 +192,11 @@
     
     	// disable interrupts
     	fRegs->ghc &= ~GHC_IE;
    -	RegsFlush();
    +	FlushPostedWrites();
     
     	// clear pending interrupts
     	fRegs->is = 0xffffffff;
    -	RegsFlush();
    +	FlushPostedWrites();
     
       	// well...
       	remove_io_interrupt_handler(fIRQ, Interrupt, this);
    @@ -204,8 +216,9 @@
     	uint32 saveCaps = fRegs->cap & (CAP_SMPS | CAP_SSS | CAP_SPM | CAP_EMS | CAP_SXS);
     	uint32 savePI = fRegs->pi;
     	
    +#if 1
     	fRegs->ghc |= GHC_HR;
    -	RegsFlush();
    +	FlushPostedWrites();
     	for (int i = 0; i < 20; i++) {
     		snooze(50000);
     		if ((fRegs->ghc & GHC_HR) == 0)
    @@ -213,12 +226,17 @@
     	}
     	if (fRegs->ghc & GHC_HR)
     		return B_TIMED_OUT;
    +#else
    +	fRegs->ghc &= ~GHC_AE;
    +	fRegs->is = 0xffffffff;
    +	FlushPostedWrites();
    +#endif
     
     	fRegs->ghc |= GHC_AE;
    -	RegsFlush();
    +	FlushPostedWrites();
     	fRegs->cap |= saveCaps;
     	fRegs->pi = savePI;
    -	RegsFlush();
    +	FlushPostedWrites();
     
     	if (fPCIVendorID == 0x8086) {
     		// Intel PCS?Port Control and Status
    @@ -264,7 +282,7 @@
     		return;
     	}
     
    -	fPort[request->target_id]->ExecuteRequest(request);
    +	fPort[request->target_id]->ScsiExecuteRequest(request);
     }
     
     
    @@ -274,7 +292,7 @@
     	if (request->target_lun || !fPort[request->target_id])
     		return SCSI_DEV_NOT_THERE;
     
    -	return fPort[request->target_id]->AbortRequest(request);
    +	return fPort[request->target_id]->ScsiAbortRequest(request);
     }
     
     
    @@ -284,7 +302,7 @@
     	if (request->target_lun || !fPort[request->target_id])
     		return SCSI_DEV_NOT_THERE;
     
    -	return fPort[request->target_id]->TerminateRequest(request);
    +	return fPort[request->target_id]->ScsiTerminateRequest(request);
     }
     
     
    @@ -294,6 +312,6 @@
     	if (targetLUN || !fPort[targetID])
     		return SCSI_DEV_NOT_THERE;
     
    -	return fPort[targetID]->ResetDevice();
    +	return fPort[targetID]->ScsiResetDevice();
     }
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h	2007-09-24 19:08:22 UTC (rev 22292)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.h	2007-09-24 21:32:32 UTC (rev 22293)
    @@ -29,7 +29,7 @@
     private:
     	bool		IsDevicePresent(uint device);
     	status_t	ResetController();
    -	void		RegsFlush();
    +	void		FlushPostedWrites();
     
     static int32	Interrupt(void *data);
     
    @@ -58,7 +58,7 @@
     
     
     inline void
    -AHCIController::RegsFlush()
    +AHCIController::FlushPostedWrites()
     {
     	volatile uint32 dummy = fRegs->ghc;
     	dummy = dummy;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-24 19:08:22 UTC (rev 22292)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-24 21:32:32 UTC (rev 22293)
    @@ -132,7 +132,7 @@
     						 PORT_INT_SDB | PORT_INT_DS | PORT_INT_PS | PORT_INT_DHR)
     
     enum {
    -	ATA_BUSY 		= 0x80,
    +	ATA_BSY 		= 0x80,
     	ATA_DRQ			= 0x08,
     	ATA_ERR			= 0x01,
     };
    @@ -237,7 +237,7 @@
     {
     	int trys = (timeout + 9999) / 10000;
     	while (trys--) {
    -		if ((*reg & bits) == bits)
    +		if (((*reg) & bits) == bits)
     			return B_OK;
     		snooze(10000);
     	}
    @@ -250,7 +250,7 @@
     {
     	int trys = (timeout + 9999) / 10000;
     	while (trys--) {
    -		if ((*reg & bits) == 0)
    +		if (((*reg) & bits) == 0)
     			return B_OK;
     		snooze(10000);
     	}
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 19:08:22 UTC (rev 22292)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 21:32:32 UTC (rev 22293)
    @@ -29,9 +29,9 @@
     
     	
     status_t
    -AHCIPort::Init()
    +AHCIPort::Init1()
     {
    -	TRACE("AHCIPort::Init port %d\n", fIndex);
    +	TRACE("AHCIPort::Init1 port %d\n", fIndex);
     
     	size_t size = sizeof(command_list_entry) * COMMAND_LIST_ENTRY_COUNT + sizeof(fis) + sizeof(command_table) + sizeof(prd) * PRD_TABLE_ENTRY_COUNT;
     
    @@ -67,7 +67,8 @@
     	fRegs->is = fRegs->is;
     
     	// clear error bits
    -	fRegs->serr = fRegs->serr;
    +//	fRegs->serr = fRegs->serr;
    +	fRegs->serr = 0xffffffff;
     
     	// spin up device
     	fRegs->cmd |= PORT_CMD_SUD;
    @@ -78,12 +79,39 @@
     	// enable FIS receive
     	fRegs->cmd |= PORT_CMD_FER;
     
    +	FlushPostedWrites();
    +
    +	return B_OK;
    +}
    +
    +
    +// called with global interrupts enabled
    +status_t
    +AHCIPort::Init2()
    +{
    +	TRACE("AHCIPort::Init2 port %d\n", fIndex);
    +
     	// start DMA engine
     	fRegs->cmd |= PORT_CMD_ST;
     
     	// enable interrupts
     	fRegs->ie = PORT_INT_MASK;
     
    +	FlushPostedWrites();
    +
    +//	if (fRegs->sig == 0xffffffff)
    +		ResetDevice();
    +
    +	PostResetDevice();
    +
    +	TRACE("ie   0x%08lx\n", fRegs->ie);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    +	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    +	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	TRACE("sact 0x%08lx\n", fRegs->sact);
    +
     	return B_OK;
     }
     
    @@ -97,13 +125,7 @@
     	fRegs->cmd &= ~PORT_CMD_FER;
     
     	// wait for receive completition, up to 500ms
    -	for (int i = 0; i <	15; i++) {
    -		if (!(fRegs->cmd & PORT_CMD_FR))
    -			break;
    -		snooze(50000);
    -	}
    -
    -	if (fRegs->cmd & PORT_CMD_FR) {
    +	if (wait_until_clear(&fRegs->cmd, PORT_CMD_FR, 500000) < B_OK) {
     		TRACE("AHCIPort::Uninit port %d error FIS rx still running\n", fIndex);
     	}
     
    @@ -111,13 +133,7 @@
     	fRegs->cmd &= ~PORT_CMD_ST;
     
     	// wait for DMA completition
    -	for (int i = 0; i <	15; i++) {
    -		if (!(fRegs->cmd & PORT_CMD_CR))
    -			break;
    -		snooze(50000);
    -	}
    -
    -	if (fRegs->cmd & PORT_CMD_CR) {
    +	if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 500000) < B_OK) {
     		TRACE("AHCIPort::Uninit port %d error DMA engine still running\n", fIndex);
     	}
     
    @@ -137,6 +153,84 @@
     }
     
     
    +
    +status_t
    +AHCIPort::ResetDevice()
    +{
    +	TRACE("AHCIPort::ResetDevice port %d\n", fIndex);
    +
    +	// stop DMA engine
    +	fRegs->cmd &= ~PORT_CMD_ST;
    +	FlushPostedWrites();
    +
    +	if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 500000) < B_OK) {
    +		TRACE("AHCIPort::ResetDevice port %d error DMA engine doesn't stop\n", fIndex);
    +	}
    +
    +	// perform a hard reset
    +	fRegs->sctl = (fRegs->sctl & ~0xf) | 1;
    +	FlushPostedWrites();
    +	snooze(10000);
    +	fRegs->sctl &= ~0xf;
    +	FlushPostedWrites();
    +
    +	if (wait_until_set(&fRegs->ssts, 0x1, 6000000) < B_OK) {
    +		TRACE("AHCIPort::ResetDevice port %d no device detected\n", fIndex);
    +	}
    +
    +	// clear error bits
    +//	fRegs->serr = fRegs->serr;
    +	fRegs->serr = 0xffffffff;
    +	FlushPostedWrites();
    +
    +	// start DMA engine
    +	fRegs->cmd |= PORT_CMD_ST;
    +	FlushPostedWrites();
    +
    +	return B_OK;
    +}
    +
    +
    +status_t
    +AHCIPort::PostResetDevice()
    +{
    +	TRACE("AHCIPort::PostResetDevice port %d\n", fIndex);
    +
    +	TRACE("tfd 1 0x%08lx\n", fRegs->tfd);
    +
    +	// wait for DMA idle ?
    +//	if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 1000000) < B_OK) {
    +//		TRACE("AHCIPort::PostResetDevice port %d error DMA engine doesn't stop\n", fIndex);
    +//	}
    +
    +	switch (fRegs->tfd & 0xff) {
    +		case 0x7f:
    +			TRACE("no device present?\n");
    +			break;
    +		case 0xff:
    +			TRACE("invalid task file status 0xff\n");
    +			// fall through
    +		default:
    +			TRACE("waiting...\n");
    +			wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 31000000);
    +	}
    +
    +	if (fRegs->sig == 0xeb140101)
    +		fRegs->cmd |= PORT_CMD_ATAPI;
    +	else
    +		fRegs->cmd &= ~PORT_CMD_ATAPI;
    +	FlushPostedWrites();
    +
    +	TRACE("device signature 0x%08lx (%s)\n", fRegs->sig,
    +		(fRegs->sig == 0xeb140101) ? "ATAPI" : (fRegs->sig == 0x00000101) ? "ATA" : "unknown");
    +
    +	TRACE("tfd 0x%08lx\n", fRegs->tfd);
    +	TRACE("device detection: 0x%lx\n", fRegs->ssts & 0xf);
    +
    +	return B_OK;
    +}
    +
    +
     void
     AHCIPort::Interrupt()
     {
    @@ -149,11 +243,12 @@
     
     
     void
    -AHCIPort::ExecuteRequest(scsi_ccb *request)
    +AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
     {
     
    -	TRACE("AHCIPort::ExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length);
    +	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
    +
     	request->subsys_status = SCSI_DEV_NOT_THERE;
     	gSCSI->finished(request, 1);
     	return;
    @@ -164,7 +259,7 @@
     
     
     uchar
    -AHCIPort::AbortRequest(scsi_ccb *request)
    +AHCIPort::ScsiAbortRequest(scsi_ccb *request)
     {
     
     	return SCSI_REQ_CMP;
    @@ -172,15 +267,14 @@
     
     
     uchar
    -AHCIPort::TerminateRequest(scsi_ccb *request)
    +AHCIPort::ScsiTerminateRequest(scsi_ccb *request)
     {
     	return SCSI_REQ_CMP;
     }
     
     
     uchar
    -AHCIPort::ResetDevice()
    +AHCIPort::ScsiResetDevice()
     {
     	return SCSI_REQ_CMP;
     }
    -
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-24 19:08:22 UTC (rev 22292)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-24 21:32:32 UTC (rev 22293)
    @@ -14,18 +14,22 @@
     				AHCIPort(AHCIController *controller, int index);
     				~AHCIPort();
     
    -	status_t	Init();
    +	status_t	Init1();
    +	status_t	Init2();
     	void		Uninit();
     
     	void		Interrupt();
     
     
    -	void		ExecuteRequest(scsi_ccb *request);
    -	uchar		AbortRequest(scsi_ccb *request);
    -	uchar		TerminateRequest(scsi_ccb *request);
    -	uchar		ResetDevice();
    +	void		ScsiExecuteRequest(scsi_ccb *request);
    +	uchar		ScsiAbortRequest(scsi_ccb *request);
    +	uchar		ScsiTerminateRequest(scsi_ccb *request);
    +	uchar		ScsiResetDevice();
     
     private:
    +	status_t	ResetDevice();
    +	status_t	PostResetDevice();
    +	void		FlushPostedWrites();
     
     private:
     	int						fIndex;
    @@ -38,4 +42,10 @@
     	volatile prd *					fPRDTable;
     };
     
    +inline void
    +AHCIPort::FlushPostedWrites()
    +{
    +	volatile uint32 dummy = fRegs->cmd;
    +	dummy = dummy;
    +}
     #endif	// _AHCI_PORT_H
    
    
    
    From marcusoverhagen at mail.berlios.de  Mon Sep 24 23:38:22 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Mon, 24 Sep 2007 23:38:22 +0200
    Subject: [Haiku-commits] r22294 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709242138.l8OLcMaw001606@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-24 23:38:21 +0200 (Mon, 24 Sep 2007)
    New Revision: 22294
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22294&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    wait for phy communication
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 21:32:32 UTC (rev 22293)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 21:38:21 UTC (rev 22294)
    @@ -187,6 +187,12 @@
     	fRegs->cmd |= PORT_CMD_ST;
     	FlushPostedWrites();
     
    +	if (fRegs->ssts & 1)
    +		if (wait_until_set(&fRegs->ssts, 0x3, 1000000) < B_OK) {
    +			TRACE("AHCIPort::ResetDevice port %d device present but no phy communication\n", fIndex);
    +		}
    +	}
    +
     	return B_OK;
     }
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Mon Sep 24 23:39:18 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Mon, 24 Sep 2007 23:39:18 +0200
    Subject: [Haiku-commits] r22295 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709242139.l8OLdI1u001665@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-24 23:39:18 +0200 (Mon, 24 Sep 2007)
    New Revision: 22295
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22295&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    oops
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 21:38:21 UTC (rev 22294)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 21:39:18 UTC (rev 22295)
    @@ -187,7 +187,7 @@
     	fRegs->cmd |= PORT_CMD_ST;
     	FlushPostedWrites();
     
    -	if (fRegs->ssts & 1)
    +	if (fRegs->ssts & 1) {
     		if (wait_until_set(&fRegs->ssts, 0x3, 1000000) < B_OK) {
     			TRACE("AHCIPort::ResetDevice port %d device present but no phy communication\n", fIndex);
     		}
    
    
    
    From axeld at mail.berlios.de  Mon Sep 24 23:48:06 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Mon, 24 Sep 2007 23:48:06 +0200
    Subject: [Haiku-commits] r22296 - haiku/trunk/src/servers/registrar
    Message-ID: <200709242148.l8OLm6au002218@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-24 23:48:06 +0200 (Mon, 24 Sep 2007)
    New Revision: 22296
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22296&view=rev
    
    Modified:
       haiku/trunk/src/servers/registrar/TRoster.cpp
    Log:
    This fixes the problem of launching more than one document with one application
    at once with Tracker (eg. launching several text documents) - only the first one
    would have been opened, and an error B_BAD_VALUE would have been reported for the
    others:
    * HandleAddApplication() did not return the correct token in case of a
      pending registration; therefore, BRoster::_LaunchApp() would try to
      check the registration with invalid arguments.
    * HandleIsAppRegistered() put the pending registration requests into
      the fIARRequestsByToken map using the wrong key, so that they could
      not be found again.
    * Minor cleanup (fixed indentation of not so temporary debug code).
    
    
    Modified: haiku/trunk/src/servers/registrar/TRoster.cpp
    ===================================================================
    --- haiku/trunk/src/servers/registrar/TRoster.cpp	2007-09-24 21:39:18 UTC (rev 22295)
    +++ haiku/trunk/src/servers/registrar/TRoster.cpp	2007-09-24 21:48:06 UTC (rev 22296)
    @@ -198,6 +198,7 @@
     				|| (info = fEarlyPreRegisteredApps.InfoFor(&ref)) != NULL)) {
     			SET_ERROR(error, B_ALREADY_RUNNING);
     			otherTeam = info->team;
    +			token = info->token;
     		}
     	}
     
    @@ -236,14 +237,12 @@
     			info->registration_time = system_time();
     			// add it to the right list
     			bool addingSuccess = false;
    -			if (team >= 0)
    -{
    +			if (team >= 0) {
     PRINT(("added ref: %ld, %lld, %s\n", info->ref.device, info->ref.directory, info->ref.name));
     				addingSuccess = (AddApp(info) == B_OK);
     				if (addingSuccess && fullReg)
     					_AppAdded(info);
    -}
    -			else {
    +			} else {
     				token = info->token = _NextToken();
     				addingSuccess = fEarlyPreRegisteredApps.AddInfo(info);
     PRINT(("added to early pre-regs, token: %lu\n", token));
    @@ -370,9 +369,10 @@
     		team = -1;
     	if (request->FindInt32("token", (int32*)&token) != B_OK)
     		token = 0;
    -PRINT(("team: %ld, token: %lu\n", team, token));
    -PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name));
     
    +	PRINT(("team: %ld, token: %lu\n", team, token));
    +	PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name));
    +
     	// check the parameters
     	// entry_ref
     	if (error == B_OK & !BEntry(&ref).Exists())
    @@ -385,24 +385,24 @@
     	RosterAppInfo *info = NULL;
     	if (error == B_OK) {
     		if ((info = fRegisteredApps.InfoFor(team)) != NULL) {
    -PRINT(("found team in fRegisteredApps\n"));
    +			PRINT(("found team in fRegisteredApps\n"));
     			_ReplyToIARRequest(request, info);
     		} else if (token > 0
     			&& (info = fEarlyPreRegisteredApps.InfoForToken(token)) != NULL) {
    -PRINT(("found ref in fEarlyRegisteredApps (by token)\n"));
    +			PRINT(("found ref in fEarlyRegisteredApps (by token)\n"));
     			// pre-registered and has no team ID assigned yet -- queue the
     			// request
     			be_app->DetachCurrentMessage();
    -			_AddIARRequest(fIARRequestsByToken, team, request);
    +			_AddIARRequest(fIARRequestsByToken, token, request);
     		} else if (team >= 0
     			&& (info = fEarlyPreRegisteredApps.InfoFor(&ref)) != NULL) {
    -PRINT(("found ref in fEarlyRegisteredApps (by ref)\n"));
    +			PRINT(("found ref in fEarlyRegisteredApps (by ref)\n"));
     			// pre-registered and has no team ID assigned yet -- queue the
     			// request
     			be_app->DetachCurrentMessage();
     			_AddIARRequest(fIARRequestsByID, team, request);
     		} else {
    -PRINT(("didn't find team or ref\n"));
    +			PRINT(("didn't find team or ref\n"));
     			// team not registered, ref/token not early pre-registered
     			_ReplyToIARRequest(request, NULL);
     		}
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 00:26:03 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 00:26:03 +0200
    Subject: [Haiku-commits] r22297 - haiku/trunk/src/system/libroot/posix/locale
    Message-ID: <200709242226.l8OMQ3Rw004255@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 00:26:03 +0200 (Tue, 25 Sep 2007)
    New Revision: 22297
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22297&view=rev
    
    Modified:
       haiku/trunk/src/system/libroot/posix/locale/setlocale.c
    Log:
    setlocale(, "") now no longer returns an error, but returns "C" now; we don't
    (yet) support any locale anyway, so evaluating LC_ALL and friends doesn't make
    much sense at this point.
    This fixes bug #1499.
    
    
    Modified: haiku/trunk/src/system/libroot/posix/locale/setlocale.c
    ===================================================================
    --- haiku/trunk/src/system/libroot/posix/locale/setlocale.c	2007-09-24 21:48:06 UTC (rev 22296)
    +++ haiku/trunk/src/system/libroot/posix/locale/setlocale.c	2007-09-24 22:26:03 UTC (rev 22297)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      */
     
    @@ -11,7 +11,7 @@
     char *
     setlocale(int category, const char *locale)
     {
    -	if (locale == NULL)
    +	if (locale == NULL || !locale[0])
     		return "C";
     
     	// ToDo: this should check if liblocale.so is available and use its functions
    
    
    
    From marcusoverhagen at mail.berlios.de  Tue Sep 25 00:42:25 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Tue, 25 Sep 2007 00:42:25 +0200
    Subject: [Haiku-commits] r22298 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709242242.l8OMgPCI005284@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-25 00:42:24 +0200 (Tue, 25 Sep 2007)
    New Revision: 22298
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22298&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    start dma later, reduce timeouts
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-24 22:26:03 UTC (rev 22297)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-24 22:42:24 UTC (rev 22298)
    @@ -118,6 +118,10 @@
     	TRACE("cap: Supports External SATA: %s\n",			(fRegs->cap & CAP_SXS) ? "yes" : "no");
     	TRACE("cap: Enclosure Management Supported: %s\n",	(fRegs->cap & CAP_EMS) ? "yes" : "no");
     
    +	TRACE("cap: Supports Command List Override: %s\n",	(fRegs->cap & CAP_SCLO) ? "yes" : "no");
    +	TRACE("cap: Supports Staggered Spin-up: %s\n",	(fRegs->cap & CAP_SSS) ? "yes" : "no");
    +	TRACE("cap: Supports Mechanical Presence Switch: %s\n",	(fRegs->cap & CAP_SMPS) ? "yes" : "no");
    +
     	TRACE("cap: Supports 64-bit Addressing: %s\n",		(fRegs->cap & CAP_S64A) ? "yes" : "no");
     	TRACE("cap: Supports Native Command Queuing: %s\n",	(fRegs->cap & CAP_SNCQ) ? "yes" : "no");
     	TRACE("cap: Supports SNotification Register: %s\n",	(fRegs->cap & CAP_SSNTF) ? "yes" : "no");
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 22:26:03 UTC (rev 22297)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-24 22:42:24 UTC (rev 22298)
    @@ -70,6 +70,9 @@
     //	fRegs->serr = fRegs->serr;
     	fRegs->serr = 0xffffffff;
     
    +	// power up device
    +	fRegs->cmd |= PORT_CMD_POD;
    +
     	// spin up device
     	fRegs->cmd |= PORT_CMD_SUD;
     
    @@ -172,9 +175,10 @@
     	FlushPostedWrites();
     	snooze(10000);
     	fRegs->sctl &= ~0xf;
    +	fRegs->serr = 0xffffffff;
     	FlushPostedWrites();
     
    -	if (wait_until_set(&fRegs->ssts, 0x1, 6000000) < B_OK) {
    +	if (wait_until_set(&fRegs->ssts, 0x1, 100000) < B_OK) {
     		TRACE("AHCIPort::ResetDevice port %d no device detected\n", fIndex);
     	}
     
    @@ -183,16 +187,19 @@
     	fRegs->serr = 0xffffffff;
     	FlushPostedWrites();
     
    -	// start DMA engine
    -	fRegs->cmd |= PORT_CMD_ST;
    -	FlushPostedWrites();
    -
     	if (fRegs->ssts & 1) {
    -		if (wait_until_set(&fRegs->ssts, 0x3, 1000000) < B_OK) {
    +		if (wait_until_set(&fRegs->ssts, 0x3, 500000) < B_OK) {
     			TRACE("AHCIPort::ResetDevice port %d device present but no phy communication\n", fIndex);
     		}
     	}
     
    +	// clear error bits
    +	fRegs->serr = 0xffffffff;
    +
    +	// start DMA engine
    +	fRegs->cmd |= PORT_CMD_ST;
    +	FlushPostedWrites();
    +
     	return B_OK;
     }
     
    
    
    
    From korli at mail.berlios.de  Tue Sep 25 01:09:43 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Tue, 25 Sep 2007 01:09:43 +0200
    Subject: [Haiku-commits] r22299 - in
    	haiku/trunk/src/add-ons/kernel/drivers/audio: . null
    Message-ID: <200709242309.l8ON9h2r015557@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-25 01:09:42 +0200 (Tue, 25 Sep 2007)
    New Revision: 22299
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22299&view=rev
    
    Added:
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/Jamfile
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.c
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.h
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_hardware.c
       haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_multi.c
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile
    Log:
    added null_audio driver from Bek, HOST team. Thanks.
    Applied some style fixes.
    It's not recognized as a fallback driver. We might also consider a simple userland BufferConsumer/BufferProducer.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/Jamfile	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -6,6 +6,7 @@
     SubInclude HAIKU_TOP src add-ons kernel drivers audio emuxki ;
     SubInclude HAIKU_TOP src add-ons kernel drivers audio hda ;
     SubInclude HAIKU_TOP src add-ons kernel drivers audio module_driver ;
    +SubInclude HAIKU_TOP src add-ons kernel drivers audio null ;
     SubInclude HAIKU_TOP src add-ons kernel drivers audio sb16 ;
     SubInclude HAIKU_TOP src add-ons kernel drivers audio sis7018 ;
     SubInclude HAIKU_TOP src add-ons kernel drivers audio usb_audio ;
    
    Added: haiku/trunk/src/add-ons/kernel/drivers/audio/null/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/null/Jamfile	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/null/Jamfile	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -0,0 +1,12 @@
    +SubDir HAIKU_TOP src add-ons kernel drivers audio null ;
    +
    +SetSubDirSupportedPlatformsBeOSCompatible ;
    +
    +UsePrivateHeaders media ;
    +
    +KernelAddon null_audio :
    +	driver.c
    +	null_hardware.c
    +	null_multi.c
    +;
    +
    
    Added: haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.c	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.c	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -0,0 +1,132 @@
    +/*
    + * Copyright 2007 Haiku Inc. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + *
    + * Authors:
    + *              Bek, host.haiku at gmx.de
    + */
    +#include "driver.h"
    +
    +int32 api_version = B_CUR_DRIVER_API_VERSION;
    +device_t device;
    +
    +
    +status_t
    +init_hardware(void)
    +{
    +	dprintf("null_audio: %s\n", __func__);
    +	return B_OK;
    +}
    +
    +
    +status_t
    +init_driver(void)
    +{
    +	dprintf("null_audio: %s\n", __func__);
    +	device.running = false;
    +	return B_OK;
    +}
    +
    +
    +void
    +uninit_driver(void)
    +{
    +}
    +
    +
    +const char**
    +publish_devices(void)
    +{
    +	static const char* published_paths[] = {
    +		MULTI_AUDIO_DEV_PATH "/null/0",
    +		NULL
    +	};
    +	dprintf("null_audio: %s\n", __func__);
    +
    +	return published_paths;
    +}
    +
    +
    +static status_t
    +null_audio_open (const char *name, uint32 flags, void** cookie)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	*cookie = &device;
    +    return B_OK;
    +}
    +
    +
    +static status_t
    +null_audio_read (void* cookie, off_t a, void* b, size_t* num_bytes)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	// Audio drivers are not supposed to return anything
    +	// inside here
    +	*num_bytes = 0;
    +	return B_IO_ERROR;
    +}
    +
    +
    +static status_t
    +null_audio_write (void* cookie, off_t a, const void* b, size_t* num_bytes)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	// Audio drivers are not supposed to return anything
    +	// inside here
    +	*num_bytes = 0;
    +	return B_IO_ERROR;
    +}
    +
    +
    +static status_t
    +null_audio_control (void* cookie, uint32 op, void* arg, size_t len)
    +{
    +	//dprintf("null_audio: %s\n" , __func__ );
    +	// In case we have a valid cookie, initialized
    +	// the driver and hardware connection properly
    +	// Simply pass through to the multi audio hooks
    +	if (cookie)
    +		return multi_audio_control(cookie, op, arg, len);
    +	else
    +		dprintf("null_audio: %s called without cookie\n" , __func__);
    +
    +	// Return error in case we have no valid setup
    +	return B_BAD_VALUE;
    +}
    +
    +
    +static status_t
    +null_audio_close (void* cookie)
    +{
    +	device_t* device = (device_t*) cookie;
    +	dprintf("null_audio: %s\n" , __func__ );
    +	if (device && device->running)
    +		null_stop_hardware(device);
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +null_audio_free (void* cookie)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	return B_OK;
    +}
    +
    +
    +device_hooks driver_hooks = {
    +        null_audio_open,
    +        null_audio_close,
    +        null_audio_free,
    +        null_audio_control,
    +        null_audio_read,
    +        null_audio_write
    +};
    +
    +
    +device_hooks*
    +find_device(const char* name)
    +{
    +	return &driver_hooks;
    +}
    +
    
    Added: haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.h	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/null/driver.h	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -0,0 +1,60 @@
    +/*
    + * Copyright 2007 Haiku Inc. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + */
    +#ifndef NULL_AUDIO_DRIVER_H
    +#define NULL_AUDIO_DRIVER_H
    +
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +#include 
    +#include 
    +
    +#define FRAMES_PER_BUFFER 1024
    +#define MULTI_AUDIO_BASE_ID 1024
    +#define MULTI_AUDIO_DEV_PATH "audio/hmulti"
    +#define MULTI_AUDIO_MASTER_ID 0
    +#define STRMINBUF 2
    +#define STRMAXBUF 2
    +
    +typedef struct {
    +	spinlock	lock;
    +	int bits;
    +
    +	void*		buffers[STRMAXBUF];
    +	uint32		num_buffers;
    +	uint32		num_channels;
    +	uint32		format;
    +	uint32		rate;
    +
    +	uint32		buffer_length;
    +	sem_id		buffer_ready_sem;
    +	uint32		frames_count;
    +	uint32		buffer_cycle;
    +	bigtime_t	real_time;
    +
    +	area_id		buffer_area;
    +} device_stream_t;
    +
    +typedef struct {
    +	device_stream_t playback_stream;
    +	device_stream_t record_stream;
    +	
    +	thread_id interrupt_thread;
    +	bool running;
    +} device_t;
    +
    +extern device_hooks driver_hooks;
    +int32 format_to_sample_size(uint32 format);
    +
    +status_t multi_audio_control(void* cookie, uint32 op, void* arg, size_t len);
    +
    +status_t null_hw_create_virtual_buffers(device_stream_t* stream, const char* name);
    +status_t null_start_hardware(device_t* device);
    +void null_stop_hardware(device_t* device);
    +
    +#endif /* NULL_AUDIO_DRIVER_H */
    +
    
    Added: haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_hardware.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_hardware.c	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_hardware.c	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -0,0 +1,123 @@
    +/*
    + * Copyright 2007 Haiku Inc. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + *
    + * Authors:
    + *              Bek, host.haiku at gmx.de
    + */
    +#include "driver.h"
    +
    +
    +status_t 
    +null_hw_create_virtual_buffers(device_stream_t* stream, const char* name)
    +{
    +	int i;
    +	int buffer_size;
    +	int area_size;
    +	uint8* buffer;
    +	status_t result;
    +	physical_entry pe;
    +
    +	buffer_size = stream->num_channels 
    +				* format_to_sample_size(stream->format) 
    +				* stream->buffer_length;
    +	buffer_size = (buffer_size + 127) & (~127);
    +	
    +	area_size = buffer_size * stream->num_buffers;
    +	area_size = (area_size + B_PAGE_SIZE - 1) & (~(B_PAGE_SIZE -1));
    +
    +	stream->buffer_area = create_area("null_audio_buffers", (void**)&buffer, 
    +							B_ANY_KERNEL_ADDRESS, area_size,
    +							B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
    +	if (stream->buffer_area < B_OK)
    +		return stream->buffer_area;
    +
    +	// Get the correct address for setting up the buffers
    +	// pointers being passed back to userland
    +	result = get_memory_map(buffer, area_size, &pe, 1);
    +	if (result != B_OK) {
    +		delete_area(stream->buffer_area);
    +		return result;
    +	}
    +	
    +	for (i=0; i < stream->num_buffers; i++) {
    +		stream->buffers[i] = buffer + (i*buffer_size);
    +	}
    +
    +	stream->buffer_ready_sem = create_sem(0, name);
    +	return B_OK;
    +}
    +
    +
    +static int32 
    +null_fake_interrupt(void* cookie)
    +{
    +	// This thread is supposed to fake the interrupt
    +	// handling done in communication with the 
    +	// hardware usually. What it does is nearly the
    +	// same like all soundrivers, get the interrupt
    +	// exchange the buffer pointer and update the
    +	// time information. Instead of exiting, we wait
    +	// until the next fake interrupt appears.
    +	int sleepTime;
    +	device_t* device = (device_t*) cookie;
    +	int sampleRate;
    +
    +	switch (device->playback_stream.rate) {
    +		case B_SR_48000:
    +			sampleRate = 48000;
    +			break;
    +		case B_SR_44100:
    +		default:
    +			sampleRate = 44100;
    +			break;
    +	}
    +
    +	// The time between until we get a new valid buffer
    +	// from our soundcard: buffer_length / samplerate
    +	sleepTime = (device->playback_stream.buffer_length*1000) / sampleRate;
    +
    +	while (device->running) {
    +		cpu_status status;
    +		status = disable_interrupts();
    +		acquire_spinlock(&device->playback_stream.lock);
    +		device->playback_stream.real_time = system_time();
    +		device->playback_stream.frames_count += device->playback_stream.buffer_length;
    +		device->playback_stream.buffer_cycle = (device->playback_stream.buffer_cycle +1) % device->playback_stream.num_buffers;
    +		release_spinlock(&device->playback_stream.lock);
    +
    +		// TODO: Create a simple sinus wave, so that recording from
    +		// the virtual device actually returns something useful
    +		acquire_spinlock(&device->record_stream.lock);
    +		device->record_stream.real_time = device->playback_stream.real_time;
    +		device->record_stream.frames_count += device->record_stream.buffer_length;
    +		device->record_stream.buffer_cycle = (device->record_stream.buffer_cycle +1) % device->record_stream.num_buffers;
    +		release_spinlock(&device->record_stream.lock);
    +
    +		restore_interrupts(status);
    +
    +		release_sem_etc(device->playback_stream.buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
    +		release_sem_etc(device->record_stream.buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE);
    +		snooze(sleepTime);
    +	}
    +	return B_OK;
    +}
    +
    +
    +status_t 
    +null_start_hardware(device_t* device)
    +{
    +	dprintf("null_audio: %s spawning fake interrupter\n", __func__);
    +	device->running = true;
    +	device->interrupt_thread = spawn_kernel_thread(null_fake_interrupt, "null_audio interrupter",
    +								B_REAL_TIME_PRIORITY, (void*)device);
    +	return resume_thread(device->interrupt_thread);
    +}
    +
    +
    +void 
    +null_stop_hardware(device_t* device)
    +{
    +	device->running = false;
    +}
    +
    
    Added: haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_multi.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_multi.c	2007-09-24 22:42:24 UTC (rev 22298)
    +++ haiku/trunk/src/add-ons/kernel/drivers/audio/null/null_multi.c	2007-09-24 23:09:42 UTC (rev 22299)
    @@ -0,0 +1,352 @@
    +/*
    + * Copyright 2007 Haiku Inc. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + *
    + * Authors:
    + *              Bek, host.haiku at gmx.de
    + */
    +#include "driver.h"
    +
    +// Convenience function to determine the byte count
    +// of a sample for a given format.
    +// Note: Currently null_audio only supports 16 bit,
    +// but that is supposed to change later
    +int32
    +format_to_sample_size(uint32 format)
    +{
    +	switch(format) {
    +		case B_FMT_8BIT_S:
    +			return 1;
    +		case B_FMT_16BIT:
    +			return 2;
    +
    +		case B_FMT_18BIT:
    +		case B_FMT_24BIT:
    +		case B_FMT_32BIT:
    +		case B_FMT_FLOAT:
    +			return 4;
    +
    +		default:
    +			return 0;
    +	}
    +}
    +
    +
    +multi_channel_info channel_descriptions[] = {
    +	{  0, B_MULTI_OUTPUT_CHANNEL, 	B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 },
    +	{  1, B_MULTI_OUTPUT_CHANNEL, 	B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 },
    +	{  2, B_MULTI_INPUT_CHANNEL, 	B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 },
    +	{  3, B_MULTI_INPUT_CHANNEL, 	B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 },
    +	{  4, B_MULTI_OUTPUT_BUS, 		B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 	B_CHANNEL_MINI_JACK_STEREO },
    +	{  5, B_MULTI_OUTPUT_BUS, 		B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO },
    +	{  6, B_MULTI_INPUT_BUS, 		B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 	B_CHANNEL_MINI_JACK_STEREO },
    +	{  7, B_MULTI_INPUT_BUS, 		B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO },
    +};
    +
    +
    +static status_t
    +get_description(void* cookie, multi_description* data)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	data->interface_version = B_CURRENT_INTERFACE_VERSION;
    +	data->interface_minimum = B_CURRENT_INTERFACE_VERSION;
    +
    +	strcpy(data->friendly_name,"Virtual Audio (null_audio)");
    +	strcpy(data->vendor_info,"Host/Haiku");
    +
    +	data->output_channel_count = 2;
    +	data->input_channel_count = 2;
    +	data->output_bus_channel_count = 2;
    +	data->input_bus_channel_count = 2;
    +	data->aux_bus_channel_count = 0;
    +
    +	if (data->request_channel_count >= (int)(sizeof(channel_descriptions) / sizeof(channel_descriptions[0]))) {
    +		memcpy(data->channels,&channel_descriptions,sizeof(channel_descriptions));
    +	}
    +
    +	data->output_rates = B_SR_44100;
    +	data->input_rates = B_SR_44100;
    +
    +	data->max_cvsr_rate = 0;
    +	data->min_cvsr_rate = 0;
    +
    +	data->output_formats = B_FMT_16BIT;
    +	data->input_formats = B_FMT_16BIT;
    +	data->lock_sources = B_MULTI_LOCK_INTERNAL;
    +	data->timecode_sources = 0;
    +	data->interface_flags = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD;
    +	data->start_latency = 30000;
    +
    +	strcpy(data->control_panel,"");
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +get_enabled_channels(void* cookie, multi_channel_enable* data)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	// By default we say, that all channels are enabled
    +	// and that this cannot be changed
    +	B_SET_CHANNEL(data->enable_bits, 0, true);
    +	B_SET_CHANNEL(data->enable_bits, 1, true);
    +	B_SET_CHANNEL(data->enable_bits, 2, true);
    +	B_SET_CHANNEL(data->enable_bits, 3, true);
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +set_global_format(device_t* device, multi_format_info* data)
    +{
    +	// The media kit asks us to set our streams
    +	// according to its settings
    +	dprintf("null_audio: %s\n" , __func__ );
    +	device->playback_stream.format = data->output.format;
    +	device->playback_stream.rate = data->output.rate;
    +
    +	device->record_stream.format = data->input.format;
    +	device->record_stream.rate = data->input.rate;
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +get_global_format(device_t* device, multi_format_info* data)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	// Zero latency is unlikely to happen, so we fake some
    +	// additional latency
    +	data->output_latency = 30;
    +	data->input_latency = 30;
    +	data->timecode_kind = 0;
    +
    +	data->output.format = device->playback_stream.format;
    +	data->output.rate = device->playback_stream.rate;
    +	data->input.format = device->record_stream.format;
    +	data->input.rate = device->record_stream.rate;
    +
    +	return B_OK;
    +}
    +
    +
    +static int32
    +create_group_control(multi_mix_control* multi, int32 idx, int32 parent, int32 string, const char* name) 
    +{
    +        multi->id = MULTI_AUDIO_BASE_ID + idx;
    +        multi->parent = parent;
    +        multi->flags = B_MULTI_MIX_GROUP;
    +        multi->master = MULTI_AUDIO_MASTER_ID;
    +        multi->string = string;
    +        if(name)
    +                strcpy(multi->name, name);
    + 
    +       return multi->id;
    +}
    +
    +
    +static status_t
    +list_mix_controls(device_t* device, multi_mix_control_info * data)
    +{
    +	int32 parent;
    +	dprintf("null_audio: %s\n" , __func__ );
    +
    +	parent = create_group_control(data->controls +0, 0, 0, 0, "Record");
    +	parent = create_group_control(data->controls +1, 1, 0, 0, "Playback");
    +	data->control_count = 2;
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +list_mix_connections(void* cookie, multi_mix_connection_info* connection_info)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	return B_ERROR;
    +}
    +
    +
    +static status_t
    +list_mix_channels(void* cookie, multi_mix_channel_info* channel_info)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +	return B_ERROR;
    +}
    +
    +
    +static status_t
    +get_buffers(device_t* device, multi_buffer_list* data)
    +{
    + 	uint32 playback_sample_size = format_to_sample_size(device->playback_stream.format);
    + 	uint32 record_sample_size = format_to_sample_size(device->record_stream.format);
    + 	uint32 cidx, bidx;
    + 	status_t result;
    +
    +	dprintf("null_audio: %s\n" , __func__ );
    + 
    +	/* Workaround for Haiku multi_audio API, since it prefers to let the driver pick
    +		values, while the BeOS multi_audio actually gives the user's defaults. */
    +	if (data->request_playback_buffers > STRMAXBUF
    +		|| data->request_playback_buffers < STRMINBUF) {
    +		data->request_playback_buffers = STRMINBUF;
    +	}
    +
    +	if (data->request_record_buffers > STRMAXBUF
    +		|| data->request_record_buffers < STRMINBUF) {
    +		data->request_record_buffers = STRMINBUF;
    +	}
    +
    +	if (data->request_playback_buffer_size == 0)
    +		data->request_playback_buffer_size = FRAMES_PER_BUFFER;
    +
    +	if (data->request_record_buffer_size == 0)
    +		data->request_record_buffer_size = FRAMES_PER_BUFFER;
    +
    +	/* ... from here on, we can assume again that a reasonable request is being made */
    +
    +	data->flags = 0;
    +
    +	// Copy the requested settings into the streams
    +	// and initialize the virtual buffers properly
    +	device->playback_stream.num_buffers = data->request_playback_buffers;
    +	device->playback_stream.num_channels = data->request_playback_channels;
    +	device->playback_stream.buffer_length = data->request_playback_buffer_size;
    +	if ((result = null_hw_create_virtual_buffers(&device->playback_stream, "null_audio_playback_sem")) != B_OK) {
    +		dprintf("null_audio %s: Error setting up playback buffers (%s)\n", __func__, strerror(result));
    +		return result;
    +	}
    +
    +	device->record_stream.num_buffers = data->request_record_buffers;
    +	device->record_stream.num_channels = data->request_record_channels;
    +	device->record_stream.buffer_length = data->request_record_buffer_size;
    +	if ((result = null_hw_create_virtual_buffers(&device->record_stream, "null_audio_record_sem")) != B_OK) {
    +		dprintf("null_audio %s: Error setting up recording buffers (%s)\n", __func__, strerror(result));
    +		return result;
    +	}
    +
    +	/* Setup data structure for multi_audio API... */
    +	data->return_playback_buffers = data->request_playback_buffers;
    +	data->return_playback_channels = data->request_playback_channels;
    +	data->return_playback_buffer_size = data->request_playback_buffer_size;
    +
    +	for (bidx=0; bidx < data->return_playback_buffers; bidx++) {
    +		for (cidx=0; cidx < data->return_playback_channels; cidx++) {
    +			data->playback_buffers[bidx][cidx].base = device->playback_stream.buffers[bidx] + (playback_sample_size * cidx);
    +			data->playback_buffers[bidx][cidx].stride = playback_sample_size * data->return_playback_channels;
    +		}
    +	}
    +
    +	data->return_record_buffers = data->request_record_buffers;
    +	data->return_record_channels = data->request_record_channels;
    +	data->return_record_buffer_size = data->request_record_buffer_size;
    +
    +	for (bidx=0; bidx < data->return_record_buffers; bidx++) {
    +		for (cidx=0; cidx < data->return_record_channels; cidx++) {
    +			data->record_buffers[bidx][cidx].base = device->record_stream.buffers[bidx] + (record_sample_size * cidx);
    +			data->record_buffers[bidx][cidx].stride = record_sample_size * data->return_record_channels;
    +		}
    +	}
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +buffer_exchange(device_t* device, multi_buffer_info* buffer_info)
    +{
    +	//dprintf("null_audio: %s\n" , __func__ );
    +	static int debug_buffers_exchanged = 0;
    +	cpu_status status;
    +	status_t result;
    +
    +	// On first call, we start our fake hardware.
    +	// Usually one would jump into his interrupt handler now
    +	if (!device->running)
    +		null_start_hardware(device);
    +
    +	result = acquire_sem(device->playback_stream.buffer_ready_sem);
    +	if (result != B_OK) {
    +		dprintf("null_audio: %s, Could not get playback buffer\n", __func__);
    +		return result;
    +	}
    +
    +	result = acquire_sem(device->record_stream.buffer_ready_sem);
    +	if (result != B_OK) {
    +		dprintf("null_audio: %s, Could not get record buffer\n", __func__);
    +		return result;
    +	}
    +
    +	status = disable_interrupts();
    +	acquire_spinlock(&device->playback_stream.lock);
    +
    +	buffer_info->playback_buffer_cycle = device->playback_stream.buffer_cycle;
    +	buffer_info->played_real_time = device->playback_stream.real_time;
    +	buffer_info->played_frames_count = device->playback_stream.frames_count;
    +
    +	buffer_info->record_buffer_cycle = device->record_stream.buffer_cycle;
    +	buffer_info->recorded_real_time = device->record_stream.real_time;
    +	buffer_info->recorded_frames_count = device->record_stream.frames_count;
    +
    +	release_spinlock(&device->playback_stream.lock);
    +	restore_interrupts(status);
    +
    +	debug_buffers_exchanged++;
    +	if (((debug_buffers_exchanged % 5000) == 0) ) { //&& debug_buffers_exchanged < 1111) {
    +		dprintf("null_audio: %s: %d buffers processed\n", __func__, debug_buffers_exchanged);
    +	}
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +buffer_force_stop(device_t* device)
    +{
    +	dprintf("null_audio: %s\n" , __func__ );
    +
    +	if (device && device->running)
    +		null_stop_hardware(device);
    +
    +	delete_area(device->playback_stream.buffer_area);
    +	delete_area(device->record_stream.buffer_area);
    +
    +	delete_sem(device->playback_stream.buffer_ready_sem);
    +	delete_sem(device->record_stream.buffer_ready_sem);
    +
    +	return B_OK;
    +}
    +
    +
    +status_t
    +multi_audio_control(void* cookie, uint32 op, void* arg, size_t len)
    +{
    +	switch(op) {
    +		case B_MULTI_GET_DESCRIPTION:			return get_description(cookie, arg);
    +		case B_MULTI_GET_EVENT_INFO:			return B_ERROR;
    +		case B_MULTI_SET_EVENT_INFO:			return B_ERROR;
    +		case B_MULTI_GET_EVENT:					return B_ERROR;
    +		case B_MULTI_GET_ENABLED_CHANNELS:		return get_enabled_channels(cookie, arg);
    +		case B_MULTI_SET_ENABLED_CHANNELS:		return B_OK;
    +		case B_MULTI_GET_GLOBAL_FORMAT:			return get_global_format(cookie, arg);
    +		case B_MULTI_SET_GLOBAL_FORMAT:			return set_global_format(cookie, arg);
    +		case B_MULTI_GET_CHANNEL_FORMATS:		return B_ERROR;
    +		case B_MULTI_SET_CHANNEL_FORMATS:		return B_ERROR;
    +		case B_MULTI_GET_MIX:					return B_ERROR;
    +		case B_MULTI_SET_MIX:					return B_ERROR;
    +		case B_MULTI_LIST_MIX_CHANNELS:			return list_mix_channels(cookie, arg);
    +		case B_MULTI_LIST_MIX_CONTROLS:			return list_mix_controls(cookie, arg);
    +		case B_MULTI_LIST_MIX_CONNECTIONS:		return list_mix_connections(cookie, arg);
    +		case B_MULTI_GET_BUFFERS:				return get_buffers(cookie, arg);
    +		case B_MULTI_SET_BUFFERS:				return B_ERROR;
    +		case B_MULTI_SET_START_TIME:			return B_ERROR;
    +		case B_MULTI_BUFFER_EXCHANGE:			return buffer_exchange(cookie, arg);
    +		case B_MULTI_BUFFER_FORCE_STOP:			return buffer_force_stop(cookie);
    +	}
    +
    +	dprintf("null_audio: %s - unknown op\n" , __func__);
    +	return B_BAD_VALUE;
    +}
    +
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 12:51:52 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 12:51:52 +0200
    Subject: [Haiku-commits] r22300 - haiku/trunk/src/tests/system/consoled
    Message-ID: <200709251051.l8PApq66025976@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 12:51:50 +0200 (Tue, 25 Sep 2007)
    New Revision: 22300
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22300&view=rev
    
    Modified:
       haiku/trunk/src/tests/system/consoled/consoled.cpp
    Log:
    The TTY now only allows session leaders to open it; consoled only called setsid()
    too late, it does it now before starting the console.
    This fixes bug #1502, and also allows to debug the GUI servers again.
    
    
    Modified: haiku/trunk/src/tests/system/consoled/consoled.cpp
    ===================================================================
    --- haiku/trunk/src/tests/system/consoled/consoled.cpp	2007-09-24 23:09:42 UTC (rev 22299)
    +++ haiku/trunk/src/tests/system/consoled/consoled.cpp	2007-09-25 10:51:50 UTC (rev 22300)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004-2005, Haiku. All rights reserved.
    + * Copyright 2004-2007, Haiku. All rights reserved.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2002, Travis Geiselbrecht. All rights reserved.
    @@ -12,6 +12,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     #include 
     #include 
    @@ -206,7 +207,7 @@
     
     				con->tty_slave_fd = open(name, O_RDWR);
     				if (con->tty_slave_fd < 0) {
    -					fprintf(stderr, "Could not open tty!\n");
    +					fprintf(stderr, "Could not open tty %s: %s!\n", name, strerror(errno));
     					close(con->tty_master_fd);
     				} else {
     					// set default mode
    @@ -316,15 +317,15 @@
     {
     	int err;
     
    +	// we're a session leader
    +	setsid();
    +
     	err = start_console(&gConsole);
     	if (err < 0) {
     		printf("consoled: error %d starting console\n", err);
     		return err;
     	}
     
    -	// we're a session leader
    -	setsid();
    -
     	// move our stdin and stdout to the console
     	dup2(gConsole.tty_slave_fd, 0);
     	dup2(gConsole.tty_slave_fd, 1);
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 14:43:34 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 14:43:34 +0200
    Subject: [Haiku-commits] r22301 -
    	haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid
    Message-ID: <200709251243.l8PChY1R008576@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 14:43:34 +0200 (Tue, 25 Sep 2007)
    New Revision: 22301
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22301&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c
       haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h
    Log:
    * Implemented double click support in the USB HID driver - in the future, this
      should really be moved into the input_server, though (BeOS does it in the
      driver, too).
    * Fixed warnings.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c	2007-09-25 10:51:50 UTC (rev 22300)
    +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c	2007-09-25 12:43:34 UTC (rev 22301)
    @@ -346,6 +346,12 @@
     	device->rbuf = create_ring_buffer(384);
     	device->is_keyboard = isKeyboard;
     
    +	// double click handling
    +	device->click_count = 1;
    +	device->click_speed = 250000;
    +	device->last_click_time = 0;
    +	device->last_buttons = 0;
    +
     	// default values taken from the PS/2 driver
     	device->repeat_rate = 35000;
     	device->repeat_delay = 300000;
    @@ -549,8 +555,7 @@
     		if (insn->usage_page == USAGE_PAGE_BUTTON) {
     			if ((insn->usage_id - 1) < MAX_BUTTONS) {
     				info.buttons |= (value & 1) << (insn->usage_id - 1);
    -				info.clicks = 1;
    -			}	
    +			}
     		} else if (insn->usage_page == USAGE_PAGE_GENERIC_DESKTOP) {
     			if (insn->is_phy_signed)
     				value = sign_extend(value, insn->num_bits);
    @@ -569,6 +574,20 @@
     		}
     	}
     
    +	if (info.buttons != 0) {
    +		if (device->last_buttons == 0) {
    +			if (device->last_click_time + device->click_speed > device->timestamp)
    +				device->click_count++;
    +			else
    +				device->click_count = 1;
    +		}
    +
    +		device->last_click_time = device->timestamp;
    +		info.clicks = device->click_count;
    +	}
    +
    +	device->last_buttons = info.buttons;
    +
     	info.timestamp = device->timestamp;
     	ring_buffer_write(device->rbuf, (const uint8*)&info, sizeof(info));
     	release_sem_etc(device->sem_cb, 1, B_DO_NOT_RESCHEDULE);
    @@ -579,8 +598,8 @@
     	callback: got a report, issue next request
     */
     static void 
    -usb_callback(void *cookie, uint32 busStatus,
    -	void *data, uint32 actualLength)
    +usb_callback(void *cookie, status_t busStatus,
    +	void *data, size_t actualLength)
     {
     	hid_device_info *device = cookie;
     	status_t status;
    @@ -615,7 +634,7 @@
     			sprintf (&linbuf[i*3], "%02X ", buffer [i]);
     		DPRINTF_INFO ((MY_ID "input report: %s\n", linbuf));
     #endif
    -		device->timestamp = system_time ();
    +		device->timestamp = system_time();
     		
     		if (device->is_keyboard) {
     			interpret_kb_buffer(device);
    @@ -650,7 +669,7 @@
     	status_t status;
     	usb_hid_descriptor *hid_desc;
     	uint8 *rep_desc = NULL;
    -	size_t desc_len, actual;
    +	size_t desc_len;
     	decomp_item *items;
     	size_t num_items;
     	int fd, report_id;
    @@ -962,6 +981,14 @@
             		return count;
           			break;
     			}
    +			case MS_SET_CLICKSPEED:
    +#ifdef __HAIKU__
    +				return user_memcpy(&device->click_speed, arg, sizeof(bigtime_t));
    +#else
    +				device->click_speed = *(bigtime_t *)arg;
    +				return B_OK;
    +#endif
    +
     			default:
     				/* not implemented */
     				break;
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h	2007-09-25 10:51:50 UTC (rev 22300)
    +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h	2007-09-25 12:43:34 UTC (rev 22301)
    @@ -19,6 +19,7 @@
     #include 
     #include 
     
    +#define DEBUG 1
     #if DEBUG
     	#define	DPRINTF_INFO(x)	dprintf x
     	#define	DPRINTF_ERR(x)	dprintf x
    @@ -85,6 +86,13 @@
     	uint flags;
     	bool is_keyboard;
     
    +	// double click (please move this into the input_server one day)
    +	uint32 last_buttons;
    +	uint32 click_count;
    +	bigtime_t click_speed;
    +	bigtime_t last_click_time;
    +
    +	// key repeats
     	struct hid_repeat_timer repeat_timer;
     	bigtime_t repeat_delay;
     	bigtime_t repeat_rate;
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 15:15:16 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 15:15:16 +0200
    Subject: [Haiku-commits] r22302 - haiku/trunk/src/kits/interface
    Message-ID: <200709251315.l8PDFGbT013311@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 15:15:15 +0200 (Tue, 25 Sep 2007)
    New Revision: 22302
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22302&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/Window.cpp
    Log:
    * Added private (as of now) B_HIDE_APPLICATION message that calls
      do_minimize_team() (which is what the Deskbar does when you select
      "Hide All").
    * Added keyboard shortcuts to minimize, and zoom a window, and to hide
      the whole application (Cmd+Ctrl+M/Z/H respectively). The former two
      are also present in Dano and up.
    
    
    Modified: haiku/trunk/src/kits/interface/Window.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/Window.cpp	2007-09-25 12:43:34 UTC (rev 22301)
    +++ haiku/trunk/src/kits/interface/Window.cpp	2007-09-25 13:15:15 UTC (rev 22302)
    @@ -47,7 +47,12 @@
     #	define STRACE(x) ;
     #endif
     
    +#define B_HIDE_APPLICATION '_AHD'
    +	// if we ever move this to a public namespace, we should also move the
    +	// handling of this message into BApplication
     
    +void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
    +
     struct BWindow::unpack_cookie {
     	unpack_cookie();
     
    @@ -686,7 +691,6 @@
     	BMessage replyMsg(B_REPLY);
     	bool handled = false;
     
    -	
     	BMessage specifier;
     	int32 what;
     	const char *prop;
    @@ -845,6 +849,10 @@
     			break;
     		}
     
    +		case B_HIDE_APPLICATION:
    +			do_minimize_team(BRect(), be_app->Team(), false);
    +			break;
    +
     		case B_WINDOW_RESIZED:
     		{
     			int32 width, height;
    @@ -2426,6 +2434,14 @@
     	AddShortcut('V', B_COMMAND_KEY, new BMessage(B_PASTE), NULL);
     	AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), NULL);
     
    +	// Window modifier keys
    +	AddShortcut('M', B_COMMAND_KEY | B_CONTROL_KEY,
    +		new BMessage(B_MINIMIZE), NULL);
    +	AddShortcut('Z', B_COMMAND_KEY | B_CONTROL_KEY,
    +		new BMessage(B_ZOOM), NULL);
    +	AddShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY,
    +		new BMessage(B_HIDE_APPLICATION), NULL);
    +
     	// We set the default pulse rate, but we don't start the pulse
     	fPulseRate = 500000;
     	fPulseRunner = NULL;
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 15:28:50 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 15:28:50 +0200
    Subject: [Haiku-commits] r22303 - haiku/trunk/src/apps/deskbar
    Message-ID: <200709251328.l8PDSoWk014048@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 15:28:50 +0200 (Tue, 25 Sep 2007)
    New Revision: 22303
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22303&view=rev
    
    Modified:
       haiku/trunk/src/apps/deskbar/Switcher.cpp
       haiku/trunk/src/apps/deskbar/Switcher.h
    Log:
    Added shortcut 'h' to the Switcher to hide applications.
    
    
    Modified: haiku/trunk/src/apps/deskbar/Switcher.cpp
    ===================================================================
    --- haiku/trunk/src/apps/deskbar/Switcher.cpp	2007-09-25 13:15:15 UTC (rev 22302)
    +++ haiku/trunk/src/apps/deskbar/Switcher.cpp	2007-09-25 13:28:50 UTC (rev 22303)
    @@ -984,6 +984,22 @@
     }
     
     
    +void
    +TSwitchManager::HideApp()
    +{
    +	// hide all teams in this group
    +
    +	TTeamGroup *teamGroup = (TTeamGroup *)fGroupList.ItemAt(fCurrentIndex);
    +
    +	for (int32 i = teamGroup->TeamList()->CountItems(); i-- > 0;) {
    +		team_id team = (team_id)teamGroup->TeamList()->ItemAt(i);
    +		app_info info;
    +		if (be_roster->GetRunningAppInfo(team, &info) == B_OK)
    +			do_minimize_team(BRect(), team, false);
    +	}
    +}
    +
    +
     window_info *
     TSwitchManager::WindowInfo(int32 groupIndex, int32 windowIndex)
     {
    @@ -1587,6 +1603,11 @@
     			fManager->QuitApp();
     			break;
     
    +		case 'h':
    +		case 'H':
    +			fManager->HideApp();
    +			break;
    +
     #if _ALLOW_STICKY_
     		case 's': 
     		case 'S':
    
    Modified: haiku/trunk/src/apps/deskbar/Switcher.h
    ===================================================================
    --- haiku/trunk/src/apps/deskbar/Switcher.h	2007-09-25 13:15:15 UTC (rev 22302)
    +++ haiku/trunk/src/apps/deskbar/Switcher.h	2007-09-25 13:28:50 UTC (rev 22303)
    @@ -64,6 +64,7 @@
     		int32 CountVisibleGroups();
     
     		void QuitApp();
    +		void HideApp();
     		void CycleApp(bool forward, bool activate = false);	
     		void CycleWindow(bool forward, bool wrap = true);	
     		void SwitchToApp(int32 prevIndex, int32 newIndex, bool forward);	
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 15:38:12 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 15:38:12 +0200
    Subject: [Haiku-commits] r22304 - haiku/trunk/src/kits/interface
    Message-ID: <200709251338.l8PDcCr9014904@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 15:38:10 +0200 (Tue, 25 Sep 2007)
    New Revision: 22304
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22304&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/Window.cpp
    Log:
    Made the private B_HIDE_APPLICATION message (now a misnomer) hide all applications
    that share the same signature - so that this feature is now consistent to what the
    Deskbar does.
    
    
    Modified: haiku/trunk/src/kits/interface/Window.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/Window.cpp	2007-09-25 13:28:50 UTC (rev 22303)
    +++ haiku/trunk/src/kits/interface/Window.cpp	2007-09-25 13:38:10 UTC (rev 22304)
    @@ -850,8 +850,21 @@
     		}
     
     		case B_HIDE_APPLICATION:
    -			do_minimize_team(BRect(), be_app->Team(), false);
    +		{
    +			// Hide all applications with the same signature
    +			// (ie. those that are part of the same group to be consistent
    +			// to what the Deskbar shows you).
    +			app_info info;
    +			be_app->GetAppInfo(&info);
    +
    +			BList list;
    +			be_roster->GetAppList(info.signature, &list);
    +
    +			for (int32 i = 0; i < list.CountItems(); i++) {
    +				do_minimize_team(BRect(), (team_id)list.ItemAt(i), false);
    +			}
     			break;
    +		}
     
     		case B_WINDOW_RESIZED:
     		{
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 16:16:18 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 16:16:18 +0200
    Subject: [Haiku-commits] r22305 -
    	haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid
    Message-ID: <200709251416.l8PEGIgZ017075@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 16:16:18 +0200 (Tue, 25 Sep 2007)
    New Revision: 22305
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22305&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c
       haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h
    Log:
    Accidently left debug output turned on; also updated copyright year.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c	2007-09-25 13:38:10 UTC (rev 22304)
    +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.c	2007-09-25 14:16:18 UTC (rev 22305)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004-2006, Haiku, Inc. All Rights Reserved.
    + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
      * Distributed under the terms of the MIT License.
      *
      * Authors:
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h	2007-09-25 13:38:10 UTC (rev 22304)
    +++ haiku/trunk/src/add-ons/kernel/drivers/input/usb_hid/hid.h	2007-09-25 14:16:18 UTC (rev 22305)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004-2006, Haiku, Inc. All Rights Reserved.
    + * Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
      * Distributed under the terms of the MIT License.
      *
      * Authors:
    @@ -19,7 +19,6 @@
     #include 
     #include 
     
    -#define DEBUG 1
     #if DEBUG
     	#define	DPRINTF_INFO(x)	dprintf x
     	#define	DPRINTF_ERR(x)	dprintf x
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 17:04:30 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 17:04:30 +0200
    Subject: [Haiku-commits] r22306 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/vm
    Message-ID: <200709251504.l8PF4Upq019769@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 17:04:29 +0200 (Tue, 25 Sep 2007)
    New Revision: 22306
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22306&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/vm_page.h
       haiku/trunk/headers/private/kernel/vm_types.h
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * Removed unused vm_page::busy_{reading|writing} fields.
    * Fixed vm_page_allocate_page_run(): it did not take the pageState into account,
      and would therefore return uninitialized memory (ie. B_CONTIGUOUS areas would
      contain garbage).
      Now, it stores if a page is cleared in a new vm_page::is_cleared field.
    * Some cleanup.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm_page.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_page.h	2007-09-25 14:16:18 UTC (rev 22305)
    +++ haiku/trunk/headers/private/kernel/vm_page.h	2007-09-25 15:04:29 UTC (rev 22306)
    @@ -37,7 +37,6 @@
     vm_page *vm_page_allocate_page(int state);
     status_t vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages);
     vm_page *vm_page_allocate_page_run(int state, addr_t length);
    -vm_page *vm_page_allocate_specific_page(addr_t page_num, int state);
     vm_page *vm_page_at_index(int32 index);
     vm_page *vm_lookup_page(addr_t pageNumber);
     
    
    Modified: haiku/trunk/headers/private/kernel/vm_types.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_types.h	2007-09-25 14:16:18 UTC (rev 22305)
    +++ haiku/trunk/headers/private/kernel/vm_types.h	2007-09-25 15:04:29 UTC (rev 22306)
    @@ -105,9 +105,10 @@
     
     	uint8				type : 2;
     	uint8				state : 3;
    -	uint8				busy_reading : 1;
    -	uint8				busy_writing : 1;
     
    +	uint8				is_cleared : 1;
    +		// is currently only used in vm_page_allocate_page_run()
    +
     	uint16				wired_count;
     	int8				usage_count;
     } vm_page;
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-25 14:16:18 UTC (rev 22305)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-25 15:04:29 UTC (rev 22306)
    @@ -4178,7 +4178,6 @@
     	dummyPage.cache = NULL;
     	dummyPage.state = PAGE_STATE_INACTIVE;
     	dummyPage.type = PAGE_TYPE_DUMMY;
    -	dummyPage.busy_writing = isWrite;
     	dummyPage.wired_count = 0;
     #ifdef DEBUG_PAGE_CACHE_TRANSITIONS
     	dummyPage.debug_flags = 0;
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-25 14:16:18 UTC (rev 22305)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-25 15:04:29 UTC (rev 22306)
    @@ -635,8 +635,6 @@
     						page->debug_flags |= 0x1;
     					if (consumerPage->type == PAGE_TYPE_DUMMY)
     						page->debug_flags |= 0x2;
    -					if (!consumerPage->busy_writing)
    -						page->debug_flags |= 0x4;
     					page->collided_page = consumerPage;
     					consumerPage->collided_page = page;
     #endif	// DEBUG_PAGE_CACHE_TRANSITIONS
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-25 14:16:18 UTC (rev 22305)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-25 15:04:29 UTC (rev 22306)
    @@ -916,29 +916,27 @@
     
     
     status_t
    -vm_mark_page_range_inuse(addr_t start_page, addr_t length)
    +vm_mark_page_range_inuse(addr_t startPage, addr_t length)
     {
    -	cpu_status state;
    -	vm_page *page;
    -	addr_t i;
    +	TRACE(("vm_mark_page_range_inuse: start 0x%lx, len 0x%lx\n",
    +		startPage, length));
     
    -	TRACE(("vm_mark_page_range_inuse: start 0x%lx, len 0x%lx\n", start_page, length));
    -
    -	if (sPhysicalPageOffset > start_page) {
    -		dprintf("vm_mark_page_range_inuse: start page %ld is before free list\n", start_page);
    +	if (sPhysicalPageOffset > startPage) {
    +		TRACE(("vm_mark_page_range_inuse: start page %ld is before free list\n",
    +			startPage));
     		return B_BAD_VALUE;
     	}
    -	start_page -= sPhysicalPageOffset;
    -	if (start_page + length > sNumPages) {
    -		dprintf("vm_mark_page_range_inuse: range would extend past free list\n");
    +	startPage -= sPhysicalPageOffset;
    +	if (startPage + length > sNumPages) {
    +		TRACE(("vm_mark_page_range_inuse: range would extend past free list\n"));
     		return B_BAD_VALUE;
     	}
     
    -	state = disable_interrupts();
    +	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageLock);
     
    -	for (i = 0; i < length; i++) {
    -		page = &sPages[start_page + i];
    +	for (addr_t i = 0; i < length; i++) {
    +		vm_page *page = &sPages[startPage + i];
     		switch (page->state) {
     			case PAGE_STATE_FREE:
     			case PAGE_STATE_CLEAR:
    @@ -953,7 +951,9 @@
     			case PAGE_STATE_UNUSED:
     			default:
     				// uh
    -				dprintf("vm_mark_page_range_inuse: page 0x%lx in non-free state %d!\n", start_page + i, page->state);
    +				dprintf("vm_mark_page_range_inuse: page 0x%lx in non-free state %d!\n",
    +					startPage + i, page->state);
    +				break;
     		}
     	}
     
    @@ -965,114 +965,67 @@
     
     
     vm_page *
    -vm_page_allocate_specific_page(addr_t page_num, int page_state)
    +vm_page_allocate_page(int pageState)
     {
    -	vm_page *p;
    -	int old_page_state = PAGE_STATE_BUSY;
    -	int state;
    +	page_queue *queue;
    +	page_queue *otherQueue;
     
    -	state = disable_interrupts();
    -	acquire_spinlock(&sPageLock);
    -
    -	p = vm_lookup_page(page_num);
    -	if (p == NULL)
    -		goto out;
    -
    -	switch (p->state) {
    +	switch (pageState) {
     		case PAGE_STATE_FREE:
    -			remove_page_from_queue(&sFreePageQueue, p);
    +			queue = &sFreePageQueue;
    +			otherQueue = &sClearPageQueue;
     			break;
     		case PAGE_STATE_CLEAR:
    -			remove_page_from_queue(&sClearPageQueue, p);
    +			queue = &sClearPageQueue;
    +			otherQueue = &sFreePageQueue;
     			break;
    -		case PAGE_STATE_UNUSED:
    -			break;
     		default:
    -			// we can't allocate this page
    -			p = NULL;
    -	}
    -	if (p == NULL)
    -		goto out;
    -
    -	old_page_state = p->state;
    -	p->state = PAGE_STATE_BUSY;
    -
    -	if (old_page_state != PAGE_STATE_UNUSED)
    -		enqueue_page(&sActivePageQueue, p);
    -
    -out:
    -	release_spinlock(&sPageLock);
    -	restore_interrupts(state);
    -
    -	if (p != NULL && page_state == PAGE_STATE_CLEAR
    -		&& (old_page_state == PAGE_STATE_FREE || old_page_state == PAGE_STATE_UNUSED))
    -		clear_page(p->physical_page_number * B_PAGE_SIZE);
    -
    -	return p;
    -}
    -
    -
    -vm_page *
    -vm_page_allocate_page(int page_state)
    -{
    -	vm_page *p;
    -	page_queue *q;
    -	page_queue *q_other;
    -	int state;
    -	int old_page_state;
    -
    -	switch (page_state) {
    -		case PAGE_STATE_FREE:
    -			q = &sFreePageQueue;
    -			q_other = &sClearPageQueue;
    -			break;
    -		case PAGE_STATE_CLEAR:
    -			q = &sClearPageQueue;
    -			q_other = &sFreePageQueue;
    -			break;
    -		default:
     			return NULL; // invalid
     	}
     
    -	state = disable_interrupts();
    +	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageLock);
     
    -	p = dequeue_page(q);
    -	if (p == NULL) {
    +	vm_page *page = dequeue_page(queue);
    +	if (page == NULL) {
     #ifdef DEBUG
    -		if (q->count != 0)
    -			panic("queue %p corrupted, count = %d\n", q, q->count);
    +		if (queue->count != 0)
    +			panic("queue %p corrupted, count = %d\n", queue, queue->count);
     #endif
     
     		// if the primary queue was empty, grap the page from the
     		// secondary queue
    -		p = dequeue_page(q_other);
    -		if (p == NULL) {
    +		page = dequeue_page(otherQueue);
    +		if (page == NULL) {
     #ifdef DEBUG
    -			if (q_other->count != 0)
    -				panic("other queue %p corrupted, count = %d\n", q_other, q_other->count);
    +			if (otherQueue->count != 0) {
    +				panic("other queue %p corrupted, count = %d\n", otherQueue,
    +					otherQueue->count);
    +			}
     #endif
     
    -			// ToDo: issue "someone" to free up some pages for us, and go into wait state until that's done
    -			panic("vm_allocate_page: out of memory! page state = %d\n", page_state);
    +			// ToDo: issue "someone" to free up some pages for us, and go into
    +			// wait state until that's done
    +			panic("vm_allocate_page: out of memory! page state = %d\n",
    +				pageState);
     		}
     	}
    -	if (p->cache != NULL)
    -		panic("supposed to be free page %p has cache\n", p);
    +	if (page->cache != NULL)
    +		panic("supposed to be free page %p has cache\n", page);
     
    -	old_page_state = p->state;
    -	p->state = PAGE_STATE_BUSY;
    +	int oldPageState = page->state;
    +	page->state = PAGE_STATE_BUSY;
     
    -	enqueue_page(&sActivePageQueue, p);
    +	enqueue_page(&sActivePageQueue, page);
     
     	release_spinlock(&sPageLock);
     	restore_interrupts(state);
     
     	// if needed take the page from the free queue and zero it out
    -	if (page_state == PAGE_STATE_CLEAR && old_page_state == PAGE_STATE_FREE)
    -		clear_page(p->physical_page_number * B_PAGE_SIZE);
    +	if (pageState == PAGE_STATE_CLEAR && oldPageState != PAGE_STATE_CLEAR)
    +		clear_page(page->physical_page_number * B_PAGE_SIZE);
     
    -	return p;
    +	return page;
     }
     
     
    @@ -1103,37 +1056,36 @@
     
     
     vm_page *
    -vm_page_allocate_page_run(int page_state, addr_t len)
    +vm_page_allocate_page_run(int pageState, addr_t length)
     {
    -	unsigned int start;
    -	unsigned int i;
    -	vm_page *first_page = NULL;
    -	int state;
    +	vm_page *firstPage = NULL;
    +	uint32 start = 0;
     
    -	start = 0;
    -
    -	state = disable_interrupts();
    +	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageLock);
     
     	for (;;) {
    -		bool foundit = true;
    -		if (start + len > sNumPages)
    +		bool foundRun = true;
    +		if (start + length > sNumPages)
     			break;
     
    -		for (i = 0; i < len; i++) {
    +		uint32 i;
    +		for (i = 0; i < length; i++) {
     			if (sPages[start + i].state != PAGE_STATE_FREE
     				&& sPages[start + i].state != PAGE_STATE_CLEAR) {
    -				foundit = false;
    +				foundRun = false;
     				i++;
     				break;
     			}
     		}
    -		if (foundit) {
    +		if (foundRun) {
     			// pull the pages out of the appropriate queues
    -			for (i = 0; i < len; i++) {
    +			for (i = 0; i < length; i++) {
    +				sPages[start + i].is_cleared
    +					= sPages[start + i].state == PAGE_STATE_CLEAR;
     				set_page_state_nolock(&sPages[start + i], PAGE_STATE_BUSY);
     			}
    -			first_page = &sPages[start];
    +			firstPage = &sPages[start];
     			break;
     		} else {
     			start += i;
    @@ -1142,7 +1094,16 @@
     	release_spinlock(&sPageLock);
     	restore_interrupts(state);
     
    -	return first_page;
    +	if (firstPage != NULL && pageState == PAGE_STATE_CLEAR) {
    +		for (uint32 i = 0; i < length; i++) {
    +			if (!sPages[start + i].is_cleared) {
    +	 			clear_page(sPages[start + i].physical_page_number
    +	 				* B_PAGE_SIZE);
    +			}
    +		}
    +	}
    +
    +	return firstPage;
     }
     
     
    @@ -1168,14 +1129,12 @@
     
     
     status_t
    -vm_page_set_state(vm_page *page, int page_state)
    +vm_page_set_state(vm_page *page, int pageState)
     {
    -	status_t status;
    -
     	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageLock);
     
    -	status = set_page_state_nolock(page, page_state);
    +	status_t status = set_page_state_nolock(page, pageState);
     
     	release_spinlock(&sPageLock);
     	restore_interrupts(state);
    
    
    
    From marcusoverhagen at mail.berlios.de  Tue Sep 25 17:37:57 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Tue, 25 Sep 2007 17:37:57 +0200
    Subject: [Haiku-commits] r22307 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709251537.l8PFbvaV022825@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-25 17:37:56 +0200 (Tue, 25 Sep 2007)
    New Revision: 22307
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22307&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    Cleanup of hard reset, works on Intel, doesn't work on Jmicron.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-25 15:04:29 UTC (rev 22306)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-25 15:37:56 UTC (rev 22307)
    @@ -223,12 +223,7 @@
     #if 1
     	fRegs->ghc |= GHC_HR;
     	FlushPostedWrites();
    -	for (int i = 0; i < 20; i++) {
    -		snooze(50000);
    -		if ((fRegs->ghc & GHC_HR) == 0)
    -			break;
    -	}
    -	if (fRegs->ghc & GHC_HR)
    +	if (wait_until_clear(&fRegs->ghc, GHC_HR, 1000000) < B_OK)
     		return B_TIMED_OUT;
     #else
     	fRegs->ghc &= ~GHC_AE;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-25 15:04:29 UTC (rev 22306)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-25 15:37:56 UTC (rev 22307)
    @@ -63,12 +63,14 @@
     	fCommandList[0].ctbau = HI32(physAddr);
     	// prdt follows after command table
     
    +	// disable transitions to partial or slumber state
    +	fRegs->sctl |= 0x300;
    +
     	// clear IRQ status bits
     	fRegs->is = fRegs->is;
     
     	// clear error bits
    -//	fRegs->serr = fRegs->serr;
    -	fRegs->serr = 0xffffffff;
    +	fRegs->serr = fRegs->serr;
     
     	// power up device
     	fRegs->cmd |= PORT_CMD_POD;
    @@ -102,7 +104,7 @@
     
     	FlushPostedWrites();
     
    -//	if (fRegs->sig == 0xffffffff)
    +	if (1 /* fRegs->sig == 0xffffffff */)
     		ResetDevice();
     
     	PostResetDevice();
    @@ -114,6 +116,7 @@
     	TRACE("sctl 0x%08lx\n", fRegs->sctl);
     	TRACE("serr 0x%08lx\n", fRegs->serr);
     	TRACE("sact 0x%08lx\n", fRegs->sact);
    +	TRACE("tfd  0x%08lx\n", fRegs->tfd);
     
     	return B_OK;
     }
    @@ -156,7 +159,6 @@
     }
     
     
    -
     status_t
     AHCIPort::ResetDevice()
     {
    @@ -173,9 +175,8 @@
     	// perform a hard reset
     	fRegs->sctl = (fRegs->sctl & ~0xf) | 1;
     	FlushPostedWrites();
    -	snooze(10000);
    +	spin(1100);
     	fRegs->sctl &= ~0xf;
    -	fRegs->serr = 0xffffffff;
     	FlushPostedWrites();
     
     	if (wait_until_set(&fRegs->ssts, 0x1, 100000) < B_OK) {
    @@ -183,8 +184,7 @@
     	}
     
     	// clear error bits
    -//	fRegs->serr = fRegs->serr;
    -	fRegs->serr = 0xffffffff;
    +	fRegs->serr = fRegs->serr;
     	FlushPostedWrites();
     
     	if (fRegs->ssts & 1) {
    @@ -194,7 +194,8 @@
     	}
     
     	// clear error bits
    -	fRegs->serr = 0xffffffff;
    +	fRegs->serr = fRegs->serr;
    +	FlushPostedWrites();
     
     	// start DMA engine
     	fRegs->cmd |= PORT_CMD_ST;
    @@ -209,25 +210,21 @@
     {
     	TRACE("AHCIPort::PostResetDevice port %d\n", fIndex);
     
    -	TRACE("tfd 1 0x%08lx\n", fRegs->tfd);
    +	if ((fRegs->ssts & 0xf) != 0x3 || (fRegs->tfd & 0xff) == 0x7f) {
    +		TRACE("AHCIPort::PostResetDevice port %d: no device\n", fIndex);
    +		return B_OK;
    +	}
     
    -	// wait for DMA idle ?
    -//	if (wait_until_clear(&fRegs->cmd, PORT_CMD_CR, 1000000) < B_OK) {
    -//		TRACE("AHCIPort::PostResetDevice port %d error DMA engine doesn't stop\n", fIndex);
    -//	}
    +	if ((fRegs->tfd & 0xff) == 0xff)
    +		snooze(200000);
     
    -	switch (fRegs->tfd & 0xff) {
    -		case 0x7f:
    -			TRACE("no device present?\n");
    -			break;
    -		case 0xff:
    -			TRACE("invalid task file status 0xff\n");
    -			// fall through
    -		default:
    -			TRACE("waiting...\n");
    -			wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 31000000);
    +	if ((fRegs->tfd & 0xff) == 0xff) {
    +		TRACE("AHCIPort::PostResetDevice port %d: invalid task file status 0xff\n", fIndex);
    +		return B_ERROR;
     	}
     
    +	wait_until_clear(&fRegs->tfd, ATA_BSY, 31000000);
    +
     	if (fRegs->sig == 0xeb140101)
     		fRegs->cmd |= PORT_CMD_ATAPI;
     	else
    @@ -237,14 +234,23 @@
     	TRACE("device signature 0x%08lx (%s)\n", fRegs->sig,
     		(fRegs->sig == 0xeb140101) ? "ATAPI" : (fRegs->sig == 0x00000101) ? "ATA" : "unknown");
     
    -	TRACE("tfd 0x%08lx\n", fRegs->tfd);
    -	TRACE("device detection: 0x%lx\n", fRegs->ssts & 0xf);
    -
     	return B_OK;
     }
     
     
     void
    +AHCIPort::DumpD2HFis()
    +{
    +	TRACE("D2H FIS:\n");
    +	TRACE("  DW0  %02x %02x %02x %02x\n", fFIS->rfis[3], fFIS->rfis[2], fFIS->rfis[1], fFIS->rfis[0]);
    +	TRACE("  DW1  %02x %02x %02x %02x\n", fFIS->rfis[7], fFIS->rfis[6], fFIS->rfis[5], fFIS->rfis[4]);
    +	TRACE("  DW2  %02x %02x %02x %02x\n", fFIS->rfis[11], fFIS->rfis[10], fFIS->rfis[9], fFIS->rfis[8]);
    +	TRACE("  DW3  %02x %02x %02x %02x\n", fFIS->rfis[15], fFIS->rfis[14], fFIS->rfis[13], fFIS->rfis[12]);
    +	TRACE("  DW4  %02x %02x %02x %02x\n", fFIS->rfis[19], fFIS->rfis[18], fFIS->rfis[17], fFIS->rfis[16]);
    +}
    +
    +
    +void
     AHCIPort::Interrupt()
     {
     	uint32 is = fRegs->is;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-25 15:04:29 UTC (rev 22306)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-25 15:37:56 UTC (rev 22307)
    @@ -30,6 +30,7 @@
     	status_t	ResetDevice();
     	status_t	PostResetDevice();
     	void		FlushPostedWrites();
    +	void		DumpD2HFis();
     
     private:
     	int						fIndex;
    
    
    
    From axeld at mail.berlios.de  Tue Sep 25 18:41:54 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Tue, 25 Sep 2007 18:41:54 +0200
    Subject: [Haiku-commits] r22308 - in haiku/trunk: headers/private/kernel
    	src/system/kernel
    Message-ID: <200709251641.l8PGfsFL023013@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-25 18:41:52 +0200 (Tue, 25 Sep 2007)
    New Revision: 22308
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22308&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/lock.h
       haiku/trunk/src/system/kernel/lock.c
    Log:
    * Added a mutex_trylock() function.
    * Replaced release_sem() with release_sem_etc() for future addition of the
      B_DO_NOT_RESCHEDULE flag.
    
    
    Modified: haiku/trunk/headers/private/kernel/lock.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/lock.h	2007-09-25 15:37:56 UTC (rev 22307)
    +++ haiku/trunk/headers/private/kernel/lock.h	2007-09-25 16:41:52 UTC (rev 22308)
    @@ -61,6 +61,7 @@
     
     extern status_t	mutex_init(mutex *m, const char *name);
     extern void mutex_destroy(mutex *m);
    +extern status_t mutex_trylock(mutex *mutex);
     extern status_t mutex_lock(mutex *m);
     extern void mutex_unlock(mutex *m);
     
    
    Modified: haiku/trunk/src/system/kernel/lock.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/lock.c	2007-09-25 15:37:56 UTC (rev 22307)
    +++ haiku/trunk/src/system/kernel/lock.c	2007-09-25 16:41:52 UTC (rev 22308)
    @@ -87,7 +87,7 @@
     
     	if (--lock->recursion == 0) {
     		lock->holder = -1;
    -		release_sem(lock->sem);
    +		release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
     	}
     }
     
    @@ -129,6 +129,29 @@
     
     
     status_t
    +mutex_trylock(mutex *mutex)
    +{
    +	thread_id me = thread_get_current_thread_id();
    +	status_t status;
    +
    +	if (kernel_startup)
    +		return B_OK;
    +
    +	status = acquire_sem_etc(mutex->sem, 1, B_RELATIVE_TIMEOUT, 0);
    +	if (status < B_OK)
    +		return status;
    +
    +	if (me == mutex->holder) {
    +		panic("mutex_trylock failure: mutex %p (sem = 0x%lx) acquired twice by"
    +			" thread 0x%lx\n", mutex, mutex->sem, me);
    +	}
    +
    +	mutex->holder = me;
    +	return B_OK;
    +}
    +
    +
    +status_t
     mutex_lock(mutex *mutex)
     {
     	thread_id me = thread_get_current_thread_id();
    @@ -165,7 +188,7 @@
     	}
     
     	mutex->holder = -1;
    -	release_sem(mutex->sem);
    +	release_sem_etc(mutex->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
     }
     
     
    @@ -235,7 +258,7 @@
     status_t
     rw_lock_read_unlock(rw_lock *lock)
     {
    -	return release_sem(lock->sem);
    +	return release_sem_etc(lock->sem, 1, 0/*B_DO_NOT_RESCHEDULE*/);
     }
     
     
    
    
    
    From korli at mail.berlios.de  Tue Sep 25 19:41:26 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Tue, 25 Sep 2007 19:41:26 +0200
    Subject: [Haiku-commits] r22309 -
    	haiku/trunk/src/add-ons/kernel/bus_managers/firewire
    Message-ID: <200709251741.l8PHfQio012426@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-25 19:41:26 +0200 (Tue, 25 Sep 2007)
    New Revision: 22309
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22309&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/bus_managers/firewire/firewire_module.c
       haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c
    Log:
    changed pci to gPci, plus some clean
    
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/firewire_module.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/firewire_module.c	2007-09-25 16:41:52 UTC (rev 22308)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/firewire_module.c	2007-09-25 17:41:26 UTC (rev 22309)
    @@ -32,7 +32,7 @@
     pci_info *pciInfo[MAX_CARDS];
     fwohci_softc_t *gFwohci_softc[MAX_CARDS];
     struct firewire_softc *gFirewire_softc[MAX_CARDS];
    -pci_module_info	*pci;
    +pci_module_info	*gPci;
     dpc_module_info *gDpc;
     
     struct supported_device{
    @@ -74,7 +74,8 @@
     };
     
     
    -static int find_device_name(pci_info *info)
    +static int 
    +find_device_name(pci_info *info)
     {
     	struct supported_device *device;
     	for (device = supported_devices; device->name; device++) {
    @@ -148,7 +149,7 @@
     	if (!info)
     		return B_NO_MEMORY;
     	
    -	if ((status = get_module(B_PCI_MODULE_NAME,(module_info **)&pci)) != B_OK) {
    +	if ((status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPci)) != B_OK) {
     		TRACE("pci module unavailable\n");
     		free(info);
     		return status;
    @@ -164,7 +165,7 @@
     	memset(gFwohci_softc, 0, sizeof(gFwohci_softc));
     
     	// find devices
    -	for (i = 0, found = 0; (status = pci->get_nth_pci_info(i, info)) == B_OK; i++) {
    +	for (i = 0, found = 0; (status = gPci->get_nth_pci_info(i, info)) == B_OK; i++) {
     		if (find_device_name(info)
     				|| ((info->class_base == PCI_serial_bus)
     					&& (info->class_sub == PCI_firewire)
    @@ -203,9 +204,6 @@
     	TRACE("found %d cards\n", found);
     	free(info);
     
    -//	if (!found)
    -//		goto err_found;
    -
     	if ((status = initialize_timer()) != B_OK) {
     		ERROR("timer init failed\n");
     		goto err_timer;
    @@ -222,7 +220,6 @@
     err_pci:
     	terminate_timer();
     err_timer:
    -err_found:
     err_outofmem:
     	for (i = 0; i < found; i++) {
     		free(gFirewire_softc[i]);
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c	2007-09-25 16:41:52 UTC (rev 22308)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c	2007-09-25 17:41:26 UTC (rev 22309)
    @@ -61,7 +61,7 @@
     #define	PCIM_CMD_BUSMASTEREN	0x0004
     #define	PCIM_CMD_MWRICEN	0x0010
     #define PCIM_CMD_IOS		0x0001 
    -extern pci_module_info	*pci;
    +extern pci_module_info	*gPci;
     extern pci_info *pciInfo[MAX_CARDS];
     extern fwohci_softc_t *gFwohci_softc[MAX_CARDS];
     extern struct firewire_softc *gFirewire_softc[MAX_CARDS];
    @@ -143,14 +143,14 @@
     
     	mtx_init(FW_GMTX(&sc->fc), "firewire", NULL, MTX_DEF);
     
    -	val = pci->read_pci_config(info->bus, info->device, info->function, 
    +	val = gPci->read_pci_config(info->bus, info->device, info->function, 
     			PCI_command, 2);
     	val |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_MWRICEN;
     
     #if 1  /* for broken hardware */
     	val &= ~PCIM_CMD_MWRICEN; 
     #endif
    -	pci->write_pci_config(info->bus, info->device, info->function, 
    +	gPci->write_pci_config(info->bus, info->device, info->function, 
     			PCI_command, 2, val);
     
     	/*
    @@ -161,28 +161,28 @@
     			info->u.h0.interrupt_pin == 0)
     		info->u.h0.interrupt_pin = 3;
     
    -	latency = olatency = pci->read_pci_config(info->bus, info->device, info->function, 
    +	latency = olatency = gPci->read_pci_config(info->bus, info->device, info->function, 
     			PCI_latency, 1);
     #define DEF_LATENCY 0x20
     	if (olatency < DEF_LATENCY) {
     		latency = DEF_LATENCY;
    -		pci->write_pci_config(info->bus, info->device, info->function, 
    +		gPci->write_pci_config(info->bus, info->device, info->function, 
     				PCI_latency, 1, latency);
     	}
     
    -	cache_line = ocache_line = pci->read_pci_config(info->bus, info->device, 
    +	cache_line = ocache_line = gPci->read_pci_config(info->bus, info->device, 
     			info->function, PCI_line_size, 1);
     #define DEF_CACHE_LINE 8
     	if (ocache_line < DEF_CACHE_LINE) {
     		cache_line = DEF_CACHE_LINE;
    -		pci->write_pci_config(info->bus, info->device, info->function, 
    +		gPci->write_pci_config(info->bus, info->device, info->function, 
     				PCI_line_size, 1, cache_line);
     	}
     	TRACE("latency timer %x -> %x.\n", olatency, latency);
     	TRACE("cache size %x -> %x.\n",	ocache_line, cache_line);
     
     	// get IRQ
    -	sc->irq = pci->read_pci_config(info->bus, info->device, info->function, 
    +	sc->irq = gPci->read_pci_config(info->bus, info->device, info->function, 
     			PCI_interrupt_line, 1);
     	if (sc->irq == 0 || sc->irq == 0xff) {
     		ERROR("no IRQ assigned\n");
    @@ -191,7 +191,7 @@
     	TRACE("IRQ %d\n", sc->irq);
     
     	// map registers into memory
    -//	val = pci->read_pci_config(info->bus, info->device, info->function, 0x14, 4);
    +//	val = gPci->read_pci_config(info->bus, info->device, info->function, 0x14, 4);
     //	val &= PCI_address_memory_32_mask;
     //	TRACE("hardware register address %p\n", (void *) val);
     	TRACE("hardware register address %x\n", info->u.h0.base_registers[0]);
    
    
    
    From korli at mail.berlios.de  Tue Sep 25 19:42:19 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Tue, 25 Sep 2007 19:42:19 +0200
    Subject: [Haiku-commits] r22310 - haiku/trunk/src/bin/ctags
    Message-ID: <200709251742.l8PHgJHX012562@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-25 19:42:11 +0200 (Tue, 25 Sep 2007)
    New Revision: 22310
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22310&view=rev
    
    Added:
       haiku/trunk/src/bin/ctags/MAINTAINERS
       haiku/trunk/src/bin/ctags/basic.c
    Removed:
       haiku/trunk/src/bin/ctags/.indent.pro
       haiku/trunk/src/bin/ctags/ctags.lsm
       haiku/trunk/src/bin/ctags/testing.mak
    Modified:
       haiku/trunk/src/bin/ctags/EXTENDING.html
       haiku/trunk/src/bin/ctags/Jamfile
       haiku/trunk/src/bin/ctags/Makefile.in
       haiku/trunk/src/bin/ctags/NEWS
       haiku/trunk/src/bin/ctags/acconfig.h
       haiku/trunk/src/bin/ctags/argproc.c
       haiku/trunk/src/bin/ctags/args.c
       haiku/trunk/src/bin/ctags/args.h
       haiku/trunk/src/bin/ctags/asm.c
       haiku/trunk/src/bin/ctags/asp.c
       haiku/trunk/src/bin/ctags/awk.c
       haiku/trunk/src/bin/ctags/beta.c
       haiku/trunk/src/bin/ctags/c.c
       haiku/trunk/src/bin/ctags/cobol.c
       haiku/trunk/src/bin/ctags/config.h.in
       haiku/trunk/src/bin/ctags/configure
       haiku/trunk/src/bin/ctags/configure.in
       haiku/trunk/src/bin/ctags/ctags.1
       haiku/trunk/src/bin/ctags/ctags.h
       haiku/trunk/src/bin/ctags/ctags.html
       haiku/trunk/src/bin/ctags/ctags.spec
       haiku/trunk/src/bin/ctags/debug.c
       haiku/trunk/src/bin/ctags/debug.h
       haiku/trunk/src/bin/ctags/descrip.mms
       haiku/trunk/src/bin/ctags/e_amiga.h
       haiku/trunk/src/bin/ctags/e_djgpp.h
       haiku/trunk/src/bin/ctags/e_mac.h
       haiku/trunk/src/bin/ctags/e_msoft.h
       haiku/trunk/src/bin/ctags/e_os2.h
       haiku/trunk/src/bin/ctags/e_qdos.h
       haiku/trunk/src/bin/ctags/e_riscos.h
       haiku/trunk/src/bin/ctags/e_vms.h
       haiku/trunk/src/bin/ctags/eiffel.c
       haiku/trunk/src/bin/ctags/entry.c
       haiku/trunk/src/bin/ctags/entry.h
       haiku/trunk/src/bin/ctags/erlang.c
       haiku/trunk/src/bin/ctags/fortran.c
       haiku/trunk/src/bin/ctags/general.h
       haiku/trunk/src/bin/ctags/get.c
       haiku/trunk/src/bin/ctags/get.h
       haiku/trunk/src/bin/ctags/html.c
       haiku/trunk/src/bin/ctags/jscript.c
       haiku/trunk/src/bin/ctags/keyword.c
       haiku/trunk/src/bin/ctags/keyword.h
       haiku/trunk/src/bin/ctags/lisp.c
       haiku/trunk/src/bin/ctags/lregex.c
       haiku/trunk/src/bin/ctags/lua.c
       haiku/trunk/src/bin/ctags/mac.c
       haiku/trunk/src/bin/ctags/main.c
       haiku/trunk/src/bin/ctags/main.h
       haiku/trunk/src/bin/ctags/maintainer.mak
       haiku/trunk/src/bin/ctags/make.c
       haiku/trunk/src/bin/ctags/mk_bc3.mak
       haiku/trunk/src/bin/ctags/mk_bc5.mak
       haiku/trunk/src/bin/ctags/mk_djg.mak
       haiku/trunk/src/bin/ctags/mk_manx.mak
       haiku/trunk/src/bin/ctags/mk_ming.mak
       haiku/trunk/src/bin/ctags/mk_mpw.mak
       haiku/trunk/src/bin/ctags/mk_mvc.mak
       haiku/trunk/src/bin/ctags/mk_os2.mak
       haiku/trunk/src/bin/ctags/mk_qdos.mak
       haiku/trunk/src/bin/ctags/mk_sas.mak
       haiku/trunk/src/bin/ctags/mkinstalldirs
       haiku/trunk/src/bin/ctags/options.c
       haiku/trunk/src/bin/ctags/options.h
       haiku/trunk/src/bin/ctags/parse.c
       haiku/trunk/src/bin/ctags/parse.h
       haiku/trunk/src/bin/ctags/parsers.h
       haiku/trunk/src/bin/ctags/pascal.c
       haiku/trunk/src/bin/ctags/perl.c
       haiku/trunk/src/bin/ctags/php.c
       haiku/trunk/src/bin/ctags/python.c
       haiku/trunk/src/bin/ctags/qdos.c
       haiku/trunk/src/bin/ctags/read.c
       haiku/trunk/src/bin/ctags/read.h
       haiku/trunk/src/bin/ctags/readtags.c
       haiku/trunk/src/bin/ctags/readtags.h
       haiku/trunk/src/bin/ctags/rexx.c
       haiku/trunk/src/bin/ctags/routines.c
       haiku/trunk/src/bin/ctags/routines.h
       haiku/trunk/src/bin/ctags/ruby.c
       haiku/trunk/src/bin/ctags/scheme.c
       haiku/trunk/src/bin/ctags/sh.c
       haiku/trunk/src/bin/ctags/slang.c
       haiku/trunk/src/bin/ctags/sml.c
       haiku/trunk/src/bin/ctags/sort.c
       haiku/trunk/src/bin/ctags/sort.h
       haiku/trunk/src/bin/ctags/source.mak
       haiku/trunk/src/bin/ctags/sql.c
       haiku/trunk/src/bin/ctags/strlist.c
       haiku/trunk/src/bin/ctags/strlist.h
       haiku/trunk/src/bin/ctags/tcl.c
       haiku/trunk/src/bin/ctags/verilog.c
       haiku/trunk/src/bin/ctags/vim.c
       haiku/trunk/src/bin/ctags/vstring.c
       haiku/trunk/src/bin/ctags/vstring.h
       haiku/trunk/src/bin/ctags/yacc.c
    Log:
    updated ctags to 5.7
    
    
    Deleted: haiku/trunk/src/bin/ctags/.indent.pro
    
    Modified: haiku/trunk/src/bin/ctags/EXTENDING.html
    ===================================================================
    --- haiku/trunk/src/bin/ctags/EXTENDING.html	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/EXTENDING.html	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,4 +1,4 @@
    -
    +
     
     
     Exuberant Ctags: Adding support for a new language
    
    Modified: haiku/trunk/src/bin/ctags/Jamfile
    ===================================================================
    --- haiku/trunk/src/bin/ctags/Jamfile	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/Jamfile	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -11,6 +11,7 @@
     	asm.c
     	asp.c
     	awk.c
    +	basic.c
     	beta.c
     	c.c
     	cobol.c
    
    Added: haiku/trunk/src/bin/ctags/MAINTAINERS
    ===================================================================
    --- haiku/trunk/src/bin/ctags/MAINTAINERS	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/MAINTAINERS	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -0,0 +1,19 @@
    +The following individuals are registered as developers for the maintenance of
    +Exuberant Ctags. They are listed by their SourgeForge username and by the
    +To send email to any one of them, send it to .
    +
    +Ctags           SourgeForge     Full
    +Parser          username        Name
    +----------      -----------     -----
    +AWK             jkoshy          Joseph Koshy
    +Basic           elias           Elias Pschernig
    +Java            elliotth        Elliott Hughes
    +JavaScript      dfishburn       David Fishburn
    +Perl            perlguy0        Dmitri Tikhonov
    +PHP             jafl            John Lindal
    +Python          elias           Elias Pschernig
    +Ruby            elliotth        Elliott Hughes
    +SML             jkoshy          Joseph Koshy
    +SQL             dfishburn       David Fishburn
    +Vim             dfishburn       David Fishburn
    +All else        dhiebert        Darren Hiebert
    
    Modified: haiku/trunk/src/bin/ctags/Makefile.in
    ===================================================================
    --- haiku/trunk/src/bin/ctags/Makefile.in	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/Makefile.in	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,4 +1,4 @@
    -# $Id: Makefile.in,v 1.8 2003/07/27 22:09:58 darren Exp $
    +# $Id: Makefile.in 359 2003-07-27 22:09:58Z darren $
     #
     # Makefile for UNIX-like platforms.
     #
    
    Modified: haiku/trunk/src/bin/ctags/NEWS
    ===================================================================
    --- haiku/trunk/src/bin/ctags/NEWS	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/NEWS	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,50 @@
    -Current Version: 5.6
    +Current Version: 5.7
     
    +ctags-5.7 (04 Sep 2007)
    +* Added support for DIM AS [Freebasic, Bug #1741778].
    +* Added support for arbitrary nesting depth [Python, Bug #1684786, Debian bug #409078].
    +* Added support for verbatim string literals [C#, Bug #1515910].
    +* Added support for .ctags as well as ctags.cnf on Windows [Bug #1246506].
    +* Added support for non-extern, non-static functions returning wchar_t, contributed by Aaron Peromsik [C++, Patch #1458930].
    +* Added support for numerous revision control systems including Bazaar and Mercurial [Bug #1472894].
    +* Added support for enums [Java, Bug #1730485, Bug #1517143, Patch #1027395, Patch #1528507].
    +* Added support for multiple-level namespace declarations [C#].
    +* Added .svn to list of directories ignored during recursion (--recurse).
    +* Added support for BlitzBasic, PureBasic and FreeBasic [FR #1100506].
    +* Added support for interfaces and static/public/protected/private functions [PHP].
    +* Added support for 'package' keyword [Perl].
    +* Added support for multi-line subroutine, package, and constant definitions [Perl].
    +* Added support for optional subroutine declarations [Perl].
    +* Added support for formats [Perl].
    +* Added support for new convert keyword [Eiffel].
    +* Added optional tags for forward variable declarations (e.g. 'struct C;') [C, C++].
    +* Changed parsing of option input file (-L) to strip trailing white space.
    +* Ignore comments mixed into definitions and declarations [Perl].
    +* Fixed detecting labels with whitespace after label name [Perl, Bug #1752361]
    +* Fixed parsing of generic classes/interfaces [Java, Bug #1447756].
    +* Fixed misidentification of fully qualified function calls as labels [Perl].
    +* Fixed parsing of inner classes [Python, Bug #1411963].
    +* Fixed line continuation [Python, Bug #928001, Patch #819471].
    +* Fixed parsing of annotations [Java, Bug #1691412].
    +* Fixed block-comment parsing [Verilog, Patch #1458042, Bugs #960316, #1111214, #1606569, #1615060].
    +* Fixed typo in man page [Debian bug #366412].
    +* Fixed missing chunk of text in man page and over-use of hyphens in UTF-8 locales [Debian bug #271323].
    +* Fixed parsing of ` as a method name [Ruby].
    +* Fixed parsing of keywords in string literals [Ruby, Bug #1742588].
    +* Fixed potential segmentation violation [Bug #1672834, Bug #1222926].
    +* Fixed parsing of destructors with whitespace after the '~' [C++, Bug #1585745].
    +* Fixed default access of unions to be public [C++, Bug #1548443].
    +* Fixed various memory leaks, mostly contributed by Dmitry Antipov.
    +* Fixed parsing of `define [Verilog, Bug #961001].
    +* Fixed crashes involving '/' [Verilog, Bug #1743330].
    +* Fixed compilation problem on MinGW [Bug #1517424].
    +* Fixed generation of HTML-formatted man page [Bug #1645864].
    +* Fixed recognition of Python scripts having '#!/usr/bin/python' as first line [Bug #1764148].
    +* Fixed parsing of Fortran comment-to-end-of-line with no newline before EOF [Debian bug #432872].
    +* Fixed parsing of << [C/C++, Bugs #1020715, #1093123, #1770479, #1770607].
    +* Fixed parsing of fully-qualified type names [Java, Bug #814263].
    +* Fixed handling of lone carriage-return characters in file [Bug #1773926].
    +
     ctags-5.6 (Mon May 29 2006)
     * Reformatted code for independence of tab stop setting.
     * Changed default configuration to disable installation of etags links.
    @@ -9,7 +54,7 @@
     * Added .mk as extension recognized as a make language file [Make].
     * Added missing help for list-maps options [Bug #1201826].
     * Added new extension field "typeref" [thanks to Bram Moolenaar].
    -* Extended functionality of Ruby parser with patch from Elliot Hughes [Ruby].
    +* Extended functionality of Ruby parser with patch from Elliott Hughes [Ruby].
     * Fixed creation of TAGS file with etags-include but no files [Bug #941233].
     * Fixed problem reading last line of list file (-L) without final newline.
     * Fixed infinite loop that could occur on files without final newline [C, Java].
    
    Modified: haiku/trunk/src/bin/ctags/acconfig.h
    ===================================================================
    --- haiku/trunk/src/bin/ctags/acconfig.h	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/acconfig.h	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: acconfig.h,v 1.4 2003/04/01 05:02:21 darren Exp $
    +*   $Id: acconfig.h 318 2003-04-01 05:02:21Z darren $
     *
     *   Copyright (c) 1998-2003, Darren Hiebert
     *
    
    Modified: haiku/trunk/src/bin/ctags/argproc.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/argproc.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/argproc.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: argproc.c,v 1.2 2006/05/30 04:37:11 darren Exp $
    +*   $Id: argproc.c 443 2006-05-30 04:37:13Z darren $
     *
     *   Copyright (c) 1989, Mark Pizzolato (mark at infopiz.uucp)
     *
    
    Modified: haiku/trunk/src/bin/ctags/args.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/args.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/args.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: args.c,v 1.7 2006/05/30 04:37:11 darren Exp $
    +*   $Id: args.c 536 2007-06-02 06:09:00Z elliotth $
     *
     *   Copyright (c) 1999-2002, Darren Hiebert
     *
    @@ -147,10 +147,11 @@
     					c = ungetc (c, fp);
     			}
     			vStringTerminate (vs);
    +			vStringStripTrailing (vs);
     			result = xMalloc (vStringLength (vs) + 1, char);
     			strcpy (result, vStringValue (vs));
    -			vStringDelete (vs);
     		}
    +		vStringDelete (vs);
     	}
     	return result;
     }
    
    Modified: haiku/trunk/src/bin/ctags/args.h
    ===================================================================
    --- haiku/trunk/src/bin/ctags/args.h	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/args.h	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: args.h,v 1.5 2006/05/30 04:37:11 darren Exp $
    +*   $Id: args.h 443 2006-05-30 04:37:13Z darren $
     *
     *   Copyright (c) 1999-2002, Darren Hiebert
     *
    
    Modified: haiku/trunk/src/bin/ctags/asm.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/asm.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/asm.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: asm.c,v 1.18 2006/05/30 04:37:11 darren Exp $
    +*   $Id: asm.c 536 2007-06-02 06:09:00Z elliotth $
     *
     *   Copyright (c) 2000-2003, Darren Hiebert
     *
    @@ -129,13 +129,12 @@
     
     static opKeyword analyzeOperator (const vString *const op)
     {
    -	static vString *keyword = NULL;
    -	opKeyword result = OP_UNDEFINED;
    +	vString *keyword = vStringNew ();
    +	opKeyword result;
     
    -	if (keyword == NULL)
    -		keyword = vStringNew ();
     	vStringCopyToLower (keyword, op);
     	result = (opKeyword) lookupKeyword (vStringValue (keyword), Lang_asm);
    +	vStringDelete (keyword);
     	return result;
     }
     
    
    Modified: haiku/trunk/src/bin/ctags/asp.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/asp.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/asp.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: asp.c,v 1.8 2006/05/30 04:37:11 darren Exp $
    +*   $Id: asp.c 443 2006-05-30 04:37:13Z darren $
     *
     *   Copyright (c) 2000, Patrick Dehne 
     *
    
    Modified: haiku/trunk/src/bin/ctags/awk.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/awk.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/awk.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: awk.c,v 1.3 2006/05/30 04:37:11 darren Exp $
    +*   $Id: awk.c 443 2006-05-30 04:37:13Z darren $
     *
     *   Copyright (c) 2000-2002, Darren Hiebert
     *
    
    Added: haiku/trunk/src/bin/ctags/basic.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/basic.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/basic.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -0,0 +1,203 @@
    +/*
    + *   $Id:$
    + *
    + *   Copyright (c) 2000-2006, Darren Hiebert, Elias Pschernig
    + *
    + *   This source code is released for free distribution under the terms of the
    + *   GNU General Public License.
    + *
    + *   This module contains functions for generating tags for BlitzBasic
    + *   (BlitzMax), PureBasic and FreeBasic language files. For now, this is kept
    + *   quite simple - but feel free to ask for more things added any time -
    + *   patches are of course most welcome.
    + */
    +
    +/*
    + *   INCLUDE FILES
    + */
    +#include "general.h" /* must always come first */
    +
    +#include 
    +
    +#include "options.h"
    +#include "parse.h"
    +#include "read.h"
    +#include "routines.h"
    +#include "vstring.h"
    +
    +/*
    + *   DATA DEFINITIONS
    + */
    +typedef enum {
    +	K_CONST,
    +	K_FUNCTION,
    +	K_LABEL,
    +	K_TYPE,
    +	K_VARIABLE,
    +	K_ENUM
    +} BasicKind;
    +
    +typedef struct {
    +	char const *token;
    +	BasicKind kind;
    +	int skip;
    +} KeyWord;
    +
    +static kindOption BasicKinds[] = {
    +	{TRUE, 'c', "constant", "constants"},
    +	{TRUE, 'f', "function", "functions"},
    +	{TRUE, 'l', "label", "labels"},
    +	{TRUE, 't', "type", "types"},
    +	{TRUE, 'v', "variable", "variables"},
    +	{TRUE, 'g', "enum", "enumerations"}
    +};
    +
    +static KeyWord blitzbasic_keywords[] = {
    +	{"const", K_CONST, 0},
    +	{"global", K_VARIABLE, 0},
    +	{"dim", K_VARIABLE, 0},
    +	{"function", K_FUNCTION, 0},
    +	{"type", K_TYPE, 0},
    +	{NULL, 0, 0}
    +};
    +
    +static KeyWord purebasic_keywords[] = {
    +	{"newlist", K_VARIABLE, 0},
    +	{"global", K_VARIABLE, 0},
    +	{"dim", K_VARIABLE, 0},
    +	{"procedure", K_FUNCTION, 0},
    +	{"interface", K_TYPE, 0},
    +	{"structure", K_TYPE, 0},
    +	{NULL, 0, 0}
    +};
    +
    +static KeyWord freebasic_keywords[] = {
    +	{"const", K_CONST, 0},
    +	{"dim as", K_VARIABLE, 1},
    +	{"dim", K_VARIABLE, 0},
    +	{"common", K_VARIABLE, 0},
    +	{"function", K_FUNCTION, 0},
    +	{"sub", K_FUNCTION, 0},
    +	{"private sub", K_FUNCTION, 0},
    +	{"public sub", K_FUNCTION, 0},
    +	{"private function", K_FUNCTION, 0},
    +	{"public function", K_FUNCTION, 0},
    +	{"type", K_TYPE, 0},
    +	{"enum", K_ENUM, 0},
    +	{NULL, 0, 0}
    +};
    +
    +/*
    + *   FUNCTION DEFINITIONS
    + */
    +
    +/* Match the name of a tag (function, variable, type, ...) starting at pos. */
    +static char const *extract_name (char const *pos, vString * name)
    +{
    +	while (isspace (*pos))
    +		pos++;
    +	vStringClear (name);
    +	for (; *pos && !isspace (*pos) && *pos != '(' && *pos != ','; pos++)
    +		vStringPut (name, *pos);
    +	vStringTerminate (name);
    +	return pos;
    +}
    +
    +/* Match a keyword starting at p (case insensitive). */
    +static int match_keyword (const char *p, KeyWord const *kw)
    +{
    +	vString *name;
    +	size_t i;
    +	int j;
    +	for (i = 0; i < strlen (kw->token); i++)
    +	{
    +		if (tolower (p[i]) != kw->token[i])
    +			return 0;
    +	}
    +	name = vStringNew ();
    +	p += i;
    +	for (j = 0; j < 1 + kw->skip; j++)
    +	{
    +		p = extract_name (p, name);
    +	}	
    +	makeSimpleTag (name, BasicKinds, kw->kind);
    +	vStringDelete (name);
    +	return 1;
    +}
    +
    +/* Match a "label:" style label. */
    +static void match_colon_label (char const *p)
    +{
    +	char const *end = p + strlen (p) - 1;
    +	while (isspace (*end))
    +		end--;
    +	if (*end == ':')
    +	{
    +		vString *name = vStringNew ();
    +		vStringNCatS (name, p, end - p);
    +		makeSimpleTag (name, BasicKinds, K_LABEL);
    +		vStringDelete (name);
    +	}
    +}
    +
    +/* Match a ".label" style label. */
    +static void match_dot_label (char const *p)
    +{
    +	if (*p == '.')
    +	{
    +		vString *name = vStringNew ();
    +		extract_name (p + 1, name);
    +		makeSimpleTag (name, BasicKinds, K_LABEL);
    +		vStringDelete (name);
    +	}
    +}
    +
    +static void findBasicTags (void)
    +{
    +	const char *line;
    +	const char *extension = fileExtension (vStringValue (File.name));
    +	KeyWord *keywords;
    +
    +	if (strcmp (extension, "bb") == 0)
    +		keywords = blitzbasic_keywords;
    +	else if (strcmp (extension, "pb") == 0)
    +		keywords = purebasic_keywords;
    +	else
    +		keywords = freebasic_keywords;
    +
    +	while ((line = (const char *) fileReadLine ()) != NULL)
    +	{
    +		const char *p = line;
    +		KeyWord const *kw;
    +
    +		while (isspace (*p))
    +			p++;
    +
    +		/* Empty line? */
    +		if (!*p)
    +			continue;
    +
    +		/* In Basic, keywords always are at the start of the line. */
    +		for (kw = keywords; kw->token; kw++)
    +			if (match_keyword (p, kw)) break;
    +
    +		/* Is it a label? */
    +		if (strcmp (extension, "bb") == 0)
    +			match_dot_label (p);
    +		else
    +			match_colon_label (p);
    +	}
    +}
    +
    +parserDefinition *BasicParser (void)
    +{
    +	static char const *extensions[] = { "bas", "bi", "bb", "pb", NULL };
    +	parserDefinition *def = parserNew ("Basic");
    +	def->kinds = BasicKinds;
    +	def->kindCount = KIND_COUNT (BasicKinds);
    +	def->extensions = extensions;
    +	def->parser = findBasicTags;
    +	return def;
    +}
    +
    +/* vi:set tabstop=4 shiftwidth=4: */
    
    Modified: haiku/trunk/src/bin/ctags/beta.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/beta.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/beta.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: beta.c,v 1.7 2006/05/30 04:37:11 darren Exp $
    +*   $Id: beta.c 536 2007-06-02 06:09:00Z elliotth $
     *
     *   Copyright (c) 1999-2000, Mj?lner Informatics
     *
    @@ -304,6 +304,7 @@
     		endofline:
     		inquote = FALSE;  /* This shouldn't really make a difference */
     	} while (!feof (File.fp));
    +	vStringDelete (line);
     }
     
     extern parserDefinition* BetaParser (void)
    
    Modified: haiku/trunk/src/bin/ctags/c.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/c.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/c.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: c.c,v 1.34 2006/05/30 04:37:11 darren Exp $
    +*   $Id: c.c 614 2007-08-19 22:46:13Z elliotth $
     *
     *   Copyright (c) 1996-2003, Darren Hiebert
     *
    @@ -30,9 +30,7 @@
     /*
     *   MACROS
     */
    -#define MaxFields   6
     
    -#define stringValue(a)      #a
     #define activeToken(st)     ((st)->token [(int) (st)->tokenIndex])
     #define parentDecl(st)      ((st)->parent == NULL ? \
                                 DECL_NONE : (st)->parent->declaration)
    @@ -287,7 +285,7 @@
     	{ TRUE,  't', "typedef",    "typedefs"},
     	{ TRUE,  'u', "union",      "union names"},
     	{ TRUE,  'v', "variable",   "variable definitions"},
    -	{ FALSE, 'x', "externvar",  "external variable declarations"},
    +	{ FALSE, 'x', "externvar",  "external and forward variable declarations"},
     };
     
     typedef enum {
    @@ -316,17 +314,19 @@
     /* Used to index into the JavaKinds table. */
     typedef enum {
     	JK_UNDEFINED = -1,
    -	JK_CLASS, JK_FIELD, JK_INTERFACE, JK_LOCAL, JK_METHOD,
    -	JK_PACKAGE, JK_ACCESS, JK_CLASS_PREFIX
    +	JK_CLASS, JK_ENUM_CONSTANT, JK_FIELD, JK_ENUM, JK_INTERFACE,
    +	JK_LOCAL, JK_METHOD, JK_PACKAGE, JK_ACCESS, JK_CLASS_PREFIX
     } javaKind;
     
     static kindOption JavaKinds [] = {
    -	{ TRUE,  'c', "class",     "classes"},
    -	{ TRUE,  'f', "field",     "fields"},
    -	{ TRUE,  'i', "interface", "interfaces"},
    -	{ FALSE, 'l', "local",     "local variables"},
    -	{ TRUE,  'm', "method",    "methods"},
    -	{ TRUE,  'p', "package",   "packages"},
    +	{ TRUE,  'c', "class",         "classes"},
    +	{ TRUE,  'e', "enum constant", "enum constants"},
    +	{ TRUE,  'f', "field",         "fields"},
    +	{ TRUE,  'g', "enum",          "enum types"},
    +	{ TRUE,  'i', "interface",     "interfaces"},
    +	{ FALSE, 'l', "local",         "local variables"},
    +	{ TRUE,  'm', "method",        "methods"},
    +	{ TRUE,  'p', "package",       "packages"},
     };
     
     /* Used to index into the VeraKinds table. */
    @@ -382,7 +382,7 @@
     	{ "delete",         KEYWORD_DELETE,         { 0, 1, 0, 0, 0 } },
     	{ "double",         KEYWORD_DOUBLE,         { 1, 1, 1, 1, 0 } },
     	{ "else",           KEYWORD_ELSE,           { 1, 1, 0, 1, 0 } },
    -	{ "enum",           KEYWORD_ENUM,           { 1, 1, 1, 0, 1 } },
    +	{ "enum",           KEYWORD_ENUM,           { 1, 1, 1, 1, 1 } },
     	{ "event",          KEYWORD_EVENT,          { 0, 0, 1, 0, 1 } },
     	{ "explicit",       KEYWORD_EXPLICIT,       { 0, 1, 1, 0, 0 } },
     	{ "extends",        KEYWORD_EXTENDS,        { 0, 0, 0, 1, 1 } },
    @@ -713,8 +713,9 @@
     	if (st->parent != NULL) switch (st->parent->declaration)
     	{
     		case DECL_ENUM:
    +			accessDefault = (isLanguage (Lang_java) ? ACCESS_PUBLIC : ACCESS_UNDEFINED);
    +			break;
     		case DECL_NAMESPACE:
    -		case DECL_UNION:
     			accessDefault = ACCESS_UNDEFINED;
     			break;
     
    @@ -727,6 +728,7 @@
     
     		case DECL_INTERFACE:
     		case DECL_STRUCT:
    +		case DECL_UNION:
     			accessDefault = ACCESS_PUBLIC;
     			break;
     
    @@ -843,12 +845,14 @@
     	javaKind result = JK_UNDEFINED;
     	switch (type)
     	{
    -		case TAG_CLASS:     result = JK_CLASS;     break;
    -		case TAG_FIELD:     result = JK_FIELD;     break;
    -		case TAG_INTERFACE: result = JK_INTERFACE; break;
    -		case TAG_LOCAL:     result = JK_LOCAL;     break;
    -		case TAG_METHOD:    result = JK_METHOD;    break;
    -		case TAG_PACKAGE:   result = JK_PACKAGE;   break;
    +		case TAG_CLASS:      result = JK_CLASS;         break;
    +		case TAG_ENUM:       result = JK_ENUM;          break;
    +		case TAG_ENUMERATOR: result = JK_ENUM_CONSTANT; break;
    +		case TAG_FIELD:      result = JK_FIELD;         break;
    +		case TAG_INTERFACE:  result = JK_INTERFACE;     break;
    +		case TAG_LOCAL:      result = JK_LOCAL;         break;
    +		case TAG_METHOD:     result = JK_METHOD;        break;
    +		case TAG_PACKAGE:    result = JK_PACKAGE;       break;
     
     		default: Assert ("Bad Java tag type" == NULL); break;
     	}
    @@ -1466,6 +1470,14 @@
     
     	initToken (token);
     
    +	/* Bug #1585745: strangely, C++ destructors allow whitespace between
    +	 * the ~ and the class name. */
    +	if (isLanguage (Lang_cpp) && firstChar == '~')
    +	{
    +		vStringPut (name, c);
    +		c = skipToNonWhite ();
    +	}
    +
     	do
     	{
     		vStringPut (name, c);
    @@ -1476,7 +1488,7 @@
     			first = FALSE;
     		}
     		c = cppGetc ();
    -	} while (isident (c) || (isLanguage (Lang_java) && isHighChar (c)));
    +	} while (isident (c) || (isLanguage (Lang_java) && (isHighChar (c) || c == '.')));
     	vStringTerminate (name);
     	cppUngetc (c);        /* unget non-identifier character */
     
    @@ -1499,15 +1511,25 @@
     	cppUngetc (c);        /* unget non-package character */
     }
     
    -static void readPackage (statementInfo *const st)
    +static void readPackageOrNamespace (statementInfo *const st, const declType declaration)
     {
    -	tokenInfo *const token = activeToken (st);
    -	Assert (isType (token, TOKEN_KEYWORD));
    -	readPackageName (token, skipToNonWhite ());
    -	token->type = TOKEN_NAME;
    -	st->declaration = DECL_PACKAGE;
    -	st->gotName = TRUE;
    -	st->haveQualifyingName = TRUE;
    +	st->declaration = declaration;
    +	
    +	if (declaration == DECL_NAMESPACE && !isLanguage (Lang_csharp))
    +	{
    +		/* In C++ a namespace is specified one level at a time. */
    +		return;
    +	}
    +	else
    +	{
    +		/* In C#, a namespace can also be specified like a Java package name. */
    +		tokenInfo *const token = activeToken (st);
    +		Assert (isType (token, TOKEN_KEYWORD));
    +		readPackageName (token, skipToNonWhite ());
    +		token->type = TOKEN_NAME;
    +		st->gotName = TRUE;
    +		st->haveQualifyingName = TRUE;
    +	}
     }
     
     static void processName (statementInfo *const st)
    @@ -1682,6 +1704,11 @@
     	skipToOneOf (";");
     }
     
    +static void processInterface (statementInfo *const st)
    +{
    +	st->declaration = DECL_INTERFACE;
    +}
    +
     static void processToken (tokenInfo *const token, statementInfo *const st)
     {
     	switch (token->keyword)        /* is it a reserved word? */
    @@ -1710,12 +1737,10 @@
     		case KEYWORD_IMPORT:    skipStatement (st);                     break;
     		case KEYWORD_INT:       st->declaration = DECL_BASE;            break;
     		case KEYWORD_INTEGER:   st->declaration = DECL_BASE;            break;
    -		case KEYWORD_INTERFACE: st->declaration = DECL_INTERFACE;       break;
    +		case KEYWORD_INTERFACE: processInterface (st);                  break;
     		case KEYWORD_LOCAL:     setAccess (st, ACCESS_LOCAL);           break;
     		case KEYWORD_LONG:      st->declaration = DECL_BASE;            break;
    -		case KEYWORD_NAMESPACE: st->declaration = DECL_NAMESPACE;       break;
     		case KEYWORD_OPERATOR:  readOperator (st);                      break;
    -		case KEYWORD_PACKAGE:   readPackage (st);                       break;
     		case KEYWORD_PRIVATE:   setAccess (st, ACCESS_PRIVATE);         break;
     		case KEYWORD_PROGRAM:   st->declaration = DECL_PROGRAM;         break;
     		case KEYWORD_PROTECTED: setAccess (st, ACCESS_PROTECTED);       break;
    @@ -1733,7 +1758,11 @@
     		case KEYWORD_VOID:      st->declaration = DECL_BASE;            break;
     		case KEYWORD_VOLATILE:  st->declaration = DECL_BASE;            break;
     		case KEYWORD_VIRTUAL:   st->implementation = IMP_VIRTUAL;       break;
    -
    +		case KEYWORD_WCHAR_T:   st->declaration = DECL_BASE;            break;
    +		
    +		case KEYWORD_NAMESPACE: readPackageOrNamespace (st, DECL_NAMESPACE); break;
    +		case KEYWORD_PACKAGE:   readPackageOrNamespace (st, DECL_PACKAGE);   break;
    +		
     		case KEYWORD_EVENT:
     			if (isLanguage (Lang_csharp))
     				st->declaration = DECL_EVENT;
    @@ -2018,6 +2047,26 @@
     	}
     }
     
    +static void processAngleBracket (void)
    +{
    +	int c = cppGetc ();
    +	if (c == '>') {
    +		/* already found match for template */
    +	} else if ((isLanguage (Lang_cpp) || isLanguage (Lang_java)) && c != '<' && c != '=') {
    +		/* this is a template */
    +		cppUngetc (c);
    +		skipToMatch ("<>");
    +	} else if (c == '<') {
    +		/* skip "<<" or "<<=". */
    +		c = cppGetc ();
    +		if (c != '=') {
    +			cppUngetc (c);
    +		}
    +	} else {
    +		cppUngetc (c);
    +	}
    +}
    +
     static int parseParens (statementInfo *const st, parenInfo *const info)
     {
     	tokenInfo *const token = activeToken (st);
    @@ -2098,7 +2147,7 @@
     
     			case '<':
     				info->isKnrParamList = FALSE;
    -				skipToMatch ("<>");
    +				processAngleBracket ();
     				break;
     
     			case ')':
    @@ -2311,17 +2360,6 @@
     	}
     }
     
    -static void processAngleBracket (void)
    -{
    -	int c = cppGetc ();
    -	if (c == '>')
    -		;  /* already found match for template */
    -	else if (isLanguage (Lang_cpp) &&  c != '<' && c != '=')
    -		skipToMatch ("<>");        /* this is a template */
    -	else
    -		cppUngetc (c);
    -}
    -
     /*  Skips over any initializing value which may follow an '=' character in a
      *  variable definition.
      */
    @@ -2349,6 +2387,7 @@
     			case '[': skipToMatch ("[]"); break;
     			case '(': skipToMatch ("()"); break;
     			case '{': skipToMatch ("{}"); break;
    +			case '<': processAngleBracket(); break;
     
     			case '}':
     				if (insideEnumBody (st))
    @@ -2381,7 +2420,7 @@
     			setToken (st, TOKEN_SEMICOLON);
     		else if (c == ',')
     			setToken (st, TOKEN_COMMA);
    -		else if ('}'  &&  inEnumBody)
    +		else if (c == '}'  &&  inEnumBody)
     		{
     			cppUngetc (c);
     			setToken (st, TOKEN_COMMA);
    @@ -2400,10 +2439,35 @@
     		processToken (token, st);
     }
     
    +static void parseJavaAnnotation (statementInfo *const st)
    +{
    +	/*
    +	 * @Override
    +	 * @Target(ElementType.METHOD)
    +	 * @SuppressWarnings(value = "unchecked")
    +	 *
    +	 * But watch out for "@interface"!
    +	 */
    +	tokenInfo *const token = activeToken (st);
    +	
    +	int c = skipToNonWhite ();
    +	readIdentifier (token, c);
    +	if (token->keyword == KEYWORD_INTERFACE)
    +	{
    +		/* Oops. This was actually "@interface" defining a new annotation. */
    +		processInterface (st);
    +	}
    +	else
    +	{
    +		/* Bug #1691412: skip any annotation arguments. */
    +		skipParens ();
    +	}
    +}
    +
     static void parseGeneralToken (statementInfo *const st, const int c)
     {
     	const tokenInfo *const prev = prevToken (st, 1);
    -
    +	
     	if (isident1 (c) || (isLanguage (Lang_java) && isHighChar (c)))
     	{
     		parseIdentifier (st, c);
    @@ -2430,6 +2494,10 @@
     		if (c2 != '=')
     			cppUngetc (c2);
     	}
    +	else if (c == '@' && isLanguage (Lang_java))
    +	{
    +		parseJavaAnnotation (st);
    +	}
     	else if (isExternCDecl (st, c))
     	{
     		st->declaration = DECL_NOMANGLE;
    @@ -2639,7 +2707,7 @@
     			else if (isType (prev, TOKEN_NAME))
     			{
     				if (isContextualKeyword (prev2))
    -					st->scope = SCOPE_EXTERN;
    +					makeTag (prev, st, TRUE, TAG_EXTERN_VAR);
     				else
     					qualifyVariableTag (st, prev);
     			}
    @@ -2650,6 +2718,13 @@
     				else
     					qualifyFunctionDeclTag (st, prev2);
     			}
    +			if (isLanguage (Lang_java) && token->type == TOKEN_SEMICOLON && insideEnumBody (st))
    +			{
    +				/* In Java, after an initial enum-like part,
    +				 * a semicolon introduces a class-like part.
    +				 * See Bug #1730485 for the full rationale. */
    +				st->parent->declaration = DECL_CLASS;
    +			}
     			break;
     
     		default: break;
    @@ -2705,7 +2780,7 @@
     	boolean retry;
     
     	Assert (passCount < 3);
    -	cppInit ((boolean) (passCount > 1));
    +	cppInit ((boolean) (passCount > 1), isLanguage (Lang_csharp));
     	Signature = vStringNew ();
     
     	exception = (exception_t) setjmp (Exception);
    
    Modified: haiku/trunk/src/bin/ctags/cobol.c
    ===================================================================
    --- haiku/trunk/src/bin/ctags/cobol.c	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/cobol.c	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,5 +1,5 @@
     /*
    -*   $Id: cobol.c,v 1.6 2006/05/30 04:37:11 darren Exp $
    +*   $Id: cobol.c 443 2006-05-30 04:37:13Z darren $
     *
     *   Copyright (c) 2000-2003, Darren Hiebert
     *
    
    Modified: haiku/trunk/src/bin/ctags/config.h.in
    ===================================================================
    --- haiku/trunk/src/bin/ctags/config.h.in	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/config.h.in	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1,6 +1,6 @@
     /* config.h.in.  Generated from configure.in by autoheader.  */
     /*
    -*   $Id: acconfig.h,v 1.4 2003/04/01 05:02:21 darren Exp $
    +*   $Id: acconfig.h 318 2003-04-01 05:02:21Z darren $
     *
     *   Copyright (c) 1998-2003, Darren Hiebert
     *
    
    Modified: haiku/trunk/src/bin/ctags/configure
    ===================================================================
    --- haiku/trunk/src/bin/ctags/configure	2007-09-25 17:41:26 UTC (rev 22309)
    +++ haiku/trunk/src/bin/ctags/configure	2007-09-25 17:42:11 UTC (rev 22310)
    @@ -1311,7 +1311,9 @@
               ac_config_headers="$ac_config_headers config.h"
     
     
    -echo 'Exuberant Ctags, version 5.6'
    +program_name=`grep 'PROGRAM_NAME  *"' ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
    +program_version=`grep 'PROGRAM_VERSION  *"' ctags.h | sed -e 's/.*"\([^"]*\)".*/\1/'`
    +echo "$program_name, version $program_version"
     uname -mrsv 2>/dev/null
     
     
    @@ -2373,8 +2375,8 @@
     
     case `uname` in
     	HP-UX)
    -		echo "$as_me:$LINENO: checking \"HP-UX native compiler\"" >&5
    -echo $ECHO_N "checking \"HP-UX native compiler\"... $ECHO_C" >&6
    +		echo "$as_me:$LINENO: checking HP-UX native compiler" >&5
    +echo $ECHO_N "checking HP-UX native compiler... $ECHO_C" >&6
     		if test "$CC" = "cc"; then
     			echo "$as_me:$LINENO: result: yes; adding compiler options for ANSI support" >&5
     echo "${ECHO_T}yes; adding compiler options for ANSI support" >&6
    @@ -2386,8 +2388,8 @@
     		;;
     	SunOS)
     		if uname -r | grep '5\.' >/dev/null 2>&1; then
    -			echo "$as_me:$LINENO: checking \"Solaris native compiler\"" >&5
    -echo $ECHO_N "checking \"Solaris native compiler\"... $ECHO_C" >&6
    +			echo "$as_me:$LINENO: checking Solaris native compiler" >&5
    +echo $ECHO_N "checking Solaris native compiler... $ECHO_C" >&6
     			if test "$CC" = "cc" -a "`which cc`" = "/usr/ucb/cc"; then
     				echo "$as_me:$LINENO: result: yes; adding compiler option for ANSI support" >&5
     echo "${ECHO_T}yes; adding compiler option for ANSI support" >&6
    @@ -2508,8 +2510,8 @@
     
     fi
     
    -echo "$as_me:$LINENO: checking \"for case-insensitive filenames\"" >&5
    -echo $ECHO_N "checking \"for case-insensitive filenames\"... $ECHO_C" >&6
    +echo "$as_me:$LINENO: checking for case-insensitive filenames" >&5
    +echo $ECHO_N "checking for case-insensitive filenames... $ECHO_C" >&6
     touch conftest.cif
     if test -f CONFTEST.CIF; then
     	echo "$as_me:$LINENO: result: yes" >&5
    @@ -3549,8 +3551,8 @@
     
     
     
    -	echo "$as_me:$LINENO: checking \"if L_tmpnam is defined in stdio.h\"" >&5
    -echo $ECHO_N "checking \"if L_tmpnam is defined in stdio.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if L_tmpnam is defined in stdio.h" >&5
    +echo $ECHO_N "checking if L_tmpnam is defined in stdio.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -3584,8 +3586,8 @@
     
     
     
    -	echo "$as_me:$LINENO: checking \"if INT_MAX is defined in limits.h\"" >&5
    -echo $ECHO_N "checking \"if INT_MAX is defined in limits.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if INT_MAX is defined in limits.h" >&5
    +echo $ECHO_N "checking if INT_MAX is defined in limits.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -3610,8 +3612,8 @@
     	echo "$as_me:$LINENO: result: no" >&5
     echo "${ECHO_T}no" >&6
     
    -	echo "$as_me:$LINENO: checking \"if MAXINT is defined in limits.h\"" >&5
    -echo $ECHO_N "checking \"if MAXINT is defined in limits.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if MAXINT is defined in limits.h" >&5
    +echo $ECHO_N "checking if MAXINT is defined in limits.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -3786,8 +3788,8 @@
     fi
     
     
    -echo "$as_me:$LINENO: checking \"for fpos_t\"" >&5
    -echo $ECHO_N "checking \"for fpos_t\"... $ECHO_C" >&6
    +echo "$as_me:$LINENO: checking for fpos_t" >&5
    +echo $ECHO_N "checking for fpos_t... $ECHO_C" >&6
     cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -3814,8 +3816,8 @@
     rm -f conftest*
     
     
    -echo "$as_me:$LINENO: checking \"for clock_t\"" >&5
    -echo $ECHO_N "checking \"for clock_t\"... $ECHO_C" >&6
    +echo "$as_me:$LINENO: checking for clock_t" >&5
    +echo $ECHO_N "checking for clock_t... $ECHO_C" >&6
     cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -4532,8 +4534,8 @@
     
     if test "$have_fgetpos" != yes ; then
     
    -	echo "$as_me:$LINENO: checking \"if SEEK_SET is defined in stdio.h\"" >&5
    -echo $ECHO_N "checking \"if SEEK_SET is defined in stdio.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if SEEK_SET is defined in stdio.h" >&5
    +echo $ECHO_N "checking if SEEK_SET is defined in stdio.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -4558,8 +4560,8 @@
     	echo "$as_me:$LINENO: result: no" >&5
     echo "${ECHO_T}no" >&6
     
    -	echo "$as_me:$LINENO: checking \"if SEEK_SET is defined in unistd.h\"" >&5
    -echo $ECHO_N "checking \"if SEEK_SET is defined in unistd.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if SEEK_SET is defined in unistd.h" >&5
    +echo $ECHO_N "checking if SEEK_SET is defined in unistd.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -5322,8 +5324,8 @@
      have_remove=yes
     else
     
    -	echo "$as_me:$LINENO: checking \"if remove is defined in unistd.h\"" >&5
    -echo $ECHO_N "checking \"if remove is defined in unistd.h\"... $ECHO_C" >&6
    +	echo "$as_me:$LINENO: checking if remove is defined in unistd.h" >&5
    +echo $ECHO_N "checking if remove is defined in unistd.h... $ECHO_C" >&6
     	cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -5892,8 +5894,8 @@
     rm -f conftest*
     
     		if test "$have_putenv_prototype" = yes ; then
    -			echo "$as_me:$LINENO: checking \"putenv prototype\"" >&5
    -echo $ECHO_N "checking \"putenv prototype\"... $ECHO_C" >&6
    +			echo "$as_me:$LINENO: checking putenv prototype" >&5
    +echo $ECHO_N "checking putenv prototype... $ECHO_C" >&6
     			cat >conftest.$ac_ext <<_ACEOF
     /* confdefs.h.  */
     _ACEOF
    @@ -6082,8 +6084,8 @@
    
    [... truncated: 12838 lines follow ...]
    
    
    From korli at mail.berlios.de  Tue Sep 25 21:18:27 2007
    From: korli at mail.berlios.de (korli at BerliOS)
    Date: Tue, 25 Sep 2007 21:18:27 +0200
    Subject: [Haiku-commits] r22311 - in haiku/trunk: headers/posix
    	src/system/libroot/posix/time
    Message-ID: <200709251918.l8PJIRIA023476@sheep.berlios.de>
    
    Author: korli
    Date: 2007-09-25 21:18:27 +0200 (Tue, 25 Sep 2007)
    New Revision: 22311
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22311&view=rev
    
    Added:
       haiku/trunk/src/system/libroot/posix/time/nanosleep.c
    Modified:
       haiku/trunk/headers/posix/time.h
       haiku/trunk/src/system/libroot/posix/time/Jamfile
    Log:
    added an implementation for nanosleep() based on snooze()
    
    
    Modified: haiku/trunk/headers/posix/time.h
    ===================================================================
    --- haiku/trunk/headers/posix/time.h	2007-09-25 17:42:11 UTC (rev 22310)
    +++ haiku/trunk/headers/posix/time.h	2007-09-25 19:18:27 UTC (rev 22311)
    @@ -67,6 +67,7 @@
     extern struct tm	*gmtime_r(const time_t *timer, struct tm *tm); 
     extern struct tm	*localtime(const time_t *timer);
     extern struct tm	*localtime_r(const time_t *timer, struct tm *tm);
    +extern int			nanosleep(const struct timespec *, struct timespec *);
     extern size_t		strftime(char *buffer, size_t maxSize, const char *format,
     						const struct tm *tm);
     extern char 		*strptime(const char *buf, const char *format, struct tm *tm);
    
    Modified: haiku/trunk/src/system/libroot/posix/time/Jamfile
    ===================================================================
    --- haiku/trunk/src/system/libroot/posix/time/Jamfile	2007-09-25 17:42:11 UTC (rev 22310)
    +++ haiku/trunk/src/system/libroot/posix/time/Jamfile	2007-09-25 19:18:27 UTC (rev 22311)
    @@ -12,6 +12,7 @@
     	ctime.c
     	difftime.c
     	localtime.c
    +	nanosleep.c
     	stime.c
     	strftime.c
     	strptime.c
    
    Added: haiku/trunk/src/system/libroot/posix/time/nanosleep.c
    ===================================================================
    --- haiku/trunk/src/system/libroot/posix/time/nanosleep.c	2007-09-25 17:42:11 UTC (rev 22310)
    +++ haiku/trunk/src/system/libroot/posix/time/nanosleep.c	2007-09-25 19:18:27 UTC (rev 22311)
    @@ -0,0 +1,35 @@
    +/* 
    +** Copyright 2007, J?r?me Duval. All rights reserved.
    +** Distributed under the terms of the Haiku License.
    +*/
    +#include 
    +#include 
    +#include 
    +
    +int
    +nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
    +{
    +	bigtime_t ms, begin_ms;
    +	status_t err;
    +
    +	if (!rqtp) {
    +		errno = EINVAL;
    +		return -1;
    +	}
    +
    +	// round up tv_nsec
    +	ms = rqtp->tv_sec * 1000000LL + (rqtp->tv_nsec + 999) / 1000;
    +	begin_ms = system_time();
    +	err = snooze(ms);
    +	if (err == B_INTERRUPTED) {
    +		errno = EINTR;
    +		if (rmtp) {
    +			bigtime_t remain_ms = ms - system_time() + begin_ms;
    +			rmtp->tv_sec = remain_ms / 1000000;
    +			rmtp->tv_nsec = (remain_ms - rmtp->tv_sec) * 1000;
    +		}
    +		return -1;
    +	}
    +	return 0;
    +}
    +
    
    
    
    From marcusoverhagen at mail.berlios.de  Tue Sep 25 23:33:16 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Tue, 25 Sep 2007 23:33:16 +0200
    Subject: [Haiku-commits] r22312 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709252133.l8PLXGVu031662@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-25 23:33:15 +0200 (Tue, 25 Sep 2007)
    New Revision: 22312
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22312&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    Implemented a identify device command for further testing, works on Intel, doesn't work on Jmicron.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-25 19:18:27 UTC (rev 22311)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-25 21:33:15 UTC (rev 22312)
    @@ -170,16 +170,16 @@
     typedef struct {
       union {
        struct {
    +	uint16		cfl : 5;		// command FIS length
    +	uint16		a : 1;			// ATAPI
    +	uint16		w : 1;			// Write
    +	uint16		p : 1;			// Prefetchable
    +	uint16		r : 1;			// Reset 
    +	uint16		b : 1;			// Build In Self Test
    +	uint16		c : 1;			// Clear Busy upon R_OK
    +	uint16		: 1;
    +	uint16		pmp : 4;		// Port Multiplier Port
     	uint16		prdtl;			// physical region description table length;		
    -	uint16		pmp : 4;		// Port Multiplier Port
    -	uint16		: 1;
    -	uint16		c : 1;			// Clear Busy upon R_OK
    -	uint16		b : 1;			// Build In Self Test
    -	uint16		r : 1;			// Reset 
    -	uint16		p : 1;			// Prefetchable
    -	uint16		w : 1;			// Write
    -	uint16		a : 1;			// ATAPI
    -	uint16		cfl : 5;		// command FIS length
        } _PACKED;
         uint32		prdtl_flags_cfl;
       } _PACKED;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-25 19:18:27 UTC (rev 22311)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-25 21:33:15 UTC (rev 22312)
    @@ -260,13 +260,98 @@
     	fRegs->is = is;
     }
     
    +char c(int i)
    +{
    +	if (i == '\n' || i == '\r' || i == '\b')
    +		return '?';
    +	return i;
    +}
     
     void
    +AHCIPort::IdentifyDevice()
    +{
    +	TRACE("AHCIPort::IdentifyDevice port %d\n", fIndex);
    +
    +	void *phy; 
    +	uint8 *data;
    +	int size = 512;
    +
    +	area_id id = alloc_mem((void **)&data, &phy, size, 0, "identify device");
    +
    +	TRACE("virt   0x%08lx\n", data);
    +	TRACE("phys   0x%08lx\n", phy);
    +
    +	memset(data, 0, size);
    +
    +	TRACE("ci   0x%08lx\n", fRegs->ci);
    +	TRACE("ie   0x%08lx\n", fRegs->ie);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    +	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    +	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	TRACE("sact 0x%08lx\n", fRegs->sact);
    +	TRACE("tfd  0x%08lx\n", fRegs->tfd);
    +
    +
    +	memset((void *)fCommandTable->cfis, 0, 5 * 4);
    +	fCommandTable->cfis[0] = 0x27;
    +	fCommandTable->cfis[1] = 0x80;
    +	fCommandTable->cfis[2] = 0xec;
    +
    +
    +	fCommandList->prdtl_flags_cfl = 0;
    +	fCommandList->prdtl = 1;
    +//	fCommandList->c = 1;
    +	fCommandList->cfl = 5;
    +	fCommandList->prdbc = 0;
    +
    +	TRACE("prdtl_flags_cfl %08x\n", fCommandList->prdtl_flags_cfl);
    +	TRACE("prdbc           %08x\n", fCommandList->prdbc);
    +
    +
    +	fPRDTable->dba = LO32(phy);
    +	fPRDTable->dbau = HI32(phy);
    +	fPRDTable->dbc = DBC_I | (size - 1);
    +
    +	TRACE("dba  %08x\n", fPRDTable->dba);
    +	TRACE("dbau %08x\n", fPRDTable->dbau);
    +	TRACE("dbc  %08x\n", fPRDTable->dbc);
    +
    +	fRegs->ci |= 1;
    +	FlushPostedWrites();
    +
    +	snooze(500000);
    +
    +	TRACE("prdbc %ld\n", fCommandList->prdbc);
    +
    +	TRACE("ci   0x%08lx\n", fRegs->ci);
    +	TRACE("ie   0x%08lx\n", fRegs->ie);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    +	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    +	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	TRACE("sact 0x%08lx\n", fRegs->sact);
    +	TRACE("tfd  0x%08lx\n", fRegs->tfd);
    +
    +	for (int i = 0; i < size; i += 8) {
    +		TRACE("  %02x %02x %02x %02x %02x %02x %02x %02x\n", data[i], data[i+1], data[i+2], data[i+3], data[i+4], data[i+5], data[i+6], data[i+7]);
    +//		TRACE("  %c%c%c%c%c%c%c%c\n", c(data[i]), c(data[i+1]), c(data[i+2]), c(data[i+3]), c(data[i+4]), c(data[i+5]), c(data[i+6]), c(data[i+7]));
    +	}
    +
    +	delete_area(id);
    +}
    +
    +
    +void
     AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
     {
     
     	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
    +	if (request->cdb[0] == 18)
    +		IdentifyDevice();
     
     	request->subsys_status = SCSI_DEV_NOT_THERE;
     	gSCSI->finished(request, 1);
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-25 19:18:27 UTC (rev 22311)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-25 21:33:15 UTC (rev 22312)
    @@ -31,6 +31,7 @@
     	status_t	PostResetDevice();
     	void		FlushPostedWrites();
     	void		DumpD2HFis();
    +	void		IdentifyDevice();
     
     private:
     	int						fIndex;
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 01:58:32 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 01:58:32 +0200
    Subject: [Haiku-commits] r22313 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709252358.l8PNwWoI022368@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 01:58:31 +0200 (Wed, 26 Sep 2007)
    New Revision: 22313
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22313&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    Log:
    * The low memory handler now runs more often in more critical situations.
    * vm_low_memory() no longer calls call_handlers() directly, but just triggers
      a run immediately.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-25 21:33:15 UTC (rev 22312)
    +++ haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-25 23:58:31 UTC (rev 22313)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      */
     
    @@ -26,24 +26,26 @@
     
     // TODO: the priority is currently ignored, and probably can be removed
     
    +struct low_memory_handler : public DoublyLinkedListLinkImpl {
    +	low_memory_func	function;
    +	void			*data;
    +	int32			priority;
    +};
    +
    +typedef DoublyLinkedList HandlerList;
    +
    +
     static const bigtime_t kLowMemoryInterval = 3000000;	// 3 secs
    +static const bigtime_t kWarnMemoryInterval = 500000;	// 0.5 secs
     
     // page limits
     static const size_t kNoteLimit = 1024;
     static const size_t kWarnLimit = 256;
     static const size_t kCriticalLimit = 32;
     
    +
     static int32 sLowMemoryState = B_NO_LOW_MEMORY;
     
    -
    -struct low_memory_handler : public DoublyLinkedListLinkImpl {
    -	low_memory_func	function;
    -	void			*data;
    -	int32			priority;
    -};
    -
    -typedef DoublyLinkedList HandlerList;
    -
     static mutex sLowMemoryMutex;
     static sem_id sLowMemoryWaitSem;
     static HandlerList sLowMemoryHandlers;
    @@ -83,8 +85,12 @@
     static int32
     low_memory(void *)
     {
    +	bigtime_t timeout = kLowMemoryInterval;
     	while (true) {
    -		snooze(kLowMemoryInterval);
    +		if (sLowMemoryState != B_LOW_MEMORY_CRITICAL) {
    +			acquire_sem_etc(sLowMemoryWaitSem, 1, B_RELATIVE_TIMEOUT,
    +				timeout);
    +		}
     
     		sLowMemoryState = compute_state();
     
    @@ -95,6 +101,11 @@
     			continue;
     
     		call_handlers(sLowMemoryState);
    +		
    +		if (sLowMemoryState == B_LOW_MEMORY_WARNING)
    +			timeout = kWarnMemoryInterval;
    +		else
    +			timeout = kLowMemoryInterval;
     	}
     	return 0;
     }
    @@ -103,9 +114,9 @@
     void
     vm_low_memory(size_t requirements)
     {
    -	// ToDo: compute level with requirements in mind
    +	// TODO: take requirements into account
     
    -	call_handlers(B_LOW_MEMORY_NOTE);
    +	release_sem(sLowMemoryWaitSem);
     }
     
     
    @@ -132,7 +143,8 @@
     		// static initializers do not work in the kernel,
     		// so we have to do it here, manually
     
    -	thread = spawn_kernel_thread(&low_memory, "low memory handler", B_LOW_PRIORITY, NULL);
    +	thread = spawn_kernel_thread(&low_memory, "low memory handler",
    +		B_LOW_PRIORITY, NULL);
     	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
     
     	return B_OK;
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 02:06:19 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 02:06:19 +0200
    Subject: [Haiku-commits] r22314 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709260006.l8Q06JkZ022778@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 02:06:18 +0200 (Wed, 26 Sep 2007)
    New Revision: 22314
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22314&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_daemons.cpp
    Log:
    bonefish+axeld:
    * The page daemon now runs independently from the low memory state.
    * It now also increases its frequency and scanned pages, as well as decreases
      the interval between runs with increasing memory pressure.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp	2007-09-25 23:58:31 UTC (rev 22313)
    +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    @@ -15,10 +15,14 @@
     #include 
     
     
    +const static uint32 kMinScanPagesCount = 512;
    +const static uint32 kMaxScanPagesCount = 8192;
    +const static bigtime_t kMinScanWaitInterval = 50000LL;		// 50 ms
    +const static bigtime_t kMaxScanWaitInterval = 1000000LL;	// 1 sec
    +
    +static uint32 sLowPagesCount;
     static sem_id sPageDaemonSem;
    -static uint32 sScanPagesCount;
     static uint32 sNumPages;
    -static bigtime_t sScanWaitInterval;
     
     
     class PageCacheLocker {
    @@ -163,24 +167,34 @@
     
     
     static status_t 
    -page_daemon(void *unused)
    +page_daemon(void* /*unused*/)
     {
    +	bigtime_t scanWaitInterval = kMaxScanWaitInterval;
    +	uint32 scanPagesCount = kMinScanPagesCount;
     	uint32 clearPage = 0;
     	uint32 checkPage = sNumPages / 2;
     
     	while (true) {
     		acquire_sem_etc(sPageDaemonSem, 1, B_RELATIVE_TIMEOUT,
    -			sScanWaitInterval);
    +			scanWaitInterval);
     
    -		if (vm_low_memory_state() < B_LOW_MEMORY_NOTE) {
    +		// Compute next run time
    +		uint32 pagesLeft = vm_page_num_free_pages();
    +		if (pagesLeft > sLowPagesCount) {
     			// don't do anything if we have enough free memory left
     			continue;
     		}
     
    -		uint32 leftToFree = 32;
    -			// TODO: make this depending on the low memory state
    +		scanWaitInterval = kMinScanWaitInterval
    +			+ (kMaxScanWaitInterval - kMinScanWaitInterval)
    +			* pagesLeft / sLowPagesCount;
    +		scanPagesCount = kMaxScanPagesCount
    +			- (kMaxScanPagesCount - kMinScanPagesCount)
    +			* pagesLeft / sLowPagesCount;
    +		uint32 leftToFree = 32 + (scanPagesCount - 32)
    +			* pagesLeft / sLowPagesCount;
     
    -		for (uint32 i = 0; i < sScanPagesCount && leftToFree > 0; i++) {
    +		for (uint32 i = 0; i < scanPagesCount && leftToFree > 0; i++) {
     			if (clearPage == 0)
     				dprintf("clear through\n");
     			if (checkPage == 0)
    @@ -206,10 +220,11 @@
     	sPageDaemonSem = create_sem(0, "page daemon");
     
     	sNumPages = vm_page_num_pages();
    -	// TODO: compute those depending on sNumPages and memory pressure!
    -	sScanPagesCount = 512;
    -	sScanWaitInterval = 1000000;
     
    +	sLowPagesCount = sNumPages / 16;
    +	if (sLowPagesCount < 1024)
    +		sLowPagesCount = 1024;
    +
     	// create a kernel thread to select pages for pageout
     	thread_id thread = spawn_kernel_thread(&page_daemon, "page daemon",
     		B_LOW_PRIORITY, NULL);
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 02:20:26 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 02:20:26 +0200
    Subject: [Haiku-commits] r22315 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/cache src/system/kernel/fs src/system/kernel/vm
    Message-ID: <200709260020.l8Q0KQlE024609@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 02:20:23 +0200 (Wed, 26 Sep 2007)
    New Revision: 22315
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22315&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/file_cache.h
       haiku/trunk/headers/private/kernel/vfs.h
       haiku/trunk/headers/private/kernel/vm.h
       haiku/trunk/src/system/kernel/cache/file_cache.cpp
       haiku/trunk/src/system/kernel/cache/vnode_store.cpp
       haiku/trunk/src/system/kernel/cache/vnode_store.h
       haiku/trunk/src/system/kernel/fs/vfs.cpp
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    bonefish+axeld:
    * Removed the vm_cache/vm_store ref_count duality that besides being a bit ugly
      also created the page dameon cache retrieval problem: now, only areas (and
      cache consumers) retrieve a reference to the store (and therefore, the vnode).
      The page daemon doesn't need to care about this at all anymore, and the pseudo
      references of the vm_cache could be removed again.
    * Rearranged deletion of vnodes such that its ID can be reused directly after
      fs_remove_vnode() has been called.
    * vm_page_allocate_page() no longer panics when it runs out of pages, but just
      waits for new pages to become available using the new sFreeCondition condition
      variable - to make sure this happens in an acceptable time frame, it'll
      trigger a run of the low memory handlers.
    * Implemented a page_thief() that steals inactive pages from caches and puts
      them into the free queue. It runs as a low memory handler.
    * The file cache now sets the usage count on the pages it inserts into the
      cache (needs some rework though, cache_io() doesn't do it yet).
    * Instead of panicking, the kernel will currently dead lock in low memory
      situations, since BFS does a bit too much in bfs_release_vnode().
    * Some minor cleanup.
    
    
    Modified: haiku/trunk/headers/private/kernel/file_cache.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/file_cache.h	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/headers/private/kernel/file_cache.h	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -47,7 +47,7 @@
     extern status_t file_cache_init_post_boot_device(void);
     extern status_t file_cache_init(void);
     
    -extern vm_store *vm_create_vnode_store(void *vnode);
    +extern vm_store *vm_create_vnode_store(struct vnode *vnode);
     
     #ifdef __cplusplus
     }
    
    Modified: haiku/trunk/headers/private/kernel/vfs.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vfs.h	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/headers/private/kernel/vfs.h	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -31,6 +31,7 @@
     struct file_descriptor;
     struct selectsync;
     struct pollfd;
    +struct vnode;
     
     
     /** The I/O context of a process/team, holds the fd array among others */
    
    Modified: haiku/trunk/headers/private/kernel/vm.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm.h	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/headers/private/kernel/vm.h	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -15,6 +15,7 @@
     
     struct kernel_args;
     struct team;
    +struct vnode;
     
     
     #ifdef __cplusplus
    @@ -65,7 +66,7 @@
     			uint32 addressSpec, uint32 protection, uint32 mapping, 
     			area_id sourceArea);
     status_t vm_delete_area(team_id aid, area_id id);
    -status_t vm_create_vnode_cache(void *vnode, vm_cache **_cache);
    +status_t vm_create_vnode_cache(struct vnode *vnode, vm_cache **_cache);
     vm_area *vm_area_lookup(vm_address_space *addressSpace, addr_t address);
     status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
     status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
    
    Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -612,6 +612,11 @@
     	// make the pages accessible in the cache
     	for (int32 i = pageIndex; i-- > 0;) {
     		pages[i]->state = PAGE_STATE_ACTIVE;
    +		if (pages[i]->usage_count < 0)
    +			pages[i]->usage_count = 1;
    +		else
    +			pages[i]->usage_count++;
    +
     		busyConditions[i].Unpublish();
     	}
     
    @@ -792,6 +797,11 @@
     	for (int32 i = pageIndex; i-- > 0;) {
     		busyConditions[i].Unpublish();
     
    +		if (pages[i]->usage_count < 0)
    +			pages[i]->usage_count = 1;
    +		else
    +			pages[i]->usage_count++;
    +
     		if (writeThrough)
     			pages[i]->state = PAGE_STATE_ACTIVE;
     		else
    @@ -1248,17 +1258,10 @@
     	if (vfs_lookup_vnode(mountID, vnodeID, &ref->vnode) != B_OK)
     		goto err2;
     
    -	// Gets (usually creates) the cache for the node - note, this does grab a
    -	// reference to the node...
    +	// Gets (usually creates) the cache for the node
     	if (vfs_get_vnode_cache(ref->vnode, &ref->cache, true) != B_OK)
     		goto err2;
     
    -	// ... that we don't need, and therefore release it again.
    -	// Our caller already holds a reference to the vnode; it will destroy us
    -	// when the last one goes away (which, of course, can only ever happen if
    -	// we don't grab an extra reference).
    -	vfs_put_vnode(ref->vnode);
    -
     	ref->cache->virtual_size = size;
     	((vnode_store *)ref->cache->store)->file_cache_ref = ref;
     	return ref;
    
    Modified: haiku/trunk/src/system/kernel/cache/vnode_store.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/vnode_store.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/cache/vnode_store.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004-2006, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      */
     
    @@ -112,7 +112,7 @@
     
     
     extern "C" vm_store *
    -vm_create_vnode_store(void *vnode)
    +vm_create_vnode_store(struct vnode *vnode)
     {
     	vnode_store *store = (vnode_store *)malloc(sizeof(struct vnode_store));
     	if (store == NULL)
    
    Modified: haiku/trunk/src/system/kernel/cache/vnode_store.h
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/vnode_store.h	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/cache/vnode_store.h	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2004, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2004-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      */
     #ifndef VNODE_STORE_H
    @@ -10,9 +10,9 @@
     
     
     struct vnode_store {
    -	vm_store	vm;
    -	void		*vnode;
    -	void		*file_cache_ref;
    +	vm_store		vm;
    +	struct vnode*	vnode;
    +	void*			file_cache_ref;
     };
     
     #endif	/* VNODE_STORE_H */
    
    Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/fs/vfs.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/fs/vfs.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -685,6 +685,12 @@
     	// count, so that it will neither become negative nor 0.
     	vnode->ref_count = 2;
     
    +	// The file system has removed the resources of the vnode now, so we can
    +	// make it available again (and remove the busy vnode from the hash)
    +	mutex_lock(&sVnodeMutex);
    +	hash_remove(sVnodeTable, vnode);
    +	mutex_unlock(&sVnodeMutex);
    +
     	// TODO: Usually, when the vnode is unreferenced, no one can get hold of the
     	// cache either (i.e. no one can get a cache reference while we're deleting
     	// the vnode).. This is, however, not the case for the page daemon. It gets
    @@ -692,18 +698,15 @@
     	// vnode reference while we're deleting the vnode.
     
     	if (!vnode->unpublished) {
    -		if (vnode->remove)
    -			FS_CALL(vnode, remove_vnode)(vnode->mount->cookie, vnode->private_node, reenter);
    -		else
    -			FS_CALL(vnode, put_vnode)(vnode->mount->cookie, vnode->private_node, reenter);
    +		if (vnode->remove) {
    +			FS_CALL(vnode, remove_vnode)(vnode->mount->cookie,
    +				vnode->private_node, reenter);
    +		} else {
    +			FS_CALL(vnode, put_vnode)(vnode->mount->cookie, vnode->private_node,
    +				reenter);
    +		}
     	}
     
    -	// The file system has removed the resources of the vnode now, so we can
    -	// make it available again (and remove the busy vnode from the hash)
    -	mutex_lock(&sVnodeMutex);
    -	hash_remove(sVnodeTable, vnode);
    -	mutex_unlock(&sVnodeMutex);
    -
     	// if we have a vm_cache attached, remove it
     	if (vnode->cache)
     		vm_cache_release_ref(vnode->cache);
    @@ -3116,12 +3119,11 @@
     }
     
     
    -/** Gets the vnode's vm_cache object. If it didn't have one, it will be
    - *	created if \a allocate is \c true.
    - *	In case it's successful, it will also grab a reference to the cache
    - *	it returns (and therefore, one from the \a vnode in question as well).
    - */
    -
    +/*!	Gets the vnode's vm_cache object. If it didn't have one, it will be
    +	created if \a allocate is \c true.
    +	In case it's successful, it will also grab a reference to the cache
    +	it returns.
    +*/
     extern "C" status_t
     vfs_get_vnode_cache(void *_vnode, vm_cache **_cache, bool allocate)
     {
    @@ -4222,9 +4224,9 @@
     
     			// O_CLOEXEC is the only flag available at this time
     			mutex_lock(&context->io_mutex);
    -			fd_set_close_on_exec(context, fd, argument & FD_CLOEXEC);
    +			fd_set_close_on_exec(context, fd, (argument & FD_CLOEXEC) != 0);
     			mutex_unlock(&context->io_mutex);
    -			
    +
     			status = B_OK;
     			break;
     		}
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -1761,7 +1761,7 @@
     	The vnode has to be marked busy when calling this function.
     */
     status_t
    -vm_create_vnode_cache(void *vnode, struct vm_cache **_cache)
    +vm_create_vnode_cache(struct vnode *vnode, struct vm_cache **_cache)
     {
     	status_t status;
     
    @@ -1787,11 +1787,10 @@
     }
     
     
    -/** Will map the file at the path specified by \a name to an area in memory.
    - *	The file will be mirrored beginning at the specified \a offset. The \a offset
    - *	and \a size arguments have to be page aligned.
    - */
    -
    +/*!	Will map the file at the path specified by \a name to an area in memory.
    +	The file will be mirrored beginning at the specified \a offset. The \a offset
    +	and \a size arguments have to be page aligned.
    +*/
     static area_id
     _vm_map_file(team_id team, const char *name, void **_address, uint32 addressSpec,
     	size_t size, uint32 protection, uint32 mapping, const char *path,
    @@ -1827,13 +1826,10 @@
     
     	// ToDo: this only works for file systems that use the file cache
     	status = vfs_get_vnode_cache(vnode, &cache, false);
    -
    -	vfs_put_vnode(vnode);
    -		// we don't need this vnode anymore - if the above call was
    -		// successful, the store already has a ref to it
    -
    -	if (status < B_OK)
    +	if (status < B_OK) {
    +		vfs_put_vnode(vnode);
     		return status;
    +	}
     
     	mutex_lock(&cache->lock);
     
    @@ -1842,6 +1838,10 @@
     
     	mutex_unlock(&cache->lock);
     
    +	vfs_put_vnode(vnode);
    +		// we don't need this vnode anymore - if the above call was
    +		// successful, the store already has a ref to it
    +
     	if (status < B_OK || mapping == REGION_PRIVATE_MAP) {
     		// map_backing_store() cannot know we no longer need the ref
     		vm_cache_release_ref(cache);
    @@ -2539,6 +2539,9 @@
     		area->mappings.Add(mapping);
     	}
     
    +	if (page->usage_count < 0)
    +		page->usage_count = 1;
    +
     	if (page->state != PAGE_STATE_MODIFIED)
     		vm_page_set_state(page, PAGE_STATE_ACTIVE);
     
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -80,16 +80,14 @@
     }
     
     
    -/*!	Acquires a pseudo reference to a cache yet unreferenced by the caller. The
    +/*!	Acquires a reference to a cache yet unreferenced by the caller. The
     	caller must make sure, that the cache is not deleted, e.g. by holding the
     	cache's source cache lock or by holding the page cache table lock while the
    -	cache is still referred to by a page. To get a real reference, the caller
    -	must subsequently call vm_cache_acquire_ref() and decrement the cache's ref
    -	count manually afterwards.
    -	Returns \c true, if the pseudo reference could be acquired.
    +	cache is still referred to by a page.
    +	Returns \c true, if the reference could be acquired.
     */
     static inline bool
    -acquire_unreferenced_cache_pseudo_ref(vm_cache* cache)
    +acquire_unreferenced_cache_ref(vm_cache* cache)
     {
     	while (true) {
     		int32 count = cache->ref_count;
    @@ -102,6 +100,73 @@
     }
     
     
    +static void
    +delete_cache(vm_cache *cache)
    +{
    +	if (cache->areas != NULL)
    +		panic("cache %p to be deleted still has areas", cache);
    +	if (!list_is_empty(&cache->consumers))
    +		panic("cache %p to be deleted still has consumers", cache);
    +
    +#if DEBUG_CACHE_LIST
    +	int state = disable_interrupts();
    +	acquire_spinlock(&sDebugCacheListLock);
    +
    +	if (cache->debug_previous)
    +		cache->debug_previous->debug_next = cache->debug_next;
    +	if (cache->debug_next)
    +		cache->debug_next->debug_previous = cache->debug_previous;
    +	if (cache == gDebugCacheList)
    +		gDebugCacheList = cache->debug_next;
    +
    +	release_spinlock(&sDebugCacheListLock);
    +	restore_interrupts(state);
    +#endif
    +
    +	// delete the cache's backing store
    +	cache->store->ops->destroy(cache->store);
    +
    +	// free all of the pages in the cache
    +	vm_page *page = cache->page_list;
    +	while (page) {
    +		vm_page *oldPage = page;
    +		int state;
    +
    +		page = page->cache_next;
    +
    +		if (!oldPage->mappings.IsEmpty() || oldPage->wired_count != 0) {
    +			panic("remove page %p from cache %p: page still has mappings!\n",
    +				oldPage, cache);
    +		}
    +
    +		// remove it from the hash table
    +		state = disable_interrupts();
    +		acquire_spinlock(&sPageCacheTableLock);
    +
    +		hash_remove(sPageCacheTable, oldPage);
    +		oldPage->cache = NULL;
    +		// TODO: we also need to remove all of the page's mappings!
    +
    +		release_spinlock(&sPageCacheTableLock);
    +		restore_interrupts(state);
    +
    +		TRACE(("vm_cache_release_ref: freeing page 0x%lx\n",
    +			oldPage->physical_page_number));
    +		vm_page_set_state(oldPage, PAGE_STATE_FREE);
    +	}
    +
    +	// remove the ref to the source
    +	if (cache->source)
    +		vm_cache_remove_consumer(cache->source, cache);
    +
    +	mutex_destroy(&cache->lock);
    +	free(cache);
    +}
    +
    +
    +//	#pragma mark -
    +
    +
     status_t
     vm_cache_init(kernel_args *args)
     {
    @@ -181,9 +246,6 @@
     	if (cache == NULL)
     		panic("vm_cache_acquire_ref: passed NULL\n");
     
    -	if (cache->store->ops->acquire_ref != NULL)
    -		cache->store->ops->acquire_ref(cache->store);
    -
     	atomic_add(&cache->ref_count, 1);
     }
     
    @@ -191,8 +253,6 @@
     void
     vm_cache_release_ref(vm_cache *cache)
     {
    -	vm_page *page;
    -
     	TRACE(("vm_cache_release_ref: cacheRef %p, ref will be %ld\n",
     		cache, cache->ref_count - 1));
     
    @@ -200,10 +260,6 @@
     		panic("vm_cache_release_ref: passed NULL\n");
     
     	if (atomic_add(&cache->ref_count, -1) != 1) {
    -		// the store ref is only released on the "working" refs, not
    -		// on the initial one (this is vnode specific)
    -		if (cache->store->ops->release_ref)
    -			cache->store->ops->release_ref(cache->store);
     #if 0
     {
     	// count min references to see if everything is okay
    @@ -237,64 +293,7 @@
     
     	// delete this cache
     
    -	if (cache->areas != NULL)
    -		panic("cache %p to be deleted still has areas", cache);
    -	if (!list_is_empty(&cache->consumers))
    -		panic("cache %p to be deleted still has consumers", cache);
    -
    -#if DEBUG_CACHE_LIST
    -	int state = disable_interrupts();
    -	acquire_spinlock(&sDebugCacheListLock);
    -
    -	if (cache->debug_previous)
    -		cache->debug_previous->debug_next = cache->debug_next;
    -	if (cache->debug_next)
    -		cache->debug_next->debug_previous = cache->debug_previous;
    -	if (cache == gDebugCacheList)
    -		gDebugCacheList = cache->debug_next;
    -
    -	release_spinlock(&sDebugCacheListLock);
    -	restore_interrupts(state);
    -#endif
    -
    -	// delete the cache's backing store
    -	cache->store->ops->destroy(cache->store);
    -
    -	// free all of the pages in the cache
    -	page = cache->page_list;
    -	while (page) {
    -		vm_page *oldPage = page;
    -		int state;
    -
    -		page = page->cache_next;
    -
    -		if (!oldPage->mappings.IsEmpty() || oldPage->wired_count != 0) {
    -			panic("remove page %p from cache %p: page still has mappings!\n",
    -				oldPage, cache);
    -		}
    -
    -		// remove it from the hash table
    -		state = disable_interrupts();
    -		acquire_spinlock(&sPageCacheTableLock);
    -
    -		hash_remove(sPageCacheTable, oldPage);
    -		oldPage->cache = NULL;
    -		// TODO: we also need to remove all of the page's mappings!
    -
    -		release_spinlock(&sPageCacheTableLock);
    -		restore_interrupts(state);
    -
    -		TRACE(("vm_cache_release_ref: freeing page 0x%lx\n",
    -			oldPage->physical_page_number));
    -		vm_page_set_state(oldPage, PAGE_STATE_FREE);
    -	}
    -
    -	// remove the ref to the source
    -	if (cache->source)
    -		vm_cache_remove_consumer(cache->source, cache);
    -
    -	mutex_destroy(&cache->lock);
    -	free(cache);
    +	delete_cache(cache);
     }
     
     
    @@ -307,16 +306,10 @@
     	if (cache == NULL)
     		return NULL;
     
    -	// get a pseudo reference
    -	if (!acquire_unreferenced_cache_pseudo_ref(cache))
    +	// get a reference
    +	if (!acquire_unreferenced_cache_ref(cache))
     		return NULL;
     
    -	locker.Unlock();
    -
    -	// turn it into a real reference
    -	vm_cache_acquire_ref(cache);
    -	atomic_add(&cache->ref_count, -1);
    -
     	return cache;
     }
     
    @@ -541,6 +534,9 @@
     	list_remove_item(&cache->consumers, consumer);
     	consumer->source = NULL;
     
    +	if (cache->store->ops->release_ref)
    +		cache->store->ops->release_ref(cache->store);
    +
     	if (cache->areas == NULL && cache->source != NULL
     		&& !list_is_empty(&cache->consumers)
     		&& cache->consumers.link.next == cache->consumers.link.prev) {
    @@ -549,14 +545,7 @@
     
     		consumer = (vm_cache *)list_get_first_item(&cache->consumers);
     
    -		bool merge = acquire_unreferenced_cache_pseudo_ref(consumer);
    -		if (merge) {
    -			// We managed to increment the reference count, but that's not a
    -			// full reference. We get a real one now and decrement the ref count
    -			// again.
    -			vm_cache_acquire_ref(consumer);
    -			atomic_add(&consumer->ref_count, -1);
    -		}
    +		bool merge = acquire_unreferenced_cache_ref(consumer);
     
     		// In case we managed to grab a reference to the consumerRef,
     		// this doesn't guarantee that we get the cache we wanted
    @@ -696,6 +685,9 @@
     	list_add_item(&cache->consumers, consumer);
     
     	vm_cache_acquire_ref(cache);
    +
    +	if (cache->store->ops->acquire_ref != NULL)
    +		cache->store->ops->acquire_ref(cache->store);
     }
     
     
    @@ -714,6 +706,9 @@
     	area->cache_prev = NULL;
     	cache->areas = area;
     
    +	if (cache->store->ops->acquire_ref != NULL)
    +		cache->store->ops->acquire_ref(cache->store);
    +
     	return B_OK;
     }
     
    @@ -730,6 +725,9 @@
     	if (cache->areas == area)
     		cache->areas = area->cache_next;
     
    +	if (cache->store->ops->release_ref)
    +		cache->store->ops->release_ref(cache->store);
    +
     	mutex_unlock(&cache->lock);
     	return B_OK;
     }
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 00:06:18 UTC (rev 22314)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 00:20:23 UTC (rev 22315)
    @@ -6,6 +6,9 @@
      * Distributed under the terms of the NewOS License.
      */
     
    +#include 
    +#include 
    +#include 
     
     #include 
     #include 
    @@ -16,15 +19,14 @@
     #include 
     #include 
     #include 
    +#include 
     #include 
     #include 
    +#include 
     #include 
     #include 
     #include 
     
    -#include 
    -#include 
    -#include 
     
     //#define TRACE_VM_PAGE
     #ifdef TRACE_VM_PAGE
    @@ -53,6 +55,7 @@
     static addr_t sPhysicalPageOffset;
     static size_t sNumPages;
     
    +static ConditionVariable sFreePageCondition;
     static spinlock sPageLock;
     
     static sem_id modified_pages_available;
    @@ -414,8 +417,8 @@
     static status_t
     set_page_state_nolock(vm_page *page, int pageState)
     {
    -	page_queue *from_q = NULL;
    -	page_queue *to_q = NULL;
    +	page_queue *fromQueue = NULL;
    +	page_queue *toQueue = NULL;
     
     	switch (page->state) {
     		case PAGE_STATE_BUSY:
    @@ -423,16 +426,16 @@
     		case PAGE_STATE_INACTIVE:
     		case PAGE_STATE_WIRED:
     		case PAGE_STATE_UNUSED:
    -			from_q = &sActivePageQueue;
    +			fromQueue = &sActivePageQueue;
     			break;
     		case PAGE_STATE_MODIFIED:
    -			from_q = &sModifiedPageQueue;
    +			fromQueue = &sModifiedPageQueue;
     			break;
     		case PAGE_STATE_FREE:
    -			from_q = &sFreePageQueue;
    +			fromQueue = &sFreePageQueue;
     			break;
     		case PAGE_STATE_CLEAR:
    -			from_q = &sClearPageQueue;
    +			fromQueue = &sClearPageQueue;
     			break;
     		default:
     			panic("vm_page_set_state: vm_page %p in invalid state %d\n", page, page->state);
    @@ -442,10 +445,6 @@
     		if (page->cache != NULL)
     			panic("free page %p has cache", page);
     	}
    -	if (pageState == PAGE_STATE_CLEAR || pageState == PAGE_STATE_FREE) {
    -		if (page->cache != NULL)
    -			panic("to be freed page %p has cache", page);
    -	}
     
     	switch (pageState) {
     		case PAGE_STATE_BUSY:
    @@ -453,22 +452,31 @@
     		case PAGE_STATE_INACTIVE:
     		case PAGE_STATE_WIRED:
     		case PAGE_STATE_UNUSED:
    -			to_q = &sActivePageQueue;
    +			toQueue = &sActivePageQueue;
     			break;
     		case PAGE_STATE_MODIFIED:
    -			to_q = &sModifiedPageQueue;
    +			toQueue = &sModifiedPageQueue;
     			break;
     		case PAGE_STATE_FREE:
    -			to_q = &sFreePageQueue;
    +			toQueue = &sFreePageQueue;
     			break;
     		case PAGE_STATE_CLEAR:
    -			to_q = &sClearPageQueue;
    +			toQueue = &sClearPageQueue;
     			break;
     		default:
     			panic("vm_page_set_state: invalid target state %d\n", pageState);
     	}
    +
    +	if (pageState == PAGE_STATE_CLEAR || pageState == PAGE_STATE_FREE) {
    +		if (sFreePageQueue.count + sClearPageQueue.count == 0)
    +			sFreePageCondition.NotifyAll();
    +
    +		if (page->cache != NULL)
    +			panic("to be freed page %p has cache", page);
    +	}
    +
     	page->state = pageState;
    -	move_page_to_queue(from_q, to_q, page);
    +	move_page_to_queue(fromQueue, toQueue, page);
     
     	return B_OK;
     }
    @@ -661,6 +669,82 @@
     }
     
     
    +static void
    +page_thief(void* /*unused*/, int32 level)
    +{
    +	uint32 steal;
    +	int32 score;
    +
    +	switch (level) {
    +		default:
    +		case B_LOW_MEMORY_NOTE:
    +			steal = 10;
    +			score = -20;
    +			break;
    +		case B_LOW_MEMORY_WARNING:
    +			steal = 50;
    +			score = -5;
    +			break;
    +		case B_LOW_MEMORY_CRITICAL:
    +			steal = 500;
    +			score = -1;
    +			break;
    +	}
    +
    +	vm_page* page = NULL;
    +	InterruptsSpinLocker locker(sPageLock);
    +
    +	while (steal > 0) {
    +		if (!locker.IsLocked())
    +			locker.Lock();
    +
    +		// find a candidate to steal from the inactive queue
    +
    +		for (int32 i = sActivePageQueue.count; i-- > 0;) {
    +			// move page to the head of the queue so that we don't
    +			// scan it again directly
    +			page = dequeue_page(&sActivePageQueue);
    +			enqueue_page(&sActivePageQueue, page);
    +
    +			if (page->state == PAGE_STATE_INACTIVE
    +				&& page->usage_count <= score)
    +				break;
    +		}
    +
    +		if (page == NULL) {
    +			if (score == 0)
    +				break;
    +
    +			score = 0;
    +			continue;
    +		}
    +
    +		locker.Unlock();
    +
    +		// try to lock the page's cache
    +
    +		vm_cache* cache = vm_cache_acquire_page_cache_ref(page);
    +		if (cache == NULL)
    +			continue;
    +
    +		if (mutex_trylock(&cache->lock) != B_OK
    +			|| page->state != PAGE_STATE_INACTIVE) {
    +			vm_cache_release_ref(cache);
    +			continue;
    +		}
    +
    +		// we can now steal this page
    +
    +		vm_cache_remove_page(cache, page);
    +		vm_page_set_state(page, PAGE_STATE_FREE);
    +		steal--;
    +
    +		mutex_unlock(&cache->lock);
    +		vm_cache_release_ref(cache);
    +	}
    +}
    +
    +
     //	#pragma mark - private kernel API
     
     
    @@ -904,6 +988,11 @@
     	tid = thread_create_kernel_thread("pageout daemon", &pageout_daemon, B_FIRST_REAL_TIME_PRIORITY + 1);
     	thread_resume_thread(tid);
     #endif
    +
    +	new (&sFreePageCondition) ConditionVariable;
    +	sFreePageCondition.Publish(&sFreePageQueue, "free page");
    +
    +	register_low_memory_handler(page_thief, NULL, 0);
     	return B_OK;
     }
     
    @@ -967,6 +1056,9 @@
     vm_page *
     vm_page_allocate_page(int pageState)
     {
    +	// TODO: we may want to have a "canWait" argument
    +
    +	ConditionVariableEntry freeConditionEntry;
     	page_queue *queue;
     	page_queue *otherQueue;
     
    @@ -983,33 +1075,43 @@
     			return NULL; // invalid
     	}
     
    -	cpu_status state = disable_interrupts();
    -	acquire_spinlock(&sPageLock);
    +	InterruptsSpinLocker locker(sPageLock);
     
    -	vm_page *page = dequeue_page(queue);
    -	if (page == NULL) {
    +	vm_page *page = NULL;
    +	while (true) {
    +		page = dequeue_page(queue);
    +		if (page == NULL) {
     #ifdef DEBUG
    -		if (queue->count != 0)
    -			panic("queue %p corrupted, count = %d\n", queue, queue->count);
    +			if (queue->count != 0)
    +				panic("queue %p corrupted, count = %d\n", queue, queue->count);
     #endif
     
    -		// if the primary queue was empty, grap the page from the
    -		// secondary queue
    -		page = dequeue_page(otherQueue);
    -		if (page == NULL) {
    +			// if the primary queue was empty, grap the page from the
    +			// secondary queue
    +			page = dequeue_page(otherQueue);
    +			if (page == NULL) {
     #ifdef DEBUG
    -			if (otherQueue->count != 0) {
    -				panic("other queue %p corrupted, count = %d\n", otherQueue,
    -					otherQueue->count);
    -			}
    +				if (otherQueue->count != 0) {
    +					panic("other queue %p corrupted, count = %d\n", otherQueue,
    +						otherQueue->count);
    +				}
     #endif
     
    -			// ToDo: issue "someone" to free up some pages for us, and go into
    -			// wait state until that's done
    -			panic("vm_allocate_page: out of memory! page state = %d\n",
    -				pageState);
    +				freeConditionEntry.Add(&sFreePageQueue);
    +				vm_low_memory(1);
    +			}
     		}
    +		if (page != NULL)
    +			break;
    +
    +		// we need to wait until new pages become available
    +		locker.Unlock();
    +
    +		freeConditionEntry.Wait();
    +
    +		locker.Lock();
     	}
    +
     	if (page->cache != NULL)
     		panic("supposed to be free page %p has cache\n", page);
     
    @@ -1018,8 +1120,7 @@
     
     	enqueue_page(&sActivePageQueue, page);
     
    -	release_spinlock(&sPageLock);
    -	restore_interrupts(state);
    +	locker.Unlock();
     
     	// if needed take the page from the free queue and zero it out
     	if (pageState == PAGE_STATE_CLEAR && oldPageState != PAGE_STATE_CLEAR)
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 11:43:59 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 11:43:59 +0200
    Subject: [Haiku-commits] r22316 - in haiku/trunk: build/jam
    	src/add-ons/kernel/file_systems src/add-ons/kernel/file_systems/fat
    Message-ID: <200709260943.l8Q9hxRS002101@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 11:43:58 +0200 (Wed, 26 Sep 2007)
    New Revision: 22316
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22316&view=rev
    
    Added:
       haiku/trunk/src/add-ons/kernel/file_systems/fat/
    Removed:
       haiku/trunk/src/add-ons/kernel/file_systems/dos/
    Modified:
       haiku/trunk/build/jam/HaikuImage
       haiku/trunk/src/add-ons/kernel/file_systems/Jamfile
       haiku/trunk/src/add-ons/kernel/file_systems/fat/Jamfile
       haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
    Log:
    Renamed "dos" file system to "fat".
    
    
    Modified: haiku/trunk/build/jam/HaikuImage
    ===================================================================
    --- haiku/trunk/build/jam/HaikuImage	2007-09-26 00:20:23 UTC (rev 22315)
    +++ haiku/trunk/build/jam/HaikuImage	2007-09-26 09:43:58 UTC (rev 22316)
    @@ -125,7 +125,7 @@
     BEOS_ADD_ONS_BUS_MANAGERS = pci $(X86_ONLY)ps2 $(X86_ONLY)isa ide scsi
     	config_manager $(X86_ONLY)agp usb firewire
     ;
    -BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda dos googlefs iso9660 nfs ;
    +BEOS_ADD_ONS_FILE_SYSTEMS = bfs cdda fat googlefs iso9660 nfs ;
     
     
     # modules
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/Jamfile	2007-09-26 00:20:23 UTC (rev 22315)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/Jamfile	2007-09-26 09:43:58 UTC (rev 22316)
    @@ -1,8 +1,8 @@
     SubDir HAIKU_TOP src add-ons kernel file_systems ;
     
    -SubInclude HAIKU_TOP src add-ons kernel file_systems dos ;
     SubInclude HAIKU_TOP src add-ons kernel file_systems bfs ;
     SubInclude HAIKU_TOP src add-ons kernel file_systems cdda ;
    +SubInclude HAIKU_TOP src add-ons kernel file_systems fat ;
     SubInclude HAIKU_TOP src add-ons kernel file_systems googlefs ;
     SubInclude HAIKU_TOP src add-ons kernel file_systems iso9660 ;
     SubInclude HAIKU_TOP src add-ons kernel file_systems nfs ;
    
    Copied: haiku/trunk/src/add-ons/kernel/file_systems/fat (from rev 22315, haiku/trunk/src/add-ons/kernel/file_systems/dos)
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/dos/Jamfile	2007-09-26 00:20:23 UTC (rev 22315)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/Jamfile	2007-09-26 09:43:58 UTC (rev 22316)
    @@ -1,10 +1,10 @@
    -SubDir HAIKU_TOP src add-ons kernel file_systems dos ;
    +SubDir HAIKU_TOP src add-ons kernel file_systems fat ;
     
     UsePrivateHeaders kernel ;
     
     SubDirCcFlags -DTRACK_FILENAME ;
     
    -KernelAddon dos :
    +KernelAddon fat :
     	attr.c
     	dir.c
     	dlist.c
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/dos/dosfs.c	2007-09-26 00:20:23 UTC (rev 22315)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c	2007-09-26 09:43:58 UTC (rev 22316)
    @@ -47,7 +47,7 @@
     
     int32 instances = 0;
     
    -static int debug_dos(int argc, char **argv)
    +static int debug_fat(int argc, char **argv)
     {
     	int i;
     	for (i=1;imagic);
     		kprintf("id: %lx, fd: %x, device: %s, flags %lx\n",
     				vol->id, vol->fd, vol->device, vol->flags);
    @@ -429,7 +429,7 @@
     	vol->beos_vnid = INVALID_VNID_BITS_MASK;
     	{
     		void *handle;
    -		handle = load_driver_settings("dos");
    +		handle = load_driver_settings("fat");
     		vol->respect_disk_image =
     				get_driver_boolean_parameter(handle, "respect", true, true);
     		unload_driver_settings(handle);
    @@ -674,7 +674,7 @@
     	int op_sync_mode;
     	int fs_flags = 0;
     
    -	handle = load_driver_settings("dos");
    +	handle = load_driver_settings("fat");
     		debug_attr = strtoul(get_driver_parameter(handle, "debug_attr", "0", "0"), NULL, 0);
     		debug_dir = strtoul(get_driver_parameter(handle, "debug_dir", "0", "0"), NULL, 0);
     		debug_dlist = strtoul(get_driver_parameter(handle, "debug_dlist", "0", "0"), NULL, 0);
    @@ -734,11 +734,11 @@
     		}
     
     #if DEBUG
    -		load_driver_symbols("dos");
    +		load_driver_symbols("fat");
     
     		if (atomic_add(&instances, 1) == 0) {
    -			add_debugger_command("dos", debug_dos, "dump a dos nspace structure");
    -			add_debugger_command("dvnode", debug_dvnode, "dump a dos vnode structure");
    +			add_debugger_command("fat", debug_fat, "dump a fat nspace structure");
    +			add_debugger_command("dvnode", debug_dvnode, "dump a fat vnode structure");
     			add_debugger_command("dfvnid", debug_dfvnid, "find a vnid in the vnid cache");
     			add_debugger_command("dfloc", debug_dfloc, "find a loc in the vnid cache");
     			add_debugger_command("dc2s", debug_dc2s, "calculate sector for cluster");
    @@ -839,7 +839,7 @@
     
     #if DEBUG
     	if (atomic_add(&instances, -1) == 1) {
    -		remove_debugger_command("dos", debug_dos);
    +		remove_debugger_command("fat", debug_fat);
     		remove_debugger_command("dvnode", debug_dvnode);
     		remove_debugger_command("dfvnid", debug_dfvnid);
     		remove_debugger_command("dfloc", debug_dfloc);
    @@ -1184,9 +1184,9 @@
     }
     
     
    -static file_system_module_info sDosFileSystem = {
    +static file_system_module_info sFATFileSystem = {
     	{
    -		"file_systems/dos" B_CURRENT_FS_API_VERSION,
    +		"file_systems/fat" B_CURRENT_FS_API_VERSION,
     		0,
     		dos_std_ops,
     	},
    @@ -1294,6 +1294,6 @@
     };
     
     module_info *modules[] = {
    -	(module_info *)&sDosFileSystem,
    +	(module_info *)&sFATFileSystem,
     	NULL,
     };
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 15:19:57 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 15:19:57 +0200
    Subject: [Haiku-commits] r22317 -
    	haiku/trunk/src/add-ons/kernel/file_systems/fat
    Message-ID: <200709261319.l8QDJv1N003415@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 15:19:57 +0200 (Wed, 26 Sep 2007)
    New Revision: 22317
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22317&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
    Log:
    * block_cache_set_dirty() was used incorrectly; I wonder why I write any
      documentation... when you ask the block cache for a writable block, it's
      automatically dirty.
    * This fixes bug #1330.
    * Minor style cleanup.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c	2007-09-26 09:43:58 UTC (rev 22316)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/fat/dosfs.c	2007-09-26 13:19:57 UTC (rev 22317)
    @@ -2,6 +2,7 @@
     	Copyright 1999-2001, Be Incorporated.   All Rights Reserved.
     	This file may be used under the terms of the Be Sample Code License.
     */
    +
     #include 
     #include 
     #include 
    @@ -47,10 +48,11 @@
     
     int32 instances = 0;
     
    -static int debug_fat(int argc, char **argv)
    +static int
    +debug_fat(int argc, char **argv)
     {
     	int i;
    -	for (i=1;imagic = NSPACE_MAGIC;
     	vol->flags = B_FS_IS_PERSISTENT | B_FS_HAS_MIME;
     	vol->fs_flags = fs_flags;
    @@ -168,12 +178,11 @@
     		dprintf("dosfs: unable to open %s (%s)\n", path, strerror(err));
     		goto error0;
     	}
    -	
    +
     	// get device characteristics
     	if (ioctl(vol->fd, B_GET_GEOMETRY, &geo) < 0) {
     		struct stat st;
    -		if ((fstat(vol->fd, &st) >= 0) &&
    -		    S_ISREG(st.st_mode)) {
    +		if (fstat(vol->fd, &st) >= 0 && S_ISREG(st.st_mode)) {
     			/* support mounting disk images */
     			geo.bytes_per_sector = 0x200;
     			geo.sectors_per_track = 1;
    @@ -210,19 +219,20 @@
     
     	// see if we need to go into op sync mode
     	vol->fs_flags &= ~FS_FLAGS_OP_SYNC;
    -	switch(op_sync_mode) {
    +	switch (op_sync_mode) {
     		case 1:
    -			if((vol->flags & B_FS_IS_REMOVABLE) == 0) {
    +			if ((vol->flags & B_FS_IS_REMOVABLE) == 0) {
     				// we're not removable, so skip op_sync
     				break;
     			}
    +			// supposed to fall through
     		case 2:
     			dprintf("dosfs: mounted with op_sync enabled\n");
     			vol->fs_flags |= FS_FLAGS_OP_SYNC;
     			break;
     		case 0:
     		default:
    -			;
    +			break;
     	}
     
     	// read in the boot sector
    @@ -233,44 +243,45 @@
     
     	// only check boot signature on hard disks to account for broken mtools
     	// behavior
    -	if (((buf[0x1fe] != 0x55) || (buf[0x1ff] != 0xaa)) && (buf[0x15] == 0xf8))
    +	if ((buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) && buf[0x15] == 0xf8)
     		goto error;
     
     	if (!memcmp(buf+3, "NTFS    ", 8) || !memcmp(buf+3, "HPFS    ", 8)) {
    -		dprintf("%4.4s, not FAT\n", buf+3);
    +		dprintf("%4.4s, not FAT\n", buf + 3);
     		goto error;
     	}
     
     	// first fill in the universal fields from the bpb
    -	vol->bytes_per_sector = read16(buf,0xb);
    -	if ((vol->bytes_per_sector != 0x200) && (vol->bytes_per_sector != 0x400) && (vol->bytes_per_sector != 0x800)) {
    +	vol->bytes_per_sector = read16(buf, 0xb);
    +	if (vol->bytes_per_sector != 0x200 && vol->bytes_per_sector != 0x400
    +		&& vol->bytes_per_sector != 0x800) {
     		dprintf("dosfs error: unsupported bytes per sector (%lu)\n",
     				vol->bytes_per_sector);
     		goto error;
     	}
    -	
    +
     	vol->sectors_per_cluster = i = buf[0xd];
    -	if ((i != 1) && (i != 2) && (i != 4) && (i != 8) && 
    -		(i != 0x10) && (i != 0x20) && (i != 0x40) && (i != 0x80)) {
    +	if (i != 1 && i != 2 && i != 4 && i != 8
    +		&& i != 0x10 && i != 0x20 && i != 0x40 && i != 0x80) {
     		dprintf("dosfs: sectors/cluster = %d\n", i);
     		goto error;
     	}
     
    -	vol->reserved_sectors = read16(buf,0xe);
    +	vol->reserved_sectors = read16(buf, 0xe);
     
     	vol->fat_count = buf[0x10];
    -	if ((vol->fat_count == 0) || (vol->fat_count > 8)) {
    +	if (vol->fat_count == 0 || vol->fat_count > 8) {
     		dprintf("dosfs: unreasonable fat count (%lu)\n", vol->fat_count);
     		goto error;
     	}
     
     	vol->media_descriptor = buf[0x15];
     	// check media descriptor versus known types
    -	if ((buf[0x15] != 0xF0) && (buf[0x15] < 0xf8)) {
    +	if (buf[0x15] != 0xf0 && buf[0x15] < 0xf8) {
     		dprintf("dosfs error: invalid media descriptor byte\n");
     		goto error;
     	}
    -	
    +
     	vol->vol_entry = -2;	// for now, assume there is no volume entry
     	memset(vol->vol_label, ' ', 11);
     
    @@ -281,9 +292,10 @@
     		vol->fat_bits = 32;
     		vol->sectors_per_fat = read32(buf,0x24);
     		vol->total_sectors = read32(buf,0x20);
    -		
    +
     		vol->fsinfo_sector = read16(buf, 0x30);
    -		if ((vol->fsinfo_sector != 0xffff) && (vol->fsinfo_sector >= vol->reserved_sectors)) {
    +		if (vol->fsinfo_sector != 0xffff
    +			&& vol->fsinfo_sector >= vol->reserved_sectors) {
     			dprintf("dosfs: fsinfo sector too large (%x)\n", vol->fsinfo_sector);
     			goto error;
     		}
    @@ -544,18 +556,20 @@
     error0:
     	close(vol->fd);
     	free(vol);
    -	return (err >= B_NO_ERROR) ? EINVAL : err;
    +	return err >= B_NO_ERROR ? EINVAL : err;
     }
     
     
     //	#pragma mark - Scanning
     
    +
     typedef struct identify_cookie {
     	uint32 bytes_per_sector;
     	uint32 total_sectors;
     	char name[12];
     } identify_cookie;
     
    +
     static float
     dosfs_identify_partition(int fd, partition_data *partition, void **_cookie)
     {
    @@ -671,10 +685,11 @@
     	int	result;
     	nspace	*vol;
     	void *handle;
    -	int op_sync_mode;
    +	int op_sync_mode = 0;
     	int fs_flags = 0;
     
     	handle = load_driver_settings("fat");
    +	if (handle != NULL) {
     		debug_attr = strtoul(get_driver_parameter(handle, "debug_attr", "0", "0"), NULL, 0);
     		debug_dir = strtoul(get_driver_parameter(handle, "debug_dir", "0", "0"), NULL, 0);
     		debug_dlist = strtoul(get_driver_parameter(handle, "debug_dlist", "0", "0"), NULL, 0);
    @@ -684,20 +699,20 @@
     		debug_file = strtoul(get_driver_parameter(handle, "debug_file", "0", "0"), NULL, 0);
     		debug_iter = strtoul(get_driver_parameter(handle, "debug_iter", "0", "0"), NULL, 0);
     		debug_vcache = strtoul(get_driver_parameter(handle, "debug_vcache", "0", "0"), NULL, 0);
    -	
    +
     		op_sync_mode = strtoul(get_driver_parameter(handle, "op_sync_mode", "0", "0"), NULL, 0);
    -		if (op_sync_mode < 0 || op_sync_mode > 2) {
    +		if (op_sync_mode < 0 || op_sync_mode > 2)
     			op_sync_mode = 0;
    -		}
     		if (strcasecmp(get_driver_parameter(handle, "lock_device", "true", "true"), "false") == 0) {
     			dprintf("dosfs: mounted with lock_device = false\n");
     		} else {
     			dprintf("dosfs: mounted with lock_device = true\n");
     			fs_flags |= FS_FLAGS_LOCK_DOOR;
     		}
    -		
    -	unload_driver_settings(handle);
    -	
    +
    +		unload_driver_settings(handle);
    +	}
    +
     	/* args is a command line option; dosfs doesn't use any so
     	   we can ignore these arguments */
     	TOUCH(args);
    @@ -756,14 +771,16 @@
     	return EINVAL;
     }
     
    -static void update_fsinfo(nspace *vol)
    +
    +static void
    +update_fsinfo(nspace *vol)
     {
    -	if ((vol->fat_bits == 32) && (vol->fsinfo_sector != 0xffff) &&
    -		((vol->flags & B_FS_IS_READONLY) == false)) {
    +	if (vol->fat_bits == 32 && vol->fsinfo_sector != 0xffff
    +		&& (vol->flags & B_FS_IS_READONLY) == 0) {
     		uchar *buffer;
     		int32 tid = cache_start_transaction(vol->fBlockCache);
     		if ((buffer = (uchar *)block_cache_get_writable_etc(vol->fBlockCache, 
    -			vol->fsinfo_sector, 0, vol->bytes_per_sector, tid)) != NULL) {
    +				vol->fsinfo_sector, 0, vol->bytes_per_sector, tid)) != NULL) {
     			if ((read32(buffer,0) == 0x41615252) && (read32(buffer,0x1e4) == 0x61417272) && (read16(buffer,0x1fe) == 0xaa55)) {
     				//number of free clusters
     				buffer[0x1e8] = (vol->free_clusters & 0xff);
    @@ -775,15 +792,17 @@
     				buffer[0x1ed] = ((vol->last_allocated >> 8) & 0xff);
     				buffer[0x1ee] = ((vol->last_allocated >> 16) & 0xff);
     				buffer[0x1ef] = ((vol->last_allocated >> 24) & 0xff);
    -				block_cache_set_dirty(vol->fBlockCache, vol->fsinfo_sector, true, tid);
     			} else {
     				dprintf("update_fsinfo: fsinfo block has invalid magic number\n");
    +				block_cache_set_dirty(vol->fBlockCache, vol->fsinfo_sector,
    +					false, tid);
     			}
     			block_cache_put(vol->fBlockCache, vol->fsinfo_sector);
     			cache_end_transaction(vol->fBlockCache, tid, NULL, NULL);
     		} else {
     			cache_end_transaction(vol->fBlockCache, tid, NULL, NULL);
    -			dprintf("update_fsinfo: error getting fsinfo sector %x\n", vol->fsinfo_sector);
    +			dprintf("update_fsinfo: error getting fsinfo sector %x\n",
    +				vol->fsinfo_sector);
     		}
     	}
     }
    @@ -976,10 +995,10 @@
     			}
     			if ((buffer[0x26] != 0x29) || memcmp(buffer + 0x2b, vol->vol_label, 11)) {
     				dprintf("dosfs_wfsstat: label mismatch\n");
    +				block_cache_set_dirty(vol->fBlockCache, 0, false, tid);
     				result = B_ERROR;
     			} else {
     				memcpy(buffer + 0x2b, name, 11);
    -				block_cache_set_dirty(vol->fBlockCache, 0, true, tid);
     				result = 0;
     			}
     			block_cache_put(vol->fBlockCache, 0);
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 16:01:28 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 16:01:28 +0200
    Subject: [Haiku-commits] r22318 - haiku/trunk/src/system/kernel/cache
    Message-ID: <200709261401.l8QE1Swp005579@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 16:01:28 +0200 (Wed, 26 Sep 2007)
    New Revision: 22318
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22318&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/cache/block_cache.cpp
    Log:
    Implemented a part of block_cache_set_dirty() so that it can gracefully exit
    in case there is nothing to do.
    
    
    Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/block_cache.cpp	2007-09-26 13:19:57 UTC (rev 22317)
    +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp	2007-09-26 14:01:28 UTC (rev 22318)
    @@ -1420,6 +1420,18 @@
     block_cache_set_dirty(void *_cache, off_t blockNumber, bool dirty,
     	int32 transaction)
     {
    +	block_cache *cache = (block_cache *)_cache;
    +	BenaphoreLocker locker(&cache->lock);
    +
    +	cached_block *block = (cached_block *)hash_lookup(cache->hash,
    +		&blockNumber);
    +	if (block == NULL)
    +		return B_BAD_VALUE;
    +	if (block->is_dirty == dirty) {
    +		// there is nothing to do for us
    +		return B_OK;
    +	}
    +
     	// TODO: not yet implemented
     	if (dirty)
     		panic("block_cache_set_dirty(): not yet implemented that way!\n");
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 19:42:27 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 19:42:27 +0200
    Subject: [Haiku-commits] r22319 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/arch/x86 src/system/kernel/cache
    	src/system/kernel/vm
    Message-ID: <200709261742.l8QHgRvs004869@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 19:42:25 +0200 (Wed, 26 Sep 2007)
    New Revision: 22319
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22319&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/vm_page.h
       haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c
       haiku/trunk/src/system/kernel/cache/block_allocator.cpp
       haiku/trunk/src/system/kernel/cache/file_cache.cpp
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * Since the page scanner and thief can work more effectively when no vm_caches
      are locked, there is now a vm_page_reserve_pages() call to ensure upfront that
      there is a page for me when I need it, and may have locked some caches.
    * The vm_soft_fault() routine now makes use of that feature.
    * vm_page_allocate_page() now resets the vm_page::usage_count, so that the file
      cache does not need to do this in read_chunk_into_cache() and
      write_chunk_to_cache().
    * In cache_io() however, it need to update the usage_count - and it does that
      now. Since non-mapped caches don't have mappings, the page scanner will punish
      the cache pages stronger than other pages which is accidently just what we
      want.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm_page.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_page.h	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/headers/private/kernel/vm_page.h	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -34,7 +34,10 @@
     
     status_t vm_page_write_modified(vm_cache *cache, bool fsReenter);
     
    -vm_page *vm_page_allocate_page(int state);
    +void vm_page_unreserve_pages(uint32 count);
    +void vm_page_reserve_pages(uint32 count);
    +
    +vm_page *vm_page_allocate_page(int pageState, bool reserved);
     status_t vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages);
     vm_page *vm_page_allocate_page_run(int state, addr_t length);
     vm_page *vm_page_at_index(int32 index);
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -352,7 +352,7 @@
     		vm_page *page;
     
     		// we need to allocate a pgtable
    -		page = vm_page_allocate_page(PAGE_STATE_CLEAR);
    +		page = vm_page_allocate_page(PAGE_STATE_CLEAR, false);
     
     		// mark the page WIRED
     		vm_page_set_state(page, PAGE_STATE_WIRED);
    
    Modified: haiku/trunk/src/system/kernel/cache/block_allocator.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/block_allocator.cpp	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/cache/block_allocator.cpp	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      */
     
    @@ -347,7 +347,7 @@
     		if (pages[pageBaseIndex] == NULL) {
     			// there are no pages for us yet
     			for (uint32 i = 0; i < numPages; i++) {
    -				vm_page *page = vm_page_allocate_page(PAGE_STATE_FREE);
    +				vm_page *page = vm_page_allocate_page(PAGE_STATE_FREE, false);
     				if (page == NULL) {
     					// ToDo: handle this gracefully
     					panic("no memory for block!!\n");
    
    Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -538,7 +538,7 @@
     	// allocate pages for the cache and mark them busy
     	for (size_t pos = 0; pos < numBytes; pos += B_PAGE_SIZE) {
     		vm_page *page = pages[pageIndex++] = vm_page_allocate_page(
    -			PAGE_STATE_FREE);
    +			PAGE_STATE_FREE, false);
     		if (page == NULL)
     			panic("no more pages!");
     
    @@ -612,10 +612,6 @@
     	// make the pages accessible in the cache
     	for (int32 i = pageIndex; i-- > 0;) {
     		pages[i]->state = PAGE_STATE_ACTIVE;
    -		if (pages[i]->usage_count < 0)
    -			pages[i]->usage_count = 1;
    -		else
    -			pages[i]->usage_count++;
     
     		busyConditions[i].Unpublish();
     	}
    @@ -697,11 +693,13 @@
     
     	// allocate pages for the cache and mark them busy
     	for (size_t pos = 0; pos < numBytes; pos += B_PAGE_SIZE) {
    -		// ToDo: if space is becoming tight, and this cache is already grown
    +		// TODO: if space is becoming tight, and this cache is already grown
     		//	big - shouldn't we better steal the pages directly in that case?
     		//	(a working set like approach for the file cache)
    +		// TODO: the pages we allocate here should have been reserved upfront
    +		//	in cache_io()
     		vm_page *page = pages[pageIndex++] = vm_page_allocate_page(
    -			PAGE_STATE_FREE);
    +			PAGE_STATE_FREE, false);
     		busyConditions[pageIndex - 1].Publish(page, "page");
     
     		vm_cache_insert_page(ref->cache, page, offset + pos);
    @@ -797,11 +795,6 @@
     	for (int32 i = pageIndex; i-- > 0;) {
     		busyConditions[i].Unpublish();
     
    -		if (pages[i]->usage_count < 0)
    -			pages[i]->usage_count = 1;
    -		else
    -			pages[i]->usage_count++;
    -
     		if (writeThrough)
     			pages[i]->state = PAGE_STATE_ACTIVE;
     		else
    @@ -960,6 +953,13 @@
     			vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE,
     				&virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
     
    +			// Since we don't actually map pages as part of an area, we have
    +			// to manually maintain its usage_count
    +			if (page->usage_count < 0)
    +				page->usage_count = 1;
    +			else
    +				page->usage_count++;
    +
     			// and copy the contents of the page already in memory
     			if (doWrite) {
     				user_memcpy((void *)(virtualAddress + pageOffset),
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -1498,7 +1498,7 @@
     #	endif
     					continue;
     #endif
    -				vm_page *page = vm_page_allocate_page(PAGE_STATE_CLEAR);
    +				vm_page *page = vm_page_allocate_page(PAGE_STATE_CLEAR, false);
     				if (page == NULL) {
     					// this shouldn't really happen, as we reserve the memory upfront
     					panic("couldn't fulfill B_FULL lock!");
    @@ -3789,7 +3789,7 @@
     		if (store->ops->has_page != NULL
     			&& store->ops->has_page(store, cacheOffset)) {
     			// insert a fresh page and mark it busy -- we're going to read it in
    -			page = vm_page_allocate_page(PAGE_STATE_FREE);
    +			page = vm_page_allocate_page(PAGE_STATE_FREE, true);
     			vm_cache_insert_page(cache, page, cacheOffset);
     
     			ConditionVariable busyCondition;
    @@ -3955,7 +3955,7 @@
     	if (page == NULL) {
     		// we still haven't found a page, so we allocate a clean one
     
    -		page = vm_page_allocate_page(PAGE_STATE_CLEAR);
    +		page = vm_page_allocate_page(PAGE_STATE_CLEAR, true);
     		FTRACE(("vm_soft_fault: just allocated page 0x%lx\n", page->physical_page_number));
     
     		// Insert the new page into our cache, and replace it with the dummy page if necessary
    @@ -4009,7 +4009,7 @@
     		// ToDo: if memory is low, it might be a good idea to steal the page
     		//	from our source cache - if possible, that is
     		FTRACE(("get new page, copy it, and put it into the topmost cache\n"));
    -		page = vm_page_allocate_page(PAGE_STATE_FREE);
    +		page = vm_page_allocate_page(PAGE_STATE_FREE, true);
     #if 0
     if (cacheOffset == 0x12000)
     	dprintf("%ld: copy page %p to page %p from cache %p to cache %p\n", find_thread(NULL),
    @@ -4176,6 +4176,11 @@
     	// The top most cache has no fault handler, so let's see if the cache or its sources
     	// already have the page we're searching for (we're going from top to bottom)
     
    +	vm_page_reserve_pages(2);
    +		// we may need up to 2 pages - reserving them upfront makes sure
    +		// we don't have any cache locked, so that the page daemon/thief
    +		// can do their job without problems
    +
     	vm_translation_map *map = &addressSpace->translation_map;
     	vm_dummy_page dummyPage;
     	dummyPage.cache = NULL;
    @@ -4230,6 +4235,7 @@
     	}
     
     	vm_cache_release_ref(topCache);
    +	vm_page_unreserve_pages(2);
     
     	return status;
     }
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 17:42:25 UTC (rev 22319)
    @@ -54,6 +54,7 @@
     static vm_page *sPages;
     static addr_t sPhysicalPageOffset;
     static size_t sNumPages;
    +static size_t sReservedPages;
     
     static ConditionVariable sFreePageCondition;
     static spinlock sPageLock;
    @@ -468,7 +469,7 @@
     	}
     
     	if (pageState == PAGE_STATE_CLEAR || pageState == PAGE_STATE_FREE) {
    -		if (sFreePageQueue.count + sClearPageQueue.count == 0)
    +		if (sFreePageQueue.count + sClearPageQueue.count <= sReservedPages)
     			sFreePageCondition.NotifyAll();
     
     		if (page->cache != NULL)
    @@ -1053,12 +1054,44 @@
     }
     
     
    -vm_page *
    -vm_page_allocate_page(int pageState)
    +void
    +vm_page_unreserve_pages(uint32 count)
     {
    -	// TODO: we may want to have a "canWait" argument
    +	InterruptsSpinLocker locker(sPageLock);
    +	ASSERT(sReservedPages >= count);
     
    +	sReservedPages -= count;
    +	
    +	if (vm_page_num_free_pages() <= sReservedPages)
    +		sFreePageCondition.NotifyAll();
    +}
    +
    +
    +void
    +vm_page_reserve_pages(uint32 count)
    +{
    +	InterruptsSpinLocker locker(sPageLock);
    +
    +	sReservedPages += count;
    +	size_t freePages = vm_page_num_free_pages();
    +	if (sReservedPages < freePages)
    +		return;
    +
     	ConditionVariableEntry freeConditionEntry;
    +	freeConditionEntry.Add(&sFreePageQueue);
    +	vm_low_memory(sReservedPages - freePages);
    +
    +	// we need to wait until new pages become available
    +	locker.Unlock();
    +
    +	freeConditionEntry.Wait();
    +}
    +
    +
    +vm_page *
    +vm_page_allocate_page(int pageState, bool reserved)
    +{
    +	ConditionVariableEntry freeConditionEntry;
     	page_queue *queue;
     	page_queue *otherQueue;
     
    @@ -1079,28 +1112,32 @@
     
     	vm_page *page = NULL;
     	while (true) {
    -		page = dequeue_page(queue);
    -		if (page == NULL) {
    +		if (reserved || sReservedPages < vm_page_num_free_pages()) {
    +			page = dequeue_page(queue);
    +			if (page == NULL) {
     #ifdef DEBUG
    -			if (queue->count != 0)
    -				panic("queue %p corrupted, count = %d\n", queue, queue->count);
    +				if (queue->count != 0)
    +					panic("queue %p corrupted, count = %d\n", queue, queue->count);
     #endif
     
    -			// if the primary queue was empty, grap the page from the
    -			// secondary queue
    -			page = dequeue_page(otherQueue);
    -			if (page == NULL) {
    +				// if the primary queue was empty, grap the page from the
    +				// secondary queue
    +				page = dequeue_page(otherQueue);
    +			}
    +		}
    +
    +		if (page == NULL) {
     #ifdef DEBUG
    -				if (otherQueue->count != 0) {
    -					panic("other queue %p corrupted, count = %d\n", otherQueue,
    -						otherQueue->count);
    -				}
    +			if (otherQueue->count != 0) {
    +				panic("other queue %p corrupted, count = %d\n", otherQueue,
    +					otherQueue->count);
    +			}
     #endif
     
    -				freeConditionEntry.Add(&sFreePageQueue);
    -				vm_low_memory(1);
    -			}
    +			freeConditionEntry.Add(&sFreePageQueue);
    +			vm_low_memory(sReservedPages + 1);
     		}
    +
     		if (page != NULL)
     			break;
     
    @@ -1117,6 +1154,7 @@
     
     	int oldPageState = page->state;
     	page->state = PAGE_STATE_BUSY;
    +	page->usage_count = 2;
     
     	enqueue_page(&sActivePageQueue, page);
     
    @@ -1142,7 +1180,7 @@
     	uint32 i;
     	
     	for (i = 0; i < numPages; i++) {
    -		pages[i] = vm_page_allocate_page(pageState);
    +		pages[i] = vm_page_allocate_page(pageState, false);
     		if (pages[i] == NULL) {
     			// allocation failed, we need to free what we already have
     			while (i-- > 0)
    @@ -1185,6 +1223,7 @@
     				sPages[start + i].is_cleared
     					= sPages[start + i].state == PAGE_STATE_CLEAR;
     				set_page_state_nolock(&sPages[start + i], PAGE_STATE_BUSY);
    +				sPages[i].usage_count = 2;
     			}
     			firstPage = &sPages[start];
     			break;
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 20:00:45 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 20:00:45 +0200
    Subject: [Haiku-commits] r22320 - haiku/trunk/src/system/kernel/cache
    Message-ID: <200709261800.l8QI0jJp006032@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 20:00:45 +0200 (Wed, 26 Sep 2007)
    New Revision: 22320
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22320&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/cache/file_cache.cpp
    Log:
    Actually, it's not a good idea to increase the usage_count, since every access
    is tracked while the page scanner runs much slower. Now, we just set it to a
    fixed positive, so that they can easily age in case they are actually unused.
    
    
    Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 17:42:25 UTC (rev 22319)
    +++ haiku/trunk/src/system/kernel/cache/file_cache.cpp	2007-09-26 18:00:45 UTC (rev 22320)
    @@ -955,10 +955,7 @@
     
     			// Since we don't actually map pages as part of an area, we have
     			// to manually maintain its usage_count
    -			if (page->usage_count < 0)
    -				page->usage_count = 1;
    -			else
    -				page->usage_count++;
    +			page->usage_count = 2;
     
     			// and copy the contents of the page already in memory
     			if (doWrite) {
    
    
    
    From marcusoverhagen at mail.berlios.de  Wed Sep 26 20:09:42 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Wed, 26 Sep 2007 20:09:42 +0200
    Subject: [Haiku-commits] r22321 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709261809.l8QI9gq5006604@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-26 20:09:42 +0200 (Wed, 26 Sep 2007)
    New Revision: 22321
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22321&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    Log:
    make sure PCI command register is setup correctly
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-26 18:00:45 UTC (rev 22320)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-26 18:09:42 UTC (rev 22321)
    @@ -80,6 +80,12 @@
     		TRACE("satacr0 = 0x%08lx, satacr1 = 0x%08lx\n", satacr0, satacr1);
     	}
     
    +	uint16 pcicmd = gPCI->read_pci_config(fPCIDevice, PCI_command, 2);
    +	TRACE("pcicmd old 0x%04x\n", pcicmd);
    +	pcicmd = PCI_PCICMD_BME | PCI_PCICMD_MSE | (pcicmd & ~PCI_PCICMD_IOS);
    +	TRACE("pcicmd new 0x%04x\n", pcicmd);
    +	gPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd);
    +
     	void *addr = (void *)pciInfo.u.h0.base_registers[5];
     	size_t size = pciInfo.u.h0.base_register_sizes[5];
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-26 18:00:45 UTC (rev 22320)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-26 18:09:42 UTC (rev 22321)
    @@ -219,6 +219,10 @@
     #define HI32(val) (((uint64)(val)) >> 32)
     #define ASSERT(expr) if (expr) {} else panic(#expr)
     
    +#define PCI_PCICMD_IOS	0x01
    +#define PCI_PCICMD_MSE	0x02
    +#define PCI_PCICMD_BME	0x04
    +
     #ifdef __cplusplus
     
     template 
    
    
    
    From korli at users.berlios.de  Wed Sep 26 20:37:45 2007
    From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=)
    Date: Wed, 26 Sep 2007 20:37:45 +0200
    Subject: [Haiku-commits] r22321 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    In-Reply-To: <200709261809.l8QI9gq5006604@sheep.berlios.de>
    References: <200709261809.l8QI9gq5006604@sheep.berlios.de>
    Message-ID: 
    
    Hi Marcus,
    
    2007/9/26, marcusoverhagen at BerliOS :
    >
    > +#define PCI_PCICMD_IOS 0x01
    > +#define PCI_PCICMD_MSE 0x02
    > +#define PCI_PCICMD_BME 0x04
    > +
    
    These are already defined here :
    
    #define PCI_command_io				0x001		/* 1/0 i/o space en/disabled */
    #define PCI_command_memory			0x002		/* 1/0 memory space en/disabled */
    #define PCI_command_master			0x004		/* 1/0 pci master en/disabled */
    
    Bye,
    J?r?me
    
    
    From marcusoverhagen at mail.berlios.de  Wed Sep 26 20:55:29 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Wed, 26 Sep 2007 20:55:29 +0200
    Subject: [Haiku-commits] r22322 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709261855.l8QItT0E008883@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-26 20:55:29 +0200 (Wed, 26 Sep 2007)
    New Revision: 22322
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22322&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    Log:
    The Jmicron AHCI controller on my machine is always in PATA emulation mode,
    despite using the "AHCI native" setting in the BIOS. 
    Added switching to AHCI mode during init, this makes it work.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-26 18:09:42 UTC (rev 22321)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-26 18:55:29 UTC (rev 22322)
    @@ -86,6 +86,15 @@
     	TRACE("pcicmd new 0x%04x\n", pcicmd);
     	gPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd);
     
    +	if (fPCIVendorID == PCI_VENDOR_JMICRON) {
    +		uint32 ctrl = gPCI->read_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4);
    +		TRACE("Jmicron controller control 1 old 0x%08lx\n", ctrl);
    +		ctrl &= ~((1 << 9) | (1 << 12) | (1 << 14));	// disable SFF 8038i emulation
    +		ctrl |= (1 << 8) | (1 << 13) | (1 << 15);		// enable AHCI controller
    +		TRACE("Jmicron controller control 1 new 0x%08lx\n", ctrl);
    +		gPCI->write_pci_config(fPCIDevice, PCI_JMICRON_CONTROLLER_CONTROL_1, 4, ctrl);
    +	}
    +
     	void *addr = (void *)pciInfo.u.h0.base_registers[5];
     	size_t size = pciInfo.u.h0.base_register_sizes[5];
     
    @@ -243,7 +252,7 @@
     	fRegs->pi = savePI;
     	FlushPostedWrites();
     
    -	if (fPCIVendorID == 0x8086) {
    +	if (fPCIVendorID == PCI_VENDOR_INTEL) {
     		// Intel PCS?Port Control and Status
     		// In AHCI enabled systems, bits[3:0] must always be set
     		gPCI->write_pci_config(fPCIDevice, 0x92, 2, 
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-26 18:09:42 UTC (rev 22321)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-26 18:55:29 UTC (rev 22322)
    @@ -223,6 +223,10 @@
     #define PCI_PCICMD_MSE	0x02
     #define PCI_PCICMD_BME	0x04
     
    +#define PCI_VENDOR_INTEL	0x8086
    +#define PCI_VENDOR_JMICRON	0x197b
    +#define PCI_JMICRON_CONTROLLER_CONTROL_1	0x40
    +
     #ifdef __cplusplus
     
     template 
    
    
    
    From axeld at mail.berlios.de  Wed Sep 26 22:19:52 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Wed, 26 Sep 2007 22:19:52 +0200
    Subject: [Haiku-commits] r22323 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/vm
    Message-ID: <200709262019.l8QKJq1d015762@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-26 22:19:51 +0200 (Wed, 26 Sep 2007)
    New Revision: 22323
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22323&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/vm_page.h
       haiku/trunk/headers/private/kernel/vm_priv.h
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * Renamed vm_page_write_modified() to vm_page_write_modifed_pages() and
      introduced a new vm_page_write_modified_page().
    * Resolved a TODO: vm_page_write_modified_pages() did not mark a to be
      written page busy but unlocked its cache which could let someone else
      steal that page in the mean time.
    * Moved the logic when to move a page to the active or inactive queue to
      a new function move_page_to_active_or_inactive_queue().
    * Moved page_state_to_string() to vm_page(); it's now also used by the
      "page" and "page_queue" KDL commands.
    * Made the output of the "page_queue list" command more useful.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm_page.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_page.h	2007-09-26 18:55:29 UTC (rev 22322)
    +++ haiku/trunk/headers/private/kernel/vm_page.h	2007-09-26 20:19:51 UTC (rev 22323)
    @@ -32,7 +32,9 @@
     size_t vm_page_num_pages(void);
     size_t vm_page_num_free_pages(void);
     
    -status_t vm_page_write_modified(vm_cache *cache, bool fsReenter);
    +status_t vm_page_write_modified_page(vm_cache *cache, struct vm_page *page,
    +	bool fsReenter);
    +status_t vm_page_write_modified_pages(vm_cache *cache, bool fsReenter);
     
     void vm_page_unreserve_pages(uint32 count);
     void vm_page_reserve_pages(uint32 count);
    
    Modified: haiku/trunk/headers/private/kernel/vm_priv.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_priv.h	2007-09-26 18:55:29 UTC (rev 22322)
    +++ haiku/trunk/headers/private/kernel/vm_priv.h	2007-09-26 20:19:51 UTC (rev 22323)
    @@ -50,6 +50,9 @@
     status_t vm_try_reserve_memory(size_t bytes);
     status_t vm_daemon_init(void);
     
    +const char *page_state_to_string(int state);
    +	// for debugging purposes only
    +
     #ifdef __cplusplus
     }
     #endif
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 18:55:29 UTC (rev 22322)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-26 20:19:51 UTC (rev 22323)
    @@ -2690,32 +2690,6 @@
     }
     
     
    -static const char *
    -page_state_to_string(int state)
    -{
    -	switch(state) {
    -		case PAGE_STATE_ACTIVE:
    -			return "active";
    -		case PAGE_STATE_INACTIVE:
    -			return "inactive";
    -		case PAGE_STATE_BUSY:
    -			return "busy";
    -		case PAGE_STATE_MODIFIED:
    -			return "modified";
    -		case PAGE_STATE_FREE:
    -			return "free";
    -		case PAGE_STATE_CLEAR:
    -			return "clear";
    -		case PAGE_STATE_WIRED:
    -			return "wired";
    -		case PAGE_STATE_UNUSED:
    -			return "unused";
    -		default:
    -			return "unknown";
    -	}
    -}
    -
    -
     static void
     dump_cache_tree_recursively(vm_cache* cache, int level,
     	vm_cache* highlightCache)
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-26 18:55:29 UTC (rev 22322)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-26 20:19:51 UTC (rev 22323)
    @@ -443,7 +443,7 @@
     		return B_OK;
     
     	mutex_lock(&cache->lock);
    -	status = vm_page_write_modified(cache, fsReenter);
    +	status = vm_page_write_modified_pages(cache, fsReenter);
     	mutex_unlock(&cache->lock);
     
     	return status;
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 18:55:29 UTC (rev 22322)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-26 20:19:51 UTC (rev 22323)
    @@ -217,6 +217,32 @@
     }
     
     
    +const char *
    +page_state_to_string(int state)
    +{
    +	switch(state) {
    +		case PAGE_STATE_ACTIVE:
    +			return "active";
    +		case PAGE_STATE_INACTIVE:
    +			return "inactive";
    +		case PAGE_STATE_BUSY:
    +			return "busy";
    +		case PAGE_STATE_MODIFIED:
    +			return "modified";
    +		case PAGE_STATE_FREE:
    +			return "free";
    +		case PAGE_STATE_CLEAR:
    +			return "clear";
    +		case PAGE_STATE_WIRED:
    +			return "wired";
    +		case PAGE_STATE_UNUSED:
    +			return "unused";
    +		default:
    +			return "unknown";
    +	}
    +}
    +
    +
     static int
     dump_page(int argc, char **argv)
     {
    @@ -269,9 +295,9 @@
     	kprintf("cache_offset:    %ld\n", page->cache_offset);
     	kprintf("cache_next,prev: %p, %p\n", page->cache_next, page->cache_prev);
     	kprintf("type:            %d\n", page->type);
    -	kprintf("state:           %d\n", page->state);
    -	kprintf("wired_count:     %u\n", page->wired_count);
    -	kprintf("usage_count:     %u\n", page->usage_count);
    +	kprintf("state:           %s\n", page_state_to_string(page->state));
    +	kprintf("wired_count:     %d\n", page->wired_count);
    +	kprintf("usage_count:     %d\n", page->usage_count);
     	#ifdef DEBUG_PAGE_QUEUE
     		kprintf("queue:           %p\n", page->queue);
     	#endif
    @@ -323,11 +349,12 @@
     	if (argc == 3) {
     		struct vm_page *page = queue->head;
     		int i;
    -		
    +
    +		kprintf("page        cache          state  wired  usage\n");
     		for (i = 0; page; i++, page = page->queue_next) {
    -			kprintf("%5d. queue_next = %p, queue_prev = %p, type = %d, "
    -				"state = %d\n", i, page->queue_next, page->queue_prev,
    -				page->type, page->state);
    +			kprintf("%p  %p  %8s  %5d  %5d\n", page, page->cache,
    +				page_state_to_string(page->state),
    +				page->wired_count, page->usage_count);
     		}
     	}
     	return 0;
    @@ -352,14 +379,20 @@
     
     	kprintf("page stats:\n");
     	kprintf("active: %lu\ninactive: %lu\nbusy: %lu\nunused: %lu\n",
    -		counter[PAGE_STATE_ACTIVE], counter[PAGE_STATE_INACTIVE], counter[PAGE_STATE_BUSY], counter[PAGE_STATE_UNUSED]);
    +		counter[PAGE_STATE_ACTIVE], counter[PAGE_STATE_INACTIVE],
    +		counter[PAGE_STATE_BUSY], counter[PAGE_STATE_UNUSED]);
     	kprintf("wired: %lu\nmodified: %lu\nfree: %lu\nclear: %lu\n",
    -		counter[PAGE_STATE_WIRED], counter[PAGE_STATE_MODIFIED], counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]);
    +		counter[PAGE_STATE_WIRED], counter[PAGE_STATE_MODIFIED],
    +		counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]);
     
    -	kprintf("\nfree_queue: %p, count = %ld\n", &sFreePageQueue, sFreePageQueue.count);
    -	kprintf("clear_queue: %p, count = %ld\n", &sClearPageQueue, sClearPageQueue.count);
    -	kprintf("modified_queue: %p, count = %ld\n", &sModifiedPageQueue, sModifiedPageQueue.count);
    -	kprintf("active_queue: %p, count = %ld\n", &sActivePageQueue, sActivePageQueue.count);
    +	kprintf("\nfree_queue: %p, count = %ld\n", &sFreePageQueue,
    +		sFreePageQueue.count);
    +	kprintf("clear_queue: %p, count = %ld\n", &sClearPageQueue,
    +		sClearPageQueue.count);
    +	kprintf("modified_queue: %p, count = %ld\n", &sModifiedPageQueue,
    +		sModifiedPageQueue.count);
    +	kprintf("active_queue: %p, count = %ld\n", &sActivePageQueue,
    +		sActivePageQueue.count);
     
     	return 0;
     }
    @@ -439,7 +472,9 @@
     			fromQueue = &sClearPageQueue;
     			break;
     		default:
    -			panic("vm_page_set_state: vm_page %p in invalid state %d\n", page, page->state);
    +			panic("vm_page_set_state: vm_page %p in invalid state %d\n",
    +				page, page->state);
    +			break;
     	}
     
     	if (page->state == PAGE_STATE_CLEAR || page->state == PAGE_STATE_FREE) {
    @@ -484,6 +519,25 @@
     
     
     static void
    +move_page_to_active_or_inactive_queue(vm_page *page, bool dequeued)
    +{
    +	// Note, this logic must be in sync with what the page daemon does
    +	int32 state;
    +	if (!page->mappings.IsEmpty() || page->usage_count >= 0
    +		|| page->wired_count)
    +		state = PAGE_STATE_ACTIVE;
    +	else
    +		state = PAGE_STATE_INACTIVE;
    +
    +	if (dequeued) {
    +		page->state = state;
    +		enqueue_page(&sActivePageQueue, page);
    +	} else
    +		set_page_state_nolock(page, state);
    +}
    +
    +
    +static void
     clear_page(addr_t pa)
     {
     	addr_t va;
    @@ -751,10 +805,70 @@
     
     /*!
     	You need to hold the vm_cache lock when calling this function.
    +	And \a page must obviously be in that cache.
    +	Note that the cache lock is released in this function.
     */
     status_t
    -vm_page_write_modified(vm_cache *cache, bool fsReenter)
    +vm_page_write_modified_page(vm_cache *cache, vm_page *page, bool fsReenter)
     {
    +	ASSERT(page->state == PAGE_STATE_MODIFIED);
    +	ASSERT(page->cache == cache);
    +
    +	ConditionVariable busyCondition;
    +	InterruptsSpinLocker locker(&sPageLock);
    +
    +	remove_page_from_queue(&sModifiedPageQueue, page);
    +	page->state = PAGE_STATE_BUSY;
    +
    +	busyCondition.Publish(page, "page");
    +
    +	locker.Unlock();
    +
    +	off_t pageOffset = (off_t)page->cache_offset << PAGE_SHIFT;
    +
    +	for (vm_area *area = cache->areas; area; area = area->cache_next) {
    +		if (pageOffset >= area->cache_offset
    +			&& pageOffset < area->cache_offset + area->size) {
    +			vm_translation_map *map = &area->address_space->translation_map;
    +			// clear the modified flag
    +			map->ops->lock(map);
    +			map->ops->clear_flags(map, pageOffset - area->cache_offset
    +				+ area->base, PAGE_MODIFIED);
    +			map->ops->unlock(map);
    +		}
    +	}
    +
    +	mutex_unlock(&cache->lock);
    +
    +	status_t status = write_page(page, fsReenter);
    +
    +	mutex_lock(&cache->lock);
    +
    +	locker.Lock();
    +
    +	if (status == B_OK) {
    +		// put it into the active queue
    +		move_page_to_active_or_inactive_queue(page, true);
    +	} else {
    +		// We don't have to put the PAGE_MODIFIED bit back, as it's still
    +		// in the modified pages list.
    +		page->state = PAGE_STATE_MODIFIED;
    +		enqueue_page(&sModifiedPageQueue, page);
    +	}
    +
    +	busyCondition.Unpublish();
    +
    +	return status;
    +}
    +
    +
    +/*!
    +	You need to hold the vm_cache lock when calling this function.
    +	Note that the cache lock is released in this function.
    +*/
    +status_t
    +vm_page_write_modified_pages(vm_cache *cache, bool fsReenter)
    +{
     	vm_page *page = cache->page_list;
     
     	// ToDo: join adjacent pages into one vec list
    @@ -805,7 +919,8 @@
     					map->ops->query(map, pageOffset - area->cache_offset + area->base,
     						&physicalAddress, &flags);
     					if (flags & PAGE_MODIFIED) {
    -// TODO: Mark busy?
    +						page->state = PAGE_STATE_BUSY;
    +						busyCondition.Publish(page, "page");
     						gotPage = true;
     						dequeuedPage = false;
     					}
    @@ -829,39 +944,32 @@
     		mutex_lock(&cache->lock);
     
     		if (status == B_OK) {
    -			if (dequeuedPage) {
    -				// put it into the active queue
    +			// put it into the active/inactive queue
     
    -				state = disable_interrupts();
    -				acquire_spinlock(&sPageLock);
    +			state = disable_interrupts();
    +			acquire_spinlock(&sPageLock);
     
    -				if (!page->mappings.IsEmpty() || page->wired_count)
    -					page->state = PAGE_STATE_ACTIVE;
    -				else
    -					page->state = PAGE_STATE_INACTIVE;
    +			move_page_to_active_or_inactive_queue(page, dequeuedPage);
    +			busyCondition.Unpublish();
     
    -				busyCondition.Unpublish();
    -
    -				enqueue_page(&sActivePageQueue, page);
    -
    -				release_spinlock(&sPageLock);
    -				restore_interrupts(state);
    -			}
    +			release_spinlock(&sPageLock);
    +			restore_interrupts(state);
     		} else {
     			// We don't have to put the PAGE_MODIFIED bit back, as it's still
     			// in the modified pages list.
    +			state = disable_interrupts();
    +			acquire_spinlock(&sPageLock);
    +
     			if (dequeuedPage) {
    -				state = disable_interrupts();
    -				acquire_spinlock(&sPageLock);
    -
     				page->state = PAGE_STATE_MODIFIED;
     				enqueue_page(&sModifiedPageQueue, page);
    +			} else
    +				set_page_state_nolock(page, PAGE_STATE_MODIFIED);
     
    -				busyCondition.Unpublish();
    +			busyCondition.Unpublish();
     
    -				release_spinlock(&sPageLock);
    -				restore_interrupts(state);
    -			}
    +			release_spinlock(&sPageLock);
    +			restore_interrupts(state);
     		}
     	}
     
    
    
    
    From jackburton at mail.berlios.de  Thu Sep 27 09:55:17 2007
    From: jackburton at mail.berlios.de (jackburton at BerliOS)
    Date: Thu, 27 Sep 2007 09:55:17 +0200
    Subject: [Haiku-commits] r22324 - haiku/trunk/headers/os/interface
    Message-ID: <200709270755.l8R7tHSJ013672@sheep.berlios.de>
    
    Author: jackburton
    Date: 2007-09-27 09:55:16 +0200 (Thu, 27 Sep 2007)
    New Revision: 22324
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22324&view=rev
    
    Modified:
       haiku/trunk/headers/os/interface/TabView.h
    Log:
    Fixed endlines
    
    
    Modified: haiku/trunk/headers/os/interface/TabView.h
    ===================================================================
    --- haiku/trunk/headers/os/interface/TabView.h	2007-09-26 20:19:51 UTC (rev 22323)
    +++ haiku/trunk/headers/os/interface/TabView.h	2007-09-27 07:55:16 UTC (rev 22324)
    @@ -1,226 +1,212 @@
    -//------------------------------------------------------------------------------
    -//	Copyright (c) 2001-2002, OpenBeOS
    -//
    -//	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.
    -//
    -//	File Name:		TabView.h
    -//	Author:			Marc Flerackers (mflerackers at androme.be)
    -//	Description:	BTab creates individual "tabs" that can be assigned
    -//                  to specific views.
    -//                  BTabView provides the framework for containing and
    -//                  managing groups of BTab objects.
    -//------------------------------------------------------------------------------
    -
    +//------------------------------------------------------------------------------
    +//	Copyright (c) 2001-2002, OpenBeOS
    +//
    +//	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.
    +//
    +//	File Name:		TabView.h
    +//	Author:			Marc Flerackers (mflerackers at androme.be)
    +//	Description:	BTab creates individual "tabs" that can be assigned
    +//                  to specific views.
    +//                  BTabView provides the framework for containing and
    +//                  managing groups of BTab objects.
    +//------------------------------------------------------------------------------
    +
     #ifndef _TAB_VIEW_H
     #define _TAB_VIEW_H
    -
    -// Standard Includes -----------------------------------------------------------
    -
    -// System Includes -------------------------------------------------------------
    -#include 
    -#include 
    -
    -// Project Includes ------------------------------------------------------------
    -
    -// Local Includes --------------------------------------------------------------
    -
    -// Local Defines ---------------------------------------------------------------
    -enum tab_position {
    -	B_TAB_FIRST = 999,
    -	B_TAB_FRONT,
    -	B_TAB_ANY
    -};
    -
    -// Globals ---------------------------------------------------------------------
    -
    -
    -// BTab class ------------------------------------------------------------------
    -class BTab : public BArchivable {
    -
    -public:
    -						BTab(BView * tabView = NULL);
    -						virtual ~BTab();
    -
    -						BTab(BMessage *archive);
    -static BArchivable		*Instantiate(BMessage *archive);
    -
    -virtual	status_t		Archive(BMessage *archive, bool deep = true) const;
    -virtual status_t		Perform(uint32 d, void *arg);
    -
    -		const char		*Label() const;
    -virtual	void			SetLabel(const char *label);
    -
    -		bool			IsSelected() const;
    -virtual	void			Select(BView *owner);
    -virtual	void			Deselect();
    -
    -virtual	void			SetEnabled(bool enabled);
    -		bool			IsEnabled() const;
    -
    -		void			MakeFocus(bool inFocus = true);
    -		bool			IsFocus() const;
    -
    -		//	sets/gets the view to be displayed for this tab
    -virtual	void			SetView(BView *view);
    -		BView			*View() const;
    -
    -virtual void			DrawFocusMark(BView *owner, BRect frame);
    -virtual void			DrawLabel(BView *owner, BRect frame);
    -virtual void			DrawTab(BView *owner, BRect frame, tab_position position,
    -							bool full = true);
    -
    -private:
    -virtual	void			_ReservedTab1();
    -virtual	void			_ReservedTab2();
    -virtual	void			_ReservedTab3();
    -virtual	void			_ReservedTab4();
    -virtual	void			_ReservedTab5();
    -virtual	void			_ReservedTab6();
    -virtual	void			_ReservedTab7();
    -virtual	void			_ReservedTab8();
    -virtual	void			_ReservedTab9();
    -virtual	void			_ReservedTab10();
    -virtual	void			_ReservedTab11();
    -virtual	void			_ReservedTab12();
    -
    -	BTab				&operator=(const BTab &);
    -		
    -	bool 				fEnabled;
    -	bool				fSelected;
    -	bool				fFocus;
    -	BView				*fView;
    -	uint32				_reserved[12];
    +
    +
    +#include 
    +#include 
    +
    +
    +enum tab_position {
    +	B_TAB_FIRST = 999,
    +	B_TAB_FRONT,
    +	B_TAB_ANY
     };
    -//------------------------------------------------------------------------------
    -
    -
    +
    +
    +// BTab class ------------------------------------------------------------------
    +class BTab : public BArchivable {
    +
    +public:
    +						BTab(BView * tabView = NULL);
    +						virtual ~BTab();
    +
    +						BTab(BMessage *archive);
    +static BArchivable		*Instantiate(BMessage *archive);
    +
    +virtual	status_t		Archive(BMessage *archive, bool deep = true) const;
    +virtual status_t		Perform(uint32 d, void *arg);
    +
    +		const char		*Label() const;
    +virtual	void			SetLabel(const char *label);
    +
    +		bool			IsSelected() const;
    +virtual	void			Select(BView *owner);
    +virtual	void			Deselect();
    +
    +virtual	void			SetEnabled(bool enabled);
    +		bool			IsEnabled() const;
    +
    +		void			MakeFocus(bool inFocus = true);
    +		bool			IsFocus() const;
    +
    +		//	sets/gets the view to be displayed for this tab
    +virtual	void			SetView(BView *view);
    +		BView			*View() const;
    +
    +virtual void			DrawFocusMark(BView *owner, BRect frame);
    +virtual void			DrawLabel(BView *owner, BRect frame);
    +virtual void			DrawTab(BView *owner, BRect frame, tab_position position,
    +							bool full = true);
    +
    +private:
    +virtual	void			_ReservedTab1();
    +virtual	void			_ReservedTab2();
    +virtual	void			_ReservedTab3();
    +virtual	void			_ReservedTab4();
    +virtual	void			_ReservedTab5();
    +virtual	void			_ReservedTab6();
    +virtual	void			_ReservedTab7();
    +virtual	void			_ReservedTab8();
    +virtual	void			_ReservedTab9();
    +virtual	void			_ReservedTab10();
    +virtual	void			_ReservedTab11();
    +virtual	void			_ReservedTab12();
    +
    +	BTab				&operator=(const BTab &);
    +		
    +	bool 				fEnabled;
    +	bool				fSelected;
    +	bool				fFocus;
    +	BView				*fView;
    +	uint32				_reserved[12];
    +};
    +//------------------------------------------------------------------------------
    +
    +
     // BTabView class --------------------------------------------------------------
     class BTabView : public BView
     {
     public:
    -						BTabView(BRect frame, const char *name,
    -							button_width width = B_WIDTH_AS_USUAL, 
    -							uint32 resizingMode = B_FOLLOW_ALL,
    -							uint32 flags = B_FULL_UPDATE_ON_RESIZE |
    -								B_WILL_DRAW | B_NAVIGABLE_JUMP |
    -								B_FRAME_EVENTS | B_NAVIGABLE);
    -						~BTabView();
    -
    -						BTabView(BMessage *archive);
    -static BArchivable		*Instantiate(BMessage *archive);
    -virtual	status_t		Archive(BMessage*, bool deep=true) const;
    -virtual status_t		Perform(perform_code d, void *arg);
    -
    -virtual	void			WindowActivated(bool active);
    -virtual void 			AttachedToWindow();		
    -virtual	void			AllAttached();
    -virtual	void			AllDetached();
    -virtual	void			DetachedFromWindow();
    -
    -virtual void 			MessageReceived(BMessage *message);
    -virtual void 			FrameMoved(BPoint newLocation);
    -virtual void			FrameResized(float width,float height);
    -virtual void			KeyDown(const char *bytes, int32 numBytes);
    -virtual void			MouseDown(BPoint point);
    -virtual void			MouseUp(BPoint point);
    -virtual void 			MouseMoved(BPoint point, uint32 transit,
    -								   const BMessage *message);
    -virtual	void			Pulse();
    -
    -virtual	void			Select(int32 tab);
    -		int32			Selection() const;
    -
    -virtual	void			MakeFocus(bool focused = true);
    -virtual	void			SetFocusTab(int32 tab, bool focused);
    -		int32			FocusTab() const;
    -
    -virtual	void			Draw(BRect updateRect);
    -virtual	BRect			DrawTabs();
    -virtual	void			DrawBox(BRect selTabRect);
    -virtual	BRect			TabFrame(int32 tab_index) const;
    -
    -virtual	void			SetFlags(uint32 flags);
    -virtual	void			SetResizingMode(uint32 mode);
    -
    -virtual void 			GetPreferredSize(float *width, float *height);
    -virtual void 			ResizeToPreferred();
    -
    -virtual BHandler		*ResolveSpecifier(BMessage *message, int32 index,
    -							BMessage *specifier, int32 what, const char *property);
    -virtual	status_t		GetSupportedSuites(BMessage *message);
    -
    -virtual	void			AddTab(BView *target, BTab *tab = NULL);
    -#if !_PR3_COMPATIBLE_
    -virtual	BTab			*RemoveTab(int32 tabIndex);
    -#else
    -virtual	BTab			*RemoveTab(int32 tabIndex) const;
    -#endif
    -
    -virtual	BTab			*TabAt ( int32 tab_index ) const;
    -
    -virtual	void			SetTabWidth(button_width width);
    -		button_width	TabWidth() const;
    -		
    -virtual	void			SetTabHeight(float height);
    -		float			TabHeight() const;
    -
    -		BView			*ContainerView() const;
    -
    -		int32			CountTabs() const;
    -		BView			*ViewForTab(int32 tabIndex) const;
    -
    -private:
    -		void			_InitObject();
    -
    -virtual	void			_ReservedTabView1();
    -virtual	void			_ReservedTabView2();
    -virtual	void			_ReservedTabView3();
    -virtual	void			_ReservedTabView4();
    -virtual	void			_ReservedTabView5();
    -virtual	void			_ReservedTabView6();
    -virtual	void			_ReservedTabView7();
    -virtual	void			_ReservedTabView8();
    -virtual	void			_ReservedTabView9();
    -virtual	void			_ReservedTabView10();
    -virtual	void			_ReservedTabView11();
    -virtual	void			_ReservedTabView12();
    -
    -						BTabView(const BTabView &);
    -		BTabView		&operator=(const BTabView &);
    -	
    -		BList			*fTabList;
    -		BView			*fContainerView;
    -		button_width	fTabWidthSetting;
    -		float 			fTabWidth;
    -		float			fTabHeight;
    -		int32			fSelection;
    -		int32			fInitialSelection;
    -		int32			fFocus;	
    +						BTabView(BRect frame, const char *name,
    +							button_width width = B_WIDTH_AS_USUAL, 
    +							uint32 resizingMode = B_FOLLOW_ALL,
    +							uint32 flags = B_FULL_UPDATE_ON_RESIZE |
    +								B_WILL_DRAW | B_NAVIGABLE_JUMP |
    +								B_FRAME_EVENTS | B_NAVIGABLE);
    +						~BTabView();
    +
    +						BTabView(BMessage *archive);
    +static BArchivable		*Instantiate(BMessage *archive);
    +virtual	status_t		Archive(BMessage*, bool deep=true) const;
    +virtual status_t		Perform(perform_code d, void *arg);
    +
    +virtual	void			WindowActivated(bool active);
    +virtual void 			AttachedToWindow();		
    +virtual	void			AllAttached();
    +virtual	void			AllDetached();
    +virtual	void			DetachedFromWindow();
    +
    +virtual void 			MessageReceived(BMessage *message);
    +virtual void 			FrameMoved(BPoint newLocation);
    +virtual void			FrameResized(float width,float height);
    +virtual void			KeyDown(const char *bytes, int32 numBytes);
    +virtual void			MouseDown(BPoint point);
    +virtual void			MouseUp(BPoint point);
    +virtual void 			MouseMoved(BPoint point, uint32 transit,
    +								   const BMessage *message);
    +virtual	void			Pulse();
    +
    +virtual	void			Select(int32 tab);
    +		int32			Selection() const;
    +
    +virtual	void			MakeFocus(bool focused = true);
    +virtual	void			SetFocusTab(int32 tab, bool focused);
    +		int32			FocusTab() const;
    +
    +virtual	void			Draw(BRect updateRect);
    +virtual	BRect			DrawTabs();
    +virtual	void			DrawBox(BRect selTabRect);
    +virtual	BRect			TabFrame(int32 tab_index) const;
    +
    +virtual	void			SetFlags(uint32 flags);
    +virtual	void			SetResizingMode(uint32 mode);
    +
    +virtual void 			GetPreferredSize(float *width, float *height);
    +virtual void 			ResizeToPreferred();
    +
    +virtual BHandler		*ResolveSpecifier(BMessage *message, int32 index,
    +							BMessage *specifier, int32 what, const char *property);
    +virtual	status_t		GetSupportedSuites(BMessage *message);
    +
    +virtual	void			AddTab(BView *target, BTab *tab = NULL);
    +#if !_PR3_COMPATIBLE_
    +virtual	BTab			*RemoveTab(int32 tabIndex);
    +#else
    +virtual	BTab			*RemoveTab(int32 tabIndex) const;
    +#endif
    +
    +virtual	BTab			*TabAt ( int32 tab_index ) const;
    +
    +virtual	void			SetTabWidth(button_width width);
    +		button_width	TabWidth() const;
    +		
    +virtual	void			SetTabHeight(float height);
    +		float			TabHeight() const;
    +
    +		BView			*ContainerView() const;
    +
    +		int32			CountTabs() const;
    +		BView			*ViewForTab(int32 tabIndex) const;
    +
    +private:
    +		void			_InitObject();
    +
    +virtual	void			_ReservedTabView1();
    +virtual	void			_ReservedTabView2();
    +virtual	void			_ReservedTabView3();
    +virtual	void			_ReservedTabView4();
    +virtual	void			_ReservedTabView5();
    +virtual	void			_ReservedTabView6();
    +virtual	void			_ReservedTabView7();
    +virtual	void			_ReservedTabView8();
    +virtual	void			_ReservedTabView9();
    +virtual	void			_ReservedTabView10();
    +virtual	void			_ReservedTabView11();
    +virtual	void			_ReservedTabView12();
    +
    +						BTabView(const BTabView &);
    +		BTabView		&operator=(const BTabView &);
    +	
    +		BList			*fTabList;
    +		BView			*fContainerView;
    +		button_width	fTabWidthSetting;
    +		float 			fTabWidth;
    +		float			fTabHeight;
    +		int32			fSelection;
    +		int32			fInitialSelection;
    +		int32			fFocus;	
     		uint32			_reserved[12];
    -};
    -//------------------------------------------------------------------------------
    +};
     
    -#endif // _TAB_VIEW_H
    -
    -/*
    - * $Log $
    - *
    - * $Id  $
    - *
    - */
    +
    +#endif // _TAB_VIEW_H
    +
    
    
    
    From jackburton at mail.berlios.de  Thu Sep 27 10:26:16 2007
    From: jackburton at mail.berlios.de (jackburton at BerliOS)
    Date: Thu, 27 Sep 2007 10:26:16 +0200
    Subject: [Haiku-commits] r22325 - in haiku/trunk: headers/os/interface
    	src/kits/interface
    Message-ID: <200709270826.l8R8QGQN015278@sheep.berlios.de>
    
    Author: jackburton
    Date: 2007-09-27 10:26:15 +0200 (Thu, 27 Sep 2007)
    New Revision: 22325
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22325&view=rev
    
    Modified:
       haiku/trunk/headers/os/interface/TabView.h
       haiku/trunk/src/kits/interface/TabView.cpp
    Log:
    Patch from Ioan Molnar:
    If a Tab is partially out of the window, clicking on it to make it the 
    active tab will scroll it to be completely visible.
    The best solution would probably be having a way to scroll through the 
    whole list of tabs, or something like this. But for now, at least, makes 
    the tabbed terminal a bit more useful.
    Thanks!
    
    
    
    Modified: haiku/trunk/headers/os/interface/TabView.h
    ===================================================================
    --- haiku/trunk/headers/os/interface/TabView.h	2007-09-27 07:55:16 UTC (rev 22324)
    +++ haiku/trunk/headers/os/interface/TabView.h	2007-09-27 08:26:15 UTC (rev 22325)
    @@ -203,8 +203,9 @@
     		float			fTabHeight;
     		int32			fSelection;
     		int32			fInitialSelection;
    -		int32			fFocus;	
    -		uint32			_reserved[12];
    +		int32			fFocus;
    +		float			fTabOffset;	
    +		uint32			_reserved[11];
     };
     
     
    
    Modified: haiku/trunk/src/kits/interface/TabView.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/TabView.cpp	2007-09-27 07:55:16 UTC (rev 22324)
    +++ haiku/trunk/src/kits/interface/TabView.cpp	2007-09-27 08:26:15 UTC (rev 22325)
    @@ -596,11 +596,26 @@
     
     	tab = TabAt(index);
     	if (tab && ContainerView()) {
    +		if(index == 0)
    +			fTabOffset = 0.0f;
     		tab->Select(ContainerView());
     		fSelection = index;
     	}
     
     	Invalidate();
    +	
    +	if(index != 0 && !Bounds().Contains(TabFrame(index))){
    +		if(!Bounds().Contains(TabFrame(index).LeftTop()))
    +			fTabOffset += TabFrame(index).left - Bounds().left - 20.0f;
    +		else
    +			fTabOffset += TabFrame(index).right - Bounds().right + 20.0f;
    +
    +		Invalidate();
    +	}
    +
    +	/*MakeFocus();
    +	SetFocusTab(index, true);
    +	FocusTab();*/
     }
     
     
    @@ -624,26 +639,29 @@
     BTabView::SetFocusTab(int32 tab, bool focused)
     {
     	if (tab >= CountTabs())
    -		return;
    +		tab = 0;
     
    +	if(tab < 0)
    +		tab = CountTabs() -1;
    +
     	if (focused) {
     		if (tab == fFocus)
     			return;
     
     		if (fFocus != -1){
    -			TabAt(fFocus)->MakeFocus(false);
    +			if(TabAt (fFocus) != NULL)
    +				TabAt(fFocus)->MakeFocus(false);
     			Invalidate(TabFrame(fFocus));
     		}
    -		if (tab != -1) {
    +		if(TabAt(tab) != NULL){
     			TabAt(tab)->MakeFocus(true);
     			Invalidate(TabFrame(tab));
    +			fFocus = tab;
     		}
    -
    -		fFocus = tab;
     	} else if (fFocus != -1) {
     		TabAt(fFocus)->MakeFocus(false);
     		Invalidate(TabFrame(fFocus));
    -//		fFocus = -1;
    +		fFocus = -1;
     	}
     }
     
    @@ -749,12 +767,21 @@
     	switch (fTabWidthSetting) {
     		case B_WIDTH_FROM_LABEL:
     		{
    -			float x = X_OFFSET;
    +			float x = 6.0f;
    +			for (int32 i = 0; i < tab_index; i++){
    +				x += StringWidth(TabAt(i)->Label()) + 20.0f;
    +			}
    +
    +			return BRect(x - fTabOffset, 0.0f,
    +				x - fTabOffset + StringWidth(TabAt(tab_index)->Label()) + 20.0f , fTabHeight);
    +
    +			
    +			/*float x = X_OFFSET;
     			for (int32 i = 0; i < tab_index; i++)
     				x += StringWidth(TabAt(i)->Label()) + 20.0f;
     
     			return BRect(x, 0.0f,
    -				x + StringWidth(TabAt(tab_index)->Label()) + 20.0f, fTabHeight);
    +				x + StringWidth(TabAt(tab_index)->Label()) + 20.0f, fTabHeight);*/
     		}
     
     		case B_WIDTH_FROM_WIDEST:
    @@ -763,19 +790,30 @@
     
     			for (int32 i = 0; i < CountTabs(); i++) {
     				float tabWidth = StringWidth(TabAt(i)->Label()) + 20.0f;
    +				if (tabWidth > width)
    +					width = tabWidth;
    +			}
    +			return BRect((6.0f + tab_index * width) - fTabOffset, 0.0f,
    +				(6.0f + tab_index * width + width) - fTabOffset, fTabHeight);
    +			/*float width = 0.0f;
     
    +			for (int32 i = 0; i < CountTabs(); i++) {
    +				float tabWidth = StringWidth(TabAt(i)->Label()) + 20.0f;
    +
     				if (tabWidth > width)
     					width = tabWidth;
     			}
     
     			return BRect(X_OFFSET + tab_index * width, 0.0f,
    -				X_OFFSET + tab_index * width + width, fTabHeight);
    +				X_OFFSET + tab_index * width + width, fTabHeight);*/
     		}
     
     		case B_WIDTH_AS_USUAL:
     		default:
    -			return BRect(X_OFFSET + tab_index * 100.0f, 0.0f,
    -				X_OFFSET + tab_index * 100.0f + 100.0f, fTabHeight);
    +			return BRect((6.0f + tab_index * 100.0f) - fTabOffset, 0.0f,
    +						(6.0f + tab_index * 100.0f + 100.0f) - fTabOffset, fTabHeight);
    +			/*return BRect(X_OFFSET + tab_index * 100.0f, 0.0f,
    +				X_OFFSET + tab_index * 100.0f + 100.0f, fTabHeight);*/
     	}
     }
     
    @@ -850,9 +888,12 @@
     	if (index <= fSelection && fSelection != 0)
     		fSelection--;
     
    -	Select(fSelection);
    +	if(CountTabs() == 0)
    +		fFocus = -1;
    +	else
    +		Select(fSelection);
     
    -	if (fFocus == CountTabs() - 1)
    +	if (fFocus == CountTabs() - 1 || CountTabs() == 0)
     		SetFocusTab(fFocus, false);
     	else
     		SetFocusTab(fFocus, true);
    @@ -939,6 +980,7 @@
     	fTabWidthSetting = B_WIDTH_AS_USUAL;
     	fSelection = 0;
     	fFocus = -1;
    +	fTabOffset = 0.0f;
     
     	rgb_color color = ui_color(B_PANEL_BACKGROUND_COLOR);
     
    
    
    
    From axeld at mail.berlios.de  Thu Sep 27 12:29:06 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 12:29:06 +0200
    Subject: [Haiku-commits] r22326 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/arch/x86 src/system/kernel/vm
    Message-ID: <200709271029.l8RAT6cH025863@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 12:29:05 +0200 (Thu, 27 Sep 2007)
    New Revision: 22326
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22326&view=rev
    
    Added:
       haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp
       haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp
       haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp
       haiku/trunk/src/system/kernel/vm/vm_address_space.cpp
       haiku/trunk/src/system/kernel/vm/vm_store_anonymous_noswap.cpp
    Removed:
       haiku/trunk/src/system/kernel/arch/x86/arch_debug.c
       haiku/trunk/src/system/kernel/arch/x86/arch_vm.c
       haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c
    Modified:
       haiku/trunk/headers/private/kernel/vm_types.h
       haiku/trunk/src/system/kernel/arch/x86/Jamfile
       haiku/trunk/src/system/kernel/vm/Jamfile
    Log:
    * Cleaned up vm_types.h a bit, and made vm_page, vm_cache, and vm_area
      opaque types for C.
    * As a result, I've renamed some more source files to .cpp, and fixed
      all warnings caused by that.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm_types.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 08:26:15 UTC (rev 22325)
    +++ haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 10:29:05 UTC (rev 22326)
    @@ -9,9 +9,10 @@
     #define _KERNEL_VM_TYPES_H
     
     
    -#include 
     #include 
     #include 
    +#include 
    +#include 
     #include 
     
     #include 
    @@ -31,9 +32,6 @@
     #ifdef __cplusplus
     struct vm_page_mapping;
     typedef DoublyLinkedListLink vm_page_mapping_link;
    -#else
    -typedef struct { void *previous; void *next; } vm_page_mapping_link;
    -#endif
     
     typedef struct vm_page_mapping {
     	vm_page_mapping_link page_link;
    @@ -42,7 +40,6 @@
     	struct vm_area *area;
     } vm_page_mapping;
     
    -#ifdef __cplusplus
     class DoublyLinkedPageLink {
     	public:
     		inline vm_page_mapping_link *operator()(vm_page_mapping *element) const
    @@ -71,10 +68,6 @@
     
     typedef class DoublyLinkedQueue vm_page_mappings;
     typedef class DoublyLinkedQueue vm_area_mappings;
    -#else	// !__cplusplus
    -typedef struct vm_page_mapping *vm_page_mappings;
    -typedef struct vm_page_mapping *vm_area_mappings;
    -#endif
     
     // vm page
     typedef struct vm_page {
    @@ -137,16 +130,10 @@
     	CACHE_TYPE_NULL
     };
     
    -#ifdef __cplusplus
    -
    -#include 
    -
     struct vm_dummy_page : vm_page {
     	ConditionVariable	busy_condition;
     };
     
    -#endif	// __cplusplus
    -
     // vm_cache
     typedef struct vm_cache {
     	mutex				lock;
    @@ -201,6 +188,13 @@
     	struct vm_area		*hash_next;
     } vm_area;
     
    +#else	// !__cplusplus
    +// these are just opaque types in C
    +typedef struct vm_page vm_page;
    +typedef struct vm_cache vm_cache;
    +typedef struct vm_area vm_area;
    +#endif
    +
     enum {
     	VM_ASPACE_STATE_NORMAL = 0,
     	VM_ASPACE_STATE_DELETION
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/Jamfile
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/Jamfile	2007-09-27 08:26:15 UTC (rev 22325)
    +++ haiku/trunk/src/system/kernel/arch/x86/Jamfile	2007-09-27 10:29:05 UTC (rev 22326)
    @@ -12,7 +12,7 @@
     
     KernelStaticLibrary libx86 :
     	arch_cpu.c
    -	arch_debug.c
    +	arch_debug.cpp
     	arch_debug_console.c
     	arch_elf.c
     	arch_int.c
    @@ -22,8 +22,8 @@
     	arch_smp.c
     	arch_thread.c
     	arch_timer.c
    -	arch_vm.c
    -	arch_vm_translation_map.c
    +	arch_vm.cpp
    +	arch_vm_translation_map.cpp
     	arch_x86.S
     	arch_interrupts.S
     	arch_system_info.c
    
    Deleted: haiku/trunk/src/system/kernel/arch/x86/arch_debug.c
    
    Copied: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp (from rev 22318, haiku/trunk/src/system/kernel/arch/x86/arch_debug.c)
    
    Deleted: haiku/trunk/src/system/kernel/arch/x86/arch_vm.c
    
    Copied: haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp (from rev 22318, haiku/trunk/src/system/kernel/arch/x86/arch_vm.c)
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_vm.c	2007-09-26 14:01:28 UTC (rev 22318)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp	2007-09-27 10:29:05 UTC (rev 22326)
    @@ -0,0 +1,276 @@
    +/*
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de.
    + * Distributed under the terms of the MIT License.
    + *
    + * Copyright 2001, Travis Geiselbrecht. All rights reserved.
    + * Distributed under the terms of the NewOS License.
    + */
    +
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +
    +#include 
    +#include 
    +
    +
    +//#define TRACE_ARCH_VM
    +#ifdef TRACE_ARCH_VM
    +#	define TRACE(x) dprintf x
    +#else
    +#	define TRACE(x) ;
    +#endif
    +
    +
    +#define kMaxMemoryTypeRegisters 32
    +
    +void *gDmaAddress;
    +
    +static uint32 sMemoryTypeBitmap;
    +static int32 sMemoryTypeIDs[kMaxMemoryTypeRegisters];
    +static uint32 sMemoryTypeRegisterCount;
    +static spinlock sMemoryTypeLock;
    +
    +
    +static int32
    +allocate_mtrr(void)
    +{
    +	InterruptsSpinLocker _(&sMemoryTypeLock);
    +
    +	// find free bit
    +
    +	for (uint32 index = 0; index < sMemoryTypeRegisterCount; index++) {
    +		if (sMemoryTypeBitmap & (1UL << index))
    +			continue;
    +
    +		sMemoryTypeBitmap |= 1UL << index;
    +		return index;
    +	}
    +
    +	return -1;
    +}
    +
    +
    +static void
    +free_mtrr(int32 index)
    +{
    +	InterruptsSpinLocker _(&sMemoryTypeLock);
    +
    +	sMemoryTypeBitmap &= ~(1UL << index);
    +}
    +
    +
    +static uint64
    +nearest_power(addr_t value)
    +{
    +	uint64 power = 1UL << 12;
    +		// 12 bits is the smallest supported alignment/length
    +
    +	while (value > power)
    +		power <<= 1;
    +
    +	return power;
    +}
    +
    +
    +static status_t
    +set_memory_type(int32 id, uint64 base, uint64 length, uint32 type)
    +{
    +	int32 index;
    +
    +	if (type == 0)
    +		return B_OK;
    +
    +	switch (type) {
    +		case B_MTR_UC:
    +			type = IA32_MTR_UNCACHED;
    +			break;
    +		case B_MTR_WC:
    +			type = IA32_MTR_WRITE_COMBINING;
    +			break;
    +		case B_MTR_WT:
    +			type = IA32_MTR_WRITE_THROUGH;
    +			break;
    +		case B_MTR_WP:
    +			type = IA32_MTR_WRITE_PROTECTED;
    +			break;
    +		case B_MTR_WB:
    +			type = IA32_MTR_WRITE_BACK;
    +			break;
    +
    +		default:
    +			return B_BAD_VALUE;
    +	}
    +
    +	if (sMemoryTypeRegisterCount == 0)
    +		return B_NOT_SUPPORTED;
    +
    +	// length must be a power of 2; just round it up to the next value
    +	length = nearest_power(length);
    +	if (length + base <= base) {
    +		// 4GB overflow
    +		return B_BAD_VALUE;
    +	}
    +
    +	// base must be aligned to the length
    +	if (base & (length - 1))
    +		return B_BAD_VALUE;
    +
    +	index = allocate_mtrr();
    +	if (index < 0)
    +		return B_ERROR;
    +
    +	TRACE(("allocate MTRR slot %ld, base = %Lx, length = %Lx\n", index,
    +		base, length));
    +
    +	sMemoryTypeIDs[index] = id;
    +	x86_set_mtrr(index, base, length, type);
    +
    +	return B_OK;
    +}
    +
    +
    +//	#pragma mark -
    +
    +
    +status_t
    +arch_vm_init(kernel_args *args)
    +{
    +	TRACE(("arch_vm_init: entry\n"));
    +	return 0;
    +}
    +
    +
    +/*!	Marks DMA region as in-use, and maps it into the kernel space */
    +status_t
    +arch_vm_init_post_area(kernel_args *args)
    +{
    +	area_id id;
    +
    +	TRACE(("arch_vm_init_post_area: entry\n"));
    +
    +	// account for DMA area and mark the pages unusable
    +	vm_mark_page_range_inuse(0x0, 0xa0000 / B_PAGE_SIZE);
    +
    +	// map 0 - 0xa0000 directly
    +	id = map_physical_memory("dma_region", (void *)0x0, 0xa0000,
    +		B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA,
    +		&gDmaAddress);
    +	if (id < 0) {
    +		panic("arch_vm_init_post_area: unable to map dma region\n");
    +		return B_NO_MEMORY;
    +	}
    +
    +	return bios_init();
    +}
    +
    +
    +/*!	Gets rid of all yet unmapped (and therefore now unused) page tables */
    +status_t
    +arch_vm_init_end(kernel_args *args)
    +{
    +	TRACE(("arch_vm_init_endvm: entry\n"));
    +
    +	// throw away anything in the kernel_args.pgtable[] that's not yet mapped
    +	vm_free_unused_boot_loader_range(KERNEL_BASE,
    +		0x400000 * args->arch_args.num_pgtables);
    +
    +	return B_OK;
    +}
    +
    +
    +status_t
    +arch_vm_init_post_modules(kernel_args *args)
    +{
    +//	void *cookie;
    +
    +	// the x86 CPU modules are now accessible
    +
    +	sMemoryTypeRegisterCount = x86_count_mtrrs();
    +	if (sMemoryTypeRegisterCount == 0)
    +		return B_OK;
    +
    +	// not very likely, but play safe here
    +	if (sMemoryTypeRegisterCount > kMaxMemoryTypeRegisters)
    +		sMemoryTypeRegisterCount = kMaxMemoryTypeRegisters;
    +
    +	// init memory type ID table
    +
    +	for (uint32 i = 0; i < sMemoryTypeRegisterCount; i++) {
    +		sMemoryTypeIDs[i] = -1;
    +	}
    +
    +	// set the physical memory ranges to write-back mode
    +
    +	for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) {
    +		set_memory_type(-1, args->physical_memory_range[i].start,
    +			args->physical_memory_range[i].size, B_MTR_WB);
    +	}
    +
    +	return B_OK;
    +}
    +
    +
    +void
    +arch_vm_aspace_swap(vm_address_space *aspace)
    +{
    +	i386_swap_pgdir((addr_t)i386_translation_map_get_pgdir(
    +		&aspace->translation_map));
    +}
    +
    +
    +bool
    +arch_vm_supports_protection(uint32 protection)
    +{
    +	// x86 always has the same read/write properties for userland and the
    +	// kernel.
    +	// That's why we do not support user-read/kernel-write access. While the
    +	// other way around is not supported either, we don't care in this case
    +	// and give the kernel full access.
    +	if ((protection & (B_READ_AREA | B_WRITE_AREA)) == B_READ_AREA
    +		&& protection & B_KERNEL_WRITE_AREA)
    +		return false;
    +
    +	return true;
    +}
    +
    +
    +void
    +arch_vm_unset_memory_type(struct vm_area *area)
    +{
    +	uint32 index;
    +
    +	if (area->memory_type == 0)
    +		return;
    +
    +	// find index for area ID
    +
    +	for (index = 0; index < sMemoryTypeRegisterCount; index++) {
    +		if (sMemoryTypeIDs[index] == area->id) {
    +			x86_set_mtrr(index, 0, 0, 0);
    +
    +			sMemoryTypeIDs[index] = -1;
    +			free_mtrr(index);
    +			break;
    +		}
    +	}
    +}
    +
    +
    +status_t
    +arch_vm_set_memory_type(struct vm_area *area, addr_t physicalBase,
    +	uint32 type)
    +{
    +	area->memory_type = type >> MEMORY_TYPE_SHIFT;
    +	return set_memory_type(area->id, physicalBase, area->size, type);
    +}
    
    Deleted: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c
    
    Copied: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp (from rev 22319, haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c)
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.c	2007-09-26 17:42:25 UTC (rev 22319)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp	2007-09-27 10:29:05 UTC (rev 22326)
    @@ -0,0 +1,1027 @@
    +/*
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + *
    + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    + * Distributed under the terms of the NewOS License.
    + */
    +
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +#include 
    +
    +#include "generic_vm_physical_page_mapper.h"
    +
    +//#define TRACE_VM_TMAP
    +#ifdef TRACE_VM_TMAP
    +#	define TRACE(x) dprintf x
    +#else
    +#	define TRACE(x) ;
    +#endif
    +
    +// 256 MB of iospace
    +#define IOSPACE_SIZE (256*1024*1024)
    +// 4 MB chunks, to optimize for 4 MB pages
    +#define IOSPACE_CHUNK_SIZE (4*1024*1024)
    +
    +typedef struct page_table_entry {
    +	uint32	present:1;
    +	uint32	rw:1;
    +	uint32	user:1;
    +	uint32	write_through:1;
    +	uint32	cache_disabled:1;
    +	uint32	accessed:1;
    +	uint32	dirty:1;
    +	uint32	reserved:1;
    +	uint32	global:1;
    +	uint32	avail:3;
    +	uint32	addr:20;
    +} page_table_entry;
    +
    +typedef struct page_directory_entry {
    +	uint32	present:1;
    +	uint32	rw:1;
    +	uint32	user:1;
    +	uint32	write_through:1;
    +	uint32	cache_disabled:1;
    +	uint32	accessed:1;
    +	uint32	reserved:1;
    +	uint32	page_size:1;
    +	uint32	global:1;
    +	uint32	avail:3;
    +	uint32	addr:20;
    +} page_directory_entry;
    +
    +static page_table_entry *iospace_pgtables = NULL;
    +
    +#define PAGE_INVALIDATE_CACHE_SIZE 64
    +
    +// vm_translation object stuff
    +typedef struct vm_translation_map_arch_info {
    +	page_directory_entry *pgdir_virt;
    +	page_directory_entry *pgdir_phys;
    +	int num_invalidate_pages;
    +	addr_t pages_to_invalidate[PAGE_INVALIDATE_CACHE_SIZE];
    +} vm_translation_map_arch_info;
    +
    +
    +static page_table_entry *page_hole = NULL;
    +static page_directory_entry *page_hole_pgdir = NULL;
    +static page_directory_entry *sKernelPhysicalPageDirectory = NULL;
    +static page_directory_entry *sKernelVirtualPageDirectory = NULL;
    +static addr_t sQueryPages;
    +static page_table_entry *sQueryPageTable;
    +
    +static vm_translation_map *tmap_list;
    +static spinlock tmap_list_lock;
    +
    +static addr_t sIOSpaceBase;
    +
    +#define CHATTY_TMAP 0
    +
    +#define ADDR_SHIFT(x) ((x)>>12)
    +#define ADDR_REVERSE_SHIFT(x) ((x)<<12)
    +
    +#define VADDR_TO_PDENT(va) (((va) / B_PAGE_SIZE) / 1024)
    +#define VADDR_TO_PTENT(va) (((va) / B_PAGE_SIZE) % 1024)
    +
    +#define FIRST_USER_PGDIR_ENT    (VADDR_TO_PDENT(USER_BASE))
    +#define NUM_USER_PGDIR_ENTS     (VADDR_TO_PDENT(ROUNDUP(USER_SIZE, B_PAGE_SIZE * 1024)))
    +#define FIRST_KERNEL_PGDIR_ENT  (VADDR_TO_PDENT(KERNEL_BASE))
    +#define NUM_KERNEL_PGDIR_ENTS   (VADDR_TO_PDENT(KERNEL_SIZE))
    +#define IS_KERNEL_MAP(map)		(map->arch_data->pgdir_phys == sKernelPhysicalPageDirectory)
    +
    +static status_t early_query(addr_t va, addr_t *out_physical);
    +static status_t get_physical_page_tmap(addr_t pa, addr_t *va, uint32 flags);
    +static status_t put_physical_page_tmap(addr_t va);
    +
    +static void flush_tmap(vm_translation_map *map);
    +
    +
    +void *
    +i386_translation_map_get_pgdir(vm_translation_map *map)
    +{
    +	return map->arch_data->pgdir_phys;
    +}
    +
    +
    +static inline void
    +init_page_directory_entry(page_directory_entry *entry)
    +{
    +	*(uint32 *)entry = 0;
    +}
    +
    +
    +static inline void
    +update_page_directory_entry(page_directory_entry *entry, page_directory_entry *with)
    +{
    +	// update page directory entry atomically
    +	*(uint32 *)entry = *(uint32 *)with;
    +}
    +
    +
    +static inline void
    +init_page_table_entry(page_table_entry *entry)
    +{
    +	*(uint32 *)entry = 0;
    +}
    +
    +
    +static inline void
    +update_page_table_entry(page_table_entry *entry, page_table_entry *with)
    +{
    +	// update page table entry atomically
    +	*(uint32 *)entry = *(uint32 *)with;
    +}
    +
    +
    +static void
    +_update_all_pgdirs(int index, page_directory_entry e)
    +{
    +	vm_translation_map *entry;
    +	unsigned int state = disable_interrupts();
    +
    +	acquire_spinlock(&tmap_list_lock);
    +
    +	for(entry = tmap_list; entry != NULL; entry = entry->next)
    +		entry->arch_data->pgdir_virt[index] = e;
    +
    +	release_spinlock(&tmap_list_lock);
    +	restore_interrupts(state);
    +}
    +
    +
    +// XXX currently assumes this translation map is active
    +
    +static status_t
    +early_query(addr_t va, addr_t *_physicalAddress)
    +{
    +	page_table_entry *pentry;
    +
    +	if (page_hole_pgdir[VADDR_TO_PDENT(va)].present == 0) {
    +		// no pagetable here
    +		return B_ERROR;
    +	}
    +
    +	pentry = page_hole + va / B_PAGE_SIZE;
    +	if (pentry->present == 0) {
    +		// page mapping not valid
    +		return B_ERROR;
    +	}
    +
    +	*_physicalAddress = pentry->addr << 12;
    +	return B_OK;
    +}
    +
    +
    +/*!	Acquires the map's recursive lock, and resets the invalidate pages counter
    +	in case it's the first locking recursion.
    +*/
    +static status_t
    +lock_tmap(vm_translation_map *map)
    +{
    +	TRACE(("lock_tmap: map %p\n", map));
    +
    +	recursive_lock_lock(&map->lock);
    +	if (recursive_lock_get_recursion(&map->lock) == 1) {
    +		// we were the first one to grab the lock
    +		TRACE(("clearing invalidated page count\n"));
    +		map->arch_data->num_invalidate_pages = 0;
    +	}
    +
    +	return B_OK;
    +}
    +
    +
    +/*!	Unlocks the map, and, if we'll actually losing the recursive lock,
    +	flush all pending changes of this map (ie. flush TLB caches as
    +	needed).
    +*/
    +static status_t
    +unlock_tmap(vm_translation_map *map)
    +{
    +	TRACE(("unlock_tmap: map %p\n", map));
    +
    +	if (recursive_lock_get_recursion(&map->lock) == 1) {
    +		// we're about to release it for the last time
    +		flush_tmap(map);
    +	}
    +
    +	recursive_lock_unlock(&map->lock);
    +	return B_OK;
    +}
    +
    +
    +static void
    +destroy_tmap(vm_translation_map *map)
    +{
    +	int state;
    +	vm_translation_map *entry;
    +	vm_translation_map *last = NULL;
    +	unsigned int i;
    +
    +	if (map == NULL)
    +		return;
    +
    +	// remove it from the tmap list
    +	state = disable_interrupts();
    +	acquire_spinlock(&tmap_list_lock);
    +
    +	entry = tmap_list;
    +	while (entry != NULL) {
    +		if (entry == map) {
    +			if (last != NULL)
    +				last->next = entry->next;
    +			else
    +				tmap_list = entry->next;
    +
    +			break;
    +		}
    +		last = entry;
    +		entry = entry->next;
    +	}
    +
    +	release_spinlock(&tmap_list_lock);
    +	restore_interrupts(state);
    +
    +	if (map->arch_data->pgdir_virt != NULL) {
    +		// cycle through and free all of the user space pgtables
    +		for (i = VADDR_TO_PDENT(USER_BASE); i <= VADDR_TO_PDENT(USER_BASE + (USER_SIZE - 1)); i++) {
    +			addr_t pgtable_addr;
    +			vm_page *page;
    +
    +			if (map->arch_data->pgdir_virt[i].present == 1) {
    +				pgtable_addr = map->arch_data->pgdir_virt[i].addr;
    +				page = vm_lookup_page(pgtable_addr);
    +				if (!page)
    +					panic("destroy_tmap: didn't find pgtable page\n");
    +				vm_page_set_state(page, PAGE_STATE_FREE);
    +			}
    +		}
    +		free(map->arch_data->pgdir_virt);
    +	}
    +
    +	free(map->arch_data);
    +	recursive_lock_destroy(&map->lock);
    +}
    +
    +
    +static void
    +put_pgtable_in_pgdir(page_directory_entry *entry,
    +	addr_t pgtable_phys, uint32 attributes)
    +{
    +	page_directory_entry table;
    +	// put it in the pgdir
    +	init_page_directory_entry(&table);
    +	table.addr = ADDR_SHIFT(pgtable_phys);
    +
    +	// ToDo: we ignore the attributes of the page table - for compatibility
    +	//	with BeOS we allow having user accessible areas in the kernel address
    +	//	space. This is currently being used by some drivers, mainly for the
    +	//	frame buffer. Our current real time data implementation makes use of
    +	//	this fact, too.
    +	//	We might want to get rid of this possibility one day, especially if
    +	//	we intend to port it to a platform that does not support this.
    +	table.user = 1;
    +	table.rw = 1;
    +	table.present = 1;
    +	update_page_directory_entry(entry, &table);
    +}
    +
    +
    +static void
    +put_page_table_entry_in_pgtable(page_table_entry *entry,
    +	addr_t physicalAddress, uint32 attributes, bool globalPage)
    +{
    +	page_table_entry page;
    +	init_page_table_entry(&page);
    +
    +	page.addr = ADDR_SHIFT(physicalAddress);
    +
    +	// if the page is user accessible, it's automatically
    +	// accessible in kernel space, too (but with the same
    +	// protection)
    +	page.user = (attributes & B_USER_PROTECTION) != 0;
    +	if (page.user)
    +		page.rw = (attributes & B_WRITE_AREA) != 0;
    +	else
    +		page.rw = (attributes & B_KERNEL_WRITE_AREA) != 0;
    +	page.present = 1;
    +
    +	if (globalPage)
    +		page.global = 1;
    +
    +	// put it in the page table
    +	update_page_table_entry(entry, &page);
    +}
    +
    +
    +static status_t
    +map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
    +{
    +	page_directory_entry *pd;
    +	page_table_entry *pt;
    +	unsigned int index;
    +	int err;
    +
    +	TRACE(("map_tmap: entry pa 0x%lx va 0x%lx\n", pa, va));
    +
    +/*
    +	dprintf("pgdir at 0x%x\n", pgdir);
    +	dprintf("index is %d\n", va / B_PAGE_SIZE / 1024);
    +	dprintf("final at 0x%x\n", &pgdir[va / B_PAGE_SIZE / 1024]);
    +	dprintf("value is 0x%x\n", *(int *)&pgdir[va / B_PAGE_SIZE / 1024]);
    +	dprintf("present bit is %d\n", pgdir[va / B_PAGE_SIZE / 1024].present);
    +	dprintf("addr is %d\n", pgdir[va / B_PAGE_SIZE / 1024].addr);
    +*/
    +	pd = map->arch_data->pgdir_virt;
    +
    +	// check to see if a page table exists for this range
    +	index = VADDR_TO_PDENT(va);
    +	if (pd[index].present == 0) {
    +		addr_t pgtable;
    +		vm_page *page;
    +
    +		// we need to allocate a pgtable
    +		page = vm_page_allocate_page(PAGE_STATE_CLEAR, false);
    +
    +		// mark the page WIRED
    +		vm_page_set_state(page, PAGE_STATE_WIRED);
    +
    +		pgtable = page->physical_page_number * B_PAGE_SIZE;
    +
    +		TRACE(("map_tmap: asked for free page for pgtable. 0x%lx\n", pgtable));
    +
    +		// put it in the pgdir
    +		put_pgtable_in_pgdir(&pd[index], pgtable, attributes
    +			| (attributes & B_USER_PROTECTION ? B_WRITE_AREA : B_KERNEL_WRITE_AREA));
    +
    +		// update any other page directories, if it maps kernel space
    +		if (index >= FIRST_KERNEL_PGDIR_ENT
    +			&& index < (FIRST_KERNEL_PGDIR_ENT + NUM_KERNEL_PGDIR_ENTS))
    +			_update_all_pgdirs(index, pd[index]);
    +
    +		map->map_count++;
    +	}
    +
    +	// now, fill in the pentry
    +	do {
    +		err = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
    +				(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
    +	} while (err < 0);
    +	index = VADDR_TO_PTENT(va);
    +
    +	put_page_table_entry_in_pgtable(&pt[index], pa, attributes,
    +		IS_KERNEL_MAP(map));
    +
    +	put_physical_page_tmap((addr_t)pt);
    +
    +	if (map->arch_data->num_invalidate_pages < PAGE_INVALIDATE_CACHE_SIZE)
    +		map->arch_data->pages_to_invalidate[map->arch_data->num_invalidate_pages] = va;
    +
    +	map->arch_data->num_invalidate_pages++;
    +
    +	map->map_count++;
    +
    +	return 0;
    +}
    +
    +
    +static status_t
    +unmap_tmap(vm_translation_map *map, addr_t start, addr_t end)
    +{
    +	page_table_entry *pt;
    +	page_directory_entry *pd = map->arch_data->pgdir_virt;
    +	status_t status;
    +	int index;
    +
    +	start = ROUNDOWN(start, B_PAGE_SIZE);
    +	end = ROUNDUP(end, B_PAGE_SIZE);
    +
    +	TRACE(("unmap_tmap: asked to free pages 0x%lx to 0x%lx\n", start, end));
    +
    +restart:
    +	if (start >= end)
    +		return B_OK;
    +
    +	index = VADDR_TO_PDENT(start);
    +	if (pd[index].present == 0) {
    +		// no pagetable here, move the start up to access the next page table
    +		start = ROUNDUP(start + 1, B_PAGE_SIZE);
    +		goto restart;
    +	}
    +
    +	do {
    +		status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
    +			(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
    +	} while (status < B_OK);
    +
    +	for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
    +			index++, start += B_PAGE_SIZE) {
    +		if (pt[index].present == 0) {
    +			// page mapping not valid
    +			continue;
    +		}
    +
    +		TRACE(("unmap_tmap: removing page 0x%lx\n", start));
    +
    +		pt[index].present = 0;
    +		map->map_count--;
    +
    +		if (map->arch_data->num_invalidate_pages < PAGE_INVALIDATE_CACHE_SIZE)
    +			map->arch_data->pages_to_invalidate[map->arch_data->num_invalidate_pages] = start;
    +
    +		map->arch_data->num_invalidate_pages++;
    +	}
    +
    +	put_physical_page_tmap((addr_t)pt);
    +
    +	goto restart;
    +}
    +
    +
    +static status_t
    +query_tmap_interrupt(vm_translation_map *map, addr_t va, addr_t *_physical,
    +	uint32 *_flags)
    +{
    +	page_directory_entry *pd = map->arch_data->pgdir_virt;
    +	page_table_entry *pt;
    +	addr_t physicalPageTable;
    +	int32 cpu = smp_get_current_cpu();
    +	int32 index;
    +
    +	*_physical = 0;
    +
    +	index = VADDR_TO_PDENT(va);
    +	if (pd[index].present == 0) {
    +		// no pagetable here
    +		return B_ERROR;
    +	}
    +
    +	// map page table entry using our per CPU mapping page
    +
    +	physicalPageTable = ADDR_REVERSE_SHIFT(pd[index].addr);
    +	pt = (page_table_entry *)(sQueryPages + cpu * B_PAGE_SIZE);
    +	index = VADDR_TO_PDENT((addr_t)pt);
    +	if (pd[index].present == 0) {
    +		// no page table here
    +		return B_ERROR;
    +	}
    +
    +	index = VADDR_TO_PTENT((addr_t)pt);
    +	put_page_table_entry_in_pgtable(&sQueryPageTable[index], physicalPageTable,
    +		B_KERNEL_READ_AREA, false);
    +	invalidate_TLB(pt);
    +
    +	index = VADDR_TO_PTENT(va);
    +	*_physical = ADDR_REVERSE_SHIFT(pt[index].addr);
    +
    +	*_flags |= ((pt[index].rw ? B_KERNEL_WRITE_AREA : 0) | B_KERNEL_READ_AREA)
    +		| (pt[index].dirty ? PAGE_MODIFIED : 0)
    +		| (pt[index].accessed ? PAGE_ACCESSED : 0)
    +		| (pt[index].present ? PAGE_PRESENT : 0);
    +
    +	return B_OK;
    +}
    +
    +
    +static status_t
    +query_tmap(vm_translation_map *map, addr_t va, addr_t *_physical, uint32 *_flags)
    +{
    +	page_table_entry *pt;
    +	page_directory_entry *pd = map->arch_data->pgdir_virt;
    +	status_t status;
    +	int32 index;
    +
    +	// default the flags to not present
    +	*_flags = 0;
    +	*_physical = 0;
    +
    +	index = VADDR_TO_PDENT(va);
    +	if (pd[index].present == 0) {
    +		// no pagetable here
    +		return B_NO_ERROR;
    +	}
    +
    +	do {
    +		status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
    +			(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
    +	} while (status < B_OK);
    +	index = VADDR_TO_PTENT(va);
    +
    +	*_physical = ADDR_REVERSE_SHIFT(pt[index].addr);
    +
    +	// read in the page state flags, clearing the modified and accessed flags in the process
    +	if (pt[index].user)
    +		*_flags |= (pt[index].rw ? B_WRITE_AREA : 0) | B_READ_AREA;
    +
    +	*_flags |= ((pt[index].rw ? B_KERNEL_WRITE_AREA : 0) | B_KERNEL_READ_AREA)
    +		| (pt[index].dirty ? PAGE_MODIFIED : 0)
    +		| (pt[index].accessed ? PAGE_ACCESSED : 0)
    +		| (pt[index].present ? PAGE_PRESENT : 0);
    +
    +	put_physical_page_tmap((addr_t)pt);
    +
    +	TRACE(("query_tmap: returning pa 0x%lx for va 0x%lx\n", *_physical, va));
    +
    +	return B_OK;
    +}
    +
    +
    +static addr_t
    +get_mapped_size_tmap(vm_translation_map *map)
    +{
    +	return map->map_count;
    +}
    +
    +
    +static status_t
    +protect_tmap(vm_translation_map *map, addr_t start, addr_t end, uint32 attributes)
    +{
    +	page_table_entry *pt;
    +	page_directory_entry *pd = map->arch_data->pgdir_virt;
    +	status_t status;
    +	int index;
    +
    +	start = ROUNDOWN(start, B_PAGE_SIZE);
    +	end = ROUNDUP(end, B_PAGE_SIZE);
    +
    +	TRACE(("protect_tmap: pages 0x%lx to 0x%lx, attributes %lx\n", start, end, attributes));
    +
    +restart:
    +	if (start >= end)
    +		return B_OK;
    +
    +	index = VADDR_TO_PDENT(start);
    +	if (pd[index].present == 0) {
    +		// no pagetable here, move the start up to access the next page table
    +		start = ROUNDUP(start + 1, B_PAGE_SIZE);
    +		goto restart;
    +	}
    +
    +	do {
    +		status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
    +				(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
    +	} while (status < B_OK);
    +
    +	for (index = VADDR_TO_PTENT(start); index < 1024 && start < end; index++, start += B_PAGE_SIZE) {
    +		if (pt[index].present == 0) {
    +			// page mapping not valid
    +			continue;
    +		}
    +
    +		TRACE(("protect_tmap: protect page 0x%lx\n", start));
    +
    +		pt[index].user = (attributes & B_USER_PROTECTION) != 0;
    +		if ((attributes & B_USER_PROTECTION) != 0)
    +			pt[index].rw = (attributes & B_WRITE_AREA) != 0;
    +		else
    +			pt[index].rw = (attributes & B_KERNEL_WRITE_AREA) != 0;
    +
    +		if (map->arch_data->num_invalidate_pages < PAGE_INVALIDATE_CACHE_SIZE)
    +			map->arch_data->pages_to_invalidate[map->arch_data->num_invalidate_pages] = start;
    +
    +		map->arch_data->num_invalidate_pages++;
    +	}
    +
    +	put_physical_page_tmap((addr_t)pt);
    +
    +	goto restart;
    +}
    +
    +
    +static status_t
    +clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags)
    
    [... truncated: 1008 lines follow ...]
    
    
    From axeld at mail.berlios.de  Thu Sep 27 14:10:07 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 14:10:07 +0200
    Subject: [Haiku-commits] r22327 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709271210.l8RCA7x7013694@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 14:10:06 +0200 (Thu, 27 Sep 2007)
    New Revision: 22327
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22327&view=rev
    
    Removed:
       haiku/trunk/src/system/kernel/vm/vm_address_space.c
       haiku/trunk/src/system/kernel/vm/vm_store_anonymous_noswap.c
    Log:
    Forget to actually delete some old C files.
    For some reason, shell wildcards do not include deleted files... :)
    
    
    Deleted: haiku/trunk/src/system/kernel/vm/vm_address_space.c
    
    Deleted: haiku/trunk/src/system/kernel/vm/vm_store_anonymous_noswap.c
    
    
    
    From axeld at mail.berlios.de  Thu Sep 27 14:12:25 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 14:12:25 +0200
    Subject: [Haiku-commits] r22328 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709271212.l8RCCP1V013826@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 14:12:24 +0200 (Thu, 27 Sep 2007)
    New Revision: 22328
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22328&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * Removed the automatic release of the "modified_pages_available" semaphore
      in enqueue_page() - it doesn't really belong there.
    * Minor cleanup.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-27 12:10:06 UTC (rev 22327)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    @@ -64,28 +64,28 @@
     
     /*!	Dequeues a page from the tail of the given queue */
     static vm_page *
    -dequeue_page(page_queue *q)
    +dequeue_page(page_queue *queue)
     {
     	vm_page *page;
     
    -	page = q->tail;
    +	page = queue->tail;
     	if (page != NULL) {
    -		if (q->head == page)
    -			q->head = NULL;
    +		if (queue->head == page)
    +			queue->head = NULL;
     		if (page->queue_prev != NULL)
     			page->queue_prev->queue_next = NULL;
     
    -		q->tail = page->queue_prev;
    -		q->count--;
    +		queue->tail = page->queue_prev;
    +		queue->count--;
     
    -		#ifdef DEBUG_PAGE_QUEUE
    -			if (page->queue != q) {
    -				panic("dequeue_page(queue: %p): page %p thinks it is in queue "
    -					"%p", q, page, page->queue);
    -			}
    +#ifdef DEBUG_PAGE_QUEUE
    +		if (page->queue != queue) {
    +			panic("dequeue_page(queue: %p): page %p thinks it is in queue "
    +				"%p", queue, page, page->queue);
    +		}
     
    -			page->queue = NULL;
    -		#endif	// DEBUG_PAGE_QUEUE
    +		page->queue = NULL;
    +#endif	// DEBUG_PAGE_QUEUE
     	}
     
     	return page;
    @@ -94,44 +94,39 @@
     
     /*!	Enqueues a page to the head of the given queue */
     static void
    -enqueue_page(page_queue *q, vm_page *page)
    +enqueue_page(page_queue *queue, vm_page *page)
     {
    -	#ifdef DEBUG_PAGE_QUEUE
    -		if (page->queue != NULL) {
    -			panic("enqueue_page(queue: %p, page: %p): page thinks it is "
    -				"already in queue %p", q, page, page->queue);
    -		}
    -	#endif	// DEBUG_PAGE_QUEUE
    +#ifdef DEBUG_PAGE_QUEUE
    +	if (page->queue != NULL) {
    +		panic("enqueue_page(queue: %p, page: %p): page thinks it is "
    +			"already in queue %p", queue, page, page->queue);
    +	}
    +#endif	// DEBUG_PAGE_QUEUE
     
    -	if (q->head != NULL)
    -		q->head->queue_prev = page;
    -	page->queue_next = q->head;
    -	q->head = page;
    +	if (queue->head != NULL)
    +		queue->head->queue_prev = page;
    +	page->queue_next = queue->head;
    +	queue->head = page;
     	page->queue_prev = NULL;
    -	if (q->tail == NULL)
    -		q->tail = page;
    -	q->count++;
    +	if (queue->tail == NULL)
    +		queue->tail = page;
    +	queue->count++;
     
    -	#ifdef DEBUG_PAGE_QUEUE
    -		page->queue = q;
    -	#endif
    -
    -	if (q == &sModifiedPageQueue) {
    -		if (q->count == 1)
    -			release_sem_etc(modified_pages_available, 1, B_DO_NOT_RESCHEDULE);
    -	}
    +#ifdef DEBUG_PAGE_QUEUE
    +	page->queue = queue;
    +#endif
     }
     
     
     static void
     remove_page_from_queue(page_queue *queue, vm_page *page)
     {
    -	#ifdef DEBUG_PAGE_QUEUE
    -		if (page->queue != queue) {
    -			panic("remove_page_from_queue(queue: %p, page: %p): page thinks it "
    -				"is in queue %p", queue, page, page->queue);
    -		}
    -	#endif	// DEBUG_PAGE_QUEUE
    +#ifdef DEBUG_PAGE_QUEUE
    +	if (page->queue != queue) {
    +		panic("remove_page_from_queue(queue: %p, page: %p): page thinks it "
    +			"is in queue %p", queue, page, page->queue);
    +	}
    +#endif	// DEBUG_PAGE_QUEUE
     
     	if (page->queue_prev != NULL)
     		page->queue_prev->queue_next = page->queue_next;
    @@ -145,9 +140,9 @@
     
     	queue->count--;
     
    -	#ifdef DEBUG_PAGE_QUEUE
    -		page->queue = NULL;
    -	#endif
    +#ifdef DEBUG_PAGE_QUEUE
    +	page->queue = NULL;
    +#endif
     }
     
     
    
    
    
    From axeld at mail.berlios.de  Thu Sep 27 14:21:36 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 14:21:36 +0200
    Subject: [Haiku-commits] r22329 - in haiku/trunk: headers/private/kernel
    	headers/private/kernel/arch headers/private/kernel/arch/x86
    	headers/private/kernel/util src/system/kernel
    	src/system/kernel/arch/x86 src/system/kernel/cache
    	src/system/kernel/debug src/system/kernel/slab
    	src/system/kernel/util src/system/kernel/vm
    Message-ID: <200709271221.l8RCLapc014731@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 14:21:33 +0200 (Thu, 27 Sep 2007)
    New Revision: 22329
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22329&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/arch/vm.h
       haiku/trunk/headers/private/kernel/arch/x86/commpage.h
       haiku/trunk/headers/private/kernel/util/syscall_args.h
       haiku/trunk/headers/private/kernel/vm.h
       haiku/trunk/headers/private/kernel/vm_address_space.h
       haiku/trunk/headers/private/kernel/vm_cache.h
       haiku/trunk/headers/private/kernel/vm_page.h
       haiku/trunk/headers/private/kernel/vm_priv.h
       haiku/trunk/headers/private/kernel/vm_types.h
       haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c
       haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp
       haiku/trunk/src/system/kernel/arch/x86/arch_thread.c
       haiku/trunk/src/system/kernel/arch/x86/commpage.c
       haiku/trunk/src/system/kernel/cache/block_allocator.cpp
       haiku/trunk/src/system/kernel/cache/vnode_store.h
       haiku/trunk/src/system/kernel/debug/debug.c
       haiku/trunk/src/system/kernel/debug/gdb.c
       haiku/trunk/src/system/kernel/elf.cpp
       haiku/trunk/src/system/kernel/slab/Slab.cpp
       haiku/trunk/src/system/kernel/system_info.c
       haiku/trunk/src/system/kernel/thread.cpp
       haiku/trunk/src/system/kernel/util/cbuf.c
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
       haiku/trunk/src/system/kernel/vm/vm_store_device.c
       haiku/trunk/src/system/kernel/vm/vm_store_device.h
       haiku/trunk/src/system/kernel/vm/vm_store_null.c
       haiku/trunk/src/system/kernel/vm/vm_store_null.h
    Log:
    * vm.h no longer includes vm_types.h - only those that actually need access
      to the private VM types are including vm_types.h now.
    * Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's
      cleaner this way, and the actual types are only used in C++ files now,
      anyway.
    * And that caused changes in many files...
    * Made commpage.h self-containing.
    * Minor cleanup.
    
    
    Modified: haiku/trunk/headers/private/kernel/arch/vm.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/arch/vm.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/arch/vm.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2002-2005, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    @@ -9,10 +9,16 @@
     #define KERNEL_ARCH_VM_H
     
     
    -#include 
     #include 
     
    +#include 
     
    +
    +struct kernel_args;
    +struct vm_area;
    +struct vm_address_space;
    +
    +
     #ifdef __cplusplus
     extern "C" {
     #endif
    @@ -20,12 +26,13 @@
     status_t arch_vm_init(struct kernel_args *args);
     status_t arch_vm_init_post_area(struct kernel_args *args);
     status_t arch_vm_init_end(struct kernel_args *args);
    -status_t arch_vm_init_post_modules(kernel_args *args);
    -void arch_vm_aspace_swap(vm_address_space *aspace);
    +status_t arch_vm_init_post_modules(struct kernel_args *args);
    +void arch_vm_aspace_swap(struct vm_address_space *aspace);
     bool arch_vm_supports_protection(uint32 protection);
     
    -status_t arch_vm_set_memory_type(vm_area *area, addr_t physicalBase, uint32 type);
    -void arch_vm_unset_memory_type(vm_area *area);
    +status_t arch_vm_set_memory_type(struct vm_area *area, addr_t physicalBase,
    +	uint32 type);
    +void arch_vm_unset_memory_type(struct vm_area *area);
     
     #ifdef __cplusplus
     }
    
    Modified: haiku/trunk/headers/private/kernel/arch/x86/commpage.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/arch/x86/commpage.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/arch/x86/commpage.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -5,8 +5,13 @@
     #ifndef _KERNEL_ARCH_x86_COMMPAGE_H
     #define _KERNEL_ARCH_x86_COMMPAGE_H
     
    -/* some systemwide commpage constants, used in the kernel and libroot */
    +/*! Some systemwide commpage constants, used in the kernel and libroot */
     
    +#ifndef _ASSEMBLER
    +#	include 
    +#endif
    +
    +
     /* be careful what you put here, this file is included from assembly */
     #define COMMPAGE_ENTRY_MAGIC   0
     #define COMMPAGE_ENTRY_VERSION 1
    @@ -23,5 +28,4 @@
     status_t commpage_init(void);
     #endif
     
    -#endif
    -
    +#endif	/* _KERNEL_ARCH_x86_COMMPAGE_H */
    
    Modified: haiku/trunk/headers/private/kernel/util/syscall_args.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/util/syscall_args.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/util/syscall_args.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -3,8 +3,8 @@
     #ifndef _SYSCALL_ARGS_H
     #define _SYSCALL_ARGS_H
     
    -#include 
    -#include 
    +#include 
    +//#include 
     
     // Hack to be able to use the IS_USER_ADDRESS macro when compiling for R5.
     #ifdef R5_MEMORY_LAYOUT
    
    Modified: haiku/trunk/headers/private/kernel/vm.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -9,12 +9,17 @@
     #define _KERNEL_VM_H
     
     
    -#include 
     #include 
    -#include 
     
    +#include 
    +
    +
     struct kernel_args;
     struct team;
    +struct vm_page;
    +struct vm_cache;
    +struct vm_area;
    +struct vm_address_space;
     struct vnode;
     
     
    @@ -23,13 +28,13 @@
     #endif
     
     // startup only
    -status_t vm_init(kernel_args *args);
    +status_t vm_init(struct kernel_args *args);
     status_t vm_init_post_sem(struct kernel_args *args);
     status_t vm_init_post_thread(struct kernel_args *args);
     status_t vm_init_post_modules(struct kernel_args *args);
    -void vm_free_kernel_args(kernel_args *args);
    +void vm_free_kernel_args(struct kernel_args *args);
     void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
    -addr_t vm_allocate_early(kernel_args *args, size_t virtualSize,
    +addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize,
     			size_t physicalSize, uint32 attributes);
     
     
    @@ -56,8 +61,8 @@
     area_id vm_map_file(team_id aid, const char *name, void **address, 
     			uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping, 
     			const char *path, off_t offset);
    -vm_cache *vm_area_get_locked_cache(vm_area *area);
    -void vm_area_put_locked_cache(vm_cache *cache);
    +struct vm_cache *vm_area_get_locked_cache(struct vm_area *area);
    +void vm_area_put_locked_cache(struct vm_cache *cache);
     area_id vm_create_null_area(team_id team, const char *name, void **address, 
     			uint32 addressSpec, addr_t size);
     area_id vm_copy_area(team_id team, const char *name, void **_address, 
    @@ -65,16 +70,17 @@
     area_id vm_clone_area(team_id team, const char *name, void **address, 
     			uint32 addressSpec, uint32 protection, uint32 mapping, 
     			area_id sourceArea);
    -status_t vm_delete_area(team_id aid, area_id id);
    -status_t vm_create_vnode_cache(struct vnode *vnode, vm_cache **_cache);
    -vm_area *vm_area_lookup(vm_address_space *addressSpace, addr_t address);
    +status_t vm_delete_area(team_id teamID, area_id areaID);
    +status_t vm_create_vnode_cache(struct vnode *vnode, struct vm_cache **_cache);
    +struct vm_area *vm_area_lookup(struct vm_address_space *addressSpace,
    +			addr_t address);
     status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
     status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
    -int32 vm_test_map_activation(vm_page *page, bool *_modified);
    -void vm_clear_map_activation(vm_page *page);
    -void vm_remove_all_page_mappings(vm_page *page);
    -status_t vm_unmap_pages(vm_area *area, addr_t base, size_t length);
    -status_t vm_map_page(vm_area *area, vm_page *page, addr_t address,
    +int32 vm_test_map_activation(struct vm_page *page, bool *_modified);
    +void vm_clear_map_activation(struct vm_page *page);
    +void vm_remove_all_page_mappings(struct vm_page *page);
    +status_t vm_unmap_pages(struct vm_area *area, addr_t base, size_t length);
    +status_t vm_map_page(struct vm_area *area, struct vm_page *page, addr_t address,
     			uint32 protection);
     status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, uint32 flags);
     status_t vm_put_physical_page(addr_t vaddr);
    
    Modified: haiku/trunk/headers/private/kernel/vm_address_space.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_address_space.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm_address_space.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -9,10 +9,11 @@
     #define _KERNEL_VM_ADDRESS_SPACE_H
     
     
    -#include 
    -#include 
    +#include 
     
    +
     struct kernel_args;
    +struct vm_address_space;
     
     
     #ifdef __cplusplus
    @@ -22,17 +23,17 @@
     status_t vm_address_space_init(void);
     status_t vm_address_space_init_post_sem(void);
     
    -void vm_delete_address_space(vm_address_space *aspace);
    +void vm_delete_address_space(struct vm_address_space *aspace);
     status_t vm_create_address_space(team_id id, addr_t base, addr_t size,
    -			bool kernel, vm_address_space **_aspace);
    +			bool kernel, struct vm_address_space **_aspace);
     status_t vm_delete_areas(struct vm_address_space *aspace);
    -vm_address_space *vm_get_kernel_address_space(void);
    -vm_address_space *vm_kernel_address_space(void);
    +struct vm_address_space *vm_get_kernel_address_space(void);
    +struct vm_address_space *vm_kernel_address_space(void);
     team_id vm_kernel_address_space_id(void);
    -vm_address_space *vm_get_current_user_address_space(void);
    +struct vm_address_space *vm_get_current_user_address_space(void);
     team_id vm_current_user_address_space_id(void);
    -vm_address_space *vm_get_address_space_by_id(team_id aid);
    -void vm_put_address_space(vm_address_space *aspace);
    +struct vm_address_space *vm_get_address_space_by_id(team_id aid);
    +void vm_put_address_space(struct vm_address_space *aspace);
     #define vm_swap_address_space(aspace) arch_vm_aspace_swap(aspace)
     
     #ifdef __cplusplus
    
    Modified: haiku/trunk/headers/private/kernel/vm_cache.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_cache.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm_cache.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -12,28 +12,34 @@
     #include 
     #include 
     
    +
     struct kernel_args;
     
    +//typedef struct vm_store vm_store;
     
    +
     #ifdef __cplusplus
     extern "C" {
     #endif
     
     status_t vm_cache_init(struct kernel_args *args);
    -vm_cache *vm_cache_create(vm_store *store);
    -void vm_cache_acquire_ref(vm_cache *cache);
    -void vm_cache_release_ref(vm_cache *cache);
    -vm_cache *vm_cache_acquire_page_cache_ref(vm_page *page);
    -vm_page *vm_cache_lookup_page(vm_cache *cache, off_t page);
    -void vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset);
    -void vm_cache_remove_page(vm_cache *cache, vm_page *page);
    -void vm_cache_remove_consumer(vm_cache *cache, vm_cache *consumer);
    -void vm_cache_add_consumer_locked(vm_cache *cache, vm_cache *consumer);
    -status_t vm_cache_write_modified(vm_cache *cache, bool fsReenter);
    -status_t vm_cache_set_minimal_commitment_locked(vm_cache *cache, off_t commitment);
    -status_t vm_cache_resize(vm_cache *cache, off_t newSize);
    -status_t vm_cache_insert_area_locked(vm_cache *cache, vm_area *area);
    -status_t vm_cache_remove_area(vm_cache *cache, vm_area *area);
    +struct vm_cache *vm_cache_create(struct vm_store *store);
    +void vm_cache_acquire_ref(struct vm_cache *cache);
    +void vm_cache_release_ref(struct vm_cache *cache);
    +struct vm_cache *vm_cache_acquire_page_cache_ref(struct vm_page *page);
    +struct vm_page *vm_cache_lookup_page(struct vm_cache *cache, off_t page);
    +void vm_cache_insert_page(struct vm_cache *cache, struct vm_page *page,
    +	off_t offset);
    +void vm_cache_remove_page(struct vm_cache *cache, struct vm_page *page);
    +void vm_cache_remove_consumer(struct vm_cache *cache, struct vm_cache *consumer);
    +void vm_cache_add_consumer_locked(struct vm_cache *cache,
    +	struct vm_cache *consumer);
    +status_t vm_cache_write_modified(struct vm_cache *cache, bool fsReenter);
    +status_t vm_cache_set_minimal_commitment_locked(struct vm_cache *cache,
    +	off_t commitment);
    +status_t vm_cache_resize(struct vm_cache *cache, off_t newSize);
    +status_t vm_cache_insert_area_locked(struct vm_cache *cache, vm_area *area);
    +status_t vm_cache_remove_area(struct vm_cache *cache, struct vm_area *area);
     
     #ifdef __cplusplus
     }
    
    Modified: haiku/trunk/headers/private/kernel/vm_page.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_page.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm_page.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -19,31 +19,32 @@
     extern "C" {
     #endif
     
    -void vm_page_init_num_pages(kernel_args *args);
    +void vm_page_init_num_pages(struct kernel_args *args);
     status_t vm_page_init(struct kernel_args *args);
     status_t vm_page_init_post_area(struct kernel_args *args);
     status_t vm_page_init_post_thread(struct kernel_args *args);
     
     status_t vm_mark_page_inuse(addr_t page);
     status_t vm_mark_page_range_inuse(addr_t startPage, addr_t length);
    -status_t vm_page_set_state(vm_page *page, int state);
    +status_t vm_page_set_state(struct vm_page *page, int state);
     
     // get some data about the number of pages in the system
     size_t vm_page_num_pages(void);
     size_t vm_page_num_free_pages(void);
     
    -status_t vm_page_write_modified_page(vm_cache *cache, struct vm_page *page,
    -	bool fsReenter);
    -status_t vm_page_write_modified_pages(vm_cache *cache, bool fsReenter);
    +status_t vm_page_write_modified_page(struct vm_cache *cache,
    +	struct vm_page *page, bool fsReenter);
    +status_t vm_page_write_modified_pages(struct vm_cache *cache, bool fsReenter);
     
     void vm_page_unreserve_pages(uint32 count);
     void vm_page_reserve_pages(uint32 count);
     
    -vm_page *vm_page_allocate_page(int pageState, bool reserved);
    -status_t vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages);
    -vm_page *vm_page_allocate_page_run(int state, addr_t length);
    -vm_page *vm_page_at_index(int32 index);
    -vm_page *vm_lookup_page(addr_t pageNumber);
    +struct vm_page *vm_page_allocate_page(int pageState, bool reserved);
    +status_t vm_page_allocate_pages(int pageState, struct vm_page **pages,
    +	uint32 numPages);
    +struct vm_page *vm_page_allocate_page_run(int state, addr_t length);
    +struct vm_page *vm_page_at_index(int32 index);
    +struct vm_page *vm_lookup_page(addr_t pageNumber);
     
     #ifdef __cplusplus
     }
    
    Modified: haiku/trunk/headers/private/kernel/vm_priv.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_priv.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm_priv.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -8,9 +8,10 @@
     #ifndef _KERNEL_VM_PRIV_H
     #define _KERNEL_VM_PRIV_H
     
    -#include 
    -#include 
     
    +#include 
    +
    +
     /* should make these scale with the system */
     #define DEFAULT_KERNEL_WORKING_SET  1024
     #define DEFAULT_WORKING_SET         256
    
    Modified: haiku/trunk/headers/private/kernel/vm_types.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -69,8 +69,7 @@
     typedef class DoublyLinkedQueue vm_page_mappings;
     typedef class DoublyLinkedQueue vm_area_mappings;
     
    -// vm page
    -typedef struct vm_page {
    +struct vm_page {
     	struct vm_page		*queue_prev;
     	struct vm_page		*queue_next;
     
    @@ -104,7 +103,7 @@
     
     	uint16				wired_count;
     	int8				usage_count;
    -} vm_page;
    +};
     
     enum {
     	PAGE_TYPE_PHYSICAL = 0,
    @@ -134,8 +133,7 @@
     	ConditionVariable	busy_condition;
     };
     
    -// vm_cache
    -typedef struct vm_cache {
    +struct vm_cache {
     	mutex				lock;
     	struct vm_area		*areas;
     	vint32				ref_count;
    @@ -158,15 +156,14 @@
     	struct vm_cache*	debug_previous;
     	struct vm_cache*	debug_next;
     #endif
    -} vm_cache;
    +};
     
     
     #if DEBUG_CACHE_LIST
     extern vm_cache* gDebugCacheList;
     #endif
     
    -// vm area
    -typedef struct vm_area {
    +struct vm_area {
     	char				*name;
     	area_id				id;
     	addr_t				base;
    @@ -186,24 +183,18 @@
     	struct vm_area		*cache_next;
     	struct vm_area		*cache_prev;
     	struct vm_area		*hash_next;
    -} vm_area;
    +};
     
    -#else	// !__cplusplus
    -// these are just opaque types in C
    -typedef struct vm_page vm_page;
    -typedef struct vm_cache vm_cache;
    -typedef struct vm_area vm_area;
    -#endif
    +#endif	// __cplusplus
     
     enum {
     	VM_ASPACE_STATE_NORMAL = 0,
     	VM_ASPACE_STATE_DELETION
     };
     
    -// address space
    -typedef struct vm_address_space {
    -	vm_area				*areas;
    -	vm_area				*area_hint;
    +struct vm_address_space {
    +	struct vm_area		*areas;
    +	struct vm_area		*area_hint;
     	sem_id				sem;
     	addr_t				base;
     	addr_t				size;
    @@ -219,26 +210,24 @@
     	addr_t				min_working_set;
     	bigtime_t			last_working_set_adjust;
     	struct vm_address_space *hash_next;
    -} vm_address_space;
    +};
     
    -// vm_store
    -typedef struct vm_store {
    +struct vm_store {
     	struct vm_store_ops	*ops;
     	struct vm_cache		*cache;
     	off_t				committed_size;
    -} vm_store;
    +};
     
    -// vm_store_ops
     typedef struct vm_store_ops {
     	void (*destroy)(struct vm_store *backing_store);
     	status_t (*commit)(struct vm_store *backing_store, off_t size);
     	bool (*has_page)(struct vm_store *backing_store, off_t offset);
    -	status_t (*read)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
    -				size_t count, size_t *_numBytes, bool fsReenter);
    -	status_t (*write)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
    -				size_t count, size_t *_numBytes, bool fsReenter);
    -	status_t (*fault)(struct vm_store *backing_store, struct vm_address_space *aspace,
    -				off_t offset);
    +	status_t (*read)(struct vm_store *backing_store, off_t offset,
    +		const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
    +	status_t (*write)(struct vm_store *backing_store, off_t offset,
    +		const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
    +	status_t (*fault)(struct vm_store *backing_store,
    +		struct vm_address_space *aspace, off_t offset);
     	void (*acquire_ref)(struct vm_store *backing_store);
     	void (*release_ref)(struct vm_store *backing_store);
     } vm_store_ops;
    @@ -291,6 +280,7 @@
     	//	flags region in the protection field.
     
     #define B_USER_AREA_FLAGS		(B_USER_PROTECTION)
    -#define B_KERNEL_AREA_FLAGS		(B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
    +#define B_KERNEL_AREA_FLAGS \
    +	(B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
     
     #endif	/* _KERNEL_VM_TYPES_H */
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    @@ -7,25 +7,25 @@
      */
     
     
    +#include 
    +
    +#include 
    +#include 
    +#include 
    +
     #include 
     #include 
     #include 
    -#include 
    +#include 
     
     #include 
    -#include 
    -#include 
     #include 
     #include 
     #include 
     
     #include "interrupts.h"
     
    -#include 
    -#include 
    -#include 
     
    -
     /* cpu vendor info */
     struct cpu_vendor_info {
     	const char *vendor;
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -7,19 +7,21 @@
      */
     
     
    +#include 
    +
    +#include 
    +
     #include 
     #include 
     #include 
     #include 
     #include 
     #include 
    +#include 
     
    -#include 
     #include 
     
    -#include 
     
    -
     struct stack_frame {
     	struct stack_frame	*previous;
     	addr_t				return_address;
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/arch_thread.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_thread.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_thread.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -7,15 +7,17 @@
      */
     
     
    -#include 
     #include 
    +
     #include 
     #include 
    +#include 
     #include 
    -#include 
     #include 
    +#include 
    +#include 
     #include 
    -#include 
    +#include 
     
     #include 
     
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/commpage.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/commpage.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/arch/x86/commpage.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -2,12 +2,18 @@
      * Copyright 2007, Travis Geiselbrecht. All rights reserved.
      * Distributed under the terms of the MIT License.
      */
    -#include 
    +
    +
     #include 
     
    -#include 
     #include 
     
    +#include 
    +
    +#include 
    +#include 
    +
    +
     static area_id comm_area;
     static area_id user_comm_area;
     static unsigned long *comm_ptr;
    @@ -18,14 +24,16 @@
     extern void _user_syscall_int(void);
     extern unsigned int _user_syscall_int_end;
     
    -static inline
    -addr_t commpage_ptr_to_user_ptr(const void *ptr)
    +
    +static inline addr_t
    +commpage_ptr_to_user_ptr(const void *ptr)
     {
     	return ((addr_t)ptr) + ((addr_t)user_comm_ptr - (addr_t)comm_ptr);
     }
     
    -static
    -status_t initialize_commpage_syscall(void)
    +
    +static status_t
    +initialize_commpage_syscall(void)
     {
     	size_t len;
     	
    @@ -40,19 +48,20 @@
     	return B_OK;
     }
     
    +
     status_t
     commpage_init(void)
     {
     	int i;
     
     	// create a read/write kernel area
    -	comm_area = create_area("commpage", (void **)&comm_ptr, B_ANY_ADDRESS, COMMPAGE_SIZE, B_FULL_LOCK, 
    -		B_KERNEL_WRITE_AREA | B_KERNEL_READ_AREA);
    +	comm_area = create_area("commpage", (void **)&comm_ptr, B_ANY_ADDRESS,
    +		COMMPAGE_SIZE, B_FULL_LOCK, B_KERNEL_WRITE_AREA | B_KERNEL_READ_AREA);
     
     	// clone it at a fixed address with user read/only permissions
     	user_comm_ptr = (void *)USER_COMMPAGE_ADDR;
    -	user_comm_area = clone_area("user_commpage", (void **)&user_comm_ptr, B_EXACT_ADDRESS, 
    -		B_READ_AREA | B_EXECUTE_AREA, comm_area);
    +	user_comm_area = clone_area("user_commpage", (void **)&user_comm_ptr,
    +		B_EXACT_ADDRESS, B_READ_AREA | B_EXECUTE_AREA, comm_area);
     
     	// zero it out
     	memset(comm_ptr, 0, COMMPAGE_SIZE);
    
    Modified: haiku/trunk/src/system/kernel/cache/block_allocator.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/block_allocator.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/cache/block_allocator.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -10,6 +10,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     #include 
     
    
    Modified: haiku/trunk/src/system/kernel/cache/vnode_store.h
    ===================================================================
    --- haiku/trunk/src/system/kernel/cache/vnode_store.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/cache/vnode_store.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -6,7 +6,7 @@
     #define VNODE_STORE_H
     
     
    -#include 
    +#include 
     
     
     struct vnode_store {
    
    Modified: haiku/trunk/src/system/kernel/debug/debug.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/debug/debug.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/debug/debug.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -15,6 +15,7 @@
     #include 
     #include 
     #include 
    +#include 
     #include 
     #include 
     #include 
    
    Modified: haiku/trunk/src/system/kernel/debug/gdb.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/debug/gdb.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/debug/gdb.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005-2006, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2002, Manuel J. Petit. All rights reserved.
    @@ -13,10 +13,13 @@
     #include 
     #include 
     #include 
    +
    +#include 
    +
    +#include 
    +#include 
    +#include 
     #include 
    -#include 
    -#include 
    -#include 
     
     
     enum { INIT = 0, CMDREAD, CKSUM1, CKSUM2, WAITACK, QUIT, GDBSTATES };
    
    Modified: haiku/trunk/src/system/kernel/elf.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/elf.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/elf.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2002-2006, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001, Travis Geiselbrecht. All rights reserved.
    @@ -8,29 +8,32 @@
     
     /* Contains the ELF loader */
     
    +#include 
    +
     #include 
    -#include 
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
     #include 
     #include 
     #include 
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    +#include 
     
     #include 
     #include 
     #include 
     #include 
     
    -#include 
    -#include 
    -#include 
    -#include 
    -#include 
    -
     //#define TRACE_ELF
     #ifdef TRACE_ELF
     #	define TRACE(x) dprintf x
    
    Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -10,22 +10,22 @@
     
     #include "slab_private.h"
     
    +#include 
    +#include 
     #include 
     #include 
     
     #include 
    +
    +#include 
     #include 
     #include 
     #include 
    -
    -#include 
     #include 
    +#include 
     #include 
     
    -#include  // swap
    -#include 
     
    -
     // TODO kMagazineCapacity should be dynamically tuned per cache.
     
     
    
    Modified: haiku/trunk/src/system/kernel/system_info.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/system_info.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/system_info.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2004-2006, Haiku, Inc.
    + * Copyright (c) 2004-2007, Haiku, Inc.
      * Distributed under the terms of the MIT license.
      *
      * Authors:
    @@ -8,14 +8,14 @@
      */
     
     
    +#include 
    +
     #include 
     #include 
     
    -#include 
    -#include 
    -
     #include 
     #include 
    +#include 
     #include 
     #include 
     #include 
    @@ -25,6 +25,8 @@
     #include 
     #include 
     
    +#include 
    +
     #include 
     
     
    
    Modified: haiku/trunk/src/system/kernel/thread.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/thread.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/thread.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -24,7 +24,9 @@
     #include 
     #include 
     #include 
    +#include 
     #include 
    +#include 
     
     #include 
     #include 
    
    Modified: haiku/trunk/src/system/kernel/util/cbuf.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/util/cbuf.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/util/cbuf.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2002-2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2002-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    @@ -12,14 +12,16 @@
      */
     
     
    -#include 
    -#include 
     #include 
    -#include 
     
     #include 
     
    +#include 
     
    +#include 
    +#include 
    +
    +
     #define CBUF_LENGTH 2048
     
     #define CBUF_FLAG_CHAIN_HEAD 1
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -35,6 +35,7 @@
     #include 
     #include 
     #include 
    +#include 
     
     #include 
     #include 
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -11,9 +11,6 @@
     #include 
     #include 
     
    -#include 
    -#include 
    -
     #include 
     #include 
     #include 
    @@ -21,9 +18,12 @@
     #include 
     #include 
     #include 
    +#include 
    +#include 
     #include 
     #include 
     #include 
    +#include 
     
     
     //#define TRACE_VM_CACHE
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_store_device.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_store_device.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/vm/vm_store_device.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -16,8 +16,8 @@
     
     
     struct device_store {
    -	vm_store	vm;
    -	addr_t		base_address;
    +	struct vm_store	vm;
    +	addr_t			base_address;
     };
     
     
    @@ -63,7 +63,8 @@
     
     
     static status_t
    -device_fault(struct vm_store *_store, struct vm_address_space *aspace, off_t offset)
    +device_fault(struct vm_store *_store, struct vm_address_space *aspace,
    +	off_t offset)
     {
     	// devices are mapped in completely, so we shouldn't experience faults
     	return B_BAD_ADDRESS;
    @@ -82,7 +83,7 @@
     };
     
     
    -vm_store *
    +struct vm_store *
     vm_store_create_device(addr_t baseAddress)
     {
     	struct device_store *store = malloc(sizeof(struct device_store));
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_store_device.h
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_store_device.h	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/vm/vm_store_device.h	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    @@ -15,6 +15,6 @@
     #ifdef __cplusplus
     extern "C"
     #endif
    -vm_store *vm_store_create_device(addr_t base_addr);
    +struct vm_store *vm_store_create_device(addr_t base_addr);
     
     #endif	/* _KERNEL_VM_STORE_DEVICE_H */
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_store_null.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_store_null.c	2007-09-27 12:12:24 UTC (rev 22328)
    +++ haiku/trunk/src/system/kernel/vm/vm_store_null.c	2007-09-27 12:21:33 UTC (rev 22329)
    @@ -35,25 +35,27 @@
     
     
     static status_t
    -null_read(struct vm_store *store, off_t offset, const iovec *vecs, size_t count,
    -	size_t *_numBytes, bool fsReenter)
    +null_read(struct vm_store *store, off_t offset, const iovec *vecs,
    +	size_t count, size_t *_numBytes, bool fsReenter)
     {
     	return -1;
     }
     
     
     static status_t
    -null_write(struct vm_store *store, off_t offset, const iovec *vecs, size_t count,
    -	size_t *_numBytes, bool fsReenter)
    +null_write(struct vm_store *store, off_t offset, const iovec *vecs,
    +	size_t count, size_t *_numBytes, bool fsReenter)
     {
     	return -1;
    
    [... truncated: 51 lines follow ...]
    
    
    From stefano.ceccherini at gmail.com  Thu Sep 27 14:32:36 2007
    From: stefano.ceccherini at gmail.com (Stefano Ceccherini)
    Date: Thu, 27 Sep 2007 14:32:36 +0200
    Subject: [Haiku-commits] r22329 - in haiku/trunk: headers/private/kernel
    	headers/private/kernel/arch headers/private/kernel/arch/x86
    	headers/private/kernel/util src/system/kernel
    	src/system/kernel/arch/x86 src/system/kernel/cache
    	src/system/kernel/debug s
    Message-ID: <894b9700709270532j124faf7bm84e27d2dbbea7028@mail.gmail.com>
    
    2007/9/27, axeld at BerliOS :
    > Author: axeld
    > Date: 2007-09-27 14:21:33 +0200 (Thu, 27 Sep 2007)
    > New Revision: 22329
    > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22329&view=rev
    >
    
    This breaks the build of ide/emulation.c.
    
    I bet you forgot to commit it ? :)
    
    
    From axeld at mail.berlios.de  Thu Sep 27 14:45:12 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 14:45:12 +0200
    Subject: [Haiku-commits] r22330 -
    	haiku/trunk/src/add-ons/kernel/console/vga_text
    Message-ID: <200709271245.l8RCjCXb017562@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 14:45:11 +0200 (Thu, 27 Sep 2007)
    New Revision: 22330
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22330&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/console/vga_text/vga_text.c
    Log:
    * Don't use the private vm_map_physical_memory() but just
      map_physical_memory().
    * Minor cleanup.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/console/vga_text/vga_text.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/console/vga_text/vga_text.c	2007-09-27 12:21:33 UTC (rev 22329)
    +++ haiku/trunk/src/add-ons/kernel/console/vga_text/vga_text.c	2007-09-27 12:45:11 UTC (rev 22330)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      *
      * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
    @@ -11,7 +11,6 @@
     #include 
     #include 
     
    -#include 
     #include 
     
     #include 
    @@ -28,8 +27,8 @@
     #define TEXT_CURSOR_LO 0x0f
     #define TEXT_CURSOR_HI 0x0e
     
    -static uint16 *gOrigin;
    -static isa_module_info *isa;
    +static uint16 *sOrigin;
    +static isa_module_info *sISA;
     
     
     static int
    @@ -37,20 +36,18 @@
     {
     	addr_t i;
     
    -	if (get_module(B_ISA_MODULE_NAME, (module_info **)&isa) < 0) {
    +	if (get_module(B_ISA_MODULE_NAME, (module_info **)&sISA) < 0) {
     		dprintf("text module_init: no isa bus found..\n");
     		return -1;
     	}
     
    -	/* we always succeede, so init our stuff */
    -	dprintf("console/text: mapping vid mem\n");
    -	vm_map_physical_memory(vm_kernel_address_space_id(), "vid_mem", (void *)&gOrigin,
    -		B_ANY_KERNEL_ADDRESS, SCREEN_END - SCREEN_START,
    -		B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, SCREEN_START);
    -	dprintf("console/text: mapped vid mem to virtual address %p\n", gOrigin);
    +	map_physical_memory("video_mem", (void *)SCREEN_START, SCREEN_END - SCREEN_START,
    +		B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, (void *)&sOrigin);
    +	dprintf("console/text: mapped vid mem to virtual address %p\n", sOrigin);
     
     	/* pre-touch all of the memory so that we dont fault while deep inside the kernel and displaying something */
    -	for(i = (addr_t)gOrigin; i < (addr_t)gOrigin + (SCREEN_END - SCREEN_START); i += B_PAGE_SIZE) {
    +	for (i = (addr_t)sOrigin; i < (addr_t)sOrigin + (SCREEN_END - SCREEN_START);
    +			i += B_PAGE_SIZE) {
     		uint16 val = *(volatile uint16 *)i;
     		*(volatile uint16 *)i = val;
     	}
    @@ -87,10 +84,10 @@
     	else
     		pos = y * COLUMNS + x;
     
    -	isa->write_io_8(TEXT_INDEX, TEXT_CURSOR_LO);
    -	isa->write_io_8(TEXT_DATA, (char)pos);
    -	isa->write_io_8(TEXT_INDEX, TEXT_CURSOR_HI);
    -	isa->write_io_8(TEXT_DATA, (char)(pos >> 8));
    +	sISA->write_io_8(TEXT_INDEX, TEXT_CURSOR_LO);
    +	sISA->write_io_8(TEXT_DATA, (char)pos);
    +	sISA->write_io_8(TEXT_INDEX, TEXT_CURSOR_HI);
    +	sISA->write_io_8(TEXT_DATA, (char)(pos >> 8));
     }
     
     
    @@ -98,7 +95,7 @@
     put_glyph(int32 x, int32 y, uint8 glyph, uint8 attr)
     {
     	uint16 pair = ((uint16)attr << 8) | (uint16)glyph;
    -	uint16 *p = gOrigin+(y*COLUMNS)+x;
    +	uint16 *p = sOrigin + (y * COLUMNS) + x;
     	*p = pair;
     }
     
    @@ -110,7 +107,7 @@
     	int32 y_limit = y + height;
     
     	while (y < y_limit) {
    -		uint16 *p = gOrigin + (y * COLUMNS) + x;
    +		uint16 *p = sOrigin + (y * COLUMNS) + x;
     		uint16 *p_limit = p + width;
     		while (p < p_limit) *p++ = pair;
     		y++;
    @@ -123,7 +120,7 @@
     {
     	if ((srcx == 0) && (width == COLUMNS)) {
     		// whole lines
    -		memmove(gOrigin + (desty * COLUMNS), gOrigin + (srcy * COLUMNS), height * COLUMNS * 2);
    +		memmove(sOrigin + (desty * COLUMNS), sOrigin + (srcy * COLUMNS), height * COLUMNS * 2);
     	} else {
     		// FIXME
     	}
    @@ -133,7 +130,7 @@
     static void
     clear(uint8 attr)
     {
    -	uint16 *base = (uint16 *)gOrigin;
    +	uint16 *base = (uint16 *)sOrigin;
     	uint32 i;
     
     	for (i = 0; i < COLUMNS * LINES; i++)
    
    
    
    From axeld at mail.berlios.de  Thu Sep 27 15:01:19 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Thu, 27 Sep 2007 15:01:19 +0200
    Subject: [Haiku-commits] r22331 - in haiku/trunk: headers/private/kernel
    	src/system/kernel src/system/kernel/arch/x86 src/system/kernel/slab
    Message-ID: <200709271301.l8RD1J1k019314@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-27 15:01:18 +0200 (Thu, 27 Sep 2007)
    New Revision: 22331
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22331&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/vm.h
       haiku/trunk/headers/private/kernel/vm_types.h
       haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c
       haiku/trunk/src/system/kernel/elf.cpp
       haiku/trunk/src/system/kernel/slab/Slab.cpp
       haiku/trunk/src/system/kernel/thread.cpp
    Log:
    * Moved some definitions from vm_types.h that functions in vm.h need as
      arguments into vm.h.
    * This should fix the broken build from earlier - thanks Stefano for the note!
    * That also allowed to clean some other includes a bit.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm.h	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/headers/private/kernel/vm.h	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -23,6 +23,58 @@
     struct vnode;
     
     
    +// additional protection flags
    +// Note: the VM probably won't support all combinations - it will try
    +// its best, but create_area() will fail if it has to.
    +// Of course, the exact behaviour will be documented somewhere...
    +#define B_EXECUTE_AREA			0x04
    +#define B_STACK_AREA			0x08
    +	// "stack" protection is not available on most platforms - it's used
    +	// to only commit memory as needed, and have guard pages at the
    +	// bottom of the stack.
    +	// "execute" protection is currently ignored, but nevertheless, you
    +	// should use it if you require to execute code in that area.
    +
    +#define B_KERNEL_EXECUTE_AREA	0x40
    +#define B_KERNEL_STACK_AREA		0x80
    +
    +#define B_USER_PROTECTION \
    +	(B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA | B_STACK_AREA)
    +#define B_KERNEL_PROTECTION \
    +	(B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_KERNEL_EXECUTE_AREA \
    +	| B_KERNEL_STACK_AREA)
    +
    +#define B_OVERCOMMITTING_AREA	0x1000
    +	// ToDo: this is not really a protection flag, but since the "protection"
    +	//	field is the only flag field, we currently use it for this.
    +	//	A cleaner approach would be appreciated - maybe just an official generic
    +	//	flags region in the protection field.
    +
    +#define B_USER_AREA_FLAGS		(B_USER_PROTECTION)
    +#define B_KERNEL_AREA_FLAGS \
    +	(B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
    +
    +// flags for vm_get_physical_page()
    +enum {
    +	PHYSICAL_PAGE_NO_WAIT = 0,
    +	PHYSICAL_PAGE_CAN_WAIT,
    +};
    +
    +// mapping argument for several internal VM functions
    +enum {
    +	REGION_NO_PRIVATE_MAP = 0,
    +	REGION_PRIVATE_MAP
    +};
    +
    +enum {
    +	// ToDo: these are here only temporarily - it's a private
    +	//	addition to the BeOS create_area() lock flags
    +	B_ALREADY_WIRED	= 6,
    +};
    +
    +#define MEMORY_TYPE_SHIFT		28
    +
    +
     #ifdef __cplusplus
     extern "C" {
     #endif
    
    Modified: haiku/trunk/headers/private/kernel/vm_types.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/headers/private/kernel/vm_types.h	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -232,55 +232,4 @@
     	void (*release_ref)(struct vm_store *backing_store);
     } vm_store_ops;
     
    -// args for the create_area funcs
    -
    -enum {
    -	REGION_NO_PRIVATE_MAP = 0,
    -	REGION_PRIVATE_MAP
    -};
    -
    -enum {
    -	// ToDo: these are here only temporarily - it's a private
    -	//	addition to the BeOS create_area() lock flags
    -	B_ALREADY_WIRED	= 6,
    -};
    -
    -enum {
    -	PHYSICAL_PAGE_NO_WAIT = 0,
    -	PHYSICAL_PAGE_CAN_WAIT,
    -};
    -
    -#define MEMORY_TYPE_SHIFT		28
    -
    -// additional protection flags
    -// Note: the VM probably won't support all combinations - it will try
    -// its best, but create_area() will fail if it has to.
    -// Of course, the exact behaviour will be documented somewhere...
    -#define B_EXECUTE_AREA			0x04
    -#define B_STACK_AREA			0x08
    -	// "stack" protection is not available on most platforms - it's used
    -	// to only commit memory as needed, and have guard pages at the
    -	// bottom of the stack.
    -	// "execute" protection is currently ignored, but nevertheless, you
    -	// should use it if you require to execute code in that area.
    -
    -#define B_KERNEL_EXECUTE_AREA	0x40
    -#define B_KERNEL_STACK_AREA		0x80
    -
    -#define B_USER_PROTECTION \
    -	(B_READ_AREA | B_WRITE_AREA | B_EXECUTE_AREA | B_STACK_AREA)
    -#define B_KERNEL_PROTECTION \
    -	(B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_KERNEL_EXECUTE_AREA \
    -	| B_KERNEL_STACK_AREA)
    -
    -#define B_OVERCOMMITTING_AREA	0x1000
    -	// ToDo: this is not really a protection flag, but since the "protection"
    -	//	field is the only flag field, we currently use it for this.
    -	//	A cleaner approach would be appreciated - maybe just an official generic
    -	//	flags region in the protection field.
    -
    -#define B_USER_AREA_FLAGS		(B_USER_PROTECTION)
    -#define B_KERNEL_AREA_FLAGS \
    -	(B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
    -
     #endif	/* _KERNEL_VM_TYPES_H */
    
    Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c
    ===================================================================
    --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -16,7 +16,7 @@
     #include 
     #include 
     #include 
    -#include 
    +#include 
     
     #include 
     #include 
    
    Modified: haiku/trunk/src/system/kernel/elf.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/elf.cpp	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/src/system/kernel/elf.cpp	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -27,7 +27,6 @@
     #include 
     #include 
     #include 
    -#include 
     
     #include 
     #include 
    
    Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -17,12 +17,12 @@
     
     #include 
     
    +#include 
     #include 
     #include 
     #include 
     #include 
     #include 
    -#include 
     #include 
     
     
    
    Modified: haiku/trunk/src/system/kernel/thread.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/thread.cpp	2007-09-27 12:45:11 UTC (rev 22330)
    +++ haiku/trunk/src/system/kernel/thread.cpp	2007-09-27 13:01:18 UTC (rev 22331)
    @@ -26,7 +26,6 @@
     #include 
     #include 
     #include 
    -#include 
     
     #include 
     #include 
    
    
    
    From marcusoverhagen at mail.berlios.de  Thu Sep 27 15:33:47 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Thu, 27 Sep 2007 15:33:47 +0200
    Subject: [Haiku-commits] r22332 - haiku/trunk/src/system/runtime_loader
    Message-ID: <200709271333.l8RDXlG5021439@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-27 15:33:47 +0200 (Thu, 27 Sep 2007)
    New Revision: 22332
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22332&view=rev
    
    Modified:
       haiku/trunk/src/system/runtime_loader/elf.cpp
    Log:
    Fix broken build and the compiler warning "enumeral mismatch in conditional expression".
    
    
    Modified: haiku/trunk/src/system/runtime_loader/elf.cpp
    ===================================================================
    --- haiku/trunk/src/system/runtime_loader/elf.cpp	2007-09-27 13:01:18 UTC (rev 22331)
    +++ haiku/trunk/src/system/runtime_loader/elf.cpp	2007-09-27 13:33:47 UTC (rev 22332)
    @@ -9,6 +9,7 @@
     
     
     #include "runtime_loader_private.h"
    +#include "vm.h"
     
     #include 
     
    @@ -257,7 +258,10 @@
     	*_pheaderSize = eheader->e_phentsize * eheader->e_phnum;
     	*_sheaderSize = eheader->e_shentsize * eheader->e_shnum;
     
    -	return *_pheaderSize > 0 && *_sheaderSize > 0 ? B_OK : B_NOT_AN_EXECUTABLE;
    +	if (*_pheaderSize <= 0 || *_sheaderSize <= 0)
    +		return B_NOT_AN_EXECUTABLE;
    +
    +	return B_OK;
     }
     
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Thu Sep 27 15:50:48 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Thu, 27 Sep 2007 15:50:48 +0200
    Subject: [Haiku-commits] r22333 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709271350.l8RDomC4022565@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-27 15:50:48 +0200 (Thu, 27 Sep 2007)
    New Revision: 22333
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22333&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    Log:
    use defines from PCI.h
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-27 13:33:47 UTC (rev 22332)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-27 13:50:48 UTC (rev 22333)
    @@ -82,7 +82,7 @@
     
     	uint16 pcicmd = gPCI->read_pci_config(fPCIDevice, PCI_command, 2);
     	TRACE("pcicmd old 0x%04x\n", pcicmd);
    -	pcicmd = PCI_PCICMD_BME | PCI_PCICMD_MSE | (pcicmd & ~PCI_PCICMD_IOS);
    +	pcicmd = PCI_command_master | PCI_command_memory | (pcicmd & ~PCI_command_io);
     	TRACE("pcicmd new 0x%04x\n", pcicmd);
     	gPCI->write_pci_config(fPCIDevice, PCI_command, 2, pcicmd);
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-27 13:33:47 UTC (rev 22332)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-27 13:50:48 UTC (rev 22333)
    @@ -219,10 +219,6 @@
     #define HI32(val) (((uint64)(val)) >> 32)
     #define ASSERT(expr) if (expr) {} else panic(#expr)
     
    -#define PCI_PCICMD_IOS	0x01
    -#define PCI_PCICMD_MSE	0x02
    -#define PCI_PCICMD_BME	0x04
    -
     #define PCI_VENDOR_INTEL	0x8086
     #define PCI_VENDOR_JMICRON	0x197b
     #define PCI_JMICRON_CONTROLLER_CONTROL_1	0x40
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 00:44:22 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 00:44:22 +0200
    Subject: [Haiku-commits] r22334 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709272244.l8RMiM1R032708@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 00:44:21 +0200 (Fri, 28 Sep 2007)
    New Revision: 22334
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22334&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
       haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp
       haiku/trunk/src/kits/interface/layouter/SimpleLayouter.h
    Log:
    * Cleanup in ComplexLayouter and LayoutOptimizer: Removed debug output or
      made it conditional, added/modified comments documenting the maths and
      algorithms.
    * Refactored quite a bit in ComplexLayouter and added special handling for
      the case that the desired solution is already feasible.
    
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-27 13:50:48 UTC (rev 22333)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-27 22:44:21 UTC (rev 22334)
    @@ -20,6 +20,15 @@
     #include "SimpleLayouter.h"
     
     
    +//#define TRACE_COMPLEX_LAYOUTER	1
    +#if TRACE_COMPLEX_LAYOUTER
    +#	define TRACE(format...)	printf(format);
    +#	define TRACE_ONLY(x)	x
    +#else
    +#	define TRACE(format...)
    +#	define TRACE_ONLY(x)
    +#endif
    +
     using std::nothrow;
     
     
    @@ -41,6 +50,13 @@
     		delete[] fLocations;
     	}
     
    +	void InitFromSizes(int32* sizes)
    +	{
    +		fLocations[0] = 0;
    +		for (int32 i = 0; i < fCount; i++) 
    +			fLocations[i + 1] = fLocations[i] + sizes[i] + fSpacing;
    +	}
    +
     	virtual float ElementLocation(int32 element)
     	{
     		if (element < 0 || element >= fCount)
    @@ -106,6 +122,12 @@
     		effectiveMax = max;
     	}
     
    +	bool IsSatisfied(int32* sumValues) const
    +	{
    +		int32 value = sumValues[end] - sumValues[start - 1];
    +		return (value >= min && value <= max);
    +	}
    +
     	int32		start;
     	int32		end;
     	int32		min;
    @@ -143,9 +165,9 @@
     	  fSums(new(nothrow) SumItem[elementCount + 1]),
     	  fSumBackups(new(nothrow) SumItemBackup[elementCount + 1]),
     	  fOptimizer(new(nothrow) LayoutOptimizer(elementCount)),
    -	  fLayoutValid(false)
    +	  fLayoutValid(false),
    +	  fOptimizerConstraintsAdded(false)
     {
    -// TODO: Check initialization!
     	if (fConstraints)
     		memset(fConstraints, 0, sizeof(Constraint*) * fElementCount);
     
    @@ -195,8 +217,8 @@
     	if (element < 0 || length <= 0 || element + length > fElementCount)
     		return;
     
    -//printf("%p->ComplexLayouter::AddConstraints(%ld, %ld, %ld, %ld, %ld)\n",
    -//this, element, length, (int32)_min, (int32)_max, (int32)_preferred);
    +	TRACE("%p->ComplexLayouter::AddConstraints(%ld, %ld, %ld, %ld, %ld)\n",
    +		this, element, length, (int32)_min, (int32)_max, (int32)_preferred);
     
     	int32 spacing = fSpacing * (length - 1);
     	int32 min = (int32)_min + 1 - spacing;
    @@ -283,7 +305,8 @@
     void
     ComplexLayouter::Layout(LayoutInfo* _layoutInfo, float _size)
     {
    -//printf("%p->ComplexLayouter::Layout(%ld)\n", this, (int32)_size);
    +	TRACE("%p->ComplexLayouter::Layout(%ld)\n", this, (int32)_size);
    +
     	if (fElementCount == 0)
     		return;
     
    @@ -312,20 +335,130 @@
     	_PropagateChangesBack(sums, fElementCount - 1, NULL);
     	_PropagateChanges(sums, fElementCount - 1, NULL);
     
    -printf("Layout(%ld)\n", size);
    -for (int32 i = 0; i < fElementCount; i++) {
    -SumItem& sum = sums[i + 1];
    -printf("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    +#if TRACE_COMPLEX_LAYOUTER
    +	TRACE("Layout(%ld)\n", size);
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = sums[i + 1];
    +		TRACE("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    +	}
    +#endif
    +
    +	int32 sizes[fElementCount];
    +	if (!_Layout(size, sums, sizes)) {
    +	}
    +
    +	layoutInfo->InitFromSizes(sizes);
     }
     
    -// TODO: Test whether the desired solution already satisfies all constraints.
    -// If so, we can skip the constraint solving part.
     
    +// CloneLayouter
    +Layouter*
    +ComplexLayouter::CloneLayouter()
    +{
    +	ComplexLayouter* layouter
    +		= new(nothrow) ComplexLayouter(fElementCount, fSpacing);
    +	ObjectDeleter layouterDeleter(layouter);
    +	if (!layouter || layouter->InitCheck() != B_OK
    +		|| !layouter->fOptimizer->AddConstraintsFrom(fOptimizer)) {
    +		return NULL;
    +	}
     
    -// TODO: We should probably already setup the constraints in _ValidateLayout().
    -// This way we might not be able to skip as many redundant constraints, but
    -// supposedly it doesn't matter all that much, since those constraints
    -// wouldn't make it into the active set anyway.
    +	// clone the constraints
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		Constraint* constraint = fConstraints[i];
    +		Constraint** end = layouter->fConstraints + i;
    +		while (constraint) {
    +			*end = new(nothrow) Constraint(constraint->start, constraint->end,
    +				constraint->min, constraint->max);
    +			if (!*end)
    +				return NULL;
    +
    +			end = &(*end)->next;
    +			constraint = constraint->next;
    +		}
    +	}
    +
    +	// copy the other stuff
    +	memcpy(layouter->fWeights, fWeights, fElementCount * sizeof(float));
    +	memcpy(layouter->fSums, fSums, (fElementCount + 1) * sizeof(SumItem));
    +	memcpy(layouter->fSumBackups, fSumBackups,
    +		(fElementCount + 1) * sizeof(SumItemBackup));
    +	layouter->fMin = fMin;
    +	layouter->fMax = fMax;
    +	layouter->fLayoutValid = fLayoutValid;
    +
    +	return layouterDeleter.Detach();
    +}
    +
    +
    +// _Layout
    +bool
    +ComplexLayouter::_Layout(int32 size, SumItem* sums, int32* sizes)
    +{
    +	// prepare the desired solution
    +	SimpleLayouter::DistributeSize(size, fWeights, sizes, fElementCount);
    +	if (_SatisfiesConstraints(sizes)) {
    +		// The desired solution already satisfies all constraints.
    +		return true;
    +	}
    +
    +	double realSizes[fElementCount];
    +	for (int32 i = 0; i < fElementCount; i++)
    +		realSizes[i] = sizes[i];
    +
    +	if (!_AddOptimizerConstraints())
    +		return false;
    +
    +
    +	// prepare a feasible solution (the minimum)
    +	double values[fElementCount];
    +	for (int32 i = 0; i < fElementCount; i++)
    +		values[i] = sums[i + 1].min - sums[i].min;
    +
    +#if TRACE_COMPLEX_LAYOUTER
    +	TRACE("feasible solution vs. desired solution:\n");
    +	for (int32 i = 0; i < fElementCount; i++)
    +		TRACE("%8.4f   %8.4f\n", values[i], realSizes[i]);
    +#endif
    +
    +	// solve
    +	TRACE_ONLY(bigtime_t time = system_time();)
    +	if (!fOptimizer->Solve(realSizes, size, values))
    +		return false;
    +	TRACE_ONLY(time = system_time() - time;)
    +
    +	// compute integer solution
    +	// The basic strategy is to floor() the sums. This guarantees that the
    +	// difference between two rounded sums remains in the range of floor()
    +	// and ceil() of their real value difference. Since the constraints have
    +	// integer values, the integer solution will therefore satisfy all
    +	// constraints the real solution satisfied.
    +	TRACE("computed solution in %lld us:\n", time);
    +
    +	double realSum = 0;
    +	double previousSum = 0;
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		realSum += values[i];
    +		double roundedRealSum = floor(realSum);
    +		if (fuzzy_equals(realSum, roundedRealSum + 1))
    +			realSum = roundedRealSum + 1;
    +		sizes[i] = int32(roundedRealSum - previousSum);
    +		previousSum = roundedRealSum;
    +
    +		TRACE("x[%ld] = %8.4f   %4ld\n", i, values[i], sizes[i]);
    +	}
    +
    +	return _SatisfiesConstraints(sizes);
    +}
    +
    +
    +// _AddOptimizerConstraints
    +bool
    +ComplexLayouter::_AddOptimizerConstraints()
    +{
    +	if (fOptimizerConstraintsAdded)
    +		return true;
    +
     	fOptimizer->RemoveAllConstraints();
     
     	// add constraints
    @@ -363,94 +496,48 @@
     							-constraint->effectiveMax, false);
     					}
     				}
    +
    +				if (!success)
    +					return false;
     			}
     
     			constraint = constraint->next;
     		}
     	}
     
    -	// prepare a feasible solution (the minimum)
    -	double values[fElementCount];
    -	for (int32 i = 0; i < fElementCount; i++)
    -		values[i] = sums[i + 1].min - sums[i].min;
    +	fOptimizerConstraintsAdded = true;
    +	return true;
    +}
     
    -	// prepare the desired solution
    -	int32 sizes[fElementCount];
    -	SimpleLayouter::DistributeSize(size, fWeights, sizes, fElementCount);
    -	double realSizes[fElementCount];
    +
    +// _SatisfiesConstraints
    +bool
    +ComplexLayouter::_SatisfiesConstraints(int32* sizes) const
    +{
    +	int32 sumValues[fElementCount + 1];
    +	sumValues[0] = 0;
     	for (int32 i = 0; i < fElementCount; i++)
    -		realSizes[i] = sizes[i];
    +		sumValues[i + 1] = sumValues[i] + sizes[i];
     
    -printf("feasible solution vs. desired solution:\n");
    -for (int32 i = 0; i < fElementCount; i++)
    -printf("%8.4f   %8.4f\n", values[i], realSizes[i]);
    -
    -	// solve
    -bigtime_t time = system_time();
    -	if (!fOptimizer->Solve(realSizes, size, values))
    -		return;
    -time = system_time() - time;
    -
    -	// compute integer solution
    -	// The basic strategy is to floor() the sums. This guarantees that the
    -	// difference between two rounded sums remains in the range of floor()
    -	// and ceil() of their real value difference. Since the constraints have
    -	// integer values, the integer solution will satisfy all constraints the
    -	// real solution satisfied.
    -printf("computed solution in %lld us:\n", time);
    -	double realSum = 0;
    -	int32 spacing = 0;
    -	layoutInfo->fLocations[0] = 0;
    -	for (int32 i = 0; i < fElementCount; i++) {
    -		realSum += values[i];
    -		double roundedRealSum = floor(realSum);
    -		if (fuzzy_equals(realSum, roundedRealSum + 1))
    -			realSum = roundedRealSum + 1;
    -		layoutInfo->fLocations[i + 1] = (int32)roundedRealSum + spacing;
    -		spacing += fSpacing;
    -
    -printf("x[%ld] = %8.4f   %4ld\n", i, values[i], layoutInfo->fLocations[i + 1] - layoutInfo->fLocations[i]);
    -	}
    +	return _SatisfiesConstraintsSums(sumValues);
     }
     
     
    -// CloneLayouter
    -Layouter*
    -ComplexLayouter::CloneLayouter()
    +// _SatisfiesConstraintsSums
    +bool
    +ComplexLayouter::_SatisfiesConstraintsSums(int32* sumValues) const
     {
    -	ComplexLayouter* layouter
    -		= new(nothrow) ComplexLayouter(fElementCount, fSpacing);
    -	ObjectDeleter layouterDeleter(layouter);
    -	if (!layouter || layouter->InitCheck() != B_OK
    -		|| !layouter->fOptimizer->AddConstraintsFrom(fOptimizer)) {
    -		return NULL;
    -	}
    -
    -	// clone the constraints
     	for (int32 i = 0; i < fElementCount; i++) {
     		Constraint* constraint = fConstraints[i];
    -		Constraint** end = layouter->fConstraints + i;
     		while (constraint) {
    -			*end = new(nothrow) Constraint(constraint->start, constraint->end,
    -				constraint->min, constraint->max);
    -			if (!*end)
    -				return NULL;
    +			if (!constraint->IsSatisfied(sumValues))
    +				return false;
     
    -			end = &(*end)->next;
     			constraint = constraint->next;
     		}
     	}
     
    -	// copy the other stuff
    -	memcpy(layouter->fWeights, fWeights, fElementCount * sizeof(float));
    -	memcpy(layouter->fSums, fSums, (fElementCount + 1) * sizeof(SumItem));
    -	memcpy(layouter->fSumBackups, fSumBackups,
    -		(fElementCount + 1) * sizeof(SumItemBackup));
    -	layouter->fMin = fMin;
    -	layouter->fMax = fMax;
    -	layouter->fLayoutValid = fLayoutValid;
    -
    -	return layouterDeleter.Detach();
    +	return true;
     }
     
     
    @@ -458,6 +545,37 @@
     void
     ComplexLayouter::_ValidateLayout()
     {
    +	// The general idea for computing the min and max for the given constraints
    +	// is that we rewrite the problem a little. Instead of considering the
    +	// x_1, ... x_n (n = fElementCount) and the constraints of the form
    +	//   x_i + ... + x_{i+j} >= min[i,j] and
    +	//   x_i + ... + x_{i+j} >= max[i,j], with i >= 1, j >= 0, i + j <= n
    +	//   and min[i,j], max[i,j] >= 0
    +	// we define
    +	//   c[0] = 0
    +	//   c[i] = \sum_{k=1}^i x_k, for all i, 1 <= i <= n
    +	// and thus the constraints read:
    +	//   c[i+j] - c[i-1] >= min[i,j]
    +	//   c[i+j] - c[i-1] <= max[i,j]
    +	//
    +	// Let minc[i] and maxc[i] the limits imposed by the given constraints, i.e.
    +	//   minc[i] <= c[i] <= maxc[i] for any tuple of (c[i])_i satisfying the
    +	// constraints (minc[i] and maxc[i] are unique), then we gain:
    +	//   minc[i+j] >= c[i-1] + min[i,j]
    +	//   maxc[i+j] <= c[i-1] + min[i,j]
    +	//   minc[i-1] >= minc[i+j] - max[i,j]
    +	//   maxc[i-1] >= maxc[i+j] - min[i,j]
    +	// We can compute the minc[i] and maxc[i] in an iterative process,
    +	// propagating the first to kinds of constraints forward and the other two
    +	// backwards. First we start considering all min constraints only. They
    +	// can't contradict each other and are usually to be enforced over max
    +	// constraints. Afterwards we add the max constraints one by one. For each
    +	// one of them we propagate resulting changes back and forth. In case of
    +	// a conflict, we relax the max constraint as much as necessary to yield
    +	// a consistent set of constraints. After all constraints have been
    +	// incorporated, the resulting minc[n] and maxc[n] are the min and max
    +	// limits we wanted to compute.
    +
     	if (fLayoutValid)
     		return;
     
    @@ -473,26 +591,26 @@
     	}
     
     	// apply min constraints forward:
    -	//   minc[k] >= minc[i-1] + min[i,j]
    +	//   minc[i+j] >= minc[i-1] + min[i,j]
     	for (int32 i = 0; i < fElementCount; i++) {
     		SumItem& sum = fSums[i + 1];
     
     		Constraint* constraint = fConstraints[i];
     		while (constraint != NULL) {
     			int32 minSum = fSums[constraint->start].min + constraint->min;
    -			if (minSum > sum.min)
    +			if (minSum > sum.min) {
     				sum.min = minSum;
    -else {
    -printf("min constraint is redundant: x%ld + ... + x%ld >= %ld\n",
    -constraint->start, constraint->end, constraint->min);
    -}
    +			} else {
    +				TRACE("min constraint is redundant: x%ld + ... + x%ld >= %ld\n",
    +					constraint->start, constraint->end, constraint->min);
    +			}
     
     			constraint = constraint->next;
     		}
     	}
     
     	// apply min constraints backwards:
    -	//   maxc[i-1] <= maxc[k] - min[i,j]
    +	//   maxc[i-1] <= maxc[i+j] - min[i,j]
     	for (int32 i = fElementCount - 1; i >= 0; i--) {
     		SumItem& sum = fSums[i + 1];
     
    @@ -515,13 +633,14 @@
     
     			constraint = constraint->next;
     		}
    -//printf("fSums[%ld] = {%ld, %ld}\n", i + 1, sum.min, sum.max);
     	}
     
    -for (int32 i = 0; i < fElementCount; i++) {
    -SumItem& sum = fSums[i + 1];
    -printf("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    -}
    +#if TRACE_COMPLEX_LAYOUTER
    +	for (int32 i = 0; i < fElementCount; i++) {
    +		SumItem& sum = fSums[i + 1];
    +		TRACE("[%ld] minc = %4ld,  maxc = %4ld\n", i + 1, sum.min, sum.max);
    +	}
    +#endif
     
     	if (fElementCount == 0) {
     		fMin = -1;
    @@ -532,74 +651,11 @@
     		fMax = fSums[fElementCount].max + spacing - 1;
     	}
     
    +	fOptimizerConstraintsAdded = false;
     	fLayoutValid = true;
     }
     
    -/*
    -		x[i] + ... + x[i+j] >= min[i,j]
    -		x[i] + ... + x[i+j] <= max[i,j]
    -	with
    -		1 <= i <= n
    -		0 <= j <= n - i
    -		0 <= min[i,j] <= max[i,j]
     
    -	Let
    -
    -		c[0] = 0
    -		c[k] = x[1] + ... + x[k]	for 1 <= k <= n
    -
    -	it follows
    -
    -		x[i] + ... + x[i+j] = c[i+j] - c[i-1]
    -
    -	and thus the constraints can be rewritten as
    -
    -		c[i+j] - c[i-1] >= min[i,j]
    -		c[i+j] - c[i-1] <= max[i,j]
    -
    -	or	
    -
    -		c[i+j] >= c[i-1] + min[i,j]
    -		c[i+j] <= c[i-1] + max[i,j]
    -
    -	We're looking for minimal minc[] and maximal maxc[] such that
    -
    -		minc[i+j] >= minc[i-1] + min[i,j]
    -		maxc[i+j] <= maxc[i-1] + max[i,j]
    -
    -		minc[i+j] <= minc[i-1] + max[i,j]
    -		maxc[i+j] >= maxc[i-1] + min[i,j]
    -
    -	holds for all i and j. The latter two kinds of constraints have to be
    -	enforced backwards:
    -
    -		minc[i-1] >= minc[i+j] - max[i,j]
    -		maxc[i-1] <= maxc[i+j] - min[i,j]
    -
    -
    -
    ------------------
    -
    -	// (1) maxc[k] <= maxc[i-1] + max[i,j]
    -	// (2) minc[i-1] >= minc[k] - max[i,j]
    -
    -	Modifying maxc[k] according to (1) potentially invalidates constraints of
    -	these forms:
    -
    -		(i)  maxc[i'-1] <= maxc[k] - min[i',j']
    -		(ii) maxc[k+1+j'] <= maxc[k] + max[k+1,j']
    -
    -	After propagating (i) constraints backwards, all of them will be hold,
    -	though more (ii) constraints might have been invalidated, though.
    -	Propagating (ii) constraints forward afterwards, will make them all hold.
    -	Since the min[i,j] and max[i,j] constraints are separation constraints and
    -	the CSP not including the newly added constraint was conflict-free,
    -	propagating the (i) and (ii) constraints won't change the maxc[i], i < k by
    -	more than what maxc[k] changed. If afterwards the constraint (1) doesn't
    -	hold, it apparently conflicts with the other constraints.
    -*/
    -
    -
     // _ApplyMaxConstraint
     void
     ComplexLayouter::_ApplyMaxConstraint(Constraint* currentConstraint, int32 index)
    @@ -636,21 +692,19 @@
     		sumMax = base.max + max;
     	}
     
    -	// apply changes
    -
    -if (currentConstraint->effectiveMax != max) {
    -printf("relaxing conflicting max constraint (1): x%ld + ... + x%ld <= %ld -> %ld\n",
    -currentConstraint->start, currentConstraint->end,
    -currentConstraint->effectiveMax, max);
    -}
    +	if (currentConstraint->effectiveMax != max) {
    +		TRACE("relaxing conflicting max constraint (1): "
    +			"x%ld + ... + x%ld <= %ld -> %ld\n", currentConstraint->start,
    +			currentConstraint->end, currentConstraint->effectiveMax, max);
    +	}
     	currentConstraint->effectiveMax = max;
     
    -	if (baseMin <= base.min && sumMax >= sum.max)
    -{
    -printf("max constraint is redundant: x%ld + ... + x%ld <= %ld\n",
    -currentConstraint->start, currentConstraint->end, currentConstraint->effectiveMax);
    +	if (baseMin <= base.min && sumMax >= sum.max) {
    +		TRACE("max constraint is redundant: x%ld + ... + x%ld <= %ld\n",
    +			currentConstraint->start, currentConstraint->end,
    +			currentConstraint->effectiveMax);
     		return;
    -}
    +	}
     
     	// backup old values, in case we detect a conflict later
     	_BackupValues(index);
    @@ -700,9 +754,9 @@
     		// if we've got a conflict, we relax the constraint and try again
     		if (diff > 0) {
     			max += diff;
    -printf("relaxing conflicting max constraint (2): x%ld + ... + x%ld <= %ld -> %ld\n",
    -currentConstraint->start, currentConstraint->end,
    -currentConstraint->effectiveMax, max);
    +			TRACE("relaxing conflicting max constraint (2): "
    +				"x%ld + ... + x%ld <= %ld -> %ld\n", currentConstraint->start,
    +				currentConstraint->end, currentConstraint->effectiveMax, max);
     			currentConstraint->effectiveMax = max;
     
     			_RestoreValues(index);
    @@ -762,8 +816,9 @@
     
     		if (sum.minDirty || sum.maxDirty) {
     			if (sum.min > sum.max) {
    -// TODO: Can this actually happen?
    -printf("adjusted max in propagation phase: index: %ld: %ld -> %ld\n", i, sum.max, sum.min);
    +				// TODO: Can this actually happen?
    +				TRACE("adjusted max in propagation phase: index: "
    +					"%ld: %ld -> %ld\n", i, sum.max, sum.min);
     				sum.max = sum.min;
     				sum.maxDirty = true;
     			}
    @@ -793,10 +848,11 @@
     			if (sum.minDirty && !ignoreMaxConstraints) {
     				int32 baseMin = sum.min - constraint->effectiveMax;
     				if (baseMin > base.min) {
    -if (baseMin > base.max) {
    -printf("min above max in back propagation phase: index: (%ld -> %ld), "
    -"min: %ld, max: %ld\n", i, constraint->start, baseMin, base.max);
    -}
    +					if (baseMin > base.max) {
    +						TRACE("min above max in back propagation phase: index: "
    +							"(%ld -> %ld), min: %ld, max: %ld\n", i,
    +							constraint->start, baseMin, base.max);
    +					}
     					base.min = baseMin;
     					base.minDirty = true;
     				}
    @@ -806,10 +862,11 @@
     			if (sum.maxDirty) {
     				int32 baseMax = sum.max - constraint->min;
     				if (baseMax < base.max) {
    -if (baseMax < base.min) {
    -printf("max below min in back propagation phase: index: (%ld -> %ld), "
    -"max: %ld, min: %ld\n", i, constraint->start, baseMax, base.min);
    -}
    +					if (baseMax < base.min) {
    +						TRACE("max below min in back propagation phase: index: "
    +							"(%ld -> %ld), max: %ld, min: %ld\n", i,
    +							constraint->start, baseMax, base.min);
    +					}
     					base.max = baseMax;
     					base.maxDirty = true;
     				}
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-27 13:50:48 UTC (rev 22333)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-27 22:44:21 UTC (rev 22334)
    @@ -1,6 +1,8 @@
     /*
      * Copyright 2007, Ingo Weinhold .
      * All rights reserved. Distributed under the terms of the MIT License.
    + *
    + * Layouter implementation that can handle complex constraints.
      */
     #ifndef COMPLEX_LAYOUTER_H
     #define COMPLEX_LAYOUTER_H
    @@ -43,6 +45,11 @@
     			struct SumItem;
     			struct SumItemBackup;
     
    +			bool				_Layout(int32 size, SumItem* sums,
    +									int32* sizes);
    +			bool				_AddOptimizerConstraints();
    +			bool				_SatisfiesConstraints(int32* sizes) const;
    +			bool				_SatisfiesConstraintsSums(int32* sums) const;
     
     			void				_ValidateLayout();
     			void				_ApplyMaxConstraint(
    @@ -67,6 +74,7 @@
     			float				fMin;
     			float				fMax;
     			bool				fLayoutValid;
    +			bool				fOptimizerConstraintsAdded;
     };
     
     }	// namespace Layout
    
    Modified: haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp	2007-09-27 13:50:48 UTC (rev 22333)
    +++ haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.cpp	2007-09-27 22:44:21 UTC (rev 22334)
    @@ -13,9 +13,53 @@
     #include 
     
     
    +//#define TRACE_LAYOUT_OPTIMIZER	1
    +#if TRACE_LAYOUT_OPTIMIZER
    +#	define TRACE(format...)	printf(format)
    +#	define TRACE_ONLY(x)	x
    +#else
    +#	define TRACE(format...)
    +#	define TRACE_ONLY(x)
    +#endif
    +#define TRACE_ERROR(format...)	fprintf(stderr, format)
    +
     using std::nothrow;
     
     
    +/*!	\class BPrivate::Layout::LayoutOptimizer
    +
    +	Given a set of layout constraints, a feasible solution, and a desired
    +	(non-)solution this class finds an optimal solution. The optimization
    +	criterion is to minimize the norm of the difference to the desired
    +	(non-)solution.
    +
    +	It does so by implementing an active set method algorithm. The basic idea
    +	is to start with the subset of the constraints that are barely satisfied by
    +	the feasible solution, i.e. including all equality constraints and those
    +	inequality constraints that are still satisfied, if restricted to equality
    +	constraints. This set is called active set, the contained constraints active
    +	constraints.
    +
    +	Considering all of the active constraints equality constraints a new
    +	solution is computed, which still satisfies all those equality constraints
    +	and is optimal with respect to the optimization criterion.
    +
    +	If the new solution equals the previous one, we find the inequality
    +	constraint that, by keeping it in the active set, prevents us most from
    +	further optimizing the solution. If none really does, we're done, having
    +	found the globally optimal solution. Otherwise we remove the found
    +	constraint from the active set and try again.
    +
    +	If the new solution does not equal the previous one, it might violate one
    +	or more of the inactive constraints. If that is the case, we add the
    +	most-violated constraint to the active set and adjust the new solution such
    +	that barely satisfies that constraint. Otherwise, we don't adjust the
    +	computed solution. With the adjusted respectively unadjusted solution
    +	we enter the next iteration, i.e. by computing a new optimal solution with
    +	respect to the active set.
    +*/
    +
    +
     // #pragma mark - vector and matrix operations
     
     
    @@ -239,7 +283,7 @@
     		}
     
     		if (fuzzy_equals(pivotValue, 0)) {
    -			printf("solve(): matrix is not regular\n");
    +			TRACE_ERROR("solve(): matrix is not regular\n");
     			return false;
     		}
     
    @@ -378,7 +422,7 @@
     			innerProductU = innerProductU + a[i][j] * a[i][j];
     		double innerProduct = innerProductU + a[j][j] * a[j][j];
     		if (fuzzy_equals(innerProduct, 0)) {
    -			printf("qr_decomposition(): 0 column %d\n", j);
    +			TRACE_ERROR("qr_decomposition(): 0 column %d\n", j);
     			return false;
     		}
     
    @@ -469,7 +513,7 @@
     
     	void Print() const
     	{
    -		printf("c[%2ld] - c[%2ld] %2s %4d\n", right, left,
    +		TRACE("c[%2ld] - c[%2ld] %2s %4d\n", right, left,
     			(equality ? "=" : ">="), (int)value);
     	}
     
    @@ -642,65 +686,41 @@
     {
     	int32 constraintCount = fConstraints.CountItems();
     
    -//printf("constraints:\n");
    -//for (int32 i = 0; i < constraintCount; i++) {
    -//	printf(" %-2ld:  ", i);
    -//	((Constraint*)fConstraints.ItemAt(i))->Print();
    -//}
    +TRACE_ONLY(
    +	TRACE("constraints:\n");
    +	for (int32 i = 0; i < constraintCount; i++) {
    +		TRACE(" %-2ld:  ", i);
    +		((Constraint*)fConstraints.ItemAt(i))->Print();
    +	}
    +)
     
    -	// our QP is suppose to be in this form:
    +	// our QP is supposed to be in this form:
     	//   min_x 1/2x^TGx + x^Td
     	//   s.t. a_i^Tx = b_i,  i \in E
     	//        a_i^Tx >= b_i, i \in I
     
    -	// init G and d
    -	//
    -	// The optimal solution minimizes the square of the distance to the desired
    -	// solution:
    -	//   \sum_i=1^n (x_i - desired_i)^2
    -	// Since we consider the sums c_i = \sum_k=1^i x_k, no the x_i directly,
    -	// we get
    -	//   \sum_{i=1}^n (c_i - c_{i-1} - desired_i)^2
    -	// Expanding and ignoring the constant part, we get
    -	//   \sum_{i=1}^n(c_i^2 - 2c_{i-1}c_i + c_{i-1}^2
    -	//                + 2desired_i(c_{i-1} - c_i))
    -	// This results in a G of the form:
    -	//  2 -1  0     ...   0  0
    -	// -1  2 -1  0  ...   .  .
    -	//  0 -1  2           .  .
    -	//  .  0     .        .  .
    -	//  .           .     0  0
    -	//  .              . -1  0
    -	//  0    ...    0 -1  2 -1
    -	//  0    ...         -1  1
    -	// and d:
    -	//   d_i = 2(desired_{i+1} - desired_i)
    -	// where desired_{n+1} = 0
    -	//
    -	// Note, that it is 1/2x^TGx, which is why we would have to multiply the
    -	// G entries with 2. Instead we divide d by 2 though, which results in the
    -	// equivalent optimization problem.
    -	//
    +	// init our initial x
     	double x[fVariableCount];
     	x[0] = values[0];
     	for (int i = 1; i < fVariableCount; i++)
     		x[i] = values[i] + x[i - 1];
     
    +	// init d
    +	// Note that the values of d and of G result from rewriting the
    +	// ||x - desired|| we actually want to minimize.
     	double d[fVariableCount];
     	for (int i = 0; i < fVariableCount - 1; i++)
     		d[i] = desired[i + 1] - desired[i];
     	d[fVariableCount - 1] = -desired[fVariableCount - 1];
     
    -//printf("d:\n");
    -//Matrix(fVariableCount, 1, d).Print();
    -
     	// init active set
     	BList activeConstraints(constraintCount);
     
     	for (int32 i = 0; i < constraintCount; i++) {
     		Constraint* constraint = (Constraint*)fConstraints.ItemAt(i);
     		double actualValue = constraint->ActualValue(x);
    -//printf("constraint %ld: actual: %f  constraint: %f\n", i, actualValue, constraint->value);
    +		TRACE("constraint %ld: actual: %f  constraint: %f\n", i, actualValue,
    +			constraint->value);
     		if (fuzzy_equals(actualValue, constraint->value))
     			activeConstraints.AddItem(constraint);
     	}
    @@ -709,16 +729,16 @@
     	// solution. We compute a vector p that brings our x closer to the optimum.
     	// We do that by computing the QP resulting from our active constraint set,
     	// W^k. Afterward each iteration we adjust the active set.
    -//int iteration = 0;
    +TRACE_ONLY(int iteration = 0;)
     	while (true) {
    -//printf("\n[iteration %d]\n", iteration++);
    -//printf("x:\n");
    -//Matrix(fVariableCount, 1, x).Print();
    -//printf("active set:\n");
    -//for (int32 i = 0; i < activeConstraints.CountItems(); i++) {
    -//	printf("  ");
    -//	((Constraint*)activeConstraints.ItemAt(i))->Print();
    -//}
    +TRACE_ONLY(
    +		TRACE("\n[iteration %d]\n", iteration++);
    +		TRACE("active set:\n");
    +		for (int32 i = 0; i < activeConstraints.CountItems(); i++) {
    +			TRACE("  ");
    +			((Constraint*)activeConstraints.ItemAt(i))->Print();
    +		}
    +)
     
     		// solve the QP:
     		//   min_p 1/2p^TGp + g_k^Tp
    @@ -729,7 +749,7 @@
     
     		int32 activeCount = activeConstraints.CountItems();
     		if (activeCount == 0) {
    -			printf("Solve(): Error: No more active constraints!\n");
    +			TRACE_ERROR("Solve(): Error: No more active constraints!\n");
     			return false;
     		}
     
    @@ -761,9 +781,6 @@
     		if (!_SolveSubProblem(gxd, am, p))
     			return false;
     
    -//printf("p:\n");
    -//Matrix(fVariableCount, 1, p).Print();
    -
     		if (is_zero(p, fVariableCount)) {
     			// compute Lagrange multipliers lambda_i
     			// if lambda_i >= 0 for all i \in W^k \union inequality constraints,
    @@ -785,8 +802,8 @@
     			const int aan = am;
     			if (aam != aan) {
     				// This should not happen, since A has full row rank.
    -				printf("Solve(): Transposed A has less linear independent rows "
    -					"than it has columns!\n");
    +				TRACE_ERROR("Solve(): Transposed A has less linear independent "
    +					"rows than it has columns!\n");
     				return false;
     			}
     
    @@ -801,11 +818,9 @@
     			bool success = solve(aa, aam, lambda);
     			if (!success) {
     				// Impossible, since we've removed all linearly dependent rows.
    -				printf("Solve(): Failed to compute lambda!\n");
    +				TRACE_ERROR("Solve(): Failed to compute lambda!\n");
     				return false;
     			}
    -//printf("lambda:\n");
    -//Matrix(aam, 1, lambda).Print();
     
     			// find min lambda_i (only, if it's < 0, though)
     			double minLambda = 0;
    @@ -829,7 +844,6 @@
     			// if the min lambda is >= 0, we're done
     			if (minIndex < 0 || fuzzy_equals(minLambda, 0)) {
     				_SetResult(x, values);
    -//printf("all lambda_i >= 0\n");
     				return true;
     			}
     
    @@ -859,7 +873,7 @@
     					barrier = i;
     				}
     			}
    -//printf("alpha: %f, barrier: %d\n", alpha, barrier);
    +			TRACE("alpha: %f, barrier: %d\n", alpha, barrier);
     
     			if (alpha < 1)
     				activeConstraints.AddItem(fConstraints.ItemAt(barrier));
    @@ -868,64 +882,25 @@
     			add_vectors_scaled(x, p, alpha, fVariableCount);
     		}
     	}
    -
    -
    -/*
    -min_x 1/2x^TGx + x^Td
    -s.t. Ax = b
    -
    -x^* = x + p
    -c = Ax - b
    -g = d + Gx
    -
    --Gp - A^T lambda^* = g
    --Ap                = c
    -
    -p = Yp_Y + Zp_Z
    -
    -Y und Z aus QR-Faktorisierung von A^T
    -
    -(AY)p_Y = -c                   -> p_Y
    -Z^TGZp_Z = -(Z^TGYp_Y + Z^Tg)  -> p_Z
    ------------
    -
    -min_x x^TGx + x^Td
    -s.t. a_i^Tx =  b_i  i \in E
    -     a_i^Tx >= b_i  i \in I
    -
    -p_k berechnen durch Loesen von
    -
    -min_p 1/2p^TGp + g_k^Tp
    -s.t. a_i^Tp = 0, i \in W^k
    -
    -
    -
    -*/
     }
     
     
     bool
     LayoutOptimizer::_SolveSubProblem(const double* d, int am, double* p)
     {
    -	// x = p
    -	// d = g_k
    -	// b = 0
    +	// We have to solve the QP subproblem:
    +	//   min_p 1/2p^TGp + d^Tp
    +	//   s.t. a_i^Tp = 0
    +	//   with a_i \in activeConstraints
     	//
    -	// x^* = x + p
    -	// c = Ax - b
    -	// g = d + Gx
    -	//
    -	// with x = 0 we get
    -	// c = -b = 0
    -	// g = d = g_k
    -	//
    -	// p = Yp_Y + Zp_Z
    -	//
    -	// (AY)p_Y = -c = 0
    -	// => p_Y = 0
    -	//
    -	// (Z^TGZ)p_Z = -(Z^TYp_Y + Z^Tg) = -Z^Tg_k
    -	// -> we have to solve (Z^TGZ)p_Z = -Z^Tg_k
    +	// We use the null space method, i.e. we find matrices Y and Z, such that
    +	// AZ = 0 and [Y Z] is regular. Then with
    +	//   p = Yp_Y + Zp_z
    +	// we get
    +	//   p_Y = 0
    +	// and
    +	//  (Z^TGZ)p_Z = -(Z^TYp_Y + Z^Tg) = -Z^Td
    +	// which is a linear equation system, which we can solve.
     
     	const int an = fVariableCount;
     
    @@ -935,7 +910,7 @@
     	transpose_matrix(fActiveMatrix, fTemp1, am, an);
     	bool success = qr_decomposition(fTemp1, an, am, tempD, Q);
     	if (!success) {
    -		printf("Solve(): QR decomposition failed!\n");
    +		TRACE_ERROR("Solve(): QR decomposition failed!\n");
     		return false;
     	}
     
    @@ -946,7 +921,7 @@
     	for (int i = 0; i < zm; i++)
     		Z[i] = Q[i] + am;
     
    -	// solve (Z^TGZ)p_Z = -Z^Tg_k
    +	// solve (Z^TGZ)p_Z = -Z^Td
     
     	// Z^T
     	transpose_matrix(Z, fZtrans, zm, zn);
    @@ -961,7 +936,7 @@
     
     	success = solve(fTemp2, zn, pz);
     	if (!success) {
    -		printf("Solve(): Failed to solve() system for p_Z\n");
    +		TRACE_ERROR("Solve(): Failed to solve() system for p_Z\n");
     		return false;
     	}
     
    
    Modified: haiku/trunk/src/kits/interface/layouter/SimpleLayouter.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/SimpleLayouter.h	2007-09-27 13:50:48 UTC (rev 22333)
    +++ haiku/trunk/src/kits/interface/layouter/SimpleLayouter.h	2007-09-27 22:44:21 UTC (rev 22334)
    @@ -1,12 +1,16 @@
     /*
    - * Copyright 2006, Haiku Inc.
    - * Distributed under the terms of the MIT License.
    + * Copyright 2006-2007, Ingo Weinhold .
    + * All rights reserved. Distributed under the terms of the MIT License.
    + *
    + * Layouter implementation that can handle simple layout constraints
    + * (restricting one element) only. It is 
      */
     #ifndef	SIMPLE_LAYOUTER_H
    
    [... truncated: 9 lines follow ...]
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 00:48:22 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 00:48:22 +0200
    Subject: [Haiku-commits] r22335 - in haiku/trunk: build/jam src/kits
    	src/kits/interface src/kits/interface/layouter src/libs
    Message-ID: <200709272248.l8RMmMps003621@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 00:48:20 +0200 (Fri, 28 Sep 2007)
    New Revision: 22335
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22335&view=rev
    
    Removed:
       haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h
       haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp
       haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.h
       haiku/trunk/src/libs/qoca/
    Modified:
       haiku/trunk/build/jam/HaikuImage
       haiku/trunk/src/kits/Jamfile
       haiku/trunk/src/kits/interface/Jamfile
       haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp
       haiku/trunk/src/libs/Jamfile
    Log:
    * Removed the qoca library and the layouter implementation using it.
    * Use the new ComplexLayouter for the more complex layouting tasks.
    
    
    
    Modified: haiku/trunk/build/jam/HaikuImage
    ===================================================================
    --- haiku/trunk/build/jam/HaikuImage	2007-09-27 22:44:21 UTC (rev 22334)
    +++ haiku/trunk/build/jam/HaikuImage	2007-09-27 22:48:20 UTC (rev 22335)
    @@ -64,8 +64,6 @@
     	libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so
     	libdevice.so libgame.so libscreensaver.so libroot.so
     	$(X86_ONLY)libGL.so libfluidsynth.so
    -	# constraint solver lib
    -	lib$(LAYOUT_CONSTRAINT_SOLVER).so
     ;
     BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server
     	net_server media_addon_server input_server app_server fake_app_server
    
    Modified: haiku/trunk/src/kits/Jamfile
    ===================================================================
    --- haiku/trunk/src/kits/Jamfile	2007-09-27 22:44:21 UTC (rev 22334)
    +++ haiku/trunk/src/kits/Jamfile	2007-09-27 22:48:20 UTC (rev 22335)
    @@ -32,8 +32,6 @@
     	storage_kit.o
     	support_kit.o
     
    -	lib$(LAYOUT_CONSTRAINT_SOLVER).so
    -
     	libicon.a
     	libagg.a
     
    @@ -68,8 +66,6 @@
     	storage_kit.o
     	support_kit.o
     
    -	lib$(LAYOUT_CONSTRAINT_SOLVER).so
    -
     	libicon.a
     	libagg.a
     
    
    Modified: haiku/trunk/src/kits/interface/Jamfile
    ===================================================================
    --- haiku/trunk/src/kits/interface/Jamfile	2007-09-27 22:44:21 UTC (rev 22334)
    +++ haiku/trunk/src/kits/interface/Jamfile	2007-09-27 22:48:20 UTC (rev 22335)
    @@ -29,22 +29,6 @@
     UseLibraryHeaders icon ;
     
     
    -# constraint solver to use
    -local constraintSolverSources = ;
    -switch $(LAYOUT_CONSTRAINT_SOLVER) {
    -	case qoca :
    -	{
    -		DEFINES += USE_QOCA_CONSTRAINT_SOLVER ;
    -		constraintSolverSources = QocaConstraintSolverLayouter.cpp ;
    -		SubDirSysHdrs [ FDirName $(HAIKU_TOP) src libs ] ;
    -		SubDirHdrs [ FDirName $(HAIKU_TOP) src libs qoca ] ;
    -	}
    -	case * :
    -	{
    -	}
    -}
    -
    -
     SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
     SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
     
    @@ -138,9 +122,9 @@
     	WidthBuffer.cpp
     
     	# layouter
    +	ComplexLayouter.cpp
     	Layouter.cpp
    +	LayoutOptimizer.cpp
     	OneElementLayouter.cpp
     	SimpleLayouter.cpp
    -
    -	$(constraintSolverSources)
     ;
    
    Modified: haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp	2007-09-27 22:44:21 UTC (rev 22334)
    +++ haiku/trunk/src/kits/interface/TwoDimensionalLayout.cpp	2007-09-27 22:48:20 UTC (rev 22335)
    @@ -13,7 +13,7 @@
     #include 
     #include 
     
    -#include "ConstraintSolverLayouter.h"
    +#include "ComplexLayouter.h"
     #include "OneElementLayouter.h"
     #include "SimpleLayouter.h"
     
    @@ -581,7 +581,7 @@
     	if (elementCount <= 1)
     		fLayouter = new OneElementLayouter();
     	else if (_HasMultiElementItems())
    -		fLayouter = new ConstraintSolverLayouter(elementCount, _Spacing());
    +		fLayouter = new ComplexLayouter(elementCount, _Spacing());
     	else
     		fLayouter = new SimpleLayouter(elementCount, _Spacing());
     
    
    Deleted: haiku/trunk/src/kits/interface/layouter/ConstraintSolverLayouter.h
    
    Deleted: haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.cpp
    
    Deleted: haiku/trunk/src/kits/interface/layouter/QocaConstraintSolverLayouter.h
    
    Modified: haiku/trunk/src/libs/Jamfile
    ===================================================================
    --- haiku/trunk/src/libs/Jamfile	2007-09-27 22:44:21 UTC (rev 22334)
    +++ haiku/trunk/src/libs/Jamfile	2007-09-27 22:48:20 UTC (rev 22335)
    @@ -13,7 +13,6 @@
     SubInclude HAIKU_TOP src libs ncurses ;
     SubInclude HAIKU_TOP src libs pdflib ;
     SubInclude HAIKU_TOP src libs png ;
    -SubInclude HAIKU_TOP src libs qoca ;
     SubInclude HAIKU_TOP src libs stdc++ ;
     SubInclude HAIKU_TOP src libs termcap ;
     SubInclude HAIKU_TOP src libs usb ;
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 02:20:53 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 02:20:53 +0200
    Subject: [Haiku-commits] r22336 - haiku/trunk/src/kits/interface
    Message-ID: <200709280020.l8S0Krmn025103@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 02:20:51 +0200 (Fri, 28 Sep 2007)
    New Revision: 22336
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22336&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/GridLayout.cpp
    Log:
    The new row/column info items were not added, so that setting column or row
    properties (like the weight or min/max) would be ignored, besides memory
    being leaked.
    
    
    Modified: haiku/trunk/src/kits/interface/GridLayout.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/GridLayout.cpp	2007-09-27 22:48:20 UTC (rev 22335)
    +++ haiku/trunk/src/kits/interface/GridLayout.cpp	2007-09-28 00:20:51 UTC (rev 22336)
    @@ -123,6 +123,7 @@
     				info->weight = 1;
     				info->minSize = 0;
     				info->maxSize = B_SIZE_UNLIMITED;
    +				fInfos.AddItem(info);
     			}
     		}
     	
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 02:27:25 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 02:27:25 +0200
    Subject: [Haiku-commits] r22337 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709280027.l8S0RPnM026068@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 02:27:24 +0200 (Fri, 28 Sep 2007)
    New Revision: 22337
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22337&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    Log:
    They way we were initializing the maximal sizes, maximum constraints could
    be considered redundant, although they weren't. We do now use smaller
    "unlimited" sizes which we can add without risking overflow, and can thus
    correctly identify redundant constraints. This fixes the
    SplitterGridLayoutTest1 in the LayoutTest1 app.
    
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-28 00:20:51 UTC (rev 22336)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-28 00:27:24 UTC (rev 22337)
    @@ -165,6 +165,7 @@
     	  fSums(new(nothrow) SumItem[elementCount + 1]),
     	  fSumBackups(new(nothrow) SumItemBackup[elementCount + 1]),
     	  fOptimizer(new(nothrow) LayoutOptimizer(elementCount)),
    +	  fUnlimited(B_SIZE_UNLIMITED / (elementCount == 0 ? 1 : elementCount)),
     	  fLayoutValid(false),
     	  fOptimizerConstraintsAdded(false)
     {
    @@ -226,8 +227,8 @@
     
     	if (min < 0)
     		min = 0;
    -	if (max > B_SIZE_UNLIMITED)
    -		max = B_SIZE_UNLIMITED;
    +	if (max > fUnlimited)
    +		max = fUnlimited;
     
     	int32 end = element + length - 1;
     	Constraint** slot = fConstraints + end;
    @@ -582,10 +583,11 @@
     	fSums[0].min = 0;
     	fSums[0].max = 0;
     
    +	int32 maxSum = 0;
     	for (int32 i = 0; i < fElementCount; i++) {
     		SumItem& sum = fSums[i + 1];
     		sum.min = 0;
    -		sum.max = B_SIZE_UNLIMITED;
    +		sum.max = maxSum += fUnlimited;
     		sum.minDirty = false;
     		sum.maxDirty = false;
     	}
    @@ -649,6 +651,8 @@
     		int32 spacing = (fElementCount - 1) * fSpacing;
     		fMin = fSums[fElementCount].min + spacing - 1;
     		fMax = fSums[fElementCount].max + spacing - 1;
    +		if (fMax >= fUnlimited)
    +			fMax = B_SIZE_UNLIMITED;
     	}
     
     	fOptimizerConstraintsAdded = false;
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-28 00:20:51 UTC (rev 22336)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-28 00:27:24 UTC (rev 22337)
    @@ -73,6 +73,7 @@
     			LayoutOptimizer*	fOptimizer;
     			float				fMin;
     			float				fMax;
    +			int32				fUnlimited;
     			bool				fLayoutValid;
     			bool				fOptimizerConstraintsAdded;
     };
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:04:06 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:04:06 +0200
    Subject: [Haiku-commits] r22338 - in haiku/trunk/headers: os/drivers
    	private/drivers
    Message-ID: <200709281404.l8SE46kx013491@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:04:05 +0200 (Fri, 28 Sep 2007)
    New Revision: 22338
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22338&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/lendian_bitfield.h
    Removed:
       haiku/trunk/headers/os/drivers/lendian_bitfield.h
    Log:
    this header should be private
    
    
    Deleted: haiku/trunk/headers/os/drivers/lendian_bitfield.h
    
    Copied: haiku/trunk/headers/private/drivers/lendian_bitfield.h (from rev 22337, haiku/trunk/headers/os/drivers/lendian_bitfield.h)
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:05:56 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:05:56 +0200
    Subject: [Haiku-commits] r22339 - in haiku/trunk/headers:
    	os/drivers/bus/scsi private/drivers
    Message-ID: <200709281405.l8SE5uCM014719@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:05:55 +0200 (Fri, 28 Sep 2007)
    New Revision: 22339
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22339&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/scsi_cmds.h
    Removed:
       haiku/trunk/headers/os/drivers/bus/scsi/scsi_cmds.h
    Log:
    this header should be private
    
    
    Deleted: haiku/trunk/headers/os/drivers/bus/scsi/scsi_cmds.h
    
    Copied: haiku/trunk/headers/private/drivers/scsi_cmds.h (from rev 22338, haiku/trunk/headers/os/drivers/bus/scsi/scsi_cmds.h)
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:06:25 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:06:25 +0200
    Subject: [Haiku-commits] r22340 - in haiku/trunk/headers:
    	os/drivers/bus/scsi private/drivers
    Message-ID: <200709281406.l8SE6PDR015023@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:06:24 +0200 (Fri, 28 Sep 2007)
    New Revision: 22340
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22340&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/scsi_periph.h
    Removed:
       haiku/trunk/headers/os/drivers/bus/scsi/scsi_periph.h
    Log:
    this header should be private
    
    
    Deleted: haiku/trunk/headers/os/drivers/bus/scsi/scsi_periph.h
    
    Copied: haiku/trunk/headers/private/drivers/scsi_periph.h (from rev 22339, haiku/trunk/headers/os/drivers/bus/scsi/scsi_periph.h)
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:07:24 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:07:24 +0200
    Subject: [Haiku-commits] r22341 - in haiku/trunk/headers: os/drivers/bus/ide
    	private/drivers
    Message-ID: <200709281407.l8SE7OHc015414@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:07:23 +0200 (Fri, 28 Sep 2007)
    New Revision: 22341
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22341&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/ide_adapter.h
    Removed:
       haiku/trunk/headers/os/drivers/bus/ide/ide_adapter.h
    Log:
    this header should be private
    
    
    Deleted: haiku/trunk/headers/os/drivers/bus/ide/ide_adapter.h
    
    Copied: haiku/trunk/headers/private/drivers/ide_adapter.h (from rev 22340, haiku/trunk/headers/os/drivers/bus/ide/ide_adapter.h)
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:08:52 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:08:52 +0200
    Subject: [Haiku-commits] r22342 - in haiku/trunk/headers: os/drivers
    	private/drivers
    Message-ID: <200709281408.l8SE8qU6015562@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:08:52 +0200 (Fri, 28 Sep 2007)
    New Revision: 22342
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22342&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/fast_log.h
    Removed:
       haiku/trunk/headers/os/drivers/fast_log.h
    Log:
    this header should be private
    
    
    Deleted: haiku/trunk/headers/os/drivers/fast_log.h
    
    Copied: haiku/trunk/headers/private/drivers/fast_log.h (from rev 22341, haiku/trunk/headers/os/drivers/fast_log.h)
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 16:13:34 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 16:13:34 +0200
    Subject: [Haiku-commits] r22343 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709281413.l8SEDY0m015830@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 16:13:34 +0200 (Fri, 28 Sep 2007)
    New Revision: 22343
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22343&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
       haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    Log:
    * Renamed fLayoutValid to fMinMaxValid.
    * Clear fMinMaxValid when a new constraint is added. "Height for width"
      constraints are therefore no longer ignored.
    
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-28 14:08:52 UTC (rev 22342)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.cpp	2007-09-28 14:13:34 UTC (rev 22343)
    @@ -166,7 +166,7 @@
     	  fSumBackups(new(nothrow) SumItemBackup[elementCount + 1]),
     	  fOptimizer(new(nothrow) LayoutOptimizer(elementCount)),
     	  fUnlimited(B_SIZE_UNLIMITED / (elementCount == 0 ? 1 : elementCount)),
    -	  fLayoutValid(false),
    +	  fMinMaxValid(false),
     	  fOptimizerConstraintsAdded(false)
     {
     	if (fConstraints)
    @@ -247,6 +247,8 @@
     		constraint->next = *slot;
     		*slot = constraint;
     	}
    +
    +	fMinMaxValid = false;
     }
     
     
    @@ -386,7 +388,7 @@
     		(fElementCount + 1) * sizeof(SumItemBackup));
     	layouter->fMin = fMin;
     	layouter->fMax = fMax;
    -	layouter->fLayoutValid = fLayoutValid;
    +	layouter->fMinMaxValid = fMinMaxValid;
     
     	return layouterDeleter.Detach();
     }
    @@ -577,7 +579,7 @@
     	// incorporated, the resulting minc[n] and maxc[n] are the min and max
     	// limits we wanted to compute.
     
    -	if (fLayoutValid)
    +	if (fMinMaxValid)
     		return;
     
     	fSums[0].min = 0;
    @@ -656,7 +658,7 @@
     	}
     
     	fOptimizerConstraintsAdded = false;
    -	fLayoutValid = true;
    +	fMinMaxValid = true;
     }
     
     
    
    Modified: haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-28 14:08:52 UTC (rev 22342)
    +++ haiku/trunk/src/kits/interface/layouter/ComplexLayouter.h	2007-09-28 14:13:34 UTC (rev 22343)
    @@ -74,7 +74,7 @@
     			float				fMin;
     			float				fMax;
     			int32				fUnlimited;
    -			bool				fLayoutValid;
    +			bool				fMinMaxValid;
     			bool				fOptimizerConstraintsAdded;
     };
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:19:08 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:19:08 +0200
    Subject: [Haiku-commits] r22344 - haiku/trunk/headers/private/drivers
    Message-ID: <200709281419.l8SEJ8Uh016258@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:19:08 +0200 (Fri, 28 Sep 2007)
    New Revision: 22344
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22344&view=rev
    
    Added:
       haiku/trunk/headers/private/drivers/ide_types.h
    Log:
    splitting the file
    
    
    Copied: haiku/trunk/headers/private/drivers/ide_types.h (from rev 22343, haiku/trunk/headers/os/drivers/bus/IDE.h)
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:51:31 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:51:31 +0200
    Subject: [Haiku-commits] r22345 - haiku/trunk/src/kits/interface/layouter
    Message-ID: <200709281451.l8SEpVDJ018196@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:51:31 +0200 (Fri, 28 Sep 2007)
    New Revision: 22345
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22345&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.h
    Log:
    added missing include file (probably gcc4 only build fix)
    
    
    Modified: haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.h
    ===================================================================
    --- haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.h	2007-09-28 14:19:08 UTC (rev 22344)
    +++ haiku/trunk/src/kits/interface/layouter/LayoutOptimizer.h	2007-09-28 14:51:31 UTC (rev 22345)
    @@ -6,8 +6,8 @@
     #define LAYOUT_OPTIMIZER_H
     
     #include 
    +#include 
     
    -
     static const double kEqualsEpsilon = 0.000001;
     
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:52:12 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:52:12 +0200
    Subject: [Haiku-commits] r22346 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709281452.l8SEqCDP018277@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:52:11 +0200 (Fri, 28 Sep 2007)
    New Revision: 22346
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22346&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    cleanup
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 14:51:31 UTC (rev 22345)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 14:52:11 UTC (rev 22346)
    @@ -350,8 +350,13 @@
     
     	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
    -	if (request->cdb[0] == 18)
    -		IdentifyDevice();
    +	switch (request->cdb[0]) {
    +		case 0x00:
    +			break;
    +		case 0x12:
    +			IdentifyDevice();
    +			break;
    +	}
     
     	request->subsys_status = SCSI_DEV_NOT_THERE;
     	gSCSI->finished(request, 1);
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 16:53:43 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 16:53:43 +0200
    Subject: [Haiku-commits] r22347 - in haiku/trunk: headers/os/drivers/bus
    	headers/private/drivers src/add-ons/kernel/bus_managers/ide
    	src/add-ons/kernel/bus_managers/scsi
    	src/add-ons/kernel/busses/ide/generic_ide_pci
    	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/drivers/disk/scsi/scsi_cd
    	src/add-ons/kernel/drivers/disk/scsi/scsi_dsk
    	src/add-ons/kernel/file_systems/cdda
    	src/add-ons/kernel/generic/ide_adapter
    	src/add-ons/kernel/generic/scsi_periph src/bin/ideinfo
    Message-ID: <200709281453.l8SErhgH018361@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 16:53:42 +0200 (Fri, 28 Sep 2007)
    New Revision: 22347
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22347&view=rev
    
    Modified:
       haiku/trunk/headers/os/drivers/bus/IDE.h
       haiku/trunk/headers/private/drivers/ide_adapter.h
       haiku/trunk/headers/private/drivers/ide_types.h
       haiku/trunk/headers/private/drivers/scsi_periph.h
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/Jamfile
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/atapi.c
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/basic_protocol.c
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_internal.h
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.h
       haiku/trunk/src/add-ons/kernel/bus_managers/scsi/Jamfile
       haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_internal.h
       haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c
       haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c
       haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c
       haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c
       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_int.h
       haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/Jamfile
       haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/scsi_dsk_int.h
       haiku/trunk/src/add-ons/kernel/file_systems/cdda/Jamfile
       haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h
       haiku/trunk/src/add-ons/kernel/file_systems/cdda/cddb.h
       haiku/trunk/src/add-ons/kernel/generic/ide_adapter/Jamfile
       haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c
       haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile
       haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h
       haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.c
       haiku/trunk/src/bin/ideinfo/Jamfile
    Log:
    convert files to new include file locations
    
    
    Modified: haiku/trunk/headers/os/drivers/bus/IDE.h
    ===================================================================
    --- haiku/trunk/headers/os/drivers/bus/IDE.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/headers/os/drivers/bus/IDE.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -13,294 +13,11 @@
     #define __IDE_H__
     
     #include 
    -#include 
    -#include 
     #include 
     #include 
     
    -// IDE task file.
    -// contains the command block interpreted under different conditions with
    -// first byte being first command register, second byte second command register
    -// etc.; for lba48, registers must be written twice, therefore there
    -// are twice as many bytes as registers - the first eight bytes are those
    -// that must be written first, the second eight bytes are those that
    -// must be written second.
    -typedef union {
    -	struct {
    -		uint8	features;
    -		uint8	sector_count;
    -		uint8	sector_number;
    -		uint8	cylinder_0_7;
    -		uint8	cylinder_8_15;
    -		LBITFIELD8_3(
    -			head				: 4,
    -			device				: 1,
    -			mode				: 3
    -		);
    -		uint8	command;
    -	} chs;
    -	struct {
    -		uint8	features;
    -		uint8	sector_count;
    -		uint8	lba_0_7;
    -		uint8	lba_8_15;
    -		uint8	lba_16_23;
    -		LBITFIELD8_3(
    -			lba_24_27			: 4,
    -			device				: 1,
    -			mode				: 3
    -		);
    -		uint8	command;
    -	} lba;
    -	struct {
    -		LBITFIELD8_3(
    -			dma					: 1,
    -			ovl					: 1,
    -			_0_res2				: 6
    -		);
    -		LBITFIELD8_2(
    -			_1_res0				: 3,
    -			tag					: 5
    -		);
    -		uint8	_2_res;
    -		uint8	byte_count_0_7;
    -		uint8	byte_count_8_15;
    -		LBITFIELD8_6(
    -			lun					: 3,
    -			_5_res3				: 1,
    -			device				: 1,
    -			_5_one5				: 1,
    -			_5_res6				: 1,
    -			_5_one7				: 1
    -		);
    -		uint8	command;
    -	} packet;
    -	struct {
    -		LBITFIELD8_5(
    -			ili					: 1,
    -			eom					: 1,
    -			abrt				: 1,
    -			_0_res3				: 1,
    -			sense_key			: 4
    -		);
    -		LBITFIELD8_4(
    -			cmd_or_data			: 1,	// 1 - cmd, 0 - data
    -			input_or_output	 	: 1,	// 0 - input (to device), 1 - output
    -			release				: 1,
    -			tag					: 5
    -		);
    -		uint8	_2_res;
    -		uint8	byte_count_0_7;
    -		uint8	byte_count_8_15;
    -		LBITFIELD8_5(
    -			_4_res0				: 4,
    -			device				: 1,
    -			_4_obs5				: 1,
    -			_4_res6				: 1,
    -			_4_obs7				: 1
    -		);
    -		LBITFIELD8_7(
    -			chk					: 1,
    -			_7_res1 				: 2,
    -			drq					: 1,
    -			serv				: 1,
    -			dmrd				: 1,
    -			drdy				: 1,
    -			bsy					: 1
    -		);
    -	} packet_res;
    -	struct {
    -		uint8	sector_count;
    -		LBITFIELD8_4(					// only  is defined for write
    -			cmd_or_data			: 1,	// 1 - cmd, 0 - data
    -			input_or_output		: 1,	// 0 - input (to device), 1 - output
    -			release				: 1,
    -			tag					: 5
    -		);
    -		uint8	lba_0_7;
    -		uint8	lba_8_15;
    -		uint8	lba_16_23;
    -		LBITFIELD8_3(
    -			lba_24_27			: 4,
    -			device				: 1,
    -			mode				: 3
    -		);
    -		uint8	command;
    -	} queued;
    -	struct {
    -		// low order bytes
    -		uint8	features;
    -		uint8	sector_count_0_7;
    -		uint8	lba_0_7;
    -		uint8	lba_8_15;
    -		uint8	lba_16_23;
    -		LBITFIELD8_3(
    -			_5low_res0			: 4,
    -			device				: 1,
    -			mode				: 3
    -		);
    -		uint8	command;
     
    -		// high order bytes
    -		uint8	_0high_res;
    -		uint8	sector_count_8_15;
    -		uint8	lba_24_31;
    -		uint8	lba_32_39;
    -		uint8	lba_40_47;
    -	} lba48;
    -	struct {
    -		// low order bytes
    -		uint8	sector_count_0_7;
    -		LBITFIELD8_4(
    -			cmd_or_data			: 1,	// 1 - cmd, 0 - data
    -			input_or_output	 	: 1,	// 0 - input (to device), 1 - output
    -			release				: 1,
    -			tag					: 5
    -		);
    -		uint8	lba_0_7;
    -		uint8	lba_8_15;
    -		uint8	lba_16_23;
    -		LBITFIELD8_3(
    -			_5low_res0				: 4,
    -			device					: 1,
    -			mode					: 3
    -		);
    -		uint8	command;
     
    -		// high order bytes
    -		uint8	sector_count_8_15;
    -		uint8	_1high_res;
    -		uint8	lba_24_31;
    -		uint8	lba_32_39;
    -		uint8	lba_40_47;
    -	} queued48;
    -	struct {
    -		uint8	_0_res[3];
    -		uint8	ver;			// RMSN version
    -		LBITFIELD8_3(
    -			pena	: 1,		// previously enabled
    -			lock	: 1,		// capable of locking
    -			pej		: 1			// can physically eject
    -		);
    -	} set_MSN_res;
    -	struct {
    -		uint8	r[7+5];
    -	} raw;
    -	struct {
    -		uint8	features;
    -		uint8	sector_count;
    -		uint8	sector_number;
    -		uint8	cylinder_low;
    -		uint8	cylinder_high;
    -		uint8	device_head;
    -		uint8	command;
    -	} write;
    -	struct {
    -		uint8	error;
    -		uint8	sector_count;
    -		uint8	sector_number;
    -		uint8	cylinder_low;
    -		uint8	cylinder_high;
    -		uint8	device_head;
    -		uint8	status;
    -	} read;
    -} ide_task_file;
    -
    -// content of "mode" field
    -enum {
    -	ide_mode_chs = 5,
    -	ide_mode_lba = 7
    -};
    -
    -// mask for ide_task_file fields to be written
    -typedef enum {
    -	ide_mask_features	 		= 0x01,
    -	ide_mask_sector_count		= 0x02,
    -
    -	// CHS
    -	ide_mask_sector_number		= 0x04,
    -	ide_mask_cylinder_low		= 0x08,
    -	ide_mask_cylinder_high		= 0x10,
    -
    -	// LBA
    -	ide_mask_LBA_low			= 0x04,
    -	ide_mask_LBA_mid			= 0x08,
    -	ide_mask_LBA_high			= 0x10,
    -
    -	// packet
    -	ide_mask_byte_count			= 0x18,
    -	
    -	// packet and dma queued result
    -	ide_mask_error				= 0x01,
    -	ide_mask_ireason			= 0x02,
    -
    -	ide_mask_device_head		= 0x20,
    -	ide_mask_command			= 0x40,
    -	
    -	ide_mask_status				= 0x40,
    -
    -	// for 48 bits, the following flags tell which registers to load twice
    -	ide_mask_features_48		= 0x80 | ide_mask_features,
    -	ide_mask_sector_count_48	= 0x80 | ide_mask_sector_count,
    -	ide_mask_LBA_low_48			= 0x100 | ide_mask_LBA_low,
    -	ide_mask_LBA_mid_48			= 0x200 | ide_mask_LBA_mid,
    -	ide_mask_LBA_high_48		= 0x400 | ide_mask_LBA_high,
    -	
    -	ide_mask_HOB				= 0x780
    -
    -	//ide_mask_all			= 0x7f
    -} ide_reg_mask;
    -
    -// status register
    -enum {
    -	ide_status_err		= 0x01,		// error
    -	ide_status_index	= 0x02,		// obsolete
    -	ide_status_corr		= 0x04,		// obsolete
    -	ide_status_drq		= 0x08,		// data request
    -	ide_status_dsc		= 0x10,		// reserved
    -	ide_status_service	= 0x10,		// ready to service device
    -	ide_status_dwf		= 0x20,		// reserved
    -	ide_status_dma		= 0x20,		// reserved
    -	ide_status_dmrd		= 0x20,		// packet: DMA ready
    -	ide_status_df		= 0x20,		// packet: disk failure
    -	ide_status_drdy		= 0x40,		// device ready
    -	ide_status_bsy		= 0x80		// busy
    -} ide_status_mask;
    -
    -// device control register
    -enum {
    -									// bit 0 must be zero
    -	ide_devctrl_nien	= 0x02,		// disable INTRQ
    -	ide_devctrl_srst	= 0x04,		// software device reset
    -	ide_devctrl_bit3	= 0x08,		// don't know, but must be set
    -									// bits inbetween are reserved
    -	ide_devctrl_hob		= 0x80		// read high order byte (for 48-bit lba)
    -} ide_devcntrl_mask;
    -
    -// error register - most bits are command specific
    -enum {
    -	// always used
    -	ide_error_abrt		= 0x04,		// command aborted
    -
    -	// used for Ultra DMA modes
    -	ide_error_icrc		= 0x80,		// interface CRC error
    -
    -	// used by reading data transfers
    -	ide_error_unc		= 0x40,		// uncorrectable data error
    -	// used by writing data transfers
    -	ide_error_wp		= 0x40,		// media write protect
    -
    -	// used by all data transfer commands
    -	ide_error_mc		= 0x20,		// medium changed
    -	ide_error_idnf		= 0x10,		// CHS translation not init./ invalid CHS address
    -	ide_error_mcr		= 0x08,		// media change requested
    -	ide_error_nm		= 0x02,		// no media (for removable media devices)
    -} ide_error_mask;
    -
    -
    -typedef struct ide_channel_info *ide_channel_cookie;
    -
    -
     // Controller Driver Node
     
     // attributes:
    @@ -317,14 +34,17 @@
     // name of controller (string, required)
     #define IDE_CONTROLLER_CONTROLLER_NAME_ITEM "ide/controller_name"
     
    +union ide_task_file;
    +typedef unsigned int ide_reg_mask;
    +
     // interface of controller driver
     typedef struct {
     	driver_module_info info;
     
     	status_t (*write_command_block_regs)
    -		(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask);
    +		(void *channel_cookie, union ide_task_file *tf, ide_reg_mask mask);
     	status_t (*read_command_block_regs)
    -		(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask);
    +		(void *channel_cookie, union ide_task_file *tf, ide_reg_mask mask);
     
     	uint8 (*get_altstatus) (void *channel_cookie);
     	status_t (*write_device_control) (void *channel_cookie, uint8 val);	
    
    Modified: haiku/trunk/headers/private/drivers/ide_adapter.h
    ===================================================================
    --- haiku/trunk/headers/private/drivers/ide_adapter.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/headers/private/drivers/ide_adapter.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -19,6 +19,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     
     
    
    Modified: haiku/trunk/headers/private/drivers/ide_types.h
    ===================================================================
    --- haiku/trunk/headers/private/drivers/ide_types.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/headers/private/drivers/ide_types.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -9,14 +9,11 @@
     	IDE bus manager interface
     */
     
    -#ifndef __IDE_H__
    -#define __IDE_H__
    +#ifndef __IDE_TYPES_H__
    +#define __IDE_TYPES_H__
     
    -#include 
     #include 
     #include 
    -#include 
    -#include 
     
     // IDE task file.
     // contains the command block interpreted under different conditions with
    @@ -25,7 +22,7 @@
     // are twice as many bytes as registers - the first eight bytes are those
     // that must be written first, the second eight bytes are those that
     // must be written second.
    -typedef union {
    +union ide_task_file {
     	struct {
     		uint8	features;
     		uint8	sector_count;
    @@ -204,7 +201,8 @@
     		uint8	device_head;
     		uint8	status;
     	} read;
    -} ide_task_file;
    +};
    +typedef union ide_task_file ide_task_file;
     
     // content of "mode" field
     enum {
    @@ -213,7 +211,7 @@
     };
     
     // mask for ide_task_file fields to be written
    -typedef enum {
    +enum {
     	ide_mask_features	 		= 0x01,
     	ide_mask_sector_count		= 0x02,
     
    @@ -249,7 +247,7 @@
     	ide_mask_HOB				= 0x780
     
     	//ide_mask_all			= 0x7f
    -} ide_reg_mask;
    +}; // ide_reg_mask
     
     // status register
     enum {
    @@ -300,64 +298,4 @@
     
     typedef struct ide_channel_info *ide_channel_cookie;
     
    -
    -// Controller Driver Node
    -
    -// attributes:
    -
    -// node type
    -#define IDE_BUS_TYPE_NAME "bus/ide/v1"
    -// maximum number of devices connected to controller (uint8, optional, default:2)
    -#define IDE_CONTROLLER_MAX_DEVICES_ITEM "ide/max_devices"
    -// set to not-0 if DMA is supported (uint8, optional, default:0)
    -// (if so, publish necessary blkdev restriction too)
    -#define IDE_CONTROLLER_CAN_DMA_ITEM "ide/can_DMA"
    -// set to not-0 if CQ is supported (uint8, optional, default:1)
    -#define IDE_CONTROLLER_CAN_CQ_ITEM "ide/can_CQ"
    -// name of controller (string, required)
    -#define IDE_CONTROLLER_CONTROLLER_NAME_ITEM "ide/controller_name"
    -
    -// interface of controller driver
    -typedef struct {
    -	driver_module_info info;
    -
    -	status_t (*write_command_block_regs)
    -		(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask);
    -	status_t (*read_command_block_regs)
    -		(void *channel_cookie, ide_task_file *tf, ide_reg_mask mask);
    -
    -	uint8 (*get_altstatus) (void *channel_cookie);
    -	status_t (*write_device_control) (void *channel_cookie, uint8 val);	
    -
    -	status_t (*write_pio) (void *channel_cookie, uint16 *data, int count, bool force_16bit );
    -	status_t (*read_pio) (void *channel_cookie, uint16 *data, int count, bool force_16bit );
    -
    -	status_t (*prepare_dma)(void *channel_cookie, 
    -							const physical_entry *sg_list, size_t sg_list_count,
    -	                        bool write);
    -	status_t (*start_dma)(void *channel_cookie);
    -	status_t (*finish_dma)(void *channel_cookie);
    -} ide_controller_interface;
    -
    -
    -// channel cookie, issued by ide bus manager
    -typedef struct ide_bus_info *ide_channel;
    -
    -
    -// Interface for Controller Driver
    -
    -// interface of bus manager as seen from controller driver
    -// use this interface as the fixed consumer of your controller driver
    -typedef struct {
    -	driver_module_info info;
    -
    -	// status - status read from controller (_not_ alt_status, as reading
    -	//          normal status acknowledges IRQ request of device)
    -	status_t	(*irq_handler)( ide_channel channel, uint8 status );
    -} ide_for_controller_interface;
    -
    -
    -#define IDE_FOR_CONTROLLER_MODULE_NAME "bus_managers/ide/controller/v1"
    -
    -
     #endif	/* __IDE_H__ */
    
    Modified: haiku/trunk/headers/private/drivers/scsi_periph.h
    ===================================================================
    --- haiku/trunk/headers/private/drivers/scsi_periph.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/headers/private/drivers/scsi_periph.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -20,7 +20,7 @@
     
     #include 
     #include 
    -#include 
    +#include 
     #include 
     
     // cookie issued by module per device
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel bus_managers ide ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ;
     UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ;
     
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/atapi.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/atapi.c	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/atapi.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -13,7 +13,7 @@
     
     #include "ide_internal.h"
     
    -#include 
    +#include 
     
     #include "ide_cmds.h"
     #include "ide_sim.h"
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/basic_protocol.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/basic_protocol.c	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/basic_protocol.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -11,7 +11,7 @@
     
     
     #include "ide_internal.h"
    -#include 
    +#include 
     
     #include "ide_sim.h"
     #include "ide_cmds.h"
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_internal.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_internal.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_internal.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -15,6 +15,7 @@
     #include 
     #include 
     #include "ide_device_infoblock.h"
    +#include 
     #include 
     #include 
     
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -25,7 +25,7 @@
     #include "ide_internal.h"
     #include "ide_sim.h"
     
    -#include 
    +#include 
     #include 
     
     #include 
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/ide_sim.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -14,7 +14,7 @@
     #define __IDE_SIM_H__
     
     
    -#include "bus/scsi/scsi_cmds.h"
    +#include "scsi_cmds.h"
     
     extern scsi_for_sim_interface *scsi;
     extern scsi_sim_interface ide_sim_module;
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel bus_managers scsi ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ;
     UsePrivateHeaders [ FDirName kernel boot platform $(TARGET_BOOT_PLATFORM) ] ;
     
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_internal.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_internal.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/scsi_internal.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -9,7 +9,7 @@
     
     
     #include 
    -#include 
    +#include 
     #include 
     #include 
     #include 
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel busses ide generic_ide_pci ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon generic_ide_pci :
     	generic_ide_pci.c
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/generic_ide_pci/generic_ide_pci.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -13,7 +13,7 @@
     #include 
     #include 
     
    -#include 
    +#include 
     
     #define debug_level_flow 0
     #define debug_level_error 3
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel busses ide ide_isa ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     # disable debug output, if debugging is disabled
     if $(DEBUG) = 0 {
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -16,8 +16,9 @@
     #include 
     #include 
     
    +#include 
     #include 
    -#include 
    +#include 
     #include 
     #include 
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel busses ide legacy_sata ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon legacy_sata :
     	legacy_sata.c
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/legacy_sata/legacy_sata.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -8,7 +8,7 @@
     #include 
     #include 
     #include 
    -#include 
    +#include 
     #include 
     
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/promise_tx2/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel busses ide promise_tx2 ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon promise_tx2 :
     	promise_tx2.c
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel busses ide silicon_image_3112 ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon silicon_image_3112 :
     	silicon_image_3112.c
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/busses/ide/silicon_image_3112/silicon_image_3112.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -8,7 +8,7 @@
     #include 
     #include 
     #include 
    -#include 
    +#include 
     #include 
     
     #define TRACE(a...) dprintf("si-3112: " a)
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel drivers disk scsi scsi_cd ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon scsi_cd :
     	device.c
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd_int.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd_int.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_cd/scsi_cd_int.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -9,7 +9,7 @@
     
     #include 
     #include "scsi_cd.h"
    -#include 
    +#include 
     #include 
     
     #define debug_level_flow 0
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel drivers disk scsi scsi_dsk ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon scsi_dsk :
     	device.c
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/scsi_dsk_int.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/scsi_dsk_int.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/drivers/disk/scsi/scsi_dsk/scsi_dsk_int.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -11,7 +11,7 @@
     
     #include 
     #include "scsi_dsk.h"
    -#include 
    +#include 
     #include 
     
     #define debug_level_flow 0
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel file_systems cdda ;
     
    -UsePrivateHeaders [ FDirName kernel ] ;
    +UsePrivateHeaders drivers kernel ;
     UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
     UsePrivateHeaders [ FDirName storage ] ;
     
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/cdda.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -6,7 +6,7 @@
     #define CDDA_H
     
     
    -#include 
    +#include 
     
     
     static const uint32 kFramesPerSecond = 75;
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/cdda/cddb.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/cdda/cddb.h	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/cdda/cddb.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -6,7 +6,7 @@
     #define CDDB_H
     
     
    -#include 
    +#include 
     
     
     uint32 compute_cddb_disc_id(scsi_toc_toc &toc);
    
    Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/generic/ide_adapter/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel generic ide_adapter ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     KernelAddon ide_adapter :
     	ide_adapter.c
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -14,10 +14,11 @@
     #include 
     #include 
     
    +#include 
    +#include 
     #include 
    -#include 
    -#include 
    -#include 
    +#include 
    +#include 
     #include 
     #include 
     
    
    Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -1,6 +1,6 @@
     SubDir HAIKU_TOP src add-ons kernel generic scsi_periph ;
     
    -UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers kernel ;
     
     # disable debug output, if debugging is disabled
     if $(DEBUG) = 0 {
    
    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	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/scsi_periph_int.h	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -6,7 +6,7 @@
     #define __SCSI_PERIPH_INT_H__
     
     
    -#include 
    +#include 
     #include 
     #include 
     
    
    Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.c	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/sync.c	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -13,7 +13,7 @@
     
     #include "scsi_periph_int.h"
     
    -#include 
    +#include 
     
     #include 
     
    
    Modified: haiku/trunk/src/bin/ideinfo/Jamfile
    ===================================================================
    --- haiku/trunk/src/bin/ideinfo/Jamfile	2007-09-28 14:52:11 UTC (rev 22346)
    +++ haiku/trunk/src/bin/ideinfo/Jamfile	2007-09-28 14:53:42 UTC (rev 22347)
    @@ -2,7 +2,7 @@
     
     SubDirHdrs $(HAIKU_TOP) src add-ons kernel bus_managers ide ;
     
    -#UsePrivateHeaders kernel ;
    +UsePrivateHeaders drivers ;
     
     StdBinCommands
     	ideinfo.c
    
    
    
    From axeld at mail.berlios.de  Fri Sep 28 17:50:27 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Fri, 28 Sep 2007 17:50:27 +0200
    Subject: [Haiku-commits] r22348 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/vm
    Message-ID: <200709281550.l8SFoRMC022582@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-28 17:50:26 +0200 (Fri, 28 Sep 2007)
    New Revision: 22348
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22348&view=rev
    
    Added:
       haiku/trunk/src/system/kernel/vm/PageCacheLocker.h
    Modified:
       haiku/trunk/headers/private/kernel/vm.h
       haiku/trunk/headers/private/kernel/vm_page.h
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_daemons.cpp
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    bonefish+axeld:
    * We now have a page writer that takes some pages from the modified queue
      and writes it back every few seconds. It can be triggered by the page
      scanner to do that more often, though. That mechanism can be greatly
      improved once we have our I/O scheduler working.
    * Removed vm_page_write_modified_page() again - it was all "eaten up" by
      the page writer.
    * Reworked vm_page_write_modified_pages() a bit: it now uses
      vm_test_map_modification() and vm_clear_map_flags() instead of the
      iterating over all areas which wouldn't even work correctly.
      The code is much simpler now, too.
    * You usually put something to the tail of a queue, and remove the contents
      from the head, not vice versa - changed queue implementation to reflect this.
    * Additionally, there is now a enqueue_page_to_head() if you actually want the
      opposite.
    * vm_page_requeue() allows you to move a page in a queue to the head or tail.
    * Replaced vm_clear_map_activation() with vm_clear_map_flags() which allows
      you to clear other flags than PAGE_ACCESSED.
    * The page scanner dumps now some arguments with each run.
    * Removed the old disabled pageout_daemon() from NewOS.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm.h	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/headers/private/kernel/vm.h	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -89,7 +89,6 @@
     addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize,
     			size_t physicalSize, uint32 attributes);
     
    -
     void slab_init(struct kernel_args *args, addr_t initialBase,
     	size_t initialSize);
     void slab_init_post_sem();
    @@ -128,8 +127,9 @@
     			addr_t address);
     status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
     status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
    +bool vm_test_map_modification(struct vm_page *page);
     int32 vm_test_map_activation(struct vm_page *page, bool *_modified);
    -void vm_clear_map_activation(struct vm_page *page);
    +void vm_clear_map_flags(struct vm_page *page, uint32 flags);
     void vm_remove_all_page_mappings(struct vm_page *page);
     status_t vm_unmap_pages(struct vm_area *area, addr_t base, size_t length);
     status_t vm_map_page(struct vm_area *area, struct vm_page *page, addr_t address,
    
    Modified: haiku/trunk/headers/private/kernel/vm_page.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_page.h	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/headers/private/kernel/vm_page.h	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -27,14 +27,14 @@
     status_t vm_mark_page_inuse(addr_t page);
     status_t vm_mark_page_range_inuse(addr_t startPage, addr_t length);
     status_t vm_page_set_state(struct vm_page *page, int state);
    +void vm_page_requeue(struct vm_page *page, bool tail);
     
     // get some data about the number of pages in the system
     size_t vm_page_num_pages(void);
     size_t vm_page_num_free_pages(void);
     
    -status_t vm_page_write_modified_page(struct vm_cache *cache,
    -	struct vm_page *page, bool fsReenter);
     status_t vm_page_write_modified_pages(struct vm_cache *cache, bool fsReenter);
    +void vm_page_schedule_write_page(struct vm_page *page);
     
     void vm_page_unreserve_pages(uint32 count);
     void vm_page_reserve_pages(uint32 count);
    
    Added: haiku/trunk/src/system/kernel/vm/PageCacheLocker.h
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/PageCacheLocker.h	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/src/system/kernel/vm/PageCacheLocker.h	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -0,0 +1,30 @@
    +/*
    + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Distributed under the terms of the MIT License.
    + */
    +#ifndef PAGE_CACHE_LOCKER_H
    +#define PAGE_CACHE_LOCKER_H
    +
    +
    +#include 
    +
    +struct vm_page;
    +
    +
    +class PageCacheLocker {
    +public:
    +	PageCacheLocker(vm_page* page);
    +	~PageCacheLocker();
    +
    +	bool IsLocked() { return fPage != NULL; }
    +
    +	bool Lock(vm_page* page);
    +	void Unlock();
    +
    +private:
    +	bool _IgnorePage(vm_page* page);
    +
    +	vm_page*	fPage;
    +};
    +
    +#endif	// PAGE_CACHE_LOCKER_H
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -2354,6 +2354,32 @@
     }
     
     
    +bool
    +vm_test_map_modification(vm_page *page)
    +{
    +	MutexLocker locker(sMappingLock);
    +
    +	vm_page_mappings::Iterator iterator = page->mappings.GetIterator();
    +	vm_page_mapping *mapping;
    +	while ((mapping = iterator.Next()) != NULL) {
    +		vm_area *area = mapping->area;
    +		vm_translation_map *map = &area->address_space->translation_map;
    +
    +		addr_t physicalAddress;
    +		uint32 flags;
    +		map->ops->lock(map);
    +		addr_t address = area->base + (page->cache_offset << PAGE_SHIFT);
    +		map->ops->query_interrupt(map, address, &physicalAddress, &flags);
    +		map->ops->unlock(map);
    +
    +		if (flags & PAGE_MODIFIED)
    +			return true;
    +	}
    +
    +	return false;
    +}
    +
    +
     int32
     vm_test_map_activation(vm_page *page, bool *_modified)
     {
    @@ -2389,7 +2415,7 @@
     
     
     void
    -vm_clear_map_activation(vm_page *page)
    +vm_clear_map_flags(vm_page *page, uint32 flags)
     {
     	MutexLocker locker(sMappingLock);
     
    @@ -2401,7 +2427,7 @@
     
     		map->ops->lock(map);
     		addr_t address = area->base + (page->cache_offset << PAGE_SHIFT);
    -		map->ops->clear_flags(map, address, PAGE_ACCESSED);
    +		map->ops->clear_flags(map, address, flags);
     		map->ops->unlock(map);
     	}
     }
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_daemons.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_daemons.cpp	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/src/system/kernel/vm/vm_daemons.cpp	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -4,6 +4,8 @@
      */
     
     
    +#include "PageCacheLocker.h"
    +
     #include 
     
     #include 
    @@ -25,23 +27,6 @@
     static uint32 sNumPages;
     
     
    -class PageCacheLocker {
    -public:
    -	PageCacheLocker(vm_page* page);
    -	~PageCacheLocker();
    -
    -	bool IsLocked() { return fPage != NULL; }
    -
    -	bool Lock(vm_page* page);
    -	void Unlock();
    -
    -private:
    -	bool _IgnorePage(vm_page* page);
    -
    -	vm_page*	fPage;
    -};
    -
    -
     PageCacheLocker::PageCacheLocker(vm_page* page)
     	:
     	fPage(NULL)
    @@ -118,7 +103,7 @@
     		return;
     
     	if (page->state == PAGE_STATE_ACTIVE)
    -		vm_clear_map_activation(page);
    +		vm_clear_map_flags(page, PAGE_ACCESSED);
     }
     
     
    @@ -155,9 +140,9 @@
     
     	if (page->usage_count < 0) {
     		vm_remove_all_page_mappings(page);
    -		if (page->state == PAGE_STATE_MODIFIED) {
    -			// TODO: schedule to write back!
    -		} else
    +		if (page->state == PAGE_STATE_MODIFIED)
    +			vm_page_schedule_write_page(page);
    +		else
     			vm_page_set_state(page, PAGE_STATE_INACTIVE);
     		//dprintf("page %p -> move to inactive\n", page);
     	}
    @@ -193,6 +178,8 @@
     			* pagesLeft / sLowPagesCount;
     		uint32 leftToFree = 32 + (scanPagesCount - 32)
     			* pagesLeft / sLowPagesCount;
    +dprintf("wait interval %Ld, scan pages %lu, free %lu, target %lu\n",
    +	scanWaitInterval, scanPagesCount, pagesLeft, leftToFree);
     
     		for (uint32 i = 0; i < scanPagesCount && leftToFree > 0; i++) {
     			if (clearPage == 0)
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-28 14:53:42 UTC (rev 22347)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-28 15:50:26 UTC (rev 22348)
    @@ -27,7 +27,9 @@
     #include 
     #include 
     
    +#include "PageCacheLocker.h"
     
    +
     //#define TRACE_VM_PAGE
     #ifdef TRACE_VM_PAGE
     #	define TRACE(x) dprintf x
    @@ -59,23 +61,23 @@
     static ConditionVariable sFreePageCondition;
     static spinlock sPageLock;
     
    -static sem_id modified_pages_available;
    +static sem_id sWriterWaitSem;
     
     
    -/*!	Dequeues a page from the tail of the given queue */
    +/*!	Dequeues a page from the head of the given queue */
     static vm_page *
     dequeue_page(page_queue *queue)
     {
     	vm_page *page;
     
    -	page = queue->tail;
    +	page = queue->head;
     	if (page != NULL) {
    -		if (queue->head == page)
    -			queue->head = NULL;
    -		if (page->queue_prev != NULL)
    -			page->queue_prev->queue_next = NULL;
    +		if (queue->tail == page)
    +			queue->tail = NULL;
    +		if (page->queue_next != NULL)
    +			page->queue_next->queue_prev = NULL;
     
    -		queue->tail = page->queue_prev;
    +		queue->head = page->queue_next;
     		queue->count--;
     
     #ifdef DEBUG_PAGE_QUEUE
    @@ -92,7 +94,7 @@
     }
     
     
    -/*!	Enqueues a page to the head of the given queue */
    +/*!	Enqueues a page to the tail of the given queue */
     static void
     enqueue_page(page_queue *queue, vm_page *page)
     {
    @@ -103,6 +105,32 @@
     	}
     #endif	// DEBUG_PAGE_QUEUE
     
    +	if (queue->tail != NULL)
    +		queue->tail->queue_next = page;
    +	page->queue_prev = queue->tail;
    +	queue->tail = page;
    +	page->queue_next = NULL;
    +	if (queue->head == NULL)
    +		queue->head = page;
    +	queue->count++;
    +
    +#ifdef DEBUG_PAGE_QUEUE
    +	page->queue = queue;
    +#endif
    +}
    +
    +
    +/*!	Enqueues a page to the head of the given queue */
    +static void
    +enqueue_page_to_head(page_queue *queue, vm_page *page)
    +{
    +#ifdef DEBUG_PAGE_QUEUE
    +	if (page->queue != NULL) {
    +		panic("enqueue_page_to_head(queue: %p, page: %p): page thinks it is "
    +			"already in queue %p", queue, page, page->queue);
    +	}
    +#endif	// DEBUG_PAGE_QUEUE
    +
     	if (queue->head != NULL)
     		queue->head->queue_prev = page;
     	page->queue_next = queue->head;
    @@ -128,16 +156,16 @@
     	}
     #endif	// DEBUG_PAGE_QUEUE
     
    -	if (page->queue_prev != NULL)
    -		page->queue_prev->queue_next = page->queue_next;
    -	else
    -		queue->head = page->queue_next;
    -
     	if (page->queue_next != NULL)
     		page->queue_next->queue_prev = page->queue_prev;
     	else
     		queue->tail = page->queue_prev;
     
    +	if (page->queue_prev != NULL)
    +		page->queue_prev->queue_next = page->queue_next;
    +	else
    +		queue->head = page->queue_next;
    +
     	queue->count--;
     
     #ifdef DEBUG_PAGE_QUEUE
    @@ -610,85 +638,6 @@
     }
     
     
    -#if 0
    -static int pageout_daemon()
    -{
    -	int state;
    -	vm_page *page;
    -	vm_region *region;
    -	IOVECS(vecs, 1);
    -	ssize_t err;
    -
    -	dprintf("pageout daemon starting\n");
    -
    -	for (;;) {
    -		acquire_sem(modified_pages_available);
    -
    -		dprintf("here\n");
    -
    -		state = disable_interrupts();
    -		acquire_spinlock(&sPageLock);
    -		page = dequeue_page(&sModifiedPageQueue);
    -		page->state = PAGE_STATE_BUSY;
    -		vm_cache_acquire_ref(page->cache_ref, true);
    -		release_spinlock(&sPageLock);
    -		restore_interrupts(state);
    -
    -		dprintf("got page %p\n", page);
    -
    -		if (page->cache_ref->cache->temporary && !trimming_cycle) {
    -			// unless we're in the trimming cycle, dont write out pages
    -			// that back anonymous stores
    -			state = disable_interrupts();
    -			acquire_spinlock(&sPageLock);
    -			enqueue_page(&sModifiedPageQueue, page);
    -			page->state = PAGE_STATE_MODIFIED;
    -			release_spinlock(&sPageLock);
    -			restore_interrupts(state);
    -			vm_cache_release_ref(page->cache_ref);
    -			continue;
    -		}
    -
    -		/* clear the modified flag on this page in all it's mappings */
    -		mutex_lock(&page->cache_ref->lock);
    -		for (region = page->cache_ref->region_list; region; region = region->cache_next) {
    -			if (page->offset > region->cache_offset
    -			  && page->offset < region->cache_offset + region->size) {
    -				vm_translation_map *map = ®ion->aspace->translation_map;
    -				map->ops->lock(map);
    -				map->ops->clear_flags(map, page->offset - region->cache_offset + region->base, PAGE_MODIFIED);
    -				map->ops->unlock(map);
    -			}
    -		}
    -		mutex_unlock(&page->cache_ref->lock);
    -
    -		/* write the page out to it's backing store */
    -		vecs->num = 1;
    -		vecs->total_len = PAGE_SIZE;
    -		vm_get_physical_page(page->physical_page_number * PAGE_SIZE, (addr_t *)&vecs->vec[0].iov_base, PHYSICAL_PAGE_CAN_WAIT);
    -		vecs->vec[0].iov_len = PAGE_SIZE;
    -
    -		err = page->cache_ref->cache->store->ops->write(page->cache_ref->cache->store, page->offset, vecs);
    -
    -		vm_put_physical_page((addr_t)vecs->vec[0].iov_base);
    -
    -		state = disable_interrupts();
    -		acquire_spinlock(&sPageLock);
    -		if (page->ref_count > 0) {
    -			page->state = PAGE_STATE_ACTIVE;
    -		} else {
    -			page->state = PAGE_STATE_INACTIVE;
    -		}
    -		enqueue_page(&sActivePageQueue, page);
    -		release_spinlock(&sPageLock);
    -		restore_interrupts(state);
    -
    -		vm_cache_release_ref(page->cache_ref);
    -	}
    -}
    -#endif
    -
    -
     static status_t
     write_page(vm_page *page, bool fsReenter)
     {
    @@ -719,6 +668,97 @@
     }
     
     
    +status_t
    +page_writer(void* /*unused*/)
    +{
    +	while (true) {
    +		acquire_sem_etc(sWriterWaitSem, 1, B_RELATIVE_TIMEOUT, 3000000);
    +			// all 3 seconds when no one triggers us
    +
    +		const uint32 kNumPages = 32;
    +		ConditionVariable busyConditions[kNumPages];
    +		vm_page *pages[kNumPages];
    +		uint32 numPages = 0;
    +
    +		// TODO: once the I/O scheduler is there, we should write back
    +		// a lot more pages back.
    +		// TODO: make this laptop friendly, too (ie. only start doing
    +		// something if someone else did something or there is really
    +		// enough to do).
    +
    +		// collect pages to be written
    +
    +		while (numPages < kNumPages) {
    +			InterruptsSpinLocker locker(sPageLock);
    +
    +			vm_page *page = sModifiedPageQueue.head;
    +			while (page != NULL && page->state == PAGE_STATE_BUSY) {
    +				// skip busy pages
    +				page = page->queue_next;
    +			}
    +			if (page == NULL)
    +				break;
    +
    +			locker.Unlock();
    +
    +			PageCacheLocker cacheLocker(page);
    +			if (!cacheLocker.IsLocked())
    +				continue;
    +
    +			locker.Lock();
    +			remove_page_from_queue(&sModifiedPageQueue, page);
    +			page->state = PAGE_STATE_BUSY;
    +
    +			busyConditions[numPages].Publish(page, "page");
    +
    +			locker.Unlock();
    +
    +			//dprintf("write page %p\n", page);
    +			vm_clear_map_flags(page, PAGE_MODIFIED);
    +			vm_cache_acquire_ref(page->cache);
    +			pages[numPages++] = page;
    +		}
    +
    +		if (numPages == 0)
    +			continue;
    +
    +		// write pages to disk
    +
    +		// TODO: put this as requests into the I/O scheduler
    +		status_t writeStatus[kNumPages];
    +		for (uint32 i = 0; i < numPages; i++) {
    +			writeStatus[i] = write_page(pages[i], false);
    +		}
    +
    +		// mark pages depending on if they could be written or not
    +
    +		for (uint32 i = 0; i < numPages; i++) {
    +			vm_cache *cache = pages[i]->cache;
    +			mutex_lock(&cache->lock);
    +
    +			if (writeStatus[i] == B_OK) {
    +				// put it into the active queue
    +				InterruptsSpinLocker locker(sPageLock);
    +				move_page_to_active_or_inactive_queue(pages[i], true);
    +			} else {
    +				// We don't have to put the PAGE_MODIFIED bit back, as it's
    +				// still in the modified pages list.
    +				InterruptsSpinLocker locker(sPageLock);
    +				pages[i]->state = PAGE_STATE_MODIFIED;
    +				enqueue_page(&sModifiedPageQueue, pages[i]);
    +			}
    +
    +			busyConditions[i].Unpublish();
    +
    +			mutex_unlock(&cache->lock);
    +			vm_cache_release_ref(cache);
    +		}
    +	}
    +
    +	return B_OK;
    +}
    +
    +
     static void
     page_thief(void* /*unused*/, int32 level)
     {
    @@ -751,7 +791,7 @@
     		// find a candidate to steal from the inactive queue
     
     		for (int32 i = sActivePageQueue.count; i-- > 0;) {
    -			// move page to the head of the queue so that we don't
    +			// move page to the tail of the queue so that we don't
     			// scan it again directly
     			page = dequeue_page(&sActivePageQueue);
     			enqueue_page(&sActivePageQueue, page);
    @@ -800,96 +840,29 @@
     
     /*!
     	You need to hold the vm_cache lock when calling this function.
    -	And \a page must obviously be in that cache.
     	Note that the cache lock is released in this function.
     */
     status_t
    -vm_page_write_modified_page(vm_cache *cache, vm_page *page, bool fsReenter)
    -{
    -	ASSERT(page->state == PAGE_STATE_MODIFIED);
    -	ASSERT(page->cache == cache);
    -
    -	ConditionVariable busyCondition;
    -	InterruptsSpinLocker locker(&sPageLock);
    -
    -	remove_page_from_queue(&sModifiedPageQueue, page);
    -	page->state = PAGE_STATE_BUSY;
    -
    -	busyCondition.Publish(page, "page");
    -
    -	locker.Unlock();
    -
    -	off_t pageOffset = (off_t)page->cache_offset << PAGE_SHIFT;
    -
    -	for (vm_area *area = cache->areas; area; area = area->cache_next) {
    -		if (pageOffset >= area->cache_offset
    -			&& pageOffset < area->cache_offset + area->size) {
    -			vm_translation_map *map = &area->address_space->translation_map;
    -			// clear the modified flag
    -			map->ops->lock(map);
    -			map->ops->clear_flags(map, pageOffset - area->cache_offset
    -				+ area->base, PAGE_MODIFIED);
    -			map->ops->unlock(map);
    -		}
    -	}
    -
    -	mutex_unlock(&cache->lock);
    -
    -	status_t status = write_page(page, fsReenter);
    -
    -	mutex_lock(&cache->lock);
    -
    -	locker.Lock();
    -
    -	if (status == B_OK) {
    -		// put it into the active queue
    -		move_page_to_active_or_inactive_queue(page, true);
    -	} else {
    -		// We don't have to put the PAGE_MODIFIED bit back, as it's still
    -		// in the modified pages list.
    -		page->state = PAGE_STATE_MODIFIED;
    -		enqueue_page(&sModifiedPageQueue, page);
    -	}
    -
    -	busyCondition.Unpublish();
    -
    -	return status;
    -}
    -
    -
    -/*!
    -	You need to hold the vm_cache lock when calling this function.
    -	Note that the cache lock is released in this function.
    -*/
    -status_t
     vm_page_write_modified_pages(vm_cache *cache, bool fsReenter)
     {
    -	vm_page *page = cache->page_list;
    -
     	// ToDo: join adjacent pages into one vec list
     
    -	for (; page; page = page->cache_next) {
    -		bool gotPage = false;
    -		bool dequeuedPage = true;
    -		off_t pageOffset;
    -		status_t status;
    -		vm_area *area;
    -		ConditionVariable busyCondition;
    +	for (vm_page *page = cache->page_list; page; page = page->cache_next) {
    +		bool dequeuedPage = false;
     
    -		cpu_status state = disable_interrupts();
    -		acquire_spinlock(&sPageLock);
    -
     		if (page->state == PAGE_STATE_MODIFIED) {
    +			InterruptsSpinLocker locker(&sPageLock);
     			remove_page_from_queue(&sModifiedPageQueue, page);
    -			page->state = PAGE_STATE_BUSY;
    -			busyCondition.Publish(page, "page");
    -			gotPage = true;
    -		}
    +			dequeuedPage = true;
    +		} else if (!vm_test_map_modification(page))
    +			continue;
     
    -		release_spinlock(&sPageLock);
    -		restore_interrupts(state);
    +		page->state = PAGE_STATE_BUSY;
     
    -		// We may have a modified page - however, while we're writing it back,
    +		ConditionVariable busyCondition;
    +		busyCondition.Publish(page, "page");
    +
    +		// We have a modified page - however, while we're writing it back,
     		// the page is still mapped. In order not to lose any changes to the
     		// page, we mark it clean before actually writing it back; if writing
     		// the page fails for some reason, we just keep it in the modified page
    @@ -899,80 +872,54 @@
     		// had the chance to write it back, then we'll write it again later -
     		// that will probably not happen that often, though.
     
    -		pageOffset = (off_t)page->cache_offset << PAGE_SHIFT;
    +		// clear the modified flag
    +		vm_clear_map_flags(page, PAGE_MODIFIED);
     
    -		for (area = cache->areas; area; area = area->cache_next) {
    -			if (pageOffset >= area->cache_offset
    -				&& pageOffset < area->cache_offset + area->size) {
    -				vm_translation_map *map = &area->address_space->translation_map;
    -				map->ops->lock(map);
    -
    -				if (!gotPage) {
    -					// Check if the PAGE_MODIFIED bit hasn't been propagated yet
    -					addr_t physicalAddress;
    -					uint32 flags;
    -					map->ops->query(map, pageOffset - area->cache_offset + area->base,
    -						&physicalAddress, &flags);
    -					if (flags & PAGE_MODIFIED) {
    -						page->state = PAGE_STATE_BUSY;
    -						busyCondition.Publish(page, "page");
    -						gotPage = true;
    -						dequeuedPage = false;
    -					}
    -				}
    -				if (gotPage) {
    -					// clear the modified flag
    -					map->ops->clear_flags(map, pageOffset - area->cache_offset
    -						+ area->base, PAGE_MODIFIED);
    -				}
    -				map->ops->unlock(map);
    -			}
    -		}
    -
    -		if (!gotPage)
    -			continue;
    -
     		mutex_unlock(&cache->lock);
     
    -		status = write_page(page, fsReenter);
    +		status_t status = write_page(page, fsReenter);
     
     		mutex_lock(&cache->lock);
     
    +		InterruptsSpinLocker locker(&sPageLock);
    +
     		if (status == B_OK) {
     			// put it into the active/inactive queue
    -
    -			state = disable_interrupts();
    -			acquire_spinlock(&sPageLock);
    -
     			move_page_to_active_or_inactive_queue(page, dequeuedPage);
    -			busyCondition.Unpublish();
    -
    -			release_spinlock(&sPageLock);
    -			restore_interrupts(state);
     		} else {
     			// We don't have to put the PAGE_MODIFIED bit back, as it's still
     			// in the modified pages list.
    -			state = disable_interrupts();
    -			acquire_spinlock(&sPageLock);
    -
     			if (dequeuedPage) {
     				page->state = PAGE_STATE_MODIFIED;
     				enqueue_page(&sModifiedPageQueue, page);
     			} else
     				set_page_state_nolock(page, PAGE_STATE_MODIFIED);
    -
    -			busyCondition.Unpublish();
    -
    -			release_spinlock(&sPageLock);
    -			restore_interrupts(state);
     		}
    +
    +		busyCondition.Unpublish();
     	}
     
     	return B_OK;
     }
     
     
    +/*!	Schedules the page writer to write back the specified \a page.
    +	Note, however, that it doesn't do this immediately, and it might
    +	take several seconds until the page is actually written out.
    +*/
     void
    +vm_page_schedule_write_page(vm_page *page)
    +{
    +	ASSERT(page->state == PAGE_STATE_MODIFIED);
    +
    +	vm_page_requeue(page, false);
    +
    +	release_sem_etc(sWriterWaitSem, 1,
    +		B_RELEASE_IF_WAITING_ONLY | B_DO_NOT_RESCHEDULE);
    +}
    +
    +
    +void
     vm_page_init_num_pages(kernel_args *args)
     {
     	uint32 i;
    @@ -1086,17 +1033,17 @@
     	thread = spawn_kernel_thread(&page_scrubber, "page scrubber", B_LOWEST_ACTIVE_PRIORITY, NULL);
     	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
     
    -	modified_pages_available = create_sem(0, "modified_pages_avail_sem");
    -#if 0
    -	// create a kernel thread to schedule modified pages to write
    -	tid = thread_create_kernel_thread("pageout daemon", &pageout_daemon, B_FIRST_REAL_TIME_PRIORITY + 1);
    -	thread_resume_thread(tid);
    -#endif
    -
     	new (&sFreePageCondition) ConditionVariable;
     	sFreePageCondition.Publish(&sFreePageQueue, "free page");
     
     	register_low_memory_handler(page_thief, NULL, 0);
    +
    +	sWriterWaitSem = create_sem(0, "page writer");
    +
    +	thread = spawn_kernel_thread(&page_writer, "page writer",
    +		B_LOW_PRIORITY, NULL);
    +	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
    +
     	return B_OK;
     }
     
    @@ -1374,15 +1321,47 @@
     status_t
     vm_page_set_state(vm_page *page, int pageState)
     {
    -	cpu_status state = disable_interrupts();
    -	acquire_spinlock(&sPageLock);
    +	InterruptsSpinLocker _(sPageLock);
     
    -	status_t status = set_page_state_nolock(page, pageState);
    +	return set_page_state_nolock(page, pageState);
    +}
     
    -	release_spinlock(&sPageLock);
    -	restore_interrupts(state);
     
    -	return status;
    +void
    +vm_page_requeue(struct vm_page *page, bool tail)
    +{
    +	InterruptsSpinLocker _(sPageLock);
    +	page_queue *queue = NULL;
    +
    +	switch (page->state) {
    +		case PAGE_STATE_BUSY:
    +		case PAGE_STATE_ACTIVE:
    +		case PAGE_STATE_INACTIVE:
    +		case PAGE_STATE_WIRED:
    +		case PAGE_STATE_UNUSED:
    +			queue = &sActivePageQueue;
    +			break;
    +		case PAGE_STATE_MODIFIED:
    +			queue = &sModifiedPageQueue;
    +			break;
    +		case PAGE_STATE_FREE:
    +			queue = &sFreePageQueue;
    +			break;
    +		case PAGE_STATE_CLEAR:
    +			queue = &sClearPageQueue;
    +			break;
    +		default:
    +			panic("vm_page_touch: vm_page %p in invalid state %d\n",
    +				page, page->state);
    +			break;
    +	}
    +
    +	remove_page_from_queue(queue, page);
    +
    +	if (tail)
    +		enqueue_page(queue, page);
    +	else
    +		enqueue_page_to_head(queue, page);
     }
     
     
    
    
    
    From axeld at pinc-software.de  Fri Sep 28 18:02:33 2007
    From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=)
    Date: Fri, 28 Sep 2007 18:02:33 +0200 CEST
    Subject: [Haiku-commits]
     =?iso-8859-15?q?r22347_-_in_haiku/trunk=3A_header?=
     =?iso-8859-15?q?s/os/drivers/bus_headers/private/drivers__src/add-ons/ker?=
     =?iso-8859-15?q?nel/bus=5Fmanagers/ide_src/add-ons/kernel/bus=5Fmanagers/?=
     =?iso-8859-15?q?scsi_src/add-ons/kernel/busses/ide/generic=5Fide=5Fpci_sr?=
     =?iso-8859-15?q?c/add-ons/kernel/busses/ide/ide=5Fisa_src/add-ons/kernel/?=
     =?iso-8859-15?q?busses/ide/legacy=5Fsata_src/add-ons/kernel/busses/ide/pr?=
     =?iso-8859-15?q?omise=5Ftx2_src/add-ons/kernel/busses/ide/silicon=5Fimage?=
     =?iso-8859-15?q?=5F3112_src/add-ons/kernel/drivers/disk/scsi/scsi=5Fcd_sr?=
     =?iso-8859-15?q?c/add-ons/kernel/drivers/disk/scsi/scsi=5Fdsk_src/add-ons?=
     =?iso-8859-15?q?/kernel/file=5Fsystems/cdda_src/add-ons/kernel/generic/id?=
     =?iso-8859-15?q?e=5Fadapter_src/add-ons/kernel/generic/scsi=5Fperiph_src/?=
     =?iso-8859-15?q?bin/ideinfo?=
    In-Reply-To: <200709281453.l8SErhgH018361@sheep.berlios.de>
    Message-ID: <26512298527-BeMail@zon>
    
    marcusoverhagen at BerliOS  wrote:
    > Log:
    > convert files to new include file locations
    
    While I welcome the other changes, what's the reason to remove the 
    scsi_cmds.h header? It only defines bus specific structures and 
    constants.
    With the same logic one could remove almost all PCI/USB headers. Since 
    bus related definitions are likely to be used by many (and also 3rd 
    party) drivers, I think it would make sense to keep them as part of the 
    public OS headers.
    
    Bye,
       Axel.
    
    
    
    From marcusoverhagen at arcor.de  Fri Sep 28 18:47:58 2007
    From: marcusoverhagen at arcor.de (Marcus Overhagen)
    Date: Fri, 28 Sep 2007 18:47:58 +0200 (CEST)
    Subject: [Haiku-commits] (no subject)
    Message-ID: <22932450.1190998078615.JavaMail.ngmail@webmail18>
    
    Hi Axel,
    
    I think it's better to not add public (stable) headers, unless they
    are cleaned up and reviewed by multiple people.
    
    I was looking for the scsi command codes, and noticed that the
    scsi_cmds.h header didn't look as clean as I hoped for.
    
    Especially, it's style didn't matched the PCI or USB headers.
    
    Thats why I moved it to the private headers. I think we should strive
    for conistency in the public headers, and thus keep most new headers
    in the private folders.
    
    regards
    Marcus
    
    ----- Original Nachricht ----
    Von:     Axel D?rfler  
    An:      SVN commits to the Haiku source
    	repository 
    Datum:   28.09.2007 18:02
    Betreff: Re: [Haiku-commits]
     r22347 - in haiku/trunk: headers/os/drivers/bus headers/private/drivers  src/add-ons/kernel/bus_managers/ide src/add-ons/kernel/bus_managers/scsi src/add-ons/kernel/busses/ide/generic_ide_pci 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/drivers/disk/scsi/scsi_cd src/add-ons/kernel/drivers/disk/scsi/scsi_dsk src/add-ons/kernel/file_systems/cdda src/add-ons/kernel/generic/ide_adapter src/add-ons/kernel/generic/scsi_periph src/bin/ideinfo
    
    > marcusoverhagen at BerliOS  wrote:
    > > Log:
    > > convert files to new include file locations
    > 
    > While I welcome the other changes, what's the reason to remove the 
    > scsi_cmds.h header? It only defines bus specific structures and 
    > constants.
    > With the same logic one could remove almost all PCI/USB headers. Since 
    > bus related definitions are likely to be used by many (and also 3rd 
    > party) drivers, I think it would make sense to keep them as part of the 
    > public OS headers.
    > 
    > Bye,
    >    Axel.
    > 
    > _______________________________________________
    > Haiku-commits mailing list
    > Haiku-commits at lists.berlios.de
    > https://lists.berlios.de/mailman/listinfo/haiku-commits
    > 
    
    Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
    ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT F?R ALLE NEUEINSTEIGER
    Jetzt bei Arcor: g?nstig und schnell mit DSL - das All-Inclusive-Paket
    f?r clevere Doppel-Sparer, nur  34,95 ?  inkl. DSL- und ISDN-Grundgeb?hr!
    http://www.arcor.de/rd/emf-dsl-2
    
    
    From axeld at pinc-software.de  Fri Sep 28 20:34:27 2007
    From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=)
    Date: Fri, 28 Sep 2007 20:34:27 +0200 CEST
    Subject: [Haiku-commits] (no subject)
    In-Reply-To: <22932450.1190998078615.JavaMail.ngmail@webmail18>
    Message-ID: <35626182683-BeMail@zon>
    
    Marcus Overhagen  wrote:
    > I think it's better to not add public (stable) headers, unless they
    > are cleaned up and reviewed by multiple people.
    > 
    > I was looking for the scsi command codes, and noticed that the
    > scsi_cmds.h header didn't look as clean as I hoped for.
    > 
    > Especially, it's style didn't matched the PCI or USB headers.
    > 
    > Thats why I moved it to the private headers. I think we should strive
    > for conistency in the public headers, and thus keep most new headers
    > in the private folders.
    
    Alright then, that sounds good, then. There are probably more headers 
    we need to decide upon one day, anyway.
    
    Bye,
       Axel.
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 20:48:09 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 20:48:09 +0200
    Subject: [Haiku-commits] r22349 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709281848.l8SIm990015592@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 20:48:09 +0200 (Fri, 28 Sep 2007)
    New Revision: 22349
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22349&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * I just saw the page writer passing a free page to write_page().
      Apparently not everyone checks the page state for PAGE_STATE_BUSY.
      vm_page_write_modified_pages() does now at least.
    * Fixed typos in comments.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-28 15:50:26 UTC (rev 22348)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-28 18:48:09 UTC (rev 22349)
    @@ -680,7 +680,7 @@
     		vm_page *pages[kNumPages];
     		uint32 numPages = 0;
     
    -		// TODO: once the I/O scheduler is there, we should write back
    +		// TODO: once the I/O scheduler is there, we should write
     		// a lot more pages back.
     		// TODO: make this laptop friendly, too (ie. only start doing
     		// something if someone else did something or there is really
    @@ -730,7 +730,7 @@
     			writeStatus[i] = write_page(pages[i], false);
     		}
     
    -		// mark pages depending on if they could be written or not
    +		// mark pages depending on whether they could be written or not
     
     		for (uint32 i = 0; i < numPages; i++) {
     			vm_cache *cache = pages[i]->cache;
    @@ -854,8 +854,10 @@
     			InterruptsSpinLocker locker(&sPageLock);
     			remove_page_from_queue(&sModifiedPageQueue, page);
     			dequeuedPage = true;
    -		} else if (!vm_test_map_modification(page))
    +		} else if (page->state == PAGE_STATE_BUSY
    +				|| !vm_test_map_modification(page)) {
     			continue;
    +		}
     
     		page->state = PAGE_STATE_BUSY;
     
    
    
    
    From nielx at mail.berlios.de  Fri Sep 28 23:14:40 2007
    From: nielx at mail.berlios.de (nielx at BerliOS)
    Date: Fri, 28 Sep 2007 23:14:40 +0200
    Subject: [Haiku-commits] r22350 - haiku/trunk/docs/user/app
    Message-ID: <200709282114.l8SLEeiI021170@sheep.berlios.de>
    
    Author: nielx
    Date: 2007-09-28 23:14:39 +0200 (Fri, 28 Sep 2007)
    New Revision: 22350
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22350&view=rev
    
    Added:
       haiku/trunk/docs/user/app/MessageFilter.dox
    Modified:
       haiku/trunk/docs/user/app/_app_messaging.dox
    Log:
    Phase I of MessageFilter.dox
    
    Added: haiku/trunk/docs/user/app/MessageFilter.dox
    ===================================================================
    --- haiku/trunk/docs/user/app/MessageFilter.dox	2007-09-28 18:48:09 UTC (rev 22349)
    +++ haiku/trunk/docs/user/app/MessageFilter.dox	2007-09-28 21:14:39 UTC (rev 22350)
    @@ -0,0 +1,329 @@
    +/*
    + * Copyright 2007, Haiku, Inc. All Rights Reserved.
    + * Distributed under the terms of the MIT License.
    + *
    + * Authors:
    + *		Niels Sascha Reedijk, niels.reedijk at gmail.com
    + */
    +
    +
    +/*!
    +	\file MessageFilter.h
    +	\brief Provides BMessageFilter class.
    +*/
    +
    +
    +/*!
    +	\enum filter_result
    +	\brief Return Codes and Protocol of the #filter_hook.
    +
    +	These return codes should be used in your own filter_hook function, or by
    +	your overrided BMessageFilter::Filter() function.
    +*/
    +
    +
    +/*!
    +	\var B_SKIP_MESSAGE
    +	\brief The message does not pass the filter criteria and should not be
    +		handled.
    +*/
    +
    +
    +/*!
    +	\var B_DISPATCH_MESSAGE
    +	\brief The message passes the filter criteria and should be dispatched to
    +		a BHandler.
    +*/
    +
    +
    +/*!
    +	\typedef filter_result (*filter_hook) (BMessage* message,
    +		 BHandler** target, BMessageFilter* filter)
    +	\brief Prototype for a custom \c filter_hook for use in the BMessageFilter
    +		class.
    +
    +	This hook can be used when you are constructing a new BMessageFilter
    +	object. It is a custom filter function you can use.
    +
    +	This hook should handle the following parameters:
    +	
    +	\param[in] message The message that needs to be verified.
    +	\param[out] target If your filter hook is conscious about the available
    +		handlers, you can set a specific BHandler based on your filters
    +		requirements. You do not have to change this field, because there will
    +		always be a working default.
    +	\param[in] filter A pointer to the filter from which this hook is called.
    +
    +	\return You should return #B_SKIP_MESSAGE in case the message does not
    +		conform to the filter criteria, or #B_DISPATCH_MESSAGE if the message
    +		passes these criteria.
    +
    +	\see BMessageFilter(uint32, filter_hook)
    +		BMessageFilter(message_delivery, message_source, filter_hook)
    +		BMessageFilter(message_delivery, message_source, uint32, filter_hook)
    +*/
    +
    +
    +/*!
    +	\enum message_delivery
    +	\brief BMessageFilter filter criteria on how a message was delivered.
    +
    +	Two constructors of the BMessageFilter class allow you to specify that it
    +	should filter based on how the message was delivered. There are two ways in
    +	which messages can be delivered within the Haiku API: by direct delivery
    +	using the BLooper::PostMessage() function, and by drag and drop in the GUI.
    +	With this filter you can, for example, specify that your handler only
    +	handles deliveries that were programmed by you, and not any random drag and
    +	drop actions initiated by the user.
    +*/
    +
    +
    +/*!
    +	\var B_ANY_DELIVERY
    +	\brief Accept both delivery methods.
    +*/
    +
    +
    +/*!
    +	\var B_DROPPED_DELIVERY
    +	\brief Only accept messages that were dropped by the user in the GUI.
    +*/
    +
    +
    +/*!
    +	\var B_PROGRAMMED_DELIVERY
    +	\brief Only accept messages that were delivered using the
    +		BLooper::PostMessage() method.
    +*/
    +
    +
    +/*!
    +	\enum message_source
    +	\brief BMessageFilter filter criteria on the source of a message.
    +
    +	One of the key features of the messaging system of Haiku, is the ability
    +	to send messages between applications. However, your handler or looper
    +	might have been written in such a way that it would make no sense to try
    +	to process messages from an external source. Use these filter criteria to
    +	filter the unwanted messages out.
    +
    +	You use these constants in the constructors of the BMessageFilter class.
    +
    +	\warning System messages, for example from the \c app_server, are
    +		considered remote messages. Keep this in mind when you want to set up
    +		criteria for your window and application loopers.
    +*/
    +
    +
    +/*!
    +	\var B_ANY_SOURCE
    +	\brief Accept both local and remote messages.
    +*/
    +
    +
    +/*!
    +	\var B_REMOTE_SOURCE
    +	\brief Only accept messages from a remote source, so from other
    +		applications.
    +*/
    +
    +
    +/*!
    +	\var B_LOCAL_SOURCE
    +	\brief Only accept messages from your own local application.
    +*/
    +
    +
    +/*!
    +	\class BMessageFilter
    +	\brief Describes a message filter for BLooper and BHandler.
    +
    +	Objects of this class serve as a description of properties that incoming
    +	messages should have in order to be processed by a handler or a looper.
    +	BMessageFilter provides three default filter criteria, the \c what
    +	constant, the #message_source and the type of message_delivery,
    +	 and an extendible #filter_hook.
    +
    +	BMessageFilter's standard filter criteria can be extended in two ways:
    +	-# Specify a #filter_hook. This is a static function that takes a message
    +		 and a pointer to a BHandler as arguments, and allows you to accept or
    +		reject the message, and even redirect it to a specific BHandler.
    +	-# Subclass the BMessageFilter class and override the Filter() function.
    +		This has the same capabilities as using a #filter_hook, but it allows
    +		cleaner code (in some cases).
    +	
    +	Both methods have their merits, but please remember that you have to choose
    +	which one you want to use, since you can't use both. The order of
    +	processing the criteria is in this order: the source, the delivery method,
    +	the filter hook and then the overrided Filter() method. Additionally, if a
    +	#filter_hook is registered, the Filter() method will not be called.
    +
    +	The BMessageFilter objects are used in two different classes. They can be
    +	associated with specific BHandlers. Using the BHandler::AddFilter()
    +	and the BHandler::SetFilterList() methods, you can add filters to the
    +	filter list. It is also possible to associate filters with BLoopers. In
    +	that case, all incoming messages of that looper are checked against the
    +	criteria. To perform filtering in loopers, have a look at the
    +	BLooper::AddCommonFilter() and the BLooper::SetCommonFilterList() methods.
    +
    +	An example of a filter that selects on the default criteria:
    +\code
    +// Our window does not handle drop events.
    +BMessageFilter *filter = new BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE);
    +window->AddCommonFilter(filter);
    +\endcode
    +
    +	An example of a filter that only allows one type of message:
    +\code
    +BMessageFilter *filter = new BMessageFilter(kHappyMessages);
    +handler->AddFilter(filter);
    +\endcode
    +
    +	An example of a #filter_hook:
    +\code
    +// The handler depends on the what code of a message
    +filter_result
    +ScreenMessage(BMessage* message, BHandler** target, BMessageFilter* filter)
    +{
    +	switch (message->what) {
    +		case kTcpEvent:
    +			target = &fTcpHandler;
    +			return B_DISPATCH_MESSAGE;
    +		case kUdpEvent:
    +			target = &fUdpHandler;
    +			return B_DISPATCH_MESSAGE;
    +	}
    +	
    +	return B_SKIP_MESSAGE;
    +}
    +
    +BMessageFilter *filter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, ScreenMessage);
    +looper->AddCommonFilter(filter);
    +\endcode
    +
    +	The two classes that use BMessageFilter are BLooper and BHandler. In the
    +	general messaging introduction, there is also a section on 
    +	\ref app-messaging-receiving "handling messages".
    +*/
    +
    +
    +
    +/*!
    +	\fn BMessageFilter::BMessageFilter(uint32 inWhat, filter_hook func)
    +	\brief Construct a new object that filters on a message constant.
    +
    +	You can also specify a #filter_hook, if you want apply custom filter
    +	criteria.
    +
    +	\see BMessageFilter(message_delivery, message_source, filter_hook)
    +	\see BMessageFilter(message_delivery, message_source, uint32 what, filter_hook)
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter::BMessageFilter(message_delivery delivery,
    +		 message_source source, filter_hook func)
    +	\brief Construct a new object that filters on delivery method and message
    +		source.
    +
    +	You can also specify a #filter_hook, if you want to apply custom filter
    +	criteria.
    +
    +	\see BMessageFilter(uint32 what,filter_hook)
    +	\see BMessageFilter(message_delivery, message_source, uint32 what, filter_hook)
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter::BMessageFilter(message_delivery delivery,
    +		message_source source, uint32 inWhat, filter_hook func)
    +	\brief Construct a new object that filters on delivery method, message
    +		source and specific message constants.
    +
    +	You can also specify a #filter_hook, if you want to apply custom filter
    +	criteria.
    +
    +	\see BMessageFilter(uint32 what,filter_hook)
    +	\see BMessageFilter(message_delivery, message_source, filter_hook)
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter::BMessageFilter(const BMessageFilter& filter)
    +	\brief Copy constructor. Copy the criteria from another object.
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter::BMessageFilter(const BMessageFilter* filter)
    +	\brief Create a new object based on criteria of another object.
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter::~BMessageFilter()
    +	\brief Destructor. Does nothing.
    +*/
    +
    +
    +/*!
    +	\fn BMessageFilter &BMessageFilter::operator=(const BMessageFilter& from)
    +	\brief Assignment operator. Copies criteria from another filter.
    +*/
    +
    +
    +/*!
    +	\fn filter_result BMessageFilter::Filter(BMessage* message,
    +		 BHandler** target)
    +	\brief Filter the message according to custom criteria.
    +
    +	The default implementation of this method always returns
    +	\c B_DISPATCH_MESSAGE. You can override this method in subclasses to
    +	suit your own criteria. You receive two arguments.
    +
    +	\param message The message that needs to be filtered.
    +	\param target If you want to, you can specify a handler that should handle
    +		this message. Note that you do have to pass a handler that is
    +		associated with the looper that received the message.
    +
    +	\return You should return \c B_DISPATCH_MESSAGE in case the message passes
    +		the tests, or \c B_SKIP_MESSAGE in case the message does not pass.
    +*/
    +
    +
    +/*!
    +	\fn message_delivery BMessageFilter::MessageDelivery() const
    +	\brief Return the message_delivery criterium of this filter.
    +*/
    +
    +
    +/*!
    +	\fn message_source BMessageFilter::MessageSource() const
    +	\brief Return the message_source criterium of this filter.
    +*/
    +
    +
    +/*!
    +	\fn uint32 BMessageFilter::Command() const
    +	\brief Return the accepted message constant.
    +
    +	This method returns zero (0) in case this filter does not filter based on
    +	the message constant.
    +
    +	\see FiltersAnyCommand() const
    +*/
    +
    +
    +/*!
    +	\fn bool BMessageFilter::FiltersAnyCommand() const
    +	\brief Return whether or not this filter has a message command criterium.
    +
    +	\see Command() const
    +*/
    +
    +
    +/*!
    +	\fn BLooper *BMessageFilter::Looper() const
    +	\brief Return the looper this filter is associated with.
    +*/
    +
    
    Modified: haiku/trunk/docs/user/app/_app_messaging.dox
    ===================================================================
    --- haiku/trunk/docs/user/app/_app_messaging.dox	2007-09-28 18:48:09 UTC (rev 22349)
    +++ haiku/trunk/docs/user/app/_app_messaging.dox	2007-09-28 21:14:39 UTC (rev 22350)
    @@ -65,8 +65,8 @@
     	Messages can be posted to the looper by using the object's PostMessage()
     	method. This method puts the message in the BMessageQueue of the looper.
     	Since PostMessage() is asynchronous, the message might not be handled
    -	immediately. See \link app_messaging_overview_bmessenger BMessenger 
    -	\endlink for a synchronous implementation.
    +	immediately. See \ref app_messaging_overview_bmessenger "BMessenger"
    +	for a synchronous implementation.
     	
     	Loopers can have a generic filter that discards messages based on
     	user-definable characteristics. The BMessageFilter class provides the
    @@ -108,7 +108,7 @@
     		that the Haiku API classes handle, and not actually handling these
     		messages could lead to inconsistent internal behavior.
     	
    -	\subsection app_messaging-overview-bmessenger BMessenger
    +	\subsection app_messaging_overview_bmessenger BMessenger
     	
     	BMessenger objects can send messages to both local and remote targets. For
     	local targets, a BMessenger provides an advantage over directly calling
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 23:19:14 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 23:19:14 +0200
    Subject: [Haiku-commits] r22351 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709282119.l8SLJETF021787@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 23:19:14 +0200 (Fri, 28 Sep 2007)
    New Revision: 22351
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22351&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h
    Log:
    added sg_memcpy to copy data into a scatter-gather table (inspired by IDE device manager)
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile	2007-09-28 21:14:39 UTC (rev 22350)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/Jamfile	2007-09-28 21:19:14 UTC (rev 22351)
    @@ -1,5 +1,8 @@
     SubDir HAIKU_TOP src add-ons kernel busses scsi ahci ;
     
    +UsePrivateHeaders drivers kernel ;
    +UsePrivateHeaders [ FDirName kernel arch $(TARGET_ARCH) ] ;
    +
     KernelAddon ahci :
     	ahci.c
     	ahci_controller.cpp
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c	2007-09-28 21:14:39 UTC (rev 22350)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c	2007-09-28 21:19:14 UTC (rev 22351)
    @@ -6,6 +6,7 @@
     
     #include 
     #include 
    +#include 
     #include 
     
     
    @@ -74,3 +75,28 @@
     	
     	return area;
     }
    +
    +
    +status_t
    +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)
    +			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);
    +
    +		data = (char *)data + size;
    +		dataSize -= size;
    +	}
    +	if (dataSize != 0)
    +		return B_ERROR;
    +	return B_OK;
    +}
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h	2007-09-28 21:14:39 UTC (rev 22350)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h	2007-09-28 21:19:14 UTC (rev 22351)
    @@ -5,7 +5,7 @@
     #ifndef __UTIL_H
     #define __UTIL_H
     
    -#include 
    +#include 
     
     #ifdef __cplusplus
     extern "C" {
    @@ -14,6 +14,8 @@
     area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name);
     area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name);
     
    +status_t sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data, size_t dataSize);
    +
     #ifdef __cplusplus
     }
     #endif
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 23:20:46 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 23:20:46 +0200
    Subject: [Haiku-commits] r22352 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709282120.l8SLKkZB021960@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 23:20:46 +0200 (Fri, 28 Sep 2007)
    New Revision: 22352
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22352&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    Log:
    removed conditional testing code
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c	2007-09-28 21:19:14 UTC (rev 22351)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c	2007-09-28 21:20:46 UTC (rev 22352)
    @@ -83,19 +83,11 @@
     			PCI_DEVICE_DEVICE_ID_ITEM, &deviceID, false) != B_OK)
     		return B_ERROR;
     
    -#if 1
     	if (strcmp(bus, "pci") || baseClass != PCI_mass_storage
     		|| subClass != PCI_sata || classAPI != PCI_sata_ahci) {
     		free(bus);
     		return 0.0f;
     	}
    -#else
    -	if (strcmp(bus, "pci") || baseClass != PCI_mass_storage
    -		|| subClass != PCI_ide) {
    -		free(bus);
    -		return 0.0;
    -	}
    -#endif
     
     	TRACE("controller found! vendor 0x%04x, device 0x%04x\n",
     		vendorID, deviceID);
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-28 21:19:14 UTC (rev 22351)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_controller.cpp	2007-09-28 21:20:46 UTC (rev 22352)
    @@ -235,16 +235,10 @@
     	uint32 saveCaps = fRegs->cap & (CAP_SMPS | CAP_SSS | CAP_SPM | CAP_EMS | CAP_SXS);
     	uint32 savePI = fRegs->pi;
     	
    -#if 1
     	fRegs->ghc |= GHC_HR;
     	FlushPostedWrites();
     	if (wait_until_clear(&fRegs->ghc, GHC_HR, 1000000) < B_OK)
     		return B_TIMED_OUT;
    -#else
    -	fRegs->ghc &= ~GHC_AE;
    -	fRegs->is = 0xffffffff;
    -	FlushPostedWrites();
    -#endif
     
     	fRegs->ghc |= GHC_AE;
     	FlushPostedWrites();
    
    
    
    From axeld at mail.berlios.de  Fri Sep 28 23:20:57 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Fri, 28 Sep 2007 23:20:57 +0200
    Subject: [Haiku-commits] r22353 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709282120.l8SLKv32022005@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-28 23:20:57 +0200 (Fri, 28 Sep 2007)
    New Revision: 22353
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22353&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    Log:
    vm_cache_resize() did not care about busy pages - now it does.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-28 21:20:46 UTC (rev 22352)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-28 21:20:57 UTC (rev 22353)
    @@ -482,6 +482,9 @@
     	The cache lock must be held when you call it.
     	Since removed pages don't belong to the cache any longer, they are not
     	written back before they will be removed.
    +
    +	Note, this function way temporarily release the cache lock in case it
    +	has to wait for busy pages.
     */
     status_t
     vm_cache_resize(vm_cache *cache, off_t newSize)
    @@ -499,17 +502,33 @@
     	newPageCount = (uint32)((newSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT);
     
     	if (newPageCount < oldPageCount) {
    -		// we need to remove all pages in the cache outside of the new virtual size
    -		vm_page *page, *next;
    +		// we need to remove all pages in the cache outside of the new virtual
    +		// size
    +		vm_page *page = cache->page_list, *next;
     
    -		for (page = cache->page_list; page; page = next) {
    +		while (page != NULL) {
     			next = page->cache_next;
     
     			if (page->cache_offset >= newPageCount) {
    +				if (page->state == PAGE_STATE_BUSY) {
    +					// wait for page to become unbusy
    +					ConditionVariableEntry entry;
    +					entry.Add(page);
    +					mutex_unlock(&cache->lock);
    +					entry.Wait();
    +					mutex_lock(&cache->lock);
    +
    +					// restart from the start of the list
    +					page = cache->page_list;
    +					continue;
    +				}
    +
     				// remove the page and put it into the free queue
     				vm_cache_remove_page(cache, page);
     				vm_page_set_state(page, PAGE_STATE_FREE);
     			}
    +
    +			page = next;
     		}
     	}
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 23:22:26 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 23:22:26 +0200
    Subject: [Haiku-commits] r22354 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709282122.l8SLMQSX022390@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 23:22:25 +0200 (Fri, 28 Sep 2007)
    New Revision: 22354
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22354&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    added scatter gather prd table setup, implement scsi inquiry command and emulate test unit ready
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-28 21:20:57 UTC (rev 22353)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_defs.h	2007-09-28 21:22:25 UTC (rev 22354)
    @@ -208,6 +208,7 @@
     } _PACKED prd;
     
     #define PRD_TABLE_ENTRY_COUNT 168
    +#define PRD_MAX_DATA_LENGTH 0x400000 /* 4 MB */
     
     
     extern scsi_sim_interface gAHCISimInterface;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 21:20:57 UTC (rev 22353)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 21:22:25 UTC (rev 22354)
    @@ -6,6 +6,8 @@
     #include "ahci_port.h"
     #include "ahci_controller.h"
     #include "util.h"
    +#include "ata_cmds.h"
    +#include "scsi_cmds.h"
     
     #include 
     #include 
    @@ -104,9 +106,7 @@
     
     	FlushPostedWrites();
     
    -	if (1 /* fRegs->sig == 0xffffffff */)
    -		ResetDevice();
    -
    +	ResetDevice();
     	PostResetDevice();
     
     	TRACE("ie   0x%08lx\n", fRegs->ie);
    @@ -260,15 +260,61 @@
     	fRegs->is = is;
     }
     
    -char c(int i)
    +
    +status_t
    +AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc)
     {
    -	if (i == '\n' || i == '\r' || i == '\b')
    -		return '?';
    -	return i;
    +	int peMax = prdMax + 1;
    +	physical_entry pe[peMax];
    +	if (get_memory_map(data, dataSize, pe, peMax ) < B_OK) {
    +		TRACE("AHCIPort::FillPrdTable get_memory_map failed\n");
    +		return B_ERROR;
    +	}
    +	int peUsed;
    +	for (peUsed = 0; pe[peUsed].size; peUsed++)
    +		;
    +	return FillPrdTable(prdTable, prdCount, prdMax, pe, peUsed, ioc);
     }
     
    +
    +status_t
    +AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, bool ioc)
    +{
    +	*prdCount = 0;
    +	while (sgCount > 0) {
    +		size_t size = sgTable->size;
    +		void *address = sgTable->address;
    +		if ((uint32)address & 1) {
    +			TRACE("AHCIPort::FillPrdTable: data alignment error\n");
    +			return B_ERROR;
    +		}
    +		while (size > 0) {
    +			size_t bytes = min_c(size, PRD_MAX_DATA_LENGTH);
    +			if (*prdCount == prdMax) {
    +				TRACE("AHCIPort::FillPrdTable: prd table exhausted\n");
    +				return B_ERROR;
    +			}
    +			prdTable->dba  = LO32(address);
    +			prdTable->dbau = HI32(address);
    +			prdTable->res  = 0;
    +			prdTable->dbc  = bytes - 1;
    +			*prdCount += 1;
    +			prdTable++;
    +			address = (char *)address + bytes;
    +			size -= bytes;
    +		}
    +		sgTable++;
    +		sgCount--;
    +	}
    +	if (ioc)
    +		prdTable->dbc |= DBC_I;
    +	return B_OK;
    +}
    +
    +
    +/*
     void
    -AHCIPort::IdentifyDevice()
    +AHCIPort::IdentifyDevice(scsi_ccb *request)
     {
     	TRACE("AHCIPort::IdentifyDevice port %d\n", fIndex);
     
    @@ -341,29 +387,153 @@
     	}
     
     	delete_area(id);
    +
    +	request->subsys_status = SCSI_REQ_CMP;
    +	gSCSI->finished(request, 1);
    +
     }
    +*/
     
    +void
    +AHCIPort::ScsiTestUnitReady(scsi_ccb *request)
    +{
    +	TRACE("AHCIPort::ScsiTestUnitReady port %d\n", fIndex);
    +	if ((fRegs->ssts & 0xf) == 0x3)
    +		request->subsys_status = SCSI_REQ_CMP;
    +	else
    +		request->subsys_status = SCSI_DEV_NOT_THERE;
    +	gSCSI->finished(request, 1);
    +}
     
    +
     void
    +AHCIPort::ScsiInquiry(scsi_ccb *request)
    +{
    +	TRACE("AHCIPort::ScsiInquiry port %d\n", fIndex);
    +
    +	scsi_cmd_inquiry *cmd = (scsi_cmd_inquiry *)request->cdb;
    +	scsi_res_inquiry scsiData;
    +	ata_res_identify_device	ataData;
    +
    +	if (cmd->evpd || cmd->page_code) {
    +		TRACE("invalid request\n");
    +		return;
    +	}
    +
    +	memset(&ataData, 0, sizeof(ataData));
    +
    +	int prdEntrys;
    +	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, &ataData, sizeof(ataData), true);
    +
    +
    +	TRACE("prdEntrys %d\n", prdEntrys);
    +	
    +	memset((void *)fCommandTable->cfis, 0, 5 * 4);
    +	fCommandTable->cfis[0] = 0x27;
    +	fCommandTable->cfis[1] = 0x80;
    +	fCommandTable->cfis[2] = 0xec;
    +
    +
    +	fCommandList->prdtl_flags_cfl = 0;
    +	fCommandList->prdtl = prdEntrys;
    +//	fCommandList->c = 1;
    +	fCommandList->cfl = 5;
    +	fCommandList->prdbc = 0;
    +
    +	fRegs->ci |= 1;
    +	FlushPostedWrites();
    +
    +	snooze(500000);
    +
    +	TRACE("prdbc %ld\n", fCommandList->prdbc);
    +
    +	TRACE("ci   0x%08lx\n", fRegs->ci);
    +	TRACE("ie   0x%08lx\n", fRegs->ie);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    +	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    +	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	TRACE("sact 0x%08lx\n", fRegs->sact);
    +	TRACE("tfd  0x%08lx\n", fRegs->tfd);
    +
    +	uint8 *data = (uint8*) &ataData;
    +	for (int i = 0; i < 512; i += 8) {
    +		TRACE("  %02x %02x %02x %02x %02x %02x %02x %02x\n", data[i], data[i+1], data[i+2], data[i+3], data[i+4], data[i+5], data[i+6], data[i+7]);
    +	}
    +
    +	scsiData.device_type = scsi_dev_direct_access;
    +	scsiData.device_qualifier = scsi_periph_qual_connected;
    +	scsiData.device_type_modifier = 0;
    +	scsiData.removable_medium = false;
    +	scsiData.ansi_version = 2;
    +	scsiData.ecma_version = 0;
    +	scsiData.iso_version = 0;
    +	scsiData.response_data_format = 2;
    +	scsiData.term_iop = false;
    +	scsiData.additional_length = sizeof(scsiData) - 4;
    +	scsiData.soft_reset = false;
    +	scsiData.cmd_queue = false;
    +	scsiData.linked = false;
    +	scsiData.sync = false;
    +	scsiData.write_bus16 = true;
    +	scsiData.write_bus32 = false;
    +	scsiData.relative_address = false;
    +
    +	bool lba			= (ataData.words[49] & (1 << 9)) != 0;
    +	bool lba48			= (ataData.words[83] & (1 << 10)) != 0;
    +	uint32 sectors		= *(uint32*)&ataData.words[60];
    +	uint64 sectors48	= *(uint64*)&ataData.words[100];
    +	uint64 size = !(lba || sectors) ? 0 : lba48 ? (sectors48 * 512) : (sectors * 512ull);
    +
    +	TRACE("model_number: %40.40s\n", ataData.model_number);
    +	TRACE("serial_number: %20.20s\n", ataData.serial_number);
    +	TRACE("firmware_revision: %8.8s\n", ataData.firmware_revision);
    +	TRACE("lba %d, lba48 %d, sectors %lu, sectors48 %llu, size %llu\n",
    +		lba, lba48, sectors, sectors48, size);
    +
    +	memcpy(scsiData.vendor_ident, ataData.model_number, sizeof(scsiData.vendor_ident));
    +	memcpy(scsiData.product_ident, ataData.model_number + 8, sizeof(scsiData.product_ident));
    +	memcpy(scsiData.product_rev, ataData.serial_number, sizeof(scsiData.product_rev));
    +
    +	if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
    +		request->subsys_status = SCSI_DATA_RUN_ERR;
    +	} else {
    +		request->subsys_status = SCSI_REQ_CMP;
    +		request->data_resid = request->data_length - sizeof(scsiData);// ???
    +		request->data_length = sizeof(scsiData); // ???
    +	}
    +
    +	gSCSI->finished(request, 1);
    +}
    +
    +
    +void
     AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
     {
     
    -	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode %u, length %u\n", fIndex, request->cdb[0], request->cdb_length);
    +	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
    +	if (request->cdb[0] == SCSI_OP_REQUEST_SENSE) {
    +		TRACE("SCSI_OP_REQUEST_SENSE\n");
    +		request->subsys_status = SCSI_DEV_NOT_THERE;
    +		gSCSI->finished(request, 1);
    +		return;
    +	}
    +	
    +	request->subsys_status = SCSI_REQ_CMP;
    +
     	switch (request->cdb[0]) {
    -		case 0x00:
    +		case SCSI_OP_TEST_UNIT_READY:
    +			ScsiTestUnitReady(request);
     			break;
    -		case 0x12:
    -			IdentifyDevice();
    +		case SCSI_OP_INQUIRY:
    +			ScsiInquiry(request);
     			break;
    +		default:
    +		request->subsys_status = SCSI_DEV_NOT_THERE;
    +		gSCSI->finished(request, 1);
     	}
    -
    -	request->subsys_status = SCSI_DEV_NOT_THERE;
    -	gSCSI->finished(request, 1);
    -	return;
    -
    -	request->subsys_status = SCSI_REQ_CMP;
    -	gSCSI->finished(request, 1);
     }
     
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-28 21:20:57 UTC (rev 22353)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-28 21:22:25 UTC (rev 22354)
    @@ -27,12 +27,20 @@
     	uchar		ScsiResetDevice();
     
     private:
    +	void		ScsiTestUnitReady(scsi_ccb *request);
    +	void		ScsiInquiry(scsi_ccb *request);
    +
    +
     	status_t	ResetDevice();
     	status_t	PostResetDevice();
     	void		FlushPostedWrites();
     	void		DumpD2HFis();
    -	void		IdentifyDevice();
     
    +
    +//	uint8 *		SetCommandFis(volatile command_list_entry *cmd, volatile fis *fis, const void *data, size_t dataSize);
    +	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc = false);
    +	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, bool ioc = false);
    +
     private:
     	int						fIndex;
     	volatile ahci_port *	fRegs;
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 23:24:26 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 23:24:26 +0200
    Subject: [Haiku-commits] r22355 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709282124.l8SLOQox023435@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 23:24:26 +0200 (Fri, 28 Sep 2007)
    New Revision: 22355
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22355&view=rev
    
    Added:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ata_cmds.h
    Log:
    add missing file
    
    
    Added: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ata_cmds.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ata_cmds.h	2007-09-28 21:22:25 UTC (rev 22354)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ata_cmds.h	2007-09-28 21:24:26 UTC (rev 22355)
    @@ -0,0 +1,20 @@
    +#ifndef _ATA_CMDS_H
    +#define _ATA_CMDS_H
    +
    +#include 
    +
    +struct ata_res_identify_device
    +{
    +	union {
    +		uint16 		words[256];
    +		struct {
    +			uint16	data1[10];
    +			char	serial_number[20];
    +			uint16	data2[3];
    +			char	firmware_revision[8];
    +			char	model_number[40];
    +		};
    +	};
    +};
    +
    +#endif
    
    
    
    From marcusoverhagen at mail.berlios.de  Fri Sep 28 23:30:53 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Fri, 28 Sep 2007 23:30:53 +0200
    Subject: [Haiku-commits] r22356 - in haiku/trunk: headers/private/drivers
    	src/add-ons/kernel/bus_managers/ide
    	src/add-ons/kernel/bus_managers/scsi
    	src/add-ons/kernel/generic/scsi_periph
    Message-ID: <200709282130.l8SLUrxG025673@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-28 23:30:53 +0200 (Fri, 28 Sep 2007)
    New Revision: 22356
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22356&view=rev
    
    Modified:
       haiku/trunk/headers/private/drivers/scsi_cmds.h
       haiku/trunk/src/add-ons/kernel/bus_managers/ide/scsi2ata.c
       haiku/trunk/src/add-ons/kernel/bus_managers/scsi/device_scan.c
       haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.c
    Log:
    renamed SCSI_OP_TUR into SCSI_OP_TEST_UNIT_READY
    
    
    Modified: haiku/trunk/headers/private/drivers/scsi_cmds.h
    ===================================================================
    --- haiku/trunk/headers/private/drivers/scsi_cmds.h	2007-09-28 21:24:26 UTC (rev 22355)
    +++ haiku/trunk/headers/private/drivers/scsi_cmds.h	2007-09-28 21:30:53 UTC (rev 22356)
    @@ -122,7 +122,7 @@
     #define SCSIS_ASC_REMOVAL_REQUESTED 0x5a01	// operator requests medium removal
     
     // some scsi op-codes
    -#define	SCSI_OP_TUR 0x00
    +#define	SCSI_OP_TEST_UNIT_READY 0x00
     #define SCSI_OP_REQUEST_SENSE 0x03
     #define SCSI_OP_FORMAT 0x04
     #define	SCSI_OP_READ_6 0x08
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/scsi2ata.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/scsi2ata.c	2007-09-28 21:24:26 UTC (rev 22355)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/scsi2ata.c	2007-09-28 21:30:53 UTC (rev 22356)
    @@ -396,7 +396,7 @@
     		start_request(device, qrequest);
     
     	switch (request->cdb[0]) {
    -		case SCSI_OP_TUR:
    +		case SCSI_OP_TEST_UNIT_READY:
     			ata_test_unit_ready(device, qrequest);
     			break;
     
    
    Modified: haiku/trunk/src/add-ons/kernel/bus_managers/scsi/device_scan.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/bus_managers/scsi/device_scan.c	2007-09-28 21:24:26 UTC (rev 22355)
    +++ haiku/trunk/src/add-ons/kernel/bus_managers/scsi/device_scan.c	2007-09-28 21:30:53 UTC (rev 22356)
    @@ -31,7 +31,7 @@
     	SHOW_FLOW0( 3, "" );
     	
     	memset( cmd, 0, sizeof( *cmd ));
    -	cmd->opcode = SCSI_OP_TUR;
    +	cmd->opcode = SCSI_OP_TEST_UNIT_READY;
     	
     	worker_req->sg_list = NULL;
     	worker_req->data = NULL;
    
    Modified: haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.c	2007-09-28 21:24:26 UTC (rev 22355)
    +++ haiku/trunk/src/add-ons/kernel/generic/scsi_periph/removable.c	2007-09-28 21:30:53 UTC (rev 22356)
    @@ -98,7 +98,7 @@
     	request->sg_list = NULL;
     
     	memset(cmd, 0, sizeof(*cmd));
    -	cmd->opcode = SCSI_OP_TUR;
    +	cmd->opcode = SCSI_OP_TEST_UNIT_READY;
     
     	request->cdb_length = sizeof(*cmd);
     
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 23:37:31 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 23:37:31 +0200
    Subject: [Haiku-commits] r22357 - haiku/trunk/src/add-ons/kernel/drivers/tty
    Message-ID: <200709282137.l8SLbVRs025975@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 23:37:31 +0200 (Fri, 28 Sep 2007)
    New Revision: 22357
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22357&view=rev
    
    Removed:
       haiku/trunk/src/add-ons/kernel/drivers/tty/SemaphorePool.cpp
       haiku/trunk/src/add-ons/kernel/drivers/tty/SemaphorePool.h
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/tty/Jamfile
       haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp
       haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp
       haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h
       haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
       haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
    Log:
    * When canonical input processing is enabled reads should only return
      anything, if a line is available. Fixes bug #1483.
    * Replaced the request owner waiting semaphore by a condition variable
      and removed the now no longer needed SemaphorePool.
    
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/Jamfile
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/Jamfile	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/Jamfile	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -8,6 +8,5 @@
     	line_buffer.cpp
     	master.cpp
     	slave.cpp
    -	SemaphorePool.cpp
    -	;
    +;
     
    
    Deleted: haiku/trunk/src/add-ons/kernel/drivers/tty/SemaphorePool.cpp
    
    Deleted: haiku/trunk/src/add-ons/kernel/drivers/tty/SemaphorePool.h
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/driver.cpp	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -11,7 +11,6 @@
     
     #include 
     
    -#include "SemaphorePool.h"
     #include "tty_private.h"
     
     
    @@ -34,8 +33,6 @@
     struct mutex gGlobalTTYLock;
     struct mutex gTTYCookieLock;
     struct recursive_lock gTTYRequestLock;
    -static char sSemaphorePoolBuffer[sizeof(SemaphorePool)];
    -SemaphorePool *gSemaphorePool = 0;
     
     
     status_t
    @@ -73,15 +70,6 @@
     		return error;
     	}
     
    -	// create the semaphore pool
    -	gSemaphorePool
    -		= new(sSemaphorePoolBuffer) SemaphorePool(kMaxCachedSemaphores);
    -	error = gSemaphorePool->Init();
    -	if (error != B_OK) {
    -		uninit_driver();
    -		return error;
    -	}
    -
     	// create driver name array and initialize basic TTY structures
     
     	char letter = 'p';
    @@ -124,11 +112,6 @@
     	for (int32 i = 0; i < (int32)kNumTTYs * 2; i++)
     		free(sDeviceNames[i]);
     
    -	if (gSemaphorePool) {
    -		gSemaphorePool->~SemaphorePool();
    -		gSemaphorePool = NULL;
    -	}
    -
     	recursive_lock_destroy(&gTTYRequestLock);
     	mutex_destroy(&gTTYCookieLock);
     	mutex_destroy(&gGlobalTTYLock);
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.cpp	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -50,6 +50,24 @@
     
     
     int32
    +line_buffer_readable_line(struct line_buffer &buffer, char eol, char eof)
    +{
    +	size_t size = buffer.in;
    +	if (size == 0)
    +		return 0;
    +
    +	// find EOL or EOF char
    +	for (size_t i = 0; i < size; i++) {
    +		char c = buffer.buffer[(buffer.first + i) % buffer.size];
    +		if (c == eol || c == '\n' || c == '\r' || c == eof)
    +			return i + 1;
    +	}
    +
    +	return 0;
    +}
    +
    +
    +int32
     line_buffer_writable(struct line_buffer &buffer)
     {
     	return buffer.size - buffer.in;
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/line_buffer.h	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -20,6 +20,7 @@
     status_t uninit_line_buffer(struct line_buffer &buffer);
     status_t clear_line_buffer(struct line_buffer &buffer);
     int32 line_buffer_readable(struct line_buffer &buffer);
    +int32 line_buffer_readable_line(struct line_buffer &buffer, char eol, char eof);
     int32 line_buffer_writable(struct line_buffer &buffer);
     ssize_t line_buffer_user_read(struct line_buffer &buffer, char *data,
     			size_t length, char eof = 0, bool* hitEOF = NULL);
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -19,7 +19,6 @@
     
     #include 
     
    -#include "SemaphorePool.h"
     #include "tty_private.h"
     
     
    @@ -134,7 +133,8 @@
     		status_t AcquireReader(bool dontBlock);
     
     	private:
    -	status_t _CheckBackgroundRead() const;
    +		size_t _CheckAvailableBytes() const;
    +		status_t _CheckBackgroundRead() const;
     
     		struct tty		*fTTY;
     		RequestOwner	fRequestOwner;
    @@ -295,7 +295,7 @@
     
     RequestOwner::RequestOwner()
     	:
    -	fSemaphore(NULL),
    +	fConditionVariable(NULL),
     	fCookie(NULL),
     	fError(B_OK),
     	fBytesNeeded(1)
    @@ -364,21 +364,12 @@
      *	The request lock MUST NOT be held!
      */
     status_t
    -RequestOwner::Wait(bool interruptable, Semaphore *sem)
    +RequestOwner::Wait(bool interruptable)
     {
    -	TRACE(("%p->RequestOwner::Wait(%d, %p)\n", this, interruptable, sem));
    +	TRACE(("%p->RequestOwner::Wait(%d)\n", this, interruptable));
     
    -	// get a semaphore (if not supplied or invalid)
     	status_t error = B_OK;
    -	bool ownsSem = false;
    -	if (!sem || sem->InitCheck() != B_OK) {
    -		error = gSemaphorePool->Get(sem);
    -		if (error != B_OK)
    -			return error;
     
    -		ownsSem = true;
    -	}
    -
     	RecursiveLocker locker(gTTYRequestLock);
     
     	// check, if already done
    @@ -386,35 +377,35 @@
     		&& (!fRequests[0].WasNotified() || !fRequests[1].WasNotified())) {
     		// not yet done
     
    -		// set the semaphore
    -		fSemaphore = sem;
    +		// publish the condition variable
    +		ConditionVariable<> conditionVariable;
    +		conditionVariable.Publish(this, "tty request");
    +		fConditionVariable = &conditionVariable;
     
    +		// add an entry to wait on
    +		ConditionVariableEntry<> entry;
    +		entry.Add(this);
    +
     		locker.Unlock();
     
     		// wait
    -		TRACE(("%p->RequestOwner::Wait(): acquiring semaphore...\n", this));
    +		TRACE(("%p->RequestOwner::Wait(): waiting for condition...\n", this));
     
    -		error = acquire_sem_etc(sem->ID(), 1,
    -			(interruptable ? B_CAN_INTERRUPT : 0), 0);
    +		error = entry.Wait(interruptable ? B_CAN_INTERRUPT : 0);
     
    -		TRACE(("%p->RequestOwner::Wait(): semaphore acquired: %lx\n", this,
    +		TRACE(("%p->RequestOwner::Wait(): condition occurred: %lx\n", this,
     			error));
     
    -		// remove the semaphore
    -		locker.SetTo(gTTYRequestLock, false);
    -		fSemaphore = NULL;
    +		// remove the condition variable
    +		locker.Lock();
    +		fConditionVariable = NULL;
    +		conditionVariable.Unpublish();
     	}
     
     	// get the result
     	if (error == B_OK)
     		error = fError;
     
    -	locker.Unlock();
    -
    -	// return the semaphore to the pool
    -	if (ownsSem)
    -		gSemaphorePool->Put(sem);
    -
     	return error;
     }
     
    @@ -439,18 +430,18 @@
     	TRACE(("%p->RequestOwner::Notify(%p)\n", this, request));
     
     	if (fError == B_OK && !request->WasNotified()) {
    -		bool releaseSem = false;
    +		bool notify = false;
     
     		if (&fRequests[0] == request) {
    -			releaseSem = fRequests[1].WasNotified();
    +			notify = fRequests[1].WasNotified();
     		} else if (&fRequests[1] == request) {
    -			releaseSem = fRequests[0].WasNotified();
    +			notify = fRequests[0].WasNotified();
     		} else {
     			// spurious call
     		}
     
    -		if (releaseSem && fSemaphore)
    -			release_sem(fSemaphore->ID());
    +		if (notify && fConditionVariable)
    +			fConditionVariable->NotifyOne();
     	}
     }
     
    @@ -464,8 +455,8 @@
     		fError = error;
     
     		if (!fRequests[0].WasNotified() || !fRequests[1].WasNotified()) {
    -			if (fSemaphore)
    -				release_sem(fSemaphore->ID());
    +			if (fConditionVariable)
    +				fConditionVariable->NotifyOne();
     		}
     	}
     }
    @@ -667,7 +658,7 @@
     
     	// check, if we're first in queue, and if there is something to read
     	if (fRequestOwner.IsFirstInQueues()) {
    -		fBytes = line_buffer_readable(fTTY->input_buffer);
    +		fBytes = _CheckAvailableBytes();
     		if (fBytes > 0)
     			return B_OK;
     	}
    @@ -686,12 +677,27 @@
     		status = _CheckBackgroundRead();
     
     	if (status == B_OK)
    -		fBytes = line_buffer_readable(fTTY->input_buffer);
    +		fBytes = _CheckAvailableBytes();
     
     	return status;
     }
     
     
    +size_t
    +ReaderLocker::_CheckAvailableBytes() const
    +{
    +	// Reading from the slave with canonical input processing enabled means
    +	// that we read at max until hitting a line end or EOF.
    +	if (!fTTY->is_master && (fTTY->settings->termios.c_lflag & ICANON) != 0) {
    +		return line_buffer_readable_line(fTTY->input_buffer,
    +			fTTY->settings->termios.c_cc[VEOL],
    +			fTTY->settings->termios.c_cc[VEOF]);
    +	}
    +
    +	return line_buffer_readable(fTTY->input_buffer);
    +}
    +
    +
     status_t
     ReaderLocker::_CheckBackgroundRead() const
     {
    @@ -1028,11 +1034,8 @@
     
     			ttyLocker.Unlock();
     
    -			// wait for our turn (we reuse the blocking semaphore, so Wait()
    -			// can't fail due to not being able to get a semaphore)
    -			Semaphore sem(cookie->blocking_semaphore);
    -			cookie->blocking_semaphore = -1;
    -			requestOwner.Wait(false, &sem);
    +			// wait for our turn
    +			requestOwner.Wait(false);
     
     			// re-lock
     			ttyLocker.SetTo(cookie->tty->lock, false);
    @@ -1402,11 +1405,17 @@
     			return status;
     		}
     
    +		size_t toRead = locker.AvailableBytes();
    +		if (toRead == 0)
    +			continue;
    +		if (toRead > length)
    +			toRead = length;
    +
     		bool _hitEOF = false;
     		bool* hitEOF = (tty->pending_eof > 0 ? &_hitEOF : NULL);
     
     		bytesRead = line_buffer_user_read(tty->input_buffer, (char *)buffer,
    -			length, tty->settings->termios.c_cc[VEOF], hitEOF);
    +			toRead, tty->settings->termios.c_cc[VEOF], hitEOF);
     		if (bytesRead < B_OK) {
     			*_length = 0;
     			return bytesRead;
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2007-09-28 21:30:53 UTC (rev 22356)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty_private.h	2007-09-28 21:37:31 UTC (rev 22357)
    @@ -5,15 +5,16 @@
     #ifndef TTY_PRIVATE_H
     #define TTY_PRIVATE_H
     
    +#include 
     
    -#include 
     #include 
    -#include 
    +#include 
    +
    +#include 
     #include 
    +#include 
     #include 
     
    -#include 
    -
     #include "line_buffer.h"
     
     
    @@ -29,7 +30,6 @@
     
     class RequestOwner;
     class Semaphore;
    -class SemaphorePool;
     struct tty;
     struct tty_cookie;
     
    @@ -87,7 +87,7 @@
     		void SetBytesNeeded(size_t bytesNeeded);
     		size_t BytesNeeded() const	{ return fBytesNeeded; }
     
    -		status_t Wait(bool interruptable, Semaphore *sem = NULL);
    +		status_t Wait(bool interruptable);
     
     		bool IsFirstInQueues();
     
    @@ -97,12 +97,12 @@
     		status_t Error() const	{ return fError; }
     
     	private:
    -		Semaphore		*fSemaphore;
    -		tty_cookie		*fCookie;
    -		status_t		fError;
    -		RequestQueue	*fRequestQueues[2];
    -		Request			fRequests[2];
    -		size_t			fBytesNeeded;
    +		ConditionVariable<>*	fConditionVariable;
    +		tty_cookie*				fCookie;
    +		status_t				fError;
    +		RequestQueue*			fRequestQueues[2];
    +		Request					fRequests[2];
    +		size_t					fBytesNeeded;
     };
     
     
    @@ -151,7 +151,6 @@
     extern struct mutex gGlobalTTYLock;
     extern struct mutex gTTYCookieLock;
     extern struct recursive_lock gTTYRequestLock;
    -extern SemaphorePool *gSemaphorePool;
     
     
     // functions available for master/slave TTYs
    
    
    
    From bonefish at mail.berlios.de  Fri Sep 28 23:40:25 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Fri, 28 Sep 2007 23:40:25 +0200
    Subject: [Haiku-commits] r22358 - haiku/trunk/headers/private/kernel
    Message-ID: <200709282140.l8SLePKK026090@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-28 23:40:25 +0200 (Fri, 28 Sep 2007)
    New Revision: 22358
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22358&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/condition_variable.h
    Log:
    Set default template argument to void, so that one doesn't need to
    bother.
    
    
    Modified: haiku/trunk/headers/private/kernel/condition_variable.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/condition_variable.h	2007-09-28 21:37:31 UTC (rev 22357)
    +++ haiku/trunk/headers/private/kernel/condition_variable.h	2007-09-28 21:40:25 UTC (rev 22358)
    @@ -95,7 +95,7 @@
     };
     
     
    -template
    +template
     class ConditionVariable : private PrivateConditionVariable {
     public:
     	inline	void				Publish(const Type* object,
    @@ -107,7 +107,7 @@
     };
     
     
    -template
    +template
     class ConditionVariableEntry : public PrivateConditionVariableEntry {
     public:
     	inline	bool				Add(const Type* object,
    
    
    
    From axeld at mail.berlios.de  Fri Sep 28 23:47:31 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Fri, 28 Sep 2007 23:47:31 +0200
    Subject: [Haiku-commits] r22359 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709282147.l8SLlVTd026477@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-28 23:47:31 +0200 (Fri, 28 Sep 2007)
    New Revision: 22359
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22359&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    Log:
    The "priority" of a handler is no longer ignored: the handlers are now
    inserted into the list according to their priority; higher priority
    handlers are now called first.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-28 21:40:25 UTC (rev 22358)
    +++ haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-28 21:47:31 UTC (rev 22359)
    @@ -24,7 +24,6 @@
     #	define TRACE(x) ;
     #endif
     
    -// TODO: the priority is currently ignored, and probably can be removed
     
     struct low_memory_handler : public DoublyLinkedListLinkImpl {
     	low_memory_func	function;
    @@ -174,22 +173,43 @@
     }
     
     
    +/*! Registers a low memory handler. The higher the \a priority, the earlier
    +	the handler will be called in low memory situations.
    +*/
     status_t
    -register_low_memory_handler(low_memory_func function, void *data, int32 priority)
    +register_low_memory_handler(low_memory_func function, void *data,
    +	int32 priority)
     {
     	TRACE(("register_low_memory_handler(function = %p, data = %p)\n",
     		function, data));
     
    -	low_memory_handler *handler = (low_memory_handler *)malloc(sizeof(low_memory_handler));
    -	if (handler == NULL)
    +	low_memory_handler *newHandler = (low_memory_handler *)malloc(
    +		sizeof(low_memory_handler));
    +	if (newHandler == NULL)
     		return B_NO_MEMORY;
     
    -	handler->function = function;
    -	handler->data = data;
    -	handler->priority = priority;
    +	newHandler->function = function;
    +	newHandler->data = data;
    +	newHandler->priority = priority;
     
     	MutexLocker locker(&sLowMemoryMutex);
    -	sLowMemoryHandlers.Add(handler);
    +
    +	// sort it in after priority (higher priority comes first)
    +
    +	HandlerList::ReverseIterator iterator
    +		= sLowMemoryHandlers.GetReverseIterator();
    +	low_memory_handler *last = NULL;
    +	while (iterator.HasNext()) {
    +		low_memory_handler *handler = iterator.Next();
    +
    +		if (handler->priority >= priority) {
    +			sLowMemoryHandlers.Insert(last, newHandler);
    +			return B_OK;
    +		}
    +		last = handler;
    +	}
    +
    +	sLowMemoryHandlers.Add(newHandler, false);
     	return B_OK;
     }
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 01:44:03 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 01:44:03 +0200
    Subject: [Haiku-commits] r22360 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709282344.l8SNi3kJ016958@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 01:44:03 +0200 (Sat, 29 Sep 2007)
    New Revision: 22360
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22360&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h
    Log:
    Added byte swapping of identify device strings.
    Added capacity reporting.
    Wait for interrupts to finish transfers.
    Added lba 48-bit read support.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 21:47:31 UTC (rev 22359)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 23:44:03 UTC (rev 22360)
    @@ -10,6 +10,7 @@
     #include "scsi_cmds.h"
     
     #include 
    +#include 
     #include 
     #include 
     
    @@ -21,12 +22,20 @@
     	: fIndex(index)
     	, fRegs(&controller->fRegs->port[index])
     	, fArea(-1)
    +	, fRequestSem(-1)
    +	, fResponseSem(-1)
    +	, fCommandActive(false)
    +	, fHarddiskSize(0)
     {
    +	fRequestSem = create_sem(1, "ahci request");
    +	fResponseSem = create_sem(1, "ahci response");
     }
     				
     
     AHCIPort::~AHCIPort()
     {
    +	delete_sem(fRequestSem);
    +	delete_sem(fResponseSem);
     }
     
     	
    @@ -256,6 +265,9 @@
     	uint32 is = fRegs->is;
     	TRACE("AHCIPort::Interrupt port %d, status %#08lx\n", fIndex, is);
     
    +	if (fCommandActive)	
    +		release_sem_etc(fResponseSem, 1, B_RELEASE_IF_WAITING_ONLY | B_DO_NOT_RESCHEDULE);
    +
     	// clear interrupts
     	fRegs->is = is;
     }
    @@ -284,6 +296,7 @@
     	while (sgCount > 0) {
     		size_t size = sgTable->size;
     		void *address = sgTable->address;
    +		TRACE("FillPrdTable: sg-entry addr %p, size %lu\n", address, size);
     		if ((uint32)address & 1) {
     			TRACE("AHCIPort::FillPrdTable: data alignment error\n");
     			return B_ERROR;
    @@ -294,6 +307,7 @@
     				TRACE("AHCIPort::FillPrdTable: prd table exhausted\n");
     				return B_ERROR;
     			}
    +			TRACE("FillPrdTable: prd-entry %u, addr %p, size %lu\n", *prdCount, address, bytes);
     			prdTable->dba  = LO32(address);
     			prdTable->dbau = HI32(address);
     			prdTable->res  = 0;
    @@ -312,6 +326,32 @@
     }
     
     
    +void
    +AHCIPort::StartTransfer()
    +{
    +	acquire_sem(fRequestSem);
    +	fCommandActive = true;
    +}
    +				
    +
    +status_t
    +AHCIPort::WaitForTransfer(int *status, bigtime_t timeout)
    +{
    +	status_t result = B_OK;
    +	if (acquire_sem_etc(fResponseSem, 1, B_RELATIVE_TIMEOUT, timeout) < B_OK) {
    +		result = B_TIMED_OUT;
    +	}
    +	fCommandActive = false;
    +	return result;
    +}
    +
    +
    +void
    +AHCIPort::FinishTransfer()
    +{
    +	release_sem(fRequestSem);
    +}
    +
     /*
     void
     AHCIPort::IdentifyDevice(scsi_ccb *request)
    @@ -422,6 +462,8 @@
     
     	memset(&ataData, 0, sizeof(ataData));
     
    +	StartTransfer();
    +
     	int prdEntrys;
     	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, &ataData, sizeof(ataData), true);
     
    @@ -443,10 +485,12 @@
     	fRegs->ci |= 1;
     	FlushPostedWrites();
     
    -	snooze(500000);
    +	int status;
    +	WaitForTransfer(&status, 100000);
     
     	TRACE("prdbc %ld\n", fCommandList->prdbc);
     
    +/*
     	TRACE("ci   0x%08lx\n", fRegs->ci);
     	TRACE("ie   0x%08lx\n", fRegs->ie);
     	TRACE("is   0x%08lx\n", fRegs->is);
    @@ -461,7 +505,7 @@
     	for (int i = 0; i < 512; i += 8) {
     		TRACE("  %02x %02x %02x %02x %02x %02x %02x %02x\n", data[i], data[i+1], data[i+2], data[i+3], data[i+4], data[i+5], data[i+6], data[i+7]);
     	}
    -
    +*/
     	scsiData.device_type = scsi_dev_direct_access;
     	scsiData.device_qualifier = scsi_periph_qual_connected;
     	scsiData.device_type_modifier = 0;
    @@ -479,22 +523,28 @@
     	scsiData.write_bus16 = true;
     	scsiData.write_bus32 = false;
     	scsiData.relative_address = false;
    +	memcpy(scsiData.vendor_ident, ataData.model_number, sizeof(scsiData.vendor_ident));
    +	memcpy(scsiData.product_ident, ataData.model_number + 8, sizeof(scsiData.product_ident));
    +	memcpy(scsiData.product_rev, ataData.serial_number, sizeof(scsiData.product_rev));
     
     	bool lba			= (ataData.words[49] & (1 << 9)) != 0;
     	bool lba48			= (ataData.words[83] & (1 << 10)) != 0;
     	uint32 sectors		= *(uint32*)&ataData.words[60];
     	uint64 sectors48	= *(uint64*)&ataData.words[100];
    -	uint64 size = !(lba || sectors) ? 0 : lba48 ? (sectors48 * 512) : (sectors * 512ull);
    +	fHarddiskSize		= !(lba || sectors) ? 0 : lba48 ? (sectors48 * 512) : (sectors * 512ull);
     
    -	TRACE("model_number: %40.40s\n", ataData.model_number);
    -	TRACE("serial_number: %20.20s\n", ataData.serial_number);
    -	TRACE("firmware_revision: %8.8s\n", ataData.firmware_revision);
    +	swap_words(ataData.model_number, sizeof(ataData.model_number));
    +	swap_words(ataData.serial_number, sizeof(ataData.serial_number));
    +	swap_words(ataData.firmware_revision, sizeof(ataData.firmware_revision));
    +
    +	TRACE("model_number: %.40s\n", ataData.model_number);
    +	TRACE("serial_number: %.20s\n", ataData.serial_number);
    +	TRACE("firmware_revision: %.8s\n", ataData.firmware_revision);
     	TRACE("lba %d, lba48 %d, sectors %lu, sectors48 %llu, size %llu\n",
    -		lba, lba48, sectors, sectors48, size);
    +		lba, lba48, sectors, sectors48, fHarddiskSize);
     
    -	memcpy(scsiData.vendor_ident, ataData.model_number, sizeof(scsiData.vendor_ident));
    -	memcpy(scsiData.product_ident, ataData.model_number + 8, sizeof(scsiData.product_ident));
    -	memcpy(scsiData.product_rev, ataData.serial_number, sizeof(scsiData.product_rev));
    +	if (fHarddiskSize >= (512ull * 0xffffffff))
    +		panic("ahci: SCSI emulation doesn't support harddisks larger than 2TB");
     
     	if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
     		request->subsys_status = SCSI_DATA_RUN_ERR;
    @@ -504,11 +554,101 @@
     		request->data_length = sizeof(scsiData); // ???
     	}
     
    +	FinishTransfer();
    +
     	gSCSI->finished(request, 1);
     }
     
     
     void
    +AHCIPort::ScsiReadCapacity(scsi_ccb *request)
    +{
    +	TRACE("AHCIPort::ScsiReadCapacity port %d\n", fIndex);
    +
    +	scsi_cmd_read_capacity *cmd = (scsi_cmd_read_capacity *)request->cdb;
    +	scsi_res_read_capacity scsiData;
    +
    +	if (cmd->pmi || cmd->lba) {
    +		TRACE("invalid request\n");
    +		return;
    +	}
    +
    +	uint64 sectorCount = fHarddiskSize / 512;
    +	uint32 sectorSize = 512;
    +	TRACE("sectorCount 0x%llx, sectorSize %lu\n", sectorCount, sectorSize);
    +/*
    +	while (sectorCount > 0xffffffff) {
    +		sectorCount /= 2;
    +		sectorSize *= 2;
    +	}
    +	TRACE("sectorCount 0x%llx, sectorSize %lu\n", sectorCount, sectorSize);
    +*/
    +
    +	scsiData.block_size = B_HOST_TO_BENDIAN_INT32(sectorSize);
    +	scsiData.lba = B_HOST_TO_BENDIAN_INT32(sectorCount - 1);
    +
    +	if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
    +		request->subsys_status = SCSI_DATA_RUN_ERR;
    +	} else {
    +		request->subsys_status = SCSI_REQ_CMP;
    +		request->data_resid = request->data_length - sizeof(scsiData);// ???
    +		request->data_length = sizeof(scsiData); // ???
    +	}
    +	gSCSI->finished(request, 1);
    +}
    +
    +
    +void
    +AHCIPort::ScsiReadWrite(scsi_ccb *request, uint64 position, size_t length, bool isWrite)
    +{
    +	TRACE("ScsiReadWrite: pos %llu, size %lu, isWrite %d\n", position, length, isWrite);
    +
    +	StartTransfer();
    +
    +	int prdEntrys;
    +	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, true);
    +
    +	TRACE("prdEntrys %d\n", prdEntrys);
    +	
    +	memset((void *)fCommandTable->cfis, 0, 5 * 4);
    +	fCommandTable->cfis[0] = 0x27;
    +	fCommandTable->cfis[1] = 0x80;
    +	fCommandTable->cfis[2] = 0x25;
    +	fCommandTable->cfis[4] = position & 0xff;
    +	fCommandTable->cfis[5] = (position >> 8) & 0xff;
    +	fCommandTable->cfis[6] = (position >> 16) & 0xff;
    +	fCommandTable->cfis[7] = 0x40; 
    +	fCommandTable->cfis[8] = (position >> 24) & 0xff;
    +	fCommandTable->cfis[9] = (position >> 32) & 0xff;
    +	fCommandTable->cfis[10] = (position >> 40) & 0xff;
    +	fCommandTable->cfis[12] = length & 0xff;
    +	fCommandTable->cfis[13] = (length >> 8) & 0xff;
    +
    +	fCommandList->prdtl_flags_cfl = 0;
    +	fCommandList->prdtl = prdEntrys;
    +//	fCommandList->c = 1;
    +	fCommandList->cfl = 5;
    +	fCommandList->prdbc = 0;
    +
    +	fRegs->ci |= 1;
    +	FlushPostedWrites();
    +
    +	int status;
    +	WaitForTransfer(&status, 100000);
    +
    +	TRACE("prdbc %ld\n", fCommandList->prdbc);
    +
    +	request->subsys_status = SCSI_REQ_CMP;
    +	request->data_resid = request->data_length - fCommandList->prdbc;// ???
    +	request->data_length = fCommandList->prdbc; // ???
    +
    +	FinishTransfer();
    +
    +	gSCSI->finished(request, 1);
    +}
    +
    +
    +void
     AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
     {
     
    @@ -530,6 +670,52 @@
     		case SCSI_OP_INQUIRY:
     			ScsiInquiry(request);
     			break;
    +		case SCSI_OP_READ_CAPACITY:
    +			ScsiReadCapacity(request);
    +			break;
    +		case SCSI_OP_READ_6:
    +		case SCSI_OP_WRITE_6:
    +		{
    +			scsi_cmd_rw_6 *cmd = (scsi_cmd_rw_6 *)request->cdb;
    +			uint32 position = ((uint32)cmd->high_lba << 16) | ((uint32)cmd->mid_lba << 8) | (uint32)cmd->low_lba;
    +			size_t length = cmd->length != 0 ? cmd->length : 256;
    +			bool isWrite = request->cdb[0] == SCSI_OP_WRITE_6;
    +			ScsiReadWrite(request, position, length, isWrite);
    +			break;
    +		}
    +		case SCSI_OP_READ_10:
    +		case SCSI_OP_WRITE_10:
    +		{
    +			scsi_cmd_rw_10 *cmd = (scsi_cmd_rw_10 *)request->cdb;
    +			uint32 position = B_BENDIAN_TO_HOST_INT32(cmd->lba);
    +			size_t length = B_BENDIAN_TO_HOST_INT16(cmd->length);
    +			bool isWrite = request->cdb[0] == SCSI_OP_WRITE_10;
    +			if (length) {
    +				ScsiReadWrite(request, position, length, isWrite);
    +			} else {
    +				TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
    +				request->subsys_status = SCSI_DEV_NOT_THERE;
    +				gSCSI->finished(request, 1);
    +			}
    +			break;
    +		}
    +		case SCSI_OP_READ_12:
    +		case SCSI_OP_WRITE_12:
    +		{
    +			scsi_cmd_rw_10 *cmd = (scsi_cmd_rw_10 *)request->cdb;
    +			uint32 position = B_BENDIAN_TO_HOST_INT32(cmd->lba);
    +			size_t length = B_BENDIAN_TO_HOST_INT32(cmd->length);
    +			bool isWrite = request->cdb[0] == SCSI_OP_WRITE_12;
    +			if (length) {
    +				ScsiReadWrite(request, position, length, isWrite);
    +			} else {
    +				TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
    +				request->subsys_status = SCSI_DEV_NOT_THERE;
    +				gSCSI->finished(request, 1);
    +			}
    +			break;
    +		}
    +
     		default:
     		request->subsys_status = SCSI_DEV_NOT_THERE;
     		gSCSI->finished(request, 1);
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-28 21:47:31 UTC (rev 22359)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-28 23:44:03 UTC (rev 22360)
    @@ -29,14 +29,19 @@
     private:
     	void		ScsiTestUnitReady(scsi_ccb *request);
     	void		ScsiInquiry(scsi_ccb *request);
    +	void		ScsiReadCapacity(scsi_ccb *request);
    +	void		ScsiReadWrite(scsi_ccb *request, uint64 position, size_t length, bool isWrite);
     
    -
     	status_t	ResetDevice();
     	status_t	PostResetDevice();
     	void		FlushPostedWrites();
     	void		DumpD2HFis();
     
    +	void		StartTransfer();
    +	status_t	WaitForTransfer(int *status, bigtime_t timeout);
    +	void		FinishTransfer();
     
    +
     //	uint8 *		SetCommandFis(volatile command_list_entry *cmd, volatile fis *fis, const void *data, size_t dataSize);
     	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc = false);
     	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, bool ioc = false);
    @@ -45,11 +50,15 @@
     	int						fIndex;
     	volatile ahci_port *	fRegs;
     	area_id					fArea;
    +	sem_id							fRequestSem;
    +	sem_id							fResponseSem;
    +	volatile bool					fCommandActive;
     
     	volatile fis *					fFIS;
     	volatile command_list_entry *	fCommandList;
     	volatile command_table *		fCommandTable;
     	volatile prd *					fPRDTable;
    +	uint64							fHarddiskSize;
     };
     
     inline void
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c	2007-09-28 21:47:31 UTC (rev 22359)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.c	2007-09-28 23:44:03 UTC (rev 22360)
    @@ -100,3 +100,15 @@
     		return B_ERROR;
     	return B_OK;
     }
    +
    +
    +void
    +swap_words(void *data, size_t size)
    +{
    +	uint16 *word = data;
    +	size_t count = size / 2;
    +	while (count--) {
    +		*word = (*word << 8) | (*word >> 8);
    +		word++;
    +	}
    +}
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h	2007-09-28 21:47:31 UTC (rev 22359)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/util.h	2007-09-28 23:44:03 UTC (rev 22360)
    @@ -16,6 +16,8 @@
     
     status_t sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data, size_t dataSize);
     
    +void swap_words(void *data, size_t size);
    +
     #ifdef __cplusplus
     }
     #endif
    
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 02:22:20 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 02:22:20 +0200
    Subject: [Haiku-commits] r22361 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709290022.l8T0MKDa019549@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 02:22:19 +0200 (Sat, 29 Sep 2007)
    New Revision: 22361
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22361&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    improved prd table handling
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-28 23:44:03 UTC (rev 22360)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 00:22:19 UTC (rev 22361)
    @@ -285,22 +285,23 @@
     	int peUsed;
     	for (peUsed = 0; pe[peUsed].size; peUsed++)
     		;
    -	return FillPrdTable(prdTable, prdCount, prdMax, pe, peUsed, ioc);
    +	return FillPrdTable(prdTable, prdCount, prdMax, pe, peUsed, dataSize, ioc);
     }
     
     
     status_t
    -AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, bool ioc)
    +AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize, bool ioc)
     {
     	*prdCount = 0;
    -	while (sgCount > 0) {
    -		size_t size = sgTable->size;
    +	while (sgCount > 0 && dataSize > 0) {
    +		size_t size = min_c(sgTable->size, dataSize);
     		void *address = sgTable->address;
     		TRACE("FillPrdTable: sg-entry addr %p, size %lu\n", address, size);
     		if ((uint32)address & 1) {
     			TRACE("AHCIPort::FillPrdTable: data alignment error\n");
     			return B_ERROR;
     		}
    +		dataSize -= size;
     		while (size > 0) {
     			size_t bytes = min_c(size, PRD_MAX_DATA_LENGTH);
     			if (*prdCount == prdMax) {
    @@ -606,7 +607,7 @@
     	StartTransfer();
     
     	int prdEntrys;
    -	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, true);
    +	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, length * 512, true);
     
     	TRACE("prdEntrys %d\n", prdEntrys);
     	
    @@ -626,7 +627,7 @@
     
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -//	fCommandList->c = 1;
    +	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    @@ -637,11 +638,15 @@
     	WaitForTransfer(&status, 100000);
     
     	TRACE("prdbc %ld\n", fCommandList->prdbc);
    +	TRACE("ci   0x%08lx\n", fRegs->ci);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
     
     	request->subsys_status = SCSI_REQ_CMP;
     	request->data_resid = request->data_length - fCommandList->prdbc;// ???
     	request->data_length = fCommandList->prdbc; // ???
     
    +	fRegs->ci &= ~1;
     	FinishTransfer();
     
     	gSCSI->finished(request, 1);
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-28 23:44:03 UTC (rev 22360)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-29 00:22:19 UTC (rev 22361)
    @@ -44,7 +44,7 @@
     
     //	uint8 *		SetCommandFis(volatile command_list_entry *cmd, volatile fis *fis, const void *data, size_t dataSize);
     	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc = false);
    -	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, bool ioc = false);
    +	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize, bool ioc = false);
     
     private:
     	int						fIndex;
    
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 02:34:09 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 02:34:09 +0200
    Subject: [Haiku-commits] r22363 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709290034.l8T0Y97v020343@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 02:34:09 +0200 (Sat, 29 Sep 2007)
    New Revision: 22363
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22363&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    don't set the "clear on RX_OK" bits
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 00:23:21 UTC (rev 22362)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 00:34:09 UTC (rev 22363)
    @@ -479,7 +479,7 @@
     
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -	fCommandList->c = 1;
    +//	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    @@ -631,7 +631,7 @@
     
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -	fCommandList->c = 1;
    +//	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 02:23:21 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 02:23:21 +0200
    Subject: [Haiku-commits] r22362 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709290023.l8T0NLhd019781@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 02:23:21 +0200 (Sat, 29 Sep 2007)
    New Revision: 22362
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22362&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    added debugging code
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 00:22:19 UTC (rev 22361)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 00:23:21 UTC (rev 22362)
    @@ -479,7 +479,7 @@
     
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -//	fCommandList->c = 1;
    +	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    @@ -490,6 +490,9 @@
     	WaitForTransfer(&status, 100000);
     
     	TRACE("prdbc %ld\n", fCommandList->prdbc);
    +	TRACE("ci   0x%08lx\n", fRegs->ci);
    +	TRACE("is   0x%08lx\n", fRegs->is);
    +	TRACE("serr 0x%08lx\n", fRegs->serr);
     
     /*
     	TRACE("ci   0x%08lx\n", fRegs->ci);
    @@ -555,6 +558,7 @@
     		request->data_length = sizeof(scsiData); // ???
     	}
     
    +	fRegs->ci &= ~1;
     	FinishTransfer();
     
     	gSCSI->finished(request, 1);
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 08:46:30 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 08:46:30 +0200
    Subject: [Haiku-commits] r22364 -
    	haiku/trunk/src/tests/servers/app/playground
    Message-ID: <200709290646.l8T6kUWQ018080@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 08:46:29 +0200 (Sat, 29 Sep 2007)
    New Revision: 22364
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22364&view=rev
    
    Modified:
       haiku/trunk/src/tests/servers/app/playground/Jamfile
       haiku/trunk/src/tests/servers/app/playground/ObjectView.cpp
       haiku/trunk/src/tests/servers/app/playground/ObjectWindow.cpp
       haiku/trunk/src/tests/servers/app/playground/States.h
    Log:
    * when selecting objects in the list view, the controls will adapt to the
      object properties
    
    
    Modified: haiku/trunk/src/tests/servers/app/playground/Jamfile
    ===================================================================
    --- haiku/trunk/src/tests/servers/app/playground/Jamfile	2007-09-29 00:34:09 UTC (rev 22363)
    +++ haiku/trunk/src/tests/servers/app/playground/Jamfile	2007-09-29 06:46:29 UTC (rev 22364)
    @@ -11,6 +11,7 @@
     	ObjectView.cpp
     	ObjectWindow.cpp
     	States.cpp
    +#	StatusView.cpp
     	: be
     ;
     
    
    Modified: haiku/trunk/src/tests/servers/app/playground/ObjectView.cpp
    ===================================================================
    --- haiku/trunk/src/tests/servers/app/playground/ObjectView.cpp	2007-09-29 00:34:09 UTC (rev 22363)
    +++ haiku/trunk/src/tests/servers/app/playground/ObjectView.cpp	2007-09-29 06:46:29 UTC (rev 22364)
    @@ -99,9 +99,21 @@
     {
     	FillRect(updateRect, B_SOLID_LOW);
     
    -	rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
    -	rgb_color shadow = tint_color(noTint, B_DARKEN_2_TINT);
    -	rgb_color light = tint_color(noTint, B_LIGHTEN_MAX_TINT);
    +//	SetHighColor(0, 0, 0);
    +//	for (float i = 10; i < 200; i += 4.25) {
    +//		StrokeLine(BPoint(i, 10), BPoint(i, 200));
    +//		StrokeLine(BPoint(10, i), BPoint(200, i));
    +//	}
    +//
    +//	SetHighColor(0, 0, 50);
    +//	for (float i = 10; i < 200; i += 8.25) {
    +//		FillRect(BRect(i, 10 + 230, i + 2, 200 + 230));
    +//		FillRect(BRect(10, i + 230, 200, i + 2 + 230));
    +//	}
    +//
    +//	rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
    +//	rgb_color shadow = tint_color(noTint, B_DARKEN_2_TINT);
    +//	rgb_color light = tint_color(noTint, B_LIGHTEN_MAX_TINT);
     
     	BRect r(Bounds());
     
    @@ -142,7 +154,7 @@
     //printf("rendering %ld small rects (region: %ld): %lld\n", counter,
     //region.CountRects(), system_time() - now);
     
    -	SetDrawingMode(B_OP_COPY);
    +	SetDrawingMode(B_OP_OVER);
     	SetHighColor(255, 0, 0, 128);
     
     	const char* message = "Click and drag to draw an object";
    @@ -154,6 +166,20 @@
     //snooze(1000);
     //
     //bigtime_t now = system_time();
    +//
    +//#ifdef __HAIKU__
    +//	BFont font;
    +//	GetFont(&font);
    +//	font.SetFalseBoldWidth(1.0);
    +//	SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
    +//	SetHighColor(0, 0, 0);
    +//	DrawString(message, p);
    +//
    +//	font.SetFalseBoldWidth(0.0);
    +//	SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
    +//	SetHighColor(255, 0, 0);
    +//#endif // __HAIKU__
    +
     	DrawString(message, p);
     
     //Sync();
    @@ -275,6 +301,10 @@
     ObjectView::MouseMoved(BPoint where, uint32 transit,
     					   const BMessage* dragMessage)
     {
    +//	BRect dirty(where, where);
    +//	dirty.InsetBy(-10, -10);
    +//	Invalidate(dirty);
    +	
     if (dragMessage) {
     //printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
     //Window()->CurrentMessage()->PrintToStream();
    @@ -442,7 +472,7 @@
     		color.alpha != fColor.alpha) {
     
     		fColor = color;
    -	
    +
     		if (fState) {
     			fState->SetColor(fColor);
     			Invalidate(fState->Bounds());
    
    Modified: haiku/trunk/src/tests/servers/app/playground/ObjectWindow.cpp
    ===================================================================
    --- haiku/trunk/src/tests/servers/app/playground/ObjectWindow.cpp	2007-09-29 00:34:09 UTC (rev 22363)
    +++ haiku/trunk/src/tests/servers/app/playground/ObjectWindow.cpp	2007-09-29 06:46:29 UTC (rev 22364)
    @@ -28,6 +28,7 @@
     
     #include "ObjectView.h"
     #include "States.h"
    +//#include "StatusView.h"
     
     #include "ObjectWindow.h"
     
    @@ -94,7 +95,7 @@
     
     	virtual void SelectionChanged()
     			{
    -				printf("SelectionChanged() - first selected: %ld\n", CurrentSelection(0));
    +//				printf("SelectionChanged() - first selected: %ld\n", CurrentSelection(0));
     			}
     };
     
    @@ -171,6 +172,12 @@
     		scrollBar->SetRange(0.0, fObjectView->Bounds().Width());
     		scrollBar->SetProportion(0.5);
     //		scrollBar->SetRange(0.0, 0.0);
    +//		b = scrollBar->Frame();
    +//		b.right = b.left + 50;
    +//		scrollBar->ResizeBy(-51, 0);
    +//		scrollBar->MoveBy(51, 0);
    +//		StatusView* statusView = new StatusView(b, scrollBar);
    +//		scrollView->AddChild(statusView);
     	}
     	AddChild(scrollView);
     
    @@ -444,6 +451,8 @@
     		case MSG_OBJECT_SELECTED:
     			if (ObjectItem* item = (ObjectItem*)fObjectLV->ItemAt(fObjectLV->CurrentSelection(0))) {
     				fObjectView->SetState(item->Object());
    +				fObjectView->SetStateColor(item->Object()->Color());
    +				_UpdateControls();
     			} else
     				fObjectView->SetState(NULL);
     			break;
    
    Modified: haiku/trunk/src/tests/servers/app/playground/States.h
    ===================================================================
    --- haiku/trunk/src/tests/servers/app/playground/States.h	2007-09-29 00:34:09 UTC (rev 22363)
    +++ haiku/trunk/src/tests/servers/app/playground/States.h	2007-09-29 06:46:29 UTC (rev 22364)
    @@ -32,6 +32,8 @@
     								{ return fTracking; }
     
     			void			SetColor(rgb_color color);
    +			rgb_color		Color() const
    +								{ return fColor; }
     			void			SetDrawingMode(drawing_mode mode);
     			void			SetFill(bool fill);
     			void			SetPenSize(float penSize);
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 09:19:33 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 09:19:33 +0200
    Subject: [Haiku-commits] r22365 - haiku/trunk/src/preferences/network
    Message-ID: <200709290719.l8T7JXP6019421@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 09:19:32 +0200 (Sat, 29 Sep 2007)
    New Revision: 22365
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22365&view=rev
    
    Modified:
       haiku/trunk/src/preferences/network/settings.cpp
    Log:
    * removed unnecessary whitespaces, small style cleanups
    
    
    Modified: haiku/trunk/src/preferences/network/settings.cpp
    ===================================================================
    --- haiku/trunk/src/preferences/network/settings.cpp	2007-09-29 06:46:29 UTC (rev 22364)
    +++ haiku/trunk/src/preferences/network/settings.cpp	2007-09-29 07:19:32 UTC (rev 22365)
    @@ -40,7 +40,6 @@
     Settings::~Settings()
     {
     	close(fSocket);
    -	
     }
     
     bool
    @@ -48,9 +47,9 @@
     {
     	//This function is used for talking direct to the stack. 
     	//It?s used by _ShowConfiguration.
    -	
    +
     	const char* name = fName.String();
    -	
    +
     	if (strlen(name) > IF_NAMESIZE)
     		return false;
     
    @@ -62,82 +61,73 @@
     void
     Settings::ReadConfiguration()
     {
    -	
     	ifreq request;
     	if (!_PrepareRequest(request))
     		return;
    -		
    +
     	BString text = "dummy";
     	char address[32];
     	sockaddr_in* inetAddress = NULL;
    -	
    +
     	// Obtain IP.	
    -	if (ioctl(fSocket, SIOCGIFADDR, &request,
    -			sizeof(request)) < 0) {
    +	if (ioctl(fSocket, SIOCGIFADDR, &request, sizeof(request)) < 0)
     		return;
    -	}
     
     	inetAddress = (sockaddr_in*)&request.ifr_addr;
    -	if (inet_ntop(AF_INET, &inetAddress->sin_addr, address,
    -				sizeof(address)) == NULL) {
    -			return;
    -		}
    -		
    -	fIP = address;
    +	if (inet_ntop(AF_INET, &inetAddress->sin_addr, address,	
    +			sizeof(address)) == NULL) {
    +		return;
    +	}
     	
    +	fIP = address;
    +
     	// Obtain netmask.
     	if (ioctl(fSocket, SIOCGIFNETMASK, &request,
     			sizeof(request)) < 0) {
     		return;
     	}
    -	
    +
     	inetAddress = (sockaddr_in*)&request.ifr_mask;
     	if (inet_ntop(AF_INET, &inetAddress->sin_addr, address,
    -				sizeof(address)) == NULL) {
    -			return;
    -		}
    -		
    +			sizeof(address)) == NULL) {
    +		return;
    +	}
    +
     	fNetmask = address;
    -	
    +
     	// Obtain gateway
    -	
    -	char* gwAddress;
     	ifconf config;
     	config.ifc_len = sizeof(config.ifc_value);
     	if (ioctl(fSocket, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
     		return;
    -		
    +
     	uint32 size = (uint32)config.ifc_value;
     	if (size == 0)
     		return;
    -	
    +
     	void *buffer = malloc(size);
     	if (buffer == NULL)
     		return;
    -	
    +
     	MemoryDeleter bufferDeleter(buffer);
     	config.ifc_len = size;
     	config.ifc_buf = buffer;
    -	
    +
     	if (ioctl(fSocket, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
     		return;
    -		
    +
     	ifreq *interface = (ifreq *)buffer;
     	ifreq *end = (ifreq *)((uint8 *)buffer + size);
    -	
    -	
    +
    +
     	while (interface < end) {
     		route_entry& route = interface->ifr_route;
    -	
    -		
    +
     		if (route.flags & RTF_GATEWAY) {
    -			inetAddress = (sockaddr_in *)route.gateway;
    -					
    -			
    -			gwAddress = inet_ntoa(inetAddress->sin_addr);
    -			fGateway = gwAddress;
    +			inetAddress = (sockaddr_in*)route.gateway;
    +			fGateway = inet_ntoa(inetAddress->sin_addr);
     		}
    -		
    +
     		int32 addressSize = 0;
     		if (route.destination != NULL)
     			addressSize += route.destination->sa_len;
    @@ -145,24 +135,17 @@
     			addressSize += route.mask->sa_len;
     		if (route.gateway != NULL)
     			addressSize += route.gateway->sa_len;
    -			
    +
     		interface = (ifreq *)((addr_t)interface + 
     			IF_NAMESIZE + sizeof(route_entry) + addressSize);
    -	
     	}
    -	
    -	bufferDeleter.Detach();
    -	free(buffer);	
    -	
    +
     	uint32 flags = 0;
     	if (ioctl(fSocket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0)
     		flags = request.ifr_flags;
    -		
    -	if ((flags & IFF_AUTO_CONFIGURED) != 0)
    -		fAuto = true;
    -	else
    -		fAuto = false;
    -	
    +
    +	fAuto = flags & IFF_AUTO_CONFIGURED;
    +
     	// read resolv.conf for the dns.
     	fNameservers.MakeEmpty();
     
    @@ -171,7 +154,7 @@
     	(line[sizeof(name) - 1] == ' ' || \
     	 line[sizeof(name) - 1] == '\t'))
     
    -		
    +
     	register FILE *fp = fopen("/etc/resolv.conf", "r");
     	if (fp == NULL) {
     		fprintf(stderr, "failed to open '/etc/resolv.conf' to "
    @@ -184,7 +167,7 @@
     	register char *cp; //, **pp;
     //	register int n;
     	int MAXNS = 2;
    -	
    +
     	// read the config file
     	while (fgets(buf, sizeof(buf), fp) != NULL) {
     		// skip comments
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 09:22:18 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 09:22:18 +0200
    Subject: [Haiku-commits] r22366 - haiku/trunk/src/preferences/network
    Message-ID: <200709290722.l8T7MI7i019633@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 09:22:18 +0200 (Sat, 29 Sep 2007)
    New Revision: 22366
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22366&view=rev
    
    Modified:
       haiku/trunk/src/preferences/network/EthernetSettingsView.cpp
    Log:
    * don't know which option to pass to fopen() in order to create a file if it
      doesn't exist, so I just used a BFile instead... this should fix part of
      ticket #1423, if someone wants to look into the gateway retrieval
      (settings.cpp) to fix the other half of the bug, that would be great
    
    
    Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp
    ===================================================================
    --- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp	2007-09-29 07:19:32 UTC (rev 22365)
    +++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp	2007-09-29 07:22:18 UTC (rev 22366)
    @@ -345,22 +345,28 @@
     void
     EthernetSettingsView::_SaveDNSConfiguration()
     {
    -	FILE* fp = fopen("/etc/resolv.conf", "w");
    -	if (fp == NULL)
    +	BFile file("/etc/resolv.conf",
    +		B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
    +	if (file.InitCheck() < B_OK) {
    +		fprintf(stderr, "failed to open /etc/resolv.conf for writing: %s\n",
    +			strerror(file.InitCheck()));
     		return;
    +	}
     
    -	fprintf(fp, "# Generated by Network Preflet\n");
    +	BString content("# Generated by Network Preflet\n");
     	// loop over all adapters
     	for (int i = 0; i < fSettings.CountItems(); i++) {
     		Settings* settings = fSettings.ItemAt(i);
     		for (int j = 0; j < settings->fNameservers.CountItems(); j++) {
     			if (settings->fNameservers.ItemAt(j)->Length() > 0) {
    -				fprintf(fp, "nameserver\t%s\n", 
    -					settings->fNameservers.ItemAt(j)->String());
    +				content << "nameserver\t"
    +					<< settings->fNameservers.ItemAt(j)->String()
    +					<< "\n";
     			}
     		}
     	}
    -	fclose(fp);	
    +
    +	file.Write(content.String(), content.Length());
     }
     
     
    
    
    
    From bonefish at cs.tu-berlin.de  Sat Sep 29 12:08:14 2007
    From: bonefish at cs.tu-berlin.de (Ingo Weinhold)
    Date: Sat, 29 Sep 2007 12:08:14 +0200
    Subject: [Haiku-commits] r22366 - haiku/trunk/src/preferences/network
    In-Reply-To: <200709290722.l8T7MI7i019633@sheep.berlios.de>
    References: <200709290722.l8T7MI7i019633@sheep.berlios.de>
    Message-ID: <20070929120814.772.1@cs.tu-berlin.de>
    
    
    On 2007-09-29 at 09:22:18 [+0200], stippi at BerliOS  
    wrote:
    > Author: stippi
    > Date: 2007-09-29 09:22:18 +0200 (Sat, 29 Sep 2007)
    > New Revision: 22366
    > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22366&view=rev
    > 
    > Modified:
    >    haiku/trunk/src/preferences/network/EthernetSettingsView.cpp
    > Log:
    > * don't know which option to pass to fopen() in order to create a file if it
    >   doesn't exist,
    
    Actually "w" already should. If it doesn't, this is a bug.
    
    BTW, always handy:
      http://www.opengroup.org/onlinepubs/009695399/toc.htm
    
    CU, Ingo
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 14:14:45 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 14:14:45 +0200
    Subject: [Haiku-commits] r22367 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709291214.l8TCEjrP019914@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 14:14:45 +0200 (Sat, 29 Sep 2007)
    New Revision: 22367
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22367&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    check for device presence before executing commands
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 07:22:18 UTC (rev 22366)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 12:14:45 UTC (rev 22367)
    @@ -669,6 +669,13 @@
     		gSCSI->finished(request, 1);
     		return;
     	}
    +
    +	if ((fRegs->ssts & 0xf) != 0x3) {
    +		TRACE("no such device!\n");
    +		request->subsys_status = SCSI_DEV_NOT_THERE;
    +		gSCSI->finished(request, 1);
    +		return;
    +	}
     	
     	request->subsys_status = SCSI_REQ_CMP;
     
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 14:54:19 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 14:54:19 +0200
    Subject: [Haiku-commits] r22368 - haiku/trunk/src/kits/interface
    Message-ID: <200709291254.l8TCsJXT022461@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 14:54:19 +0200 (Sat, 29 Sep 2007)
    New Revision: 22368
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22368&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/Menu.cpp
    Log:
    * very minor cosmetic change
    
    
    Modified: haiku/trunk/src/kits/interface/Menu.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/Menu.cpp	2007-09-29 12:14:45 UTC (rev 22367)
    +++ haiku/trunk/src/kits/interface/Menu.cpp	2007-09-29 12:54:19 UTC (rev 22368)
    @@ -1084,7 +1084,7 @@
     
     void
     BMenu::GetItemMargins(float *left, float *top, float *right,
    -						   float *bottom) const
    +	float *bottom) const
     {
     	if (left != NULL)
     		*left = fPad.left;
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 14:55:19 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 14:55:19 +0200
    Subject: [Haiku-commits] r22369 - haiku/trunk/src/kits/interface
    Message-ID: <200709291255.l8TCtJKR022577@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 14:55:19 +0200 (Sat, 29 Sep 2007)
    New Revision: 22369
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22369&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/RegionSupport.cpp
    Log:
    * slight code style fix, but that file would need a complete cleanup to be
      style compliant...
    
    
    Modified: haiku/trunk/src/kits/interface/RegionSupport.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/RegionSupport.cpp	2007-09-29 12:54:19 UTC (rev 22368)
    +++ haiku/trunk/src/kits/interface/RegionSupport.cpp	2007-09-29 12:55:19 UTC (rev 22369)
    @@ -1104,34 +1104,28 @@
      *-----------------------------------------------------------------------
      */
     int
    -BRegion::Support::miUnionNonO (
    -    register BRegion*	pReg,
    -    register clipping_rect*	r,
    -    clipping_rect*  	  	rEnd,
    -    register int  	top,
    -    register int  	bottom)
    +BRegion::Support::miUnionNonO(register BRegion* pReg,
    +	register clipping_rect* r, clipping_rect* rEnd,
    +    register int top, register int bottom)
     {
    -    register clipping_rect*	pNextRect;
    +	register clipping_rect*	pNextRect = &pReg->fData[pReg->fCount];
     
    -    pNextRect = &pReg->fData[pReg->fCount];
    +	assert(top < bottom);
     
    -    assert(top < bottom);
    +	while (r != rEnd) {
    +		assert(r->left < r->right);
    +		MEMCHECK(pReg, pNextRect, pReg->fData);
    +		pNextRect->left = r->left;
    +		pNextRect->top = top;
    +		pNextRect->right = r->right;
    +		pNextRect->bottom = bottom;
    +		pReg->fCount += 1;
    +		pNextRect++;
     
    -    while (r != rEnd)
    -    {
    -	assert(r->left < r->right);
    -	MEMCHECK(pReg, pNextRect, pReg->fData);
    -	pNextRect->left = r->left;
    -	pNextRect->top = top;
    -	pNextRect->right = r->right;
    -	pNextRect->bottom = bottom;
    -	pReg->fCount += 1;
    -	pNextRect++;
    -
    -	assert(pReg->fCount<=pReg->fDataSize);
    -	r++;
    -    }
    -    return 0;	/* lint */
    +		assert(pReg->fCount<=pReg->fDataSize);
    +		r++;
    +	}
    +	return 0;
     }
     
     
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 14:58:59 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 14:58:59 +0200
    Subject: [Haiku-commits] r22370 - haiku/trunk/src/kits/interface
    Message-ID: <200709291258.l8TCwxWb022778@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 14:58:59 +0200 (Sat, 29 Sep 2007)
    New Revision: 22370
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22370&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/StatusBar.cpp
    Log:
    * some simplifications in the code, I'm not sure if it supported NULL texts as
      the BeBook mentions it does
    * make sure the view is invalidated on resize
    * needs more fixes (for example GetPreferredSize() does not take everything
      into account)
    
    
    Modified: haiku/trunk/src/kits/interface/StatusBar.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/StatusBar.cpp	2007-09-29 12:55:19 UTC (rev 22369)
    +++ haiku/trunk/src/kits/interface/StatusBar.cpp	2007-09-29 12:58:59 UTC (rev 22370)
    @@ -91,6 +91,8 @@
     
     	fBarColor = kDefaultBarColor;
     	fCustomBarHeight = false;
    +
    +	SetFlags(Flags() | B_FRAME_EVENTS);
     }
     
     
    @@ -356,12 +358,8 @@
     void
     BStatusBar::SetTo(float value, const char* text, const char* trailingText)
     {
    -	if (text != NULL)
    -		_SetTextData(fText, fTextWidth, text, fLabelWidth, false);
    -	if (trailingText != NULL) {
    -		_SetTextData(fTrailingText, fTrailingTextWidth, trailingText,
    -			fTrailingLabelWidth, true);
    -	}
    +	SetText(text);
    +	SetTrailingText(trailingText);
     
     	if (value > fMax)
     		value = fMax;
    @@ -527,6 +525,7 @@
     BStatusBar::FrameResized(float newWidth, float newHeight)
     {
     	BView::FrameResized(newWidth, newHeight);
    +	Invalidate();
     }
     
     
    @@ -656,6 +655,9 @@
     BStatusBar::_SetTextData(BString& text, float& width, const char* source,
     	float position, bool rightAligned)
     {
    +	if (source == NULL)
    +		source = "";
    +
     	// If there were no changes, we don't have to do anything
     	if (text == source)
     		return;
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 15:00:25 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 15:00:25 +0200
    Subject: [Haiku-commits] r22371 - haiku/trunk/src/kits/interface
    Message-ID: <200709291300.l8TD0POl022911@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 15:00:24 +0200 (Sat, 29 Sep 2007)
    New Revision: 22371
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22371&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/MenuItem.cpp
    Log:
    * improvement to checkmark and submenu indicator layout and drawing (layout
      takes menu margins into account, drawing is now fully scalable)
    
    
    Modified: haiku/trunk/src/kits/interface/MenuItem.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/MenuItem.cpp	2007-09-29 12:58:59 UTC (rev 22370)
    +++ haiku/trunk/src/kits/interface/MenuItem.cpp	2007-09-29 13:00:24 UTC (rev 22371)
    @@ -667,22 +667,30 @@
     	fSuper->PushState();
     
     	BRect r(fBounds);
    -	r.right = r.left + r.Height();
    -	r.top += 2;
    -	r.bottom -= 2;
    +	float leftMargin;
    +	fSuper->GetItemMargins(&leftMargin, NULL, NULL, NULL);
    +	r.right = r.left + leftMargin - 3;
     	r.left += 1;
    -	r.right -= 5;
     
    +	BPoint center(floorf((r.left + r.right) / 2.0),
    +		floorf((r.top + r.bottom) / 2.0));
    +
    +	float size = min_c(r.Height() - 2, r.Width());
    +	r.top = floorf(center.y - size / 2 + 0.5);
    +	r.bottom = floorf(center.y + size / 2 + 0.5);
    +	r.left = floorf(center.x - size / 2 + 0.5);
    +	r.right = floorf(center.x + size / 2 + 0.5);
    +
     	fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
    -	fSuper->FillRect(r);
    +	fSuper->FillRoundRect(r, 2, 2);
     
    -	BPoint center(floorf((r.left + r.right) / 2.0) + 0.5,
    -				  floorf((r.top + r.bottom) / 2.0) + 0.5);
    -		// NOTE: center is on X.5, Y.5 on purpose!
     	BShape arrowShape;
    -	arrowShape.MoveTo(BPoint(center.x - 4, center.y - 1.5));
    -	arrowShape.LineTo(BPoint(center.x - 1, center.y + 2.0));
    -	arrowShape.LineTo(BPoint(center.x + 4, center.y - 3.5));
    +	center.x += 0.5;
    +	center.y += 0.5;
    +	size *= 0.3;
    +	arrowShape.MoveTo(BPoint(center.x - size, center.y - size * 0.25));
    +	arrowShape.LineTo(BPoint(center.x - size * 0.25, center.y + size));
    +	arrowShape.LineTo(BPoint(center.x + size, center.y - size));
     
     	fSuper->SetDrawingMode(B_OP_OVER);
     	fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
    @@ -765,23 +773,35 @@
     	fSuper->PushState();
     
     	BRect r(fBounds);
    -	r.left = r.right - r.Height();
    -	r.InsetBy(2.0, 2.0);
    +	float rightMargin;
    +	fSuper->GetItemMargins(NULL, NULL, &rightMargin, NULL);
    +	r.left = r.right - rightMargin + 3;
    +	r.right -= 1;
     
    +	BPoint center(floorf((r.left + r.right) / 2.0),
    +		floorf((r.top + r.bottom) / 2.0));
    +
    +	float size = min_c(r.Height() - 2, r.Width());
    +	r.top = floorf(center.y - size / 2 + 0.5);
    +	r.bottom = floorf(center.y + size / 2 + 0.5);
    +	r.left = floorf(center.x - size / 2 + 0.5);
    +	r.right = floorf(center.x + size / 2 + 0.5);
    +
     	fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
    -	fSuper->FillRect(r);
    +	fSuper->FillRoundRect(r, 2, 2);
     
    -	BPoint center(floorf((r.left + r.right) / 2.0) + 0.5,
    -				  floorf((r.top + r.bottom) / 2.0) + 0.5);
    -		// NOTE: center is on X.5, Y.5 on purpose!
     	BShape arrowShape;
    -	arrowShape.MoveTo(BPoint(center.x - 1.5, center.y - 3));
    -	arrowShape.LineTo(BPoint(center.x + 2.0, center.y));
    -	arrowShape.LineTo(BPoint(center.x - 1.5, center.y + 3));
    +	center.x += 0.5;
    +	center.y += 0.5;
    +	size *= 0.25;
    +	float hSize = size * 0.7;
    +	arrowShape.MoveTo(BPoint(center.x - hSize, center.y - size));
    +	arrowShape.LineTo(BPoint(center.x + hSize, center.y));
    +	arrowShape.LineTo(BPoint(center.x - hSize, center.y + size));
     
     	fSuper->SetDrawingMode(B_OP_OVER);
     	fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT));
    -	fSuper->SetPenSize(2.0);
    +	fSuper->SetPenSize(ceilf(size * 0.4));
     	// NOTE: StrokeShape() offsets the shape by the current pen position,
     	// it is not documented in the BeBook, but it is true!
     	fSuper->MovePenTo(B_ORIGIN);
    
    
    
    From stippi at mail.berlios.de  Sat Sep 29 16:06:20 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sat, 29 Sep 2007 16:06:20 +0200
    Subject: [Haiku-commits] r22373 - haiku/trunk/src/add-ons/accelerants/radeon
    Message-ID: <200709291406.l8TE6KEo025923@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-29 16:06:19 +0200 (Sat, 29 Sep 2007)
    New Revision: 22373
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22373&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c
    Log:
    * check for possible division by zero (just had a crash with divide error
      on another machine, don't know if this was really the cause, but it should
      be checked nevertheless I guess)
    
    
    Modified: haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c
    ===================================================================
    --- haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c	2007-09-29 14:06:04 UTC (rev 22372)
    +++ haiku/trunk/src/add-ons/accelerants/radeon/ProposeDisplayMode.c	2007-09-29 14:06:19 UTC (rev 22373)
    @@ -152,6 +152,9 @@
     	SHOW_FLOW( 4, "X %d, virtX %d", target->timing.h_display,  target->virtual_width);
     	SHOW_FLOW( 4, "fpRes %dx%d", flatpanel->panel_xres,  flatpanel->panel_yres);
     
    +	if (target->timing.h_total * target->timing.v_total == 0)
    +		return B_BAD_VALUE;
    +
     	// save refresh rate - we want to leave this (artifical) value untouched
     	// don't use floating point, we are in kernel mode
     	target_refresh = 
    
    
    
    From axeld at mail.berlios.de  Sat Sep 29 16:06:05 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sat, 29 Sep 2007 16:06:05 +0200
    Subject: [Haiku-commits] r22372 -
    	haiku/trunk/src/add-ons/kernel/file_systems/bfs
    Message-ID: <200709291406.l8TE65k8025889@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-29 16:06:04 +0200 (Sat, 29 Sep 2007)
    New Revision: 22372
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22372&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
       haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h
       haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp
    Log:
    * bfs_{read|write}_pages() now only try to lock - this fixes a possible
      deadlock whenever someone without a lock (like the page_writer()) is calling
      this function.
    * Added a new ReadWriteLock::TryLock() method.
    * Renamed bfs_read_vnode() and bfs_release_vnode() to bfs_get_vnode() and
      bfs_put_vnode() just like those functions are called in fs_interface.h.
    * Fixed a warning in BPlusTree::_SplitNode().
    
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp	2007-09-29 13:00:24 UTC (rev 22371)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp	2007-09-29 14:06:04 UTC (rev 22372)
    @@ -1002,7 +1002,7 @@
     	int32 keyIndex = *_keyIndex;	// can become less than zero!
     
     	if (keyIndex > node->NumKeys()) {
    -		FATAL(("key index out of bounds: %d, num keys: %d\n", keyIndex,
    +		FATAL(("key index out of bounds: %ld, num keys: %u\n", keyIndex,
     			node->NumKeys()));
     		return B_BAD_VALUE;
     	}
    
    Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h	2007-09-29 13:00:24 UTC (rev 22371)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Lock.h	2007-09-29 14:06:04 UTC (rev 22372)
    @@ -16,7 +16,7 @@
     
     
     // Configure here if and when real benaphores should be used
    -#define USE_BENAPHORE
    +//#define USE_BENAPHORE
     	// if defined, benaphores are used for the Semaphore/RecursiveLock classes
     //#	define FAST_LOCK
     	// the ReadWriteLock class uses a second Semaphore to
    @@ -285,16 +285,16 @@
     		{
     			if (atomic_add(&fCount, -1) <= 0)
     				return acquire_sem(fSemaphore);
    -			
    +
     			return B_OK;
     		}
    -		
    +
     		void Unlock()
     		{
     			if (atomic_add(&fCount, 1) < 0)
     				release_sem(fSemaphore);
     		}
    -		
    +
     		status_t LockWrite()
     		{
     			if (fWriteLock.Lock() < B_OK)
    @@ -313,7 +313,7 @@
     
     			return status;
     		}
    -		
    +
     		void UnlockWrite()
     		{
     			int32 readers = atomic_add(&fCount, MAX_READERS);
    @@ -377,7 +377,18 @@
     			}
     			return acquire_sem(fSemaphore);
     		}
    -		
    +
    +		status_t TryLock()
    +		{
    +			// This allows nested locking when holding a write lock
    +			thread_id currentThread = find_thread(NULL);
    +			if (currentThread == fOwner) {
    +				fOwnerCount++;
    +				return B_OK;
    +			}
    +			return acquire_sem_etc(fSemaphore, 1, B_RELATIVE_TIMEOUT, 0);
    +		}
    +
     		void Unlock()
     		{
     			thread_id currentThread = find_thread(NULL);
    @@ -386,7 +397,7 @@
     
     			release_sem(fSemaphore);
     		}
    -		
    +
     		status_t LockWrite()
     		{
     			thread_id currentThread = find_thread(NULL);
    @@ -401,7 +412,7 @@
     			}
     			return status;
     		}
    -		
    +
     		void UnlockWrite()
     		{
     			if (--fOwnerCount == 0) {
    
    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	2007-09-29 13:00:24 UTC (rev 22371)
    +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp	2007-09-29 14:06:04 UTC (rev 22372)
    @@ -225,11 +225,10 @@
     //	#pragma mark -
     
     
    -/**	Reads in the node from disk and creates an inode object from it.
    - */
    -
    +/*!	Reads in the node from disk and creates an inode object from it.
    +*/
     static status_t
    -bfs_read_vnode(void *_ns, ino_t id, void **_node, bool reenter)
    +bfs_get_vnode(void *_ns, ino_t id, void **_node, bool reenter)
     {
     	//FUNCTION_START(("ino_t = %Ld\n", id));
     	Volume *volume = (Volume *)_ns;
    @@ -271,11 +270,9 @@
     
     
     static status_t
    -bfs_release_vnode(void *_ns, void *_node, bool reenter)
    +bfs_put_vnode(void *_volume, void *_node, bool reenter)
     {
    -	//FUNCTION_START(("node = %p\n", _node));
    -
    -	Volume *volume = (Volume *)_ns;
    +	Volume *volume = (Volume *)_volume;
     	Inode *inode = (Inode *)_node;
     
     	// since a directory's size can be changed without having it opened,
    @@ -292,8 +289,7 @@
     	}
     
     	delete inode;
    -
    -	return B_NO_ERROR;
    +	return B_OK;
     }
     
     
    @@ -353,11 +349,13 @@
     	if (inode->FileCache() == NULL)
     		RETURN_ERROR(B_BAD_VALUE);
     
    -	if (!reenter)
    -		inode->Lock().Lock();
    +	if (!reenter) {
    +		if (inode->Lock().TryLock() < B_OK)
    +			return B_BUSY;
    +	}
     
    -	status_t status = file_cache_read_pages(inode->FileCache(), pos, vecs, count,
    -		_numBytes);
    +	status_t status = file_cache_read_pages(inode->FileCache(), pos, vecs,
    +		count, _numBytes);
     
     	if (!reenter)
     		inode->Lock().Unlock();
    @@ -375,11 +373,13 @@
     	if (inode->FileCache() == NULL)
     		RETURN_ERROR(B_BAD_VALUE);
     
    -	if (!reenter)
    -		inode->Lock().Lock();
    +	if (!reenter) {
    +		if (inode->Lock().TryLock() < B_OK)
    +			return B_BUSY;
    +	}
     
    -	status_t status = file_cache_write_pages(inode->FileCache(), pos, vecs, count,
    -		_numBytes);
    +	status_t status = file_cache_write_pages(inode->FileCache(), pos, vecs,
    +		count, _numBytes);
     
     	if (!reenter)
     		inode->Lock().Unlock();
    @@ -2161,8 +2161,8 @@
     	/* vnode operations */
     	&bfs_lookup,
     	&bfs_get_vnode_name,
    -	&bfs_read_vnode,
    -	&bfs_release_vnode,
    +	&bfs_get_vnode,
    +	&bfs_put_vnode,
     	&bfs_remove_vnode,
     
     	/* VM file access */
    
    
    
    From axeld at mail.berlios.de  Sat Sep 29 17:46:41 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sat, 29 Sep 2007 17:46:41 +0200
    Subject: [Haiku-commits] r22374 - in haiku/trunk: headers/private/kernel
    	src/system/kernel/slab src/system/kernel/vm
    Message-ID: <200709291546.l8TFkfYf030446@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-29 17:46:40 +0200 (Sat, 29 Sep 2007)
    New Revision: 22374
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22374&view=rev
    
    Modified:
       haiku/trunk/headers/private/kernel/vm_low_memory.h
       haiku/trunk/src/system/kernel/slab/Slab.cpp
       haiku/trunk/src/system/kernel/vm/vm.cpp
       haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    Log:
    * register_low_memory_handler() was called too early by several kernel
      components - now, we divide the initialization of that service into two parts
      which allows this (before, most handlers were gone after boot).
    * Added debugger command that dumps the low memory handlers.
    * The slab allocator now registers its low memory handler with a higher
      priority, so that it'll run before the potentially heavier ones.
    
    
    Modified: haiku/trunk/headers/private/kernel/vm_low_memory.h
    ===================================================================
    --- haiku/trunk/headers/private/kernel/vm_low_memory.h	2007-09-29 14:06:19 UTC (rev 22373)
    +++ haiku/trunk/headers/private/kernel/vm_low_memory.h	2007-09-29 15:46:40 UTC (rev 22374)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
    + * Copyright 2005-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved.
      * Distributed under the terms of the MIT License.
      */
     #ifndef _KERNEL_VM_LOW_MEMORY_H
    @@ -24,6 +24,7 @@
     #endif
     
     status_t vm_low_memory_init(void);
    +status_t vm_low_memory_init_post_thread(void);
     int32 vm_low_memory_state(void);
     void vm_low_memory(size_t requirements);
     
    
    Modified: haiku/trunk/src/system/kernel/slab/Slab.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-29 14:06:19 UTC (rev 22373)
    +++ haiku/trunk/src/system/kernel/slab/Slab.cpp	2007-09-29 15:46:40 UTC (rev 22374)
    @@ -449,7 +449,7 @@
     		cache->free_pages = area_free_pages;
     	}
     
    -	register_low_memory_handler(object_cache_low_memory, cache, 0);
    +	register_low_memory_handler(object_cache_low_memory, cache, 5);
     
     	BenaphoreLocker _(sObjectCacheListLock);
     	sObjectCaches.Add(cache);
    
    Modified: haiku/trunk/src/system/kernel/vm/vm.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-29 14:06:19 UTC (rev 22373)
    +++ haiku/trunk/src/system/kernel/vm/vm.cpp	2007-09-29 15:46:40 UTC (rev 22374)
    @@ -3405,6 +3405,8 @@
     	TRACE(("heap at 0x%lx\n", heapBase));
     	heap_init(heapBase, heapSize);
     
    +	vm_low_memory_init();
    +
     	size_t slabInitialSize = 2 * B_PAGE_SIZE;
     	addr_t slabInitialBase = vm_allocate_early(args, slabInitialSize,
     		slabInitialSize, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
    @@ -3525,7 +3527,7 @@
     {
     	vm_page_init_post_thread(args);
     	vm_daemon_init();
    -	vm_low_memory_init();
    +	vm_low_memory_init_post_thread();
     
     	return heap_init_post_thread(args);
     }
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-29 14:06:19 UTC (rev 22373)
    +++ haiku/trunk/src/system/kernel/vm/vm_low_memory.cpp	2007-09-29 15:46:40 UTC (rev 22374)
    @@ -4,19 +4,21 @@
      */
     
     
    -#include 
    -
     #include 
    -#include 
    -#include 
    -#include 
    -#include 
     
     #include 
     #include 
     #include 
     
    +#include 
     
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +
     //#define TRACE_LOW_MEMORY
     #ifdef TRACE_LOW_MEMORY
     #	define TRACE(x)	dprintf x
    @@ -110,6 +112,30 @@
     }
     
     
    +static int
    +dump_handlers(int argc, char **argv)
    +{
    +	HandlerList::Iterator iterator = sLowMemoryHandlers.GetIterator();
    +	kprintf("function    data       prio  function-name\n");
    +
    +	while (iterator.HasNext()) {
    +		low_memory_handler *handler = iterator.Next();
    +
    +		const char* symbol = NULL;
    +		elf_debug_lookup_symbol_address((addr_t)handler->function, NULL,
    +			&symbol, NULL, NULL);
    +
    +		kprintf("%p  %p  %3ld  %s\n", handler->function, handler->data,
    +			handler->priority, symbol);
    +	}
    +
    +	return 0;
    +}
    +
    +
    +//	#pragma mark - private kernel API
    +
    +
     void
     vm_low_memory(size_t requirements)
     {
    @@ -129,8 +155,17 @@
     status_t
     vm_low_memory_init(void)
     {
    -	thread_id thread;
    +	new(&sLowMemoryHandlers) HandlerList;
    +		// static initializers do not work in the kernel,
    +		// so we have to do it here, manually
     
    +	return B_OK;
    +}
    +
    +
    +status_t
    +vm_low_memory_init_post_thread(void)
    +{
     	if (mutex_init(&sLowMemoryMutex, "low memory") < B_OK)
     		return B_ERROR;
     	
    @@ -138,14 +173,11 @@
     	if (sLowMemoryWaitSem < B_OK)
     		return sLowMemoryWaitSem;
     
    -	new(&sLowMemoryHandlers) HandlerList;
    -		// static initializers do not work in the kernel,
    -		// so we have to do it here, manually
    -
    -	thread = spawn_kernel_thread(&low_memory, "low memory handler",
    +	thread_id thread = spawn_kernel_thread(&low_memory, "low memory handler",
     		B_LOW_PRIORITY, NULL);
     	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
     
    +	add_debugger_command("low_memory", &dump_handlers, "Dump list of low memory handlers");
     	return B_OK;
     }
     
    
    
    
    From axeld at mail.berlios.de  Sat Sep 29 17:48:11 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sat, 29 Sep 2007 17:48:11 +0200
    Subject: [Haiku-commits] r22375 - in haiku/trunk/src/system/kernel: fs vm
    Message-ID: <200709291548.l8TFmBYM030568@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-29 17:48:11 +0200 (Sat, 29 Sep 2007)
    New Revision: 22375
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22375&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/fs/vfs.cpp
       haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    Log:
    * Added some more debug output.
    * Cleanup.
    
    
    Modified: haiku/trunk/src/system/kernel/fs/vfs.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/fs/vfs.cpp	2007-09-29 15:46:40 UTC (rev 22374)
    +++ haiku/trunk/src/system/kernel/fs/vfs.cpp	2007-09-29 15:48:11 UTC (rev 22375)
    @@ -2280,7 +2280,7 @@
     	kprintf(" private_node:  %p\n", vnode->private_node);
     	kprintf(" mount:         %p\n", vnode->mount);
     	kprintf(" covered_by:    %p\n", vnode->covered_by);
    -	kprintf(" cache_ref:     %p\n", vnode->cache);
    +	kprintf(" cache:         %p\n", vnode->cache);
     	kprintf(" flags:         %s%s%s\n", vnode->remove ? "r" : "-",
     		vnode->busy ? "b" : "-", vnode->unpublished ? "u" : "-");
     	kprintf(" advisory_lock: %p\n", vnode->advisory_locking);
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_cache.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-29 15:46:40 UTC (rev 22374)
    +++ haiku/trunk/src/system/kernel/vm/vm_cache.cpp	2007-09-29 15:48:11 UTC (rev 22375)
    @@ -317,19 +317,16 @@
     vm_page *
     vm_cache_lookup_page(vm_cache *cache, off_t offset)
     {
    -	struct page_lookup_key key;
    -	cpu_status state;
    -	vm_page *page;
    -
     	ASSERT_LOCKED_MUTEX(&cache->lock);
     
    +	struct page_lookup_key key;
     	key.offset = (uint32)(offset >> PAGE_SHIFT);
     	key.cache = cache;
     
    -	state = disable_interrupts();
    +	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageCacheTableLock);
     
    -	page = (vm_page *)hash_lookup(sPageCacheTable, &key);
    +	vm_page *page = (vm_page *)hash_lookup(sPageCacheTable, &key);
     
     	release_spinlock(&sPageCacheTableLock);
     	restore_interrupts(state);
    @@ -344,8 +341,6 @@
     void
     vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset)
     {
    -	cpu_status state;
    -
     	TRACE(("vm_cache_insert_page: cache %p, page %p, offset %Ld\n",
     		cache, page, offset));
     	ASSERT_LOCKED_MUTEX(&cache->lock);
    @@ -367,8 +362,7 @@
     
     	page->usage_count = 2;
     
    -	state = disable_interrupts();
    -	acquire_spinlock(&sPageCacheTableLock);
    +	InterruptsSpinLocker locker(sPageCacheTableLock);
     
     	page->cache = cache;
     
    @@ -385,9 +379,6 @@
     #endif	// KDEBUG
     
     	hash_insert(sPageCacheTable, page);
    -
    -	release_spinlock(&sPageCacheTableLock);
    -	restore_interrupts(state);
     }
     
     
    @@ -399,8 +390,6 @@
     void
     vm_cache_remove_page(vm_cache *cache, vm_page *page)
     {
    -	cpu_status state;
    -
     	TRACE(("vm_cache_remove_page: cache %p, page %p\n", cache, page));
     	ASSERT_LOCKED_MUTEX(&cache->lock);
     
    @@ -409,7 +398,7 @@
     			cache, page->cache);
     	}
     
    -	state = disable_interrupts();
    +	cpu_status state = disable_interrupts();
     	acquire_spinlock(&sPageCacheTableLock);
     
     	hash_remove(sPageCacheTable, page);
    @@ -435,15 +424,13 @@
     status_t
     vm_cache_write_modified(vm_cache *cache, bool fsReenter)
     {
    -	status_t status;
    -
     	TRACE(("vm_cache_write_modified(cache = %p)\n", cache));
     
     	if (cache->temporary)
     		return B_OK;
     
     	mutex_lock(&cache->lock);
    -	status = vm_page_write_modified_pages(cache, fsReenter);
    +	status_t status = vm_page_write_modified_pages(cache, fsReenter);
     	mutex_unlock(&cache->lock);
     
     	return status;
    @@ -458,11 +445,13 @@
     status_t
     vm_cache_set_minimal_commitment_locked(vm_cache *cache, off_t commitment)
     {
    -	status_t status = B_OK;
    -	vm_store *store = cache->store;
    -
    +	TRACE(("vm_cache_set_minimal_commitment_locked(cache %p, commitment %Ld)\n",
    +		cache, commitment));
     	ASSERT_LOCKED_MUTEX(&cache->lock);
     
    +	vm_store *store = cache->store;
    +	status_t status = B_OK;
    +
     	// If we don't have enough committed space to cover through to the new end of region...
     	if (store->committed_size < commitment) {
     		// ToDo: should we check if the cache's virtual size is large
    @@ -489,17 +478,17 @@
     status_t
     vm_cache_resize(vm_cache *cache, off_t newSize)
     {
    -	uint32 oldPageCount, newPageCount;
    -	status_t status;
    -
    +	TRACE(("vm_cache_resize(cache %p, newSize %Ld) old size %Ld\n",
    +		cache, newSize, cache->virtual_size));
     	ASSERT_LOCKED_MUTEX(&cache->lock);
     
    -	status = cache->store->ops->commit(cache->store, newSize);
    +	status_t status = cache->store->ops->commit(cache->store, newSize);
     	if (status != B_OK)
     		return status;
     
    -	oldPageCount = (uint32)((cache->virtual_size + B_PAGE_SIZE - 1) >> PAGE_SHIFT);
    -	newPageCount = (uint32)((newSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT);
    +	uint32 oldPageCount = (uint32)((cache->virtual_size + B_PAGE_SIZE - 1)
    +		>> PAGE_SHIFT);
    +	uint32 newPageCount = (uint32)((newSize + B_PAGE_SIZE - 1) >> PAGE_SHIFT);
     
     	if (newPageCount < oldPageCount) {
     		// we need to remove all pages in the cache outside of the new virtual
    @@ -615,11 +604,6 @@
     				if (consumerPage == NULL) {
     					// the page already is not yet in the consumer cache - move
     					// it upwards
    -#if 0
    -if (consumer->virtual_base == 0x11000)
    -	dprintf("%ld: move page %p offset %ld from cache %p to cache %p\n",
    -		find_thread(NULL), page, page->cache_offset, cache, consumer);
    -#endif
     					vm_cache_remove_page(cache, page);
     					vm_cache_insert_page(consumer, page,
     						(off_t)page->cache_offset << PAGE_SHIFT);
    @@ -628,7 +612,7 @@
     					// the page is currently busy taking a read fault - IOW,
     					// vm_soft_fault() has mapped our page so we can just
     					// move it up
    -//dprintf("%ld: merged busy page %p, cache %p, offset %ld\n", find_thread(NULL), page, cacheRef->cache, page->cache_offset);
    +					//dprintf("%ld: merged busy page %p, cache %p, offset %ld\n", find_thread(NULL), page, cacheRef->cache, page->cache_offset);
     					vm_cache_remove_page(consumer, consumerPage);
     					consumerPage->state = PAGE_STATE_INACTIVE;
     					((vm_dummy_page*)consumerPage)->busy_condition.Unpublish();
    @@ -647,11 +631,6 @@
     					consumerPage->collided_page = page;
     #endif	// DEBUG_PAGE_CACHE_TRANSITIONS
     				}
    -#if 0
    -else if (consumer->virtual_base == 0x11000)
    -	dprintf("%ld: did not move page %p offset %ld from cache %p to cache %p because there is page %p\n",
    -		find_thread(NULL), page, page->cache_offset, cache, consumer, consumerPage);
    -#endif
     			}
     
     			newSource = cache->source;
    @@ -717,6 +696,7 @@
     status_t
     vm_cache_insert_area_locked(vm_cache *cache, vm_area *area)
     {
    +	TRACE(("vm_cache_insert_area_locked(cache %p, area %p)\n", cache, area));
     	ASSERT_LOCKED_MUTEX(&cache->lock);
     
     	area->cache_next = cache->areas;
    @@ -735,8 +715,10 @@
     status_t
     vm_cache_remove_area(vm_cache *cache, vm_area *area)
     {
    -	mutex_lock(&cache->lock);
    +	TRACE(("vm_cache_remove_area(cache %p, area %p)\n", cache, area));
     
    +	MutexLocker locker(cache->lock);
    +
     	if (area->cache_prev)
     		area->cache_prev->cache_next = area->cache_next;
     	if (area->cache_next)
    @@ -747,6 +729,5 @@
     	if (cache->store->ops->release_ref)
     		cache->store->ops->release_ref(cache->store);
     
    -	mutex_unlock(&cache->lock);
     	return B_OK;
     }
    
    
    
    From marcusoverhagen at mail.berlios.de  Sat Sep 29 19:11:25 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sat, 29 Sep 2007 19:11:25 +0200
    Subject: [Haiku-commits] r22376 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709291711.l8THBP2D028985@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-29 19:11:24 +0200 (Sat, 29 Sep 2007)
    New Revision: 22376
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22376&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    Log:
    Cleanup, device present detection improved.
    Added support for non-48-bit LBA, added write support.
    Proper error handling still missing, write support disabled for your protection.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 15:48:11 UTC (rev 22375)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-29 17:11:24 UTC (rev 22376)
    @@ -25,7 +25,10 @@
     	, fRequestSem(-1)
     	, fResponseSem(-1)
     	, fCommandActive(false)
    -	, fHarddiskSize(0)
    +	, fDevicePresent(false)
    +	, fUse48BitCommands(false)
    +	, fSectorSize(0)
    +	, fSectorCount(0)
     {
     	fRequestSem = create_sem(1, "ahci request");
     	fResponseSem = create_sem(1, "ahci response");
    @@ -127,6 +130,8 @@
     	TRACE("sact 0x%08lx\n", fRegs->sact);
     	TRACE("tfd  0x%08lx\n", fRegs->tfd);
     
    +	fDevicePresent = (fRegs->ssts & 0xf) == 0x3;
    +
     	return B_OK;
     }
     
    @@ -439,10 +444,7 @@
     AHCIPort::ScsiTestUnitReady(scsi_ccb *request)
     {
     	TRACE("AHCIPort::ScsiTestUnitReady port %d\n", fIndex);
    -	if ((fRegs->ssts & 0xf) == 0x3)
    -		request->subsys_status = SCSI_REQ_CMP;
    -	else
    -		request->subsys_status = SCSI_DEV_NOT_THERE;
    +	request->subsys_status = SCSI_REQ_CMP;
     	gSCSI->finished(request, 1);
     }
     
    @@ -479,7 +481,6 @@
     
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -//	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    @@ -535,8 +536,17 @@
     	bool lba48			= (ataData.words[83] & (1 << 10)) != 0;
     	uint32 sectors		= *(uint32*)&ataData.words[60];
     	uint64 sectors48	= *(uint64*)&ataData.words[100];
    -	fHarddiskSize		= !(lba || sectors) ? 0 : lba48 ? (sectors48 * 512) : (sectors * 512ull);
    +	fUse48BitCommands   = lba && lba48;
    +	fSectorSize			= 512;
    +	fSectorCount		= !(lba || sectors) ? 0 : lba48 ? sectors48 : sectors;
     
    +#if 1
    +	if (fSectorCount < 0x0fffffff) {
    +		TRACE("disabling 48 bit commands\n");
    +		fUse48BitCommands = 0;
    +	}
    +#endif
    +
     	swap_words(ataData.model_number, sizeof(ataData.model_number));
     	swap_words(ataData.serial_number, sizeof(ataData.serial_number));
     	swap_words(ataData.firmware_revision, sizeof(ataData.firmware_revision));
    @@ -544,12 +554,9 @@
     	TRACE("model_number: %.40s\n", ataData.model_number);
     	TRACE("serial_number: %.20s\n", ataData.serial_number);
     	TRACE("firmware_revision: %.8s\n", ataData.firmware_revision);
    -	TRACE("lba %d, lba48 %d, sectors %lu, sectors48 %llu, size %llu\n",
    -		lba, lba48, sectors, sectors48, fHarddiskSize);
    +	TRACE("lba %d, lba48 %d, fUse48BitCommands %d, sectors %lu, sectors48 %llu, size %llu\n",
    +		lba, lba48, fUse48BitCommands, sectors, sectors48, fSectorCount * fSectorSize);
     
    -	if (fHarddiskSize >= (512ull * 0xffffffff))
    -		panic("ahci: SCSI emulation doesn't support harddisks larger than 2TB");
    -
     	if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
     		request->subsys_status = SCSI_DATA_RUN_ERR;
     	} else {
    @@ -578,20 +585,14 @@
     		return;
     	}
     
    -	uint64 sectorCount = fHarddiskSize / 512;
    -	uint32 sectorSize = 512;
    -	TRACE("sectorCount 0x%llx, sectorSize %lu\n", sectorCount, sectorSize);
    -/*
    -	while (sectorCount > 0xffffffff) {
    -		sectorCount /= 2;
    -		sectorSize *= 2;
    -	}
    -	TRACE("sectorCount 0x%llx, sectorSize %lu\n", sectorCount, sectorSize);
    -*/
    +	TRACE("SectorSize %lu, SectorCount 0x%llx\n", fSectorSize, fSectorCount);
     
    -	scsiData.block_size = B_HOST_TO_BENDIAN_INT32(sectorSize);
    -	scsiData.lba = B_HOST_TO_BENDIAN_INT32(sectorCount - 1);
    +	if (fSectorCount > 0xffffffff)
    +		panic("ahci: SCSI emulation doesn't support harddisks larger than 2TB");
     
    +	scsiData.block_size = B_HOST_TO_BENDIAN_INT32(fSectorSize);
    +	scsiData.lba = B_HOST_TO_BENDIAN_INT32(fSectorCount - 1);
    +
     	if (sg_memcpy(request->sg_list, request->sg_count, &scsiData, sizeof(scsiData)) < B_OK) {
     		request->subsys_status = SCSI_DATA_RUN_ERR;
     	} else {
    @@ -608,6 +609,16 @@
     {
     	TRACE("ScsiReadWrite: pos %llu, size %lu, isWrite %d\n", position, length, isWrite);
     
    +#if 1
    +	if (isWrite) {
    +		TRACE("write request ignored\n");
    +		request->subsys_status = SCSI_REQ_CMP;
    +		request->data_resid = 0;
    +		gSCSI->finished(request, 1);
    +		return;
    +	}
    +#endif
    +
     	StartTransfer();
     
     	int prdEntrys;
    @@ -616,22 +627,37 @@
     	TRACE("prdEntrys %d\n", prdEntrys);
     	
     	memset((void *)fCommandTable->cfis, 0, 5 * 4);
    -	fCommandTable->cfis[0] = 0x27;
    -	fCommandTable->cfis[1] = 0x80;
    -	fCommandTable->cfis[2] = 0x25;
    -	fCommandTable->cfis[4] = position & 0xff;
    -	fCommandTable->cfis[5] = (position >> 8) & 0xff;
    -	fCommandTable->cfis[6] = (position >> 16) & 0xff;
    -	fCommandTable->cfis[7] = 0x40; 
    -	fCommandTable->cfis[8] = (position >> 24) & 0xff;
    -	fCommandTable->cfis[9] = (position >> 32) & 0xff;
    -	fCommandTable->cfis[10] = (position >> 40) & 0xff;
    -	fCommandTable->cfis[12] = length & 0xff;
    -	fCommandTable->cfis[13] = (length >> 8) & 0xff;
     
    +	if (fUse48BitCommands) {
    +		fCommandTable->cfis[0] = 0x27;
    +		fCommandTable->cfis[1] = 0x80;
    +		fCommandTable->cfis[2] = isWrite ? 0x35 : 0x25;
    +		fCommandTable->cfis[4] = position & 0xff;
    +		fCommandTable->cfis[5] = (position >> 8) & 0xff;
    +		fCommandTable->cfis[6] = (position >> 16) & 0xff;
    +		fCommandTable->cfis[7] = 0x40; 
    +		fCommandTable->cfis[8] = (position >> 24) & 0xff;
    +		fCommandTable->cfis[9] = (position >> 32) & 0xff;
    +		fCommandTable->cfis[10] = (position >> 40) & 0xff;
    +		fCommandTable->cfis[12] = length & 0xff;
    +		fCommandTable->cfis[13] = (length >> 8) & 0xff;
    +	} else {
    +		if (length > 256)
    +			panic("ahci: ScsiReadWrite length too large");
    +		if (position > 0x0fffffff)
    +			panic("achi: ScsiReadWrite position too large for non-48-bit LBA\n");
    +		fCommandTable->cfis[0] = 0x27;
    +		fCommandTable->cfis[1] = 0x80;
    +		fCommandTable->cfis[2] = isWrite ? 0xca : 0xc8;
    +		fCommandTable->cfis[4] = position & 0xff;
    +		fCommandTable->cfis[5] = (position >> 8) & 0xff;
    +		fCommandTable->cfis[6] = (position >> 16) & 0xff;
    +		fCommandTable->cfis[7] = 0x40 | ((position >> 24) & 0x0f);
    +		fCommandTable->cfis[12] = length & 0xff;
    +	}
    +
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
    -//	fCommandList->c = 1;
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    @@ -664,13 +690,11 @@
     	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
     	if (request->cdb[0] == SCSI_OP_REQUEST_SENSE) {
    -		TRACE("SCSI_OP_REQUEST_SENSE\n");
    -		request->subsys_status = SCSI_DEV_NOT_THERE;
    -		gSCSI->finished(request, 1);
    +		panic("ahci: SCSI_OP_REQUEST_SENSE not yet supported\n");
     		return;
     	}
     
    -	if ((fRegs->ssts & 0xf) != 0x3) {
    +	if (!fDevicePresent) {
     		TRACE("no such device!\n");
     		request->subsys_status = SCSI_DEV_NOT_THERE;
     		gSCSI->finished(request, 1);
    @@ -710,7 +734,7 @@
     				ScsiReadWrite(request, position, length, isWrite);
     			} else {
     				TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
    -				request->subsys_status = SCSI_DEV_NOT_THERE;
    +				request->subsys_status = SCSI_REQ_INVALID;
     				gSCSI->finished(request, 1);
     			}
     			break;
    @@ -726,15 +750,15 @@
     				ScsiReadWrite(request, position, length, isWrite);
     			} else {
     				TRACE("AHCIPort::ScsiExecuteRequest error: transfer without data!\n");
    -				request->subsys_status = SCSI_DEV_NOT_THERE;
    +				request->subsys_status = SCSI_REQ_INVALID;
     				gSCSI->finished(request, 1);
     			}
     			break;
     		}
    -
     		default:
    -		request->subsys_status = SCSI_DEV_NOT_THERE;
    -		gSCSI->finished(request, 1);
    +			TRACE("AHCIPort::ScsiExecuteRequest port %d unsupported request opcode 0x%02x\n", fIndex, request->cdb[0]);
    +			request->subsys_status = SCSI_REQ_ABORTED;
    +			gSCSI->finished(request, 1);
     	}
     }
     
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-29 15:48:11 UTC (rev 22375)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-29 17:11:24 UTC (rev 22376)
    @@ -53,12 +53,15 @@
     	sem_id							fRequestSem;
     	sem_id							fResponseSem;
     	volatile bool					fCommandActive;
    +	bool							fDevicePresent;
    +	bool							fUse48BitCommands;
    +	uint32							fSectorSize;
    +	uint64							fSectorCount;
     
     	volatile fis *					fFIS;
     	volatile command_list_entry *	fCommandList;
     	volatile command_table *		fCommandTable;
     	volatile prd *					fPRDTable;
    -	uint64							fHarddiskSize;
     };
     
     inline void
    
    
    
    From axeld at mail.berlios.de  Sat Sep 29 20:17:41 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sat, 29 Sep 2007 20:17:41 +0200
    Subject: [Haiku-commits] r22377 - haiku/trunk/src/tests/kits/interface
    Message-ID: <200709291817.l8TIHf8u022944@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-29 20:17:40 +0200 (Sat, 29 Sep 2007)
    New Revision: 22377
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22377&view=rev
    
    Added:
       haiku/trunk/src/tests/kits/interface/MenuTriggerTest.cpp
    Modified:
       haiku/trunk/src/tests/kits/interface/Jamfile
    Log:
    Added test application for menu triggers.
    
    
    Modified: haiku/trunk/src/tests/kits/interface/Jamfile
    ===================================================================
    --- haiku/trunk/src/tests/kits/interface/Jamfile	2007-09-29 17:11:24 UTC (rev 22376)
    +++ haiku/trunk/src/tests/kits/interface/Jamfile	2007-09-29 18:17:40 UTC (rev 22377)
    @@ -123,6 +123,11 @@
     	;
     
     
    +Application MenuTriggerTest :
    +	MenuTriggerTest.cpp
    +	: be
    +;
    +
     SEARCH on [ FGristFiles
     		ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp Slider.cpp Control.cpp
     	] = [ FDirName $(HAIKU_TOP) src kits interface ] ;
    
    Added: haiku/trunk/src/tests/kits/interface/MenuTriggerTest.cpp
    ===================================================================
    --- haiku/trunk/src/tests/kits/interface/MenuTriggerTest.cpp	2007-09-29 17:11:24 UTC (rev 22376)
    +++ haiku/trunk/src/tests/kits/interface/MenuTriggerTest.cpp	2007-09-29 18:17:40 UTC (rev 22377)
    @@ -0,0 +1,105 @@
    +/*
    + * Copyright 2007, Haiku Inc.
    + * Distributed under the terms of the MIT License.
    + *
    + * Authors:
    + *		Axel D?rfler, axeld at pinc-software.de
    + */
    +
    +
    +#include 
    +#include 
    +#include 
    +#include 
    +#include 
    +
    +#include 
    +
    +
    +class Window : public BWindow {
    +	public:
    +		Window();
    +		virtual ~Window();
    +		
    +		virtual bool QuitRequested();
    +};
    +
    +
    +Window::Window()
    +	: BWindow(BRect(100, 100, 400, 400), "Menu Trigger Test",
    +			B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
    +{
    +	BMenuBar *bar = new BMenuBar(BRect(0, 0, 10, 10), "menuBar");
    +	AddChild(bar);
    +
    +	BMenu *menu = new BMenu("File");
    +	menu->AddItem(new BMenuItem("Bart", NULL));
    +	menu->AddItem(new BMenuItem("bart", NULL));
    +	menu->AddItem(new BMenuItem("bart", NULL));
    +	menu->AddItem(new BMenuItem("Bart", NULL));
    +	menu->AddItem(new BMenuItem("BART", NULL));
    +	menu->AddItem(new BMenuItem("b?rt", NULL));
    +	menu->AddItem(new BMenuItem("b?rst", NULL));
    +	menu->AddSeparatorItem();
    +	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
    +	bar->AddItem(menu);
    +
    +	menu = new BMenu("Edit");
    +	menu->AddItem(new BMenuItem("1 a", NULL));
    +	menu->AddItem(new BMenuItem("2 a", NULL));
    +	menu->AddItem(new BMenuItem("3 a", NULL));
    +	menu->AddItem(new BMenuItem("3 a", NULL));
    +	menu->AddItem(new BMenuItem("3 a?a", NULL));
    +	bar->AddItem(menu);
    +	
    +}
    +
    +Window::~Window()
    +{
    +}
    +
    +
    +bool
    +Window::QuitRequested()
    +{
    +	be_app->PostMessage(B_QUIT_REQUESTED);
    +	return true;
    +}
    +
    +
    +//	#pragma mark -
    +
    +
    +class Application : public BApplication {
    +	public:
    +		Application();
    +
    +		virtual void ReadyToRun(void);
    +};
    +
    +
    +Application::Application()
    +	: BApplication("application/x-vnd.haiku-view_state")
    +{
    +}
    +
    +
    +void
    +Application::ReadyToRun(void)
    +{
    +	Window *window = new Window();
    +	window->Show();
    +}
    +
    +
    +//	#pragma mark -
    +
    +
    +int 
    +main(int argc, char **argv)
    +{
    +	Application app;// app;
    +
    +	app.Run();
    +	return 0;
    +}
    
    
    
    From bonefish at mail.berlios.de  Sun Sep 30 01:52:24 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Sun, 30 Sep 2007 01:52:24 +0200
    Subject: [Haiku-commits] r22378 - haiku/trunk/src/system/kernel/fs
    Message-ID: <200709292352.l8TNqO4u025588@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-30 01:52:23 +0200 (Sun, 30 Sep 2007)
    New Revision: 22378
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22378&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/fs/pipefs.cpp
    Log:
    * Use condition variables instead of semaphores for blocking readers and
      writers.
    * Removed the optimization for piping data between two threads of the
      same team. This greatly simplifies the code. It seems to me the case
      is very uncommon; it could be added back later, though.
    * Basically rewrote reading from and writing to the pipe:
      - A blockable writer can now write more than what is currently
        available in the ring buffer.
      - Writing respects the PIPE_BUF non-interleaving limit, though our
        headers don't seem to define PIPE_BUF anywhere.
      - Unblock writers, when the last reader is gone and send those that
        haven't written anything yet a SIGPIPE. Fixes bug #1476.
    * Correctly implemented select() support. We were only notifying
      writers. We manage two separate select sync pools per pipe now: one
      for the reader end and one for the writer end.
    * Reading/writing from the root dir does no longer end in KDL.
    
    
    Modified: haiku/trunk/src/system/kernel/fs/pipefs.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/fs/pipefs.cpp	2007-09-29 18:17:40 UTC (rev 22377)
    +++ haiku/trunk/src/system/kernel/fs/pipefs.cpp	2007-09-29 23:52:23 UTC (rev 22378)
    @@ -1,12 +1,19 @@
     /*
    + * Copyright 2007, Ingo Weinhold, bonefish at cs.tu-berlin.de.
      * Copyright 2003-2007, 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 
     #include 
     #include 
    @@ -20,12 +27,7 @@
     #include 
     #include 
     
    -#include 
    -#include 
    -#include 
    -#include 
     
    -
     //#define TRACE_PIPEFS
     #ifdef TRACE_PIPEFS
     #	define TRACE(x) dprintf x
    @@ -38,6 +40,10 @@
     #define PIPEFS_MAX_BUFFER_SIZE	32768
     
     
    +// TODO: PIPE_BUF is supposed to be defined somewhere else.
    +#define PIPE_BUF	_POSIX_PIPE_BUF
    +
    +
     namespace pipefs {
     
     class Volume;
    @@ -63,31 +69,21 @@
     
     class ReadRequest : public DoublyLinkedListLinkImpl {
     	public:
    -		ReadRequest(void *buffer, size_t bufferSize);
    -		~ReadRequest();
    +		void SetUnnotified()	{ fNotified = false; }
     
    -		status_t	Wait(bool nonBlocking);
    -		void		Notify();
    -		void		Abort();
    +		void Notify()
    +		{
    +			if (!fNotified) {
    +				fWaitCondition.NotifyOne();
    +				fNotified = true;
    +			}
    +		}
     
    -		status_t	PutBuffer(RingBuffer &buffer, size_t *_bytesRead = NULL,
    -						bool releasePartiallyFilled = true);
    -		status_t	PutData(const void **_data, size_t *_dataSize);
    +		ConditionVariable<>& WaitCondition() { return fWaitCondition; }
     
    -		size_t		SpaceLeft() const { return fBufferSize - fBytesRead; }
    -		size_t		BytesRead() const { return fBytesRead; }
    -		team_id		Team() const { return fTeam; }
    -
    -		bool		IsQueued() const { return fIsQueued; }
    -		void		SetQueued(bool queued);
    -
     	private:
    -		sem_id		fLock;
    -		team_id		fTeam;
    -		void		*fBuffer;
    -		size_t		fBufferSize;
    -		size_t		fBytesRead;
    -		bool		fIsQueued;
    +		ConditionVariable<>	fWaitCondition;
    +		bool				fNotified;
     };
     
     typedef DoublyLinkedList RequestList;
    @@ -168,24 +164,30 @@
     		benaphore	*RequestLock() { return &fRequestLock; }
     		RequestList	&Requests() { return fRequests; }
     
    -		status_t	WriteDataToBuffer(const void **_data, size_t *_bytesLeft,
    +		status_t	WriteDataToBuffer(const void *data, size_t *_length,
     						bool nonBlocking);
    +		status_t	ReadDataFromBuffer(void *data, size_t *_length,
    +						bool nonBlocking, ReadRequest &request);
     		size_t		BytesAvailable() const { return fBuffer.Readable(); }
     
    -		void		MayReleaseWriter();
    -		void		FillPendingRequests(const void **_buffer,
    -						size_t *_bytesLeft);
    -		void 		FillPendingRequests();
    -		status_t	AddRequest(ReadRequest &request);
    -		status_t	RemoveRequest(ReadRequest &request);
    +		void		AddRequest(ReadRequest &request);
    +		void		RemoveRequest(ReadRequest &request);
    +		status_t	WaitForRequest(ReadRequest &request);
     
    +		void		NotifyBytesRead(size_t bytes);
    +		void		NotifyReadDone();
    +		void		NotifyBytesWritten(size_t bytes);
    +		void		NotifyWriteDone();
    +		void		NotifyEndClosed(bool writer);
    +
     		void		Open(int openMode);
     		void		Close(int openMode);
     		int32		ReaderCount() const { return fReaderCount; }
     		int32		WriterCount() const { return fWriterCount; }
     
    -		status_t	Select(uint8 event, uint32 ref, selectsync *sync);
    -		status_t	Deselect(uint8 event, selectsync *sync);
    +		status_t	Select(uint8 event, uint32 ref, selectsync *sync,
    +						int openMode);
    +		status_t	Deselect(uint8 event, selectsync *sync, int openMode);
     
     		static int32 NameHashNextOffset();
     		static uint32 name_hash_func(void *_node, const void *_key,
    @@ -213,12 +215,14 @@
     		RequestList	fRequests;
     
     		benaphore	fRequestLock;
    -		sem_id		fWriteLock;
     
    +		ConditionVariable<> fWriteCondition;
    +
     		int32		fReaderCount;
     		int32		fWriterCount;
     
    -		select_sync_pool	*fSelectSyncPool;
    +		select_sync_pool	*fReadSelectSyncPool;
    +		select_sync_pool	*fWriteSelectSyncPool;
     };
     
     
    @@ -561,7 +565,8 @@
     	fHashNext(NULL),
     	fReaderCount(0),
     	fWriterCount(0),
    -	fSelectSyncPool(NULL)
    +	fReadSelectSyncPool(NULL),
    +	fWriteSelectSyncPool(NULL)
     {
     	fName = strdup(name);
     	if (fName == NULL)
    @@ -571,7 +576,7 @@
     	fType = type;
     
     	if (S_ISFIFO(type)) {
    -		fWriteLock = create_sem(1, "pipe write");
    +		fWriteCondition.Publish(this, "pipe");
     		benaphore_init(&fRequestLock, "pipe request");
     	}
     
    @@ -587,7 +592,7 @@
     	free(const_cast(fName));
     
     	if (S_ISFIFO(fType)) {
    -		delete_sem(fWriteLock);
    +		fWriteCondition.Unpublish();
     		benaphore_destroy(&fRequestLock);
     	}
     }
    @@ -596,8 +601,7 @@
     status_t 
     Inode::InitCheck()
     {
    -	if (fName == NULL
    -		|| S_ISFIFO(fType) && (fRequestLock.sem < B_OK || fWriteLock < B_OK))
    +	if (fName == NULL || S_ISFIFO(fType) && fRequestLock.sem < B_OK)
     		return B_ERROR;
     
     	return B_OK;
    @@ -606,204 +610,242 @@
     
     /*!
     	Writes the specified data bytes to the inode's ring buffer. The
    -	Inode::WriteLock() must be held when calling this method.
    -	Releases the reader sem if necessary, so that blocking
    -	readers will get started.
    +	request lock must be held when calling this method.
    +	Notifies readers if necessary, so that blocking readers will get started.
     	Returns B_OK for success, B_BAD_ADDRESS if copying from the buffer failed,
    -	and various semaphore errors (like B_WOULD_BLOCK in non-blocking mode).
    +	and various semaphore errors (like B_WOULD_BLOCK in non-blocking mode). If
    +	the returned length is > 0, the returned error code can be ignored.
     */
     status_t
    -Inode::WriteDataToBuffer(const void **_data, size_t *_bytesLeft,
    -	bool nonBlocking)
    +Inode::WriteDataToBuffer(const void *_data, size_t *_length, bool nonBlocking)
     {
    -	const void *data = *_data;
    -	size_t dataSize = *_bytesLeft;
    +	const uint8* data = (const uint8*)_data;
    +	size_t dataSize = *_length;
    +	size_t& written = *_length;
    +	written = 0;
     
     	TRACE(("Inode::WriteDataToBuffer(data = %p, bytes = %lu)\n",
     		data, dataSize));
     
    -	// if this is a blocking call, we need to make sure that data can
    -	// still come in and we don't block the whole inode data transfer
    -	// to prevent deadlocks from happening
    +	// According to the standard, request up to PIPE_BUF bytes shall not be
    +	// interleaved with other writer's data.
    +	size_t minToWrite = 1;
    +	if (dataSize <= PIPE_BUF)
    +		minToWrite = dataSize;
     
    -	while (fBuffer.Writable() == 0) {
    -		if (nonBlocking)
    -			return B_WOULD_BLOCK;
    +	while (dataSize > 0) {
    +		// Wait until enough space in the buffer is available.
    +		while (fBuffer.Writable() < minToWrite && fReaderCount > 0) {
    +			if (nonBlocking)
    +				return B_WOULD_BLOCK;
     
    -		benaphore_unlock(&fRequestLock);
    +			ConditionVariableEntry<> entry;
    +			entry.Add(this);
     
    -		status_t status = acquire_sem_etc(fWriteLock, 1, B_CAN_INTERRUPT, 0);
    +			benaphore_unlock(&fRequestLock);
     
    -		benaphore_lock(&fRequestLock);
    +			status_t status = entry.Wait(B_CAN_INTERRUPT);
     
    -		if (status != B_OK)
    -			return status;
    -	}
    +			benaphore_lock(&fRequestLock);
     
    -	// ensure that we don't write more than PIPEFS_MAX_BUFFER_SIZE
    -	// into a pipe without blocking
    +			if (status != B_OK)
    +				return status;
    +		}
     
    -	size_t spaceLeft = fBuffer.Writable();
    -	if (dataSize > spaceLeft)
    -		dataSize = spaceLeft;
    +		// write only as long as there are readers left
    +		if (fReaderCount == 0) {
    +			if (written == 0)
    +				send_signal(find_thread(NULL), SIGPIPE);
    +			return EPIPE;
    +		}
     
    -	if (fBuffer.UserWrite(data, dataSize) < B_OK) {
    -		release_sem(fWriteLock);
    -		return B_BAD_ADDRESS;
    -	}
    +		// write as much as we can
     
    -	*_data = (const void *)((addr_t)data + dataSize);
    -	*_bytesLeft -= dataSize;
    +		size_t toWrite = fBuffer.Writable();
    +		if (toWrite > dataSize)
    +			toWrite = dataSize;
     
    -	MayReleaseWriter();
    +		if (fBuffer.UserWrite(data, toWrite) < B_OK)
    +			return B_BAD_ADDRESS;
     
    +		data += toWrite;
    +		dataSize -= toWrite;
    +		written += toWrite;
    +
    +		NotifyBytesWritten(toWrite);
    +	}
    +
     	return B_OK;
     }
     
     
    -void 
    -Inode::MayReleaseWriter()
    +status_t
    +Inode::ReadDataFromBuffer(void *data, size_t *_length, bool nonBlocking,
    +	ReadRequest &request)
     {
    -	if (fBuffer.Writable() > 0) {
    -		if (fSelectSyncPool)
    -			notify_select_event_pool(fSelectSyncPool, B_SELECT_WRITE);
    +	size_t dataSize = *_length;
    +	*_length = 0;
     
    -		release_sem(fWriteLock);
    +	// wait until our request is first in queue
    +	status_t error;
    +	if (fRequests.Head() != &request) {
    +		if (nonBlocking)
    +			return B_WOULD_BLOCK;
    +
    +		error = WaitForRequest(request);
    +		if (error != B_OK)
    +			return error;
     	}
    -}
     
    +	// wait until data are available
    +	while (fBuffer.Readable() == 0) {
    +		if (nonBlocking)
    +			return B_WOULD_BLOCK;
     
    -/*!
    -	This functions fills pending requests out of the ring buffer.
    -	It either stops when there are no more requests to satisfy, or
    -	the ring buffer is empty, whatever comes first.
    -	You must hold the request lock when calling this function.
    -*/
    -void
    -Inode::FillPendingRequests()
    -{
    -	size_t bytesLeft = fBuffer.Readable();
    +		if (fWriterCount == 0)
    +			return B_OK;
     
    -	TRACE(("Inode::FillPendingRequests(): bytesLeft = %lu\n", bytesLeft));
    +		error = WaitForRequest(request);
    +		if (error != B_OK)
    +			return error;
    +	}
     
    -	ReadRequest *request;
    -	RequestList::Iterator iterator = fRequests.GetIterator();
    -	while (bytesLeft != 0 && (request = iterator.Next()) != NULL) {
    -		// notify the request, so that it can be filled
    -		size_t space = request->SpaceLeft();
    -		if (space == 0)
    -			continue;
    +	// read as much as we can
    +	size_t toRead = fBuffer.Readable();
    +	if (toRead > dataSize)
    +		toRead = dataSize;
     
    -		if (space > bytesLeft)
    -			bytesLeft = 0;
    -		else
    -			bytesLeft -= space;
    +	if (fBuffer.UserRead(data, toRead) < B_OK)
    +		return B_BAD_ADDRESS;
     
    -		request->Notify();
    -		MayReleaseWriter();
    -	}
    -	
    -	if (fSelectSyncPool)
    -		notify_select_event_pool(fSelectSyncPool, B_SELECT_READ);
    +	NotifyBytesRead(toRead);
    +
    +	*_length = toRead;
    +
    +	return B_OK;
     }
     
     
    -/*!
    -	This function feeds the pending read requests using the provided
    -	buffer directly. It will also make sure that bytes in the ring
    -	buffer are served first.
    -	It only does something as long as the first request in the queue
    -	shares the same team context as the caller (write context).
    -	You must hold the request lock when calling this function.
    -*/
     void
    -Inode::FillPendingRequests(const void **_data, size_t *_bytesLeft)
    +Inode::AddRequest(ReadRequest &request)
     {
    -	team_id team = team_get_current_team_id();
    +	fRequests.Add(&request);
    +}
     
    -	TRACE(("Inode::FillPendingRequests(data = %p, bytes = %lu)\n", 
    -		_data, *_bytesLeft));
     
    -	ReadRequest *request;
    -	RequestList::Iterator iterator = fRequests.GetIterator();
    -	while (*_bytesLeft != 0 && (request = iterator.Next()) != NULL) {
    -		// Note that we leave this loop not to mess up the request queue
    -		if (request->Team() != team)
    -			break;
    +void
    +Inode::RemoveRequest(ReadRequest &request)
    +{
    +	fRequests.Remove(&request);
    +}
     
    -		// try to fill this request from the ring buffer first
    -		size_t bytesRead;
    -		if (request->PutBuffer(fBuffer, &bytesRead, false) != B_OK)
    -			continue;
     
    -		MayReleaseWriter();
    +status_t
    +Inode::WaitForRequest(ReadRequest &request)
    +{
    +	request.SetUnnotified();
     
    -		if (request->SpaceLeft() > 0) {
    -			// ToDo: This is something where we can optimize the buffer
    -			//	hand-shaking considerably: we should have a function
    -			//	that copies the data to another address space - either
    -			//	remapping copy on write or a direct copy.
    +	// publish the condition variable
    +	ConditionVariable<>& conditionVariable = request.WaitCondition();
    +	conditionVariable.Publish(&request, "pipe read request");
     
    -			// place our data into that buffer
    -			request->PutData(_data, _bytesLeft);
    -		}
    -	}
    -}
    +	// add the entry to wait on
    +	ConditionVariableEntry<> entry;
    +	entry.Add(&request);
     
    +	// wait
    +	benaphore_unlock(&fRequestLock);
    +	status_t status = entry.Wait(B_CAN_INTERRUPT);
    +	benaphore_lock(&fRequestLock);
     
    -/** This function adds a request into the queue.
    - *	If there is already data waiting in the pipe, the request will
    - *	be fulfilled.
    - *	This function is called from within the readers thread only.
    - */
    +	// unpublish the condition variable
    +	conditionVariable.Unpublish();
     
    -status_t
    -Inode::AddRequest(ReadRequest &request)
    +	return status != B_OK;
    +}
    +
    +
    +void
    +Inode::NotifyBytesRead(size_t bytes)
     {
    -	BenaphoreLocker locker(RequestLock());
    -	if (!locker.IsLocked())
    -		return B_ERROR;
    +	// notify writer, if something can be written now
    +	if (bytes > 0 && fBuffer.Writable() == bytes) {
    +		if (fWriteSelectSyncPool)
    +			notify_select_event_pool(fWriteSelectSyncPool, B_SELECT_WRITE);
     
    -	if (BytesAvailable() > 0 && request.PutBuffer(fBuffer) == B_OK) {
    -		MayReleaseWriter();
    -	} else {
    -		fRequests.Add(&request);
    -		request.SetQueued(true);
    +		fWriteCondition.NotifyOne();
     	}
    -
    -	return B_OK;
     }
     
     
    -/** This function removes a request from the queue.
    - *	This function is called from within the readers thread only.
    - */
    +void
    +Inode::NotifyReadDone()
    +{
    +	// notify next reader, if there's still something to be read
    +	if (fBuffer.Readable() > 0) {
    +		if (ReadRequest* request = fRequests.First())
    +			request->Notify();
    +	}
    +}
     
    -status_t
    -Inode::RemoveRequest(ReadRequest &request)
    +
    +void
    +Inode::NotifyBytesWritten(size_t bytes)
     {
    -	TRACE(("Inode::RemoveRequest(request = %p)\n", &request));
    +	// notify reader, if something can be read now
    +	if (bytes > 0 && fBuffer.Readable() == bytes) {
    +		if (fReadSelectSyncPool)
    +			notify_select_event_pool(fReadSelectSyncPool, B_SELECT_READ);
     
    -	BenaphoreLocker locker(RequestLock());
    -	if (!locker.IsLocked())
    -		return B_ERROR;
    +		if (ReadRequest* request = fRequests.First())
    +			request->Notify();
    +	}
    +}
     
    -	// we might have some data waiting now, if the direct team
    -	// handshake couldn't be done
     
    -	if (BytesAvailable() > 0 && request.PutBuffer(fBuffer) == B_OK)
    -		release_sem(fWriteLock);
    +void
    +Inode::NotifyWriteDone()
    +{
    +	// notify next writer, if there's still space for writing
    +	if (fBuffer.Writable() > 0)
    +		fWriteCondition.NotifyOne();
    +}
     
    -	if (request.IsQueued())
    -		fRequests.Remove(&request);
     
    -	return B_OK;
    +void
    +Inode::NotifyEndClosed(bool writer)
    +{
    +	if (writer) {
    +		// Our last writer has been closed; if the pipe
    +		// contains no data, unlock all waiting readers
    +		if (fBuffer.Readable() == 0) {
    +			ReadRequest *request;
    +			RequestList::Iterator iterator = fRequests.GetIterator();
    +			while ((request = iterator.Next()) != NULL)
    +				request->Notify();
    +
    +			if (fReadSelectSyncPool)
    +				notify_select_event_pool(fReadSelectSyncPool, B_SELECT_READ);
    +		}
    +	} else {
    +		// Last reader is gone. Wake up all writers.
    +		fWriteCondition.NotifyAll();
    +
    +		if (fWriteSelectSyncPool) {
    +			notify_select_event_pool(fWriteSelectSyncPool, B_SELECT_WRITE);
    +			notify_select_event_pool(fWriteSelectSyncPool, B_SELECT_ERROR);
    +		}
    +	}
     }
     
     
    +
     void
     Inode::Open(int openMode)
     {
    +	if (!S_ISFIFO(fType))
    +		return;
    +
     	if ((openMode & O_ACCMODE) == O_WRONLY)
     		atomic_add(&fWriterCount, 1);
     
    @@ -817,23 +859,20 @@
     {
     	TRACE(("Inode::Close(openMode = %d)\n", openMode));
     
    -	if ((openMode & O_ACCMODE) == O_WRONLY
    -		&& atomic_add(&fWriterCount, -1) == 1) {
    -		// Our last writer has been closed; if the pipe
    -		// contains no data, unlock all waiting readers
    +	if (!S_ISFIFO(fType))
    +		return;
     
    -		BenaphoreLocker locker(RequestLock());
    +	BenaphoreLocker locker(RequestLock());
     
    -		if (BytesAvailable() == 0) {
    -			ReadRequest *request;
    -			RequestList::Iterator iterator = fRequests.GetIterator();
    -			while ((request = iterator.Next()) != NULL)
    -				request->Abort();
    -		}
    +	if ((openMode & O_ACCMODE) == O_WRONLY
    +		&& atomic_add(&fWriterCount, -1) == 1) {
    +		NotifyEndClosed(true);
     	}
     
    -	if ((openMode & O_ACCMODE) == O_RDONLY || (openMode & O_ACCMODE) == O_RDWR)
    -		atomic_add(&fReaderCount, -1);
    +	if ((openMode & O_ACCMODE) == O_RDONLY || (openMode & O_ACCMODE) == O_RDWR) {
    +		if (atomic_add(&fReaderCount, -1) == 1)
    +			NotifyEndClosed(false);
    +	}
     }
     
     
    @@ -906,153 +945,57 @@
     
     
     status_t
    -Inode::Select(uint8 event, uint32 ref, selectsync *sync)
    +Inode::Select(uint8 event, uint32 ref, selectsync *sync, int openMode)
     {
    -	if (add_select_sync_pool_entry(&fSelectSyncPool, sync, ref, event) != B_OK)
    -		return B_ERROR;
    +	if (!S_ISFIFO(fType))
    +		return B_IS_A_DIRECTORY;
     
    -	if ((event == B_SELECT_READ && BytesAvailable() > 0)
    -		|| (event == B_SELECT_WRITE && fBuffer.Writable() > 0))
    -		return notify_select_event(sync, ref, event);
    +	bool writer = true;
    +	select_sync_pool** pool;
    +	if ((openMode & O_RWMASK) == O_RDONLY) {
    +		pool = &fReadSelectSyncPool;
    +		writer = false;
    +	} else if ((openMode & O_RWMASK) == O_WRONLY) {
    +		pool = &fWriteSelectSyncPool;
    +	} else
    +		return B_NOT_ALLOWED;
     
    -	return B_OK;
    -}
    +	if (add_select_sync_pool_entry(pool, sync, ref, event) != B_OK)
    +		return B_ERROR;
     
    -
    -status_t
    -Inode::Deselect(uint8 event, selectsync *sync)
    -{
    -	remove_select_sync_pool_entry(&fSelectSyncPool, sync, event);
    -	return B_OK;
    -}
    -
    -
    -//	#pragma mark -
    -
    -
    -ReadRequest::ReadRequest(void *buffer, size_t bufferSize)
    -	:
    -	fBuffer(buffer),
    -	fBufferSize(bufferSize),
    -	fBytesRead(0),
    -	fIsQueued(false)
    -{
    -	fLock = create_sem(0, "request lock");
    -	fTeam = team_get_current_team_id();
    -}
    -
    -
    -ReadRequest::~ReadRequest()
    -{
    -	delete_sem(fLock);
    -}
    -
    -
    -status_t 
    -ReadRequest::Wait(bool nonBlocking)
    -{
    -	TRACE(("pipefs: request@%p waits for data (%sblocking), thread 0x%lx\n",
    -		this, nonBlocking ? "non" : "", find_thread(NULL)));
    -	return acquire_sem_etc(fLock, 1,
    -		(nonBlocking ? B_TIMEOUT : 0) | B_CAN_INTERRUPT, 0);
    -}
    -
    -
    -void
    -ReadRequest::Notify()
    -{
    -	release_sem(fLock);
    -}
    -
    -
    -void
    -ReadRequest::Abort()
    -{
    -	fBuffer = NULL;
    -	release_sem(fLock);
    -}
    -
    -
    -void
    -ReadRequest::SetQueued(bool queued)
    -{
    -	fIsQueued = queued;
    -}
    -
    -
    -/*!
    -	Reads the contents of the ring buffer into the requests data buffer
    -	if any (canceled requests don't have a buffer anymore).
    -	This function must only be called in the team context that initiated
    -	the read request.
    -*/
    -status_t
    -ReadRequest::PutBuffer(RingBuffer &buffer, size_t *_bytesRead,
    -	bool releasePartiallyFilled)
    -{
    -	TRACE(("pipefs: ReadRequest::PutBuffer()\n"));
    -
    -	if (_bytesRead)
    -		*_bytesRead = 0;
    -
    -	if (fBuffer == NULL)
    -		return B_CANCELED;
    -
    -	size_t length = buffer.Readable();
    -	size_t spaceLeft = SpaceLeft();
    -
    -	// we read spaceLeft bytes at maximum - but never
    -	// more than there are in the buffer
    -	if (spaceLeft < length)
    -		length = spaceLeft;
    -
    -	if (length == 0)
    -		return B_OK;
    -
    -	if (buffer.UserRead((char*)fBuffer + fBytesRead, length) < B_OK) {
    -		// if the buffer is just invalid, we release the reader as well
    -		release_sem(fLock);
    -		return B_BAD_ADDRESS;
    +	// signal right away, if the condition holds already
    +	if (writer) {
    +		if (event == B_SELECT_WRITE
    +				&& (fBuffer.Writable() > 0 || fReaderCount == 0)
    +			|| event == B_SELECT_ERROR && fReaderCount == 0) {
    +			return notify_select_event(sync, ref, event);
    +		}
    +	} else {
    +		if (event == B_SELECT_READ
    +				&& (fBuffer.Readable() > 0 || fWriterCount == 0)) {
    +			return notify_select_event(sync, ref, event);
    +		}
     	}
     
    -	fBytesRead += length;
    -	if (_bytesRead)
    -		*_bytesRead = length;
    -
    -	if (releasePartiallyFilled || SpaceLeft() == 0)
    -		release_sem(fLock);
    -
     	return B_OK;
     }
     
     
    -/*!
    -	Copies the specified buffer into the request. This function currently
    -	only works for the local address space (both, sender and receiver must
    -	be in the same address space).
    -*/
     status_t
    -ReadRequest::PutData(const void **_buffer, size_t *_bytesLeft)
    +Inode::Deselect(uint8 event, selectsync *sync, int openMode)
     {
    -	TRACE(("pipefs: ReadRequest::PutData(buffer = %p, size = %lu)\n",
    -		*_buffer, *_bytesLeft));
    +	if (!S_ISFIFO(fType))
    +		return B_IS_A_DIRECTORY;
     
    -	size_t bytes = *_bytesLeft;
    -	if (bytes > SpaceLeft())
    -		bytes = SpaceLeft();
    +	select_sync_pool** pool;
    +	if ((openMode & O_RWMASK) == O_RDONLY) {
    +		pool = &fReadSelectSyncPool;
    +	} else if ((openMode & O_RWMASK) == O_WRONLY) {
    +		pool = &fWriteSelectSyncPool;
    +	} else
    +		return B_NOT_ALLOWED;
     
    -	uint8 *source = (uint8 *)*_buffer;
    -
    -	if (user_memcpy((uint8 *)fBuffer + fBytesRead, source, bytes) < B_OK) {
    -		release_sem(fLock);
    -		return B_BAD_ADDRESS;
    -	}
    -
    -	fBytesRead += bytes;
    -	*_buffer = (void *)(source + bytes);
    -	*_bytesLeft -= bytes;
    -
    -	release_sem(fLock);
    +	remove_select_sync_pool_entry(pool, sync, event);
     	return B_OK;
     }
     
    @@ -1353,11 +1296,15 @@
     	TRACE(("pipefs_read(vnode = %p, cookie = %p, length = %lu, mode = %d)\n",
     		_node, cookie, *_length, cookie->open_mode));
     
    +	if (!S_ISFIFO(inode->Type()))
    +		return B_IS_A_DIRECTORY;
    +
     	if ((cookie->open_mode & O_RWMASK) != O_RDONLY)
     		return B_NOT_ALLOWED;
     
    +	BenaphoreLocker locker(inode->RequestLock());
    +
     	if (inode->WriterCount() == 0) {
    -		BenaphoreLocker locker(inode->RequestLock());
     
     		// as long there is no writer, and the pipe is empty,
     		// we always just return 0 to indicate end of file
    @@ -1369,22 +1316,20 @@
     
     	// issue read request
     
    -	ReadRequest request(buffer, *_length);
    -	if (inode->AddRequest(request) != B_OK)
    -		return B_ERROR;
    +	ReadRequest request;
    +	inode->AddRequest(request);
     
    -	// wait for it to be filled
    +	size_t length = *_length;
    +	status_t status = inode->ReadDataFromBuffer(buffer, &length,
    +		(cookie->open_mode & O_NONBLOCK) != 0, request);
     
    -	status_t status = request.Wait((cookie->open_mode & O_NONBLOCK) != 0);
     	inode->RemoveRequest(request);
    +	inode->NotifyReadDone();
     
    -	if ((status == B_TIMED_OUT || status == B_INTERRUPTED || status == B_WOULD_BLOCK)
    -		&& request.BytesRead() > 0)
    +	if (length > 0)
     		status = B_OK;
     
    -	if (status == B_OK)
    -		*_length = request.BytesRead();
    -
    +	*_length = length;
     	return status;
     }
     
    @@ -1399,37 +1344,28 @@
     	TRACE(("pipefs_write(vnode = %p, cookie = %p, length = %lu)\n",
     		_node, cookie, *_length));
     
    +	if (!S_ISFIFO(inode->Type()))
    +		return B_IS_A_DIRECTORY;
    +
     	if ((cookie->open_mode & O_RWMASK) != O_WRONLY)
     		return B_NOT_ALLOWED;
     
    -	if (inode->ReaderCount() == 0) {
    -		// if there is no reader yet, we signal the thread and return
    -		send_signal(find_thread(NULL), SIGPIPE);
    -		return EPIPE;
    -	}
    -
     	BenaphoreLocker locker(inode->RequestLock());
     
    -	size_t bytesLeft = *_length;
    -	inode->FillPendingRequests(&buffer, &bytesLeft);	
    +	size_t length = *_length;
    +	if (length == 0)
    +		return B_OK;
     
    -	status_t status;
    +	// copy data into ring buffer
    +	status_t status = inode->WriteDataToBuffer(buffer, &length,
    +		(cookie->open_mode & O_NONBLOCK) != 0);
     
    -	if (bytesLeft != 0) {
    -		// we could not place all our data in pending requests, so
    -		// have to put them into a temporary buffer
    +	inode->NotifyWriteDone();
     
    -		status = inode->WriteDataToBuffer(&buffer, &bytesLeft,
    -			(cookie->open_mode & O_NONBLOCK) != 0);
    -		if (status == B_OK) {
    -			inode->FillPendingRequests();
    -			*_length -= bytesLeft;
    -		}
    -	} else {
    -		// could write everything without the need to copy!
    +	if (length > 0)
     		status = B_OK;
    -	}
     
    +	*_length = length;
     	return status;
     }
     
    @@ -1624,13 +1560,15 @@
     pipefs_select(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, uint8 event,
     	uint32 ref, selectsync *sync)
     {
    +	file_cookie *cookie = (file_cookie *)_cookie;
    +
     	TRACE(("pipefs_select(vnode = %p)\n", _node));
     	Inode *inode = (Inode *)_node;
     	if (!inode)
     		return B_ERROR;
     
     	BenaphoreLocker locker(inode->RequestLock());
    -	return inode->Select(event, ref, sync);
    +	return inode->Select(event, ref, sync, cookie->open_mode);
     }
     
     
    @@ -1638,13 +1576,15 @@
     pipefs_deselect(fs_volume _fs, fs_vnode _node, fs_cookie _cookie, uint8 event,
     	selectsync *sync)
     {
    +	file_cookie *cookie = (file_cookie *)_cookie;
    +
     	TRACE(("pipefs_deselect(vnode = %p)\n", _node));
     	Inode *inode = (Inode *)_node;
     	if (!inode)
     		return B_ERROR;
     	
     	BenaphoreLocker locker(inode->RequestLock());
    -	return inode->Deselect(event, sync);
    +	return inode->Deselect(event, sync, cookie->open_mode);
     }
     
     
    
    
    
    From bonefish at mail.berlios.de  Sun Sep 30 02:52:06 2007
    From: bonefish at mail.berlios.de (bonefish at BerliOS)
    Date: Sun, 30 Sep 2007 02:52:06 +0200
    Subject: [Haiku-commits] r22379 - haiku/trunk/src/add-ons/kernel/drivers/tty
    Message-ID: <200709300052.l8U0q6Rp029877@sheep.berlios.de>
    
    Author: bonefish
    Date: 2007-09-30 02:52:06 +0200 (Sun, 30 Sep 2007)
    New Revision: 22379
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22379&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
    Log:
    Notifying readers and select() takes canonical input processing into
    account when checking for the number of readable bytes. For readers
    it doesn't make a difference, since they were looping anyway, but
    select() would report read-availability incorrectly.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2007-09-29 23:52:23 UTC (rev 22378)
    +++ haiku/trunk/src/add-ons/kernel/drivers/tty/tty.cpp	2007-09-30 00:52:06 UTC (rev 22379)
    @@ -1099,7 +1099,16 @@
     	if (!tty)
     		return;
     
    -	int32 readable = line_buffer_readable(tty->input_buffer);
    +	// Check, if something is readable (depending on whether canonical input
    +	// processing is enabled).
    +	int32 readable;
    +	if (!tty->is_master && (tty->settings->termios.c_lflag & ICANON) != 0) {
    +		readable = line_buffer_readable_line(tty->input_buffer,
    +			tty->settings->termios.c_cc[VEOL],
    +			tty->settings->termios.c_cc[VEOF]);
    +	} else
    +		readable = line_buffer_readable(tty->input_buffer);
    +
     	if (readable > 0) {
     		// if nobody is waiting send select events, otherwise notify the waiter
     		if (!tty->reader_queue.IsEmpty())
    
    
    
    From stippi at mail.berlios.de  Sun Sep 30 09:54:58 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sun, 30 Sep 2007 09:54:58 +0200
    Subject: [Haiku-commits] r22380 - haiku/trunk/build/jam
    Message-ID: <200709300754.l8U7sw4A028295@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-30 09:54:58 +0200 (Sun, 30 Sep 2007)
    New Revision: 22380
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22380&view=rev
    
    Modified:
       haiku/trunk/build/jam/HaikuImage
    Log:
    * updated WonderBrush location to the new release
    
    
    Modified: haiku/trunk/build/jam/HaikuImage
    ===================================================================
    --- haiku/trunk/build/jam/HaikuImage	2007-09-30 00:52:06 UTC (rev 22379)
    +++ haiku/trunk/build/jam/HaikuImage	2007-09-30 07:54:58 UTC (rev 22380)
    @@ -419,7 +419,7 @@
     # WonderBrush
     if [ IsOptionalHaikuImagePackageAdded WonderBrush ] {
     	InstallOptionalHaikuImagePackage WonderBrush
    -		: http://www.yellowbites.com/downloads/WonderBrush-2.0.2-demo-x86-R5.zip
    +		: http://www.yellowbites.com/downloads/WonderBrush-2.1.1-demo-x86-R5.zip
     		: apps
     	;
     	AddSymlinkToHaikuImage home config be Applications
    
    
    
    From stippi at mail.berlios.de  Sun Sep 30 11:34:42 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sun, 30 Sep 2007 11:34:42 +0200
    Subject: [Haiku-commits] r22381 - in haiku/trunk/data/artwork: . icons
    Message-ID: <200709300934.l8U9YgoM032582@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-30 11:34:20 +0200 (Sun, 30 Sep 2007)
    New Revision: 22381
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22381&view=rev
    
    Added:
       haiku/trunk/data/artwork/icons/
       haiku/trunk/data/artwork/icons/Action_Login
       haiku/trunk/data/artwork/icons/Action_Logout
       haiku/trunk/data/artwork/icons/Action_Submit
       haiku/trunk/data/artwork/icons/Alert_Info
       haiku/trunk/data/artwork/icons/Alert_Stop
       haiku/trunk/data/artwork/icons/Alert_Warning
       haiku/trunk/data/artwork/icons/App_About
       haiku/trunk/data/artwork/icons/App_About_2
       haiku/trunk/data/artwork/icons/App_CDPlayer
       haiku/trunk/data/artwork/icons/App_Calculator
       haiku/trunk/data/artwork/icons/App_Calculator_2
       haiku/trunk/data/artwork/icons/App_Clock
       haiku/trunk/data/artwork/icons/App_Cortex
       haiku/trunk/data/artwork/icons/App_Deskbar
       haiku/trunk/data/artwork/icons/App_Diskprobe
       haiku/trunk/data/artwork/icons/App_Expander
       haiku/trunk/data/artwork/icons/App_Expander_2
       haiku/trunk/data/artwork/icons/App_Generic
       haiku/trunk/data/artwork/icons/App_Generic_2
       haiku/trunk/data/artwork/icons/App_Generic_3
       haiku/trunk/data/artwork/icons/App_Icon-O-Matic
       haiku/trunk/data/artwork/icons/App_Installer
       haiku/trunk/data/artwork/icons/App_Launchbox
       haiku/trunk/data/artwork/icons/App_Magnify
       haiku/trunk/data/artwork/icons/App_Mail
       haiku/trunk/data/artwork/icons/App_MediaPlayer
       haiku/trunk/data/artwork/icons/App_MediaPlayer_2
       haiku/trunk/data/artwork/icons/App_MidiPlayer
       haiku/trunk/data/artwork/icons/App_Pe
       haiku/trunk/data/artwork/icons/App_People
       haiku/trunk/data/artwork/icons/App_PowerStatus
       haiku/trunk/data/artwork/icons/App_Pulse
       haiku/trunk/data/artwork/icons/App_ShowImage
       haiku/trunk/data/artwork/icons/App_SoundRecorder
       haiku/trunk/data/artwork/icons/App_StyledEdit
       haiku/trunk/data/artwork/icons/App_TV
       haiku/trunk/data/artwork/icons/App_Teapot
       haiku/trunk/data/artwork/icons/App_Terminal
       haiku/trunk/data/artwork/icons/App_Tracker
       haiku/trunk/data/artwork/icons/App_VLC
       haiku/trunk/data/artwork/icons/App_Vision
       haiku/trunk/data/artwork/icons/App_Wonderbrush
       haiku/trunk/data/artwork/icons/App_Workspaces
       haiku/trunk/data/artwork/icons/App_Zip-O-Matic
       haiku/trunk/data/artwork/icons/Device_CD
       haiku/trunk/data/artwork/icons/Device_Floppy
       haiku/trunk/data/artwork/icons/Device_Harddisk
       haiku/trunk/data/artwork/icons/Device_Harddisk_boot
       haiku/trunk/data/artwork/icons/Device_Volume
       haiku/trunk/data/artwork/icons/File_Archive
       haiku/trunk/data/artwork/icons/File_Archive_BZ2
       haiku/trunk/data/artwork/icons/File_Archive_GZ
       haiku/trunk/data/artwork/icons/File_Archive_LHA
       haiku/trunk/data/artwork/icons/File_Archive_RAR
       haiku/trunk/data/artwork/icons/File_Archive_TAR
       haiku/trunk/data/artwork/icons/File_Archive_ZIP
       haiku/trunk/data/artwork/icons/File_Audio
       haiku/trunk/data/artwork/icons/File_Audio_2
       haiku/trunk/data/artwork/icons/File_Bookmark
       haiku/trunk/data/artwork/icons/File_Broken_Link
       haiku/trunk/data/artwork/icons/File_Generic
       haiku/trunk/data/artwork/icons/File_HTML
       haiku/trunk/data/artwork/icons/File_IDE_Project
       haiku/trunk/data/artwork/icons/File_Mail
       haiku/trunk/data/artwork/icons/File_Mail_2
       haiku/trunk/data/artwork/icons/File_Mail_3
       haiku/trunk/data/artwork/icons/File_PDF
       haiku/trunk/data/artwork/icons/File_Person
       haiku/trunk/data/artwork/icons/File_Person_smaller
       haiku/trunk/data/artwork/icons/File_Query
       haiku/trunk/data/artwork/icons/File_Query_2
       haiku/trunk/data/artwork/icons/File_Query_Template
       haiku/trunk/data/artwork/icons/File_Resource
       haiku/trunk/data/artwork/icons/File_SourceCode
       haiku/trunk/data/artwork/icons/File_Stack
       haiku/trunk/data/artwork/icons/File_Text
       haiku/trunk/data/artwork/icons/File_Video
       haiku/trunk/data/artwork/icons/Folder_apps
       haiku/trunk/data/artwork/icons/Folder_config
       haiku/trunk/data/artwork/icons/Folder_development
       haiku/trunk/data/artwork/icons/Folder_download
       haiku/trunk/data/artwork/icons/Folder_fonts
       haiku/trunk/data/artwork/icons/Folder_generic
       haiku/trunk/data/artwork/icons/Folder_haiku
       haiku/trunk/data/artwork/icons/Folder_home
       haiku/trunk/data/artwork/icons/Folder_mail
       haiku/trunk/data/artwork/icons/Folder_people
       haiku/trunk/data/artwork/icons/Folder_prefs
       haiku/trunk/data/artwork/icons/Folder_queries
       haiku/trunk/data/artwork/icons/Misc_Earth
       haiku/trunk/data/artwork/icons/Misc_Text_Image
       haiku/trunk/data/artwork/icons/Misc_Trash_Contents
       haiku/trunk/data/artwork/icons/Misc_Window
       haiku/trunk/data/artwork/icons/Overlay_apps
       haiku/trunk/data/artwork/icons/Overlay_development
       haiku/trunk/data/artwork/icons/Overlay_download
       haiku/trunk/data/artwork/icons/Overlay_gear
       haiku/trunk/data/artwork/icons/Overlay_house
       haiku/trunk/data/artwork/icons/Overlay_leaf
       haiku/trunk/data/artwork/icons/Overlay_mail
       haiku/trunk/data/artwork/icons/Overlay_pen
       haiku/trunk/data/artwork/icons/Overlay_people
       haiku/trunk/data/artwork/icons/Overlay_prefs
       haiku/trunk/data/artwork/icons/Overlay_query
       haiku/trunk/data/artwork/icons/Prefs_Appearance
       haiku/trunk/data/artwork/icons/Prefs_Backgrounds
       haiku/trunk/data/artwork/icons/Prefs_DataTranslation
       haiku/trunk/data/artwork/icons/Prefs_Devices
       haiku/trunk/data/artwork/icons/Prefs_Filetypes
       haiku/trunk/data/artwork/icons/Prefs_Fonts
       haiku/trunk/data/artwork/icons/Prefs_Joystick
       haiku/trunk/data/artwork/icons/Prefs_Keyboard
       haiku/trunk/data/artwork/icons/Prefs_Keymap
       haiku/trunk/data/artwork/icons/Prefs_Media
       haiku/trunk/data/artwork/icons/Prefs_Menu
       haiku/trunk/data/artwork/icons/Prefs_Modem
       haiku/trunk/data/artwork/icons/Prefs_Mouse
       haiku/trunk/data/artwork/icons/Prefs_Printer
       haiku/trunk/data/artwork/icons/Prefs_Screen
       haiku/trunk/data/artwork/icons/Prefs_ScreenSaver
       haiku/trunk/data/artwork/icons/Prefs_Sounds
       haiku/trunk/data/artwork/icons/Prefs_VirtualMemory
       haiku/trunk/data/artwork/icons/System_Kernel
       haiku/trunk/data/artwork/icons/Trash_Empty
       haiku/trunk/data/artwork/icons/Trash_Full
       haiku/trunk/data/artwork/icons/Tray_Network
       haiku/trunk/data/artwork/icons/Tray_Network_no_connection
       haiku/trunk/data/artwork/icons/Tray_Network_no_device
       haiku/trunk/data/artwork/icons/Tray_Network_no_settings
       haiku/trunk/data/artwork/icons/Tray_Network_ready
    Log:
    * all the icons in native Icon-O-Matic format (including named paths, styles and
      shapes) which have so far been done for Haiku, the website and other apps
    
    
    Added: haiku/trunk/data/artwork/icons/Action_Login
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Action_Login
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Action_Logout
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Action_Logout
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Action_Submit
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Action_Submit
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Alert_Info
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Alert_Info
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Alert_Stop
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Alert_Stop
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Alert_Warning
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Alert_Warning
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_About
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_About
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_About_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_About_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_CDPlayer
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_CDPlayer
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Calculator
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Calculator
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Calculator_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Calculator_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Clock
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Clock
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Cortex
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Cortex
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Deskbar
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Deskbar
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Diskprobe
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Diskprobe
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Expander
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Expander
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Expander_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Expander_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Generic
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Generic
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Generic_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Generic_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Generic_3
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Generic_3
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Icon-O-Matic
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Icon-O-Matic
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Installer
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Installer
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Launchbox
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Launchbox
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Magnify
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Magnify
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Mail
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Mail
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_MediaPlayer
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_MediaPlayer
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_MediaPlayer_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_MediaPlayer_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_MidiPlayer
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_MidiPlayer
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Pe
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Pe
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_People
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_People
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_PowerStatus
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_PowerStatus
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Pulse
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Pulse
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_ShowImage
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_ShowImage
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_SoundRecorder
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_SoundRecorder
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_StyledEdit
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_StyledEdit
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_TV
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_TV
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Teapot
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Teapot
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Terminal
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Terminal
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Tracker
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Tracker
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_VLC
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_VLC
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Vision
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Vision
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Workspaces
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Workspaces
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/App_Zip-O-Matic
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/App_Zip-O-Matic
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Device_CD
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Device_CD
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Device_Floppy
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Device_Floppy
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Device_Harddisk
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Device_Harddisk
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Device_Harddisk_boot
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Device_Harddisk_boot
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Device_Volume
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Device_Volume
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_BZ2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_BZ2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_GZ
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_GZ
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_LHA
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_LHA
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_RAR
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_RAR
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_TAR
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_TAR
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Archive_ZIP
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Archive_ZIP
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Audio
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Audio
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Audio_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Audio_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Bookmark
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Bookmark
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Broken_Link
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Broken_Link
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Generic
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Generic
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_HTML
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_HTML
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_IDE_Project
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_IDE_Project
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Mail
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Mail
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Mail_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Mail_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Mail_3
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Mail_3
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_PDF
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_PDF
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Person
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Person
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Person_smaller
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Person_smaller
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Query
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Query
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Query_2
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Query_2
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Query_Template
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Query_Template
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Resource
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Resource
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_SourceCode
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_SourceCode
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Stack
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Stack
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Text
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Text
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/File_Video
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/File_Video
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_apps
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_apps
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_config
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_config
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_development
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_development
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_download
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_download
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_fonts
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_fonts
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_generic
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_generic
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_haiku
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_haiku
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_home
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_home
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_mail
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_mail
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_people
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_people
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_prefs
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_prefs
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Folder_queries
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Folder_queries
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Misc_Earth
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Misc_Earth
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Misc_Text_Image
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Misc_Text_Image
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Misc_Trash_Contents
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Misc_Trash_Contents
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Misc_Window
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Misc_Window
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_apps
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_apps
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_development
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_development
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_download
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_download
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_gear
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_gear
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_house
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_house
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_leaf
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_leaf
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Overlay_mail
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Overlay_mail
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    
    [... truncated: 300 lines follow ...]
    
    
    From axeld at mail.berlios.de  Sun Sep 30 11:36:30 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sun, 30 Sep 2007 11:36:30 +0200
    Subject: [Haiku-commits] r22382 - haiku/trunk/src/system/kernel/vm
    Message-ID: <200709300936.l8U9aU9x032704@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-30 11:36:28 +0200 (Sun, 30 Sep 2007)
    New Revision: 22382
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22382&view=rev
    
    Modified:
       haiku/trunk/src/system/kernel/vm/vm_page.cpp
    Log:
    * Decoupled the page_thief() from the low memory handler chain. This is
      necessary because low memory handlers might need to wait for other services
      while we need to make sure the page thief can always steal pages.
    * Made the page thief more aggressive when memory is critical: added a third
      run where it will also steal a small amount of active pages to keep things
      going.
    * The page thief did not maintain the cache's reference correctly in all
      situations.
    
    
    Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp
    ===================================================================
    --- haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-30 09:34:20 UTC (rev 22381)
    +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp	2007-09-30 09:36:28 UTC (rev 22382)
    @@ -61,6 +61,7 @@
     static ConditionVariable sFreePageCondition;
     static spinlock sPageLock;
     
    +static sem_id sThiefWaitSem;
     static sem_id sWriterWaitSem;
     
     
    @@ -713,7 +714,7 @@
     
     			locker.Unlock();
     
    -			//dprintf("write page %p\n", page);
    +			//dprintf("write page %p, cache %p (%ld)\n", page, page->cache, page->cache->ref_count);
     			vm_clear_map_flags(page, PAGE_MODIFIED);
     			vm_cache_acquire_ref(page->cache);
     			pages[numPages++] = page;
    @@ -759,79 +760,123 @@
     }
     
     
    -static void
    -page_thief(void* /*unused*/, int32 level)
    +static status_t
    +page_thief(void* /*unused*/)
     {
    -	uint32 steal;
    -	int32 score;
    +	bigtime_t timeout = B_INFINITE_TIMEOUT;
     
    -	switch (level) {
    -		default:
    -		case B_LOW_MEMORY_NOTE:
    -			steal = 10;
    -			score = -20;
    -			break;
    -		case B_LOW_MEMORY_WARNING:
    -			steal = 50;
    -			score = -5;
    -			break;
    -		case B_LOW_MEMORY_CRITICAL:
    -			steal = 500;
    -			score = -1;
    -			break;
    -	}
    +	while (true) {
    +		acquire_sem_etc(sThiefWaitSem, 1, B_RELATIVE_TIMEOUT, timeout);
     
    -	vm_page* page = NULL;
    -	InterruptsSpinLocker locker(sPageLock);
    +		int32 state = vm_low_memory_state();
    +		uint32 steal;
    +		int32 score;
    +		switch (state) {
    +			default:
    +				timeout = B_INFINITE_TIMEOUT;
    +				continue;
     
    -	while (steal > 0) {
    -		if (!locker.IsLocked())
    -			locker.Lock();
    +			case B_LOW_MEMORY_NOTE:
    +				steal = 10;
    +				score = -20;
    +				timeout = 1000000;
    +				break;
    +			case B_LOW_MEMORY_WARNING:
    +				steal = 50;
    +				score = -5;
    +				timeout = 1000000;
    +				break;
    +			case B_LOW_MEMORY_CRITICAL:
    +				steal = 500;
    +				score = -1;
    +				timeout = 100000;
    +				break;
    +		}
    +		//dprintf("page thief running - target %ld...\n", steal);
     
    -		// find a candidate to steal from the inactive queue
    +		vm_page* page = NULL;
    +		bool stealActive = false;
    +		InterruptsSpinLocker locker(sPageLock);
     
    -		for (int32 i = sActivePageQueue.count; i-- > 0;) {
    -			// move page to the tail of the queue so that we don't
    -			// scan it again directly
    -			page = dequeue_page(&sActivePageQueue);
    -			enqueue_page(&sActivePageQueue, page);
    +		while (steal > 0) {
    +			if (!locker.IsLocked())
    +				locker.Lock();
     
    -			if (page->state == PAGE_STATE_INACTIVE
    -				&& page->usage_count <= score)
    -				break;
    -		}
    +			// find a candidate to steal from the inactive queue
     
    -		if (page == NULL) {
    -			if (score == 0)
    -				break;
    +			for (int32 i = sActivePageQueue.count; i-- > 0;) {
    +				// move page to the tail of the queue so that we don't
    +				// scan it again directly
    +				page = dequeue_page(&sActivePageQueue);
    +				enqueue_page(&sActivePageQueue, page);
     
    -			score = 0;
    -			continue;
    -		}
    +				if ((page->state == PAGE_STATE_INACTIVE
    +						|| stealActive && page->state == PAGE_STATE_ACTIVE)
    +					&& page->usage_count <= score)
    +					break;
    +			}
     
    -		locker.Unlock();
    +			if (page == NULL) {
    +				if (score == 0) {
    +					if (state != B_LOW_MEMORY_CRITICAL)
    +						break;
    +					if (stealActive && score > 5)
    +						break;
     
    -		// try to lock the page's cache
    +					// when memory is really low, we really want pages
    +					if (stealActive)
    +						score = 127;
    +					else {
    +						stealActive = true;
    +						score = 5;
    +						steal = 5;
    +					}
    +					continue;
    +				}
     
    -		vm_cache* cache = vm_cache_acquire_page_cache_ref(page);
    -		if (cache == NULL)
    -			continue;
    +				score = 0;
    +				continue;
    +			}
     
    -		if (mutex_trylock(&cache->lock) != B_OK
    -			|| page->state != PAGE_STATE_INACTIVE) {
    +			locker.Unlock();
    +
    +			// try to lock the page's cache
    +
    +			vm_cache* cache = vm_cache_acquire_page_cache_ref(page);
    +			if (cache == NULL)
    +				continue;
    +
    +			if (mutex_trylock(&cache->lock) != B_OK) {
    +				vm_cache_release_ref(cache);
    +				continue;
    +			}
    +			if (page->state != PAGE_STATE_INACTIVE) {
    +				mutex_unlock(&cache->lock);
    +				vm_cache_release_ref(cache);
    +				continue;
    +			}
    +
    +			// we can now steal this page
    +
    +			//dprintf("  steal page %p from cache %p\n", page, cache);
    +			vm_remove_all_page_mappings(page);
    +			vm_cache_remove_page(cache, page);
    +			vm_page_set_state(page, PAGE_STATE_FREE);
    +			steal--;
    +
    +			mutex_unlock(&cache->lock);
     			vm_cache_release_ref(cache);
    -			continue;
     		}
    +	}
     
    -		// we can now steal this page
    +	return B_OK;
    +}
     
    -		vm_cache_remove_page(cache, page);
    -		vm_page_set_state(page, PAGE_STATE_FREE);
    -		steal--;
     
    -		mutex_unlock(&cache->lock);
    -		vm_cache_release_ref(cache);
    -	}
    +static void
    +schedule_page_thief(void* /*unused*/, int32 level)
    +{
    +	release_sem(sThiefWaitSem);
     }
     
     
    @@ -878,9 +923,7 @@
     		vm_clear_map_flags(page, PAGE_MODIFIED);
     
     		mutex_unlock(&cache->lock);
    -
     		status_t status = write_page(page, fsReenter);
    -
     		mutex_lock(&cache->lock);
     
     		InterruptsSpinLocker locker(&sPageLock);
    @@ -1032,20 +1075,25 @@
     	thread_id thread;
     
     	// create a kernel thread to clear out pages
    -	thread = spawn_kernel_thread(&page_scrubber, "page scrubber", B_LOWEST_ACTIVE_PRIORITY, NULL);
    +	thread = spawn_kernel_thread(&page_scrubber, "page scrubber",
    +		B_LOWEST_ACTIVE_PRIORITY, NULL);
     	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
     
     	new (&sFreePageCondition) ConditionVariable;
     	sFreePageCondition.Publish(&sFreePageQueue, "free page");
     
    -	register_low_memory_handler(page_thief, NULL, 0);
    -
     	sWriterWaitSem = create_sem(0, "page writer");
    +	sThiefWaitSem = create_sem(0, "page thief");
     
     	thread = spawn_kernel_thread(&page_writer, "page writer",
     		B_LOW_PRIORITY, NULL);
     	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
     
    +	thread = spawn_kernel_thread(&page_thief, "page thief",
    +		B_LOW_PRIORITY, NULL);
    +	send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
    +
    +	register_low_memory_handler(schedule_page_thief, NULL, 100);
     	return B_OK;
     }
     
    
    
    
    From stippi at mail.berlios.de  Sun Sep 30 11:49:04 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sun, 30 Sep 2007 11:49:04 +0200
    Subject: [Haiku-commits] r22383 - haiku/trunk/data/artwork/icons
    Message-ID: <200709300949.l8U9n4o9000995@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-30 11:49:01 +0200 (Sun, 30 Sep 2007)
    New Revision: 22383
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22383&view=rev
    
    Added:
       haiku/trunk/data/artwork/icons/Action_Search
       haiku/trunk/data/artwork/icons/Website_Comment
       haiku/trunk/data/artwork/icons/Website_Comment-add
       haiku/trunk/data/artwork/icons/Website_Comment-delete
       haiku/trunk/data/artwork/icons/Website_Comment-edit
       haiku/trunk/data/artwork/icons/Website_Comment-reply
       haiku/trunk/data/artwork/icons/Website_Comments
       haiku/trunk/data/artwork/icons/Website_Edit_Profile
       haiku/trunk/data/artwork/icons/Website_Email-post
       haiku/trunk/data/artwork/icons/Website_Login.wonderbrush
       haiku/trunk/data/artwork/icons/Website_Logout.wonderbrush
       haiku/trunk/data/artwork/icons/Website_New.wonderbrush
       haiku/trunk/data/artwork/icons/Website_Profile.wonderbrush
       haiku/trunk/data/artwork/icons/Website_Register
       haiku/trunk/data/artwork/icons/Website_Search.wonderbrush
       haiku/trunk/data/artwork/icons/Website_Submit
       haiku/trunk/data/artwork/icons/Website_Submit.wonderbrush
       haiku/trunk/data/artwork/icons/Website_Subscribe
       haiku/trunk/data/artwork/icons/Website_Subscription
       haiku/trunk/data/artwork/icons/Website_Unsubscribe
    Removed:
       haiku/trunk/data/artwork/icons/Action_Submit
    Log:
    * put more website icons under version control
    
    
    Added: haiku/trunk/data/artwork/icons/Action_Search
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Action_Search
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Deleted: haiku/trunk/data/artwork/icons/Action_Submit
    
    Added: haiku/trunk/data/artwork/icons/Website_Comment
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comment
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Comment-add
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comment-add
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Comment-delete
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comment-delete
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Comment-edit
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comment-edit
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Comment-reply
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comment-reply
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Comments
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Comments
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Edit_Profile
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Edit_Profile
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Email-post
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Email-post
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Login.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Login.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Logout.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Logout.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_New.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_New.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Profile.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Profile.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Register
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Register
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Search.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Search.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Copied: haiku/trunk/data/artwork/icons/Website_Submit (from rev 22381, haiku/trunk/data/artwork/icons/Action_Submit)
    ===================================================================
    (Binary files differ)
    
    Added: haiku/trunk/data/artwork/icons/Website_Submit.wonderbrush
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Submit.wonderbrush
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Subscribe
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Subscribe
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Subscription
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Subscription
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    Added: haiku/trunk/data/artwork/icons/Website_Unsubscribe
    ===================================================================
    (Binary files differ)
    
    
    Property changes on: haiku/trunk/data/artwork/icons/Website_Unsubscribe
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
    
    
    From axeld at mail.berlios.de  Sun Sep 30 12:52:46 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sun, 30 Sep 2007 12:52:46 +0200
    Subject: [Haiku-commits] r22384 - in haiku/trunk: headers/os/interface
    	src/kits/interface
    Message-ID: <200709301052.l8UAqkpb014415@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-30 12:52:45 +0200 (Sun, 30 Sep 2007)
    New Revision: 22384
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22384&view=rev
    
    Modified:
       haiku/trunk/headers/os/interface/Menu.h
       haiku/trunk/headers/os/interface/MenuItem.h
       haiku/trunk/src/kits/interface/Menu.cpp
       haiku/trunk/src/kits/interface/MenuBar.cpp
       haiku/trunk/src/kits/interface/MenuItem.cpp
    Log:
    * Rewrote the trigger selection mechanism: it now searches for uppercase
      characters first, and then falls back to take everything. fTrigger is now
      uint32 and works with all unicode characters; unlike in BeOS, the
      MenuTriggerTest application now works correctly in Haiku.
    * fTriggerIndex is now a character position, not a byte position of the label;
      this allows BMenuItem::DrawContent() to draw the trigger at the correct
      position, even if there are multi-byte UTF-8 characters.
    * The above fixed bug #1506; triggers are still not working, though.
    * Rewrote Menu.h header.
    * Renamed all private methods (that are not called by BWindow) to have the
      underscore prefix.
    * Removed unused methods.
    * Some minor cleanup.
    
    
    Modified: haiku/trunk/headers/os/interface/Menu.h
    ===================================================================
    --- haiku/trunk/headers/os/interface/Menu.h	2007-09-30 09:49:01 UTC (rev 22383)
    +++ haiku/trunk/headers/os/interface/Menu.h	2007-09-30 10:52:45 UTC (rev 22384)
    @@ -1,33 +1,25 @@
    -/*******************************************************************************
    -/
    -/	File:			Menu.h
    -/
    -/   Description:    BMenu display a menu of selectable items.
    -/
    -/	Copyright 1994-98, Be Incorporated, All Rights Reserved
    -/
    -*******************************************************************************/
    -
    +/*
    + * Copyright 2007, Haiku, Inc. All Rights Reserved.
    + * Distributed under the terms of the MIT License.
    + */
     #ifndef _MENU_H
     #define _MENU_H
     
    -#include 
    +
     #include 
     #include 
     #include 
     
    -/*----------------------------------------------------------------*/
    -/*----- Menu declarations and structures -------------------------*/
    -
     class BMenuItem;
     class BMenuBar;
     
    +
     namespace BPrivate {
     	class BMenuWindow;
    +	class ExtraMenuData;
    +	class TriggerList;
     }
     
    -class _ExtraMenuData_;
    -
     enum menu_layout {
     	B_ITEMS_IN_ROW = 0,
     	B_ITEMS_IN_COLUMN,
    @@ -44,281 +36,242 @@
     	bool		triggers_always_shown;
     };
     
    -_IMPEXP_BE status_t	set_menu_info(menu_info *info);
    -_IMPEXP_BE status_t	get_menu_info(menu_info *info);
    +status_t get_menu_info(menu_info* info);
    +status_t set_menu_info(menu_info* info);
     
    -typedef bool (* menu_tracking_hook )(BMenu *, void *);
    +typedef bool (*menu_tracking_hook)(BMenu* menu, void* state);
     
    -/*----------------------------------------------------------------*/
    -/*----- BMenu class ----------------------------------------------*/
     
    -class BMenu : public BView
    -{
    +class BMenu : public BView {
     public:
    -						BMenu(	const char *title,
    +							BMenu(const char* title,
     								menu_layout layout = B_ITEMS_IN_COLUMN);
    -						BMenu(const char *title, float width, float height);
    -virtual					~BMenu();
    +							BMenu(const char* title, float width, float height);
    +	virtual					~BMenu();
     
    -						BMenu(BMessage *data);
    -static	BArchivable		*Instantiate(BMessage *data);
    -virtual	status_t		Archive(BMessage *data, bool deep = true) const;
    +							BMenu(BMessage* archive);
    +	static	BArchivable*	Instantiate(BMessage* archive);
    +	virtual	status_t		Archive(BMessage* archive, bool deep = true) const;
     
    -virtual void			AttachedToWindow();
    -virtual void			DetachedFromWindow();
    +	virtual void			AttachedToWindow();
    +	virtual void			DetachedFromWindow();
     
    -		bool			AddItem(BMenuItem *item);
    -		bool			AddItem(BMenuItem *item, int32 index);
    -		bool			AddItem(BMenuItem *item, BRect frame);
    -		bool			AddItem(BMenu *menu);
    -		bool			AddItem(BMenu *menu, int32 index);
    -		bool			AddItem(BMenu *menu, BRect frame);
    -		bool			AddList(BList *list, int32 index);
    -		bool			AddSeparatorItem();
    -		bool			RemoveItem(BMenuItem *item);
    -		BMenuItem		*RemoveItem(int32 index);
    -		bool			RemoveItems(int32 index,
    -									int32 count,
    -									bool del = false);
    -		bool			RemoveItem(BMenu *menu);
    +			bool			AddItem(BMenuItem* item);
    +			bool			AddItem(BMenuItem* item, int32 index);
    +			bool			AddItem(BMenuItem* item, BRect frame);
    +			bool			AddItem(BMenu* menu);
    +			bool			AddItem(BMenu* menu, int32 index);
    +			bool			AddItem(BMenu* menu, BRect frame);
    +			bool			AddList(BList* list, int32 index);
     
    -		BMenuItem		*ItemAt(int32 index) const;
    -		BMenu			*SubmenuAt(int32 index) const;
    -		int32			CountItems() const;
    -		int32			IndexOf(BMenuItem *item) const;
    -		int32			IndexOf(BMenu *menu) const;
    -		BMenuItem		*FindItem(uint32 command) const;
    -		BMenuItem		*FindItem(const char *name) const;
    +			bool			AddSeparatorItem();
     
    -virtual	status_t		SetTargetForItems(BHandler *target);
    -virtual	status_t		SetTargetForItems(BMessenger messenger);
    -virtual	void			SetEnabled(bool state);
    -virtual	void			SetRadioMode(bool state);
    -virtual	void			SetTriggersEnabled(bool state);
    -virtual void			SetMaxContentWidth(float max);
    +			bool			RemoveItem(BMenuItem* item);
    +			BMenuItem*		RemoveItem(int32 index);
    +			bool			RemoveItems(int32 index, int32 count,
    +								bool deleteItems = false);
    +			bool			RemoveItem(BMenu* menu);
     
    -		void			SetLabelFromMarked(bool on);
    -		bool			IsLabelFromMarked();
    -		bool			IsEnabled() const;	
    -		bool			IsRadioMode() const;
    -		bool			AreTriggersEnabled() const;
    -		bool			IsRedrawAfterSticky() const;
    -		float			MaxContentWidth() const;
    +			BMenuItem*		ItemAt(int32 index) const;
    +			BMenu*			SubmenuAt(int32 index) const;
    +			int32			CountItems() const;
    +			int32			IndexOf(BMenuItem* item) const;
    +			int32			IndexOf(BMenu* menu) const;
    +			BMenuItem*		FindItem(uint32 command) const;
    +			BMenuItem*		FindItem(const char* name) const;
     
    -		BMenuItem		*FindMarked();
    +	virtual	status_t		SetTargetForItems(BHandler* target);
    +	virtual	status_t		SetTargetForItems(BMessenger messenger);
    +	virtual	void			SetEnabled(bool state);
    +	virtual	void			SetRadioMode(bool state);
    +	virtual	void			SetTriggersEnabled(bool state);
    +	virtual	void			SetMaxContentWidth(float maxWidth);
     
    -		BMenu			*Supermenu() const;
    -		BMenuItem		*Superitem() const;
    +			void			SetLabelFromMarked(bool state);
    +			bool			IsLabelFromMarked();
    +			bool			IsEnabled() const;
    +			bool			IsRadioMode() const;
    +			bool			AreTriggersEnabled() const;
    +			bool			IsRedrawAfterSticky() const;
    +			float			MaxContentWidth() const;
     
    -virtual void			MessageReceived(BMessage *msg);
    -virtual	void			KeyDown(const char *bytes, int32 numBytes);
    -virtual void			Draw(BRect updateRect);
    -virtual	BSize			MinSize();
    -virtual	BSize			MaxSize();
    -virtual	BSize			PreferredSize();
    -virtual void			GetPreferredSize(float *width, float *height);
    -virtual void			ResizeToPreferred();
    -virtual	void			DoLayout();
    -virtual	void			FrameMoved(BPoint new_position);
    -virtual	void			FrameResized(float new_width, float new_height);
    -		void			InvalidateLayout();
    -virtual	void			InvalidateLayout(bool descendants);
    -	
    -virtual BHandler		*ResolveSpecifier(BMessage *msg,
    -										int32 index,
    -										BMessage *specifier,
    -										int32 form,
    -										const char *property);
    -virtual status_t		GetSupportedSuites(BMessage *data);
    +			BMenuItem*		FindMarked();
     
    -virtual status_t		Perform(perform_code d, void *arg);
    +			BMenu*			Supermenu() const;
    +			BMenuItem*		Superitem() const;
     
    -virtual void		MakeFocus(bool state = true);
    -virtual void		AllAttached();
    -virtual void		AllDetached();
    +	virtual void			MessageReceived(BMessage* message);
    +	virtual	void			KeyDown(const char* bytes, int32 numBytes);
    +	virtual void			Draw(BRect updateRect);
    +	virtual	BSize			MinSize();
    +	virtual	BSize			MaxSize();
    +	virtual	BSize			PreferredSize();
    +	virtual void			GetPreferredSize(float* _width, float* _height);
    +	virtual void			ResizeToPreferred();
    +	virtual	void			DoLayout();
    +	virtual	void			FrameMoved(BPoint newPosition);
    +	virtual	void			FrameResized(float newWidth, float newHeight);
    +			void			InvalidateLayout();
    +	virtual	void			InvalidateLayout(bool descendants);
     
    +	virtual BHandler*		ResolveSpecifier(BMessage* message, int32 index,
    +								BMessage* specifier, int32 form,
    +								const char* property);
    +	virtual status_t		GetSupportedSuites(BMessage* data);
    +
    +	virtual status_t		Perform(perform_code d, void* arg);
    +
    +	virtual void			MakeFocus(bool focus = true);
    +	virtual void			AllAttached();
    +	virtual void			AllDetached();
    +
     protected:
    -				
    -					BMenu(	BRect frame,
    -							const char *viewName,
    -							uint32 resizeMask,
    -							uint32 flags,
    -							menu_layout layout,
    -							bool resizeToFit);
    +							BMenu(BRect frame, const char* name,
    +								uint32 resizeMask, uint32 flags,
    +								menu_layout layout, bool resizeToFit);
     
    -virtual	BPoint		ScreenLocation();
    +	virtual	BPoint			ScreenLocation();
     
    -		void		SetItemMargins(	float left, 
    -									float top, 
    -									float right, 
    -									float bottom);
    -		void		GetItemMargins(	float *left, 
    -									float *top, 
    -									float *right, 
    -									float *bottom) const;
    +			void			SetItemMargins(float left, float top, float right,
    +								float bottom);
    +			void			GetItemMargins(float* left, float* top,
    +								float* right, float* bottom) const;
     
    -		menu_layout	Layout() const;
    +			menu_layout		Layout() const;
     
    -virtual	void		Show();
    -		void		Show(bool selectFirstItem);
    -		void		Hide();
    -		BMenuItem	*Track(	bool start_opened = false,
    -							BRect *special_rect = NULL);
    -	
    +	virtual	void			Show();
    +			void			Show(bool selectFirstItem);
    +			void			Hide();
    +			BMenuItem*		Track(bool startOpened = false,
    +								BRect* specialRect = NULL);
    +
     public:
    -		enum add_state {
    -			B_INITIAL_ADD,
    -			B_PROCESSING,
    -			B_ABORT
    -		};
    -virtual	bool		AddDynamicItem(add_state s);
    -virtual void		DrawBackground(BRect update);
    +	enum add_state {
    +		B_INITIAL_ADD,
    +		B_PROCESSING,
    +		B_ABORT
    +	};
    +	virtual	bool			AddDynamicItem(add_state state);
    +	virtual void			DrawBackground(BRect update);
     
    -		void		SetTrackingHook(menu_tracking_hook func, void *state);
    -						
    -/*----- Private or reserved -----------------------------------------*/
    +			void			SetTrackingHook(menu_tracking_hook hook,
    +								void* state);
    +
     private:
    -friend class BWindow;
    -friend class BMenuBar;
    -friend class BMenuItem;
    -friend status_t _init_interface_kit_();
    -friend status_t	set_menu_info(menu_info *);
    -friend status_t	get_menu_info(menu_info *);
    +	friend class BWindow;
    +	friend class BMenuBar;
    +	friend class BMenuItem;
    +	friend status_t _init_interface_kit_();
    +	friend status_t	set_menu_info(menu_info* info);
    +	friend status_t	get_menu_info(menu_info* info);
     
    -struct LayoutData;
    +	struct LayoutData;
     
    -virtual	void			_ReservedMenu3();
    -virtual	void			_ReservedMenu4();
    -virtual	void			_ReservedMenu5();
    -virtual	void			_ReservedMenu6();
    +	virtual	void			_ReservedMenu3();
    +	virtual	void			_ReservedMenu4();
    +	virtual	void			_ReservedMenu5();
    +	virtual	void			_ReservedMenu6();
     
    -		BMenu			&operator=(const BMenu &);
    +			BMenu&			operator=(const BMenu& other);
     
    -		void		InitData(BMessage *data = NULL);
    -		bool		_show(bool selectFirstItem = false);
    -		void		_hide();
    -		BMenuItem	*_track(int *action, long start = -1);
    +			void			_InitData(BMessage* archive);
    +			bool			_Show(bool selectFirstItem = false);
    +			void			_Hide();
    +			BMenuItem*		_Track(int* action, long start = -1);
     
    -		void		_UpdateStateOpenSelect(BMenuItem *item, bigtime_t &openTime, bigtime_t &closeTime);
    -		void		_UpdateStateClose(BMenuItem *item, const BPoint &where, const uint32 &buttons);
    -		
    -		bool		_AddItem(BMenuItem *item, int32 index);
    -		bool		RemoveItems(int32 index,
    -								int32 count,
    -								BMenuItem *item,
    -								bool del = false);
    -		bool		RelayoutIfNeeded();
    -		void		LayoutItems(int32 index);
    -		BSize		_ValidatePreferredSize();
    -		void		ComputeLayout(int32 index, bool bestFit, bool moveItems,
    -								  float* width, float* height);
    -		void		_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, BRect &outRect);
    -		void		_ComputeRowLayout(int32 index, bool bestFit, bool moveItems, BRect &outRect);		
    -		void		_ComputeMatrixLayout(BRect &outRect);
    +			void			_UpdateStateOpenSelect(BMenuItem* item,
    +								bigtime_t& openTime, bigtime_t& closeTime);
    +			void			_UpdateStateClose(BMenuItem* item,
    +								const BPoint& where, const uint32& buttons);
     
    -		BRect		Bump(BRect current, BPoint extent, int32 index) const;
    -		BPoint		ItemLocInRect(BRect frame) const;
    -		BRect		CalcFrame(BPoint where, bool *scrollOn);
    -		bool		ScrollMenu(BRect bounds, BPoint loc, bool *fast);
    -		void		ScrollIntoView(BMenuItem *item);
    +			bool			_AddItem(BMenuItem* item, int32 index);
    +			bool			_RemoveItems(int32 index, int32 count,
    +								BMenuItem* item, bool deleteItems = false);
    +			bool			_RelayoutIfNeeded();
    +			void			_LayoutItems(int32 index);
    +			BSize			_ValidatePreferredSize();
    +			void			_ComputeLayout(int32 index, bool bestFit,
    +								bool moveItems, float* width, float* height);
    +			void			_ComputeColumnLayout(int32 index, bool bestFit,
    +								bool moveItems, BRect& outRect);
    +			void			_ComputeRowLayout(int32 index, bool bestFit,
    +								bool moveItems, BRect& outRect);		
    +			void			_ComputeMatrixLayout(BRect& outRect);
     
    -		void		DrawItems(BRect updateRect);
    -		int			State(BMenuItem **item = NULL) const;
    -		void		InvokeItem(BMenuItem *item, bool now = false);
    +			BRect			_CalcFrame(BPoint where, bool* scrollOn);
     
    -		bool		OverSuper(BPoint loc);
    -		bool		OverSubmenu(BMenuItem *item, BPoint loc);
    -		BPrivate::BMenuWindow* MenuWindow();
    -		void		DeleteMenuWindow();
    -		BMenuItem	*HitTestItems(BPoint where, BPoint slop = B_ORIGIN) const;
    -		BRect		Superbounds() const;
    -		void		CacheFontInfo();
    +			void			_DrawItems(BRect updateRect);
     
    -		void		ItemMarked(BMenuItem *item);
    -		void		Install(BWindow *target);
    -		void		Uninstall();
    -		void		_SelectItem(BMenuItem* item, bool showSubmenu = true,
    -						bool selectFirstItem = false);
    -		BMenuItem	*CurrentSelection() const;
    -		bool		SelectNextItem(BMenuItem *item, bool forward);
    -		BMenuItem	*NextItem(BMenuItem *item, bool forward) const;
    -		bool		IsItemVisible(BMenuItem *item) const;
    -		void		SetIgnoreHidden(bool on);
    -		void		SetStickyMode(bool on);
    -		bool		IsStickyMode() const;
    -		void		CalcTriggers();
    -		const char	*ChooseTrigger(const char *title, BList *chars);
    -		void		UpdateWindowViewSize(bool upWind = true);
    -		bool		IsStickyPrefOn();
    -		void		RedrawAfterSticky(BRect bounds);
    -		bool		OkToProceed(BMenuItem *);
    -		
    -		bool		CustomTrackingWantsToQuit();
    +			bool			_OverSuper(BPoint loc);
    +			bool			_OverSubmenu(BMenuItem* item, BPoint loc);
    +			BPrivate::BMenuWindow* _MenuWindow();
    +			void			_DeleteMenuWindow();
    +			BMenuItem*		_HitTestItems(BPoint where,
    +								BPoint slop = B_ORIGIN) const;
    +			BRect			_Superbounds() const;
    +			void			_CacheFontInfo();
     
    -		void		QuitTracking();
    -		
    +			void			_ItemMarked(BMenuItem* item);
    +			void			_Install(BWindow* target);
    +			void			_Uninstall();
    +			void			_SelectItem(BMenuItem* item,
    +								bool showSubmenu = true,
    +								bool selectFirstItem = false);
    +			bool			_SelectNextItem(BMenuItem* item, bool forward);
    +			BMenuItem*		_NextItem(BMenuItem* item, bool forward) const;
    +			void			_SetIgnoreHidden(bool on);
    +			void			_SetStickyMode(bool on);
    +			bool			_IsStickyMode() const;
    +			void			_CalcTriggers();
    +			bool			_ChooseTrigger(const char* title, int32& index,
    +								uint32& trigger, BPrivate::TriggerList& triggers);
    +			void			_UpdateWindowViewSize(bool updatePosition = true);
    +			bool			_OkToProceed(BMenuItem* item);
     
    -		status_t	ParseMsg(BMessage *msg, int32 *sindex, BMessage *spec,
    -						int32 *form, const char **prop,
    -						BMenu **tmenu, BMenuItem **titem, int32 *user_data,
    -						BMessage *reply) const;
    +			bool			_CustomTrackingWantsToQuit();
     
    -		status_t	DoMenuMsg(BMenuItem **next, BMenu *tar, BMessage *m,
    -						BMessage *r, BMessage *spec, int32 f) const;
    -		status_t	DoMenuItemMsg(BMenuItem **next, BMenu *tar, BMessage *m,
    -						BMessage *r, BMessage *spec, int32 f) const;
    +			// private methods called by BWindow
    +			int				State(BMenuItem** _item = NULL) const;
    +			void			InvokeItem(BMenuItem* item, bool now = false);
    +			void			QuitTracking();
     
    -		status_t	DoEnabledMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
    -						BMessage *r) const;
    -		status_t	DoLabelMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
    -						BMessage *r) const;
    -		status_t	DoMarkMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
    -						BMessage *r) const;
    -		status_t	DoDeleteMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
    -						BMessage *r) const;
    -		status_t	DoCreateMsg(BMenuItem *ti, BMenu *tm, BMessage *m,
    -						BMessage *r, bool menu) const;
    +	static	menu_info		sMenuInfo;
    +	static	bool			sAltAsCommandKey;
     
    -static	menu_info	sMenuInfo;
    -static	bool		sAltAsCommandKey;
    +			BMenuItem*		fChosenItem;
    +			BList			fItems;
    +			BRect			fPad;
    +			BMenuItem*		fSelected;
    +			BPrivate::BMenuWindow* fCachedMenuWindow;
    +			BMenu*			fSuper;
    +			BMenuItem*		fSuperitem;
    +			BRect			fSuperbounds;
    +			float			fAscent;
    +			float			fDescent;
    +			float			fFontHeight;
    +			uint32			fState;
    +			menu_layout		fLayout;
    +			BRect*			fExtraRect;
    +			float			fMaxContentWidth;
    +			BPoint*			fInitMatrixSize;
    +			BPrivate::ExtraMenuData* fExtraMenuData;
     
    -		BMenuItem	*fChosenItem;
    -		BList		fItems;
    -		BRect		fPad;
    -		BMenuItem	*fSelected;
    -		BPrivate::BMenuWindow* fCachedMenuWindow;
    -		BMenu		*fSuper;
    -		BMenuItem	*fSuperitem;
    -		BRect		fSuperbounds;
    -		float		fAscent;
    -		float		fDescent;
    -		float		fFontHeight;
    -		uint32		fState;
    -		menu_layout	fLayout;
    -		BRect		*fExtraRect;
    -		float		fMaxContentWidth;
    -		BPoint		*fInitMatrixSize;
    -		_ExtraMenuData_	*fExtraMenuData;
    +			LayoutData*		fLayoutData;
     
    -		LayoutData*	fLayoutData;
    +			int32			fSubmenus;
     
    -		int32		fSubmenus;
    -
    -		char		fTrigger;
    -		bool		fResizeToFit;
    -		bool		fUseCachedMenuLayout;
    -		bool		fEnabled;
    -		bool		fDynamicName;
    -		bool		fRadioMode;
    -		bool		fTrackNewBounds;
    -		bool		fStickyMode;
    -		bool		fIgnoreHidden;
    -		bool		fTriggerEnabled;
    -		bool		fRedrawAfterSticky;
    -		bool		fAttachAborted;
    +			char			fTrigger;
    +			bool			fResizeToFit;
    +			bool			fUseCachedMenuLayout;
    +			bool			fEnabled;
    +			bool			fDynamicName;
    +			bool			fRadioMode;
    +			bool			fTrackNewBounds;
    +			bool			fStickyMode;
    +			bool			fIgnoreHidden;
    +			bool			fTriggerEnabled;
    +			bool			fRedrawAfterSticky;
    +			bool			fAttachAborted;
     };
     
    -/*-------------------------------------------------------------*/
    -/*-------------------------------------------------------------*/
    -
    -#endif /* _MENU_H */
    +#endif	// _MENU_H
    
    Modified: haiku/trunk/headers/os/interface/MenuItem.h
    ===================================================================
    --- haiku/trunk/headers/os/interface/MenuItem.h	2007-09-30 09:49:01 UTC (rev 22383)
    +++ haiku/trunk/headers/os/interface/MenuItem.h	2007-09-30 10:52:45 UTC (rev 22384)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2006, Haiku, Inc. All Rights Reserved.
    + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
      * Distributed under the terms of the MIT License.
      */
     #ifndef _MENU_ITEM_H
    @@ -65,7 +65,7 @@
     		void				Uninstall();
     		void				SetSuper(BMenu* superMenu);
     		void				Select(bool select);
    -		void				SetAutomaticTrigger(char trigger);
    +		void				SetAutomaticTrigger(int32 index, uint32 trigger);
     
     	protected:
     		virtual	status_t	Invoke(BMessage *msg = NULL);
    @@ -91,13 +91,13 @@
     		float				fCachedWidth;
     		int16				fTriggerIndex;
     		char				fUserTrigger;
    -		char				fAutomaticTrigger;
     		char				fShortcutChar;
     		bool				fMark;
     		bool				fEnabled;
     		bool				fSelected;
    +		uint32				fTrigger;
     
    -		uint32				_reserved[4];
    +		uint32				_reserved[3];
     };
     
     // BSeparatorItem now has its own declaration file, but for source
    
    Modified: haiku/trunk/src/kits/interface/Menu.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/Menu.cpp	2007-09-30 09:49:01 UTC (rev 22383)
    +++ haiku/trunk/src/kits/interface/Menu.cpp	2007-09-30 10:52:45 UTC (rev 22384)
    @@ -1,5 +1,5 @@
     /*
    - * Copyright 2001-2006, Haiku, Inc.
    + * Copyright 2001-2007, Haiku, Inc.
      * Distributed under the terms of the MIT License.
      *
      * Authors:
    @@ -30,61 +30,82 @@
     #include 
     #include 
     
    +#include "utf8_functions.h"
    +
    +
     using std::nothrow;
     using BPrivate::BMenuWindow;
     
    +namespace BPrivate {
     
    -class _ExtraMenuData_ {
    +class TriggerList {
     public:
    +	TriggerList() {}
    +	~TriggerList() {}
    +
    +	// TODO: make this work with Unicode characters!
    +
    +	bool HasTrigger(uint32 c)
    +		{ return fList.HasItem((void*)tolower(c)); }
    +	bool AddTrigger(uint32 c)
    +		{ return fList.AddItem((void*)tolower(c)); }
    +
    +private:
    +	BList	fList;
    +};
    +
    +class ExtraMenuData {
    +public:
     	menu_tracking_hook trackingHook;
     	void *trackingState;
     
    -	_ExtraMenuData_(menu_tracking_hook func, void *state)
    +	ExtraMenuData(menu_tracking_hook func, void *state)
     	{
     		trackingHook = func;
     		trackingState = state;
    -	};
    +	}
     };
     
    +}	// namespace BPrivate
     
    +
     menu_info BMenu::sMenuInfo;
     bool BMenu::sAltAsCommandKey;
     
     
    -static property_info
    -sPropList[] = {
    +static property_info sPropList[] = {
     	{ "Enabled", { B_GET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Returns true if menu or menu item is enabled; false "
     		"otherwise.", 
     		0, { B_BOOL_TYPE }
     	},
    -	
    +
     	{ "Enabled", { B_SET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Enables or disables menu or menu item.", 
     		0, { B_BOOL_TYPE }
     	},
    -	
    +
     	{ "Label", { B_GET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Returns the string label of the menu or menu item.",
     		0, { B_STRING_TYPE }
     	},
    -	
    +
     	{ "Label", { B_SET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Sets the string label of the menu or menu item.",
     		0, { B_STRING_TYPE }
     	},
    -	
    +
     	{ "Mark", { B_GET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Returns true if the menu item or the menu's superitem "
     		"is marked; false otherwise.", 
     		0, { B_BOOL_TYPE }
     	},
    -	
    +
     	{ "Mark", { B_SET_PROPERTY, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Marks or unmarks the menu item or the menu's superitem.",
     		0, { B_BOOL_TYPE }
     	},
    -	
    +
     	{ "Menu", { B_CREATE_PROPERTY, 0 },
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Adds a new menu item at the specified index with the text label found in \"data\" "
    @@ -93,7 +114,7 @@
     		{ 	{{{"data", B_STRING_TYPE}}}
     		} 
     	},
    -	
    +
     	{ "Menu", { B_DELETE_PROPERTY, 0 },
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Removes the selected menu or menus.", 0, {}
    @@ -104,12 +125,12 @@
     		"Directs scripting message to the specified menu, first popping the current "
     		"specifier off the stack.", 0, {}
     	},
    -	
    +
     	{ "MenuItem", { B_COUNT_PROPERTIES, 0 },
     		{ B_DIRECT_SPECIFIER, 0 }, "Counts the number of menu items in the specified menu.",
     		0, { B_INT32_TYPE }
     	},
    -	
    +
     	{ "MenuItem", { B_CREATE_PROPERTY, 0 },
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Adds a new menu item at the specified index with the text label found in \"data\" "
    @@ -126,12 +147,12 @@
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Removes the specified menu item from its parent menu." 
     	},
    -	
    +
     	{ "MenuItem", { B_EXECUTE_PROPERTY, 0 },
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Invokes the specified menu item." 
     	},
    -	
    +
     	{ "MenuItem", { },
     		{ B_NAME_SPECIFIER, B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER, 0 },
     		"Directs scripting message to the specified menu, first popping the current "
    @@ -151,80 +172,80 @@
     
     
     BMenu::BMenu(const char *name, menu_layout layout)
    -	:	BView(BRect(0, 0, 0, 0), name, 0, B_WILL_DRAW),
    -		fChosenItem(NULL),
    -		fPad(14.0f, 2.0f, 20.0f, 0.0f),
    -		fSelected(NULL),
    -		fCachedMenuWindow(NULL),
    -		fSuper(NULL),
    -		fSuperitem(NULL),
    -		fAscent(-1.0f),
    -		fDescent(-1.0f),
    -		fFontHeight(-1.0f),
    -		fState(0),
    -		fLayout(layout),
    -		fExtraRect(NULL),
    -		fMaxContentWidth(0.0f),
    -		fInitMatrixSize(NULL),
    -		fExtraMenuData(NULL),
    -		fSubmenus(0),
    -		fTrigger(0),
    -		fResizeToFit(true),
    -		fUseCachedMenuLayout(false),
    -		fEnabled(true),
    -		fDynamicName(false),
    -		fRadioMode(false),
    -		fTrackNewBounds(false),
    -		fStickyMode(false),
    -		fIgnoreHidden(true),
    -		fTriggerEnabled(true),
    -		fRedrawAfterSticky(false),
    -		fAttachAborted(false)
    +	: BView(BRect(0, 0, 0, 0), name, 0, B_WILL_DRAW),
    +	fChosenItem(NULL),
    +	fPad(14.0f, 2.0f, 20.0f, 0.0f),
    +	fSelected(NULL),
    +	fCachedMenuWindow(NULL),
    +	fSuper(NULL),
    +	fSuperitem(NULL),
    +	fAscent(-1.0f),
    +	fDescent(-1.0f),
    +	fFontHeight(-1.0f),
    +	fState(0),
    +	fLayout(layout),
    +	fExtraRect(NULL),
    +	fMaxContentWidth(0.0f),
    +	fInitMatrixSize(NULL),
    +	fExtraMenuData(NULL),
    +	fSubmenus(0),
    +	fTrigger(0),
    +	fResizeToFit(true),
    +	fUseCachedMenuLayout(false),
    +	fEnabled(true),
    +	fDynamicName(false),
    +	fRadioMode(false),
    +	fTrackNewBounds(false),
    +	fStickyMode(false),
    +	fIgnoreHidden(true),
    +	fTriggerEnabled(true),
    +	fRedrawAfterSticky(false),
    +	fAttachAborted(false)
     {
    -	InitData(NULL);
    +	_InitData(NULL);
     }
     
     
     BMenu::BMenu(const char *name, float width, float height)
    -	:	BView(BRect(0.0f, width, 0.0f, height), name, 0, B_WILL_DRAW),
    -		fChosenItem(NULL),
    -		fSelected(NULL),
    -		fCachedMenuWindow(NULL),
    -		fSuper(NULL),
    -		fSuperitem(NULL),
    -		fAscent(-1.0f),
    -		fDescent(-1.0f),
    -		fFontHeight(-1.0f),
    -		fState(0),
    -		fLayout(B_ITEMS_IN_MATRIX),
    -		fExtraRect(NULL),
    -		fMaxContentWidth(0.0f),
    -		fInitMatrixSize(NULL),
    -		fExtraMenuData(NULL),
    -		fSubmenus(0),
    -		fTrigger(0),
    -		fResizeToFit(true),
    -		fUseCachedMenuLayout(false),
    -		fEnabled(true),
    -		fDynamicName(false),
    -		fRadioMode(false),
    -		fTrackNewBounds(false),
    -		fStickyMode(false),
    -		fIgnoreHidden(true),
    -		fTriggerEnabled(true),
    -		fRedrawAfterSticky(false),
    -		fAttachAborted(false)
    +	: BView(BRect(0.0f, width, 0.0f, height), name, 0, B_WILL_DRAW),
    +	fChosenItem(NULL),
    +	fSelected(NULL),
    +	fCachedMenuWindow(NULL),
    +	fSuper(NULL),
    +	fSuperitem(NULL),
    +	fAscent(-1.0f),
    +	fDescent(-1.0f),
    +	fFontHeight(-1.0f),
    +	fState(0),
    +	fLayout(B_ITEMS_IN_MATRIX),
    +	fExtraRect(NULL),
    +	fMaxContentWidth(0.0f),
    +	fInitMatrixSize(NULL),
    +	fExtraMenuData(NULL),
    +	fSubmenus(0),
    +	fTrigger(0),
    +	fResizeToFit(true),
    +	fUseCachedMenuLayout(false),
    +	fEnabled(true),
    +	fDynamicName(false),
    +	fRadioMode(false),
    +	fTrackNewBounds(false),
    +	fStickyMode(false),
    +	fIgnoreHidden(true),
    +	fTriggerEnabled(true),
    +	fRedrawAfterSticky(false),
    +	fAttachAborted(false)
     {
    -	InitData(NULL);
    +	_InitData(NULL);
     }
     
     
     BMenu::~BMenu()
     {
    -	DeleteMenuWindow();
    +	_DeleteMenuWindow();
     
     	RemoveItems(0, CountItems(), true);
    -		
    +	
     	delete fInitMatrixSize;
     	delete fExtraMenuData;
     	delete fLayoutData;
    @@ -232,46 +253,46 @@
     
     
     BMenu::BMenu(BMessage *archive)
    -	:	BView(archive),
    -		fChosenItem(NULL),
    -		fPad(14.0f, 2.0f, 20.0f, 0.0f),
    -		fSelected(NULL),
    -		fCachedMenuWindow(NULL),
    -		fSuper(NULL),
    -		fSuperitem(NULL),
    -		fAscent(-1.0f),
    -		fDescent(-1.0f),
    -		fFontHeight(-1.0f),
    -		fState(0),
    -		fLayout(B_ITEMS_IN_ROW),
    -		fExtraRect(NULL),
    -		fMaxContentWidth(0.0f),
    -		fInitMatrixSize(NULL),
    -		fExtraMenuData(NULL),
    -		fSubmenus(0),
    -		fTrigger(0),
    -		fResizeToFit(true),
    -		fUseCachedMenuLayout(false),
    -		fEnabled(true),
    -		fDynamicName(false),
    -		fRadioMode(false),
    -		fTrackNewBounds(false),
    -		fStickyMode(false),
    -		fIgnoreHidden(true),
    -		fTriggerEnabled(true),
    -		fRedrawAfterSticky(false),
    -		fAttachAborted(false)
    +	: BView(archive),
    +	fChosenItem(NULL),
    +	fPad(14.0f, 2.0f, 20.0f, 0.0f),
    +	fSelected(NULL),
    +	fCachedMenuWindow(NULL),
    +	fSuper(NULL),
    +	fSuperitem(NULL),
    +	fAscent(-1.0f),
    +	fDescent(-1.0f),
    +	fFontHeight(-1.0f),
    +	fState(0),
    +	fLayout(B_ITEMS_IN_ROW),
    +	fExtraRect(NULL),
    +	fMaxContentWidth(0.0f),
    +	fInitMatrixSize(NULL),
    +	fExtraMenuData(NULL),
    +	fSubmenus(0),
    +	fTrigger(0),
    +	fResizeToFit(true),
    +	fUseCachedMenuLayout(false),
    +	fEnabled(true),
    +	fDynamicName(false),
    +	fRadioMode(false),
    +	fTrackNewBounds(false),
    +	fStickyMode(false),
    +	fIgnoreHidden(true),
    +	fTriggerEnabled(true),
    +	fRedrawAfterSticky(false),
    +	fAttachAborted(false)
     {
    -	InitData(archive);
    +	_InitData(archive);
     }
     
     
    -BArchivable *
    -BMenu::Instantiate(BMessage *data)
    +BArchivable*
    +BMenu::Instantiate(BMessage* archive)
     {
    -	if (validate_instantiation(data, "BMenu"))
    -		return new (nothrow) BMenu(data);
    -	
    +	if (validate_instantiation(archive, "BMenu"))
    +		return new (nothrow) BMenu(archive);
    +
     	return NULL;
     }
     
    @@ -323,7 +344,8 @@
     	key_map *keys = NULL; 
     	char *chars = NULL; 
     	get_key_map(&keys, &chars);
    -	if (keys == NULL || keys->left_command_key != 0x5d || keys->right_command_key != 0x5f)
    +	if (keys == NULL || keys->left_command_key != 0x5d
    +		|| keys->right_command_key != 0x5f)
     		sAltAsCommandKey = false;
     	free(chars);
     	free(keys);
    @@ -332,7 +354,7 @@
     	BMenu *superMenu = Supermenu();
     	if (AddDynamicItem(B_INITIAL_ADD)) {
     		do {
    -			if (superMenu != NULL && !superMenu->OkToProceed(superItem)) {
    +			if (superMenu != NULL && !superMenu->_OkToProceed(superItem)) {
     				AddDynamicItem(B_ABORT);
     				fAttachAborted = true;
     				break;
    @@ -341,9 +363,9 @@
     	}
     
     	if (!fAttachAborted) {
    -		CacheFontInfo();
    -		LayoutItems(0);
    -		UpdateWindowViewSize(false);
    +		_CacheFontInfo();
    +		_LayoutItems(0);
    +		_UpdateWindowViewSize(false);
     	}
     }
     
    @@ -375,8 +397,8 @@
     	InvalidateLayout();
     	if (LockLooper()) {
     		if (!Window()->IsHidden()) {
    -			LayoutItems(index);
    -			UpdateWindowViewSize(false);
    +			_LayoutItems(index);
    +			_UpdateWindowViewSize(false);
     			Invalidate();
     		} 
     		UnlockLooper();
    @@ -404,7 +426,7 @@
     
     	if (LockLooper()) {
     		if (!Window()->IsHidden()) {
    -			LayoutItems(index);
    +			_LayoutItems(index);
     			Invalidate();
     		} 
     		UnlockLooper();
    @@ -494,8 +516,8 @@
     	InvalidateLayout();
     	if (locked && Window() != NULL && !Window()->IsHidden()) {	
     		// Make sure we update the layout if needed.
    -		LayoutItems(index);
    -		UpdateWindowViewSize(false);
    +		_LayoutItems(index);
    +		_UpdateWindowViewSize(false);
     		Invalidate();		
     	}
     
    @@ -522,8 +544,7 @@
     bool
     BMenu::RemoveItem(BMenuItem *item)
     {
    -	// TODO: Check if item is also deleted
    -	return RemoveItems(0, 0, item, false);
    +	return _RemoveItems(0, 0, item, false);
     }
    
    [... truncated: 1709 lines follow ...]
    
    
    From marcusoverhagen at mail.berlios.de  Sun Sep 30 16:02:05 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sun, 30 Sep 2007 16:02:05 +0200
    Subject: [Haiku-commits] r22385 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709301402.l8UE25Yt003587@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-30 16:02:04 +0200 (Sun, 30 Sep 2007)
    New Revision: 22385
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22385&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    Cleanup, improved error handling, fix setting of DBC_I bit
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 10:52:45 UTC (rev 22384)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 14:02:04 UTC (rev 22385)
    @@ -15,7 +15,8 @@
     #include 
     
     #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a)
    -#define FLOW(a...)	dprintf("ahci: " a)
    +// #define FLOW(a...)	dprintf("ahci: " a)
    +#define FLOW(a...)
     
     
     AHCIPort::AHCIPort(AHCIController *controller, int index)
    @@ -301,7 +302,7 @@
     	while (sgCount > 0 && dataSize > 0) {
     		size_t size = min_c(sgTable->size, dataSize);
     		void *address = sgTable->address;
    -		TRACE("FillPrdTable: sg-entry addr %p, size %lu\n", address, size);
    +		FLOW("FillPrdTable: sg-entry addr %p, size %lu\n", address, size);
     		if ((uint32)address & 1) {
     			TRACE("AHCIPort::FillPrdTable: data alignment error\n");
     			return B_ERROR;
    @@ -313,7 +314,7 @@
     				TRACE("AHCIPort::FillPrdTable: prd table exhausted\n");
     				return B_ERROR;
     			}
    -			TRACE("FillPrdTable: prd-entry %u, addr %p, size %lu\n", *prdCount, address, bytes);
    +			FLOW("FillPrdTable: prd-entry %u, addr %p, size %lu\n", *prdCount, address, bytes);
     			prdTable->dba  = LO32(address);
     			prdTable->dbau = HI32(address);
     			prdTable->res  = 0;
    @@ -326,8 +327,16 @@
     		sgTable++;
     		sgCount--;
     	}
    +	if (*prdCount == 0) {
    +		TRACE("AHCIPort::FillPrdTable: count is 0\n");
    +		return B_ERROR;
    +	}
    +	if (dataSize > 0) {
    +		TRACE("AHCIPort::FillPrdTable: sg table %ld bytes too small\n", dataSize);
    +		return B_ERROR;
    +	}
     	if (ioc)
    -		prdTable->dbc |= DBC_I;
    +		(prdTable - 1)->dbc |= DBC_I;
     	return B_OK;
     }
     
    @@ -358,88 +367,7 @@
     	release_sem(fRequestSem);
     }
     
    -/*
    -void
    -AHCIPort::IdentifyDevice(scsi_ccb *request)
    -{
    -	TRACE("AHCIPort::IdentifyDevice port %d\n", fIndex);
     
    -	void *phy; 
    -	uint8 *data;
    -	int size = 512;
    -
    -	area_id id = alloc_mem((void **)&data, &phy, size, 0, "identify device");
    -
    -	TRACE("virt   0x%08lx\n", data);
    -	TRACE("phys   0x%08lx\n", phy);
    -
    -	memset(data, 0, size);
    -
    -	TRACE("ci   0x%08lx\n", fRegs->ci);
    -	TRACE("ie   0x%08lx\n", fRegs->ie);
    -	TRACE("is   0x%08lx\n", fRegs->is);
    -	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    -	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    -	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    -	TRACE("serr 0x%08lx\n", fRegs->serr);
    -	TRACE("sact 0x%08lx\n", fRegs->sact);
    -	TRACE("tfd  0x%08lx\n", fRegs->tfd);
    -
    -
    -	memset((void *)fCommandTable->cfis, 0, 5 * 4);
    -	fCommandTable->cfis[0] = 0x27;
    -	fCommandTable->cfis[1] = 0x80;
    -	fCommandTable->cfis[2] = 0xec;
    -
    -
    -	fCommandList->prdtl_flags_cfl = 0;
    -	fCommandList->prdtl = 1;
    -//	fCommandList->c = 1;
    -	fCommandList->cfl = 5;
    -	fCommandList->prdbc = 0;
    -
    -	TRACE("prdtl_flags_cfl %08x\n", fCommandList->prdtl_flags_cfl);
    -	TRACE("prdbc           %08x\n", fCommandList->prdbc);
    -
    -
    -	fPRDTable->dba = LO32(phy);
    -	fPRDTable->dbau = HI32(phy);
    -	fPRDTable->dbc = DBC_I | (size - 1);
    -
    -	TRACE("dba  %08x\n", fPRDTable->dba);
    -	TRACE("dbau %08x\n", fPRDTable->dbau);
    -	TRACE("dbc  %08x\n", fPRDTable->dbc);
    -
    -	fRegs->ci |= 1;
    -	FlushPostedWrites();
    -
    -	snooze(500000);
    -
    -	TRACE("prdbc %ld\n", fCommandList->prdbc);
    -
    -	TRACE("ci   0x%08lx\n", fRegs->ci);
    -	TRACE("ie   0x%08lx\n", fRegs->ie);
    -	TRACE("is   0x%08lx\n", fRegs->is);
    -	TRACE("cmd  0x%08lx\n", fRegs->cmd);
    -	TRACE("ssts 0x%08lx\n", fRegs->ssts);
    -	TRACE("sctl 0x%08lx\n", fRegs->sctl);
    -	TRACE("serr 0x%08lx\n", fRegs->serr);
    -	TRACE("sact 0x%08lx\n", fRegs->sact);
    -	TRACE("tfd  0x%08lx\n", fRegs->tfd);
    -
    -	for (int i = 0; i < size; i += 8) {
    -		TRACE("  %02x %02x %02x %02x %02x %02x %02x %02x\n", data[i], data[i+1], data[i+2], data[i+3], data[i+4], data[i+5], data[i+6], data[i+7]);
    -//		TRACE("  %c%c%c%c%c%c%c%c\n", c(data[i]), c(data[i+1]), c(data[i+2]), c(data[i+3]), c(data[i+4]), c(data[i+5]), c(data[i+6]), c(data[i+7]));
    -	}
    -
    -	delete_area(id);
    -
    -	request->subsys_status = SCSI_REQ_CMP;
    -	gSCSI->finished(request, 1);
    -
    -}
    -*/
    -
     void
     AHCIPort::ScsiTestUnitReady(scsi_ccb *request)
     {
    @@ -460,6 +388,8 @@
     
     	if (cmd->evpd || cmd->page_code) {
     		TRACE("invalid request\n");
    +		request->subsys_status = SCSI_REQ_ABORTED;
    +		gSCSI->finished(request, 1);
     		return;
     	}
     
    @@ -484,6 +414,13 @@
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    +	if (wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 4000000) < B_OK) {
    +		TRACE("device is busy\n");
    +		FinishTransfer();
    +		request->subsys_status = SCSI_REQ_ABORTED;
    +		gSCSI->finished(request, 1);
    +		return;
    +	}
     	fRegs->ci |= 1;
     	FlushPostedWrites();
     
    @@ -551,9 +488,9 @@
     	swap_words(ataData.serial_number, sizeof(ataData.serial_number));
     	swap_words(ataData.firmware_revision, sizeof(ataData.firmware_revision));
     
    -	TRACE("model_number: %.40s\n", ataData.model_number);
    -	TRACE("serial_number: %.20s\n", ataData.serial_number);
    -	TRACE("firmware_revision: %.8s\n", ataData.firmware_revision);
    +	TRACE("model_number: %40s\n", ataData.model_number);
    +	TRACE("serial_number: %20s\n", ataData.serial_number);
    +  	TRACE("firmware_revision: %8s\n", ataData.firmware_revision);
     	TRACE("lba %d, lba48 %d, fUse48BitCommands %d, sectors %lu, sectors48 %llu, size %llu\n",
     		lba, lba48, fUse48BitCommands, sectors, sectors48, fSectorCount * fSectorSize);
     
    @@ -624,7 +561,7 @@
     	int prdEntrys;
     	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, length * 512, true);
     
    -	TRACE("prdEntrys %d\n", prdEntrys);
    +	FLOW("prdEntrys %d\n", prdEntrys);
     	
     	memset((void *)fCommandTable->cfis, 0, 5 * 4);
     
    @@ -661,6 +598,13 @@
     	fCommandList->cfl = 5;
     	fCommandList->prdbc = 0;
     
    +	if (wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 4000000) < B_OK) {
    +		TRACE("device is busy\n");
    +		FinishTransfer();
    +		request->subsys_status = SCSI_REQ_ABORTED;
    +		gSCSI->finished(request, 1);
    +		return;
    +	}
     	fRegs->ci |= 1;
     	FlushPostedWrites();
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Sun Sep 30 17:12:40 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sun, 30 Sep 2007 17:12:40 +0200
    Subject: [Haiku-commits] r22386 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709301512.l8UFCeNm008010@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-30 17:12:39 +0200 (Sun, 30 Sep 2007)
    New Revision: 22386
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22386&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp
    Log:
    Improved interrupt handling
    Removed DBC_I interrupt
    Reduce debug output
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 14:02:04 UTC (rev 22385)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 15:12:39 UTC (rev 22386)
    @@ -23,16 +23,17 @@
     	: fIndex(index)
     	, fRegs(&controller->fRegs->port[index])
     	, fArea(-1)
    +	, fSpinlock(0)
    +	, fCommandsActive(0)
     	, fRequestSem(-1)
     	, fResponseSem(-1)
    -	, fCommandActive(false)
     	, fDevicePresent(false)
     	, fUse48BitCommands(false)
     	, fSectorSize(0)
     	, fSectorCount(0)
     {
     	fRequestSem = create_sem(1, "ahci request");
    -	fResponseSem = create_sem(1, "ahci response");
    +	fResponseSem = create_sem(0, "ahci response");
     }
     				
     
    @@ -269,18 +270,30 @@
     AHCIPort::Interrupt()
     {
     	uint32 is = fRegs->is;
    -	TRACE("AHCIPort::Interrupt port %d, status %#08lx\n", fIndex, is);
    +	uint32 ci = fRegs->ci;
    +	fRegs->is = is; // clear interrupts
     
    -	if (fCommandActive)	
    +	FLOW("AHCIPort::Interrupt port %d, fCommandsActive 0x%08lx, is 0x%08lx, ci 0x%08lx\n", fIndex, fCommandsActive, is, ci);
    +
    +	int release = 0;
    +
    +	acquire_spinlock(&fSpinlock);
    +	if ((fCommandsActive & 1) && !(ci & 1)) {
    +		release = 1;
    +		fCommandsActive &= ~1;
    +	}
    +	release_spinlock(&fSpinlock);
    +	
    +	if (is & PORT_INT_FATAL)
    +		panic("ahci fatal error, is 0x%08lx", is);
    +
    +	if (release)
     		release_sem_etc(fResponseSem, 1, B_RELEASE_IF_WAITING_ONLY | B_DO_NOT_RESCHEDULE);
    -
    -	// clear interrupts
    -	fRegs->is = is;
     }
     
     
     status_t
    -AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc)
    +AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize)
     {
     	int peMax = prdMax + 1;
     	physical_entry pe[peMax];
    @@ -291,12 +304,12 @@
     	int peUsed;
     	for (peUsed = 0; pe[peUsed].size; peUsed++)
     		;
    -	return FillPrdTable(prdTable, prdCount, prdMax, pe, peUsed, dataSize, ioc);
    +	return FillPrdTable(prdTable, prdCount, prdMax, pe, peUsed, dataSize);
     }
     
     
     status_t
    -AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize, bool ioc)
    +AHCIPort::FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize)
     {
     	*prdCount = 0;
     	while (sgCount > 0 && dataSize > 0) {
    @@ -335,8 +348,6 @@
     		TRACE("AHCIPort::FillPrdTable: sg table %ld bytes too small\n", dataSize);
     		return B_ERROR;
     	}
    -	if (ioc)
    -		(prdTable - 1)->dbc |= DBC_I;
     	return B_OK;
     }
     
    @@ -345,18 +356,19 @@
     AHCIPort::StartTransfer()
     {
     	acquire_sem(fRequestSem);
    -	fCommandActive = true;
     }
     				
     
     status_t
    -AHCIPort::WaitForTransfer(int *status, bigtime_t timeout)
    +AHCIPort::WaitForTransfer(int *tfd, bigtime_t timeout)
     {
     	status_t result = B_OK;
     	if (acquire_sem_etc(fResponseSem, 1, B_RELATIVE_TIMEOUT, timeout) < B_OK) {
    +		fCommandsActive &= ~1;
     		result = B_TIMED_OUT;
    +	} else {
    +		*tfd = fRegs->tfd;
     	}
    -	fCommandActive = false;
     	return result;
     }
     
    @@ -398,10 +410,10 @@
     	StartTransfer();
     
     	int prdEntrys;
    -	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, &ataData, sizeof(ataData), true);
    +	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, &ataData, sizeof(ataData));
     
     
    -	TRACE("prdEntrys %d\n", prdEntrys);
    +	FLOW("prdEntrys %d\n", prdEntrys);
     	
     	memset((void *)fCommandTable->cfis, 0, 5 * 4);
     	fCommandTable->cfis[0] = 0x27;
    @@ -421,16 +433,22 @@
     		gSCSI->finished(request, 1);
     		return;
     	}
    +
    +	cpu_status cpu = disable_interrupts();
    +	acquire_spinlock(&fSpinlock);
     	fRegs->ci |= 1;
     	FlushPostedWrites();
    +	fCommandsActive |= 1;
    +	release_spinlock(&fSpinlock);
    +	restore_interrupts(cpu);
     
     	int status;
     	WaitForTransfer(&status, 100000);
     
    -	TRACE("prdbc %ld\n", fCommandList->prdbc);
    -	TRACE("ci   0x%08lx\n", fRegs->ci);
    -	TRACE("is   0x%08lx\n", fRegs->is);
    -	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	FLOW("prdbc %ld\n", fCommandList->prdbc);
    +	FLOW("ci   0x%08lx\n", fRegs->ci);
    +	FLOW("is   0x%08lx\n", fRegs->is);
    +	FLOW("serr 0x%08lx\n", fRegs->serr);
     
     /*
     	TRACE("ci   0x%08lx\n", fRegs->ci);
    @@ -484,13 +502,21 @@
     	}
     #endif
     
    -	swap_words(ataData.model_number, sizeof(ataData.model_number));
    -	swap_words(ataData.serial_number, sizeof(ataData.serial_number));
    -	swap_words(ataData.firmware_revision, sizeof(ataData.firmware_revision));
    +	char modelNumber[sizeof(ataData.model_number) + 1];
    +	char serialNumber[sizeof(ataData.serial_number) + 1];
    +	char firmwareRev[sizeof(ataData.firmware_revision) + 1];
     
    -	TRACE("model_number: %40s\n", ataData.model_number);
    -	TRACE("serial_number: %20s\n", ataData.serial_number);
    -  	TRACE("firmware_revision: %8s\n", ataData.firmware_revision);
    +	strlcpy(modelNumber, ataData.model_number, sizeof(modelNumber));
    +	strlcpy(serialNumber, ataData.serial_number, sizeof(serialNumber));
    +	strlcpy(firmwareRev, ataData.firmware_revision, sizeof(firmwareRev));
    +
    +	swap_words(modelNumber, sizeof(modelNumber) - 1);
    +	swap_words(serialNumber, sizeof(serialNumber) - 1);
    +	swap_words(firmwareRev, sizeof(firmwareRev) - 1);
    +
    +	TRACE("model number:  %s\n", modelNumber);
    +	TRACE("serial number: %s\n", serialNumber);
    +  	TRACE("firmware rev.: %s\n", firmwareRev);
     	TRACE("lba %d, lba48 %d, fUse48BitCommands %d, sectors %lu, sectors48 %llu, size %llu\n",
     		lba, lba48, fUse48BitCommands, sectors, sectors48, fSectorCount * fSectorSize);
     
    @@ -502,7 +528,6 @@
     		request->data_length = sizeof(scsiData); // ???
     	}
     
    -	fRegs->ci &= ~1;
     	FinishTransfer();
     
     	gSCSI->finished(request, 1);
    @@ -544,8 +569,10 @@
     void
     AHCIPort::ScsiReadWrite(scsi_ccb *request, uint64 position, size_t length, bool isWrite)
     {
    -	TRACE("ScsiReadWrite: pos %llu, size %lu, isWrite %d\n", position, length, isWrite);
    +	uint32 bytecount = length * 512;
     
    +	TRACE("ScsiReadWrite: position %llu, size %lu, isWrite %d\n", position * 512, bytecount, isWrite);
    +
     #if 1
     	if (isWrite) {
     		TRACE("write request ignored\n");
    @@ -559,7 +586,7 @@
     	StartTransfer();
     
     	int prdEntrys;
    -	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, length * 512, true);
    +	FillPrdTable(fPRDTable, &prdEntrys, PRD_TABLE_ENTRY_COUNT, request->sg_list, request->sg_count, bytecount);
     
     	FLOW("prdEntrys %d\n", prdEntrys);
     	
    @@ -605,22 +632,31 @@
     		gSCSI->finished(request, 1);
     		return;
     	}
    +	cpu_status cpu = disable_interrupts();
    +	acquire_spinlock(&fSpinlock);
     	fRegs->ci |= 1;
     	FlushPostedWrites();
    +	fCommandsActive |= 1;
    +	release_spinlock(&fSpinlock);
    +	restore_interrupts(cpu);
     
    -	int status;
    -	WaitForTransfer(&status, 100000);
    +	int tfd;
    +	status_t status = WaitForTransfer(&tfd, 4000000);
     
    -	TRACE("prdbc %ld\n", fCommandList->prdbc);
    -	TRACE("ci   0x%08lx\n", fRegs->ci);
    -	TRACE("is   0x%08lx\n", fRegs->is);
    -	TRACE("serr 0x%08lx\n", fRegs->serr);
    +	FLOW("prdbc %ld\n", fCommandList->prdbc);
     
    -	request->subsys_status = SCSI_REQ_CMP;
    +	if (status < B_OK || (tfd & ATA_ERR)) {
    +		TRACE("device error\n");
    +		request->subsys_status = SCSI_REQ_ABORTED;
    +	} else if (fCommandList->prdbc != bytecount) {
    +		TRACE("should never happen\n");
    +		request->subsys_status = SCSI_REQ_CMP_ERR;
    +	} else {
    +		request->subsys_status = SCSI_REQ_CMP;
    +	}
     	request->data_resid = request->data_length - fCommandList->prdbc;// ???
     	request->data_length = fCommandList->prdbc; // ???
     
    -	fRegs->ci &= ~1;
     	FinishTransfer();
     
     	gSCSI->finished(request, 1);
    @@ -631,7 +667,7 @@
     AHCIPort::ScsiExecuteRequest(scsi_ccb *request)
     {
     
    -	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length);
    +//	TRACE("AHCIPort::ScsiExecuteRequest port %d, opcode 0x%02x, length %u\n", fIndex, request->cdb[0], request->cdb_length);
     
     	if (request->cdb[0] == SCSI_OP_REQUEST_SENSE) {
     		panic("ahci: SCSI_OP_REQUEST_SENSE not yet supported\n");
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-30 14:02:04 UTC (rev 22385)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.h	2007-09-30 15:12:39 UTC (rev 22386)
    @@ -38,21 +38,22 @@
     	void		DumpD2HFis();
     
     	void		StartTransfer();
    -	status_t	WaitForTransfer(int *status, bigtime_t timeout);
    +	status_t	WaitForTransfer(int *tfd, bigtime_t timeout);
     	void		FinishTransfer();
     
     
     //	uint8 *		SetCommandFis(volatile command_list_entry *cmd, volatile fis *fis, const void *data, size_t dataSize);
    -	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize, bool ioc = false);
    -	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize, bool ioc = false);
    +	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const void *data, size_t dataSize);
    +	status_t	FillPrdTable(volatile prd *prdTable, int *prdCount, int prdMax, const physical_entry *sgTable, int sgCount, size_t dataSize);
     
     private:
     	int						fIndex;
     	volatile ahci_port *	fRegs;
     	area_id					fArea;
    +	spinlock						fSpinlock;
    +	volatile uint32					fCommandsActive;
     	sem_id							fRequestSem;
     	sem_id							fResponseSem;
    -	volatile bool					fCommandActive;
     	bool							fDevicePresent;
     	bool							fUse48BitCommands;
     	uint32							fSectorSize;
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp	2007-09-30 14:02:04 UTC (rev 22385)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_sim.cpp	2007-09-30 15:12:39 UTC (rev 22386)
    @@ -10,7 +10,8 @@
     #include 
     
     #define TRACE(a...) dprintf("\33[34mahci:\33[0m " a)
    -#define FLOW(a...)	dprintf("ahci: " a)
    +//#define FLOW(a...)	dprintf("ahci: " a)
    +#define FLOW(a...)
     
     
     pci_device_module_info *gPCI;
    @@ -24,7 +25,7 @@
     static void
     ahci_scsi_io(scsi_sim_cookie cookie, scsi_ccb *request)
     {
    -	TRACE("ahci_scsi_io, cookie %p, path_id %u, target_id %u, target_lun %u\n", 
    +	FLOW("ahci_scsi_io, cookie %p, path_id %u, target_id %u, target_lun %u\n", 
     		cookie, request->path_id, request->target_id, request->target_lun);
     	static_cast(cookie)->ExecuteRequest(request);
     }
    @@ -105,7 +106,7 @@
     
     	*isATAPI = false;
     	*noAutoSense = false;
    -	*maxBlocks = 255;
    +	*maxBlocks = 256;
     }
     
     
    
    
    
    From marcusoverhagen at mail.berlios.de  Sun Sep 30 17:54:35 2007
    From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS)
    Date: Sun, 30 Sep 2007 17:54:35 +0200
    Subject: [Haiku-commits] r22387 -
    	haiku/trunk/src/add-ons/kernel/busses/scsi/ahci
    Message-ID: <200709301554.l8UFsZJj012826@sheep.berlios.de>
    
    Author: marcusoverhagen
    Date: 2007-09-30 17:54:35 +0200 (Sun, 30 Sep 2007)
    New Revision: 22387
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22387&view=rev
    
    Modified:
       haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    Log:
    This enable write support. The driver should be useable now.
    
    
    Modified: haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp
    ===================================================================
    --- haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 15:12:39 UTC (rev 22386)
    +++ haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci_port.cpp	2007-09-30 15:54:35 UTC (rev 22387)
    @@ -275,6 +275,12 @@
     
     	FLOW("AHCIPort::Interrupt port %d, fCommandsActive 0x%08lx, is 0x%08lx, ci 0x%08lx\n", fIndex, fCommandsActive, is, ci);
     
    +	if (is & PORT_INT_ERROR)
    +		TRACE("AHCIPort::Interrupt port %d, fCommandsActive 0x%08lx, is 0x%08lx, ci 0x%08lx\n", fIndex, fCommandsActive, is, ci);
    +	
    +	if (is & PORT_INT_FATAL)
    +		panic("ahci fatal error, is 0x%08lx", is);
    +
     	int release = 0;
     
     	acquire_spinlock(&fSpinlock);
    @@ -283,9 +289,6 @@
     		fCommandsActive &= ~1;
     	}
     	release_spinlock(&fSpinlock);
    -	
    -	if (is & PORT_INT_FATAL)
    -		panic("ahci fatal error, is 0x%08lx", is);
     
     	if (release)
     		release_sem_etc(fResponseSem, 1, B_RELEASE_IF_WAITING_ONLY | B_DO_NOT_RESCHEDULE);
    @@ -495,7 +498,7 @@
     	fSectorSize			= 512;
     	fSectorCount		= !(lba || sectors) ? 0 : lba48 ? sectors48 : sectors;
     
    -#if 1
    +#if 0
     	if (fSectorCount < 0x0fffffff) {
     		TRACE("disabling 48 bit commands\n");
     		fUse48BitCommands = 0;
    @@ -573,7 +576,7 @@
     
     	TRACE("ScsiReadWrite: position %llu, size %lu, isWrite %d\n", position * 512, bytecount, isWrite);
     
    -#if 1
    +#if 0
     	if (isWrite) {
     		TRACE("write request ignored\n");
     		request->subsys_status = SCSI_REQ_CMP;
    @@ -593,6 +596,8 @@
     	memset((void *)fCommandTable->cfis, 0, 5 * 4);
     
     	if (fUse48BitCommands) {
    +		if (length > 65536)
    +			panic("ahci: ScsiReadWrite length too large, %lu sectors", length);
     		fCommandTable->cfis[0] = 0x27;
     		fCommandTable->cfis[1] = 0x80;
     		fCommandTable->cfis[2] = isWrite ? 0x35 : 0x25;
    @@ -607,7 +612,7 @@
     		fCommandTable->cfis[13] = (length >> 8) & 0xff;
     	} else {
     		if (length > 256)
    -			panic("ahci: ScsiReadWrite length too large");
    +			panic("ahci: ScsiReadWrite length too large, %lu sectors", length);
     		if (position > 0x0fffffff)
     			panic("achi: ScsiReadWrite position too large for non-48-bit LBA\n");
     		fCommandTable->cfis[0] = 0x27;
    @@ -623,6 +628,8 @@
     	fCommandList->prdtl_flags_cfl = 0;
     	fCommandList->prdtl = prdEntrys;
     	fCommandList->cfl = 5;
    +	if (isWrite) 
    +		fCommandList->w = 1;
     	fCommandList->prdbc = 0;
     
     	if (wait_until_clear(&fRegs->tfd, ATA_BSY | ATA_DRQ, 4000000) < B_OK) {
    
    
    
    From axeld at mail.berlios.de  Sun Sep 30 18:03:54 2007
    From: axeld at mail.berlios.de (axeld at BerliOS)
    Date: Sun, 30 Sep 2007 18:03:54 +0200
    Subject: [Haiku-commits] r22388 - in haiku/trunk/src: kits/interface
    	servers/app servers/app/drawing
    Message-ID: <200709301603.l8UG3sLK013495@sheep.berlios.de>
    
    Author: axeld
    Date: 2007-09-30 18:03:53 +0200 (Sun, 30 Sep 2007)
    New Revision: 22388
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22388&view=rev
    
    Modified:
       haiku/trunk/src/kits/interface/Bitmap.cpp
       haiku/trunk/src/servers/app/ServerApp.cpp
       haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp
       haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h
       haiku/trunk/src/servers/app/drawing/HWInterface.cpp
       haiku/trunk/src/servers/app/drawing/HWInterface.h
    Log:
    Correctly implemented the missing BBitmap::GetOverlayRestrictions() on the
    client and the server. This should fix bug #1490, but I haven't tested it yet.
    
    
    Modified: haiku/trunk/src/kits/interface/Bitmap.cpp
    ===================================================================
    --- haiku/trunk/src/kits/interface/Bitmap.cpp	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/kits/interface/Bitmap.cpp	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -754,9 +754,10 @@
     
     	status_t status;
     	if (link.FlushWithReply(status) < B_OK)
    -		return B_ERROR;
    +		return status;
     
    -	return status;
    +	link.Read(restrictions, sizeof(overlay_restrictions));
    +	return B_OK;
     }
     
     
    
    Modified: haiku/trunk/src/servers/app/ServerApp.cpp
    ===================================================================
    --- haiku/trunk/src/servers/app/ServerApp.cpp	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/servers/app/ServerApp.cpp	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -665,7 +665,7 @@
     		}
     		case AS_GET_BITMAP_OVERLAY_RESTRICTIONS:
     		{
    -			overlay_restrictions overlayRestrictions;
    +			overlay_restrictions restrictions;
     			status_t status = B_ERROR;
     
     			int32 token;
    @@ -677,12 +677,13 @@
     				STRACE(("ServerApp %s: Get overlay restrictions for bitmap %ld\n",
     					Signature(), token));
     
    -				// TODO: fill overlay restrictions
    +				status = fDesktop->HWInterface()->GetOverlayRestrictions(
    +					bitmap->Overlay(), &restrictions);
     			}
     
     			fLink.StartMessage(status);
     			if (status == B_OK)
    -				fLink.Attach(&overlayRestrictions, sizeof(overlay_restrictions));
    +				fLink.Attach(&restrictions, sizeof(overlay_restrictions));
     
     			fLink.Flush();
     			break;
    
    Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp
    ===================================================================
    --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.cpp	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -856,6 +856,34 @@
     }
     
     
    +status_t
    +AccelerantHWInterface::GetOverlayRestrictions(const Overlay* overlay,
    +	overlay_restrictions* restrictions)
    +{
    +	if (overlay == NULL || restrictions == NULL)
    +		return B_BAD_VALUE;
    +	if (fAccGetOverlayConstraints == NULL)
    +		return B_NOT_SUPPORTED;
    +
    +	overlay_constraints constraints;
    +	status_t status = fAccGetOverlayConstraints(&fDisplayMode,
    +		overlay->OverlayBuffer(), &constraints);
    +	if (status < B_OK)
    +		return status;
    +
    +	memset(restrictions, 0, sizeof(overlay_restrictions));
    +	memcpy(&restrictions->source, &constraints.view, sizeof(overlay_limits));
    +	memcpy(&restrictions->destination, &constraints.window,
    +		sizeof(overlay_limits));
    +	restrictions->min_width_scale = constraints.h_scale.min;
    +	restrictions->max_width_scale = constraints.h_scale.max;
    +	restrictions->min_height_scale = constraints.v_scale.min;
    +	restrictions->max_height_scale = constraints.v_scale.max;
    +
    +	return B_OK;
    +}
    +
    +
     bool
     AccelerantHWInterface::CheckOverlayRestrictions(int32 width, int32 height,
     	color_space colorSpace)
    
    Modified: haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h
    ===================================================================
    --- haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/servers/app/drawing/AccelerantHWInterface.h	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -59,10 +59,12 @@
     	virtual overlay_token		AcquireOverlayChannel();
     	virtual void				ReleaseOverlayChannel(overlay_token token);
     
    -	virtual bool				CheckOverlayRestrictions(int32 width, int32 height,
    -									color_space colorSpace);
    -	virtual const overlay_buffer* AllocateOverlayBuffer(int32 width, int32 height,
    -									color_space space);
    +	virtual status_t			GetOverlayRestrictions(const Overlay* overlay,
    +									overlay_restrictions* restrictions);
    +	virtual bool				CheckOverlayRestrictions(int32 width,
    +									int32 height, color_space colorSpace);
    +	virtual const overlay_buffer* AllocateOverlayBuffer(int32 width,
    +									int32 height, color_space space);
     	virtual void				FreeOverlayBuffer(const overlay_buffer* buffer);
     
     	virtual void				ConfigureOverlay(Overlay* overlay);
    
    Modified: haiku/trunk/src/servers/app/drawing/HWInterface.cpp
    ===================================================================
    --- haiku/trunk/src/servers/app/drawing/HWInterface.cpp	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/servers/app/drawing/HWInterface.cpp	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -344,8 +344,17 @@
     }
     
     
    +status_t
    +HWInterface::GetOverlayRestrictions(const Overlay* overlay,
    +	overlay_restrictions* restrictions)
    +{
    +	return B_NOT_SUPPORTED;
    +}
    +
    +
     bool
    -HWInterface::CheckOverlayRestrictions(int32 width, int32 height, color_space colorSpace)
    +HWInterface::CheckOverlayRestrictions(int32 width, int32 height,
    +	color_space colorSpace)
     {
     	return false;
     }
    
    Modified: haiku/trunk/src/servers/app/drawing/HWInterface.h
    ===================================================================
    --- haiku/trunk/src/servers/app/drawing/HWInterface.h	2007-09-30 15:54:35 UTC (rev 22387)
    +++ haiku/trunk/src/servers/app/drawing/HWInterface.h	2007-09-30 16:03:53 UTC (rev 22388)
    @@ -120,6 +120,8 @@
     	virtual overlay_token		AcquireOverlayChannel();
     	virtual void				ReleaseOverlayChannel(overlay_token token);
     
    +	virtual status_t			GetOverlayRestrictions(const Overlay* overlay,
    +									overlay_restrictions* restrictions);
     	virtual bool				CheckOverlayRestrictions(int32 width, int32 height,
     									color_space colorSpace);
     	virtual const overlay_buffer* AllocateOverlayBuffer(int32 width, int32 height,
    
    
    
    From stippi at mail.berlios.de  Sun Sep 30 19:24:58 2007
    From: stippi at mail.berlios.de (stippi at BerliOS)
    Date: Sun, 30 Sep 2007 19:24:58 +0200
    Subject: [Haiku-commits] r22389 - haiku/trunk/build/jam
    Message-ID: <200709301724.l8UHOwNk003592@sheep.berlios.de>
    
    Author: stippi
    Date: 2007-09-30 19:24:57 +0200 (Sun, 30 Sep 2007)
    New Revision: 22389
    ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22389&view=rev
    
    Modified:
       haiku/trunk/build/jam/HaikuImage
       haiku/trunk/build/jam/UserBuildConfig.sample
    Log:
    * prepare optional package Vision (download at sourceforge has been updated
      with HVIF icon too, thanks DeadYak!)
    * enable optional packages in your UserBuildSetup
    
    
    Modified: haiku/trunk/build/jam/HaikuImage
    ===================================================================
    --- haiku/trunk/build/jam/HaikuImage	2007-09-30 16:03:53 UTC (rev 22388)
    +++ haiku/trunk/build/jam/HaikuImage	2007-09-30 17:24:57 UTC (rev 22389)
    @@ -416,6 +416,16 @@
     #pragma mark - Optional Packages
     
     
    +# Vision
    +if [ IsOptionalHaikuImagePackageAdded Vision ] {
    +	InstallOptionalHaikuImagePackage Vision
    +		: http://vision.sourceforge.net/Vision-0.9.7-SF-01052007.zip
    +		: apps
    +	;
    +	AddSymlinkToHaikuImage home config be Applications
    +		: /boot/apps/Vision-0.9.7-SF-01052007/Vision ;
    +}
    +
     # WonderBrush
     if [ IsOptionalHaikuImagePackageAdded WonderBrush ] {
     	InstallOptionalHaikuImagePackage WonderBrush
    
    Modified: haiku/trunk/build/jam/UserBuildConfig.sample
    ===================================================================
    --- haiku/trunk/build/jam/UserBuildConfig.sample	2007-09-30 16:03:53 UTC (rev 22388)
    +++ haiku/trunk/build/jam/UserBuildConfig.sample	2007-09-30 17:24:57 UTC (rev 22389)
    @@ -71,6 +71,9 @@
     # via wget (i.e. wget must be installed).
     AddOptionalHaikuImagePackages WonderBrush ;
     
    +# Adds the optional package Vision to the image. See above.
    +AddOptionalHaikuImagePackages Vision ;
    +
     # Add all available optional packages.
     HAIKU_ADD_ALL_OPTIONAL_PACKAGES = 1 ;