From leavengood at gmail.com Sat Dec 1 00:07:26 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Fri, 30 Nov 2007 18:07:26 -0500 Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <21977076.1196455072857.JavaMail.ngmail@webmail11> References: <542624725-BeMail@laptop> <21977076.1196455072857.JavaMail.ngmail@webmail11> Message-ID: On 11/30/07, Marcus Overhagen wrote: > > > > > what's the guidelines for trunk/3rdparty/ ? > > > > > > Not sure. Marcus created it. Currently it has the feel of stuff that comes > > > from third parties and is somehow Haiku-related, but not needed for Haiku > > > It was meant for that purpose, for example to include binary-only third > party drivers, tools and applications that might be useful to be installed > on the haiku image. we could put for example a firefox.zip there that > is know to work with haiku and already compiled, so it just needs to > be unzipped onto the haiku image. I also have used 3rdparty for my WebKit port and associated libraries. I think it makes a good place for that. This way the WebKit code can be integrated into the Haiku build without actually being a part of the Haiku repo. I plan to release my current WebKit code this weekend so we shall see how well it works for other people. Regards, Ryan From mmlr at mail.berlios.de Sat Dec 1 11:18:27 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sat, 1 Dec 2007 11:18:27 +0100 Subject: [Haiku-commits] r23035 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200712011018.lB1AIRkb029260@sheep.berlios.de> Author: mmlr Date: 2007-12-01 11:18:27 +0100 (Sat, 01 Dec 2007) New Revision: 23035 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23035&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp Log: Messed up those numbers. The interval can range from 0 to 16 and we can use 0 to 10 with the 1024 frame list. So it's obviously 11 entries and not 10. Fixes the wrong tree layout and the doubled polling intervals of interrupts. Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-11-30 19:59:29 UTC (rev 23034) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ehci.cpp 2007-12-01 10:18:27 UTC (rev 23035) @@ -254,7 +254,7 @@ memset(logicalBase, 0, B_PAGE_SIZE); fInterruptEntries = (interrupt_entry *)logicalBase; - for (int32 i = 0; i < 10; i++) { + for (int32 i = 0; i < 11; i++) { ehci_qh *queueHead = &fInterruptEntries[i].queue_head; queueHead->this_phy = physicalBase; queueHead->current_qtd_phy = EHCI_QTD_TERMINATE; @@ -275,7 +275,7 @@ // build flat interrupt tree TRACE(("usb_ehci: build up interrupt links\n")); uint32 interval = 1024; - uint32 intervalIndex = 9; + uint32 intervalIndex = 10; while (interval > 1) { uint32 insertIndex = interval / 2; while (insertIndex < 1024) { @@ -292,7 +292,7 @@ ehci_qh *firstLogical = &fInterruptEntries[0].queue_head; uint32 firstPhysical = firstLogical->this_phy | EHCI_QH_TYPE_QH; fPeriodicFrameList[0] = firstPhysical; - for (int32 i = 1; i < 10; i++) { + for (int32 i = 1; i < 11; i++) { fInterruptEntries[i].queue_head.next_phy = firstPhysical; fInterruptEntries[i].queue_head.next_log = firstLogical; } @@ -1267,10 +1267,10 @@ interval = 1; // this may happen as intervals can go up to 16; we limit the value to - // 10 as you cannot support intervals above that with a frame list of + // 11 as you cannot support intervals above that with a frame list of // just 1024 entries... - if (interval > 10) - interval = 10; + if (interval > 11) + interval = 11; ehci_qh *interruptQueue = &fInterruptEntries[interval - 1].queue_head; queueHead->next_log = interruptQueue->next_log; From axeld at mail.berlios.de Sat Dec 1 12:09:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 12:09:58 +0100 Subject: [Haiku-commits] r23036 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200712011109.lB1B9wsk031119@sheep.berlios.de> Author: axeld Date: 2007-12-01 12:09:58 +0100 (Sat, 01 Dec 2007) New Revision: 23036 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23036&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c Log: * device_delete_child() now works differently from FreeBSD: in FreeBSD you can't just call this function if you don't know if a device has a direct reference to one of its children. Since we want to be able to delete the root without having any knowledge about its children, we now detach everything first, and then delete the entries. This fixes a possible crashing bug when a preloaded driver (used for network boot) tried to acquire its resources again at a later point. * device_detach() and device_attach() now check if the device has an attach or detach method at all. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-12-01 10:18:27 UTC (rev 23035) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-12-01 11:09:58 UTC (rev 23036) @@ -314,27 +314,40 @@ int device_delete_child(device_t parent, device_t child) { + int status; + if (child == NULL) return 0; if (parent != NULL) list_remove_item(&parent->children, child); + // We differentiate from the FreeBSD logic here - it will first delete + // the children, and will then detach the device. + // This has the problem that you cannot safely call device_delete_child() + // as you don't know if one of the children deletes its own children this + // way when it is detached. + // Therefore, we'll detach first, and then delete whatever is left. + parent = child; + child = NULL; - while ((child = list_remove_head_item(&parent->children)) != NULL) { - device_delete_child(NULL, child); + // detach children + while ((child = list_get_next_item(&parent->children, child)) != NULL) { + device_detach(child); } - if ((atomic_and(&parent->flags, ~DEVICE_ATTACHED) & DEVICE_ATTACHED) != 0 - && parent->methods.detach != NULL) { - int status = parent->methods.detach(parent); - if (status != 0) { - atomic_or(&parent->flags, DEVICE_ATTACHED); - return status; - } + // detach device + status = device_detach(parent); + if (status != 0) + return status; + + // delete children + while ((child = list_get_first_item(&parent->children)) != NULL) { + device_delete_child(parent, child); } + // delete device if (parent->flags & DEVICE_DESC_ALLOCED) free((char *)parent->description); @@ -356,7 +369,8 @@ { int result; - if (device->driver == NULL) + if (device->driver == NULL + || device->methods.attach == NULL) return B_ERROR; result = device->methods.attach(device); @@ -373,7 +387,8 @@ if (device->driver == NULL) return B_ERROR; - if ((atomic_and(&device->flags, ~DEVICE_ATTACHED) & DEVICE_ATTACHED) != 0) { + if ((atomic_and(&device->flags, ~DEVICE_ATTACHED) & DEVICE_ATTACHED) != 0 + && device->methods.detach != NULL) { int result = device->methods.detach(device); if (result != 0) { atomic_or(&device->flags, DEVICE_ATTACHED); From axeld at mail.berlios.de Sat Dec 1 13:01:13 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 13:01:13 +0100 Subject: [Haiku-commits] r23037 - haiku/trunk/src/system/kernel Message-ID: <200712011201.lB1C1DDW014859@sheep.berlios.de> Author: axeld Date: 2007-12-01 13:01:11 +0100 (Sat, 01 Dec 2007) New Revision: 23037 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23037&view=rev Modified: haiku/trunk/src/system/kernel/int.c Log: The "ints" KDL command now also dumps the handlers associated to a vector. Modified: haiku/trunk/src/system/kernel/int.c =================================================================== --- haiku/trunk/src/system/kernel/int.c 2007-12-01 11:09:58 UTC (rev 23036) +++ haiku/trunk/src/system/kernel/int.c 2007-12-01 12:01:11 UTC (rev 23037) @@ -76,19 +76,28 @@ { int i; for (i = 0; i < NUM_IO_VECTORS; i++) { + struct io_handler *io; + if (io_vectors[i].vector_lock == 0 && io_vectors[i].enable_count == 0 && io_vectors[i].handled_count == 0 && io_vectors[i].unhandled_count == 0 && io_vectors[i].handler_list.next == &io_vectors[i].handler_list) continue; + kprintf("int %3d, enabled %ld, handled %8lld, unhandled %8lld%s%s\n", - i, - io_vectors[i].enable_count, - io_vectors[i].handled_count, + i, io_vectors[i].enable_count, io_vectors[i].handled_count, io_vectors[i].unhandled_count, - (io_vectors[i].vector_lock != 0) ? ", ACTIVE" : "", - (io_vectors[i].handler_list.next == &io_vectors[i].handler_list) ? ", no handler" : ""); + io_vectors[i].vector_lock != 0 ? ", ACTIVE" : "", + io_vectors[i].handler_list.next == &io_vectors[i].handler_list + ? ", no handler" : ""); + + for (io = io_vectors[i].handler_list.next; + io != &io_vectors[i].handler_list; io = io->next) { + kprintf("\t%p", io->func); + } + if (io_vectors[i].handler_list.next != &io_vectors[i].handler_list) + kprintf("\n"); } return 0; } From axeld at mail.berlios.de Sat Dec 1 14:16:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 14:16:34 +0100 Subject: [Haiku-commits] r23038 - haiku/trunk/src/libs/compat/freebsd_network Message-ID: <200712011316.lB1DGYRG024185@sheep.berlios.de> Author: axeld Date: 2007-12-01 14:16:34 +0100 (Sat, 01 Dec 2007) New Revision: 23038 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23038&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c haiku/trunk/src/libs/compat/freebsd_network/device.c Log: * We need to call if_init() before trying to set the media. * Accidently excluded the MII bus from being probed in r23019 - in fact, now all devices have to be probed. Modified: haiku/trunk/src/libs/compat/freebsd_network/compat.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-12-01 12:01:11 UTC (rev 23037) +++ haiku/trunk/src/libs/compat/freebsd_network/compat.c 2007-12-01 13:16:34 UTC (rev 23038) @@ -415,7 +415,7 @@ MII_OUI(ma->mii_id1, ma->mii_id2), MII_MODEL(ma->mii_id2)); } else device_set_driver(child, driver); - } else if (child->driver != &miibus_driver) + } else child->methods.probe(child); if (child->driver != NULL) { Modified: haiku/trunk/src/libs/compat/freebsd_network/device.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-12-01 12:01:11 UTC (rev 23037) +++ haiku/trunk/src/libs/compat/freebsd_network/device.c 2007-12-01 13:16:34 UTC (rev 23038) @@ -47,6 +47,8 @@ return B_BUSY; } + ifp->if_init(ifp->if_softc); + ifp->if_flags &= ~IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); @@ -57,8 +59,6 @@ ifp->if_flags |= IFF_UP; ifp->if_ioctl(ifp, SIOCSIFFLAGS, NULL); - ifp->if_init(ifp->if_softc); - *cookie = ifp; return B_OK; } From axeld at mail.berlios.de Sat Dec 1 14:18:09 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 14:18:09 +0100 Subject: [Haiku-commits] r23039 - haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk Message-ID: <200712011318.lB1DI9WG024237@sheep.berlios.de> Author: axeld Date: 2007-12-01 14:18:09 +0100 (Sat, 01 Dec 2007) New Revision: 23039 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23039&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c Log: The Marvell Yukon driver needs the SWI task queues as well. The driver is now working, but it does not yet work reliably here - it encounters a "PCI Express protocol violation", at least that's what it says. Will look into that later. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-12-01 13:16:34 UTC (rev 23038) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/Jamfile 2007-12-01 13:18:09 UTC (rev 23039) @@ -5,7 +5,7 @@ UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ; UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ; -SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 EM_FAST_INTR=1 ] ; +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; KernelAddon marvell_yukon : if_msk.c Modified: haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-12-01 13:16:34 UTC (rev 23038) +++ haiku/trunk/src/add-ons/kernel/drivers/network/marvell_yukon/dev/msk/glue.c 2007-12-01 13:18:09 UTC (rev 23039) @@ -29,8 +29,4 @@ NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); NO_HAIKU_REENABLE_INTERRUPTS(); -#ifdef EM_FAST_INTR - HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE); -#else - HAIKU_DRIVER_REQUIREMENTS(0); -#endif +HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE | FBSD_SWI_TASKQUEUE); From axeld at mail.berlios.de Sat Dec 1 16:27:57 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 16:27:57 +0100 Subject: [Haiku-commits] r23040 - haiku/vendor Message-ID: <200712011527.lB1FRvHA003438@sheep.berlios.de> Author: axeld Date: 2007-12-01 16:27:56 +0100 (Sat, 01 Dec 2007) New Revision: 23040 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23040&view=rev Added: haiku/vendor/freebsd/ Log: Added a vendor branch for the FreeBSD drivers. From axeld at mail.berlios.de Sat Dec 1 16:39:01 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 16:39:01 +0100 Subject: [Haiku-commits] r23041 - in haiku/vendor/freebsd: . current current/dev current/dev/em current/dev/fxp current/dev/mii current/dev/msk current/pci Message-ID: <200712011539.lB1Fd1w4004347@sheep.berlios.de> Author: axeld Date: 2007-12-01 16:38:33 +0100 (Sat, 01 Dec 2007) New Revision: 23041 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23041&view=rev Added: haiku/vendor/freebsd/current/ haiku/vendor/freebsd/current/dev/ haiku/vendor/freebsd/current/dev/em/ haiku/vendor/freebsd/current/dev/em/LICENSE haiku/vendor/freebsd/current/dev/em/README haiku/vendor/freebsd/current/dev/em/e1000_80003es2lan.c haiku/vendor/freebsd/current/dev/em/e1000_80003es2lan.h haiku/vendor/freebsd/current/dev/em/e1000_82540.c haiku/vendor/freebsd/current/dev/em/e1000_82541.c haiku/vendor/freebsd/current/dev/em/e1000_82541.h haiku/vendor/freebsd/current/dev/em/e1000_82542.c haiku/vendor/freebsd/current/dev/em/e1000_82543.c haiku/vendor/freebsd/current/dev/em/e1000_82543.h haiku/vendor/freebsd/current/dev/em/e1000_82571.c haiku/vendor/freebsd/current/dev/em/e1000_82571.h haiku/vendor/freebsd/current/dev/em/e1000_82575.c haiku/vendor/freebsd/current/dev/em/e1000_82575.h haiku/vendor/freebsd/current/dev/em/e1000_api.c haiku/vendor/freebsd/current/dev/em/e1000_api.h haiku/vendor/freebsd/current/dev/em/e1000_defines.h haiku/vendor/freebsd/current/dev/em/e1000_hw.h haiku/vendor/freebsd/current/dev/em/e1000_ich8lan.c haiku/vendor/freebsd/current/dev/em/e1000_ich8lan.h haiku/vendor/freebsd/current/dev/em/e1000_mac.c haiku/vendor/freebsd/current/dev/em/e1000_mac.h haiku/vendor/freebsd/current/dev/em/e1000_manage.c haiku/vendor/freebsd/current/dev/em/e1000_manage.h haiku/vendor/freebsd/current/dev/em/e1000_nvm.c haiku/vendor/freebsd/current/dev/em/e1000_nvm.h haiku/vendor/freebsd/current/dev/em/e1000_osdep.h haiku/vendor/freebsd/current/dev/em/e1000_phy.c haiku/vendor/freebsd/current/dev/em/e1000_phy.h haiku/vendor/freebsd/current/dev/em/e1000_regs.h haiku/vendor/freebsd/current/dev/em/if_em.c haiku/vendor/freebsd/current/dev/em/if_em.h haiku/vendor/freebsd/current/dev/fxp/ haiku/vendor/freebsd/current/dev/fxp/if_fxp.c haiku/vendor/freebsd/current/dev/fxp/if_fxpreg.h haiku/vendor/freebsd/current/dev/fxp/if_fxpvar.h haiku/vendor/freebsd/current/dev/fxp/rcvbundl.h haiku/vendor/freebsd/current/dev/mii/ haiku/vendor/freebsd/current/dev/mii/bmtphy.c haiku/vendor/freebsd/current/dev/mii/bmtphyreg.h haiku/vendor/freebsd/current/dev/mii/brgphyreg.h haiku/vendor/freebsd/current/dev/mii/ciphy.c haiku/vendor/freebsd/current/dev/mii/ciphyreg.h haiku/vendor/freebsd/current/dev/mii/e1000phy.c haiku/vendor/freebsd/current/dev/mii/e1000phyreg.h haiku/vendor/freebsd/current/dev/mii/exphy.c haiku/vendor/freebsd/current/dev/mii/rlphy.c haiku/vendor/freebsd/current/dev/mii/ukphy.c haiku/vendor/freebsd/current/dev/mii/ukphy_subr.c haiku/vendor/freebsd/current/dev/msk/ haiku/vendor/freebsd/current/dev/msk/if_msk.c haiku/vendor/freebsd/current/dev/msk/if_mskreg.h haiku/vendor/freebsd/current/pci/ haiku/vendor/freebsd/current/pci/if_rl.c haiku/vendor/freebsd/current/pci/if_rlreg.h haiku/vendor/freebsd/current/pci/if_vr.c haiku/vendor/freebsd/current/pci/if_vrreg.h haiku/vendor/freebsd/current/pci/if_xl.c haiku/vendor/freebsd/current/pci/if_xlreg.h Log: Added verbatim copies of the FreeBSD 7 drivers we're currently using. Added: haiku/vendor/freebsd/current/dev/em/LICENSE =================================================================== --- haiku/vendor/freebsd/current/dev/em/LICENSE 2007-12-01 15:27:56 UTC (rev 23040) +++ haiku/vendor/freebsd/current/dev/em/LICENSE 2007-12-01 15:38:33 UTC (rev 23041) @@ -0,0 +1,31 @@ +$FreeBSD: src/sys/dev/em/LICENSE,v 1.6 2007/05/04 00:00:11 jfv Exp $ + + Copyright (c) 2001-2007, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + Added: haiku/vendor/freebsd/current/dev/em/README =================================================================== --- haiku/vendor/freebsd/current/dev/em/README 2007-12-01 15:27:56 UTC (rev 23040) +++ haiku/vendor/freebsd/current/dev/em/README 2007-12-01 15:38:33 UTC (rev 23041) @@ -0,0 +1,405 @@ +$FreeBSD: src/sys/dev/em/README,v 1.15 2007/05/30 23:32:21 jfv Exp $ +FreeBSD* Driver for Intel Network Connection +============================================= + +May 30, 2007 + + +Contents +======== + +- Overview +- Identifying Your Adapter +- Building and Installation +- Speed and Duplex Configuration +- Additional Configurations +- Known Limitations +- Support +- License + + +Overview +======== + +This file describes the FreeBSD* driver for Intel Network Connection. +This driver has been developed for use with FreeBSD, Release 7.x. + +For questions related to hardware requirements, refer to the documentation +supplied with your Gigabit adapter. All hardware requirements listed +apply to use with FreeBSD. + + +Identifying Your Adapter +======================== + +For information on how to identify your adapter, go to the Adapter & +Driver ID Guide at: + +http://support.intel.com/support/network/sb/cs-012904.htm + + +For the latest Intel network drivers for FreeBSD, see: + +http://downloadfinder.intel.com/scripts-df-external/support_intel.aspx + + +NOTE: Mobile adapters are not fully supported. +NOTE: The Intel(R) 82562v 10/100 Network Connection only provides 10/100 +support. + +Building and Installation +========================= + +NOTE: The driver can be installed as a dynamic loadable kernel module or + compiled into the kernel. You must have kernel sources installed in + order to compile the driver module. + +In the instructions below, x.x.x is the driver version as indicated in the +name of the driver tar file. + +1. Move the base driver tar file to the directory of your choice. For + example, use /home/username/em or /usr/local/src/em. + +2. Untar/unzip the archive: + + tar xzvf em-x.x.x.tar.gz + + This will create an em-x.x.x directory. + +3. To create a loadable module, perform the following steps. + NOTE: To compile the driver into the kernel, go directly to step 4. + + a. To compile the module + + cd em-x.x.x + make + + b. To install the compiled module to the system directory: + + make install + + c. If you want the driver to load automatically when the system is booted: + + 1. Edit /boot/loader.conf, and add the following line: + + if_em_load="YES" + +4. To compile the driver into the kernel, enter: + + cd em-x.x.x/src + cp *.[ch] /usr/src/sys/dev/em + + Edit the kernel configuration file (i.e., GENERIC or MYKERNEL) in + /usr/src/sys/i386/conf, and ensure the following line is present: + + device em + + Compile and install the kernel. The system must be rebooted for the + kernel updates to take effect. For additional information on compiling + the kernel, consult the FreeBSD operating system documentation. + +5. To assign an IP address to the interface, enter the following: + + ifconfig em + +6. Verify that the interface works. Enter the following, where + is the IP address for another machine on the same subnet as the interface + that is being tested: + + ping + +7. To configure the IP address to remain after reboot, edit /etc/rc.conf, + and create the appropriate ifconfig_ementry: + + ifconfig_em="" + + Example usage: + + ifconfig_em0="inet 192.168.10.1 netmask 255.255.255.0" + + NOTE: For assistance, see the ifconfig man page. + + +Speed and Duplex Configuration +============================== + +By default, the adapter auto-negotiates the speed and duplex of the +connection. If there is a specific need, the ifconfig utility can be used to +configure the speed and duplex settings on the adapter. Example usage: + + ifconfig em media 100baseTX mediaopt + full-duplex + + NOTE: Only use mediaopt to set the driver to full-duplex. If mediaopt is + not specified and you are not running at gigabit speed, the driver + defaults to half-duplex. + +If the interface is currently forced to 100 full duplex, in order to change +to half duplex you must use this command: + + ifconfig em media 100baseTX -mediaopt + full-duplex + + +This driver supports the following media type options: + + autoselect - Enables auto-negotiation for speed and duplex. + + 10baseT/UTP - Sets speed to 10 Mbps. Use the ifconfig mediaopt + option to select full-duplex mode. + + 100baseTX - Sets speed to 100 Mbps. Use the ifconfig mediaopt + option to select full-duplex mode. + + 1000baseTX - Sets speed to 1000 Mbps. In this case, the driver + supports only full-duplex mode. + + 1000baseSX - Sets speed to 1000 Mbps. In this case, the driver + supports only full-duplex mode. + +For more information on the ifconfig utility, see the ifconfig man page. + + +Additional Configurations +========================= + +The driver supports Transmit/Receive Checksum Offload and Jumbo Frames on +all but the 82542-based adapters. For specific adapters, refer to the +Identifying Your Adapter section. + + Jumbo Frames + ------------ + To enable Jumbo Frames, use the ifconfig utility to set the Maximum + Transport Unit (MTU) frame size above its default of 1500 bytes. + + The Jumbo Frames MTU range for Intel Adapters is 1500 to 16110. To modify + the setting, enter the following: + + ifconfig em mtu 9000 + + To confirm the MTU used between two specific devices, use: + + route get + + Notes: + + - Only enable Jumbo Frames if your network infrastructure supports them. + + - To enable Jumbo Frames, increase the MTU size on the interface beyond + 1500. + + - The Jumbo Frames setting on the switch must be set to at least 22 bytes + larger than that of the MTU. + + - The maximum MTU setting for Jumbo Frames is 16110. This value coincides + with the maximum Jumbo Frames size of 16128. + + - Some Intel gigabit adapters that support Jumbo Frames have a frame size + limit of 9238 bytes, with a corresponding MTU size limit of 9216 bytes. + The adapters with this limitation are based on the Intel(R) 82571EB, + 82572EI, 82573L, 82566, 82562, and 80003ES2LAN controller. These + correspond to the following product names: + Intel(R) PRO/1000 PT Server Adapter + Intel(R) PRO/1000 PT Desktop Adapter + Intel(R) PRO/1000 PT Network Connection + Intel(R) PRO/1000 PT Dual Port Server Adapter + Intel(R) PRO/1000 PT Dual Port Network Connection + Intel(R) PRO/1000 PT Quad Port Server Adapter + Intel(R) PRO/1000 PF Quad Port Server Adapter + Intel(R) PRO/1000 PF Server Adapter + Intel(R) PRO/1000 PF Network Connection + Intel(R) PRO/1000 PF Dual Port Server Adapter + Intel(R) PRO/1000 PB Server Connection + Intel(R) PRO/1000 PL Network Connection + Intel(R) PRO/1000 EB Network Connection with I/O Acceleration + Intel(R) PRO/1000 EB Backplane Connection with I/O Acceleration + Intel(R) 82566DM-2 Gigabit Network Connection + + - Adapters based on the Intel(R) 82542 and 82573V/E controller do not + support Jumbo Frames. These correspond to the following product names: + Intel(R) PRO/1000 Gigabit Server Adapter + Intel(R) PRO/1000 PM Network Connection + + - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or + loss of link. + + - The following adapters do not support Jumbo Frames: + Intel(R) 82562V 10/100 Network Connection + Intel(R) 82566DM Gigabit Network Connection + Intel(R) 82566DC Gigabit Network Connection + Intel(R) 82566MM Gigabit Network Connection + Intel(R) 82566MC Gigabit Network Connection + Intel(R) 82562GT 10/100 Network Connection + Intel(R) 82562G 10/100 Network Connection + Intel(R) 82566DC-2 Gigabit Network Connection + Intel(R) 82562V-2 10/100 Network Connection + Intel(R) 82562G-2 10/100 Network Connection + Intel(R) 82562GT-2 10/100 Network Connection + + VLANs + ----- + To create a new VLAN interface: + + ifconfig create + + To associate the VLAN interface with a physical interface and + assign a VLAN ID, IP address, and netmask: + + ifconfig netmask vlan + vlandev + + Example: + + ifconfig vlan10 10.0.0.1 netmask 255.255.255.0 vlan 10 vlandev em0 + + In this example, all packets will be marked on egress with 802.1Q VLAN + tags, specifying a VLAN ID of 10. + + To remove a VLAN interface: + + Intel Network Connection ifconfig destroy + + + Polling + ------- + + To enable polling in the driver, add the following options to the kernel + configuration, and then recompile the kernel: + + options DEVICE_POLLING + options HZ=1000 + + At runtime use: + ifconfig emX polling (to turn polling on) + and: + ifconfig emX -polling (to turn it off) + + + Checksum Offload + ---------------- + Checksum offloading is not supported on 82542 Gigabit adapters. + + Checksum offloading supports both TCP and UDP packets and is + supported for both transmit and receive. + + Checksum offloading can be enabled or disabled using ifconfig. + Both transmit and receive offloading will be either enabled or + disabled together. You cannot enable/disable one without the other. + + To enable checksum offloading: + + ifconfig rxcsum + + To disable checksum offloading: + + ifconfig -rxcsum + + To confirm the current setting: + + ifconfig + + Look for the presence or absence of the following line: + + options=3 + + See the ifconfig man page for further information. + + + TSO + --- + The FreeBSD driver offers support for TSO (TCP Segmentation Offload). + + You can enable/disable it in two ways/places: + + - sysctl net.inet.tcp.tso=0 (or 1 to enable it) + + Doing this disables TSO in the stack and will affect all adapters. + + - ifconfig emX -tso + + Doing this will disable TSO only for this adapter. + + To enable: + + - ifconfig emX tso + + NOTES: By default only PCI-Express adapters are ENABLED to do TSO. Others + can be enabled by the user at their own risk + TSO is not supported on 82547 and 82544-based adapters, as well as older adapters. + + +Known Limitations +================= + + Detected Tx Unit Hang in Quad Port Adapters + ------------------------------------------- + + In some cases ports 3 and 4 wont pass traffic. Ports 1 and 2 don't show + any errors and will pass traffic. + + This issue MAY be resolved by updating to the latest BIOS. You can + check your system's BIOS by downloading the Linux Firmware Developer Kit + that can be obtained at http://www.linuxfirmwarekit.org/ + + + There are known performance issues with this driver when running UDP traffic + with Jumbo Frames. + ---------------------------------------------------------------------------- + + 82541/82547 can't link or is slow to link with some link partners + ----------------------------------------------------------------- + + There is a known compatibility issue where time to link is slow or link is not + established between 82541/82547 controllers and some switches. Known switches + include: + Planex FXG-08TE + I-O Data ETG-SH8 + + The driver can be compiled with the following changes: + + Edit ./em.x.x.x/src/if_em.h to change the #define EM_MASTER_SLAVE + For example, change from: + + #define EM_MASTER_SLAVE e1000_ms_hw_default + to: + #define EM_MASTER_SLAVE 2 + + Use one of the following options: + 1 = Master mode + 2 = Slave mode + 3 = Auto master/slave + Setting 2 is recommended. + + Recompile the module: + a. To compile the module + cd em-x.x.x + make clean + make + + b. To install the compiled module in system directory: + make install + + +Support +======= + +For general information and support, go to the Intel support website at: + + http://support.intel.com + +If an issue is identified, support is through email only at: +freebsdnic at mailbox.intel.com + + +License +======= + +This software program is released under the terms of a license agreement +between you ('Licensee') and Intel. Do not use or load this software or any +associated materials (collectively, the 'Software') until you have carefully +read the full terms and conditions of the LICENSE located in this software +package. By loading or using the Software, you agree to the terms of this +Agreement. If you do not agree with the terms of this Agreement, do not +install or use the Software. + +* Other names and brands may be claimed as the property of others. Added: haiku/vendor/freebsd/current/dev/em/e1000_80003es2lan.c =================================================================== --- haiku/vendor/freebsd/current/dev/em/e1000_80003es2lan.c 2007-12-01 15:27:56 UTC (rev 23040) +++ haiku/vendor/freebsd/current/dev/em/e1000_80003es2lan.c 2007-12-01 15:38:33 UTC (rev 23041) @@ -0,0 +1,1339 @@ +/******************************************************************************* + + Copyright (c) 2001-2007, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************************/ +/*$FreeBSD: src/sys/dev/em/e1000_80003es2lan.c,v 1.3 2007/05/16 00:14:23 jfv Exp $*/ + +/* e1000_80003es2lan + */ + +#include "e1000_api.h" +#include "e1000_80003es2lan.h" + +void e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw); + +STATIC s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_release_phy_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_release_nvm_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, + u32 offset, + u16 *data); +STATIC s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, + u32 offset, + u16 data); +STATIC s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset, + u16 words, u16 *data); +STATIC s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, + u16 *duplex); +STATIC s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw); +STATIC s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw); +STATIC void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw); +static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); +static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex); +static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw); +static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw); +static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw); +static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); + +/* A table for the GG82563 cable length where the range is defined + * with a lower bound at "index" and the upper bound at + * "index + 5". + */ +static const +u16 e1000_gg82563_cable_length_table[] = + { 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF }; +#define GG82563_CABLE_LENGTH_TABLE_SIZE \ + (sizeof(e1000_gg82563_cable_length_table) / \ + sizeof(e1000_gg82563_cable_length_table[0])) + +/** + * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs. + * @hw: pointer to the HW structure + * + * This is a function pointer entry point called by the api module. + **/ +STATIC s32 +e1000_init_phy_params_80003es2lan(struct e1000_hw *hw) +{ + struct e1000_phy_info *phy = &hw->phy; + struct e1000_functions *func = &hw->func; + s32 ret_val = E1000_SUCCESS; + + DEBUGFUNC("e1000_init_phy_params_80003es2lan"); + + if (hw->media_type != e1000_media_type_copper) { + phy->type = e1000_phy_none; + goto out; + } + + phy->addr = 1; + phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; + phy->reset_delay_us = 100; + phy->type = e1000_phy_gg82563; + + func->acquire_phy = e1000_acquire_phy_80003es2lan; + func->check_polarity = e1000_check_polarity_m88; + func->check_reset_block = e1000_check_reset_block_generic; + func->commit_phy = e1000_phy_sw_reset_generic; + func->get_cfg_done = e1000_get_cfg_done_80003es2lan; + func->get_phy_info = e1000_get_phy_info_m88; + func->release_phy = e1000_release_phy_80003es2lan; + func->reset_phy = e1000_phy_hw_reset_generic; + func->set_d3_lplu_state = e1000_set_d3_lplu_state_generic; + + func->force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan; + func->get_cable_length = e1000_get_cable_length_80003es2lan; + func->read_phy_reg = e1000_read_phy_reg_gg82563_80003es2lan; + func->write_phy_reg = e1000_write_phy_reg_gg82563_80003es2lan; + + /* This can only be done after all function pointers are setup. */ + ret_val = e1000_get_phy_id(hw); + + /* Verify phy id */ + if (phy->id != GG82563_E_PHY_ID) { + ret_val = -E1000_ERR_PHY; + goto out; + } + +out: + return ret_val; +} + +/** + * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs. + * @hw: pointer to the HW structure + * + * This is a function pointer entry point called by the api module. + **/ +STATIC s32 +e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw) +{ + struct e1000_nvm_info *nvm = &hw->nvm; + struct e1000_functions *func = &hw->func; + u32 eecd = E1000_READ_REG(hw, E1000_EECD); + u16 size; + + DEBUGFUNC("e1000_init_nvm_params_80003es2lan"); + + nvm->opcode_bits = 8; + nvm->delay_usec = 1; + switch (nvm->override) { + case e1000_nvm_override_spi_large: + nvm->page_size = 32; + nvm->address_bits = 16; + break; + case e1000_nvm_override_spi_small: + nvm->page_size = 8; + nvm->address_bits = 8; + break; + default: + nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; + nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8; + break; + } + + nvm->type = e1000_nvm_eeprom_spi; + + size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> + E1000_EECD_SIZE_EX_SHIFT); + + /* Added to a constant, "size" becomes the left-shift value + * for setting word_size. + */ + size += NVM_WORD_SIZE_BASE_SHIFT; + nvm->word_size = 1 << size; + + /* Function Pointers */ + func->acquire_nvm = e1000_acquire_nvm_80003es2lan; + func->read_nvm = e1000_read_nvm_eerd; + func->release_nvm = e1000_release_nvm_80003es2lan; + func->update_nvm = e1000_update_nvm_checksum_generic; + func->valid_led_default = e1000_valid_led_default_generic; + func->validate_nvm = e1000_validate_nvm_checksum_generic; + func->write_nvm = e1000_write_nvm_80003es2lan; + + return E1000_SUCCESS; +} + +/** + * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs. + * @hw: pointer to the HW structure + * + * This is a function pointer entry point called by the api module. + **/ +STATIC s32 +e1000_init_mac_params_80003es2lan(struct e1000_hw *hw) +{ + struct e1000_mac_info *mac = &hw->mac; + struct e1000_functions *func = &hw->func; + s32 ret_val = E1000_SUCCESS; + + DEBUGFUNC("e1000_init_mac_params_80003es2lan"); + + /* Set media type */ + switch (hw->device_id) { + case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: + hw->media_type = e1000_media_type_internal_serdes; + break; + default: + hw->media_type = e1000_media_type_copper; + break; + } + + /* Set mta register count */ + mac->mta_reg_count = 128; + /* Set rar entry count */ + mac->rar_entry_count = E1000_RAR_ENTRIES; + /* Set if part includes ASF firmware */ + mac->asf_firmware_present = TRUE; + /* Set if manageability features are enabled. */ + mac->arc_subsystem_valid = + (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK) + ? TRUE : FALSE; + + /* Function pointers */ + + /* bus type/speed/width */ + func->get_bus_info = e1000_get_bus_info_pcie_generic; + /* reset */ + func->reset_hw = e1000_reset_hw_80003es2lan; + /* hw initialization */ + func->init_hw = e1000_init_hw_80003es2lan; + /* link setup */ + func->setup_link = e1000_setup_link_generic; + /* physical interface link setup */ + func->setup_physical_interface = + (hw->media_type == e1000_media_type_copper) + ? e1000_setup_copper_link_80003es2lan + : e1000_setup_fiber_serdes_link_generic; + /* check for link */ + switch (hw->media_type) { + case e1000_media_type_copper: + func->check_for_link = e1000_check_for_copper_link_generic; + break; + case e1000_media_type_fiber: + func->check_for_link = e1000_check_for_fiber_link_generic; + break; + case e1000_media_type_internal_serdes: + func->check_for_link = e1000_check_for_serdes_link_generic; + break; + default: + ret_val = -E1000_ERR_CONFIG; + goto out; + break; + } + /* check management mode */ + func->check_mng_mode = e1000_check_mng_mode_generic; + /* multicast address update */ + func->mc_addr_list_update = e1000_mc_addr_list_update_generic; + /* writing VFTA */ + func->write_vfta = e1000_write_vfta_generic; + /* clearing VFTA */ + func->clear_vfta = e1000_clear_vfta_generic; + /* setting MTA */ + func->mta_set = e1000_mta_set_generic; + /* blink LED */ + func->blink_led = e1000_blink_led_generic; + /* setup LED */ + func->setup_led = e1000_setup_led_generic; + /* cleanup LED */ + func->cleanup_led = e1000_cleanup_led_generic; + /* turn on/off LED */ + func->led_on = e1000_led_on_generic; + func->led_off = e1000_led_off_generic; + /* remove device */ + func->remove_device = e1000_remove_device_generic; + /* clear hardware counters */ + func->clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan; + /* link info */ + func->get_link_up_info = e1000_get_link_up_info_80003es2lan; + +out: + return ret_val; +} + +/** + * e1000_init_function_pointers_80003es2lan - Init ESB2 func ptrs. + * @hw: pointer to the HW structure + * + * The only function explicitly called by the api module to initialize + * all function pointers and parameters. + **/ +void +e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw) +{ + DEBUGFUNC("e1000_init_function_pointers_80003es2lan"); + + hw->func.init_mac_params = e1000_init_mac_params_80003es2lan; + hw->func.init_nvm_params = e1000_init_nvm_params_80003es2lan; + hw->func.init_phy_params = e1000_init_phy_params_80003es2lan; +} + +/** + * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY + * @hw: pointer to the HW structure + * + * A wrapper to acquire access rights to the correct PHY. This is a + * function pointer entry point called by the api module. + **/ +STATIC s32 +e1000_acquire_phy_80003es2lan(struct e1000_hw *hw) +{ + u16 mask; + + DEBUGFUNC("e1000_acquire_phy_80003es2lan"); + + mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; + + return e1000_acquire_swfw_sync_80003es2lan(hw, mask); +} + +/** + * e1000_release_phy_80003es2lan - Release rights to access PHY + * @hw: pointer to the HW structure + * + * A wrapper to release access rights to the correct PHY. This is a + * function pointer entry point called by the api module. + **/ +STATIC void +e1000_release_phy_80003es2lan(struct e1000_hw *hw) +{ + u16 mask; + + DEBUGFUNC("e1000_release_phy_80003es2lan"); + + mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; + e1000_release_swfw_sync_80003es2lan(hw, mask); +} + +/** + * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM + * @hw: pointer to the HW structure + * + * Acquire the semaphore to access the EEPROM. This is a function + * pointer entry point called by the api module. + **/ +STATIC s32 +e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw) +{ + s32 ret_val; + + DEBUGFUNC("e1000_acquire_nvm_80003es2lan"); + + ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); + if (ret_val) + goto out; + + ret_val = e1000_acquire_nvm_generic(hw); + + if (ret_val) + e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); + +out: + return ret_val; +} + +/** + * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM + * @hw: pointer to the HW structure + * + * Release the semaphore used to access the EEPROM. This is a + * function pointer entry point called by the api module. + **/ +STATIC void +e1000_release_nvm_80003es2lan(struct e1000_hw *hw) +{ + DEBUGFUNC("e1000_release_nvm_80003es2lan"); + + e1000_release_nvm_generic(hw); + e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM); +} + +/** + * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore + * @hw: pointer to the HW structure + * @mask: specifies which semaphore to acquire + * + * Acquire the SW/FW semaphore to access the PHY or NVM. The mask + * will also specify which port we're acquiring the lock for. + **/ +static s32 +e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) +{ + u32 swfw_sync; + u32 swmask = mask; + u32 fwmask = mask << 16; + s32 ret_val = E1000_SUCCESS; + s32 i = 0, timeout = 200; + + DEBUGFUNC("e1000_acquire_swfw_sync_80003es2lan"); + + while (i < timeout) { + if (e1000_get_hw_semaphore_generic(hw)) { + ret_val = -E1000_ERR_SWFW_SYNC; + goto out; + } + + swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); + if (!(swfw_sync & (fwmask | swmask))) + break; + + /* Firmware currently using resource (fwmask) + * or other software thread using resource (swmask) */ + e1000_put_hw_semaphore_generic(hw); + msec_delay_irq(5); + i++; + } + + if (i == timeout) { + DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n"); + ret_val = -E1000_ERR_SWFW_SYNC; + goto out; + } + + swfw_sync |= swmask; + E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync); + + e1000_put_hw_semaphore_generic(hw); + +out: + return ret_val; +} + +/** + * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore + * @hw: pointer to the HW structure + * @mask: specifies which semaphore to acquire + * + * Release the SW/FW semaphore used to access the PHY or NVM. The mask + * will also specify which port we're releasing the lock for. + **/ +static void +e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask) +{ + u32 swfw_sync; + + DEBUGFUNC("e1000_release_swfw_sync_80003es2lan"); + + while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS); + /* Empty */ + + swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); + swfw_sync &= ~mask; + E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync); + + e1000_put_hw_semaphore_generic(hw); +} + +/** + * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register + * @hw: pointer to the HW structure + * @offset: offset of the register to read + * @data: pointer to the data returned from the operation + * + * Read the GG82563 PHY register. This is a function pointer entry + * point called by the api module. + **/ +STATIC s32 +e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, u32 offset, + u16 *data) +{ + s32 ret_val; + u32 page_select; + u16 temp; + + DEBUGFUNC("e1000_read_phy_reg_gg82563_80003es2lan"); + + /* Select Configuration Page */ + if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) + page_select = GG82563_PHY_PAGE_SELECT; + else { + /* Use Alternative Page Select register to access + * registers 30 and 31 + */ + page_select = GG82563_PHY_PAGE_SELECT_ALT; + } + + temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT); + ret_val = e1000_write_phy_reg_m88(hw, page_select, temp); + if (ret_val) + goto out; + + /* The "ready" bit in the MDIC register may be incorrectly set + * before the device has completed the "Page Select" MDI + * transaction. So we wait 200us after each MDI command... + */ + usec_delay(200); + + /* ...and verify the command was successful. */ + ret_val = e1000_read_phy_reg_m88(hw, page_select, &temp); + + if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) { + ret_val = -E1000_ERR_PHY; + goto out; + } + + usec_delay(200); + + ret_val = e1000_read_phy_reg_m88(hw, + MAX_PHY_REG_ADDRESS & offset, + data); + + usec_delay(200); + +out: + return ret_val; +} + +/** + * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register + * @hw: pointer to the HW structure + * @offset: offset of the register to read + * @data: value to write to the register + * + * Write to the GG82563 PHY register. This is a function pointer entry + * point called by the api module. + **/ +STATIC s32 +e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, u32 offset, + u16 data) +{ + s32 ret_val; + u32 page_select; + u16 temp; + + DEBUGFUNC("e1000_write_phy_reg_gg82563_80003es2lan"); + + /* Select Configuration Page */ + if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) + page_select = GG82563_PHY_PAGE_SELECT; + else { + /* Use Alternative Page Select register to access [... truncated: 50312 lines follow ...] From axeld at mail.berlios.de Sat Dec 1 16:42:28 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 16:42:28 +0100 Subject: [Haiku-commits] r23042 - haiku/vendor/freebsd Message-ID: <200712011542.lB1FgScp004722@sheep.berlios.de> Author: axeld Date: 2007-12-01 16:42:28 +0100 (Sat, 01 Dec 2007) New Revision: 23042 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23042&view=rev Added: haiku/vendor/freebsd/RELENG_7_BP/ Log: Added tag for the RELENG_7_BP tag of this FreeBSD version. Copied: haiku/vendor/freebsd/RELENG_7_BP (from rev 23041, haiku/vendor/freebsd/current) From axeld at mail.berlios.de Sat Dec 1 18:35:00 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 18:35:00 +0100 Subject: [Haiku-commits] r23043 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/dev/pci compat/sys Message-ID: <200712011735.lB1HZ0cY025996@sheep.berlios.de> Author: axeld Date: 2007-12-01 18:34:59 +0100 (Sat, 01 Dec 2007) New Revision: 23043 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23043&view=rev Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/callout.h haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h Log: Some more extensions to the FreeBSD compatibility layer. Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-12-01 15:42:28 UTC (rev 23042) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-12-01 17:34:59 UTC (rev 23043) @@ -515,6 +515,50 @@ } +uint32_t +pci_get_domain(device_t dev) +{ + return 0; +} + + +uint8_t +pci_get_bus(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->bus; +} + + +uint8_t +pci_get_slot(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->device; +} + + +uint8_t +pci_get_function(device_t dev) +{ + pci_info *info + = &((struct root_device_softc *)dev->root->softc)->pci_info; + return info->function; +} + + +device_t +pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, uint8_t func) +{ + // We don't support that yet - if we want to support the multi port + // feature of the Broadcom BCM 570x driver, we would have to change + // that. + return NULL; +} + + static void pci_set_command_bit(device_t dev, uint16_t bit) { Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h 2007-12-01 15:42:28 UTC (rev 23042) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/dev/pci/pcivar.h 2007-12-01 17:34:59 UTC (rev 23043) @@ -9,6 +9,10 @@ #include +#define PCI_RF_DENSE 0x10000 + // ignored on x86 + + int pci_enable_busmaster(device_t dev); int pci_enable_io(device_t dev, int reg); @@ -25,6 +29,13 @@ uint32_t pci_read_config(device_t dev, int reg, int width); void pci_write_config(device_t dev, int reg, uint32_t val, int width); +uint32_t pci_get_domain(device_t dev); +uint8_t pci_get_bus(device_t dev); +uint8_t pci_get_slot(device_t dev); +uint8_t pci_get_function(device_t dev); +device_t pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot, + uint8_t func); + int pci_find_extcap(device_t dev, int capability, int *capreg); int pci_msi_count(device_t dev); @@ -33,4 +44,10 @@ int pci_msix_count(device_t dev); int pci_alloc_msix(device_t dev, int *count); +static inline int +pci_get_vpd_ident(device_t dev, const char **identptr) +{ + return -1; +} + #endif /* _FBSD_COMPAT_DEV_PCI_PCIVAR_H_ */ Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/callout.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/callout.h 2007-12-01 15:42:28 UTC (rev 23042) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/callout.h 2007-12-01 17:34:59 UTC (rev 23043) @@ -1,3 +1,7 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_CALLOUT_H_ #define _FBSD_COMPAT_SYS_CALLOUT_H_ @@ -16,14 +20,18 @@ }; -void callout_init_mtx(struct callout *, struct mtx *, int); +void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags); int callout_reset(struct callout *, int, void (*)(void *), void *); #define callout_drain(c) _callout_stop_safe(c, 1) #define callout_stop(c) _callout_stop_safe(c, 0) int _callout_stop_safe(struct callout *, int); +#define callout_pending(c) ((c)->c_timer.due > 0) +#define callout_active(c) ((c)->c_timer.due == -1) + // TODO: there is currently no way to find out about this! + static inline void callout_init(struct callout *c, int mpsafe) { @@ -33,4 +41,4 @@ callout_init_mtx(c, &Giant, 0); } -#endif +#endif /* _FBSD_COMPAT_SYS_CALLOUT_H_ */ Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2007-12-01 15:42:28 UTC (rev 23042) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/param.h 2007-12-01 17:34:59 UTC (rev 23043) @@ -1,8 +1,18 @@ +/* + * Copyright 2007, Hugo Santos. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _FBSD_COMPAT_SYS_PARAM_H_ #define _FBSD_COMPAT_SYS_PARAM_H_ + #include + +/* The version this compatibility layer is based on */ +#define __FreeBSD_version 700053 + + #define MAXBSIZE 0x10000 #define PAGE_SHIFT 12 @@ -28,11 +38,15 @@ #define MCLSHIFT 11 #endif -#define MCLBYTES (1 << MCLSHIFT) +#define MCLBYTES (1 << MCLSHIFT) +#define MJUMPAGESIZE PAGE_SIZE +#define MJUM9BYTES (9 * 1024) +#define MJUM16BYTES (16 * 1024) + #define ALIGN_BYTES (sizeof(int) - 1) #define ALIGN(x) ((((unsigned)x) + ALIGN_BYTES) & ~ALIGN_BYTES) #define roundup2(x, y) (((x) + ((y) - 1)) & (~((y) - 1))) -#endif +#endif /* _FBSD_COMPAT_SYS_PARAM_H_ */ From bonefish at mail.berlios.de Sat Dec 1 20:27:30 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Dec 2007 20:27:30 +0100 Subject: [Haiku-commits] r23044 - haiku/trunk/src/tests/system/kernel Message-ID: <200712011927.lB1JRUBQ007571@sheep.berlios.de> Author: bonefish Date: 2007-12-01 20:27:30 +0100 (Sat, 01 Dec 2007) New Revision: 23044 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23044&view=rev Modified: haiku/trunk/src/tests/system/kernel/syscall_time.cpp Log: Use is_computer_on() as test syscall. Modified: haiku/trunk/src/tests/system/kernel/syscall_time.cpp =================================================================== --- haiku/trunk/src/tests/system/kernel/syscall_time.cpp 2007-12-01 17:34:59 UTC (rev 23043) +++ haiku/trunk/src/tests/system/kernel/syscall_time.cpp 2007-12-01 19:27:30 UTC (rev 23044) @@ -9,8 +9,6 @@ #ifdef __HAIKU__ # include -#else -extern "C" void _kclose_(int fd); #endif @@ -22,10 +20,9 @@ for (int32 i = 0; i < loops; i++) { #ifdef __HAIKU__ -// _kern_null(); - _kern_close(-1); + _kern_is_computer_on(); #else - _kclose_(-1); + is_computer_on(); #endif } From bonefish at mail.berlios.de Sat Dec 1 20:34:25 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Dec 2007 20:34:25 +0100 Subject: [Haiku-commits] r23045 - haiku/branches/developer/bonefish Message-ID: <200712011934.lB1JYPoC008065@sheep.berlios.de> Author: bonefish Date: 2007-12-01 20:34:25 +0100 (Sat, 01 Dec 2007) New Revision: 23045 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23045&view=rev Added: haiku/branches/developer/bonefish/optimization/ Log: Created branch from r23004 for working on some optimizations. Copied: haiku/branches/developer/bonefish/optimization (from rev 23004, haiku/trunk) From axeld at mail.berlios.de Sat Dec 1 20:51:56 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 1 Dec 2007 20:51:56 +0100 Subject: [Haiku-commits] r23046 - haiku/trunk/src/kits/interface Message-ID: <200712011951.lB1JpuWO008939@sheep.berlios.de> Author: axeld Date: 2007-12-01 20:51:56 +0100 (Sat, 01 Dec 2007) New Revision: 23046 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23046&view=rev Modified: haiku/trunk/src/kits/interface/ListItem.cpp Log: Applied a slightly changed patch by cl21: changed how the BListItem layouts its text contents. This fixes bug #619. Thanks! Modified: haiku/trunk/src/kits/interface/ListItem.cpp =================================================================== --- haiku/trunk/src/kits/interface/ListItem.cpp 2007-12-01 19:34:25 UTC (rev 23045) +++ haiku/trunk/src/kits/interface/ListItem.cpp 2007-12-01 19:51:56 UTC (rev 23046) @@ -345,10 +345,11 @@ font_height fheight; font->GetHeight(&fheight); - - fBaselineOffset = fheight.ascent + fheight.leading; - SetHeight((float)ceil(fheight.ascent + fheight.descent + - fheight.leading) + 4); + + fBaselineOffset = fheight.ascent + 2 + floorf(fheight.leading / 2); + + SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent) + + ceilf(fheight.leading) + 4); } From bonefish at mail.berlios.de Sat Dec 1 21:16:56 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Dec 2007 21:16:56 +0100 Subject: [Haiku-commits] r23047 - haiku/branches/developer/bonefish Message-ID: <200712012016.lB1KGuTQ010407@sheep.berlios.de> Author: bonefish Date: 2007-12-01 21:16:55 +0100 (Sat, 01 Dec 2007) New Revision: 23047 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23047&view=rev Removed: haiku/branches/developer/bonefish/optimization/ Log: Copied from revision. From bonefish at mail.berlios.de Sat Dec 1 21:17:15 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 1 Dec 2007 21:17:15 +0100 Subject: [Haiku-commits] r23048 - haiku/branches/developer/bonefish Message-ID: <200712012017.lB1KHFc5010516@sheep.berlios.de> Author: bonefish Date: 2007-12-01 21:17:15 +0100 (Sat, 01 Dec 2007) New Revision: 23048 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23048&view=rev Added: haiku/branches/developer/bonefish/optimization/ Log: Created branch from r23046 for working on some optimizations. Copied: haiku/branches/developer/bonefish/optimization (from rev 23046, haiku/trunk) From superstippi at gmx.de Sat Dec 1 21:18:52 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Sat, 01 Dec 2007 21:18:52 +0100 Subject: [Haiku-commits] r23046 - haiku/trunk/src/kits/interface In-Reply-To: <200712011951.lB1JpuWO008939@sheep.berlios.de> References: <200712011951.lB1JpuWO008939@sheep.berlios.de> Message-ID: <20071201211852.1746.4@stippis2.1196529758.fake> Hi, axeld at BerliOS wrote (2007-12-01, 20:51:56 [+0100]): > - > - fBaselineOffset = fheight.ascent + fheight.leading; > - SetHeight((float)ceil(fheight.ascent + fheight.descent + > - fheight.leading) + 4); > + > + fBaselineOffset = fheight.ascent + 2 + floorf(fheight.leading / 2); > + > + SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent) > + + ceilf(fheight.leading) + 4); > } I am thinking we should try to make controls truely scale with the font size where we come across it. In the above case, the 2 pixel extra spacing at top and bottom are hardcoded, but it probably looks better if the spacing is depending on the font size as well. How about float totalFontHeight = ceilf(fheight.ascent) + ceilf(fheight.descent); float itemHeight = floorf(totalFontHeight * 1.4 + 0.5); SetHeight(itemHeight); fBaselineOffset = (itemHeight - totalFontHeight) / 2 + ceilf(fheight.ascent); Best regards, -Stephan From axeld at pinc-software.de Sun Dec 2 11:37:18 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 02 Dec 2007 11:37:18 +0100 CET Subject: [Haiku-commits] r23046 - haiku/trunk/src/kits/interface In-Reply-To: <20071201211852.1746.4@stippis2.1196529758.fake> Message-ID: <2735752175-BeMail@zon> Stephan Assmus wrote: > axeld at BerliOS wrote (2007-12-01, 20:51:56 [+0100]): > > - fBaselineOffset = fheight.ascent + fheight.leading; > > - SetHeight((float)ceil(fheight.ascent + fheight.descent + > > - fheight.leading) + 4); > > + > > + fBaselineOffset = fheight.ascent + 2 + floorf(fheight.leading > > / 2); > > + > > + SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent) > > + + ceilf(fheight.leading) + 4); > I am thinking we should try to make controls truely scale with the > font > size where we come across it. In the above case, the 2 pixel extra > spacing > at top and bottom are hardcoded, but it probably looks better if the > spacing is depending on the font size as well. How about > > float totalFontHeight = ceilf(fheight.ascent) + > ceilf(fheight.descent); > float itemHeight = floorf(totalFontHeight * 1.4 + 0.5); > SetHeight(itemHeight); > > fBaselineOffset = (itemHeight - totalFontHeight) / 2 > + ceilf(fheight.ascent); Yeah, you're right, even though the "leading" should automatically make up for some of that. But if you tested your version, and it looks good, please go on and commit it :-) Bye, Axel. From axeld at pinc-software.de Sun Dec 2 11:41:26 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 02 Dec 2007 11:41:26 +0100 CET Subject: [Haiku-commits] r23022 - haiku/trunk/src/bin In-Reply-To: <1731917308-BeMail@laptop> Message-ID: <2983185062-BeMail@zon> "Fran?ois Revol" wrote: > > > That was for binary compatibility with the few R5 apps using it. > > > The code can probably be added to Appearance's ArgsReceived and > > > symlinked. > > There is no WindowShade app on any of my BeOS installations, so > > there > > is no reason for any backwards compatibility either. > On mine neither (but it didn't work on Dano), but there are a few > apps > on bebits using it. > I know it's a toy but it's a bit funky like sliding tabs... [...] I don't quite see the connection. Sliding tabs might be funky, but they actually are useful when working with many overlapping windows. Theming is a toy that IMO just hurts consistency and the visual identity. > Btw, > to support changing colors of decors it will need to access the > DesktopSettings obj when drawing, in UIColor()... but the one passed > on > ctor doesn't live long enough (on stack). As I didn't dig much > app_server I'm wondering if I can switch it to cache the Desktop > object > instead, if it lives long enough, to instanciate a DesktopSettings > when > needed. No, that's not really needed - an update mechanism would be all we need, and that would be needed anyway. > It will also need some more colors, maybe we could allocate some > color > ids specifically for Decors ? B_WINDOW_DECOR_EXTRA_1_COLOR, ... > that'd > be color specific but would allow them to be saved in settings and > changeable. No, please not. Bye, Axel. From axeld at mail.berlios.de Sun Dec 2 15:30:54 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 2 Dec 2007 15:30:54 +0100 Subject: [Haiku-commits] r23049 - haiku/trunk/build/jam Message-ID: <200712021430.lB2EUsNi031657@sheep.berlios.de> Author: axeld Date: 2007-12-02 15:30:52 +0100 (Sun, 02 Dec 2007) New Revision: 23049 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23049&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Added "mail" directory - this fixes Beam not starting up on a plain Haiku installation. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-12-01 20:17:15 UTC (rev 23048) +++ haiku/trunk/build/jam/HaikuImage 2007-12-02 14:30:52 UTC (rev 23049) @@ -6,6 +6,7 @@ AddDirectoryToHaikuImage home Desktop ; AddDirectoryToHaikuImage home config bin ; AddDirectoryToHaikuImage home config lib ; +AddDirectoryToHaikuImage home mail ; AddDirectoryToHaikuImage var log ; AddDirectoryToHaikuImage var tmp ; From axeld at mail.berlios.de Sun Dec 2 17:38:39 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 2 Dec 2007 17:38:39 +0100 Subject: [Haiku-commits] r23050 - in haiku/trunk/src: add-ons/kernel/file_systems/bfs system/kernel/cache Message-ID: <200712021638.lB2Gcd2b004970@sheep.berlios.de> Author: axeld Date: 2007-12-02 17:38:38 +0100 (Sun, 02 Dec 2007) New Revision: 23050 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23050&view=rev Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/system/kernel/cache/block_cache.cpp Log: * bfs_free_cookie() accidently reverted a transaction after having updated the inode's internal last modified and size copies, causing in inconsistent data. This fixes #1643. * The block being replayed are now dumped to the debug output. Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2007-12-02 14:30:52 UTC (rev 23049) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Journal.cpp 2007-12-02 16:38:38 UTC (rev 23050) @@ -380,7 +380,7 @@ CachedBlock cached(fVolume); for (int32 index = 0; index < array->CountRuns(); index++) { const block_run &run = array->RunAt(index); - PRINT(("replay block run %lu:%u:%u in log at %Ld!\n", + INFORM(("replay block run %lu:%u:%u in log at %Ld!\n", run.AllocationGroup(), run.Start(), run.Length(), blockNumber)); off_t offset = fVolume->ToOffset(run); 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-12-02 14:30:52 UTC (rev 23049) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-12-02 16:38:38 UTC (rev 23050) @@ -1277,9 +1277,9 @@ } WriteLocked locker(inode->Lock()); - status_t status = B_ERROR; + status_t status = transaction.IsStarted() ? B_OK : B_ERROR; - if (transaction.IsStarted()) { + if (status == B_OK) { // trim the preallocated blocks and update the size, // and last_modified indices if needed bool changedSize = false, changedTime = false; Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp =================================================================== --- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2007-12-02 14:30:52 UTC (rev 23049) +++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2007-12-02 16:38:38 UTC (rev 23050) @@ -40,6 +40,7 @@ #endif #define DEBUG_BLOCK_CACHE +//#define DEBUG_CHANGED // This macro is used for fatal situations that are acceptable in a running // system, like out of memory situations - should only panic for debugging. From bonefish at mail.berlios.de Mon Dec 3 14:25:45 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Mon, 3 Dec 2007 14:25:45 +0100 Subject: [Haiku-commits] r23051 - haiku/trunk/src/tests/system/kernel Message-ID: <200712031325.lB3DPjfu004642@sheep.berlios.de> Author: bonefish Date: 2007-12-03 14:25:44 +0100 (Mon, 03 Dec 2007) New Revision: 23051 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23051&view=rev Modified: haiku/trunk/src/tests/system/kernel/Jamfile Log: Make the syscall_time test compile under BeOS, too. Modified: haiku/trunk/src/tests/system/kernel/Jamfile =================================================================== --- haiku/trunk/src/tests/system/kernel/Jamfile 2007-12-02 16:38:38 UTC (rev 23050) +++ haiku/trunk/src/tests/system/kernel/Jamfile 2007-12-03 13:25:44 UTC (rev 23051) @@ -32,6 +32,8 @@ SimpleTest select_check : select_check.cpp ; SimpleTest select_close_test : select_close_test.cpp ; +SetSupportedPlatformsForTarget syscall_time + : $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ; SimpleTest syscall_time : syscall_time.cpp ; SimpleTest transfer_area_test : transfer_area_test.cpp ; From bonefish at mail.berlios.de Tue Dec 4 02:06:34 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 02:06:34 +0100 Subject: [Haiku-commits] r23052 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200712040106.lB416Y9l002795@sheep.berlios.de> Author: bonefish Date: 2007-12-04 02:06:33 +0100 (Tue, 04 Dec 2007) New Revision: 23052 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23052&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c Log: Added assembler-friendly push/pop iframe functions. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-03 13:25:44 UTC (rev 23051) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-04 01:06:33 UTC (rev 23052) @@ -17,7 +17,9 @@ #endif void x86_push_iframe(struct iframe_stack *stack, struct iframe *frame); +void x86_push_iframe_current_thread(struct iframe *frame); void x86_pop_iframe(struct iframe_stack *stack); +void x86_pop_iframe_current_thread(void); struct iframe *i386_get_user_iframe(void); void *x86_next_page_directory(struct thread *from, struct thread *to); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-03 13:25:44 UTC (rev 23051) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-04 01:06:33 UTC (rev 23052) @@ -71,6 +71,16 @@ void +x86_push_iframe_current_thread(struct iframe *frame) +{ + struct thread *thread = thread_get_current_thread(); + struct iframe_stack *stack = &thread->arch_info.iframes; + ASSERT(stack->index < IFRAME_TRACE_DEPTH); + stack->frames[stack->index++] = frame; +} + + +void x86_pop_iframe(struct iframe_stack *stack) { ASSERT(stack->index > 0); @@ -78,6 +88,16 @@ } +void +x86_pop_iframe_current_thread(void) +{ + struct thread *thread = thread_get_current_thread(); + struct iframe_stack *stack = &thread->arch_info.iframes; + ASSERT(stack->index > 0); + stack->index--; +} + + /*! Returns the current iframe structure of the running thread. This function must only be called in a context where it's actually From bonefish at mail.berlios.de Tue Dec 4 02:19:07 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 02:19:07 +0100 Subject: [Haiku-commits] r23053 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712040119.lB41J7na004297@sheep.berlios.de> Author: bonefish Date: 2007-12-04 02:19:05 +0100 (Tue, 04 Dec 2007) New Revision: 23053 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23053&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/interrupts.h Log: * Implemented a designated handler for our syscall interrupt (99) in assembler. This saves several if's, the big switch of the generic handler. Furthermore we directly call the respective syscall function (the jump table's already there) instead of entering the syscall dispatcher. Syscall tracing is broken ATM, though, and there are a few open TODO's. * Added an empty handler for interrupt 98 for performance comparisons. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 01:06:33 UTC (rev 23052) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 01:19:05 UTC (rev 23053) @@ -649,6 +649,7 @@ set_intr_gate(46, &trap46); set_intr_gate(47, &trap47); +set_system_gate(98, &trap98); // for performance testing only set_system_gate(99, &trap99); set_intr_gate(251, &trap251); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-04 01:06:33 UTC (rev 23052) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-04 01:19:05 UTC (rev 23053) @@ -86,8 +86,6 @@ TRAP(trap46, 46) TRAP(trap47, 47) -TRAP(trap99, 99) - TRAP(trap251, 251) TRAP(trap252, 252) TRAP(trap253, 253) @@ -145,6 +143,104 @@ addl $16,%esp // ignore the vector, error code, and original eax/edx values iret + +// test interrupt handler for performance measurements +.align 16 +.globl trap98 +trap98: + iret + + +.align 16 +.globl trap99 +trap99: + // push error, vector, old_edx, old_eax, and other registers + pushl $0 + pushl $99 + pushl %edx + pushl %eax + pusha + push %ds + push %es + push %fs + push %gs + + // save %eax, the number of the syscall + movl %eax, %ecx + + movl $KERNEL_DATA_SEG,%eax + cld + movl %eax,%ds + movl %eax,%es + + // Set %ebp (the frame pointer) to iframe - 8, so that the "sc" command + // recognizes the iframe. +// TODO: Fix this. We should set %ebp to the iframe and do the same in int_bottom. + lea -8(%esp), %ebp + + // push iframe + cli // disable interrupts + movl %esp, %eax + push %eax + call x86_push_iframe_current_thread + addl $4, %esp + + call thread_at_kernel_entry + + sti // enable interrupts + +// TODO: Make kSyscallCount a macro! + cmp kSyscallCount, %ecx // check syscall number + jae bad_syscall_number + movl $kSyscallInfos, %eax // get syscall info + lea (%eax, %ecx, 8), %esi + + // copy parameters onto this stack + movl %esp, %eax + subl $80, %esp // leave some room for the syscall params + movl 4(%esi), %ebx // get and push the syscall parameter size + push %ebx + movl 76(%eax), %eax + addl $4, %eax // address of the syscall parameters +// TODO: check !IS_KERNEL_ADDRESS(%eax) + push %eax + lea 8(%esp), %ebx // stack address where to copy the params + push %ebx + call user_memcpy + addl $12, %esp + test %eax, %eax + jne bad_syscall_params + + // call the syscall function + call *(%esi) + + bad_syscall_params: + addl $80, %esp // remove syscall params from stack + + bad_syscall_number: + // overwrite the values of %eax and %edx on the stack (the syscall return + // value) + movl %esp, %edi + movl %edx, 36(%edi) + movl %eax, 44(%edi) + + call thread_at_kernel_exit + + // pop iframe + cli // disable interrupts + call x86_pop_iframe_current_thread + sti // enable interrupts + + pop %gs + addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment + pop %es + pop %ds + + popa + addl $16,%esp // ignore the vector, error code, and original eax/edx values + iret + + _interrupt_stack_offset: .long 0 // this value will be maintained by the function below Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/interrupts.h =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/interrupts.h 2007-12-04 01:06:33 UTC (rev 23052) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/interrupts.h 2007-12-04 01:19:05 UTC (rev 23053) @@ -23,6 +23,7 @@ void double_fault(); // int 8 +void trap98(); void trap99(); void trap251();void trap252();void trap253();void trap254();void trap255(); From bonefish at mail.berlios.de Tue Dec 4 02:42:37 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 02:42:37 +0100 Subject: [Haiku-commits] r23054 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200712040142.lB41gb7i005932@sheep.berlios.de> Author: bonefish Date: 2007-12-04 02:42:35 +0100 (Tue, 04 Dec 2007) New Revision: 23054 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23054&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp Log: * Finally got rid of the i386_reinit_user_debug_after_context_switch() workaround by disabling interrupts before calling i386_init_user_debug_at_kernel_exit() and keeping them disabled until the interrupt return. * Both i386_exit_user_debug_at_kernel_entry() and i386_init_user_debug_at_kernel_exit() are now called with interrupts disabled. * Got rid of the X86_THREAD_DEBUG_DR7_SET flag. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h 2007-12-04 01:19:05 UTC (rev 23053) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h 2007-12-04 01:42:35 UTC (rev 23054) @@ -94,11 +94,6 @@ X86_BREAKPOINT_LENGTH_4 = 0x3, }; -// thread debug flags -enum { - X86_THREAD_DEBUG_DR7_SET = 0x01, -}; - struct arch_breakpoint { void *address; // NULL, if deactivated uint32 type; // one of the architecture types above @@ -124,7 +119,6 @@ extern void i386_init_user_debug_at_kernel_exit(struct iframe *frame); extern void i386_exit_user_debug_at_kernel_entry(); -extern void i386_reinit_user_debug_after_context_switch(struct thread *thread); extern int i386_handle_debug_exception(struct iframe *frame); extern int i386_handle_breakpoint_exception(struct iframe *frame); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 01:19:05 UTC (rev 23053) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 01:42:35 UTC (rev 23054) @@ -588,13 +588,16 @@ // interrupts are not enabled at this point if we came from // a hardware interrupt thread_at_kernel_exit(); + disable_interrupts(); + // keep interrupts disabled till returning from the interrupt + // -- required to avoid a race condition after setting the debug + // registers i386_init_user_debug_at_kernel_exit(&frame); - } + } else + disable_interrupts(); // dprintf("0x%x cpu %d!\n", thread_get_current_thread_id(), smp_get_current_cpu()); - disable_interrupts(); - if (thread) x86_pop_iframe(&thread->arch_info.iframes); else Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-04 01:19:05 UTC (rev 23053) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-04 01:42:35 UTC (rev 23054) @@ -340,11 +340,6 @@ if ((newPageDirectory % B_PAGE_SIZE) != 0) panic("arch_thread_context_switch: bad pgdir 0x%lx\n", newPageDirectory); - // reinit debugging; necessary, if the thread was preempted after - // initializing debugging before returning to userland - if (to->team->address_space != NULL) - i386_reinit_user_debug_after_context_switch(to); - gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state); i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-04 01:19:05 UTC (rev 23053) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-04 01:42:35 UTC (rev 23054) @@ -683,14 +683,13 @@ /** - * Interrupts are enabled. + * Interrupts are disabled. */ void i386_init_user_debug_at_kernel_exit(struct iframe *frame) { struct thread *thread = thread_get_current_thread(); - cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -698,7 +697,6 @@ // install the breakpoints install_breakpoints(teamInfo); - thread->debug_info.arch_info.flags |= X86_THREAD_DEBUG_DR7_SET; // set/clear TF in EFLAGS depending on if single stepping is desired if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) @@ -711,24 +709,21 @@ RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); RELEASE_THREAD_LOCK(); - restore_interrupts(state); } /** - * Interrupts may be enabled. + * Interrupts are disabled. */ void i386_exit_user_debug_at_kernel_entry() { struct thread *thread = thread_get_current_thread(); - cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); // disable breakpoints disable_breakpoints(); - thread->debug_info.arch_info.flags &= ~X86_THREAD_DEBUG_DR7_SET; #if KERNEL_BREAKPOINTS struct team* kernelTeam = team_get_kernel_team(); @@ -738,44 +733,10 @@ #endif RELEASE_THREAD_LOCK(); - restore_interrupts(state); } /** - * Interrupts are disabled and the thread lock is being held. - */ -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 - } -} - - -/** * Interrupts are disabled and will be enabled by the function. */ int From bonefish at mail.berlios.de Tue Dec 4 03:58:55 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 03:58:55 +0100 Subject: [Haiku-commits] r23055 - haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86 Message-ID: <200712040258.lB42wtQf008592@sheep.berlios.de> Author: bonefish Date: 2007-12-04 03:58:54 +0100 (Tue, 04 Dec 2007) New Revision: 23055 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23055&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_kernel.h Log: Made assembler safe. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_kernel.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_kernel.h 2007-12-04 01:42:35 UTC (rev 23054) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_kernel.h 2007-12-04 02:58:54 UTC (rev 23055) @@ -5,7 +5,9 @@ #ifndef _KERNEL_ARCH_x86_KERNEL_H #define _KERNEL_ARCH_x86_KERNEL_H -#include +#ifndef _ASSEMBLER +# include +#endif // memory layout #define KERNEL_BASE 0x80000000 From bonefish at mail.berlios.de Tue Dec 4 03:59:44 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 03:59:44 +0100 Subject: [Haiku-commits] r23056 - haiku/branches/developer/bonefish/optimization/src/tools/gensyscalls Message-ID: <200712040259.lB42xi49008643@sheep.berlios.de> Author: bonefish Date: 2007-12-04 03:59:44 +0100 (Tue, 04 Dec 2007) New Revision: 23056 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23056&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/tools/gensyscalls/gensyscalls.cpp Log: Made the generated syscall_table.h assembler safe and added a SYSCALL_COUNT macro. Modified: haiku/branches/developer/bonefish/optimization/src/tools/gensyscalls/gensyscalls.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/tools/gensyscalls/gensyscalls.cpp 2007-12-04 02:58:54 UTC (rev 23055) +++ haiku/branches/developer/bonefish/optimization/src/tools/gensyscalls/gensyscalls.cpp 2007-12-04 02:59:44 UTC (rev 23056) @@ -371,8 +371,16 @@ if (!file.is_open()) throw IOException(string("Failed to open `") + filename + "'."); + // output syscall count macro + file << "#define SYSCALL_COUNT " << fSyscallCount << endl; + file << endl; + + // assembler guard + file << "#ifndef _ASSEMBLER" << endl; + file << endl; + // output syscall count - file << "const int kSyscallCount = " << fSyscallCount << ";" << endl; + file << "const int kSyscallCount = SYSCALL_COUNT;" << endl; file << endl; // syscall infos array preamble @@ -394,6 +402,9 @@ // syscall infos array end file << "};" << endl; + + // assembler guard end + file << "#endif // _ASSEMBLER" << endl; } void _WriteSTraceFile(const char *filename) From bonefish at mail.berlios.de Tue Dec 4 04:14:08 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 4 Dec 2007 04:14:08 +0100 Subject: [Haiku-commits] r23057 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel src/system/kernel src/system/kernel/arch/x86 Message-ID: <200712040314.lB43E85d009348@sheep.berlios.de> Author: bonefish Date: 2007-12-04 04:14:07 +0100 (Tue, 04 Dec 2007) New Revision: 23057 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23057&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp Log: * thread_at_kernel_entry() gets a bigtime_t argument, the current time. Moreover it is guaranteed to be called with interrupts disabled. * All interrupt handlers set ebp to the iframe, now. This makes things a little easier in the syscall handler. * In the syscall handler: - Use the new SYSCALL_COUNT macro instead of kSyscallCount. - Make sure that the syscall parameter address is not a kernel address. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-04 03:14:07 UTC (rev 23057) @@ -26,7 +26,7 @@ struct thread *thread_dequeue(struct thread_queue *q); struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id); -void thread_at_kernel_entry(void); +void thread_at_kernel_entry(bigtime_t now); // called when the thread enters the kernel on behalf of the thread void thread_at_kernel_exit(void); void thread_reset_for_exec(void); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-04 03:14:07 UTC (rev 23057) @@ -42,3 +42,5 @@ # We need to specify the dependency on the generated syscalls file explicitly. Includes [ FGristFiles arch_x86.S arch_interrupts.S ] : syscall_numbers.h ; +Includes [ FGristFiles arch_interrupts.S ] + : syscall_table.h ; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp 2007-12-04 03:14:07 UTC (rev 23057) @@ -209,14 +209,14 @@ bool isIFrame = false; // see if the ebp matches the iframe for (i = 0; i < frameStack->index; i++) { - if (ebp == ((uint32)frameStack->frames[i] - 8)) { + if (ebp == ((addr_t)frameStack->frames[i])) { // it's an iframe isIFrame = true; } } if (isIFrame) { - struct iframe *frame = (struct iframe *)(ebp + 8); + struct iframe *frame = (struct iframe *)ebp; print_iframe(frame); print_stack_frame(thread, frame->eip, ebp, frame->ebp); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-04 03:14:07 UTC (rev 23057) @@ -369,7 +369,7 @@ if (frame.cs == USER_CODE_SEG) { i386_exit_user_debug_at_kernel_entry(); - thread_at_kernel_entry(); + thread_at_kernel_entry(system_time()); } restore_interrupts(state); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-04 03:14:07 UTC (rev 23057) @@ -8,8 +8,10 @@ */ #include +#include #include "syscall_numbers.h" +#include "syscall_table.h" #define FUNCTION(x) .global x; .type x, at function; x @@ -109,6 +111,7 @@ cmpl %eax,%ebx // check if we changed the stack jne custom_stack kernel_stack: + movl %esp, %ebp // frame pointer is the iframe call i386_handle_trap pop %gs addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment @@ -133,6 +136,7 @@ subl $84,%esi movl %esi,(%edi) // save custom stack address and segment *after* the movl %ebx,4(%edi) // iframe structure on the stack + movl %esp, %ebp // frame pointer is the iframe call i386_handle_trap lss 84(%esp),%esp // reload custom stack address pop %gs @@ -173,36 +177,38 @@ movl %eax,%ds movl %eax,%es - // Set %ebp (the frame pointer) to iframe - 8, so that the "sc" command - // recognizes the iframe. -// TODO: Fix this. We should set %ebp to the iframe and do the same in int_bottom. - lea -8(%esp), %ebp + movl %esp, %ebp // frame pointer is the iframe // push iframe cli // disable interrupts - movl %esp, %eax - push %eax + push %ebp call x86_push_iframe_current_thread addl $4, %esp + call system_time + push %edx + push %eax call thread_at_kernel_entry + add $8, %esp sti // enable interrupts -// TODO: Make kSyscallCount a macro! - cmp kSyscallCount, %ecx // check syscall number + cmp $SYSCALL_COUNT, %ecx // check syscall number jae bad_syscall_number movl $kSyscallInfos, %eax // get syscall info lea (%eax, %ecx, 8), %esi - + // copy parameters onto this stack - movl %esp, %eax subl $80, %esp // leave some room for the syscall params + + movl 76(%ebp), %eax // get the address of the syscall parameters + addl $4, %eax + cmp $KERNEL_BASE, %eax + jae bad_syscall_params + movl 4(%esi), %ebx // get and push the syscall parameter size push %ebx - movl 76(%eax), %eax - addl $4, %eax // address of the syscall parameters -// TODO: check !IS_KERNEL_ADDRESS(%eax) + push %eax lea 8(%esp), %ebx // stack address where to copy the params push %ebx @@ -220,9 +226,8 @@ bad_syscall_number: // overwrite the values of %eax and %edx on the stack (the syscall return // value) - movl %esp, %edi - movl %edx, 36(%edi) - movl %eax, 44(%edi) + movl %edx, 36(%ebp) + movl %eax, 44(%ebp) call thread_at_kernel_exit Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-04 02:59:44 UTC (rev 23056) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-04 03:14:07 UTC (rev 23057) @@ -1458,26 +1458,21 @@ Called in the interrupt handler code when a thread enters the kernel for any reason. Only tracks time for now. + Interrupts are disabled. */ void -thread_at_kernel_entry(void) +thread_at_kernel_entry(bigtime_t now) { struct thread *thread = thread_get_current_thread(); - cpu_status state; - bigtime_t now; TRACE(("thread_atkernel_entry: entry thread %ld\n", thread->id)); - state = disable_interrupts(); - // track user time now = system_time(); thread->user_time += now - thread->last_time; thread->last_time = now; thread->in_kernel = true; - - restore_interrupts(state); } From jackburton at mail.berlios.de Tue Dec 4 11:58:31 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 4 Dec 2007 11:58:31 +0100 Subject: [Haiku-commits] r23058 - haiku/trunk/src/apps/terminal Message-ID: <200712041058.lB4AwVKE023477@sheep.berlios.de> Author: jackburton Date: 2007-12-04 11:58:31 +0100 (Tue, 04 Dec 2007) New Revision: 23058 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23058&view=rev Modified: haiku/trunk/src/apps/terminal/TermView.cpp haiku/trunk/src/apps/terminal/TermView.h Log: Selecting text from right to left didn't work. I disabled the use of ResizeSelection() because it didn't support this. Selecting text flicker a lot now, it will be fixed later. Selection should be changed to work a bit more like BTextView. This fixes bug #1638 Modified: haiku/trunk/src/apps/terminal/TermView.cpp =================================================================== --- haiku/trunk/src/apps/terminal/TermView.cpp 2007-12-04 03:14:07 UTC (rev 23057) +++ haiku/trunk/src/apps/terminal/TermView.cpp 2007-12-04 10:58:31 UTC (rev 23058) @@ -41,6 +41,7 @@ #include #include +#include // defined VTKeyTbl.c extern int function_keycode_table[]; @@ -167,7 +168,7 @@ fScrBot(fTermRows - 1), fScrBufSize(historySize), fScrRegionSet(0), - fPreviousMousePoint(0, 0), + fClickPoint(0, 0), fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), @@ -215,7 +216,7 @@ fScrBot(fTermRows - 1), fScrBufSize(historySize), fScrRegionSet(0), - fPreviousMousePoint(0, 0), + fClickPoint(0, 0), fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), @@ -264,7 +265,7 @@ fScrBot(fTermRows - 1), fScrBufSize(1000), fScrRegionSet(0), - fPreviousMousePoint(0, 0), + fClickPoint(0, 0), fSelStart(-1, -1), fSelEnd(-1, -1), fMouseTracking(false), @@ -1825,8 +1826,6 @@ void TermView::MouseDown(BPoint where) { - // TODO: Get rid of the extra thread for mouse tracking, - // and implement it using something like BTextView uses. if (!IsFocus()) MakeFocus(); @@ -1879,7 +1878,7 @@ } // If mouse has a lot of movement, disable double/triple click. - /*BPoint inPoint = fPreviousMousePoint - where; + /*BPoint inPoint = fClickPoint - where; if (abs((int)inPoint.x) > 16 || abs((int)inPoint.y) > 16) clicks = 1; */ @@ -1887,7 +1886,7 @@ SetMouseEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); - fPreviousMousePoint = where; + fClickPoint = where; if (mod & B_SHIFT_KEY) _AddSelectRegion(_BPointToCurPos(where)); @@ -1927,58 +1926,32 @@ if (!fMouseTracking) return; - bool selected = _HasSelection(); - - //int32 button; - //Window()->CurrentMessage()->FindInt32("buttons", &button); - - CurPos startPos = _BPointToCurPos(fPreviousMousePoint); + CurPos startPos = _BPointToCurPos(fClickPoint); 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; + _DeSelect(); + _Select(startPos, endPos); + + // Scroll check + if (fScrollBar != NULL) { + // Get now scroll point + float scrollStart, scrollEnd; + fScrollBar->GetRange(&scrollStart, &scrollEnd); + float scrollPos = fScrollBar->Value(); - 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; - } + if (where.y < Bounds().LeftTop().y ) { + // mouse point left of window + if (scrollPos != scrollStart) + ScrollTo(0, where.y); + } - // 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); - } + if (where.y > Bounds().LeftBottom().y) { + // mouse point left of window + if (scrollPos != scrollEnd) + ScrollTo(0, where.y); } - _ResizeSelectRegion(endPos); } } @@ -1995,6 +1968,9 @@ void TermView::_Select(CurPos start, CurPos end) { + if (end < start) + std::swap(start, end); + if (start.x < 0) start.x = 0; if (end.x >= fTermColumns) @@ -2104,6 +2080,8 @@ void TermView::_ResizeSelectRegion(CurPos pos) { + //TODO: Broken. Selecting from right to left doesn't work. + CurPos inPos = fSelEnd; // error check, and if mouse point to a plase full width character, @@ -2127,9 +2105,10 @@ if (pos.x >= fTermColumns) pos.x = fTermColumns - 1; } + fSelEnd = pos; - - fTextBuffer->Select(fSelStart, pos); + + fTextBuffer->Select(fSelStart, fSelEnd); _TermDrawSelectedRegion(inPos, pos); } @@ -2189,14 +2168,12 @@ void TermView::_SelectLine(BPoint where, int mod) { - CurPos start, end, pos; + CurPos pos = _BPointToCurPos(where); - pos = _BPointToCurPos(where); - if (mod & B_SHIFT_KEY) { - start = CurPos(0, pos.y); - end = CurPos(fTermColumns - 1, pos.y); + CurPos start = CurPos(0, pos.y); + CurPos end = CurPos(fTermColumns - 1, pos.y); if (start < fSelStart) _AddSelectRegion(start); @@ -2406,7 +2383,7 @@ BString copyStr(""); fTextBuffer->GetStringFromRegion(copyStr, fSelStart, fSelEnd); - BMessage message(B_MIME_TYPE); + BMessage message(B_MIME_DATA); message.AddData("text/plain", B_MIME_TYPE, copyStr.String(), copyStr.Length()); BPoint start = _CurPosToBPoint(fSelStart); Modified: haiku/trunk/src/apps/terminal/TermView.h =================================================================== --- haiku/trunk/src/apps/terminal/TermView.h 2007-12-04 03:14:07 UTC (rev 23057) +++ haiku/trunk/src/apps/terminal/TermView.h 2007-12-04 10:58:31 UTC (rev 23058) @@ -259,7 +259,7 @@ int32 fScrBufSize; bool fScrRegionSet; - BPoint fPreviousMousePoint; + BPoint fClickPoint; // view selection CurPos fSelStart; From jackburton at mail.berlios.de Tue Dec 4 12:06:56 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 4 Dec 2007 12:06:56 +0100 Subject: [Haiku-commits] r23059 - haiku/trunk/src/tests/kits/game/chart Message-ID: <200712041106.lB4B6uRe025615@sheep.berlios.de> Author: jackburton Date: 2007-12-04 12:06:56 +0100 (Tue, 04 Dec 2007) New Revision: 23059 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23059&view=rev Modified: haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp Log: The placement of the animation view was off by one to the left. This caused bug #96. Modified: haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp =================================================================== --- haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp 2007-12-04 10:58:31 UTC (rev 23058) +++ haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp 2007-12-04 11:06:56 UTC (rev 23059) @@ -623,7 +623,7 @@ h += SPACE_LABEL+SPACE_POPUP+2*H_BORDER; /* left column gray background */ - r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH-1, frame.bottom); + r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH - 1, frame.bottom); fLeftView = new BView(r, "top view", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW); fLeftView->SetViewColor(background_color); AddChild(fLeftView); @@ -853,11 +853,11 @@ radio->ResizeToPreferred(); fSpecialBox->AddChild(radio); - // Note: direct window mode uses LEFT_WIDTH + // Note: direct window mode uses LEFT_WIDTH to calculate + // the left border of the animation view, so we use it here too. //fLeftView->ResizeTo(max_c(boxWidth + 2, fLeftView->Bounds().Width()), fLeftView->Bounds().Height()); - /* animation area */ - r.Set(fLeftView->Frame().right, TOP_LEFT_LIMIT, frame.right, frame.bottom); + r.Set(LEFT_WIDTH, TOP_LEFT_LIMIT, frame.right, frame.bottom); fChartView = new ChartView(r); fChartView->SetViewColor(0, 0, 0); AddChild(fChartView); From jackburton at mail.berlios.de Tue Dec 4 14:02:34 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 4 Dec 2007 14:02:34 +0100 Subject: [Haiku-commits] r23060 - haiku/trunk/src/tests/kits/game/chart Message-ID: <200712041302.lB4D2YL8023238@sheep.berlios.de> Author: jackburton Date: 2007-12-04 14:02:33 +0100 (Tue, 04 Dec 2007) New Revision: 23060 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23060&view=rev Modified: haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp haiku/trunk/src/tests/kits/game/chart/ChartWindow.h Log: Renamed all member variables to fit our guidelines. Removed useless workaround for an old beos bug Modified: haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp =================================================================== --- haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp 2007-12-04 11:06:56 UTC (rev 23059) +++ haiku/trunk/src/tests/kits/game/chart/ChartWindow.cpp 2007-12-04 13:02:33 UTC (rev 23060) @@ -374,17 +374,6 @@ BFont boldFont(be_bold_font); if (boldFont.Size() > MAX_FONT_SIZE) boldFont.SetSize(MAX_FONT_SIZE); - - /* Check to see if we need the work-around for the case where - DirectConnected is called back with B_BUFFER_RESET not set - properly. This happens only with version 1.3.0 of the - app_server. */ - need_r3_buffer_reset_work_around = false; - - version_info vi; - if (get_file_version_info(B_BEOS_SERVERS_DIRECTORY, "app_server", &vi) == B_NO_ERROR - && (vi.major == 1) && (vi.middle == 3) && (vi.minor == 0)) - need_r3_buffer_reset_work_around = true; /* offset the content area frame in window relative coordinate */ frame.OffsetTo(0.0, 0.0); @@ -398,8 +387,8 @@ /* initial bitmap buffer */ fOffscreen = NULL; - max_width = WINDOW_H_STD - LEFT_WIDTH; - max_height = WINDOW_V_STD - TOP_LEFT_LIMIT; + fMaxWidth = WINDOW_H_STD - LEFT_WIDTH; + fMaxHeight = WINDOW_V_STD - TOP_LEFT_LIMIT; /* initialise the default setting state */ for (int32 i = 0; i < 7; i++) @@ -421,43 +410,43 @@ fCurrentSettings.depth = screen.ColorSpace(); fCurrentSettings.width = (int32)frame.right+1-LEFT_WIDTH; fCurrentSettings.height = (int32)frame.bottom+1-TOP_LEFT_LIMIT; - previous_fullscreen_mode = WINDOW_MODE; + fPreviousFullscreenMode = WINDOW_MODE; fNextSettings.Set(&fCurrentSettings); /* initialise various global parameters */ fInstantLoadLevel = 0; fSecondThreadThreshold = 0.5; - last_dynamic_delay = 0.0; - crc_alea = CRC_START; + fLastDynamicDelay = 0.0; + fCrcAlea = CRC_START; /* initialise the starfield and the special structs */ - stars.list = (star*)malloc(sizeof(star)*STAR_DENSITY_MAX); - specials.list = (star*)malloc(sizeof(star)*SPECIAL_COUNT_MAX); - special_list = (special*)malloc(sizeof(special)*SPECIAL_COUNT_MAX); + fStars.list = (star*)malloc(sizeof(star)*STAR_DENSITY_MAX); + fSpecials.list = (star*)malloc(sizeof(star)*SPECIAL_COUNT_MAX); + fSpecialList = (special*)malloc(sizeof(special)*SPECIAL_COUNT_MAX); InitStars(SPACE_CHAOS); - stars.count = fCurrentSettings.star_density; - stars.erase_count = 0; + fStars.count = fCurrentSettings.star_density; + fStars.erase_count = 0; InitSpecials(SPECIAL_NONE); - specials.erase_count = 0; + fSpecials.erase_count = 0; colors[0] = 1; colors[1] = 2; colors[2] = 3; SetStarColors(colors, 3); /* set camera default position and rotation */ - camera_alpha = 0.2; - camera_theta = 0.0; - camera_phi = 0.0; - camera.Set(camera_alpha, camera_theta, camera_phi); - camera_invert = camera.Transpose(); - origin.x = 0.5; - origin.y = 0.5; - origin.z = 0.1; + fCameraAlpha = 0.2; + fCameraTheta = 0.0; + fCameraPhi = 0.0; + fCamera.Set(fCameraAlpha, fCameraTheta, fCameraPhi); + fCameraInvert = fCamera.Transpose(); + fOrigin.x = 0.5; + fOrigin.y = 0.5; + fOrigin.z = 0.1; /* initialise camera animation */ - tracking_target = -1; - speed = 0.0115; - target_speed = speed; + fTrackingTarget = -1; + fSpeed = 0.0115; + fTargetSpeed = fSpeed; /* initialise the view coordinate system */ InitGeometry(); @@ -465,17 +454,17 @@ SetCubeOffset(); /* init the direct buffer in a valid state */ - direct_buffer.buffer_width = fCurrentSettings.width; - direct_buffer.buffer_height = fCurrentSettings.height; - direct_buffer.clip_list_count = 1; - direct_buffer.clip_bounds.top = 0; - direct_buffer.clip_bounds.left = 0; - direct_buffer.clip_bounds.right = -1; - direct_buffer.clip_bounds.bottom = -1; - direct_buffer.clip_list[0].top = 0; - direct_buffer.clip_list[0].left = 0; - direct_buffer.clip_list[0].right = -1; - direct_buffer.clip_list[0].bottom = -1; + fDirectBuffer.buffer_width = fCurrentSettings.width; + fDirectBuffer.buffer_height = fCurrentSettings.height; + fDirectBuffer.clip_list_count = 1; + fDirectBuffer.clip_bounds.top = 0; + fDirectBuffer.clip_bounds.left = 0; + fDirectBuffer.clip_bounds.right = -1; + fDirectBuffer.clip_bounds.bottom = -1; + fDirectBuffer.clip_list[0].top = 0; + fDirectBuffer.clip_list[0].left = 0; + fDirectBuffer.clip_list[0].right = -1; + fDirectBuffer.clip_list[0].bottom = -1; fDirectConnected = false; /* build the UI content of the window */ @@ -558,44 +547,44 @@ this will be used to record the content of the Picture button. */ r.Set(0, 0, BUTTON_WIDTH-1, TOP_LEFT_LIMIT - 1 - 2*V_BORDER); - offwindow_button = new BButton(r, "", "", NULL); - offwindow_button->Hide(); - AddChild(offwindow_button); - offwindow_button->ResizeTo(r.Width(), r.Height()); + fOffwindowButton = new BButton(r, "", "", NULL); + fOffwindowButton->Hide(); + AddChild(fOffwindowButton); + fOffwindowButton->ResizeTo(r.Width(), r.Height()); /* refresh rate picture button */ r.Set(h, v, h+BUTTON_WIDTH-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); - refresh_button = new BPictureButton(r, "", + fRefreshButton = new BPictureButton(r, "", ButtonPicture(false, REFRESH_BUTTON_PICT), ButtonPicture(true, REFRESH_BUTTON_PICT), new BMessage(OPEN_REFRESH_MSG)); - refresh_button->SetViewColor(B_TRANSPARENT_32_BIT); - refresh_button->ResizeToPreferred(); - fTopView->AddChild(refresh_button); + fRefreshButton->SetViewColor(B_TRANSPARENT_32_BIT); + fRefreshButton->ResizeToPreferred(); + fTopView->AddChild(fRefreshButton); h += BUTTON_WIDTH+2*H_BORDER; /* background color button */ r.Set(h, v, h+BUTTON_WIDTH-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); - color_button = new BPictureButton(r, "", + fColorButton = new BPictureButton(r, "", ButtonPicture(false, COLOR_BUTTON_PICT), ButtonPicture(true, COLOR_BUTTON_PICT), new BMessage(OPEN_COLOR_MSG)); - color_button->SetViewColor(B_TRANSPARENT_32_BIT); - color_button->ResizeToPreferred(); - fTopView->AddChild(color_button); + fColorButton->SetViewColor(B_TRANSPARENT_32_BIT); + fColorButton->ResizeToPreferred(); + fTopView->AddChild(fColorButton); h += BUTTON_WIDTH+2*H_BORDER; /* star density button */ r.Set(h, v, h+BUTTON_WIDTH-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); - density_button = new BPictureButton(r, "", + fDensityButton = new BPictureButton(r, "", ButtonPicture(false, DENSITY_BUTTON_PICT), ButtonPicture(true, DENSITY_BUTTON_PICT), new BMessage(OPEN_DENSITY_MSG)); - density_button->SetViewColor(B_TRANSPARENT_32_BIT); - density_button->ResizeToPreferred(); - fTopView->AddChild(density_button); + fDensityButton->SetViewColor(B_TRANSPARENT_32_BIT); + fDensityButton->ResizeToPreferred(); + fTopView->AddChild(fDensityButton); h += BUTTON_WIDTH+H_BORDER; @@ -657,12 +646,12 @@ /* frames per second display string */ r.Set(h-1, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET, v+STATUS_EDIT-1); - frames = new BStringView(r, "", "0.0"); - frames->SetAlignment(B_ALIGN_RIGHT); - frames->SetFont(be_bold_font); - frames->SetFontSize(24.0); - frames->SetViewColor(B_TRANSPARENT_32_BIT); - fStatusBox->AddChild(frames); + fFramesView = new BStringView(r, "", "0.0"); + fFramesView->SetAlignment(B_ALIGN_RIGHT); + fFramesView->SetFont(be_bold_font); + fFramesView->SetFontSize(24.0); + fFramesView->SetViewColor(B_TRANSPARENT_32_BIT); + fStatusBox->AddChild(fFramesView); v += STATUS_EDIT+STATUS_OFFSET; @@ -677,12 +666,12 @@ /* CPU load pourcentage display string */ r.Set(h-1, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET, v+STATUS_EDIT-1); - cpu_load = new BStringView(r, "", "0.0"); - cpu_load->SetAlignment(B_ALIGN_RIGHT); - cpu_load->SetFont(be_bold_font); - cpu_load->SetFontSize(24.0); - cpu_load->SetViewColor(B_TRANSPARENT_32_BIT); - fStatusBox->AddChild(cpu_load); + fCpuLoadView = new BStringView(r, "", "0.0"); + fCpuLoadView->SetAlignment(B_ALIGN_RIGHT); + fCpuLoadView->SetFont(be_bold_font); + fCpuLoadView->SetFontSize(24.0); + fCpuLoadView->SetViewColor(B_TRANSPARENT_32_BIT); + fStatusBox->AddChild(fCpuLoadView); v2 += STATUS_BOX+LEFT_OFFSET*2; h = h2; @@ -901,9 +890,9 @@ delete_sem(fSecondThreadRelease); /* free the buffers used to store the starlists */ - free(stars.list); - free(specials.list); - free(special_list); + free(fStars.list); + free(fSpecials.list); + free(fSpecialList); } @@ -975,7 +964,7 @@ LaunchSound(); break; case BACK_DEMO_MSG : - fNextSettings.fullscreen_mode = previous_fullscreen_mode; + fNextSettings.fullscreen_mode = fPreviousFullscreenMode; break; case SECOND_THREAD_MSG : check_box = dynamic_cast(handler); @@ -1099,20 +1088,20 @@ /* create and open the picture */ pict = new BPicture(); - r = offwindow_button->Bounds(); - offwindow_button->SetValue(active); - offwindow_button->BeginPicture(pict); + r = fOffwindowButton->Bounds(); + fOffwindowButton->SetValue(active); + fOffwindowButton->BeginPicture(pict); /* draw the standard BButton in whatever state is required. */ - offwindow_button->Draw(r); + fOffwindowButton->Draw(r); if (button_type == COLOR_BUTTON_PICT) { /* this button just contains a rectangle of the current background color, with a one pixel black border. */ r.InsetBy(6.0, 4.0); - offwindow_button->SetHighColor(0, 0, 0); - offwindow_button->StrokeRect(r); + fOffwindowButton->SetHighColor(0, 0, 0); + fOffwindowButton->StrokeRect(r); r.InsetBy(1.0, 1.0); - offwindow_button->SetHighColor(fCurrentSettings.back_color); - offwindow_button->FillRect(r); + fOffwindowButton->SetHighColor(fCurrentSettings.back_color); + fOffwindowButton->FillRect(r); } else if (button_type == DENSITY_BUTTON_PICT) { /* this button just contains a big string (using a bigger font size @@ -1121,11 +1110,11 @@ value = (fCurrentSettings.star_density*100 + STAR_DENSITY_MAX/2) / STAR_DENSITY_MAX; sprintf(word, "%3ld", value); draw_string: - offwindow_button->SetFont(be_bold_font); - offwindow_button->SetFontSize(14.0); - delta.x = BUTTON_WIDTH/2-(offwindow_button->StringWidth(word) * 0.5); + fOffwindowButton->SetFont(be_bold_font); + fOffwindowButton->SetFontSize(14.0); + delta.x = BUTTON_WIDTH/2-(fOffwindowButton->StringWidth(word) * 0.5); delta.y = (TOP_LEFT_LIMIT-2*V_BORDER)/2 + 6.0; - offwindow_button->DrawString(word, delta); + fOffwindowButton->DrawString(word, delta); } else { /* this button just contains a big string (using a bigger font size @@ -1135,7 +1124,7 @@ goto draw_string; } /* close and return the picture */ - return offwindow_button->EndPicture(); + return fOffwindowButton->EndPicture(); } /* Create a floating window including a slightly modified version of @@ -1323,8 +1312,8 @@ timeout = 0; if (LockWithTimeout(timeout) == B_OK) { - frames->SetText(text_frames); - cpu_load->SetText(text_cpu_load); + fFramesView->SetText(text_frames); + fCpuLoadView->SetText(text_cpu_load); Unlock(); } } @@ -1338,22 +1327,22 @@ { /* calculate some parameters required for the 3d processing */ float dz = sqrt(1.0 - (DH_REF*DH_REF + DV_REF*DV_REF) * (0.5 + 0.5/Z_CUT_RATIO) * (0.5 + 0.5/Z_CUT_RATIO)); - depth_ref = dz / (1.0 - 1.0/Z_CUT_RATIO); + fDepthRef = dz / (1.0 - 1.0/Z_CUT_RATIO); /* set the position of the pyramid of vision, so that it was always possible to include it into a 1x1x1 cube parallel to the 3 main axis. */ - geo.z_max = depth_ref; - geo.z_min = depth_ref/Z_CUT_RATIO; + fGeometry.z_max = fDepthRef; + fGeometry.z_min = fDepthRef/Z_CUT_RATIO; /* used for lighting processing */ - geo.z_max_square = geo.z_max * geo.z_max; + fGeometry.z_max_square = fGeometry.z_max * fGeometry.z_max; /* preprocess that for the fast clipping based on the pyramid of vision */ - geo.xz_max = (0.5*DH_REF)/geo.z_max; - geo.xz_min = -geo.xz_max; - geo.yz_max = (0.5*DV_REF)/geo.z_max; - geo.yz_min = -geo.yz_max; + fGeometry.xz_max = (0.5*DH_REF)/fGeometry.z_max; + fGeometry.xz_min = -fGeometry.xz_max; + fGeometry.yz_max = (0.5*DV_REF)/fGeometry.z_max; + fGeometry.yz_min = -fGeometry.yz_max; } /* second part of the asynchronous setting mechanism. This will be @@ -1374,15 +1363,15 @@ if (fCurrentSettings.fullscreen_mode != new_set.fullscreen_mode) { switch (new_set.fullscreen_mode) { case WINDOW_MODE : - previous_fullscreen_mode = WINDOW_MODE; - ResizeTo(PreviousFrame.Width(), PreviousFrame.Height()); - MoveTo(PreviousFrame.left, PreviousFrame.top); + fPreviousFullscreenMode = WINDOW_MODE; + ResizeTo(fPreviousFrame.Width(), fPreviousFrame.Height()); + MoveTo(fPreviousFrame.left, fPreviousFrame.top); break; case FULLSCREEN_MODE : { - previous_fullscreen_mode = FULLSCREEN_MODE; + fPreviousFullscreenMode = FULLSCREEN_MODE; if (fCurrentSettings.fullscreen_mode == WINDOW_MODE) - PreviousFrame = Frame(); + fPreviousFrame = Frame(); BScreen a_screen(this); MoveTo(a_screen.Frame().left, a_screen.Frame().top); ResizeTo(a_screen.Frame().Width(), a_screen.Frame().Height()); @@ -1390,9 +1379,9 @@ break; case FULLDEMO_MODE : { - previous_fullscreen_mode = fCurrentSettings.fullscreen_mode; + fPreviousFullscreenMode = fCurrentSettings.fullscreen_mode; if (fCurrentSettings.fullscreen_mode == WINDOW_MODE) - PreviousFrame = Frame(); + fPreviousFrame = Frame(); BScreen b_screen(this); ResizeTo(b_screen.Frame().Width() + LEFT_WIDTH, b_screen.Frame().Height() + TOP_LEFT_LIMIT); MoveTo(b_screen.Frame().left - LEFT_WIDTH, b_screen.Frame().top - TOP_LEFT_LIMIT); @@ -1411,13 +1400,13 @@ if (LockWithTimeout(200000) == B_OK) { if (old_step != fInstantLoad->step) fInstantLoad->Invalidate(); - refresh_button->SetEnabledOff(ButtonPicture(false, REFRESH_BUTTON_PICT)); - refresh_button->SetEnabledOn(ButtonPicture(true, REFRESH_BUTTON_PICT)); - refresh_button->Invalidate(); + fRefreshButton->SetEnabledOff(ButtonPicture(false, REFRESH_BUTTON_PICT)); + fRefreshButton->SetEnabledOn(ButtonPicture(true, REFRESH_BUTTON_PICT)); + fRefreshButton->Invalidate(); Unlock(); } if (fCurrentSettings.animation != ANIMATION_OFF) - frame_delay = (bigtime_t)(1000000.0/new_set.refresh_rate); + fFrameDelay = (bigtime_t)(1000000.0/new_set.refresh_rate); } /* check for change in the star colors list */ @@ -1446,21 +1435,21 @@ /* check the settings of the offscreen bitmap */ CheckBitmap(new_set.depth, new_set.width, new_set.height); /* synchronise the camera geometry and the offscreen buffer geometry */ - SetGeometry(bitmap_buffer.buffer_width, bitmap_buffer.buffer_height); + SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); /* reset the offscreen background and cancel the erasing */ SetBitmapBackGround(); - stars.erase_count = 0; - specials.erase_count = 0; + fStars.erase_count = 0; + fSpecials.erase_count = 0; } if (new_set.display == DISPLAY_DIRECT) { /* this need to be atomic in regard of DirectConnected */ while (acquire_sem(fDrawingLock) == B_INTERRUPTED) ; /* synchronise the camera geometry and the direct buffer geometry */ - SetGeometry(direct_buffer.buffer_width, direct_buffer.buffer_height); + SetGeometry(fDirectBuffer.buffer_width, fDirectBuffer.buffer_height); /* cancel erasing of stars not in visible part of the direct window */ - RefreshClipping(&direct_buffer, &stars); - RefreshClipping(&direct_buffer, &specials); + RefreshClipping(&fDirectBuffer, &fStars); + RefreshClipping(&fDirectBuffer, &fSpecials); release_sem(fDrawingLock); } } @@ -1470,17 +1459,17 @@ /* when there is no camera animation, we loop only 10 times per second. */ if (new_set.animation == ANIMATION_OFF) - frame_delay = 100000; + fFrameDelay = 100000; else - frame_delay = (bigtime_t)(1000000.0/new_set.refresh_rate); + fFrameDelay = (bigtime_t)(1000000.0/new_set.refresh_rate); /* reset the free camera animation context for a fresh start */ if (new_set.animation == ANIMATION_FREE_MOVE) { - d_alpha = 0.0; - d_theta = 0.0; - d_phi = 0.0; - cnt_alpha = 0; - cnt_theta = 0; - cnt_phi = 0; + fDynamicAlpha = 0.0; + fDynamicTheta = 0.0; + fDynamicPhi = 0.0; + fCountAlpha = 0; + fCountTheta = 0; + fCountPhi = 0; } } @@ -1499,25 +1488,25 @@ BScreen screen(this); /* set the background color and it's 8 bits index equivalent */ fCurrentSettings.back_color = new_set.back_color; - back_color_index = screen.IndexForColor(new_set.back_color); + fBackColorIndex = screen.IndexForColor(new_set.back_color); /* set the nackground color of the view (directwindow mode) */ fChartView->SetViewColor(new_set.back_color); /* change the color of the picture button used in the UI */ - color_button->SetEnabledOff(ButtonPicture(false, COLOR_BUTTON_PICT)); - color_button->SetEnabledOn(ButtonPicture(true, COLOR_BUTTON_PICT)); - color_button->Invalidate(); + fColorButton->SetEnabledOff(ButtonPicture(false, COLOR_BUTTON_PICT)); + fColorButton->SetEnabledOn(ButtonPicture(true, COLOR_BUTTON_PICT)); + fColorButton->Invalidate(); /* update all dependencies in the offscreen buffer descriptor */ - SetColorSpace(&bitmap_buffer, bitmap_buffer.depth); + SetColorSpace(&fBitmapBuffer, fBitmapBuffer.depth); /* update all dependencies in the directwindow buffer descriptor */ while (acquire_sem(fDrawingLock) == B_INTERRUPTED) ; - SetColorSpace(&direct_buffer, direct_buffer.depth); + SetColorSpace(&fDirectBuffer, fDirectBuffer.depth); release_sem(fDrawingLock); /* in offscreen mode, erase the background and cancel star erasing */ if (new_set.display == DISPLAY_BITMAP) { SetBitmapBackGround(); - stars.erase_count = 0; - specials.erase_count = 0; + fStars.erase_count = 0; + fSpecials.erase_count = 0; } /* in directwindow mode, just force an update */ else @@ -1531,12 +1520,12 @@ if (LockWithTimeout(200000) == B_OK) { fCurrentSettings.star_density = new_set.star_density; /* change the picture button used in the UI */ - density_button->SetEnabledOff(ButtonPicture(false, DENSITY_BUTTON_PICT)); - density_button->SetEnabledOn(ButtonPicture(true, DENSITY_BUTTON_PICT)); - density_button->Invalidate(); + fDensityButton->SetEnabledOff(ButtonPicture(false, DENSITY_BUTTON_PICT)); + fDensityButton->SetEnabledOn(ButtonPicture(true, DENSITY_BUTTON_PICT)); + fDensityButton->Invalidate(); Unlock(); } - stars.count = new_set.star_density; + fStars.count = new_set.star_density; } /* check for change in the buffer format for the offscreen bitmap. @@ -1546,18 +1535,18 @@ /* need to reset the buffer if it's currently used for display */ if (new_set.display == DISPLAY_BITMAP) { SetBitmapBackGround(); - stars.erase_count = 0; - specials.erase_count = 0; + fStars.erase_count = 0; + fSpecials.erase_count = 0; } } /* check for change in the drawing area of the offscreen bitmap */ if ((new_set.width != fCurrentSettings.width) || (new_set.height != fCurrentSettings.height)) { CheckBitmap(new_set.depth, new_set.width, new_set.height); - bitmap_buffer.buffer_width = new_set.width; - bitmap_buffer.buffer_height = new_set.height; + fBitmapBuffer.buffer_width = new_set.width; + fBitmapBuffer.buffer_height = new_set.height; if (new_set.display == DISPLAY_BITMAP) - SetGeometry(bitmap_buffer.buffer_width, bitmap_buffer.buffer_height); + SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); SetBitmapClipping(new_set.width, new_set.height); } @@ -1580,32 +1569,32 @@ switch (space_model) { /* Create a random starfield */ case SPACE_CHAOS : - FillStarList(stars.list, STAR_DENSITY_MAX); - key_point_count = 0; + FillStarList(fStars.list, STAR_DENSITY_MAX); + fKeyPointCount = 0; break; /* Create a starfield with big concentration of stars (amas) */ case SPACE_AMAS : case SPACE_SPIRAL : /* pick 8 random position for the amas */ - FillStarList(stars.list, 8); + FillStarList(fStars.list, 8); for (i=0; i<8; i++) { - amas[i].x = stars.list[i].x; - amas[i].y = stars.list[i].y; - amas[i].z = stars.list[i].z; + amas[i].x = fStars.list[i].x; + amas[i].y = fStars.list[i].y; + amas[i].z = fStars.list[i].z; amas_select[i] = i; - factor[i] = ((float)(crc_alea&2047) + 0.5)*(1.0/128.0) + 16.0/3.0; + factor[i] = ((float)(fCrcAlea&2047) + 0.5)*(1.0/128.0) + 16.0/3.0; CrcStep(); CrcStep(); } /* make each amas ramdomly smaller or bigger */ for (i=8; i<32; i++) { - amas_select[i] = (crc_alea & 7); + amas_select[i] = (fCrcAlea & 7); CrcStep(); } /* create a random starfield */ - FillStarList(stars.list, STAR_DENSITY_MAX); + FillStarList(fStars.list, STAR_DENSITY_MAX); /* In spiral mode, only half the star will be put into the amas. the other half will be put into the spiral galaxy. */ @@ -1613,7 +1602,7 @@ i_step = 1; else i_step = 2; - s = stars.list; + s = fStars.list; for (i=0; i=0; step--) @@ -1665,8 +1654,8 @@ /* record the center of the amas as key points for the free camera animation mode. */ for (i=0; i<8; i++) - key_points[i] = amas[i]; - key_point_count = 8; + fKeyPoints[i] = amas[i]; + fKeyPointCount = 8; /* no further processing needed in amas only mode. */ if (space_model == SPACE_AMAS) @@ -1674,11 +1663,11 @@ /* in spiral mode, the second half of the star will be distributed on random spiral like galaxy. */ - s = stars.list+1; + s = fStars.list+1; for (i=1; ix - 0.5; @@ -1694,7 +1683,7 @@ step++; } - step -= (crc_alea&3); + step -= (fCrcAlea&3); CrcStep(); fact = 0.5; for (;step>=0; step--) @@ -1707,12 +1696,12 @@ /* other star are put at a random place somewhere on one of teh two spiral arms... */ alpha = 3.4 * s->x * (s->x*0.5 + 1.0); - if (crc_alea & 64) + if (fCrcAlea & 64) alpha += 3.14159; r = s->x * 0.34 + 0.08; - r += (s->y-0.725 + 0.03 * (float)(crc_alea & 15))*0.04*(1.2+r); + r += (s->y-0.725 + 0.03 * (float)(fCrcAlea & 15))*0.04*(1.2+r); r *= 0.5; - dx = (s->z-0.8 + 0.04 * (float)(crc_alea & 15)) * (2.0 - abs(s->y - 0.5)) * (0.025*0.5); + dx = (s->z-0.8 + 0.04 * (float)(fCrcAlea & 15)) * (2.0 - abs(s->y - 0.5)) * (0.025*0.5); dy = cos(alpha) * r; dz = sin(alpha) * r; } @@ -1728,26 +1717,26 @@ /* add the center of the galaxy to the key point list for free camera animation mode */ - key_points[8].x = 0.5; - key_points[8].y = 0.5; - key_points[8].z = 0.5; + fKeyPoints[8].x = 0.5; + fKeyPoints[8].y = 0.5; + fKeyPoints[8].z = 0.5; /* add seven other galaxy star to the key point list */ for (i=9; i<16; i++) { - key_points[i].x = stars.list[i*(STAR_DENSITY_MAX/18)].x; - key_points[i].y = stars.list[i*(STAR_DENSITY_MAX/18)].y; - key_points[i].z = stars.list[i*(STAR_DENSITY_MAX/18)].z; + fKeyPoints[i].x = fStars.list[i*(STAR_DENSITY_MAX/18)].x; + fKeyPoints[i].y = fStars.list[i*(STAR_DENSITY_MAX/18)].y; + fKeyPoints[i].z = fStars.list[i*(STAR_DENSITY_MAX/18)].z; } - key_point_count = 16; + fKeyPointCount = 16; break; } /* In all starfield modes, for all stars, peek a random brightness level */ for (i=0; i>8) & 1023) * (6.283159/1024.0); + alpha = ((fCrcAlea>>8) & 1023) * (6.283159/1024.0); CrcStep(); /* pick a random ejection speed */ - coeff = 0.000114 + 0.0000016 * (float)((crc_alea>>17) & 31); - if ((crc_alea & 7) > 4) coeff *= 0.75; - if ((crc_alea & 7) == 7) coeff *= 0.65; + coeff = 0.000114 + 0.0000016 * (float)((fCrcAlea>>17) & 31); + if ((fCrcAlea & 7) > 4) coeff *= 0.75; + if ((fCrcAlea & 7) == 7) coeff *= 0.65; CrcStep(); /* calculate the ejection speed vector */ ksin = sin(alpha) * coeff; kcos = cos(alpha) * coeff; - special_list[i].comet.dx = dx.x * kcos + dy.x * ksin; - special_list[i].comet.dy = dx.y * kcos + dy.y * ksin; - special_list[i].comet.dz = dx.z * kcos + dy.z * ksin; + fSpecialList[i].comet.dx = dx.x * kcos + dy.x * ksin; + fSpecialList[i].comet.dy = dx.y * kcos + dy.y * ksin; + fSpecialList[i].comet.dz = dx.z * kcos + dy.z * ksin; } } break; @@ -1841,24 +1830,24 @@ brightness level in real time) close from the first stars of the starfield. */ case SPECIAL_NOVAS : - specials.count = 96; - for (i=0; i= color_count) index = 0; } for (i=0; i= color_count) index = 0; @@ -1892,19 +1881,19 @@ float zoom; /* calculate the zoom factor for the 3d projection */ - geo.zoom_factor = (float)dh*(depth_ref/DH_REF); - zoom = (float)dv*(depth_ref/DV_REF); - if (zoom > geo.zoom_factor) - geo.zoom_factor = zoom; + fGeometry.zoom_factor = (float)dh*(fDepthRef/DH_REF); + zoom = (float)dv*(fDepthRef/DV_REF); + if (zoom > fGeometry.zoom_factor) + fGeometry.zoom_factor = zoom; /* offset of the origin in the view area */ - geo.offset_h = (float)dh * 0.5; - geo.offset_v = (float)dv * 0.5; + fGeometry.offset_h = (float)dh * 0.5; + fGeometry.offset_v = (float)dv * 0.5; /* sub-pixel precision double-sampling */ - geo.zoom_factor *= 2.0; - geo.offset_h = geo.offset_h * 2.0 - 1.0; - geo.offset_v = geo.offset_v * 2.0 - 1.0; + fGeometry.zoom_factor *= 2.0; + fGeometry.offset_h = fGeometry.offset_h * 2.0 - 1.0; + fGeometry.offset_v = fGeometry.offset_v * 2.0 - 1.0; } @@ -2099,7 +2088,7 @@ /* init refresh rate control */ timer = system_time(); - w->frame_delay = 100000; + w->fFrameDelay = 100000; /* init performance timing control variables */ next_stat = timer + STAT_DELAY; @@ -2117,14 +2106,14 @@ before_frame = system_time(); /* credit the timer by the current delay between frame */ - timer += w->frame_delay; + timer += w->fFrameDelay; /* change the settings, if needed */ w->ChangeSetting(w->fNextSettings); /* draw the next frame */ if (w->fCurrentSettings.display == DISPLAY_BITMAP) { - w->RefreshStars(&w->bitmap_buffer, time_factor * 2.4); + w->RefreshStars(&w->fBitmapBuffer, time_factor * 2.4); if (w->LockWithTimeout(200000) == B_OK) { w->fChartView->DrawBitmap(w->fOffscreen); w->Unlock(); @@ -2138,7 +2127,7 @@ while (acquire_sem(w->fDrawingLock) == B_INTERRUPTED) ; if (w->fDirectConnected) - w->RefreshStars(&w->direct_buffer, time_factor * 2.4); + w->RefreshStars(&w->fDirectBuffer, time_factor * 2.4); release_sem(w->fDrawingLock); } @@ -2217,8 +2206,8 @@ /* the duration of the processing is needed to control the dynamic load split (see RefreshStar) */ bigtime_t before = system_time(); - RefreshStarPacket(w->fSecondThreadBuffer, &w->fStars2, &w->geo); - RefreshStarPacket(w->fSecondThreadBuffer, &w->fSpecials2, &w->geo); + RefreshStarPacket(w->fSecondThreadBuffer, &w->fStars2, &w->fGeometry); + RefreshStarPacket(w->fSecondThreadBuffer, &w->fSpecials2, &w->fGeometry); bigtime_t after = system_time(); w->fSecondThreadDelay = after-before; @@ -2243,9 +2232,9 @@ min.x = min.y = min.z = 10.0; max.x = max.y = max.z = -10.0; - dx = camera.Axis(0)*(DH_REF*0.5); - dy = camera.Axis(1)*(DV_REF*0.5); - dz = camera.Axis(2)*depth_ref; + dx = fCamera.Axis(0)*(DH_REF*0.5); + dy = fCamera.Axis(1)*(DV_REF*0.5); + dz = fCamera.Axis(2)*fDepthRef; for (i=0; i<8; i++) { /* left side / right side */ @@ -2257,7 +2246,7 @@ /* rear cut plan / front cut plan */ if (i&4) p1 = p1 * (1.0 / Z_CUT_RATIO); /* relative to the position of the camera */ - p1 = p1 + origin; + p1 = p1 + fOrigin; if (min.x > p1.x) min.x = p1.x; if (min.y > p1.y) min.y = p1.y; @@ -2277,32 +2266,32 @@ while (min.x < 0.0) { min.x += 1.0; max.x += 1.0; - origin.x += 1.0; + fOrigin.x += 1.0; } while (min.y < 0.0) { min.y += 1.0; max.y += 1.0; - origin.y += 1.0; + fOrigin.y += 1.0; } while (min.z < 0.0) { min.z += 1.0; max.z += 1.0; - origin.z += 1.0; + fOrigin.z += 1.0; } while (max.x >= 2.0) { min.x -= 1.0; max.x -= 1.0; - origin.x -= 1.0; + fOrigin.x -= 1.0; } while (max.y >= 2.0) { min.y -= 1.0; max.y -= 1.0; - origin.y -= 1.0; + fOrigin.y -= 1.0; } while (max.z >= 2.0) { min.z -= 1.0; max.z -= 1.0; - origin.z -= 1.0; + fOrigin.z -= 1.0; } /* set the cutting plans. For example, if the bouding box of @@ -2312,9 +2301,9 @@ in [1.0 ; 1.4] where they will be visible. Same process on other axis. That way, we have to test every star of the starfield in one position and only one. */ - cut.x = (min.x + max.x - 1.0) * 0.5; - cut.y = (min.y + max.y - 1.0) * 0.5; - cut.z = (min.z + max.z - 1.0) * 0.5; + fCut.x = (min.x + max.x - 1.0) * 0.5; + fCut.y = (min.y + max.y - 1.0) * 0.5; + fCut.z = (min.z + max.z - 1.0) * 0.5; /* Make sure those new settings are copied into the struct used by the embedded C-engine. */ @@ -2333,32 +2322,32 @@ /* Slow rotation around the "center" of the visible area. */ case ANIMATION_ROTATE : /* turn around a point at 0.45 in front of the camera */ - move = camera.Axis(2); + move = fCamera.Axis(2); move = move * 0.45; - origin = origin + move; + fOrigin = fOrigin + move; /* turn around the alpha angle of the spheric rotation matrix */ - camera_alpha += 0.011*time_factor; - if (camera_alpha > 2*3.14159) - camera_alpha -= 2*3.14159; + fCameraAlpha += 0.011*time_factor; + if (fCameraAlpha > 2*3.14159) + fCameraAlpha -= 2*3.14159; /* set the other two angles close from hardcoded values */ - if (camera_theta < 0.18) - camera_theta += 0.003*time_factor; - if (camera_theta > 0.22) - camera_theta -= 0.003*time_factor; + if (fCameraTheta < 0.18) + fCameraTheta += 0.003*time_factor; + if (fCameraTheta > 0.22) + fCameraTheta -= 0.003*time_factor; - if (camera_phi < -0.02) - camera_phi += 0.003*time_factor; - if (camera_phi > 0.02) [... truncated: 890 lines follow ...] From jackburton at mail.berlios.de Wed Dec 5 12:21:18 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 5 Dec 2007 12:21:18 +0100 Subject: [Haiku-commits] r23061 - haiku/trunk/src/apps/deskcalc Message-ID: <200712051121.lB5BLICf028674@sheep.berlios.de> Author: jackburton Date: 2007-12-05 12:21:18 +0100 (Wed, 05 Dec 2007) New Revision: 23061 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23061&view=rev Modified: haiku/trunk/src/apps/deskcalc/CalcView.cpp Log: Use floorf() on the calculations otherwise casting to an int could truncate negative values to 0. Fixes bug #914. Modified: haiku/trunk/src/apps/deskcalc/CalcView.cpp =================================================================== --- haiku/trunk/src/apps/deskcalc/CalcView.cpp 2007-12-04 13:02:33 UTC (rev 23060) +++ haiku/trunk/src/apps/deskcalc/CalcView.cpp 2007-12-05 11:21:18 UTC (rev 23061) @@ -39,7 +39,7 @@ const uint8 K_COLOR_OFFSET = 32; const float K_FONT_YPROP = 0.6f; -const float K_DISPLAY_YPROP = 0.2; +const float K_DISPLAY_YPROP = 0.2f; enum { K_OPTIONS_REQUESTED = 'opts', @@ -404,7 +404,8 @@ CalcView::MouseDown(BPoint point) { // ensure this view is the current focus - MakeFocus(); + if (!IsFocus()) + MakeFocus(); // read mouse buttons state int32 buttons = 0; @@ -427,8 +428,8 @@ float sizeRow = (fHeight - sizeDisp) / (float)fRows; // calculate location within grid - int gridCol = (int)(point.x / sizeCol); - int gridRow = (int)((point.y - sizeDisp) / sizeRow); + int gridCol = (int)floorf(point.x / sizeCol); + int gridRow = (int)floorf((point.y - sizeDisp) / sizeRow); // check limits if ((gridCol >= 0) && (gridCol < fColums) && From jackburton at mail.berlios.de Wed Dec 5 13:13:01 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 5 Dec 2007 13:13:01 +0100 Subject: [Haiku-commits] r23062 - haiku/trunk/src/kits/interface Message-ID: <200712051213.lB5CD1w3022862@sheep.berlios.de> Author: jackburton Date: 2007-12-05 13:12:48 +0100 (Wed, 05 Dec 2007) New Revision: 23062 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23062&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: Dispatch also the B_WINDOW_ACTIVATED messages. This fixes bug #613, but we need to check which other messages are handled by beos here. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2007-12-05 11:21:18 UTC (rev 23061) +++ haiku/trunk/src/kits/interface/Window.cpp 2007-12-05 12:12:48 UTC (rev 23062) @@ -1683,7 +1683,7 @@ BMessage *msg; for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { - if (msg->what == _UPDATE_) { + if (msg->what == _UPDATE_ || msg->what == B_WINDOW_ACTIVATED) { BWindow::DispatchMessage(msg, this); // we need to make sure that no overridden method is called // here; for BWindow::DispatchMessage() we now exactly what From jackburton at mail.berlios.de Wed Dec 5 13:13:44 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 5 Dec 2007 13:13:44 +0100 Subject: [Haiku-commits] r23063 - haiku/trunk/src/kits/interface Message-ID: <200712051213.lB5CDi82024989@sheep.berlios.de> Author: jackburton Date: 2007-12-05 13:13:43 +0100 (Wed, 05 Dec 2007) New Revision: 23063 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23063&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: added a TODO item Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2007-12-05 12:12:48 UTC (rev 23062) +++ haiku/trunk/src/kits/interface/Window.cpp 2007-12-05 12:13:43 UTC (rev 23063) @@ -1683,6 +1683,7 @@ BMessage *msg; for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { + // TODO: Dispatch more messages ?!?!? Check what beos does. if (msg->what == _UPDATE_ || msg->what == B_WINDOW_ACTIVATED) { BWindow::DispatchMessage(msg, this); // we need to make sure that no overridden method is called From axeld at pinc-software.de Wed Dec 5 14:19:16 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 05 Dec 2007 14:19:16 +0100 CET Subject: [Haiku-commits] r23062 - haiku/trunk/src/kits/interface In-Reply-To: <200712051213.lB5CD1w3022862@sheep.berlios.de> Message-ID: <9549572796-BeMail@zon> jackburton at BerliOS wrote: > Log: > Dispatch also the B_WINDOW_ACTIVATED messages. This fixes bug #613, > but > we need to check which other messages are handled by beos here. Actually, BeOS really only checks for drawing messages there. So what we do now is already deviating from this - I'm just not sure if that's so bad :) We definitely need to test this a bit more (ie. activation/focus in different setups), but I currently don't have time and ideas to do so. Bye, Axel. From axeld at mail.berlios.de Wed Dec 5 19:33:58 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Wed, 5 Dec 2007 19:33:58 +0100 Subject: [Haiku-commits] r23064 - haiku/trunk/src/tools/fs_shell Message-ID: <200712051833.lB5IXwCe009929@sheep.berlios.de> Author: axeld Date: 2007-12-05 19:33:58 +0100 (Wed, 05 Dec 2007) New Revision: 23064 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23064&view=rev Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp Log: The fs_shell now also works with devices that don't return a correct hd_geometry, but do support the BLKGETSIZE64 ioctl (it just crashed before). Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/unistd.cpp 2007-12-05 12:13:43 UTC (rev 23063) +++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2007-12-05 18:33:58 UTC (rev 23064) @@ -28,7 +28,8 @@ # endif # if defined(HAIKU_HOST_PLATFORM_LINUX) -# include +# include +# include # endif #endif @@ -155,22 +156,42 @@ // to be HDIO_GETGEO, which is kind of obsolete, BTW), and // get the partition size via binary search. if (ioctl(fd, HDIO_GETGEO, &hdGeometry) == 0) { - off_t bytesPerCylinder = (off_t)hdGeometry.heads - * hdGeometry.sectors * 512; - off_t deviceSize = bytesPerCylinder * hdGeometry.cylinders; - off_t partitionSize = get_partition_size(fd, deviceSize); + int blockSize = 512; + if (hdGeometry.heads == 0) { + off_t size; + if (ioctl(fd, BLKGETSIZE64, &size) == 0) { + off_t blocks = size / blockSize; + uint32_t heads = (blocks + ULONG_MAX - 1) + / ULONG_MAX; + if (heads == 0) + heads = 1; - geometry->head_count = hdGeometry.heads; - geometry->cylinder_count = partitionSize / bytesPerCylinder; - geometry->sectors_per_track = hdGeometry.sectors; + geometry->head_count = heads; + geometry->cylinder_count = blocks / heads; + geometry->sectors_per_track = 1; + error = B_OK; + } else + error = errno; + } else { + off_t bytesPerCylinder = (off_t)hdGeometry.heads + * hdGeometry.sectors * 512; + off_t deviceSize = bytesPerCylinder * hdGeometry.cylinders; + off_t partitionSize = get_partition_size(fd, deviceSize); - // TODO: Get the real values... - geometry->bytes_per_sector = 512; - geometry->device_type = FSSH_B_DISK; - geometry->removable = false; - geometry->read_only = false; - geometry->write_once = false; - error = B_OK; + geometry->head_count = hdGeometry.heads; + geometry->cylinder_count = partitionSize / bytesPerCylinder; + geometry->sectors_per_track = hdGeometry.sectors; + error = B_OK; + } + + if (error == B_OK) { + // TODO: Get the real values... + geometry->bytes_per_sector = blockSize; + geometry->device_type = FSSH_B_DISK; + geometry->removable = false; + geometry->read_only = false; + geometry->write_once = false; + } } else error = errno; From mmu_man at mail.berlios.de Wed Dec 5 23:00:08 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 5 Dec 2007 23:00:08 +0100 Subject: [Haiku-commits] r23065 - haiku/trunk/src/add-ons/kernel/drivers/network/etherpci Message-ID: <200712052200.lB5M08W0022928@sheep.berlios.de> Author: mmu_man Date: 2007-12-05 23:00:06 +0100 (Wed, 05 Dec 2007) New Revision: 23065 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23065&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c Log: Print a new line there for cleaner output. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c 2007-12-05 18:33:58 UTC (rev 23064) +++ haiku/trunk/src/add-ons/kernel/drivers/network/etherpci/etherpci.c 2007-12-05 22:00:06 UTC (rev 23065) @@ -1363,6 +1363,7 @@ put_module(B_PCI_MODULE_NAME ); return B_ERROR; } + dprintf("\n"); /* Create device name list*/ for (i=0; i Author: bonefish Date: 2007-12-06 00:17:20 +0100 (Thu, 06 Dec 2007) New Revision: 23066 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23066&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/user_debugger.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp Log: * Introduced a thread::flags field that summarizes the events relevant in interrupt handlers (signals pending, user debugging enabled, breakpoints defined, etc.). Several changes in the signal and user debugger code to maintain it. * Added quick version of thread_kernel_exit() that doesn't handle signals (i.e. it only tracks the time). Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h 2007-12-05 23:17:20 UTC (rev 23066) @@ -29,6 +29,7 @@ status_t arch_clear_breakpoint(void *address); status_t arch_set_watchpoint(void *address, uint32 type, int32 length); status_t arch_clear_watchpoint(void *address); +bool arch_has_breakpoints(struct arch_team_debug_info *info); #if KERNEL_BREAKPOINTS status_t arch_set_kernel_breakpoint(void *address); Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-05 23:17:20 UTC (rev 23066) @@ -29,6 +29,7 @@ void thread_at_kernel_entry(bigtime_t now); // called when the thread enters the kernel on behalf of the thread void thread_at_kernel_exit(void); +void thread_at_kernel_exit_no_signals(void); void thread_reset_for_exec(void); status_t thread_init(struct kernel_args *args); Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-05 23:17:20 UTC (rev 23066) @@ -7,6 +7,7 @@ #ifndef _KERNEL_THREAD_TYPES_H #define _KERNEL_THREAD_TYPES_H +#ifndef _ASSEMBLER #include #include @@ -182,6 +183,11 @@ typedef int32 (*thread_entry_func)(thread_func, void *); struct thread { + int32 flags; // summary of events relevant in interrupt + // handlers (signals pending, user debugging + // enabled, etc.) + // (accessed from assembler code -- don't + // move!) struct thread *all_next; struct thread *team_next; struct thread *queue_next; /* i.e. run queue, release queue, etc. */ @@ -268,4 +274,16 @@ struct thread *tail; }; + +#endif // !_ASSEMBLER + + +// bits for the thread::flags field +#define THREAD_FLAGS_SIGNALS_PENDING 0x01 +#define THREAD_FLAGS_DEBUG_THREAD 0x02 +#define THREAD_FLAGS_DEBUGGER_INSTALLED 0x04 +#define THREAD_FLAGS_BREAKPOINTS_DEFINED 0x08 +#define THREAD_FLAGS_BREAKPOINTS_INSTALLED 0x10 + + #endif /* _KERNEL_THREAD_TYPES_H */ Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/user_debugger.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/user_debugger.h 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/user_debugger.h 2007-12-05 23:17:20 UTC (rev 23066) @@ -144,6 +144,7 @@ void init_user_debug(); + // debug event callbacks void user_debug_pre_syscall(uint32 syscall, void *args); @@ -155,6 +156,7 @@ void user_debug_stop_thread(); void user_debug_team_created(team_id teamID); void user_debug_team_deleted(team_id teamID, port_id debuggerPort); +void user_debug_update_new_thread_flags(thread_id threadID); void user_debug_thread_created(thread_id threadID); void user_debug_thread_deleted(team_id teamID, thread_id threadID); void user_debug_image_created(const image_info *imageInfo); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-05 23:17:20 UTC (rev 23066) @@ -613,6 +613,15 @@ } +bool +arch_has_breakpoints(struct arch_team_debug_info *info) +{ + // Reading info->dr7 is atomically, so we don't need to lock. The caller + // has to ensure, that the info doesn't go away. + return (info->dr7 != X86_BREAKPOINTS_DISABLED_DR7); +} + + #if KERNEL_BREAKPOINTS status_t @@ -707,6 +716,8 @@ // No need to have that here in the code executed for ever kernel->user // mode switch. + atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_INSTALLED); + RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); RELEASE_THREAD_LOCK(); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp 2007-12-05 23:17:20 UTC (rev 23066) @@ -23,6 +23,8 @@ #include #include +#include + //#define TRACE_USER_DEBUGGER #ifdef TRACE_USER_DEBUGGER # define TRACE(x) dprintf x @@ -109,6 +111,96 @@ } +/*! Updates the thread::flags field according to what user debugger flags are + set for the thread. + Interrupts must be disabled and the thread lock must be held. +*/ +static void +update_thread_user_debug_flag(struct thread* thread) +{ + if (atomic_get(&thread->debug_info.flags) + & (B_THREAD_DEBUG_STOP | B_THREAD_DEBUG_SINGLE_STEP)) { + atomic_or(&thread->flags, THREAD_FLAGS_DEBUG_THREAD); + } else + atomic_and(&thread->flags, ~THREAD_FLAGS_DEBUG_THREAD); +} + + +/*! Updates the thread::flags THREAD_FLAGS_BREAKPOINTS_DEFINED bit of the + current thread. + Interrupts must be disabled and the team lock must be held. +*/ +static void +update_thread_breakpoints_flag() +{ + struct thread* thread = thread_get_current_thread(); + struct team* team = thread->team; + + if (arch_has_breakpoints(&team->debug_info.arch_info)) + atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_DEFINED); + else + atomic_and(&thread->flags, ~THREAD_FLAGS_BREAKPOINTS_DEFINED); +} + + +/*! Updates the thread::flags THREAD_FLAGS_BREAKPOINTS_DEFINED bit of all + threads of the current team. + Interrupts must be disabled and the team lock must be held. +*/ +static void +update_threads_breakpoints_flag() +{ + InterruptsSpinLocker _(team_spinlock); + + struct team* team = thread_get_current_thread()->team; + struct thread* thread = team->thread_list; + + if (arch_has_breakpoints(&team->debug_info.arch_info)) { + for (; thread != NULL; thread = thread->team_next) + atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_DEFINED); + } else { + for (; thread != NULL; thread = thread->team_next) + atomic_and(&thread->flags, ~THREAD_FLAGS_BREAKPOINTS_DEFINED); + } +} + + +/*! Updates the thread::flags B_TEAM_DEBUG_DEBUGGER_INSTALLED bit of the + current thread. + Interrupts must be disabled and the team lock must be held. +*/ +static void +update_thread_debugger_installed_flag() +{ + struct thread* thread = thread_get_current_thread(); + struct team* team = thread->team; + + if (atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_DEBUGGER_INSTALLED) + atomic_or(&thread->flags, THREAD_FLAGS_DEBUGGER_INSTALLED); + else + atomic_and(&thread->flags, ~THREAD_FLAGS_DEBUGGER_INSTALLED); +} + + +/*! Updates the thread::flags THREAD_FLAGS_DEBUGGER_INSTALLED bit of all + threads of the given team. + Interrupts must be disabled and the team lock must be held. +*/ +static void +update_threads_debugger_installed_flag(struct team* team) +{ + struct thread* thread = team->thread_list; + + if (atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_DEBUGGER_INSTALLED) { + for (; thread != NULL; thread = thread->team_next) + atomic_or(&thread->flags, THREAD_FLAGS_DEBUGGER_INSTALLED); + } else { + for (; thread != NULL; thread = thread->team_next) + atomic_and(&thread->flags, ~THREAD_FLAGS_DEBUGGER_INSTALLED); + } +} + + /** * For the first initialization the function must be called with \a initLock * set to \c true. If it would be possible that another thread accesses the @@ -379,6 +471,8 @@ threadFlags |= B_THREAD_DEBUG_STOPPED; atomic_set(&thread->debug_info.flags, threadFlags); + update_thread_user_debug_flag(thread); + RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); RELEASE_THREAD_LOCK(); restore_interrupts(state); @@ -519,6 +613,8 @@ // unset the "stopped" state atomic_and(&thread->debug_info.flags, ~B_THREAD_DEBUG_STOPPED); + update_thread_user_debug_flag(thread); + } else { // the debugger is gone: cleanup our info completely threadDebugInfo = thread->debug_info; @@ -745,6 +841,29 @@ void +user_debug_update_new_thread_flags(thread_id threadID) +{ + // Update thread::flags of the thread. + + InterruptsLocker interruptsLocker; + + SpinLocker threadLocker(thread_spinlock); + + struct thread *thread = thread_get_thread_struct_locked(threadID); + if (!thread) + return; + + update_thread_user_debug_flag(thread); + + threadLocker.Unlock(); + + SpinLocker teamLocker(team_spinlock); + update_thread_breakpoints_flag(); + update_thread_debugger_installed_flag(); +} + + +void user_debug_thread_created(thread_id threadID) { // check, if a debugger is installed and is interested in thread events @@ -976,6 +1095,9 @@ destroyDebugInfo = true; } + // update the thread::flags fields + update_threads_debugger_installed_flag(nubThread->team); + RELEASE_TEAM_DEBUG_INFO_LOCK(nubThread->team->debug_info); RELEASE_TEAM_LOCK(); restore_interrupts(state); @@ -1476,6 +1598,9 @@ if (result == B_OK) result = arch_set_breakpoint(address); + if (result == B_OK) + update_threads_breakpoints_flag(); + // prepare the reply reply.set_breakpoint.error = result; replySize = sizeof(reply.set_breakpoint); @@ -1501,6 +1626,9 @@ if (result == B_OK) result = arch_clear_breakpoint(address); + if (result == B_OK) + update_threads_breakpoints_flag(); + break; } @@ -1527,6 +1655,9 @@ if (result == B_OK) result = arch_set_watchpoint(address, type, length); + if (result == B_OK) + update_threads_breakpoints_flag(); + // prepare the reply reply.set_watchpoint.error = result; replySize = sizeof(reply.set_watchpoint); @@ -1552,6 +1683,9 @@ if (result == B_OK) result = arch_clear_watchpoint(address); + if (result == B_OK) + update_threads_breakpoints_flag(); + break; } @@ -1790,7 +1924,7 @@ Interrupts must be disabled and the team debug info lock of the team to be debugged must be held. The function will release the lock, but leave - interrupts disabled. + interrupts disabled. The team lock must be held, too. The function also clears the arch specific team and thread debug infos (including among other things formerly set break/watchpoints). @@ -1833,6 +1967,9 @@ } RELEASE_THREAD_LOCK(); + + // update the thread::flags fields + update_threads_debugger_installed_flag(team); } @@ -2218,6 +2355,8 @@ // set the flag that tells the thread to stop as soon as possible atomic_or(&thread->debug_info.flags, B_THREAD_DEBUG_STOP); + update_thread_user_debug_flag(thread); + switch (thread->state) { case B_THREAD_SUSPENDED: // thread suspended: wake it up @@ -2272,10 +2411,16 @@ // that we install a break/watchpoint the debugger doesn't know about. // set the break/watchpoint + status_t result; if (watchpoint) - return arch_set_watchpoint(address, type, length); + result = arch_set_watchpoint(address, type, length); else - return arch_set_breakpoint(address); + result = arch_set_breakpoint(address); + + if (result == B_OK) + update_threads_breakpoints_flag(); + + return result; } @@ -2297,8 +2442,14 @@ // that we clear a break/watchpoint the debugger has just installed. // clear the break/watchpoint + status_t result; if (watchpoint) - return arch_clear_watchpoint(address); + result = arch_clear_watchpoint(address); else - return arch_clear_breakpoint(address); + result = arch_clear_breakpoint(address); + + if (result == B_OK) + update_threads_breakpoints_flag(); + + return result; } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp 2007-12-05 23:17:20 UTC (rev 23066) @@ -54,6 +54,28 @@ uint32 flags); +/*! Updates the thread::flags field according to what signals are pending. + Interrupts must be disabled and the thread lock must be held. +*/ +static void +update_thread_signals_flag(struct thread* thread) +{ + if (atomic_get(&thread->sig_pending) & ~atomic_get(&thread->sig_block_mask)) + atomic_or(&thread->flags, THREAD_FLAGS_SIGNALS_PENDING); + else + atomic_and(&thread->flags, ~THREAD_FLAGS_SIGNALS_PENDING); +} + + +static void +update_current_thread_signals_flag() +{ + InterruptsSpinLocker locker(thread_spinlock); + + update_thread_signals_flag(thread_get_current_thread()); +} + + static bool notify_debugger(struct thread *thread, int signal, struct sigaction *handler, bool deadly) @@ -246,6 +268,8 @@ (handler->sa_mask | SIGNAL_TO_MASK(signal)) & BLOCKABLE_SIGNALS); } + update_current_thread_signals_flag(); + return reschedule; } @@ -253,6 +277,8 @@ if (restart) arch_check_syscall_restart(thread); + update_current_thread_signals_flag(); + return reschedule; } @@ -358,6 +384,9 @@ } break; } + + update_thread_signals_flag(thread); + return B_OK; } @@ -482,6 +511,8 @@ default: return B_BAD_VALUE; } + + update_current_thread_signals_flag(); } if (oldSet != NULL) @@ -631,6 +662,8 @@ state = disable_interrupts(); GRAB_THREAD_LOCK(); + update_thread_signals_flag(thread); + scheduler_reschedule(); RELEASE_THREAD_LOCK(); @@ -643,6 +676,8 @@ // restore the original block mask atomic_set(&thread->sig_block_mask, oldMask); + update_current_thread_signals_flag(); + // we're not supposed to actually succeed // ToDo: could this get us into trouble with SA_RESTART handlers? return B_INTERRUPTED; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-05 22:00:06 UTC (rev 23065) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-05 23:17:20 UTC (rev 23066) @@ -220,6 +220,7 @@ else strcpy(thread->name, "unnamed thread"); + thread->flags = 0; thread->id = threadID >= 0 ? threadID : allocate_thread_id(); thread->team = NULL; thread->cpu = cpu; @@ -501,6 +502,8 @@ kill_thread(thread->id); } + user_debug_update_new_thread_flags(thread->id); + // copy the user entry over to the args field in the thread struct // the function this will call will immediately switch the thread into // user space. @@ -1465,7 +1468,7 @@ { struct thread *thread = thread_get_current_thread(); - TRACE(("thread_atkernel_entry: entry thread %ld\n", thread->id)); + TRACE(("thread_at_kernel_entry: entry thread %ld\n", thread->id)); // track user time now = system_time(); @@ -1487,7 +1490,7 @@ cpu_status state; bigtime_t now; - TRACE(("thread_atkernel_exit: exit thread %ld\n", thread->id)); + TRACE(("thread_at_kernel_exit: exit thread %ld\n", thread->id)); if (handle_signals(thread)) { state = disable_interrupts(); @@ -1511,7 +1514,27 @@ } +/*! The quick version of thread_kernel_exit(), in case no signals are pending + and no debugging shall be done. + Interrupts are disabled in this case. +*/ void +thread_at_kernel_exit_no_signals(void) +{ + struct thread *thread = thread_get_current_thread(); + + TRACE(("thread_at_kernel_exit_no_signals: exit thread %ld\n", thread->id)); + + thread->in_kernel = false; + + // track kernel time + bigtime_t now = system_time(); + thread->kernel_time += now - thread->last_time; + thread->last_time = now; +} + + +void thread_reset_for_exec(void) { struct thread *thread = thread_get_current_thread(); From bonefish at mail.berlios.de Thu Dec 6 00:25:01 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Dec 2007 00:25:01 +0100 Subject: [Haiku-commits] r23067 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712052325.lB5NP16w028193@sheep.berlios.de> Author: bonefish Date: 2007-12-06 00:25:01 +0100 (Thu, 06 Dec 2007) New Revision: 23067 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23067&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S Log: Some more work on the syscall interrupt handler: * Reintroduced user debugging support functionality, including syscall tracing. * Use the thread::flags field to skip calling functions, if possible. * Small optimizations. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-05 23:17:20 UTC (rev 23066) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-05 23:25:01 UTC (rev 23067) @@ -7,6 +7,7 @@ ** Distributed under the terms of the NewOS License. */ +#include #include #include @@ -170,7 +171,7 @@ push %gs // save %eax, the number of the syscall - movl %eax, %ecx + movl %eax, %esi movl $KERNEL_DATA_SEG,%eax cld @@ -185,18 +186,25 @@ call x86_push_iframe_current_thread addl $4, %esp + // disable breakpoints, if installed + movl %dr3, %edi // thread pointer (pointer to thread::flags) + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, (%edi) + jz skip_debug_at_kernel_entry + call i386_exit_user_debug_at_kernel_entry + skip_debug_at_kernel_entry: + call system_time push %edx push %eax call thread_at_kernel_entry - add $8, %esp + // leave the time on the stack (needed for post syscall debugging) sti // enable interrupts - cmp $SYSCALL_COUNT, %ecx // check syscall number + cmp $SYSCALL_COUNT, %esi // check syscall number jae bad_syscall_number movl $kSyscallInfos, %eax // get syscall info - lea (%eax, %ecx, 8), %esi + lea (%eax, %esi, 8), %esi // copy parameters onto this stack subl $80, %esp // leave some room for the syscall params @@ -217,22 +225,44 @@ test %eax, %eax jne bad_syscall_params + // pre syscall debugging + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) + jnz do_pre_syscall_debug + pre_syscall_debug_done: + // call the syscall function call *(%esi) - bad_syscall_params: - addl $80, %esp // remove syscall params from stack - - bad_syscall_number: // overwrite the values of %eax and %edx on the stack (the syscall return // value) movl %edx, 36(%ebp) movl %eax, 44(%ebp) - call thread_at_kernel_exit + // post syscall debugging + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) + jnz do_post_syscall_debug + post_syscall_debug_done: + bad_syscall_params: + bad_syscall_number: + // if no signals are pending and the thread shall not be debugged, we can + // use the quick kernel exit function + testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD), (%edi) + jnz kernel_exit_handle_signals + cli // disable interrupts + call thread_at_kernel_exit_no_signals + kernel_exit_done: + + // install breakpoints, if defined + testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, (%edi) + jz skip_debug_at_kernel_exit + push %ebp + call i386_init_user_debug_at_kernel_exit + skip_debug_at_kernel_exit: + + movl %ebp, %esp // remove all parameters from the stack + // pop iframe - cli // disable interrupts call x86_pop_iframe_current_thread sti // enable interrupts @@ -245,7 +275,36 @@ addl $16,%esp // ignore the vector, error code, and original eax/edx values iret + do_pre_syscall_debug: + movl %esp, %eax // syscall parameters + push %eax + movl 48(%ebp), %eax // syscall number + push %eax + call user_debug_pre_syscall + addl $8, %esp + jmp pre_syscall_debug_done + do_post_syscall_debug: + movl -4(%ebp), %ecx // syscall start time + push %ecx + movl -8(%ebp), %ecx + push %ecx + push %edx // syscall return value + push %eax + lea 16(%esp), %eax // syscall parameters + push %eax + movl 48(%ebp), %eax // syscall number + push %eax + call user_debug_post_syscall + addl $8, %esp + jmp post_syscall_debug_done + + kernel_exit_handle_signals: + call thread_at_kernel_exit + cli // disable interrupts + jmp kernel_exit_done + + _interrupt_stack_offset: .long 0 // this value will be maintained by the function below From axeld at mail.berlios.de Thu Dec 6 21:40:25 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 6 Dec 2007 21:40:25 +0100 Subject: [Haiku-commits] r23068 - in haiku/trunk: build/jam src/bin Message-ID: <200712062040.lB6KePYJ025659@sheep.berlios.de> Author: axeld Date: 2007-12-06 21:40:24 +0100 (Thu, 06 Dec 2007) New Revision: 23068 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23068&view=rev Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/src/bin/Jamfile haiku/trunk/src/bin/cal.c Log: * Made cal.c compile, and fixed warnings. * Added it to the build, and the image. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-12-05 23:25:01 UTC (rev 23067) +++ haiku/trunk/build/jam/HaikuImage 2007-12-06 20:40:24 UTC (rev 23068) @@ -23,9 +23,9 @@ GPL_ONLY = "" ; } -BEOS_BIN = "[" addattr alert arp base64 basename bc beep bison bzip2 cat catattr - chgrp chmod chop chown cksum clear clockconfig cmp comm compress cp copyattr - $(X86_ONLY)CortexAddOnHost +BEOS_BIN = "[" addattr alert arp base64 basename bc beep bison bzip2 cal cat + catattr 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 echo eject env error expand expr expr factor false fdinfo ffm find finddir fmt fold fortune frcode ftp funzip fwcontrol Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2007-12-05 23:25:01 UTC (rev 23067) +++ haiku/trunk/src/bin/Jamfile 2007-12-06 20:40:24 UTC (rev 23068) @@ -17,6 +17,7 @@ # standard commands that don't need any additional library StdBinCommands + cal.c catattr.cpp chop.c clear.c Modified: haiku/trunk/src/bin/cal.c =================================================================== --- haiku/trunk/src/bin/cal.c 2007-12-05 23:25:01 UTC (rev 23067) +++ haiku/trunk/src/bin/cal.c 2007-12-06 20:40:24 UTC (rev 23068) @@ -34,14 +34,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static char copyright[] = "@(#) Copyright (c) 1989, 1993, 1994\n\n - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ -#ifndef lint -static char sccsid[] = "@(#)cal.c 8.4 (Berkeley) 4/2/94"; -#endif /* not lint */ - #include #include @@ -96,7 +88,7 @@ char j_day_headings[] = " "; /* leap year -- account for gregorian reformation in 1752 */ -#define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && ((yr) % 100) || !((yr) % 400)) +#define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : (!((yr) % 4) && ((yr) % 100)) || !((yr) % 400)) /* number of centuries since 1700, not inclusive */ #define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0) @@ -109,16 +101,16 @@ int julian; -void ascii_day __P((char *, int)); -void center __P((char *, int, int)); -void day_array __P((int, int, int *)); -int day_in_week __P((int, int, int)); -int day_in_year __P((int, int, int)); -void j_yearly __P((int)); -void monthly __P((int, int)); -void trim_trailing_spaces __P((char *)); -void usage __P((void)); -void yearly __P((int)); +void ascii_day(char *, int); +void center(char *, int, int); +void day_array(int, int, int *); +int day_in_week(int, int, int); +int day_in_year(int, int, int); +void j_yearly(int); +void monthly(int, int); +void trim_trailing_spaces(char *); +void usage(void); +void yearly(int); int main(argc, argv) From bonefish at mail.berlios.de Thu Dec 6 22:05:50 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Thu, 6 Dec 2007 22:05:50 +0100 Subject: [Haiku-commits] r23069 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200712062105.lB6L5oj4028089@sheep.berlios.de> Author: bonefish Date: 2007-12-06 22:05:49 +0100 (Thu, 06 Dec 2007) New Revision: 23069 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23069&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread_types.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c Log: * Removed per thread iframe stack. The iframes are still accessible by iterating through the stack frames. Added a "type" field to the iframe structure, so that it can be distinguished from a normal stack frame. * Don't reenable interrupts at the end of the syscall handler. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-06 21:05:49 UTC (rev 23069) @@ -9,10 +9,14 @@ #define _KERNEL_ARCH_x86_CPU_H +#ifndef _ASSEMBLER + #include #include +#endif // !_ASSEMBLER + // MSR registers (possibly Intel specific) #define IA32_MSR_APIC_BASE 0x1b @@ -81,6 +85,15 @@ #define IA32_MTR_WRITE_PROTECTED 5 #define IA32_MTR_WRITE_BACK 6 + +// iframe types +#define IFRAME_TYPE_SYSCALL 0x1 +#define IFRAME_TYPE_OTHER 0x2 +#define IFRAME_TYPE_MASK 0xf + + +#ifndef _ASSEMBLER + typedef struct x86_cpu_module_info { module_info info; uint32 (*count_mtrrs)(void); @@ -110,6 +123,7 @@ }; struct iframe { + uint32 type; // iframe type uint32 gs; uint32 fs; uint32 es; @@ -277,5 +291,6 @@ } // extern "C" { #endif +#endif // !_ASSEMBLER #endif /* _KERNEL_ARCH_x86_CPU_H */ Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-06 21:05:49 UTC (rev 23069) @@ -16,10 +16,6 @@ extern "C" { #endif -void x86_push_iframe(struct iframe_stack *stack, struct iframe *frame); -void x86_push_iframe_current_thread(struct iframe *frame); -void x86_pop_iframe(struct iframe_stack *stack); -void x86_pop_iframe_current_thread(void); struct iframe *i386_get_user_iframe(void); void *x86_next_page_directory(struct thread *from, struct thread *to); Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread_types.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread_types.h 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread_types.h 2007-12-06 21:05:49 UTC (rev 23069) @@ -19,13 +19,6 @@ uint32 *ss; }; -#define IFRAME_TRACE_DEPTH 4 - -struct iframe_stack { - struct iframe *frames[IFRAME_TRACE_DEPTH]; - int32 index; -}; - // architecture specific thread info struct arch_thread { struct farcall current_stack; @@ -33,9 +26,6 @@ // 512 byte floating point save point - this must be 16 byte aligned uint8 fpu_state[512]; - - // used to track interrupts on this thread - struct iframe_stack iframes; } _ALIGNED(16); struct arch_team { Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_debug.cpp 2007-12-06 21:05:49 UTC (rev 23069) @@ -142,11 +142,56 @@ } +static bool +is_kernel_stack_address(struct thread* thread, addr_t address) +{ + // We don't have a thread pointer in the early boot process, but then we are + // on the kernel stack for sure. + if (thread == NULL) + return IS_KERNEL_ADDRESS(address); + + return address >= thread->kernel_stack_base + && address < thread->kernel_stack_base + KERNEL_STACK_SIZE; +} + + +static bool +is_iframe(struct thread* thread, addr_t frame) +{ + return is_kernel_stack_address(thread, frame) + && (*(addr_t*)frame & ~IFRAME_TYPE_MASK) == 0; +} + + +static struct iframe * +find_previous_iframe(struct thread *thread, addr_t frame) +{ + // iterate backwards through the stack frames, until we hit an iframe + while (is_kernel_stack_address(thread, frame)) { + if (is_iframe(thread, frame)) + return (struct iframe*)frame; + + frame = *(addr_t*)frame; + } + + return NULL; +} + + +static struct iframe* +get_previous_iframe(struct thread* thread, struct iframe* frame) +{ + if (frame == NULL) + return NULL; + + return find_previous_iframe(thread, frame->ebp); +} + + static int stack_trace(int argc, char **argv) { uint32 previousLocations[NUM_PREVIOUS_LOCATIONS]; - struct iframe_stack *frameStack; struct thread *thread = NULL; addr_t oldPageDirectory = 0; uint32 ebp = 0; @@ -186,12 +231,6 @@ ebp = x86_read_ebp(); } - // We don't have a thread pointer early in the boot process - if (thread != NULL) - frameStack = &thread->arch_info.iframes; - else - frameStack = &gBootFrameStack; - if (thread != NULL) { kprintf("stack trace for thread 0x%lx \"%s\"\n", thread->id, thread->name); @@ -205,17 +244,13 @@ kprintf("frame caller :function + offset\n"); + bool onKernelStack = true; + for (;;) { - bool isIFrame = false; - // see if the ebp matches the iframe - for (i = 0; i < frameStack->index; i++) { - if (ebp == ((addr_t)frameStack->frames[i])) { - // it's an iframe - isIFrame = true; - } - } + onKernelStack = onKernelStack + && is_kernel_stack_address(thread, ebp); - if (isIFrame) { + if (onKernelStack && is_iframe(thread, ebp)) { struct iframe *frame = (struct iframe *)ebp; print_iframe(frame); @@ -275,17 +310,13 @@ return 0; } - // We don't have a thread pointer early in the boot process if (thread != NULL) - frameStack = &thread->arch_info.iframes; - else - frameStack = &gBootFrameStack; - - if (thread != NULL) kprintf("iframes for thread 0x%lx \"%s\"\n", thread->id, thread->name); - for (i = 0; i < frameStack->index; i++) { - print_iframe(frameStack->frames[i]); + struct iframe* frame = find_previous_iframe(thread, x86_read_ebp()); + while (frame != NULL) { + print_iframe(frame); + frame = get_previous_iframe(thread, frame); } return 0; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-06 21:05:49 UTC (rev 23069) @@ -99,8 +99,6 @@ #define MAX_ARGS 16 -struct iframe_stack gBootFrameStack; - typedef struct { uint32 a, b; } desc_table; @@ -362,11 +360,6 @@ state = disable_interrupts(); - if (thread) - x86_push_iframe(&thread->arch_info.iframes, &frame); - else - x86_push_iframe(&gBootFrameStack, &frame); - if (frame.cs == USER_CODE_SEG) { i386_exit_user_debug_at_kernel_entry(); thread_at_kernel_entry(system_time()); @@ -597,11 +590,6 @@ disable_interrupts(); // dprintf("0x%x cpu %d!\n", thread_get_current_thread_id(), smp_get_current_cpu()); - - if (thread) - x86_pop_iframe(&thread->arch_info.iframes); - else - x86_pop_iframe(&gBootFrameStack); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-06 21:05:49 UTC (rev 23069) @@ -9,6 +9,7 @@ #include #include +#include #include #include "syscall_numbers.h" @@ -103,6 +104,7 @@ push %es push %fs push %gs + push $IFRAME_TYPE_OTHER movl $KERNEL_DATA_SEG,%eax cld movl %eax,%ds @@ -114,6 +116,7 @@ kernel_stack: movl %esp, %ebp // frame pointer is the iframe call i386_handle_trap + addl $4, %esp // skip iframe type pop %gs addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment pop %es @@ -169,6 +172,7 @@ push %es push %fs push %gs + push $IFRAME_TYPE_OTHER // save %eax, the number of the syscall movl %eax, %esi @@ -180,13 +184,8 @@ movl %esp, %ebp // frame pointer is the iframe - // push iframe - cli // disable interrupts - push %ebp - call x86_push_iframe_current_thread - addl $4, %esp - // disable breakpoints, if installed + cli // disable interrupts movl %dr3, %edi // thread pointer (pointer to thread::flags) testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, (%edi) jz skip_debug_at_kernel_entry @@ -209,7 +208,7 @@ // copy parameters onto this stack subl $80, %esp // leave some room for the syscall params - movl 76(%ebp), %eax // get the address of the syscall parameters + movl 80(%ebp), %eax // get the address of the syscall parameters addl $4, %eax cmp $KERNEL_BASE, %eax jae bad_syscall_params @@ -235,8 +234,8 @@ // overwrite the values of %eax and %edx on the stack (the syscall return // value) - movl %edx, 36(%ebp) - movl %eax, 44(%ebp) + movl %edx, 40(%ebp) + movl %eax, 48(%ebp) // post syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) @@ -262,10 +261,7 @@ movl %ebp, %esp // remove all parameters from the stack - // pop iframe - call x86_pop_iframe_current_thread - sti // enable interrupts - + addl $4, %esp // skip iframe type pop %gs addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment pop %es @@ -278,7 +274,7 @@ do_pre_syscall_debug: movl %esp, %eax // syscall parameters push %eax - movl 48(%ebp), %eax // syscall number + movl 52(%ebp), %eax // syscall number push %eax call user_debug_pre_syscall addl $8, %esp @@ -293,7 +289,7 @@ push %eax lea 16(%esp), %eax // syscall parameters push %eax - movl 48(%ebp), %eax // syscall number + movl 52(%ebp), %eax // syscall number push %eax call user_debug_post_syscall addl $8, %esp @@ -364,8 +360,9 @@ */ FUNCTION(i386_restore_frame_from_syscall): - addl $4, %esp // make the iframe our current stack position (we don't need the + addl $8, %esp // make the iframe our current stack position (we don't need the // return address anymore, as we will use the one of the frame) + // also skip iframe type pop %gs // recreate the frame environment addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment pop %es Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-06 20:40:24 UTC (rev 23068) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-06 21:05:49 UTC (rev 23069) @@ -62,39 +62,32 @@ } -void -x86_push_iframe(struct iframe_stack *stack, struct iframe *frame) +static struct iframe * +find_previous_iframe(addr_t frame) { - ASSERT(stack->index < IFRAME_TRACE_DEPTH); - stack->frames[stack->index++] = frame; -} - - -void -x86_push_iframe_current_thread(struct iframe *frame) -{ struct thread *thread = thread_get_current_thread(); - struct iframe_stack *stack = &thread->arch_info.iframes; - ASSERT(stack->index < IFRAME_TRACE_DEPTH); - stack->frames[stack->index++] = frame; -} + // iterate backwards through the stack frames, until we hit an iframe + while (frame >= thread->kernel_stack_base + && frame < thread->kernel_stack_base + KERNEL_STACK_SIZE) { + addr_t previousFrame = *(addr_t*)frame; + if ((previousFrame & ~IFRAME_TYPE_MASK) == 0) + return (struct iframe*)frame; -void -x86_pop_iframe(struct iframe_stack *stack) -{ - ASSERT(stack->index > 0); - stack->index--; + frame = previousFrame; + } + + return NULL; } -void -x86_pop_iframe_current_thread(void) +static struct iframe* +get_previous_iframe(struct iframe* frame) { - struct thread *thread = thread_get_current_thread(); - struct iframe_stack *stack = &thread->arch_info.iframes; - ASSERT(stack->index > 0); - stack->index--; + if (frame == NULL) + return NULL; + + return find_previous_iframe(frame->ebp); } @@ -104,14 +97,10 @@ sure that such iframe exists; ie. from syscalls, but usually not from standard kernel threads. */ -static struct iframe * +static struct iframe* get_current_iframe(void) { - struct thread *thread = thread_get_current_thread(); - - ASSERT(thread->arch_info.iframes.index >= 0); - return thread->arch_info.iframes.frames[ - thread->arch_info.iframes.index - 1]; + return find_previous_iframe(x86_read_ebp()); } @@ -125,13 +114,12 @@ struct iframe * i386_get_user_iframe(void) { - struct thread *thread = thread_get_current_thread(); - int i; + struct iframe* frame = get_current_iframe(); - for (i = thread->arch_info.iframes.index - 1; i >= 0; i--) { - struct iframe *frame = thread->arch_info.iframes.frames[i]; + while (frame != NULL) { if (frame->cs == USER_CODE_SEG) return frame; + frame = get_previous_iframe(frame); } return NULL; @@ -388,10 +376,6 @@ disable_interrupts(); - // When entering the userspace, the iframe stack needs to be empty. After - // an exec() it'll still contain the iframe from the syscall, though. - t->arch_info.iframes.index = 0; - i386_set_tss_and_kstack(t->kernel_stack_base + KERNEL_STACK_SIZE); // set the CPU dependent GDT entry for TLS From jackburton at mail.berlios.de Thu Dec 6 22:09:35 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 6 Dec 2007 22:09:35 +0100 Subject: [Haiku-commits] r23070 - haiku/trunk/src/servers/app Message-ID: <200712062109.lB6L9Zpo028379@sheep.berlios.de> Author: jackburton Date: 2007-12-06 22:09:35 +0100 (Thu, 06 Dec 2007) New Revision: 23070 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23070&view=rev Modified: haiku/trunk/src/servers/app/DesktopSettings.cpp Log: Also update the ui_color for menu backgrounds, when using set_menu_info. Update the menu_info neverthless, when setting the ui_color for menu backgrounds. Fixes bug #550. Modified: haiku/trunk/src/servers/app/DesktopSettings.cpp =================================================================== --- haiku/trunk/src/servers/app/DesktopSettings.cpp 2007-12-06 21:05:49 UTC (rev 23069) +++ haiku/trunk/src/servers/app/DesktopSettings.cpp 2007-12-06 21:09:35 UTC (rev 23070) @@ -391,7 +391,9 @@ DesktopSettingsPrivate::SetMenuInfo(const menu_info& info) { fMenuInfo = info; - Save(kAppearanceSettings); + // Also update the ui_color + SetUIColor(B_MENU_BACKGROUND_COLOR, info.background_color); + // SetUIColor already saves the settings } @@ -486,6 +488,10 @@ if (index < 0 || index >= kNumColors) return; fShared.colors[index] = color; + // TODO: deprecate the background_color member of the menu_info struct, + // otherwise we have to keep this duplication... + if (which == B_MENU_BACKGROUND_COLOR) + fMenuInfo.background_color = color; Save(kAppearanceSettings); } From jackburton at mail.berlios.de Thu Dec 6 22:17:46 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Thu, 6 Dec 2007 22:17:46 +0100 Subject: [Haiku-commits] r23071 - haiku/trunk/src/preferences/menu Message-ID: <200712062117.lB6LHk0p028840@sheep.berlios.de> Author: jackburton Date: 2007-12-06 22:17:46 +0100 (Thu, 06 Dec 2007) New Revision: 23071 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23071&view=rev Modified: haiku/trunk/src/preferences/menu/MenuBar.cpp Log: Set the low color to be the same as the view color, otherwise antialiased text won't work correctly (for example when you set a dark color). Modified: haiku/trunk/src/preferences/menu/MenuBar.cpp =================================================================== --- haiku/trunk/src/preferences/menu/MenuBar.cpp 2007-12-06 21:09:35 UTC (rev 23070) +++ haiku/trunk/src/preferences/menu/MenuBar.cpp 2007-12-06 21:17:46 UTC (rev 23071) @@ -117,7 +117,8 @@ font.SetSize(info.font_size); SetFont(&font); SetViewColor(info.background_color); - + SetLowColor(ViewColor()); + // force the menu to redraw InvalidateLayout(); Invalidate(); From leavengood at gmail.com Thu Dec 6 22:23:29 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Thu, 6 Dec 2007 16:23:29 -0500 Subject: [Haiku-commits] r23071 - haiku/trunk/src/preferences/menu In-Reply-To: <200712062117.lB6LHk0p028840@sheep.berlios.de> References: <200712062117.lB6LHk0p028840@sheep.berlios.de> Message-ID: On 12/6/07, jackburton at BerliOS wrote: > > Log: > Set the low color to be the same as the view color, otherwise > antialiased text won't work correctly (for example when you set a dark > color). I had noticed this a while ago but never reported a bug. Good job. Little details like this really make a difference. Ryan From mmlr at mail.berlios.de Thu Dec 6 22:36:16 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 6 Dec 2007 22:36:16 +0100 Subject: [Haiku-commits] r23072 - haiku/trunk/src/system/kernel/fs Message-ID: <200712062136.lB6LaG5J029991@sheep.berlios.de> Author: mmlr Date: 2007-12-06 22:36:15 +0100 (Thu, 06 Dec 2007) New Revision: 23072 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23072&view=rev Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp Log: First try at implementing driver rescans (this has been laying around my disk for quite some time). Modified: haiku/trunk/src/system/kernel/fs/devfs.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-12-06 21:17:46 UTC (rev 23071) +++ haiku/trunk/src/system/kernel/fs/devfs.cpp 2007-12-06 21:36:15 UTC (rev 23072) @@ -2476,3 +2476,34 @@ return publish_directory(sDeviceFileSystem, path); } + +extern "C" status_t +devfs_rescan_driver(const char *driverName) +{ + TRACE(("devfs_rescan_driver: %s\n", driverName)); + + // iterate over the drivers and search a matching driverName + struct hash_iterator i; + hash_open(sDeviceFileSystem->driver_hash, &i); + + driver_entry *driver = (driver_entry *)hash_next( + sDeviceFileSystem->driver_hash, &i); + while (driver) { + const char *name = strrchr(driver->path, '/'); + if (name == NULL) + name = driver->path; + else + name++; + + if (!strcmp(name, driverName)) { + hash_close(sDeviceFileSystem->driver_hash, &i, false); + // ToDo: force a uninit/init cycle on the driver if loaded + return load_driver(driver); + } + + driver = (driver_entry *)hash_next(sDeviceFileSystem->driver_hash, &i); + } + + hash_close(sDeviceFileSystem->driver_hash, &i, false); + return B_ENTRY_NOT_FOUND; +} From mmlr at mail.berlios.de Thu Dec 6 22:41:09 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 6 Dec 2007 22:41:09 +0100 Subject: [Haiku-commits] r23073 - haiku/trunk/headers/private/kernel/fs Message-ID: <200712062141.lB6Lf9Lm030278@sheep.berlios.de> Author: mmlr Date: 2007-12-06 22:41:08 +0100 (Thu, 06 Dec 2007) New Revision: 23073 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23073&view=rev Modified: haiku/trunk/headers/private/kernel/fs/devfs.h Log: Forgot the header change in the last commit. Modified: haiku/trunk/headers/private/kernel/fs/devfs.h =================================================================== --- haiku/trunk/headers/private/kernel/fs/devfs.h 2007-12-06 21:36:15 UTC (rev 23072) +++ haiku/trunk/headers/private/kernel/fs/devfs.h 2007-12-06 21:41:08 UTC (rev 23073) @@ -31,6 +31,7 @@ status_t devfs_unpublish_device(const char *path, bool disconnect); status_t devfs_publish_device(const char *path, void *ident, device_hooks *calls); status_t devfs_publish_directory(const char *path); +status_t devfs_rescan_driver(const char *driverName); #ifdef __cplusplus } From mmlr at mail.berlios.de Thu Dec 6 22:58:06 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Thu, 6 Dec 2007 22:58:06 +0100 Subject: [Haiku-commits] r23074 - in haiku/trunk: headers/private/kernel/util src/system/kernel/util Message-ID: <200712062158.lB6Lw6AB031793@sheep.berlios.de> Author: mmlr Date: 2007-12-06 22:58:06 +0100 (Thu, 06 Dec 2007) New Revision: 23074 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23074&view=rev Modified: haiku/trunk/headers/private/kernel/util/khash.h haiku/trunk/src/system/kernel/util/khash.c Log: Something else that has been laying around for some time. Implemented hash_grow() that can grow a hash table to a new table size. Automatic growing is commented out in hash_insert() since there needs to be a way to disallow growing in certain cases (i.e. where no allocations can be made). This is detailed in the ToDo at the top of the file. Modified: haiku/trunk/headers/private/kernel/util/khash.h =================================================================== --- haiku/trunk/headers/private/kernel/util/khash.h 2007-12-06 21:41:08 UTC (rev 23073) +++ haiku/trunk/headers/private/kernel/util/khash.h 2007-12-06 21:58:06 UTC (rev 23074) @@ -28,6 +28,7 @@ int compare_func(void *element, const void *key), uint32 hash_func(void *element, const void *key, uint32 range)); int hash_uninit(struct hash_table *table); +status_t hash_grow(struct hash_table *table, uint32 newSize); status_t hash_insert(struct hash_table *table, void *_element); status_t hash_remove(struct hash_table *table, void *_element); void hash_remove_current(struct hash_table *table, struct hash_iterator *iterator); Modified: haiku/trunk/src/system/kernel/util/khash.c =================================================================== --- haiku/trunk/src/system/kernel/util/khash.c 2007-12-06 21:41:08 UTC (rev 23073) +++ haiku/trunk/src/system/kernel/util/khash.c 2007-12-06 21:58:06 UTC (rev 23074) @@ -127,12 +127,54 @@ status_t +hash_grow(struct hash_table *table, uint32 newSize) +{ + struct hash_element **newTable; + uint32 index; + void *start; + bool status; + + if (table->table_size >= newSize) + return B_OK; + + newTable = (struct hash_element **)malloc(sizeof(void *) * newSize); + + if (newTable == NULL) + return B_NO_MEMORY; + + for (index = 0; index < newSize; index++) + newTable[index] = NULL; + + // rehash all the entries and add them to the new table + for (index = 0; index < table->table_size; index++) { + void *element; + void *next; + + for (element = table->table[index]; element != NULL; element = next) { + uint32 hash = table->hash_func(element, NULL, newSize); + next = NEXT(table, element); + PUT_IN_NEXT(table, element, newTable[hash]); + newTable[hash] = (struct hash_element *)element; + } + } + + free(table->table); + + table->table = newTable; + table->table_size = newSize; + + TRACE(("hash_grow: grown table %p, new size %lu\n", table, newSize)); + return B_OK; +} + + +status_t hash_insert(struct hash_table *table, void *element) { uint32 hash; ASSERT(table != NULL && element != NULL); - TRACE(("hash_insert: table 0x%x, element 0x%x\n", table, element)); + TRACE(("hash_insert: table %p, element %p\n", table, element)); hash = table->hash_func(element, NULL, table->table_size); PUT_IN_NEXT(table, element, table->table[hash]); @@ -140,8 +182,12 @@ table->num_elements++; // ToDo: resize hash table if it's grown too much! + /*if ((uint32)table->num_elements > table->table_size * 4) { + dprintf("hash_insert: table has grown too much: %d in %d\n", table->num_elements, (int)table->table_size); + hash_grow(table, (uint32)table->num_elements); + }*/ - return 0; + return B_OK; } From korli at mail.berlios.de Fri Dec 7 20:30:35 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 7 Dec 2007 20:30:35 +0100 Subject: [Haiku-commits] r23075 - haiku/trunk/headers/posix Message-ID: <200712071930.lB7JUZZu032617@sheep.berlios.de> Author: korli Date: 2007-12-07 20:30:34 +0100 (Fri, 07 Dec 2007) New Revision: 23075 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23075&view=rev Modified: haiku/trunk/headers/posix/pthread.h Log: applied patch by kaliber Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2007-12-06 21:58:06 UTC (rev 23074) +++ haiku/trunk/headers/posix/pthread.h 2007-12-07 19:30:34 UTC (rev 23075) @@ -21,7 +21,7 @@ typedef struct _pthread_barrierattr *pthread_barrierattr_t; typedef struct _pthread_spinlock *pthread_spinlock_t; -struct pthread_once { +struct _pthread_once { int state; pthread_mutex_t mutex; }; From korli at mail.berlios.de Fri Dec 7 22:03:01 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Fri, 7 Dec 2007 22:03:01 +0100 Subject: [Haiku-commits] r23076 - in haiku/trunk: build/jam headers/posix src/system/libroot/posix/pthread src/tests/system/libroot/posix/posixtestsuite src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once Message-ID: <200712072103.lB7L31Ra004608@sheep.berlios.de> Author: korli Date: 2007-12-07 22:02:59 +0100 (Fri, 07 Dec 2007) New Revision: 23076 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23076&view=rev Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-2.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-3.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/2-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/3-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/4-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/6-1.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/testfrmw.c haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/testfrmw.h Modified: haiku/trunk/build/jam/HaikuImage haiku/trunk/headers/posix/pthread.h haiku/trunk/src/system/libroot/posix/pthread/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/run_posix_tests.sh Log: added pthread_once() implementation and tests there is still a TODO on an init race condition Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/build/jam/HaikuImage 2007-12-07 21:02:59 UTC (rev 23076) @@ -456,6 +456,8 @@ pthread_key_create_3-1 ; AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_key_delete : pthread_key_delete_1-1 pthread_key_delete_1-2 pthread_key_delete_2-1 ; + AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_once + : pthread_once_1-1 pthread_once_1-2 pthread_once_1-3 pthread_once_2-1 ; AddFilesToHaikuImage home posixtestsuite conformance interfaces pthread_setspecific : pthread_setspecific_1-1 pthread_setspecific_1-2 ; } Modified: haiku/trunk/headers/posix/pthread.h =================================================================== --- haiku/trunk/headers/posix/pthread.h 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/headers/posix/pthread.h 2007-12-07 21:02:59 UTC (rev 23076) @@ -125,6 +125,7 @@ /* misc. functions */ extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); +extern int pthread_once(pthread_once_t *once_control, void (*init_routine)()); /* thread attributes functions */ extern int pthread_attr_destroy(pthread_attr_t *attr); Modified: haiku/trunk/src/system/libroot/posix/pthread/Jamfile =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/system/libroot/posix/pthread/Jamfile 2007-12-07 21:02:59 UTC (rev 23076) @@ -11,5 +11,6 @@ pthread_key.c pthread_mutex.c pthread_mutexattr.c + pthread_once.c ; Added: haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c =================================================================== --- haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/system/libroot/posix/pthread/pthread_once.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,31 @@ +/* +** Copyright 2007, J?r?me Duval. All rights reserved. +** Distributed under the terms of the MIT License. +*/ + + +#include +#include "pthread_private.h" + + +int +pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +{ + if (once_control->state == PTHREAD_NEEDS_INIT) { + // TODO race condition ? + if (once_control->mutex == NULL) { + if (pthread_mutex_init(&once_control->mutex, NULL) != 0) + return -1; + } + pthread_mutex_lock(&once_control->mutex); + + if (once_control->state == PTHREAD_NEEDS_INIT) { + init_routine(); + once_control->state = PTHREAD_DONE_INIT; + } + + pthread_mutex_unlock(&once_control->mutex); + } + return 0; +} + Modified: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/Jamfile 2007-12-07 21:02:59 UTC (rev 23076) @@ -6,6 +6,7 @@ SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_key_create ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_key_delete ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_getspecific ; +SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_once ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces pthread_setspecific ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sighold ; SubInclude HAIKU_TOP src tests system libroot posix posixtestsuite conformance interfaces sigignore ; Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-1.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-1.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002, Intel Corporation. All rights reserved. + * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + * Test that pthread_once() + * + * Dynamic package installation. Tihe first call to pthread_once() by any + * thread in a process, with a given 'once_control', shall call the + * 'init_routine' with no arguments. Subsequent calls of pthread_once() + * with the same once_control shall not call the 'init_routine'. The + * 'once_control' paramter shall determine whether the associated + * initialization routine has been called. + * + * STEPS: + * 1.Initialize a pthread_once object + * 2.Call pthread_once passing it this object + * 3.Call pthread_once again, this time, it shouldn't execute the function + * passed to it. If it does, the test fails. + */ + +#include +#include +#include "posixtest.h" + +/* Keeps track of how many times the init function has been called. */ +int init_flag; + +/* The init function that pthread_once calls */ +void *an_init_func() +{ + init_flag++; + return NULL; +} + +int main() +{ + pthread_once_t once_control = PTHREAD_ONCE_INIT; + + init_flag=0; + + /* Call pthread_once, passing it the once_control */ + pthread_once(&once_control, (void*)an_init_func); + + /* Call pthread_once again. The init function should not be + * called. */ + pthread_once(&once_control, (void*)an_init_func); + + if(init_flag != 1) + { + printf("Test FAILED\n"); + return PTS_FAIL; + } + + printf("Test PASSED\n"); + return PTS_PASS; + +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-2.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-2.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-2.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2004, Bull S.A.. All rights reserved. +* Created by: Sebastien Decugis + +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., 59 +* Temple Place - Suite 330, Boston MA 02111-1307, USA. + + +* This sample test aims to check the following assertion: +* +* In a process, the first call to pthread_once with a given once_control +* calls the init routine. + +* The steps are: +* -> call pthread_once +* -> check the init_routine executed + +* The test fails if the init_routine has not been called after pthread_once +* has returned. + +*/ + + +/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */ +#define _POSIX_C_SOURCE 200112L + +/********************************************************************************************/ +/****************************** standard includes *****************************************/ +/********************************************************************************************/ +#include +#include +#include +#include +#include +#include + +/********************************************************************************************/ +/****************************** Test framework *****************************************/ +/********************************************************************************************/ +#include "testfrmw.h" + #include "testfrmw.c" +/* This header is responsible for defining the following macros: + * UNRESOLVED(ret, descr); + * where descr is a description of the error and ret is an int (error code for example) + * FAILED(descr); + * where descr is a short text saying why the test has failed. + * PASSED(); + * No parameter. + * + * Both three macros shall terminate the calling process. + * The testcase shall not terminate in any other maneer. + * + * The other file defines the functions + * void output_init() + * void output(char * string, ...) + * + * Those may be used to output information. + */ + +/********************************************************************************************/ +/********************************** Configuration ******************************************/ +/********************************************************************************************/ +#ifndef VERBOSE +#define VERBOSE 1 +#endif + +/********************************************************************************************/ +/*********************************** Test case *****************************************/ +/********************************************************************************************/ + +int control; + +void my_init( void ) +{ + + control = 1; + + return ; +} + +/* The main test function. */ +int main( int argc, char * argv[] ) +{ + int ret; + + pthread_once_t myctl = PTHREAD_ONCE_INIT; + + /* Initialize output */ + output_init(); + + control = 0; + + /* Call the initializer */ + ret = pthread_once( &myctl, my_init ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "pthread_once failed" ); + } + + if ( control != 1 ) + { + FAILED( "The initializer function did not execute" ); + } + + PASSED; +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-3.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-3.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/1-3.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,183 @@ +/* +* Copyright (c) 2004, Bull S.A.. All rights reserved. +* Created by: Sebastien Decugis + +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., 59 +* Temple Place - Suite 330, Boston MA 02111-1307, USA. + + +* This sample test aims to check the following assertion: +* +* Subsequent calls with the same once_control do not call init routine. + +* The steps are: +* -> Create several threads +* -> each call pthread_once +* -> check the init_routine executed once + +* The test fails if the init_routine has not been called or has +* been called several times. + +*/ + + +/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */ +#define _POSIX_C_SOURCE 200112L + +/********************************************************************************************/ +/****************************** standard includes *****************************************/ +/********************************************************************************************/ +#include +#include +#include +#include +#include +#include + +/********************************************************************************************/ +/****************************** Test framework *****************************************/ +/********************************************************************************************/ +#include "testfrmw.h" + #include "testfrmw.c" +/* This header is responsible for defining the following macros: + * UNRESOLVED(ret, descr); + * where descr is a description of the error and ret is an int (error code for example) + * FAILED(descr); + * where descr is a short text saying why the test has failed. + * PASSED(); + * No parameter. + * + * Both three macros shall terminate the calling process. + * The testcase shall not terminate in any other maneer. + * + * The other file defines the functions + * void output_init() + * void output(char * string, ...) + * + * Those may be used to output information. + */ + +/********************************************************************************************/ +/********************************** Configuration ******************************************/ +/********************************************************************************************/ +#ifndef VERBOSE +#define VERBOSE 1 +#endif + +#define NTHREADS 30 + +/********************************************************************************************/ +/*********************************** Test case *****************************************/ +/********************************************************************************************/ + +int control; +pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; + +void my_init( void ) +{ + int ret = 0; + ret = pthread_mutex_lock( &mtx ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to lock mutex in initializer" ); + } + + control++; + + ret = pthread_mutex_unlock( &mtx ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to unlock mutex in initializer" ); + } + + return ; +} + +/* Thread function */ +void * threaded ( void * arg ) +{ + int ret; + + ret = pthread_once( arg, my_init ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "pthread_once failed" ); + } + + return NULL; +} + +/* The main test function. */ +int main( int argc, char * argv[] ) +{ + int ret, i; + + pthread_once_t myctl = PTHREAD_ONCE_INIT; + + pthread_t th[ NTHREADS ]; + + /* Initialize output */ + output_init(); + + control = 0; + + /* Create the children */ + + for ( i = 0; i < NTHREADS; i++ ) + { + ret = pthread_create( &th[ i ], NULL, threaded, &myctl ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to create a thread" ); + } + } + + /* Then join */ + for ( i = 0; i < NTHREADS; i++ ) + { + ret = pthread_join( th[ i ], NULL ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to join a thread" ); + } + } + + /* Fetch the memory */ + ret = pthread_mutex_lock( &mtx ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to lock mutex in initializer" ); + } + + if ( control != 1 ) + { + output( "Control: %d\n", control ); + FAILED( "The initializer function did not execute once" ); + } + + ret = pthread_mutex_unlock( &mtx ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Failed to unlock mutex in initializer" ); + } + + PASSED; +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/2-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/2-1.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/2-1.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2004, Bull S.A.. All rights reserved. +* Created by: Sebastien Decugis + +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., 59 +* Temple Place - Suite 330, Boston MA 02111-1307, USA. + + +* This sample test aims to check the following assertion: +* +* pthread_once returns only when init routine has completed. + +* The steps are: +* -> call pthread_once (the init routine lasts for 1 second) +* -> check the init_routine executed + +* The test fails if the init_routine has not been completed when pthread_once +* returns. + +*/ + + +/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */ +#define _POSIX_C_SOURCE 200112L + +/********************************************************************************************/ +/****************************** standard includes *****************************************/ +/********************************************************************************************/ +#include +#include +#include +#include +#include +#include + +/********************************************************************************************/ +/****************************** Test framework *****************************************/ +/********************************************************************************************/ +#include "testfrmw.h" + #include "testfrmw.c" +/* This header is responsible for defining the following macros: + * UNRESOLVED(ret, descr); + * where descr is a description of the error and ret is an int (error code for example) + * FAILED(descr); + * where descr is a short text saying why the test has failed. + * PASSED(); + * No parameter. + * + * Both three macros shall terminate the calling process. + * The testcase shall not terminate in any other maneer. + * + * The other file defines the functions + * void output_init() + * void output(char * string, ...) + * + * Those may be used to output information. + */ + +/********************************************************************************************/ +/********************************** Configuration ******************************************/ +/********************************************************************************************/ +#ifndef VERBOSE +#define VERBOSE 1 +#endif + +/********************************************************************************************/ +/*********************************** Test case *****************************************/ +/********************************************************************************************/ + +int control; + +void my_init( void ) +{ + sleep( 1 ); + + control = 1; + + return ; +} + +/* The main test function. */ +int main( int argc, char * argv[] ) +{ + int ret; + + pthread_once_t myctl = PTHREAD_ONCE_INIT; + + /* Initialize output */ + output_init(); + + control = 0; + + /* Call the initializer */ + ret = pthread_once( &myctl, my_init ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "pthread_once failed" ); + } + + if ( control != 1 ) + { + FAILED( "The initializer function did not execute" ); + } + + PASSED; +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/3-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/3-1.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/3-1.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2002, Intel Corporation. All rights reserved. + * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + * + * Test pthread_once() + * + * The pthread_once() function is not a cancelation point. However if + * 'init_routine'is a cancelation point and is canceled, the effect on + * 'once_control' shall be as if pthread_once() was never called. + * + * STEPS: + * 1. Create a cancelable thread. + * 2. In the thread routine, call pthread_once using a global pthread_once_t + * object. + * 3. Cancel the thread during the pthread_once init function + * 4. Call pthread_once again with the same pthread once_t object + * 5. This should call the pthread_once init function. If not, the test fails. + */ + +#include +#include +#include +#include "posixtest.h" + +/* Global pthread_once_t object */ +pthread_once_t once_control; + +/* Keeps track of how many times the init function has been called. */ +int init_flag; + +/* The init function that pthread_once calls */ +void *an_init_func() +{ + /* Indicate to main() that the init function has been reached */ + init_flag=1; + + /* Stay in a continuous loop until the thread that called + * this function gets canceled */ + sleep(10); + + /* The thread could not be canceled, timeout after 10 secs */ + perror("Init function timed out (10 secs), thread could not be canceled\n"); + init_flag=-1; + return NULL; +} + +/* Thread function */ +void *a_thread_func() +{ + /* Make the thread cancelable immediately */ + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + + pthread_once(&once_control, (void*)an_init_func); + return NULL; +} + +/* 2nd init function used by the 2nd call of pthread_once */ +void *an_init_func2() +{ + /* Indicate to main() that this init function has been reached */ + init_flag=1; + return NULL; +} + +int main() +{ + pthread_t new_th; + once_control = PTHREAD_ONCE_INIT; + init_flag=0; + + /* Create a thread that will execute the first call to pthread_once() */ + if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) + { + perror("Error creating thread\n"); + return PTS_UNRESOLVED; + } + + /* Wait until the init function is reached to cancel the thread */ + while(init_flag==0) + sleep(1); + + /* Send cancel request to the thread*/ + if(pthread_cancel(new_th) != 0) + { + perror("Could send cancel request to thread\n"); + return PTS_UNRESOLVED; + } + + /* Wait until the thread is canceled */ + pthread_join(new_th, NULL); + + /* If the thread could not be canceled and timed out, send + * an error */ + if (init_flag == -1) + { + perror("Error: could not cancel thread\n"); + return PTS_UNRESOLVED; + } + + init_flag=0; + + /* Should be able to call pthread_once() again with the same + * pthread_once_t object. */ + pthread_once(&once_control, (void*)an_init_func2); + + /* If the init function from the 2nd call to pthread_once() was not + * reached, the test fails. */ + if(init_flag != 1) + { + printf("Test FAILED\n: %d", init_flag); + return PTS_FAIL; + } + + printf("Test PASSED\n"); + return PTS_PASS; +} + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/4-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/4-1.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/4-1.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,17 @@ + /* + * Copyright (c) 2002, Intel Corporation. All rights reserved. + * Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com + * This file is licensed under the GPL license. For the full content + * of this license, see the COPYING file at the top level of this + * source tree. + + Test pthread_once() + + *The constant PTHREAD_ONCE_INIT is defined in the pthread.h header. + */ + +#include + +pthread_once_t dummy = PTHREAD_ONCE_INIT; + + Added: haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/6-1.c =================================================================== --- haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/6-1.c 2007-12-07 19:30:34 UTC (rev 23075) +++ haiku/trunk/src/tests/system/libroot/posix/posixtestsuite/conformance/interfaces/pthread_once/6-1.c 2007-12-07 21:02:59 UTC (rev 23076) @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2004, Bull S.A.. All rights reserved. +* Created by: Sebastien Decugis + +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., 59 +* Temple Place - Suite 330, Boston MA 02111-1307, USA. + + +* This sample test aims to check the following assertion: +* +* The function does not return EINTR + +* The steps are: +* -> kill a thread which calls pthread_once +* -> check that EINTR is never returned + +*/ + + +/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */ +#define _POSIX_C_SOURCE 200112L + +/********************************************************************************************/ +/****************************** standard includes *****************************************/ +/********************************************************************************************/ +#include + #include + #include + #include + #include + #include + +#include + #include + #include + +/********************************************************************************************/ +/****************************** Test framework *****************************************/ +/********************************************************************************************/ +#include "testfrmw.h" + #include "testfrmw.c" +/* This header is responsible for defining the following macros: + * UNRESOLVED(ret, descr); + * where descr is a description of the error and ret is an int (error code for example) + * FAILED(descr); + * where descr is a short text saying why the test has failed. + * PASSED(); + * No parameter. + * + * Both three macros shall terminate the calling process. + * The testcase shall not terminate in any other maneer. + * + * The other file defines the functions + * void output_init() + * void output(char * string, ...) + * + * Those may be used to output information. + */ + +/********************************************************************************************/ +/********************************** Configuration ******************************************/ +/********************************************************************************************/ +#ifndef VERBOSE +#define VERBOSE 1 +#endif + +#define WITH_SYNCHRO + + +/********************************************************************************************/ +/*********************************** Test cases *****************************************/ +/********************************************************************************************/ + +char do_it = 1; +unsigned long count_ope = 0; +#ifdef WITH_SYNCHRO +sem_t semsig1; +sem_t semsig2; +unsigned long count_sig = 0; +#endif + +sigset_t usersigs; + +typedef struct +{ + int sig; +#ifdef WITH_SYNCHRO + sem_t *sem; +#endif +} + +thestruct; + +/* the following function keeps on sending the signal to the process */ +void * sendsig ( void * arg ) +{ + thestruct * thearg = ( thestruct * ) arg; + int ret; + pid_t process; + + process = getpid(); + + /* We block the signals SIGUSR1 and SIGUSR2 for this THREAD */ + ret = pthread_sigmask( SIG_BLOCK, &usersigs, NULL ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Unable to block SIGUSR1 and SIGUSR2 in signal thread" ); + } + + while ( do_it ) + { +#ifdef WITH_SYNCHRO + + if ( ( ret = sem_wait( thearg->sem ) ) ) + { + UNRESOLVED( errno, "Sem_wait in sendsig" ); + } + + count_sig++; +#endif + + ret = kill( process, thearg->sig ); + + if ( ret != 0 ) + { + UNRESOLVED( errno, "Kill in sendsig" ); + } + + } + + return NULL; +} + +/* Next are the signal handlers. */ +/* This one is registered for signal SIGUSR1 */ +void sighdl1( int sig ) +{ +#ifdef WITH_SYNCHRO + + if ( sem_post( &semsig1 ) ) + { + UNRESOLVED( errno, "Sem_post in signal handler 1" ); + } + +#endif +} + +/* This one is registered for signal SIGUSR2 */ +void sighdl2( int sig ) +{ +#ifdef WITH_SYNCHRO + + if ( sem_post( &semsig2 ) ) + { + UNRESOLVED( errno, "Sem_post in signal handler 2" ); + } + +#endif +} + +int init_ctl; +/* Init function */ +void initializer( void ) +{ + init_ctl++; + return ; +} + + +/* Test function -- calls pthread_equal() and checks that EINTR is never returned. */ +void * test( void * arg ) +{ + int ret = 0; + pthread_once_t once_ctl; + + /* We don't block the signals SIGUSR1 and SIGUSR2 for this THREAD */ + ret = pthread_sigmask( SIG_UNBLOCK, &usersigs, NULL ); + + if ( ret != 0 ) + { + UNRESOLVED( ret, "Unable to unblock SIGUSR1 and SIGUSR2 in worker thread" ); + } + + + while ( do_it ) + { + count_ope++; + + once_ctl = PTHREAD_ONCE_INIT; + init_ctl = 0; + + ret = pthread_once( &once_ctl, initializer ); + + if ( ret == EINTR ) + { + FAILED( "pthread_once returned EINTR" ); + } + + if ( ret != 0 ) + { + UNRESOLVED( ret, "pthread_once failed" ); + } + + ret = pthread_once( &once_ctl, initializer ); + + if ( ret == EINTR ) + { + FAILED( "pthread_once returned EINTR" ); + } + + if ( ret != 0 ) + { + UNRESOLVED( ret, "pthread_once failed" ); + } + + if ( init_ctl != 1 ) + { + output( "init_ctl:%d\n", init_ctl ); + FAILED( "The initializer did not execute as expected" ); + } + + } + + return NULL; +} + +/* Main function */ +int main ( int argc, char * argv[] ) +{ + int ret; + pthread_t th_work, th_sig1, th_sig2; + thestruct arg1, arg2; + + struct sigaction sa; + + /* Initialize output routine */ + output_init(); + + /* We need to register the signal handlers for the PROCESS */ + sigemptyset ( &sa.sa_mask ); + sa.sa_flags = 0; [... truncated: 318 lines follow ...] From bonefish at mail.berlios.de Sat Dec 8 00:52:17 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Dec 2007 00:52:17 +0100 Subject: [Haiku-commits] r23077 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712072352.lB7NqHpa019573@sheep.berlios.de> Author: bonefish Date: 2007-12-08 00:52:16 +0100 (Sat, 08 Dec 2007) New Revision: 23077 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23077&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S Log: Made the common syscall return path a little shorter, by checking for all rare events (signals, thread debugging, breakpoints) at once. The performance gain is hardly measurable though. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-07 21:02:59 UTC (rev 23076) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-07 23:52:16 UTC (rev 23077) @@ -237,28 +237,15 @@ movl %edx, 40(%ebp) movl %eax, 48(%ebp) - // post syscall debugging - testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) - jnz do_post_syscall_debug - post_syscall_debug_done: + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + , (%edi) + jnz post_syscall_work - bad_syscall_params: - bad_syscall_number: - // if no signals are pending and the thread shall not be debugged, we can - // use the quick kernel exit function - testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD), (%edi) - jnz kernel_exit_handle_signals cli // disable interrupts call thread_at_kernel_exit_no_signals - kernel_exit_done: - // install breakpoints, if defined - testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, (%edi) - jz skip_debug_at_kernel_exit - push %ebp - call i386_init_user_debug_at_kernel_exit - skip_debug_at_kernel_exit: - +post_syscall_work_done: movl %ebp, %esp // remove all parameters from the stack addl $4, %esp // skip iframe type @@ -280,7 +267,10 @@ addl $8, %esp jmp pre_syscall_debug_done - do_post_syscall_debug: + post_syscall_work: + // post syscall debugging + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) + jz post_syscall_debug_done movl -4(%ebp), %ecx // syscall start time push %ecx movl -8(%ebp), %ecx @@ -293,8 +283,25 @@ push %eax call user_debug_post_syscall addl $8, %esp - jmp post_syscall_debug_done + post_syscall_debug_done: + bad_syscall_params: + bad_syscall_number: + // if no signals are pending and the thread shall not be debugged, we can + // use the quick kernel exit function + testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD), (%edi) + jnz kernel_exit_handle_signals + cli // disable interrupts + call thread_at_kernel_exit_no_signals + kernel_exit_done: + + // install breakpoints, if defined + testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, (%edi) + jz post_syscall_work_done + push %ebp + call i386_init_user_debug_at_kernel_exit + jmp post_syscall_work_done + kernel_exit_handle_signals: call thread_at_kernel_exit cli // disable interrupts From bonefish at mail.berlios.de Sat Dec 8 02:10:56 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Dec 2007 02:10:56 +0100 Subject: [Haiku-commits] r23078 - haiku/branches/developer/bonefish/optimization/src/system/kernel Message-ID: <200712080110.lB81AueO005200@sheep.berlios.de> Author: bonefish Date: 2007-12-08 02:10:44 +0100 (Sat, 08 Dec 2007) New Revision: 23078 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23078&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp Log: Ugh, the time is already passed as a parameter. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-07 23:52:16 UTC (rev 23077) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-08 01:10:44 UTC (rev 23078) @@ -1471,7 +1471,6 @@ TRACE(("thread_at_kernel_entry: entry thread %ld\n", thread->id)); // track user time - now = system_time(); thread->user_time += now - thread->last_time; thread->last_time = now; From bonefish at mail.berlios.de Sat Dec 8 04:21:51 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Dec 2007 04:21:51 +0100 Subject: [Haiku-commits] r23079 - haiku/branches/developer/bonefish/optimization/build/jam Message-ID: <200712080321.lB83Lprg015661@sheep.berlios.de> Author: bonefish Date: 2007-12-08 04:21:50 +0100 (Sat, 08 Dec 2007) New Revision: 23079 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23079&view=rev Modified: haiku/branches/developer/bonefish/optimization/build/jam/MainBuildRules Log: Added rule CreateAsmStructOffsetsHeader which can translate a specially formed C++ file into a header file with macro definitions for offsets of C structure members. This makes it easy to access members of C structures in assembly code. (Idea stolen from the Linux kernel, BTW.) Modified: haiku/branches/developer/bonefish/optimization/build/jam/MainBuildRules =================================================================== --- haiku/branches/developer/bonefish/optimization/build/jam/MainBuildRules 2007-12-08 01:10:44 UTC (rev 23078) +++ haiku/branches/developer/bonefish/optimization/build/jam/MainBuildRules 2007-12-08 03:21:50 UTC (rev 23079) @@ -212,7 +212,119 @@ $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" "$(NEEDLIBS)" $(LINKLIBS) } +rule CreateAsmStructOffsetsHeader header : source +{ + # CreateAsmStructOffsetsHeader header : source + # + # Grist will be added to both header and source. + header = [ FGristFiles $(header) ] ; + source = [ FGristFiles $(source) ] ; + + # find out which headers, defines, etc. to use + local headers ; + local sysHeaders ; + local defines ; + local flags ; + local includesSeparator ; + local localIncludesOption ; + local systemIncludesOption ; + + on $(header) { # use on $(1) variable values + if ! $(PLATFORM) in $(SUPPORTED_PLATFORMS) { + return ; + } + + # headers and defines + headers = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; + sysHeaders = $(SUBDIRSYSHDRS) $(SYSHDRS) ; + defines = $(DEFINES) ; + + if $(PLATFORM) = host { + sysHeaders += $(HOST_HDRS) ; + defines += $(HOST_DEFINES) ; + + if $(USES_BE_API) { + sysHeaders += $(HOST_BE_API_HEADERS) ; + } + + } else { + sysHeaders += $(TARGET_HDRS) ; + defines += $(TARGET_DEFINES) ; + } + + # optimization flags + if $(DEBUG) = 0 { + flags += $(OPTIM) ; + } else { + flags += -O0 ; + } + + if $(PLATFORM) = host { + # warning flags + if $(WARNINGS) != 0 { + flags += $(HOST_WARNING_C++FLAGS) ; + } + + # debug and other flags + flags += $(HOST_C++FLAGS) $(HOST_DEBUG_$(DEBUG)_C++FLAGS) + $(SUBDIRC++FLAGS) $(C++FLAGS) ; + + if $(USES_BE_API) { + flags += $(HOST_BE_API_C++FLAGS) ; + } + + C++ on $(header) = $(HOST_C++) ; + + includesSeparator = $(HOST_INCLUDES_SEPARATOR) ; + localIncludesOption = $(HOST_LOCAL_INCLUDES_OPTION) ; + systemIncludesOption = $(HOST_SYSTEM_INCLUDES_OPTION) ; + + } else { + # warning flags + if $(WARNINGS) != 0 { + flags += $(TARGET_WARNING_C++FLAGS) ; + } + + # debug and other flags + flags += $(TARGET_C++FLAGS) $(TARGET_DEBUG_$(DEBUG)_C++FLAGS) + $(SUBDIRC++FLAGS) $(C++FLAGS) ; + + C++ on $(header) = $(TARGET_C++) ; + + includesSeparator = $(TARGET_INCLUDES_SEPARATOR) ; + localIncludesOption = $(TARGET_LOCAL_INCLUDES_OPTION) ; + systemIncludesOption = $(TARGET_SYSTEM_INCLUDES_OPTION) ; + } + } + + # locate object, search for source, and set on target variables + + Depends $(header) : $(source) ; + SEARCH on $(source) += $(SEARCH_SOURCE) ; + MakeLocateArch $(header) ; + LocalClean clean : $(header) ; + + HDRRULE on $(source) = HdrRule ; + HDRSCAN on $(source) = $(HDRPATTERN) ; + HDRSEARCH on $(source) = $(headers) $(sysHeaders) $(STDHDRS) ; + HDRGRIST on $(source) = $(HDRGRIST) ; + + C++FLAGS on $(header) = $(flags) ; + CCHDRS on $(header) = [ FIncludes $(headers) : $(localIncludesOption) ] + $(includesSeparator) + [ FSysIncludes $(sysHeaders) : $(systemIncludesOption) ] ; + CCDEFS on $(header) = [ FDefines $(defines) ] ; + + CreateAsmStructOffsetsHeader1 $(header) : $(source) ; +} + +actions CreateAsmStructOffsetsHeader1 +{ + $(C++) -S "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o - \ + | grep "#define" | sed -e 's/\$//' > "$(1)" +} + rule MergeObjectFromObjects { # MergeObjectFromObjects : : ; From bonefish at mail.berlios.de Sat Dec 8 04:31:41 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sat, 8 Dec 2007 04:31:41 +0100 Subject: [Haiku-commits] r23080 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712080331.lB83VfIY016151@sheep.berlios.de> Author: bonefish Date: 2007-12-08 04:31:39 +0100 (Sat, 08 Dec 2007) New Revision: 23080 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23080&view=rev Added: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S Log: Inlined thread_at_kernel_entry() and thread_at_kernel_exit_no_signals() into the syscall interrupt handler, resulting in a surprising 15+% speedup on my machine (P4 3.2 GHz), now beating Zeta by a small margin. Linux (2.6.22.5) still wins by a whopping factor 5.4, though. 8-O Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-08 03:21:50 UTC (rev 23079) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-08 03:31:39 UTC (rev 23080) @@ -39,6 +39,8 @@ $(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused ; +CreateAsmStructOffsetsHeader asm_offsets.h : asm_offsets.cpp ; + # We need to specify the dependency on the generated syscalls file explicitly. Includes [ FGristFiles arch_x86.S arch_interrupts.S ] : syscall_numbers.h ; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-08 03:21:50 UTC (rev 23079) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-08 03:31:39 UTC (rev 23080) @@ -12,6 +12,7 @@ #include #include +#include "asm_offsets.h" #include "syscall_numbers.h" #include "syscall_table.h" @@ -192,12 +193,29 @@ call i386_exit_user_debug_at_kernel_entry skip_debug_at_kernel_entry: + // update the thread's user time + call system_time push %edx push %eax - call thread_at_kernel_entry // leave the time on the stack (needed for post syscall debugging) + movl %eax, %ebx // save for later + movl %edx, %ecx + + // thread->user_time += now - thread->last_time; + sub THREAD_last_time(%edi), %eax + sbb (THREAD_last_time + 4)(%edi), %edx + add %eax, THREAD_user_time(%edi) + adc %edx, (THREAD_user_time + 4)(%edi) + + // thread->last_time = now; + movl %ebx, THREAD_last_time(%edi) + movl %ecx, (THREAD_last_time + 4)(%edi) + + // thread->in_kernel = true; + movb $1, THREAD_in_kernel(%edi) + sti // enable interrupts cmp $SYSCALL_COUNT, %esi // check syscall number @@ -243,8 +261,27 @@ jnz post_syscall_work cli // disable interrupts - call thread_at_kernel_exit_no_signals + // update the thread's kernel time + + call system_time + + movl %eax, %ebx // save for later + movl %edx, %ecx + + // thread->kernel_time += now - thread->last_time; + sub THREAD_last_time(%edi), %eax + sbb (THREAD_last_time + 4)(%edi), %edx + add %eax, THREAD_kernel_time(%edi) + adc %edx, (THREAD_kernel_time + 4)(%edi) + + // thread->last_time = now; + movl %ebx, THREAD_last_time(%edi) + movl %ecx, (THREAD_last_time + 4)(%edi) + + // thread->in_kernel = false; + movb $0, THREAD_in_kernel(%edi) + post_syscall_work_done: movl %ebp, %esp // remove all parameters from the stack Added: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-08 03:21:50 UTC (rev 23079) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-08 03:31:39 UTC (rev 23080) @@ -0,0 +1,29 @@ +/* + * Copyright 2007, Ingo Weinhold, ingo_weinhold at gmx.de. + * Distributed under the terms of the MIT License. + */ + +// This file is used to get C structure offsets into assembler code. +// The build system assembles the file and processes the output to create +// a header file with macro definitions, that can be included from assembler +// code. + +#include + + +#define DEFINE_MACRO(macro, value) \ + asm volatile("#define " #macro " %0" : : "i" (value)) + +#define DEFINE_OFFSET_MACRO(prefix, structure, member) \ + DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member)); + + +void +dummy() +{ + // struct thread + DEFINE_OFFSET_MACRO(THREAD, thread, kernel_time); + DEFINE_OFFSET_MACRO(THREAD, thread, user_time); + DEFINE_OFFSET_MACRO(THREAD, thread, last_time); + DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); +} From axeld at pinc-software.de Sat Dec 8 12:01:12 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 08 Dec 2007 12:01:12 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23080_-_haiku/branches/developer?= =?iso-8859-15?q?/bonefish/optimization/src/system/kernel/arch/x86?= In-Reply-To: <200712080331.lB83VfIY016151@sheep.berlios.de> Message-ID: <917748366-BeMail@zon> bonefish at BerliOS wrote: > +CreateAsmStructOffsetsHeader asm_offsets.h : asm_offsets.cpp ; Nice, so the flags field could be made movable, too, at least in theory :-) Bye, Axel. From korli at mail.berlios.de Sat Dec 8 13:45:04 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 8 Dec 2007 13:45:04 +0100 Subject: [Haiku-commits] r23081 - haiku/trunk/src/kits/tracker Message-ID: <200712081245.lB8Cj4Er016668@sheep.berlios.de> Author: korli Date: 2007-12-08 13:45:03 +0100 (Sat, 08 Dec 2007) New Revision: 23081 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23081&view=rev Modified: haiku/trunk/src/kits/tracker/TrackerInitialState.cpp Log: don't add backgroundTexture.tga as default folder image fix bug #1649 Modified: haiku/trunk/src/kits/tracker/TrackerInitialState.cpp =================================================================== --- haiku/trunk/src/kits/tracker/TrackerInitialState.cpp 2007-12-08 03:31:39 UTC (rev 23080) +++ haiku/trunk/src/kits/tracker/TrackerInitialState.cpp 2007-12-08 12:45:03 UTC (rev 23081) @@ -463,6 +463,7 @@ // path.Append(kDefaultFolderTemplate); BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png"); +#if 0 BString defaultBackgroundTexture("/backgroundTexture.tga"); BNode node; @@ -473,6 +474,7 @@ BackgroundImage::kTiled, BPoint(0, 0), 0xffffffff, false); } +#endif BDirectory dir; if (FSGetBootDeskDir(&dir) == B_OK) { From axeld at mail.berlios.de Sat Dec 8 15:23:36 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 8 Dec 2007 15:23:36 +0100 Subject: [Haiku-commits] r23082 - in haiku/trunk: headers/private/fs_shell src/add-ons/kernel/file_systems/bfs src/tools/fs_shell Message-ID: <200712081423.lB8ENa8b024014@sheep.berlios.de> Author: axeld Date: 2007-12-08 15:23:35 +0100 (Sat, 08 Dec 2007) New Revision: 23082 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23082&view=rev Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h haiku/trunk/headers/private/fs_shell/fssh_kernel_export.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_control.h haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp haiku/trunk/src/tools/fs_shell/kernel_export.cpp Log: * BFS now always writes back the whole block when it writes the super block. * Therefore, I've added an I/O control that let's it update the boot block part of this block, so that makebootable can use it on a mounted volume (this will probably be moved into a disk system API later). * Added user_memcpy() to the fs_shell. * Minor cleanup. Modified: haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/headers/private/fs_shell/fssh_api_wrapper.h 2007-12-08 14:23:35 UTC (rev 23082) @@ -932,9 +932,11 @@ // #pragma mark - fssh_kernel_export.h /* kernel threads */ - #define spawn_kernel_thread fssh_spawn_kernel_thread +/* misc */ +#define user_memcpy fssh_user_memcpy + /* primitive kernel debugging facilities */ #define dprintf fssh_dprintf #define kprintf fssh_kprintf Modified: haiku/trunk/headers/private/fs_shell/fssh_kernel_export.h =================================================================== --- haiku/trunk/headers/private/fs_shell/fssh_kernel_export.h 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/headers/private/fs_shell/fssh_kernel_export.h 2007-12-08 14:23:35 UTC (rev 23082) @@ -10,15 +10,18 @@ extern "C" { #endif -/*-------------------------------------------------------------*/ + /* kernel threads */ extern fssh_thread_id fssh_spawn_kernel_thread(fssh_thread_func function, const char *threadName, int32_t priority, void *arg); +/* misc */ -/*-------------------------------------------------------------*/ +extern fssh_status_t fssh_user_memcpy(void *dest, const void *source, + fssh_size_t length); + /* primitive kernel debugging facilities */ extern void fssh_dprintf(const char *format, ...) /* just like printf */ Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/Volume.cpp 2007-12-08 14:23:35 UTC (rev 23082) @@ -78,13 +78,13 @@ int DeviceOpener::Open(const char *device, int mode) { - fDevice = open(device, mode); + fDevice = open(device, mode | O_NOCACHE); if (fDevice < 0) fDevice = errno; if (fDevice < 0 && mode == O_RDWR) { // try again to open read-only (don't rely on a specific error code) - return Open(device, O_RDONLY); + return Open(device, O_RDONLY | O_NOCACHE); } if (fDevice >= 0) { @@ -97,7 +97,7 @@ if (geometry.read_only) { // reopen device read-only close(fDevice); - return Open(device, O_RDONLY); + return Open(device, O_RDONLY | O_NOCACHE); } } } @@ -203,7 +203,8 @@ void -disk_super_block::Initialize(const char *diskName, off_t numBlocks, uint32 blockSize) +disk_super_block::Initialize(const char *diskName, off_t numBlocks, + uint32 blockSize) { memset(this, 0, sizeof(disk_super_block)); @@ -312,7 +313,8 @@ flags |= B_MOUNT_READ_ONLY; #endif - DeviceOpener opener(deviceName, flags & B_MOUNT_READ_ONLY ? O_RDONLY : O_RDWR); + DeviceOpener opener(deviceName, (flags & B_MOUNT_READ_ONLY) != 0 + ? O_RDONLY : O_RDWR); fDevice = opener.Device(); if (fDevice < B_OK) RETURN_ERROR(fDevice); @@ -326,21 +328,6 @@ if (fstat(fDevice, &stat) < 0) RETURN_ERROR(B_ERROR); -// TODO: allow turning off caching of the underlying file (once O_NOCACHE works) -#if 0 -#ifndef NO_FILE_UNCACHED_IO - if ((stat.st_mode & S_FILE) != 0 && ioctl(fDevice, IOCTL_FILE_UNCACHED_IO, NULL) < 0) { - // mount read-only if the cache couldn't be disabled -# ifdef DEBUG - FATAL(("couldn't disable cache for image file - system may dead-lock!\n")); -# else - FATAL(("couldn't disable cache for image file!\n")); - Panic(); -# endif - } -#endif -#endif - // read the super block if (Identify(fDevice, &fSuperBlock) != B_OK) { FATAL(("invalid super block!\n")); @@ -383,11 +370,6 @@ if (status == B_OK) { // try to get indices root dir - // question: why doesn't get_vnode() work here?? - // answer: we have not yet backpropagated the pointer to the - // volume in bfs_mount(), so bfs_read_vnode() can't get it. - // But it's not needed to do that anyway. - if (!Indices().IsZero()) fIndicesNode = new Inode(this, ToVnode(Indices())); @@ -397,8 +379,8 @@ INFORM(("bfs: volume doesn't have indices!\n")); if (fIndicesNode) { - // if this is the case, the index root node is gone bad, and - // BFS switch to read-only mode + // if this is the case, the index root node is gone bad, + // and BFS switch to read-only mode fFlags |= VOLUME_READ_ONLY; delete fIndicesNode; fIndicesNode = NULL; @@ -450,12 +432,14 @@ status_t Volume::ValidateBlockRun(block_run run) { - if (run.AllocationGroup() < 0 || run.AllocationGroup() > (int32)AllocationGroups() + if (run.AllocationGroup() < 0 + || run.AllocationGroup() > (int32)AllocationGroups() || run.Start() > (1UL << AllocationGroupShift()) || run.length == 0 || uint32(run.Length() + run.Start()) > (1UL << AllocationGroupShift())) { Panic(); - FATAL(("*** invalid run(%d,%d,%d)\n", (int)run.AllocationGroup(), run.Start(), run.Length())); + FATAL(("*** invalid run(%d,%d,%d)\n", (int)run.AllocationGroup(), + run.Start(), run.Length())); return B_BAD_DATA; } return B_OK; @@ -466,8 +450,10 @@ Volume::ToBlockRun(off_t block) const { block_run run; - run.allocation_group = HOST_ENDIAN_TO_BFS_INT32(block >> AllocationGroupShift()); - run.start = HOST_ENDIAN_TO_BFS_INT16(block & ((1LL << AllocationGroupShift()) - 1)); + run.allocation_group = HOST_ENDIAN_TO_BFS_INT32( + block >> AllocationGroupShift()); + run.start = HOST_ENDIAN_TO_BFS_INT16( + block & ((1LL << AllocationGroupShift()) - 1)); run.length = HOST_ENDIAN_TO_BFS_INT16(1); return run; } @@ -489,16 +475,20 @@ status_t -Volume::AllocateForInode(Transaction &transaction, const Inode *parent, mode_t type, block_run &run) +Volume::AllocateForInode(Transaction &transaction, const Inode *parent, + mode_t type, block_run &run) { - return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(), type, run); + return fBlockAllocator.AllocateForInode(transaction, &parent->BlockRun(), + type, run); } status_t Volume::WriteSuperBlock() { - if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block)) != sizeof(disk_super_block)) + // TODO: this assumes a block size of 512 bytes of the underlying device + if (write_pos(fDevice, 512, &fSuperBlock, sizeof(disk_super_block)) + != sizeof(disk_super_block)) return B_IO_ERROR; return B_OK; @@ -506,15 +496,18 @@ void -Volume::UpdateLiveQueries(Inode *inode, const char *attribute, int32 type, const uint8 *oldKey, - size_t oldLength, const uint8 *newKey, size_t newLength) +Volume::UpdateLiveQueries(Inode *inode, const char *attribute, int32 type, + const uint8 *oldKey, size_t oldLength, const uint8 *newKey, + size_t newLength) { if (fQueryLock.Lock() < B_OK) return; Query *query = NULL; - while ((query = fQueries.Next(query)) != NULL) - query->LiveUpdate(inode, attribute, type, oldKey, oldLength, newKey, newLength); + while ((query = fQueries.Next(query)) != NULL) { + query->LiveUpdate(inode, attribute, type, oldKey, oldLength, newKey, + newLength); + } fQueryLock.Unlock(); } @@ -568,11 +561,10 @@ if (read_pos(fd, 0, buffer, sizeof(buffer)) != sizeof(buffer)) return B_IO_ERROR; - // Note: that does work only for x86, for PowerPC, the super block - // may be located at offset 0! memcpy(superBlock, buffer + 512, sizeof(disk_super_block)); if (!superBlock->IsValid()) { #ifndef BFS_LITTLE_ENDIAN_ONLY + // For PPC, the super block might be located at offset 0 memcpy(superBlock, buffer, sizeof(disk_super_block)); if (!superBlock->IsValid()) return B_BAD_VALUE; @@ -615,7 +607,7 @@ // create valid super block fSuperBlock.Initialize(name, numBlocks, blockSize); - + // initialize short hands to the super block (to save byte swapping) fBlockSize = fSuperBlock.BlockSize(); fBlockShift = fSuperBlock.BlockShift(); Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs.h 2007-12-08 14:23:35 UTC (rev 23082) @@ -1,6 +1,5 @@ -/* bfs - BFS definitions and helper functions - * - * Copyright 2001-2004, Axel D?rfler, axeld at pinc-software.de. +/* + * Copyright 2001-2007, Axel D?rfler, axeld at pinc-software.de. * Parts of this code is based on work previously done by Marcus Overhagen. * * This file may be used under the terms of the MIT License. @@ -8,7 +7,9 @@ #ifndef BFS_H #define BFS_H +//! BFS definitions and helper functions + #include "bfs_endian.h" #include "system_dependencies.h" @@ -71,7 +72,9 @@ int32 magic3; inode_addr root_dir; inode_addr indices; - int32 pad[8]; + int32 _reserved[8]; + int32 pad_to_block[87]; + // this also contains parts of the boot block int32 Magic1() const { return BFS_ENDIAN_TO_HOST_INT32(magic1); } int32 Magic2() const { return BFS_ENDIAN_TO_HOST_INT32(magic2); } Modified: haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_control.h =================================================================== --- haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_control.h 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/bfs_control.h 2007-12-08 14:23:35 UTC (rev 23082) @@ -16,6 +16,8 @@ */ #define BFS_IOCTL_VERSION 14200 +#define BFS_IOCTL_UPDATE_BOOT_BLOCK 14204 + /* ioctls to use the "chkbfs" feature from the outside * all calls use a struct check_result as single parameter */ 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-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp 2007-12-08 14:23:35 UTC (rev 23082) @@ -576,6 +576,17 @@ return allocator.CheckNextNode(control); } + case BFS_IOCTL_UPDATE_BOOT_BLOCK: + { + // let's makebootable (or anyone else) update the boot block + // while BFS is mounted + if (user_memcpy(&volume->SuperBlock().pad_to_block, + (uint8 *)buffer + offsetof(disk_super_block, pad_to_block), + sizeof(volume->SuperBlock().pad_to_block)) < B_OK) + return B_BAD_ADDRESS; + + return volume->WriteSuperBlock(); + } #ifdef DEBUG case 56742: { Modified: haiku/trunk/src/tools/fs_shell/kernel_export.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/kernel_export.cpp 2007-12-08 12:45:03 UTC (rev 23081) +++ haiku/trunk/src/tools/fs_shell/kernel_export.cpp 2007-12-08 14:23:35 UTC (rev 23082) @@ -20,6 +20,14 @@ } +fssh_status_t +fssh_user_memcpy(void *dest, const void *source, fssh_size_t length) +{ + memcpy(dest, source, length); + return FSSH_B_OK; +} + + void fssh_dprintf(const char *format, ...) { @@ -65,6 +73,7 @@ *badAddress = 42; } + void fssh_kernel_debugger(const char *message) { @@ -78,6 +87,7 @@ return 0; } + int fssh_add_debugger_command(char *name, fssh_debugger_command_hook hook, char *help) From korli at users.berlios.de Sat Dec 8 15:37:34 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 8 Dec 2007 15:37:34 +0100 Subject: [Haiku-commits] r23082 - in haiku/trunk: headers/private/fs_shell src/add-ons/kernel/file_systems/bfs src/tools/fs_shell In-Reply-To: <200712081423.lB8ENa8b024014@sheep.berlios.de> References: <200712081423.lB8ENa8b024014@sheep.berlios.de> Message-ID: Hi Axel, 2007/12/8, axeld at BerliOS : > haiku/trunk/src/tools/fs_shell/kernel_export.cpp This one breaks the build :) src/tools/fs_shell/kernel_export.cpp: In function 'fssh_status_t fssh_user_memcpy(void*, const void*, fssh_size_t)': src/tools/fs_shell/kernel_export.cpp:26: erreur: 'memcpy' was not declared in this scope cc -c "src/tools/fs_shell/kernel_export.cpp" -O -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare -Wno-multichar -DFS_SHELL=1 -D_ZETA_USING_DEPRECATED_API_=1 -D_ZETA_TS_FIND_DIR_=1 -DARCH_x86 -D_NO_INLINE_ASM -D__INTEL__ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DHAIKU_HOST_PLATFORM_LINUX -iquote src/tools/fs_shell -iquote /home/korli/svnhaiku/haiku/generated_v2/objects/common/tools/fs_shell -iquote /home/korli/svnhaiku/haiku/generated_v2/objects/linux/x86/common/tools/fs_shell -iquote /home/korli/svnhaiku/haiku/generated_v2/objects/haiku/x86/common/tools/fs_shell -I headers/build -I headers/build/os -I headers/build/os/kernel -I headers/build/os/storage -I headers/build/os/support -I headers/private/fs_shell -I headers/private/shared -I headers/build/host/linux -o "/home/korli/svnhaiku/haiku/generated_v2/objects/linux/x86/release/tools/fs_shell/kernel_export.o" ; Bye J?r?me From korli at mail.berlios.de Sat Dec 8 15:40:33 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sat, 8 Dec 2007 15:40:33 +0100 Subject: [Haiku-commits] r23083 - haiku/trunk/src/tools/fs_shell Message-ID: <200712081440.lB8EeXfD024964@sheep.berlios.de> Author: korli Date: 2007-12-08 15:40:33 +0100 (Sat, 08 Dec 2007) New Revision: 23083 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23083&view=rev Modified: haiku/trunk/src/tools/fs_shell/kernel_export.cpp Log: fix linux build Modified: haiku/trunk/src/tools/fs_shell/kernel_export.cpp =================================================================== --- haiku/trunk/src/tools/fs_shell/kernel_export.cpp 2007-12-08 14:23:35 UTC (rev 23082) +++ haiku/trunk/src/tools/fs_shell/kernel_export.cpp 2007-12-08 14:40:33 UTC (rev 23083) @@ -8,6 +8,7 @@ #include #include #include +#include #include "fssh_errors.h" From korli at users.berlios.de Sat Dec 8 15:41:38 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sat, 8 Dec 2007 15:41:38 +0100 Subject: [Haiku-commits] r23082 - in haiku/trunk: headers/private/fs_shell src/add-ons/kernel/file_systems/bfs src/tools/fs_shell In-Reply-To: References: <200712081423.lB8ENa8b024014@sheep.berlios.de> Message-ID: 2007/12/8, J?r?me Duval : > src/tools/fs_shell/kernel_export.cpp: In function 'fssh_status_t > fssh_user_memcpy(void*, const void*, fssh_size_t)': > src/tools/fs_shell/kernel_export.cpp:26: erreur: 'memcpy' was not > declared in this scope > Ok, I added string.h as an include in r23083 Bye, J?r?me From axeld at mail.berlios.de Sat Dec 8 15:52:14 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 8 Dec 2007 15:52:14 +0100 Subject: [Haiku-commits] r23084 - haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci Message-ID: <200712081452.lB8EqEYY025740@sheep.berlios.de> Author: axeld Date: 2007-12-08 15:52:14 +0100 (Sat, 08 Dec 2007) New Revision: 23084 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23084&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c Log: * Only acknowledge the interrupt in the service thread, so that no new one will be triggered. * Also, loop as long as new interrupts are coming in. * This fixes the high CPU usage and low throughput of the 3com driver; it now works just fine; dunno why it worked for me that well last time. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-12-08 14:40:33 UTC (rev 23083) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-12-08 14:52:14 UTC (rev 23084) @@ -41,7 +41,6 @@ return 0; atomic_or((int32 *)&sc->xl_intr_status, status); - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK | (status & XL_INTRS)); return 1; } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-12-08 14:40:33 UTC (rev 23083) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-12-08 14:52:14 UTC (rev 23084) @@ -2289,12 +2289,12 @@ #ifndef __HAIKU__ while ((status = CSR_READ_2(sc, XL_STATUS)) & XL_INTRS && status != 0xFFFF) { - CSR_WRITE_2(sc, XL_COMMAND, - XL_CMD_INTR_ACK|(status & XL_INTRS)); #else status = atomic_and((int32 *)&sc->xl_intr_status, 0); - if ((status & XL_INTRS) != 0 && status != 0xFFFF) { + do { #endif + CSR_WRITE_2(sc, XL_COMMAND, + XL_CMD_INTR_ACK|(status & XL_INTRS)); if (status & XL_STAT_UP_COMPLETE) { int curpkts; @@ -2329,7 +2329,12 @@ xl_stats_update_locked(sc); sc->xl_stats_no_timeout = 0; } +#ifdef __HAIKU__ + status = CSR_READ_2(sc, XL_STATUS); + } while ((status & XL_INTRS) != 0 && status != 0xFFFF); +#else } +#endif if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { if (sc->xl_type == XL_TYPE_905B) From axeld at pinc-software.de Sat Dec 8 15:56:58 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sat, 08 Dec 2007 15:56:58 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23082_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/fs=5Fshell_src/add-ons/kernel/file=5Fsystems/bf?= =?iso-8859-15?q?s_src/tools/fs=5Fshell?= In-Reply-To: Message-ID: <15063674635-BeMail@zon> "J?r?me Duval" wrote: > 2007/12/8, J?r?me Duval : > > src/tools/fs_shell/kernel_export.cpp: In function 'fssh_status_t > > fssh_user_memcpy(void*, const void*, fssh_size_t)': > > src/tools/fs_shell/kernel_export.cpp:26: erreur: 'memcpy' was not > > declared in this scope > Ok, I added string.h as an include in r23083 Thanks! It worked fine on BeOS, so I did not notice this header wasn't included. Bye, Axel. From ingo_weinhold at gmx.de Sat Dec 8 16:55:52 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Sat, 08 Dec 2007 16:55:52 +0100 Subject: [Haiku-commits] r23080 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 In-Reply-To: <917748366-BeMail@zon> References: <917748366-BeMail@zon> Message-ID: <20071208165552.347.1@knochen-vm.nameserver> On 2007-12-08 at 12:01:12 [+0100], Axel D?rfler wrote: > bonefish at BerliOS wrote: > > +CreateAsmStructOffsetsHeader asm_offsets.h : asm_offsets.cpp ; > > Nice, so the flags field could be made movable, too, at least in theory > :-) Yep, I plan to do that. There are also some iframe members that are accessed via hard-coded offsets ATM. CU, Ingo From axeld at mail.berlios.de Sat Dec 8 20:38:52 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 8 Dec 2007 20:38:52 +0100 Subject: [Haiku-commits] r23085 - in haiku/trunk/src: add-ons/kernel/drivers/network/3com/pci libs/compat/freebsd_network Message-ID: <200712081938.lB8JcqPP000735@sheep.berlios.de> Author: axeld Date: 2007-12-08 20:38:51 +0100 (Sat, 08 Dec 2007) New Revision: 23085 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23085&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c haiku/trunk/src/libs/compat/freebsd_network/bus.c Log: * Turns out the 3com driver wasn't picked up after my changes, but the marvell_yukon driver worked flawlessly this one time... (I got almost 10 MB/s with that one, now 7.5 MB/s with the 3com driver) * We need to acknowledge the interrupt in the handler, because else, the interrupt continues to fire after the PIC interrupt is acknowledged by the kernel. * It also helps a lot to turn off the interrupts on the device while xl_intr() is handling the interrupt. * When the slow handler is running, we now set the new "handling" field in the internal interrupt handler which will not invoke the scheduler then (but only signals a handled interrupt). Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-12-08 14:52:14 UTC (rev 23084) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/glue.c 2007-12-08 19:38:51 UTC (rev 23085) @@ -40,6 +40,8 @@ if (status == 0xffff || (status & XL_INTRS) == 0) return 0; + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB); + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_INTR_ACK | (status & XL_INTRS)); atomic_or((int32 *)&sc->xl_intr_status, status); return 1; } @@ -48,6 +50,8 @@ void __haiku_reenable_interrupts(device_t dev) { + struct xl_softc *sc = device_get_softc(dev); + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STAT_ENB | XL_INTRS); } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-12-08 14:52:14 UTC (rev 23084) +++ haiku/trunk/src/add-ons/kernel/drivers/network/3com/pci/if_xl.c 2007-12-08 19:38:51 UTC (rev 23085) @@ -2286,16 +2286,13 @@ } #endif - #ifndef __HAIKU__ +#ifndef __HAIKU__ while ((status = CSR_READ_2(sc, XL_STATUS)) & XL_INTRS && status != 0xFFFF) { #else status = atomic_and((int32 *)&sc->xl_intr_status, 0); - do { + while (true) { #endif - CSR_WRITE_2(sc, XL_COMMAND, - XL_CMD_INTR_ACK|(status & XL_INTRS)); - if (status & XL_STAT_UP_COMPLETE) { int curpkts; @@ -2331,10 +2328,13 @@ } #ifdef __HAIKU__ status = CSR_READ_2(sc, XL_STATUS); - } while ((status & XL_INTRS) != 0 && status != 0xFFFF); -#else + if ((status & XL_INTRS) == 0 || status == 0xffff) + break; + + CSR_WRITE_2(sc, XL_COMMAND, + XL_CMD_INTR_ACK|(status & XL_INTRS)); +#endif } -#endif if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { if (sc->xl_type == XL_TYPE_905B) Modified: haiku/trunk/src/libs/compat/freebsd_network/bus.c =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-12-08 14:52:14 UTC (rev 23084) +++ haiku/trunk/src/libs/compat/freebsd_network/bus.c 2007-12-08 19:38:51 UTC (rev 23085) @@ -49,6 +49,7 @@ thread_id thread; sem_id sem; + int32 handling; }; @@ -235,7 +236,7 @@ return B_UNHANDLED_INTERRUPT; release_sem_etc(intr->sem, 1, B_DO_NOT_RESCHEDULE); - return B_INVOKE_SCHEDULER; + return intr->handling ? B_HANDLED_INTERRUPT : B_INVOKE_SCHEDULER; } @@ -264,7 +265,9 @@ //device_printf(intr->dev, "in soft interrupt handler.\n"); + atomic_or(&intr->handling, 1); intr->handler(intr->arg); + atomic_and(&intr->handling, 0); HAIKU_REENABLE_INTERRUPTS(intr->dev); } From axeld at mail.berlios.de Sat Dec 8 21:32:04 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 8 Dec 2007 21:32:04 +0100 Subject: [Haiku-commits] r23086 - haiku/trunk/src/system/kernel/vm Message-ID: <200712082032.lB8KW4X8003906@sheep.berlios.de> Author: axeld Date: 2007-12-08 21:32:04 +0100 (Sat, 08 Dec 2007) New Revision: 23086 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23086&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp Log: If there are more than 4 MB dirty cache pages, the page writer won't stop anymore writing back pages when there is enough free memory. Modified: haiku/trunk/src/system/kernel/vm/vm_page.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-12-08 19:38:51 UTC (rev 23085) +++ haiku/trunk/src/system/kernel/vm/vm_page.cpp 2007-12-08 20:32:04 UTC (rev 23086) @@ -902,8 +902,7 @@ marker.state = PAGE_STATE_UNUSED; while (true) { - if (sModifiedPageQueue.count - sModifiedTemporaryPages < 1024 - || free_page_queue_count() > 1024) { + if (sModifiedPageQueue.count - sModifiedTemporaryPages < 1024) { int32 count = 0; get_sem_count(sWriterWaitSem, &count); if (count == 0) From axeld at mail.berlios.de Sat Dec 8 22:45:40 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sat, 8 Dec 2007 22:45:40 +0100 Subject: [Haiku-commits] r23087 - haiku/trunk/src/system/libroot/posix/stdlib Message-ID: <200712082145.lB8LjeEv007468@sheep.berlios.de> Author: axeld Date: 2007-12-08 22:45:40 +0100 (Sat, 08 Dec 2007) New Revision: 23087 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23087&view=rev Modified: haiku/trunk/src/system/libroot/posix/stdlib/realpath.c Log: If either the path or the resolved path is NULL, realpath() now returns EINVAL. This also fixes bug #1659. Modified: haiku/trunk/src/system/libroot/posix/stdlib/realpath.c =================================================================== --- haiku/trunk/src/system/libroot/posix/stdlib/realpath.c 2007-12-08 20:32:04 UTC (rev 23086) +++ haiku/trunk/src/system/libroot/posix/stdlib/realpath.c 2007-12-08 21:45:40 UTC (rev 23087) @@ -58,6 +58,11 @@ char *p, *q, wbuf[MAXPATHLEN]; int symlinks = 0; + if (path == NULL || resolved == NULL) { + errno = EINVAL; + return NULL; + } + /* Save the starting point. */ if ((fd = open(".", O_RDONLY)) < 0) { strcpy(resolved, "."); From mmu_man at mail.berlios.de Sat Dec 8 23:15:13 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 8 Dec 2007 23:15:13 +0100 Subject: [Haiku-commits] r23088 - haiku/trunk/src/bin Message-ID: <200712082215.lB8MFDtU008878@sheep.berlios.de> Author: mmu_man Date: 2007-12-08 23:15:12 +0100 (Sat, 08 Dec 2007) New Revision: 23088 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23088&view=rev Added: haiku/trunk/src/bin/filepanel.cpp Modified: haiku/trunk/src/bin/Jamfile Log: One more oldie I found when digging old code... A filepanel command allowing scripts to ask the user where to load or save a file. Modified: haiku/trunk/src/bin/Jamfile =================================================================== --- haiku/trunk/src/bin/Jamfile 2007-12-08 21:45:40 UTC (rev 23087) +++ haiku/trunk/src/bin/Jamfile 2007-12-08 22:15:12 UTC (rev 23088) @@ -147,6 +147,11 @@ usb_dev_info.cpp : be USBKit.a : $(haiku-utils_rsrc) ; +# standard commands that need libbe.so, libtracker.so +StdBinCommands + filepanel.cpp + : be tracker : $(haiku-utils_rsrc) ; + SubInclude HAIKU_TOP src bin addattr ; SubInclude HAIKU_TOP src bin bash ; SubInclude HAIKU_TOP src bin bc ; Added: haiku/trunk/src/bin/filepanel.cpp =================================================================== --- haiku/trunk/src/bin/filepanel.cpp 2007-12-08 21:45:40 UTC (rev 23087) +++ haiku/trunk/src/bin/filepanel.cpp 2007-12-08 22:15:12 UTC (rev 23088) @@ -0,0 +1,196 @@ +/* + * filepanel.cpp - a command line tool to open a BFilePanel and get the result + * copyright 2003, Francois Revol, revol at free.fr + * LDFLAGS="-lbe -ltracker" make filepanel + * return: + * 0: the user has selected something, + * 1: the user canceled/closed the panel, + * 2: an error occured. + */ + +//#define USE_FNMATCH + +#ifdef USE_FNMATCH +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define APP_SIG "application/x-vnd.mmu_man.filepanel" + +volatile int return_code = 0; + +class FilePanelApp : public BApplication +{ +public: + FilePanelApp(); + + virtual void MessageReceived(BMessage *message); + virtual void RefsReceived(BMessage *message); +}; + +FilePanelApp::FilePanelApp() + :BApplication(APP_SIG) +{ +} + +void +FilePanelApp::MessageReceived(BMessage *message) +{ + entry_ref e; + const char *name; + BEntry entry; + BPath p; + +// message->PrintToStream(); + switch (message->what) { + case B_SAVE_REQUESTED: + message->FindRef("directory", &e); + message->FindString("name", &name); + entry.SetTo(&e); + entry.GetPath(&p); + printf("%s/%s\n", p.Path(), name); + be_app_messenger.SendMessage(B_QUIT_REQUESTED); + break; + case B_CANCEL: + return_code = 1; +//puts("plop"); + be_app_messenger.SendMessage(B_QUIT_REQUESTED); + break; + default: + BApplication::MessageReceived(message); + } +} + +void +FilePanelApp::RefsReceived(BMessage *message) +{ + entry_ref e; + BEntry entry; + int i; + BPath p; +// message->PrintToStream(); + for (i = 0; message->FindRef("refs", i, &e) == B_OK; i++) { + entry.SetTo(&e); + entry.GetPath(&p); + puts(p.Path()); + } + be_app_messenger.SendMessage(B_QUIT_REQUESTED); +} + +int usage(char *pname, int error) +{ + fprintf(stderr, "display a load/save file panel\n"); + fprintf(stderr, "usage: %s [--help] [--directory folder] [--load|--save] [--title ttl] [--single] [--modal] [--allow pattern] [--forbid pattern]\n", pname); + fprintf(stderr, "usage: %s [-h] [-d folder] [-l|-s] [-t ttl] [-1] [-m] [-a pattern] [-f pattern]\n", pname); + fprintf(stderr, "options:\n"); + fprintf(stderr, "short\tlong\tdescription\n"); + fprintf(stderr, "-h\t--help\tdisplay usage\n"); + fprintf(stderr, "-d\t--directory\topen at \n"); + fprintf(stderr, "-l\t--load\tuse a load FilePanel (default)\n"); + fprintf(stderr, "-s\t--save\tuse a save FilePanel\n"); + fprintf(stderr, "-k\t--kind\tkind of entries that can be opened (flavour): any combination of f, d, s (file (default), directory, symlink)\n"); + fprintf(stderr, "-t\t--title\tset the FilePanel window title\n"); + fprintf(stderr, "-1\t--single\tallow only 1 file to be selected\n"); + fprintf(stderr, "-m\t--modal\tmakes the FilePanel modal\n"); +#ifndef USE_FNMATCH + fprintf(stderr, "-a\t--allow\tunimplemented\n"); + fprintf(stderr, "-f\t--forbid\tunimplemented\n"); +#else + fprintf(stderr, "-a\t--allow\tunimplemented\n"); + fprintf(stderr, "-f\t--forbid\tunimplemented\n"); +#endif + return error; +} + +int main(int argc, char **argv) +{ + int i; + file_panel_mode fpMode = B_OPEN_PANEL; + uint32 nodeFlavour = 0; + char *openAt = NULL; + char *windowTitle = NULL; + bool allowMultiSelect = true; + bool makeModal = false; + + for (i = 1; i < argc; i++) { + if (strncmp(argv[i], "--", 2) && ((*(argv[i]) == '-' && strlen(argv[i]) != 2) || *(argv[i]) != '-')) { + fprintf(stderr, "%s not a valid option\n", argv[i]); + return usage(argv[0], 2); + } + if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) { + return usage(argv[0], 0); + } else if (!strcmp(argv[i], "--directory") || !strcmp(argv[i], "-d")) { + if (++i >= argc) { + fprintf(stderr, "%s: this option requires a parameter\n", argv[i-1]); + return usage(argv[0], 2); + } + openAt = argv[i]; + } else if (!strcmp(argv[i], "--load") || !strcmp(argv[i], "-l")) { + fpMode = B_OPEN_PANEL; + } else if (!strcmp(argv[i], "--save") || !strcmp(argv[i], "-s")) { + fpMode = B_SAVE_PANEL; + } else if (!strcmp(argv[i], "--kind") || !strcmp(argv[i], "-k")) { + if (++i >= argc) { + fprintf(stderr, "%s: this option requires a parameter\n", argv[i-1]); + return usage(argv[0], 2); + } + if (strchr(argv[i], 'f')) nodeFlavour |= B_FILE_NODE; + if (strchr(argv[i], 'd')) nodeFlavour |= B_DIRECTORY_NODE; + if (strchr(argv[i], 's')) nodeFlavour |= B_SYMLINK_NODE; + } else if (!strcmp(argv[i], "--title") || !strcmp(argv[i], "-t")) { + if (++i >= argc) { + fprintf(stderr, "%s: this option requires a parameter\n", argv[i-1]); + return usage(argv[0], 2); + } + windowTitle = argv[i]; + } else if (!strcmp(argv[i], "--single") || !strcmp(argv[i], "-1")) { + allowMultiSelect = false; + } else if (!strcmp(argv[i], "--modal") || !strcmp(argv[i], "-m")) { + makeModal = true; + } else if (!strcmp(argv[i], "--allow") || !strcmp(argv[i], "-a")) { + if (++i >= argc) { + fprintf(stderr, "%s: this option requires a parameter\n", argv[i-1]); + return usage(argv[0], 2); + } + fprintf(stderr, "%s: UNIMPLEMENTED\n", argv[i-1]); + } else if (!strcmp(argv[i], "--forbid") || !strcmp(argv[i], "-f")) { + if (++i >= argc) { + fprintf(stderr, "%s: this option requires a parameter\n", argv[i-1]); + return usage(argv[0], 2); + } + fprintf(stderr, "%s: UNIMPLEMENTED\n", argv[i-1]); + } else { + fprintf(stderr, "%s not a valid option\n", argv[i]); + return usage(argv[0], 2); + } + } + new FilePanelApp; + entry_ref panelDir; +// THIS LINE makes main() return always 0 no matter which value on return of exit() ??? + BFilePanel *fPanel = new BFilePanel(fpMode, NULL, NULL, nodeFlavour, allowMultiSelect, NULL, NULL, makeModal); +/**/ + if (openAt) + fPanel->SetPanelDirectory(openAt); + if (windowTitle) + fPanel->Window()->SetTitle(windowTitle); + + fPanel->Show(); +/**/ + be_app->Run(); + delete be_app; +// printf("rc = %d\n", return_code); +// WTF ?? +//return 2; + exit(2); + exit(return_code); + return return_code; +} + From stippi at mail.berlios.de Sat Dec 8 23:59:05 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sat, 8 Dec 2007 23:59:05 +0100 Subject: [Haiku-commits] r23089 - haiku/trunk/src/servers/app Message-ID: <200712082259.lB8Mx5iR015255@sheep.berlios.de> Author: stippi Date: 2007-12-08 23:59:04 +0100 (Sat, 08 Dec 2007) New Revision: 23089 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23089&view=rev Modified: haiku/trunk/src/servers/app/ServerPicture.cpp haiku/trunk/src/servers/app/ServerWindow.cpp Log: * lock pattern drawing to the true view origin, independend of the views position on screen (fixes drawing glitches in patterns when the view was moved on screen (for example because the parent window got moved)) Modified: haiku/trunk/src/servers/app/ServerPicture.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerPicture.cpp 2007-12-08 22:15:12 UTC (rev 23088) +++ haiku/trunk/src/servers/app/ServerPicture.cpp 2007-12-08 22:59:04 UTC (rev 23089) @@ -467,8 +467,8 @@ { view->PopState(); - IntPoint p = view->ScrollingOffset(); - p += IntPoint(view->CurrentState()->Origin()); + BPoint p(0, 0); + view->ConvertToScreenForDrawing(&p); view->Window()->GetDrawingEngine()->SetDrawState( view->CurrentState(), p.x, p.y); } Modified: haiku/trunk/src/servers/app/ServerWindow.cpp =================================================================== --- haiku/trunk/src/servers/app/ServerWindow.cpp 2007-12-08 22:15:12 UTC (rev 23088) +++ haiku/trunk/src/servers/app/ServerWindow.cpp 2007-12-08 22:59:04 UTC (rev 23089) @@ -3179,8 +3179,8 @@ // "offsets" passed below would need to be updated again DrawingEngine* drawingEngine = fWindowLayer->GetDrawingEngine(); if (layer && drawingEngine) { - IntPoint p = layer->ScrollingOffset(); - p += IntPoint(layer->CurrentState()->Origin()); + BPoint p(0, 0); + layer->ConvertToScreenForDrawing(&p); drawingEngine->SetDrawState(layer->CurrentState(), p.x, p.y); } } From mmu_man at mail.berlios.de Sun Dec 9 02:56:39 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 9 Dec 2007 02:56:39 +0100 Subject: [Haiku-commits] r23090 - haiku/trunk/src/bin Message-ID: <200712090156.lB91udld016623@sheep.berlios.de> Author: mmu_man Date: 2007-12-09 02:56:39 +0100 (Sun, 09 Dec 2007) New Revision: 23090 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23090&view=rev Modified: haiku/trunk/src/bin/filepanel.cpp Log: Fix return code and some style. Modified: haiku/trunk/src/bin/filepanel.cpp =================================================================== --- haiku/trunk/src/bin/filepanel.cpp 2007-12-08 22:59:04 UTC (rev 23089) +++ haiku/trunk/src/bin/filepanel.cpp 2007-12-09 01:56:39 UTC (rev 23090) @@ -49,7 +49,7 @@ BEntry entry; BPath p; -// message->PrintToStream(); + //message->PrintToStream(); switch (message->what) { case B_SAVE_REQUESTED: message->FindRef("directory", &e); @@ -61,7 +61,6 @@ break; case B_CANCEL: return_code = 1; -//puts("plop"); be_app_messenger.SendMessage(B_QUIT_REQUESTED); break; default: @@ -85,7 +84,8 @@ be_app_messenger.SendMessage(B_QUIT_REQUESTED); } -int usage(char *pname, int error) +int +usage(char *pname, int error) { fprintf(stderr, "display a load/save file panel\n"); fprintf(stderr, "usage: %s [--help] [--directory folder] [--load|--save] [--title ttl] [--single] [--modal] [--allow pattern] [--forbid pattern]\n", pname); @@ -110,7 +110,8 @@ return error; } -int main(int argc, char **argv) +int +main(int argc, char **argv) { int i; file_panel_mode fpMode = B_OPEN_PANEL; @@ -189,7 +190,7 @@ // printf("rc = %d\n", return_code); // WTF ?? //return 2; - exit(2); +// exit(2); exit(return_code); return return_code; } From bonefish at mail.berlios.de Sun Dec 9 04:17:03 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Dec 2007 04:17:03 +0100 Subject: [Haiku-commits] r23091 - haiku/branches/developer/bonefish/optimization/src/system/kernel Message-ID: <200712090317.lB93H3vk021127@sheep.berlios.de> Author: bonefish Date: 2007-12-09 04:17:01 +0100 (Sun, 09 Dec 2007) New Revision: 23091 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23091&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp Log: The "thread" debugger command also prints the thread::flags fields, now. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-09 01:56:39 UTC (rev 23090) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-09 03:17:01 UTC (rev 23091) @@ -1061,6 +1061,7 @@ strerror(thread->kernel_errno)); kprintf("kernel_time: %Ld\n", thread->kernel_time); kprintf("user_time: %Ld\n", thread->user_time); + kprintf("flags: 0x%lx\n", thread->flags); kprintf("architecture dependant section:\n"); arch_thread_dump_info(&thread->arch_info); } From bonefish at mail.berlios.de Sun Dec 9 04:35:33 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Dec 2007 04:35:33 +0100 Subject: [Haiku-commits] r23092 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch src/system/kernel/arch/x86 src/system/kernel/debug Message-ID: <200712090335.lB93ZXfN021677@sheep.berlios.de> Author: bonefish Date: 2007-12-09 04:35:31 +0100 (Sun, 09 Dec 2007) New Revision: 23092 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23092&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp Log: * Introduced new arch_update_thread_single_step() function which is supposed to prepare whatever is necessary to enable or disable single stepping. For x86 that means we don't have to do that in i386_init_user_debug_at_kernel_exit() all the time. Squashes a TODO. * i386_init_user_debug_at_kernel_exit() and i386_exit_user_debug_at_kernel_entry() check thread::flags at the beginning and drop out, if nothing has to be done at all. * i386_exit_user_debug_at_kernel_entry() didn't clear the thread::flags bit THREAD_FLAGS_BREAKPOINTS_INSTALLED, and together with the fact that i386_handle_trap() always caused this flag to be set, it resulted in this function being executed every time in the syscall handler. Apparently with quite some impact: After fixing it, the time per syscall (as determined by the syscall_time test) dropped from 1.41 to 0.81 us. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h 2007-12-09 03:17:01 UTC (rev 23091) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/user_debugger.h 2007-12-09 03:35:31 UTC (rev 23092) @@ -22,6 +22,8 @@ void arch_clear_thread_debug_info(struct arch_thread_debug_info *info); void arch_destroy_thread_debug_info(struct arch_thread_debug_info *info); +void arch_update_thread_single_step(); + void arch_set_debug_cpu_state(const struct debug_cpu_state *cpuState); void arch_get_debug_cpu_state(struct debug_cpu_state *cpuState); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-09 03:17:01 UTC (rev 23091) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-09 03:35:31 UTC (rev 23092) @@ -512,6 +512,21 @@ void +arch_update_thread_single_step() +{ + if (struct iframe* frame = i386_get_user_iframe()) { + struct thread* thread = thread_get_current_thread(); + + // set/clear TF in EFLAGS depending on if single stepping is desired + if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) + frame->flags |= (1 << X86_EFLAGS_TF); + else + frame->flags &= ~(1 << X86_EFLAGS_TF); + } +} + + +void arch_set_debug_cpu_state(const struct debug_cpu_state *cpuState) { if (struct iframe *frame = i386_get_user_iframe()) { @@ -699,6 +714,11 @@ { struct thread *thread = thread_get_current_thread(); +#if !KERNEL_BREAKPOINTS + if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_DEFINED)) + return; +#endif + GRAB_THREAD_LOCK(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -707,15 +727,6 @@ // install the breakpoints install_breakpoints(teamInfo); - // set/clear TF in EFLAGS depending on if single stepping is desired - if (thread->debug_info.flags & B_THREAD_DEBUG_SINGLE_STEP) - frame->flags |= (1 << X86_EFLAGS_TF); - else - frame->flags &= ~(1 << X86_EFLAGS_TF); - // ToDo: Move into a function called from thread_hit_debug_event(). - // No need to have that here in the code executed for ever kernel->user - // mode switch. - atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_INSTALLED); RELEASE_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -731,6 +742,11 @@ { struct thread *thread = thread_get_current_thread(); +#if !KERNEL_BREAKPOINTS + if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_INSTALLED)) + return; +#endif + GRAB_THREAD_LOCK(); // disable breakpoints @@ -743,6 +759,8 @@ RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); #endif + atomic_and(&thread->flags, ~THREAD_FLAGS_BREAKPOINTS_INSTALLED); + RELEASE_THREAD_LOCK(); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp 2007-12-09 03:17:01 UTC (rev 23091) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/debug/user_debugger.cpp 2007-12-09 03:35:31 UTC (rev 23092) @@ -625,6 +625,9 @@ RELEASE_THREAD_LOCK(); restore_interrupts(state); + // enable/disable single stepping + arch_update_thread_single_step(); + if (destroyThreadInfo) destroy_thread_debug_info(&threadDebugInfo); From stippi at mail.berlios.de Sun Dec 9 16:36:29 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 9 Dec 2007 16:36:29 +0100 Subject: [Haiku-commits] r23093 - in haiku/trunk/src/libs/icon: . shape transformer Message-ID: <200712091536.lB9FaTsl031091@sheep.berlios.de> Author: stippi Date: 2007-12-09 16:36:28 +0100 (Sun, 09 Dec 2007) New Revision: 23093 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23093&view=rev Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp haiku/trunk/src/libs/icon/shape/Shape.cpp haiku/trunk/src/libs/icon/shape/Shape.h haiku/trunk/src/libs/icon/transformer/AffineTransformer.cpp haiku/trunk/src/libs/icon/transformer/ContourTransformer.cpp haiku/trunk/src/libs/icon/transformer/PathSource.cpp haiku/trunk/src/libs/icon/transformer/PathSource.h haiku/trunk/src/libs/icon/transformer/StrokeTransformer.cpp Log: * make sure that the ApproximationScale() implementation of any Transformer not negative * PathSource can now remember a global scale, and the IconRenderer sets it, since this value is used in the curve converter for on the fly generation of vertices, this change does not affect anything and doesn't create the need to "update" the conversion pipeline to render an icon at different sizes (like Icon-O-Matic does) -> this change fixes edgy curves on icons rendered bigger than 64x64 as reported by Axel some time ago Modified: haiku/trunk/src/libs/icon/IconRenderer.cpp =================================================================== --- haiku/trunk/src/libs/icon/IconRenderer.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/IconRenderer.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006-2007, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -100,7 +100,7 @@ { StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex); if (!styleItem) { - printf("no style at index: %d!\n", styleIndex); + printf("no style at index: %u!\n", styleIndex); return fTransparent; } @@ -120,7 +120,7 @@ { StyleItem* styleItem = (StyleItem*)fStyles.ItemAt(styleIndex); if (!styleItem || !styleItem->style->Gradient()) { - printf("no style/gradient at index: %d!\n", styleIndex); + printf("no style/gradient at index: %u!\n", styleIndex); // TODO: memset() span? return; } @@ -397,6 +397,7 @@ styleIndex++; // global scale + shape->SetGlobalScale(max_c(1.0, transform.scale())); ScaledPath scaledPath(shape->VertexSource(), transform); if (shape->Hinting()) { // additional hinting Modified: haiku/trunk/src/libs/icon/shape/Shape.cpp =================================================================== --- haiku/trunk/src/libs/icon/shape/Shape.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/shape/Shape.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -482,6 +482,13 @@ return *source; } +// SetGlobalScale +void +Shape::SetGlobalScale(double scale) +{ + fPathSource.SetGlobalScale(scale); +} + // AddTransformer bool Shape::AddTransformer(Transformer* transformer) Modified: haiku/trunk/src/libs/icon/shape/Shape.h =================================================================== --- haiku/trunk/src/libs/icon/shape/Shape.h 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/shape/Shape.h 2007-12-09 15:36:28 UTC (rev 23093) @@ -105,6 +105,7 @@ BRect Bounds(bool updateLast = false) const; ::VertexSource& VertexSource(); + void SetGlobalScale(double scale); bool AddTransformer(Transformer* transformer); bool AddTransformer(Transformer* transformer, Modified: haiku/trunk/src/libs/icon/transformer/AffineTransformer.cpp =================================================================== --- haiku/trunk/src/libs/icon/transformer/AffineTransformer.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/transformer/AffineTransformer.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -93,7 +93,7 @@ double AffineTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * scale(); + return fabs(fSource.ApproximationScale() * scale()); } // #pragma mark - Modified: haiku/trunk/src/libs/icon/transformer/ContourTransformer.cpp =================================================================== --- haiku/trunk/src/libs/icon/transformer/ContourTransformer.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/transformer/ContourTransformer.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -111,7 +111,11 @@ double ContourTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * width(); + double scale = fSource.ApproximationScale(); + double factor = fabs(width()); + if (factor > 1.0) + scale *= factor; + return scale; } // #pragma mark - Modified: haiku/trunk/src/libs/icon/transformer/PathSource.cpp =================================================================== --- haiku/trunk/src/libs/icon/transformer/PathSource.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/transformer/PathSource.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -13,10 +13,13 @@ // constructor PathSource::PathSource(PathContainer* paths) - : VertexSource(), - fPaths(paths), - fAGGPath(), - fAGGCurvedPath(fAGGPath) + : VertexSource() + , fPaths(paths) + , fAGGPath() + , fAGGCurvedPath(fAGGPath) + + , fGlobalScale(1.0) + , fLastTransformerScale(1.0) { } @@ -68,6 +71,15 @@ fAGGPath.close_polygon(); } - fAGGCurvedPath.approximation_scale(approximationScale); + fLastTransformerScale = approximationScale; + fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); } +// SetGlobalScale +void +PathSource::SetGlobalScale(double scale) +{ + fGlobalScale = scale; + fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); +} + Modified: haiku/trunk/src/libs/icon/transformer/PathSource.h =================================================================== --- haiku/trunk/src/libs/icon/transformer/PathSource.h 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/transformer/PathSource.h 2007-12-09 15:36:28 UTC (rev 23093) @@ -37,12 +37,17 @@ // PathSource void Update(bool leavePathsOpen, - double approximationScale); + double approximationScale); + void SetGlobalScale(double scale); + private: PathContainer* fPaths; AGGPath fAGGPath; AGGCurvedPath fAGGCurvedPath; + + double fGlobalScale; + double fLastTransformerScale; }; } // namespace Icon Modified: haiku/trunk/src/libs/icon/transformer/StrokeTransformer.cpp =================================================================== --- haiku/trunk/src/libs/icon/transformer/StrokeTransformer.cpp 2007-12-09 03:35:31 UTC (rev 23092) +++ haiku/trunk/src/libs/icon/transformer/StrokeTransformer.cpp 2007-12-09 15:36:28 UTC (rev 23093) @@ -121,7 +121,11 @@ double StrokeTransformer::ApproximationScale() const { - return fSource.ApproximationScale() * width(); + double scale = fSource.ApproximationScale(); + double factor = fabs(width()); + if (factor > 1.0) + scale *= factor; + return scale; } // #pragma mark - From stippi at mail.berlios.de Sun Dec 9 16:37:16 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 9 Dec 2007 16:37:16 +0100 Subject: [Haiku-commits] r23094 - haiku/trunk/src/apps/diskprobe Message-ID: <200712091537.lB9FbGwd031160@sheep.berlios.de> Author: stippi Date: 2007-12-09 16:37:16 +0100 (Sun, 09 Dec 2007) New Revision: 23094 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23094&view=rev Modified: haiku/trunk/src/apps/diskprobe/AttributeEditors.cpp Log: * it's now fine to display icons at 256x256 Modified: haiku/trunk/src/apps/diskprobe/AttributeEditors.cpp =================================================================== --- haiku/trunk/src/apps/diskprobe/AttributeEditors.cpp 2007-12-09 15:36:28 UTC (rev 23093) +++ haiku/trunk/src/apps/diskprobe/AttributeEditors.cpp 2007-12-09 15:37:16 UTC (rev 23094) @@ -784,7 +784,7 @@ if (editor.Type() == B_VECTOR_ICON_TYPE) { // vector icon fScaleSlider = new BSlider(BRect(0, 0, 195, 20), "", NULL, - new BMessage(kMsgScaleChanged), 2, 16); + new BMessage(kMsgScaleChanged), 2, 32); fScaleSlider->SetModificationMessage(new BMessage(kMsgScaleChanged)); fScaleSlider->ResizeToPreferred(); fScaleSlider->SetValue(8.0); From stippi at mail.berlios.de Sun Dec 9 16:41:31 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Sun, 9 Dec 2007 16:41:31 +0100 Subject: [Haiku-commits] r23095 - haiku/trunk/src/preferences/drivesetup Message-ID: <200712091541.lB9FfVTK031424@sheep.berlios.de> Author: stippi Date: 2007-12-09 16:41:31 +0100 (Sun, 09 Dec 2007) New Revision: 23095 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23095&view=rev Added: haiku/trunk/src/preferences/drivesetup/DiskView.cpp haiku/trunk/src/preferences/drivesetup/DiskView.h haiku/trunk/src/preferences/drivesetup/run Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp haiku/trunk/src/preferences/drivesetup/Jamfile haiku/trunk/src/preferences/drivesetup/MainWindow.cpp haiku/trunk/src/preferences/drivesetup/MainWindow.h haiku/trunk/src/preferences/drivesetup/PartitionList.cpp haiku/trunk/src/preferences/drivesetup/PartitionList.h Log: * some work in progress to display a view of the selected disk device * build DriveSetup for the test environment, though it doesn't display anything in that mode... just to work on some general things, maybe I add a fake partition tree just to test things later * cleanup Added: haiku/trunk/src/preferences/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/DiskView.cpp 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/DiskView.cpp 2007-12-09 15:41:31 UTC (rev 23095) @@ -0,0 +1,158 @@ +/* + * Copyright 2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * Stephan A?mus + */ +#include "DiskView.h" + +#include +#include + +using BPrivate::HashMap; +using BPrivate::HashKey32; + + +static const pattern kStripes = { { 0xc7, 0x8f, 0x1f, 0x3e, + 0x7c, 0xf8, 0xf1, 0xe3 } }; +static const rgb_color kInvalidColor = { 0, 0, 0, 0 }; +static const rgb_color kStripesHigh = { 112, 112, 112, 255 }; +static const rgb_color kStripesLow = { 104, 104, 104, 255 }; + +static const int32 kMaxPartitionColors = 256; +static rgb_color kPartitionColors[kMaxPartitionColors]; + + +struct PartitionBox { + PartitionBox() + : frame(0, 0, -1, -1) + , color(kInvalidColor) + { + } + + PartitionBox(const BRect& frame, const rgb_color& color) + : frame(frame) + , color(color) + { + } + + PartitionBox(const PartitionBox& other) + : frame(other.frame) + , color(other.color) + { + } + + ~PartitionBox() + { + } + + PartitionBox& operator=(const PartitionBox& other) + { + frame = other.frame; + color = other.color; + return *this; + } + + BRect frame; + rgb_color color; +}; + + +class PartitionDrawer : public BDiskDeviceVisitor { +public: + PartitionDrawer(BView* view) + : fView(view) + , fBoxMap() + , fColorIndex(0) + { + } + + virtual bool Visit(BDiskDevice* device) + { + fBoxMap.Put(device->ID(), PartitionBox(fView->Bounds(), _NextColor())); + return true; + } + + virtual bool Visit(BPartition* partition, int32 level) + { + if (!partition->Parent() || !fBoxMap.ContainsKey(partition->Parent()->ID())) + return false; + + PartitionBox parent = fBoxMap.Get(partition->Parent()->ID()); + BRect frame = parent.frame; + // TODO .... calculate frame within parent frame (inset...) + + fBoxMap.Put(partition->ID(), PartitionBox(frame, _NextColor())); + return true; + } + + private: + + rgb_color _NextColor() + { + fColorIndex++; + if (fColorIndex > kMaxPartitionColors) + fColorIndex = 0; + return kPartitionColors[fColorIndex]; + } + + typedef HashKey32 PartitionKey; + typedef HashMap PartitionBoxMap; + + BView* fView; + PartitionBoxMap fBoxMap; + int32 fColorIndex; +}; + + +// #pragma mark - + + +DiskView::DiskView(const BRect& frame, uint32 resizeMode) + : Inherited(frame, "diskview", resizeMode, B_WILL_DRAW) + , fDisk(NULL) + , fSelectedParition(-1) +{ + for (int32 i = 0; i < 256; i++) { + kPartitionColors[i].red = (i * 1675) & 0xff; + kPartitionColors[i].green = (i * 318) & 0xff; + kPartitionColors[i].blue = (i * 9328) & 0xff; + kPartitionColors[i].alpha = 255; + } +} + + +DiskView::~DiskView() +{ + SetDisk(NULL, -1); +} + + +void +DiskView::Draw(BRect updateRect) +{ + BRect bounds(Bounds()); + + if (!fDisk) { + SetHighColor(kStripesHigh); + SetLowColor(kStripesLow); + FillRect(bounds, kStripes); + return; + } + + // TODO: render the partitions (use PartitionDrawer to iterate our disk) + SetHighColor(255, 255, 120); + FillRect(bounds); +} + + +void +DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition) +{ + delete fDisk; + fDisk = disk; + fSelectedParition = selectedPartition; + + Invalidate(); +} Added: haiku/trunk/src/preferences/drivesetup/DiskView.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/DiskView.h 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/DiskView.h 2007-12-09 15:41:31 UTC (rev 23095) @@ -0,0 +1,31 @@ +/* + * Copyright 2007 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef DISK_VIEW_H +#define DISK_VIEW_H + + +#include +#include + + +class DiskView : public BView { + typedef BView Inherited; +public: + DiskView(const BRect& frame, + uint32 resizeMode); + virtual ~DiskView(); + + // BView interface + virtual void Draw(BRect updateRect); + + void SetDisk(BDiskDevice* disk, + partition_id selectedPartition); +private: + BDiskDevice* fDisk; + partition_id fSelectedParition; +}; + + +#endif // DISK_VIEW_H Modified: haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/DriveSetup.cpp 2007-12-09 15:41:31 UTC (rev 23095) @@ -111,7 +111,6 @@ fprintf(stderr, "failed to unflatten settings: %s\n", strerror(ret)); return ret; } -fSettings.PrintToStream(); ret = fWindow->RestoreSettings(&fSettings); if (ret < B_OK) { Modified: haiku/trunk/src/preferences/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/preferences/drivesetup/Jamfile 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/Jamfile 2007-12-09 15:41:31 UTC (rev 23095) @@ -1,16 +1,23 @@ SubDir HAIKU_TOP src preferences drivesetup ; -SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; -UsePrivateHeaders interface storage shared ; +UsePrivateHeaders interface shared storage ; -AddResources DriveSetup : DriveSetup.rdef ; - Preference DriveSetup : + DiskView.cpp DriveSetup.cpp MainWindow.cpp PartitionList.cpp Support.cpp : be + : + DriveSetup.rdef ; + +if ( $(TARGET_PLATFORM) = libbe_test ) { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : DriveSetup + : tests!apps ; +} + Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.cpp 2007-12-09 15:41:31 UTC (rev 23095) @@ -8,6 +8,7 @@ * Stephan A?mus */ #include "MainWindow.h" +#include "DiskView.h" #include "PartitionList.h" #include "Support.h" @@ -51,6 +52,8 @@ MSG_EJECT = 'ejct', MSG_SURFACE_TEST = 'sfct', MSG_RESCAN = 'rscn', + + MSG_PARTITION_ROW_SELECTED = 'prsl', }; @@ -93,11 +96,24 @@ createMenu->AddItem(new BMenuItem("Logical", new BMessage(MSG_CREATE_LOGICAL))); + // add DiskView BRect r(Bounds()); r.top = rootMenu->Frame().bottom + 1; - fListView = new PartitionListView(r); + r.bottom = floorf(r.top + r.Height() * 0.33); + fDiskView = new DiskView(r, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); + AddChild(fDiskView); + + // add PartitionListView + r.top = r.bottom + 2; + r.bottom = Bounds().bottom; + r.InsetBy(-1, -1); + fListView = new PartitionListView(r, B_FOLLOW_ALL); AddChild(fListView); + // configure PartitionListView + fListView->SetSelectionMessage(new BMessage(MSG_PARTITION_ROW_SELECTED)); + fListView->SetTarget(this); + // Populate the Initialiaze menu with the available file systems _ScanFileSystems(); @@ -147,7 +163,12 @@ case MSG_RESCAN: _ScanDrives(); break; - + + case MSG_PARTITION_ROW_SELECTED: + printf("MSG_PARTITION_ROW_SELECTED\n"); + _AdaptToSelectedPartition(); + break; + default: BWindow::MessageReceived(message); break; @@ -227,6 +248,35 @@ } +void +MainWindow::_AdaptToSelectedPartition() +{ + BRow* _selectedRow = fListView->CurrentSelection(); + if (!_selectedRow) { + fDiskView->SetDisk(NULL, -1); + return; + } + + // recurse to top level row + BRow* _topLevelRow = _selectedRow; + BRow* parent = NULL; + while (fListView->FindParent(_topLevelRow, &parent, NULL)) + _topLevelRow = parent; + + PartitionListRow* topLevelRow + = dynamic_cast(_topLevelRow); + PartitionListRow* selectedRow + = dynamic_cast(_selectedRow); + + if (!topLevelRow || !selectedRow) + return; + + BDiskDevice* disk = new BDiskDevice(); + disk->SetTo(topLevelRow->ID()); + fDiskView->SetDisk(disk, selectedRow->ID()); +} + + // #pragma mark - DriveVisitor Modified: haiku/trunk/src/preferences/drivesetup/MainWindow.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/MainWindow.h 2007-12-09 15:41:31 UTC (rev 23095) @@ -13,6 +13,7 @@ class BDiskDevice; class BPartition; class BMenu; +class DiskView; class PartitionListView; @@ -28,18 +29,15 @@ status_t StoreSettings(BMessage* archive) const; status_t RestoreSettings(BMessage* archive); - // These are public for visitor.... - void AddPartition(BPartition* partition, - int32 level); - void AddDrive(BDiskDevice* device); - private: void _ScanDrives(); void _ScanFileSystems(); + void _AdaptToSelectedPartition(); BDiskDeviceRoster fDDRoster; PartitionListView* fListView; + DiskView* fDiskView; BMenu* fInitMenu; }; Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.cpp 2007-12-09 15:41:31 UTC (rev 23095) @@ -21,7 +21,7 @@ partition->GetPath(&path); -// SetField(new BBitmapField(NULL), 0); + SetField(new BBitmapField(NULL), 0); // if (partition->IsDevice()) // Only show device path for actual devices (so only for /dev/disk/..../raw entries) SetField(new BStringField(path.Path()), 1); @@ -38,24 +38,24 @@ SetField(new BStringField(partition->ContentType()), 2); // Filesystem SetField(new BStringField(partition->ContentName()), 3); // Volume Name } else { - SetField(new BStringField(""), 2); - SetField(new BStringField(""), 3); + SetField(new BStringField("n/a"), 2); + SetField(new BStringField("n/a"), 3); } if (partition->IsMounted() && partition->GetMountPoint(&path) == B_OK) { SetField(new BStringField(path.Path()), 4); } else { - SetField(new BStringField(""), 4); + SetField(new BStringField("n/a"), 4); } SetField(new BStringField(string_for_size(partition->Size(), size)), 5); } -PartitionListView::PartitionListView(const BRect& frame) - : Inherited(frame, "storagelist", B_FOLLOW_ALL, 0, B_NO_BORDER, true) +PartitionListView::PartitionListView(const BRect& frame, uint32 resizeMode) + : Inherited(frame, "storagelist", resizeMode, 0, B_NO_BORDER, true) { -// AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), 0); + AddColumn(new BBitmapColumn("", 20, 20, 100, B_ALIGN_CENTER), 0); AddColumn(new BStringColumn("Device", 100, 50, 500, B_TRUNCATE_MIDDLE), 1); AddColumn(new BStringColumn("Filesystem", 100, 50, 500, B_TRUNCATE_MIDDLE), 2); AddColumn(new BStringColumn("Volume Name", 100, 50, 500, B_TRUNCATE_MIDDLE), 3); Modified: haiku/trunk/src/preferences/drivesetup/PartitionList.h =================================================================== --- haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/PartitionList.h 2007-12-09 15:41:31 UTC (rev 23095) @@ -32,7 +32,8 @@ class PartitionListView : public BColumnListView { typedef BColumnListView Inherited; public: - PartitionListView(const BRect& frame); + PartitionListView(const BRect& frame, + uint32 resizeMode); PartitionListRow* FindRow(partition_id id, PartitionListRow* parent = NULL); Added: haiku/trunk/src/preferences/drivesetup/run =================================================================== --- haiku/trunk/src/preferences/drivesetup/run 2007-12-09 15:37:16 UTC (rev 23094) +++ haiku/trunk/src/preferences/drivesetup/run 2007-12-09 15:41:31 UTC (rev 23095) @@ -0,0 +1,18 @@ +#!/bin/sh + +../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit + +if test -f ../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then + ../../../generated/tests/libbe_test/x86/apps//haiku_app_server & +else + echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." +fi + +sleep 1s + +if test -f ../../../generated/tests/libbe_test/x86/apps/DriveSetup; then + ../../../generated/tests/libbe_test/x86/apps/DriveSetup +else + echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." +fi + From bonefish at mail.berlios.de Sun Dec 9 17:24:48 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Dec 2007 17:24:48 +0100 Subject: [Haiku-commits] r23096 - haiku/branches/developer/bonefish/optimization/headers/private/kernel Message-ID: <200712091624.lB9GOmi9001201@sheep.berlios.de> Author: bonefish Date: 2007-12-09 17:24:47 +0100 (Sun, 09 Dec 2007) New Revision: 23096 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23096&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/ksyscalls.h Log: Avoid warnings when denoted as struct syscall_info. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/ksyscalls.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/ksyscalls.h 2007-12-09 15:41:31 UTC (rev 23095) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/ksyscalls.h 2007-12-09 16:24:47 UTC (rev 23096) @@ -9,7 +9,7 @@ #include -typedef struct { +typedef struct syscall_info { void *function; // pointer to the syscall function int parameter_size; // summed up parameter size } syscall_info; From bonefish at mail.berlios.de Sun Dec 9 17:27:26 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Dec 2007 17:27:26 +0100 Subject: [Haiku-commits] r23097 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel src/system/kernel/arch/x86 Message-ID: <200712091627.lB9GRQZP001360@sheep.berlios.de> Author: bonefish Date: 2007-12-09 17:27:25 +0100 (Sun, 09 Dec 2007) New Revision: 23097 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23097&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp Log: Defined offset macros for all C structure members accessed by the syscall interrupt handler. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-09 16:24:47 UTC (rev 23096) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-09 16:27:25 UTC (rev 23097) @@ -186,8 +186,6 @@ int32 flags; // summary of events relevant in interrupt // handlers (signals pending, user debugging // enabled, etc.) - // (accessed from assembler code -- don't - // move!) struct thread *all_next; struct thread *team_next; struct thread *queue_next; /* i.e. run queue, release queue, etc. */ Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-09 16:24:47 UTC (rev 23096) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-09 16:27:25 UTC (rev 23097) @@ -163,7 +163,7 @@ .align 16 .globl trap99 trap99: - // push error, vector, old_edx, old_eax, and other registers + // push error, vector, orig_edx, orig_eax, and other registers pushl $0 pushl $99 pushl %edx @@ -187,8 +187,8 @@ // disable breakpoints, if installed cli // disable interrupts - movl %dr3, %edi // thread pointer (pointer to thread::flags) - testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, (%edi) + movl %dr3, %edi // thread pointer + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) jz skip_debug_at_kernel_entry call i386_exit_user_debug_at_kernel_entry skip_debug_at_kernel_entry: @@ -221,17 +221,19 @@ cmp $SYSCALL_COUNT, %esi // check syscall number jae bad_syscall_number movl $kSyscallInfos, %eax // get syscall info - lea (%eax, %esi, 8), %esi + lea (%eax, %esi, SYSCALL_INFO_sizeof), %esi // copy parameters onto this stack subl $80, %esp // leave some room for the syscall params - movl 80(%ebp), %eax // get the address of the syscall parameters + // get the address of the syscall parameters + movl IFRAME_user_esp(%ebp), %eax addl $4, %eax - cmp $KERNEL_BASE, %eax + cmp $KERNEL_BASE, %eax // must not be a kernel address jae bad_syscall_params - movl 4(%esi), %ebx // get and push the syscall parameter size + // get and push the syscall parameter size + movl SYSCALL_INFO_parameter_size(%esi), %ebx push %ebx push %eax @@ -243,21 +245,21 @@ jne bad_syscall_params // pre syscall debugging - testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jnz do_pre_syscall_debug pre_syscall_debug_done: // call the syscall function - call *(%esi) + call *SYSCALL_INFO_function(%esi) // overwrite the values of %eax and %edx on the stack (the syscall return // value) - movl %edx, 40(%ebp) - movl %eax, 48(%ebp) + movl %edx, IFRAME_edx(%ebp) + movl %eax, IFRAME_eax(%ebp) testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ - , (%edi) + , THREAD_flags(%edi) jnz post_syscall_work cli // disable interrupts @@ -298,7 +300,7 @@ do_pre_syscall_debug: movl %esp, %eax // syscall parameters push %eax - movl 52(%ebp), %eax // syscall number + movl IFRAME_orig_eax(%ebp), %eax // syscall number push %eax call user_debug_pre_syscall addl $8, %esp @@ -306,7 +308,7 @@ post_syscall_work: // post syscall debugging - testl $THREAD_FLAGS_DEBUGGER_INSTALLED, (%edi) + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jz post_syscall_debug_done movl -4(%ebp), %ecx // syscall start time push %ecx @@ -316,7 +318,7 @@ push %eax lea 16(%esp), %eax // syscall parameters push %eax - movl 52(%ebp), %eax // syscall number + movl IFRAME_orig_eax(%ebp), %eax // syscall number push %eax call user_debug_post_syscall addl $8, %esp @@ -326,14 +328,15 @@ bad_syscall_number: // if no signals are pending and the thread shall not be debugged, we can // use the quick kernel exit function - testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD), (%edi) + testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD) \ + , THREAD_flags(%edi) jnz kernel_exit_handle_signals cli // disable interrupts call thread_at_kernel_exit_no_signals kernel_exit_done: // install breakpoints, if defined - testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, (%edi) + testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) jz post_syscall_work_done push %ebp call i386_init_user_debug_at_kernel_exit Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-09 16:24:47 UTC (rev 23096) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-09 16:27:25 UTC (rev 23097) @@ -8,6 +8,8 @@ // a header file with macro definitions, that can be included from assembler // code. +#include +#include #include @@ -17,7 +19,10 @@ #define DEFINE_OFFSET_MACRO(prefix, structure, member) \ DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member)); +#define DEFINE_SIZEOF_MACRO(prefix, structure) \ + DEFINE_MACRO(prefix##_sizeof, sizeof(struct structure)); + void dummy() { @@ -26,4 +31,16 @@ DEFINE_OFFSET_MACRO(THREAD, thread, user_time); DEFINE_OFFSET_MACRO(THREAD, thread, last_time); DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); + DEFINE_OFFSET_MACRO(THREAD, thread, flags); + + // struct iframe + DEFINE_OFFSET_MACRO(IFRAME, iframe, eax); + DEFINE_OFFSET_MACRO(IFRAME, iframe, edx); + DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax); + DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp); + + // struct syscall_info + DEFINE_SIZEOF_MACRO(SYSCALL_INFO, syscall_info); + DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, function); + DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, parameter_size); } From mmu_man at mail.berlios.de Sun Dec 9 19:58:49 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sun, 9 Dec 2007 19:58:49 +0100 Subject: [Haiku-commits] r23098 - haiku/trunk/build/jam Message-ID: <200712091858.lB9IwnlA027160@sheep.berlios.de> Author: mmu_man Date: 2007-12-09 19:58:48 +0100 (Sun, 09 Dec 2007) New Revision: 23098 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23098&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add Links as an optional package. Text mode only but it will help waiting for WebKit to be usable :) Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-12-09 16:27:25 UTC (rev 23097) +++ haiku/trunk/build/jam/HaikuImage 2007-12-09 18:58:48 UTC (rev 23098) @@ -495,6 +495,16 @@ #UnzipArchiveToHaikuImage home : data/vv.mp3.zip : 0 ; } +# Links web browser +if [ IsOptionalHaikuImagePackageAdded Links ] { + InstallOptionalHaikuImagePackage Links + : http://revolf.free.fr/beos/links-beos-bin.zip + : + ; + AddSymlinkToHaikuImage home config be Applications + : /boot/home/config/bin/links ; +} + #pragma mark - Build The Image From mmlr at mail.berlios.de Sun Dec 9 21:42:48 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 9 Dec 2007 21:42:48 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200712092042.lB9Kgm3q005827@sheep.berlios.de> Author: mmlr Date: 2007-12-09 21:42:47 +0100 (Sun, 09 Dec 2007) New Revision: 23099 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23099&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp Log: * Use the rescan function when compiled for Haiku * Move waiting for the first explore to complete * Small cleanup Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-12-09 18:58:48 UTC (rev 23098) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp 2007-12-09 20:42:47 UTC (rev 23099) @@ -26,8 +26,6 @@ } - - void Pipe::InitCommon(int8 deviceAddress, uint8 endpointAddress, usb_speed speed, pipeDirection direction, size_t maxPacketSize, uint8 interval, Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-12-09 18:58:48 UTC (rev 23098) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-12-09 20:42:47 UTC (rev 23099) @@ -57,7 +57,7 @@ size_t bufferSize = sizeof(moduleName); TRACE(("USB Stack: looking for host controller modules\n")); - while(read_next_module_name(moduleList, moduleName, &bufferSize) == B_OK) { + while (read_next_module_name(moduleList, moduleName, &bufferSize) == B_OK) { bufferSize = sizeof(moduleName); TRACE(("USB Stack: found module %s\n", moduleName)); @@ -81,6 +81,12 @@ fExploreThread = spawn_kernel_thread(ExploreThread, "usb explore", B_LOW_PRIORITY, this); resume_thread(fExploreThread); + + // wait for the first explore to complete. this ensures that a driver that + // is opening the module does not get rescanned while or before installing + // its hooks. + while (!fFirstExploreDone) + snooze(100); } @@ -110,7 +116,6 @@ { if (fBusManagers.Count() == 0) return ENODEV; - return B_OK; } @@ -355,7 +360,7 @@ close(devFS); #else // use the private devfs API under Haiku - //devfs_rescan_driver(name); + devfs_rescan_driver(rescanItem->name); #endif rescan_item *next = rescanItem->link; @@ -436,11 +441,6 @@ { TRACE(("USB Stack: installing notify hooks for driver \"%s\"\n", driverName)); - // wait for the first explore to complete - // this ensures that we get all initial devices - while (!fFirstExploreDone) - snooze(1000); - usb_driver_info *element = fDriverList; while (element) { if (strcmp(element->driver_name, driverName) == 0) { From axeld at pinc-software.de Sun Dec 9 21:46:49 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 09 Dec 2007 21:46:49 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23099_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/bus=5Fmanagers/usb?= In-Reply-To: <200712092042.lB9Kgm3q005827@sheep.berlios.de> Message-ID: <32057318245-BeMail@zon> mmlr at BerliOS wrote: > + // wait for the first explore to complete. this ensures that a > driver that > + // is opening the module does not get rescanned while or before > installing > + // its hooks. > + while (!fFirstExploreDone) > + snooze(100); snooze(100) is pretty expensive, though. Do you really need that granularity? If so, maybe a dedicated semaphore is the better solution. Bye, Axel. From mmlr at mlotz.ch Sun Dec 9 21:52:13 2007 From: mmlr at mlotz.ch (Michael Lotz) Date: Sun, 09 Dec 2007 21:52:13 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <32057318245-BeMail@zon> Message-ID: <2238244582-BeMail@primary> Hi Axel > > + while (!fFirstExploreDone) > > + snooze(100); > > snooze(100) is pretty expensive, though. Do you really need that > granularity? If so, maybe a dedicated semaphore is the better > solution. I have set this pretty arbitrarily. Now that you mention it, the explore will take quite a bit of time (due to grace time when allocating and setting device address/configuration). So this could probably be made to snooze(10000) or snooze(100000). Would this be more realistic? Regards Michael From mmlr at mail.berlios.de Sun Dec 9 22:01:56 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 9 Dec 2007 22:01:56 +0100 Subject: [Haiku-commits] r23100 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/boot/platform/bios_ia32 Message-ID: <200712092101.lB9L1uwa006771@sheep.berlios.de> Author: mmlr Date: 2007-12-09 22:01:55 +0100 (Sun, 09 Dec 2007) New Revision: 23100 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23100&view=rev Added: haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h Modified: haiku/trunk/headers/private/kernel/arch/x86/smp_apic.h haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp Log: * Initial support for ACPI tables to detect multiprocessor configurations * ACPI is evaluated first as it also handles things like multi core or hyper threading setups * Removed other (disabled) hyper threading code per the notes in the corresponding ToDo * Limit the detected CPU count to 2 for now as I wasn't able to get it working in either emulation nor real hardware with more than 2 CPUs * Added a reserved byte to the mp_config_table struct, it worked only by luck as the compiler did padding there to get to the same size I can now boot my Core 2 Quad with two out of four processors active :-) Added: haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h 2007-12-09 20:42:47 UTC (rev 23099) +++ haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h 2007-12-09 21:01:55 UTC (rev 23100) @@ -0,0 +1,69 @@ +/* + * Copyright 2007, Michael Lotz, mmlr at mlotz.ch. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_x86_SMP_ACPI_H +#define _KERNEL_ARCH_x86_SMP_ACPI_H + +#define ACPI_RSDP_SIGNATURE "RSD PTR " +#define ACPI_RSDT_SIGNATURE "RSDT" +#define ACPI_MADT_SIGNATURE "APIC" + +struct acpi_rsdp { + char signature[8]; /* "RSD PTR " including blank */ + uint8 checksum; /* checksum of bytes 0-19 (per ACPI 1.0) */ + char oem_id[6]; /* not null terminated */ + uint8 revision; /* 0 = ACPI 1.0, 2 = ACPI 3.0 */ + uint32 rsdt_address; /* physical memory address of RSDT */ + uint32 rsdt_length; /* length in bytes including header */ + uint64 xsdt_address; /* 64bit physical memory address of XSDT */ + uint8 extended_checksum; /* including entire table */ + uint8 reserved[3]; +} _PACKED; + +struct acpi_descriptor_header { + char signature[4]; /* table identifier as ASCII string */ + uint32 length; /* length in bytes of the entire table */ + uint8 revision; + uint8 checksum; /* checksum of entire table */ + char oem_id[6]; /* not null terminated */ + char oem_table_id[8]; /* oem supplied table identifier */ + uint32 oem_revision; /* oem supplied revision number */ + char creator_id[4]; /* creator / asl compiler id */ + uint32 creator_revision; /* compiler revision */ +} _PACKED; + +struct acpi_madt { + acpi_descriptor_header header; /* "APIC" signature */ + uint32 local_apic_address; /* physical address for local CPUs APICs */ + uint32 flags; +} _PACKED; + +enum { + ACPI_MADT_LOCAL_APIC = 0, + ACPI_MADT_IO_APIC = 1 +}; + +struct acpi_apic { + uint8 type; + uint8 length; +} _PACKED; + +struct acpi_local_apic { + uint8 type; /* 0 = processor local APIC */ + uint8 length; /* 8 bytes */ + uint8 acpi_processor_id; + uint8 apic_id; /* the id of this APIC */ + uint32 flags; /* 1 = enabled */ +} _PACKED; + +struct acpi_io_apic { + uint8 type; /* 1 = I/O APIC */ + uint8 length; /* 12 bytes */ + uint8 io_apic_id; /* the id of this APIC */ + uint8 reserved; + uint32 io_apic_address; /* phyisical address of I/O APIC */ + uint32 interrupt_base; /* global system interrupt base */ +} _PACKED; + +#endif /* _KERNEL_ARCH_x86_SMP_ACPI_H */ Modified: haiku/trunk/headers/private/kernel/arch/x86/smp_apic.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/smp_apic.h 2007-12-09 20:42:47 UTC (rev 23099) +++ haiku/trunk/headers/private/kernel/arch/x86/smp_apic.h 2007-12-09 21:01:55 UTC (rev 23100) @@ -125,6 +125,7 @@ uint32 apic; /* address of apic */ uint16 ext_length; /* length of extended section */ uint8 ext_checksum; /* checksum of extended table entries */ + uint8 reserved; }; struct mp_floating_struct { Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-09 20:42:47 UTC (rev 23099) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-09 21:01:55 UTC (rev 23100) @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,11 @@ { 0, 0, 0 } }; +static struct smp_scan_spots_struct acpi_scan_spots[] = { + { 0x0, 0x400, 0x400 - 0x0 }, + { 0xe0000, 0x100000, 0x100000 - 0xe0000 }, + { 0, 0, 0 } +}; extern "C" void execute_n_instructions(int count); @@ -74,21 +80,6 @@ } -static bool -supports_hyper_threading(void) -{ - cpuid_info info; - if (get_current_cpuid(&info, 0) == B_OK - && !strncmp(info.eax_0.vendor_id, "GenuineIntel", 12) - && info.eax_0.max_eax > 0) { - if (get_current_cpuid(&info, 1) == B_OK) - return (info.eax_1.features & (1 << 28)) != 0; - } - - return false; -} - - static int smp_get_current_cpu(void) { @@ -100,15 +91,15 @@ static uint32 * -smp_probe(uint32 base, uint32 limit) +smp_mp_probe(uint32 base, uint32 limit) { uint32 *ptr; - TRACE(("smp_probe: entry base 0x%lx, limit 0x%lx\n", base, limit)); + TRACE(("smp_mp_probe: entry base 0x%lx, limit 0x%lx\n", base, limit)); for (ptr = (uint32 *) base; (uint32)ptr < limit; ptr++) { if (*ptr == MP_FLOATING_SIGNATURE) { - TRACE(("smp_probe: found floating pointer structure at %p\n", ptr)); + TRACE(("smp_mp_probe: found floating pointer structure at %p\n", ptr)); return ptr; } } @@ -116,8 +107,23 @@ } +static acpi_rsdp * +smp_acpi_probe(uint32 base, uint32 limit) +{ + TRACE(("smp_acpi_probe: entry base 0x%lx, limit 0x%lx\n", base, limit)); + for (char *pointer = (char *)base; (uint32)pointer < limit; pointer += 16) { + if (strncmp(pointer, ACPI_RSDP_SIGNATURE, 8) == 0) { + TRACE(("smp_acpi_probe: found ACPI RSDP signature at %p\n", pointer)); + return (acpi_rsdp *)pointer; + } + } + + return NULL; +} + + static void -smp_do_config(void) +smp_do_mp_config() { struct mp_config_table *config; char *ptr; @@ -138,11 +144,8 @@ /* print out our new found configuration. */ - ptr = (char *)&(config->oem[0]); - TRACE(("smp: oem id: %c%c%c%c%c%c%c%c product id: " - "%c%c%c%c%c%c%c%c%c%c%c%c\n", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], - ptr[5], ptr[6], ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], - ptr[13], ptr[14], ptr[15], ptr[16], ptr[17], ptr[18], ptr[19])); + TRACE(("smp: oem id: %.8s product id: %.12s\n", config->oem, + config->product)); TRACE(("smp: base table has %d entries, extended section %d bytes\n", config->num_base_entries, config->ext_length)); @@ -212,29 +215,89 @@ (void *)gKernelArgs.arch_args.ioapic_phys, gKernelArgs.num_cpus); - // Try to detect single CPU hyper threading setup - // ToDo: this should be done using the ACPI APIC table - // ToDo: this only works with a single HT enabled CPU anyway + // this BIOS looks broken, because it didn't report any cpus (VMWare) + if (gKernelArgs.num_cpus == 0) + gKernelArgs.num_cpus = 1; +} - if (gKernelArgs.num_cpus == 1 && supports_hyper_threading()) { - cpuid_info info; - get_current_cpuid(&info, 1); - dprintf("CPU supports Hyper-Threading, %ld processors in package\n", - info.eax_1.logical_cpus); +static status_t +smp_do_acpi_config(acpi_rsdp *rsdp) +{ + TRACE(("smp: using ACPI to detect MP configuration\n")); + TRACE(("smp: found rsdp at %p oem id: %.6s\n", rsdp, rsdp->oem_id)); + TRACE(("smp: rsdp points to rsdt at 0x%lx\n", rsdp->rsdt_address)); - // enable the second logical processor -/* - gKernelArgs.num_cpus = 2; - gKernelArgs.arch_args.cpu_apic_id[1] = gKernelArgs.arch_args.cpu_apic_id[0] + 1; - gKernelArgs.arch_args.cpu_os_id[gKernelArgs.arch_args.cpu_apic_id[1]] = 1; - gKernelArgs.arch_args.cpu_apic_version[1] = gKernelArgs.arch_args.cpu_apic_version[0];; -*/ + // reset CPU count + gKernelArgs.num_cpus = 0; + + // map and validate the root system description table + acpi_descriptor_header *rsdt + = (acpi_descriptor_header *)mmu_map_physical_memory( + rsdp->rsdt_address, B_PAGE_SIZE, kDefaultPageFlags); + if (!rsdt || strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) != 0) { + TRACE(("smp: invalid root system description table\n")); + return B_ERROR; } - // this BIOS looks broken, because it didn't report any cpus (VMWare) - if (gKernelArgs.num_cpus == 0) - gKernelArgs.num_cpus = 1; + int32 numEntries = (rsdt->length - sizeof(acpi_descriptor_header)) / 4; + if (numEntries <= 0) { + TRACE(("smp: root system description table is empty\n")); + return B_ERROR; + } + + TRACE(("smp: searching %ld entries for APIC information\n", numEntries)); + uint32 *pointer = (uint32 *)((uint8 *)rsdt + sizeof(acpi_descriptor_header)); + for (int32 j = 0; j < numEntries; j++, pointer++) { + acpi_descriptor_header *header = (acpi_descriptor_header *) + mmu_map_physical_memory(*pointer, B_PAGE_SIZE, kDefaultPageFlags); + if (!header || strncmp(header->signature, ACPI_MADT_SIGNATURE, 4) != 0) { + // not interesting for us + TRACE(("smp: skipping uninteresting header '%.4s'\n", header->signature)); + continue; + } + + acpi_madt *madt = (acpi_madt *)header; + gKernelArgs.arch_args.apic_phys = madt->local_apic_address; + TRACE(("smp: local apic address is 0x%lx\n", madt->local_apic_address)); + + acpi_apic *apic = (acpi_apic *)((uint8 *)madt + sizeof(acpi_madt)); + acpi_apic *end = (acpi_apic *)((uint8 *)madt + header->length); + while (apic < end) { + switch (apic->type) { + case ACPI_MADT_LOCAL_APIC: + { + acpi_local_apic *localApic = (acpi_local_apic *)apic; + TRACE(("smp: found local APIC with id %u\n", localApic->apic_id)); + gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = localApic->apic_id; + gKernelArgs.arch_args.cpu_os_id[localApic->apic_id] = gKernelArgs.num_cpus; + // ToDo: how to find out? putting 0x10 in to indicate a local apic + gKernelArgs.arch_args.cpu_apic_version[gKernelArgs.num_cpus] = 0x10; + gKernelArgs.num_cpus++; + break; + } + + case ACPI_MADT_IO_APIC: { + acpi_io_apic *ioApic = (acpi_io_apic *)apic; + TRACE(("smp: found io APIC with id %u and address 0x%lx\n", + ioApic->io_apic_id, ioApic->io_apic_address)); + gKernelArgs.arch_args.ioapic_phys = ioApic->io_apic_address; + break; + } + } + + apic = (acpi_apic *)((uint8 *)apic + apic->length); + } + + if (gKernelArgs.num_cpus > 0) + break; + } + + // ToDo: remove CPU limit + if (gKernelArgs.num_cpus > 2) + gKernelArgs.num_cpus = 2; + + return gKernelArgs.num_cpus > 0 ? B_OK : B_ERROR; } @@ -248,8 +311,18 @@ return gKernelArgs.num_cpus = 1; #endif + // first try to find ACPI tables to get MP configuration as it handles + // physical as well as logical MP configurations as in multiple cpus, + // multiple cores or hyper threading. + for (i = 0; acpi_scan_spots[i].length > 0; i++) { + acpi_rsdp *rsdp = smp_acpi_probe(smp_scan_spots[i].start, + smp_scan_spots[i].stop); + if (rsdp != NULL && smp_do_acpi_config(rsdp) == B_OK) + return gKernelArgs.num_cpus; + } + for (i = 0; smp_scan_spots[i].length > 0; i++) { - sFloatingStruct = (struct mp_floating_struct *)smp_probe(smp_scan_spots[i].start, + sFloatingStruct = (struct mp_floating_struct *)smp_mp_probe(smp_scan_spots[i].start, smp_scan_spots[i].stop); if (sFloatingStruct != NULL) break; @@ -265,6 +338,7 @@ if (sFloatingStruct->config_table == NULL) { // XXX need to implement #if 1 + TRACE(("smp: standard configuration %d unimplemented\n", sFloatingStruct->mp_feature_1)); gKernelArgs.num_cpus = 1; return 1; #else @@ -280,8 +354,9 @@ */ #endif } else { - smp_do_config(); + smp_do_mp_config(); } + return gKernelArgs.num_cpus; } @@ -515,18 +590,11 @@ if (gKernelArgs.num_cpus < 2) return; - // ToDo: this should work with dual CPUs with HT as well! - if (gKernelArgs.num_cpus > 2 || !supports_hyper_threading()) { + if (gKernelArgs.num_cpus > 2) { menu->AddItem(item = new(nothrow) MenuItem("Disable SMP")); item->SetData(B_SAFEMODE_DISABLE_SMP); item->SetType(MENU_ITEM_MARKABLE); } - - if (supports_hyper_threading()) { - menu->AddItem(item = new(nothrow) MenuItem("Disable Hyper-Threading")); - item->SetData(B_SAFEMODE_DISABLE_HYPER_THREADING); - item->SetType(MENU_ITEM_MARKABLE); - } } @@ -561,5 +629,3 @@ } } } - - From bonefish at mail.berlios.de Sun Dec 9 22:13:12 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 9 Dec 2007 22:13:12 +0100 Subject: [Haiku-commits] r23101 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200712092113.lB9LDCa3007265@sheep.berlios.de> Author: bonefish Date: 2007-12-09 22:13:11 +0100 (Sun, 09 Dec 2007) New Revision: 23101 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23101&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp Log: * Renamed the x86 user debugger functions from i386_* to x86_*. * x86_handle_debug_exception() and x86_handle_breakpoint_exception() do no longer have a return value -- it was constant (B_HANDLED_INTERRUPT) anyway. * Removed custom interrupt stack support. It was apparently not used. * Removed i386_handle_trap(). The assembly part does a little more now, and it uses a jump table to call the C function responsible for handling the respective interrupt. * i386_restore_frame_from_syscall() also does the necessary kernel exit work, now. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h 2007-12-09 21:01:55 UTC (rev 23100) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_user_debugger.h 2007-12-09 21:13:11 UTC (rev 23101) @@ -5,7 +5,7 @@ #ifndef _KERNEL_ARCH_X86_USER_DEBUGGER_H #define _KERNEL_ARCH_X86_USER_DEBUGGER_H -#define ARCH_INIT_USER_DEBUG i386_init_user_debug +#define ARCH_INIT_USER_DEBUG x86_init_user_debug // number of breakpoints the CPU supports // Actually it supports 4, but DR3 is used to hold the struct thread*. @@ -117,13 +117,13 @@ struct iframe; struct thread; -extern void i386_init_user_debug_at_kernel_exit(struct iframe *frame); -extern void i386_exit_user_debug_at_kernel_entry(); +extern void x86_init_user_debug_at_kernel_exit(struct iframe *frame); +extern void x86_exit_user_debug_at_kernel_entry(); -extern int i386_handle_debug_exception(struct iframe *frame); -extern int i386_handle_breakpoint_exception(struct iframe *frame); +extern void x86_handle_debug_exception(struct iframe *frame); +extern void x86_handle_breakpoint_exception(struct iframe *frame); -extern void i386_init_user_debug(); +extern void x86_init_user_debug(); #ifdef __cplusplus } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-09 21:01:55 UTC (rev 23100) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_int.c 2007-12-09 21:13:11 UTC (rev 23101) @@ -107,7 +107,13 @@ static uint16 sLevelTriggeredInterrupts; // binary mask: 1 level, 0 edge +// table with functions handling respective interrupts +typedef void interrupt_handler_function(struct iframe* frame); +#define INTERRUPT_HANDLER_TABLE_SIZE 256 +interrupt_handler_function* gInterruptHandlerTable[ + INTERRUPT_HANDLER_TABLE_SIZE]; + static void set_gate(desc_table *gate_addr, addr_t addr, int type, int dpl) { @@ -318,254 +324,192 @@ static void -fatal_exception(struct iframe *frame) +invalid_exception(struct iframe* frame) { + struct thread* thread = thread_get_current_thread(); char name[32]; - panic("Fatal exception \"%s\" occurred! Error code: 0x%lx\n", - exception_name(frame->vector, name, sizeof(name)), frame->error_code); + panic("unhandled trap 0x%lx (%s) at ip 0x%lx, thread 0x%lx!\n", + frame->vector, exception_name(frame->vector, name, sizeof(name)), + frame->eip, thread ? thread->id : -1); } static void -unexpected_exception(struct iframe *frame, debug_exception_type type, - int signal) +fatal_exception(struct iframe *frame) { - if (frame->cs == USER_CODE_SEG) { - enable_interrupts(); - - if (user_debug_exception_occurred(type, signal)) - send_signal(team_get_current_team_id(), signal); - } else { - char name[32]; - panic("Unexpected exception \"%s\" occurred in kernel mode! " - "Error code: 0x%lx\n", - exception_name(frame->vector, name, sizeof(name)), - frame->error_code); - } + char name[32]; + panic("Fatal exception \"%s\" occurred! Error code: 0x%lx\n", + exception_name(frame->vector, name, sizeof(name)), frame->error_code); } -/* keep the compiler happy, this function must be called only from assembly */ -void i386_handle_trap(struct iframe frame); - -void -i386_handle_trap(struct iframe frame) +static void +unexpected_exception(struct iframe* frame) { - struct thread *thread = thread_get_current_thread(); - int ret = B_HANDLED_INTERRUPT; - cpu_status state; + debug_exception_type type; + int signal; - // all exceptions besides 3 (breakpoint), and 99 (syscall) enter this - // function with interrupts disabled - - state = disable_interrupts(); - - if (frame.cs == USER_CODE_SEG) { - i386_exit_user_debug_at_kernel_entry(); - thread_at_kernel_entry(system_time()); - } - - restore_interrupts(state); - -// if(frame.vector != 0x20) -// dprintf("i386_handle_trap: vector 0x%x, ip 0x%x, cpu %d\n", frame.vector, frame.eip, smp_get_current_cpu()); - - switch (frame.vector) { - // fatal exceptions - - case 2: // NMI Interrupt - case 9: // Coprocessor Segment Overrun - case 7: // Device Not Available Exception (#NM) - case 10: // Invalid TSS Exception (#TS) - case 11: // Segment Not Present (#NP) - case 12: // Stack Fault Exception (#SS) - case 18: // Machine-Check Exception (#MC) - fatal_exception(&frame); - break; - - case 8: // Double Fault Exception (#DF) - { - // The double fault iframe contains no useful information (as - // per Intel's architecture spec). Thus we simply save the - // information from the (unhandable) exception which caused the - // double in our iframe. This will result even in useful stack - // traces. Only problem is that we trust that at least the - // TSS is still accessible. - struct tss *tss = &gCPU[smp_get_current_cpu()].arch.tss; - - frame.cs = tss->cs; - frame.es = tss->es; - frame.ds = tss->ds; - frame.fs = tss->fs; - frame.gs = tss->gs; - frame.eip = tss->eip; - frame.ebp = tss->ebp; - frame.esp = tss->esp; - frame.eax = tss->eax; - frame.ebx = tss->ebx; - frame.ecx = tss->ecx; - frame.edx = tss->edx; - frame.esi = tss->esi; - frame.edi = tss->edi; - frame.flags = tss->eflags; - - panic("double fault!\n"); - - break; - } - - // exceptions we can handle - // (most of them only when occurring in userland) - + switch (frame->vector) { case 0: // Divide Error Exception (#DE) - unexpected_exception(&frame, B_DIVIDE_ERROR, SIGFPE); + type = B_DIVIDE_ERROR; + signal = SIGFPE; break; - case 1: // Debug Exception (#DB) - ret = i386_handle_debug_exception(&frame); - break; - - case 3: // Breakpoint Exception (#BP) - ret = i386_handle_breakpoint_exception(&frame); - break; - case 4: // Overflow Exception (#OF) - unexpected_exception(&frame, B_OVERFLOW_EXCEPTION, SIGTRAP); + type = B_OVERFLOW_EXCEPTION; + signal = SIGTRAP; break; case 5: // BOUND Range Exceeded Exception (#BR) - unexpected_exception(&frame, B_BOUNDS_CHECK_EXCEPTION, SIGTRAP); + type = B_BOUNDS_CHECK_EXCEPTION; + signal = SIGTRAP; break; case 6: // Invalid Opcode Exception (#UD) - unexpected_exception(&frame, B_INVALID_OPCODE_EXCEPTION, SIGILL); + type = B_INVALID_OPCODE_EXCEPTION; + signal = SIGILL; break; case 13: // General Protection Exception (#GP) - unexpected_exception(&frame, B_GENERAL_PROTECTION_FAULT, SIGKILL); + type = B_GENERAL_PROTECTION_FAULT; + signal = SIGKILL; break; - case 14: // Page-Fault Exception (#PF) - { - bool kernelDebugger = debug_debugger_running(); - unsigned int cr2; - addr_t newip; - - asm("movl %%cr2, %0" : "=r" (cr2)); - - if (kernelDebugger) { - // if this thread has a fault handler, we're allowed to be here - if (thread && thread->fault_handler != NULL) { - frame.eip = thread->fault_handler; - break; - } - - // otherwise, not really - panic("page fault in debugger without fault handler! Touching " - "address %p from eip %p\n", (void *)cr2, (void *)frame.eip); - break; - } else if ((frame.flags & 0x200) == 0) { - // if the interrupts were disabled, and we are not running the kernel startup - // the page fault was not allowed to happen and we must panic - panic("page fault, but interrupts were disabled. Touching address " - "%p from eip %p\n", (void *)cr2, (void *)frame.eip); - break; - } else if (thread != NULL && thread->page_faults_allowed < 1) { - panic("page fault not allowed at this place. Touching address " - "%p from eip %p\n", (void *)cr2, (void *)frame.eip); - } - - enable_interrupts(); - - ret = vm_page_fault(cr2, frame.eip, - (frame.error_code & 0x2) != 0, // write access - (frame.error_code & 0x4) != 0, // userland - &newip); - if (newip != 0) { - // the page fault handler wants us to modify the iframe to set the - // IP the cpu will return to to be this ip - frame.eip = newip; - } - break; - } - case 16: // x87 FPU Floating-Point Error (#MF) - unexpected_exception(&frame, B_FLOATING_POINT_EXCEPTION, SIGFPE); + type = B_FLOATING_POINT_EXCEPTION; + signal = SIGFPE; break; case 17: // Alignment Check Exception (#AC) - unexpected_exception(&frame, B_ALIGNMENT_EXCEPTION, SIGTRAP); + type = B_ALIGNMENT_EXCEPTION; + signal = SIGTRAP; break; case 19: // SIMD Floating-Point Exception (#XF) - unexpected_exception(&frame, B_FLOATING_POINT_EXCEPTION, SIGFPE); + type = B_FLOATING_POINT_EXCEPTION; + signal = SIGFPE; break; - case 99: // syscall - { - uint64 retcode; - unsigned int args[MAX_ARGS]; + default: + invalid_exception(frame); + return; + } -#if 0 + if (frame->cs == USER_CODE_SEG) { + enable_interrupts(); + + if (user_debug_exception_occurred(type, signal)) + send_signal(team_get_current_team_id(), signal); + } else { + char name[32]; + panic("Unexpected exception \"%s\" occurred in kernel mode! " + "Error code: 0x%lx\n", + exception_name(frame->vector, name, sizeof(name)), + frame->error_code); + } +} + + +static void +double_fault_exception(struct iframe* frame) { - int i; - dprintf("i386_handle_trap: syscall %d, count %d, ptr 0x%x\n", frame.eax, frame.ecx, frame.edx); - dprintf(" call stack:\n"); - for(i=0; ics = tss->cs; + frame->es = tss->es; + frame->ds = tss->ds; + frame->fs = tss->fs; + frame->gs = tss->gs; + frame->eip = tss->eip; + frame->ebp = tss->ebp; + frame->esp = tss->esp; + frame->eax = tss->eax; + frame->ebx = tss->ebx; + frame->ecx = tss->ecx; + frame->edx = tss->edx; + frame->esi = tss->esi; + frame->edi = tss->edi; + frame->flags = tss->eflags; + + panic("double fault!\n"); } -#endif - /* syscall interface works as such: - * %eax has syscall # - * %esp + 4 points to the syscall parameters - */ - if (frame.eax >= 0 && frame.eax < kSyscallCount) { - void *params = (void*)(frame.user_esp + 4); - int paramSize = kSyscallInfos[frame.eax].parameter_size; - if (IS_KERNEL_ADDRESS((addr_t)params) - || user_memcpy(args, params, paramSize) < B_OK) { - retcode = B_BAD_ADDRESS; - } else - ret = syscall_dispatcher(frame.eax, (void *)args, &retcode); - } else { - // invalid syscall number - retcode = EINVAL; - } - frame.eax = retcode & 0xffffffff; - frame.edx = retcode >> 32; - break; + + +static void +page_fault_exception(struct iframe* frame) +{ + struct thread *thread = thread_get_current_thread(); + bool kernelDebugger = debug_debugger_running(); + unsigned int cr2; + addr_t newip; + + asm("movl %%cr2, %0" : "=r" (cr2)); + + if (kernelDebugger) { + // if this thread has a fault handler, we're allowed to be here + if (thread && thread->fault_handler != NULL) { + frame->eip = thread->fault_handler; + return; } - default: - if (frame.vector >= ARCH_INTERRUPT_BASE) { - bool levelTriggered = pic_is_level_triggered(frame.vector); + // otherwise, not really + panic("page fault in debugger without fault handler! Touching " + "address %p from eip %p\n", (void *)cr2, (void *)frame->eip); + return; + } else if ((frame->flags & 0x200) == 0) { + // if the interrupts were disabled, and we are not running the kernel startup + // the page fault was not allowed to happen and we must panic + panic("page fault, but interrupts were disabled. Touching address " + "%p from eip %p\n", (void *)cr2, (void *)frame->eip); + return; + } else if (thread != NULL && thread->page_faults_allowed < 1) { + panic("page fault not allowed at this place. Touching address " + "%p from eip %p\n", (void *)cr2, (void *)frame->eip); + return; + } - // This is a workaround for spurious assertions of interrupts 7/15 - // which seems to be an often seen problem on the PC platform - if (pic_is_spurious_interrupt(frame.vector - ARCH_INTERRUPT_BASE)) { - TRACE(("got spurious interrupt at vector %ld\n", frame.vector)); - break; - } + enable_interrupts(); - if (!levelTriggered) - pic_end_of_interrupt(frame.vector); + vm_page_fault(cr2, frame->eip, + (frame->error_code & 0x2) != 0, // write access + (frame->error_code & 0x4) != 0, // userland + &newip); + if (newip != 0) { + // the page fault handler wants us to modify the iframe to set the + // IP the cpu will return to to be this ip + frame->eip = newip; + } +} - ret = int_io_interrupt_handler(frame.vector - ARCH_INTERRUPT_BASE, - levelTriggered); - if (levelTriggered) - pic_end_of_interrupt(frame.vector); - } else { - char name[32]; - panic("i386_handle_trap: unhandled trap 0x%lx (%s) at ip 0x%lx, " - "thread 0x%lx!\n", frame.vector, - exception_name(frame.vector, name, sizeof(name)), frame.eip, - thread ? thread->id : -1); - ret = B_HANDLED_INTERRUPT; - } - break; +static void +hardware_interrupt(struct iframe* frame) +{ + bool levelTriggered = pic_is_level_triggered(frame->vector); + int ret; + + // This is a workaround for spurious assertions of interrupts 7/15 + // which seems to be an often seen problem on the PC platform + if (pic_is_spurious_interrupt(frame->vector - ARCH_INTERRUPT_BASE)) { + TRACE(("got spurious interrupt at vector %ld\n", frame->vector)); + return; } + if (!levelTriggered) + pic_end_of_interrupt(frame->vector); + + ret = int_io_interrupt_handler(frame->vector - ARCH_INTERRUPT_BASE, + levelTriggered); + + if (levelTriggered) + pic_end_of_interrupt(frame->vector); + if (ret == B_INVOKE_SCHEDULER) { cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); @@ -575,27 +519,15 @@ RELEASE_THREAD_LOCK(); restore_interrupts(state); } - - if (frame.cs == USER_CODE_SEG) { - enable_interrupts(); - // interrupts are not enabled at this point if we came from - // a hardware interrupt - thread_at_kernel_exit(); - disable_interrupts(); - // keep interrupts disabled till returning from the interrupt - // -- required to avoid a race condition after setting the debug - // registers - i386_init_user_debug_at_kernel_exit(&frame); - } else - disable_interrupts(); - -// dprintf("0x%x cpu %d!\n", thread_get_current_thread_id(), smp_get_current_cpu()); } status_t arch_int_init(kernel_args *args) { + int i; + interrupt_handler_function** table; + // set the global sIDT variable sIDT = (desc_table *)args->arch_args.vir_idt; @@ -640,7 +572,7 @@ set_intr_gate(46, &trap46); set_intr_gate(47, &trap47); -set_system_gate(98, &trap98); // for performance testing only + set_system_gate(98, &trap98); // for performance testing only set_system_gate(99, &trap99); set_intr_gate(251, &trap251); @@ -649,6 +581,35 @@ set_intr_gate(254, &trap254); set_intr_gate(255, &trap255); + // init interrupt handler table + table = gInterruptHandlerTable; + + // defaults + for (i = 0; i < ARCH_INTERRUPT_BASE; i++) + table[i] = invalid_exception; + for (i = ARCH_INTERRUPT_BASE; i < INTERRUPT_HANDLER_TABLE_SIZE; i++) + table[i] = hardware_interrupt; + + table[0] = unexpected_exception; // Divide Error Exception (#DE) + table[1] = x86_handle_debug_exception; // Debug Exception (#DB) + table[2] = fatal_exception; // NMI Interrupt + table[3] = x86_handle_breakpoint_exception; // Breakpoint Exception (#BP) + table[4] = unexpected_exception; // Overflow Exception (#OF) + table[5] = unexpected_exception; // BOUND Range Exceeded Exception (#BR) + table[6] = unexpected_exception; // Invalid Opcode Exception (#UD) + table[7] = fatal_exception; // Device Not Available Exception (#NM) + table[8] = double_fault_exception; // Double Fault Exception (#DF) + table[9] = fatal_exception; // Coprocessor Segment Overrun + table[10] = fatal_exception; // Invalid TSS Exception (#TS) + table[11] = fatal_exception; // Segment Not Present (#NP) + table[12] = fatal_exception; // Stack Fault Exception (#SS) + table[13] = unexpected_exception; // General Protection Exception (#GP) + table[14] = page_fault_exception; // Page-Fault Exception (#PF) + table[16] = unexpected_exception; // x87 FPU Floating-Point Error (#MF) + table[17] = unexpected_exception; // Alignment Check Exception (#AC) + table[18] = fatal_exception; // Machine-Check Exception (#MC) + table[19] = unexpected_exception; // SIMD Floating-Point Exception (#XF) + return B_OK; } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-09 21:01:55 UTC (rev 23100) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-09 21:13:11 UTC (rev 23101) @@ -1,11 +1,11 @@ /* -** Copyright 2002-2004, The Haiku Team. All rights reserved. -** Distributed under the terms of the Haiku License. -** -** Copyright 2001, Travis Geiselbrecht. All rights reserved. -** Copyright 2002, Michael Noisternig. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ + * Copyright 2002-2007, The Haiku Team. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Copyright 2002, Michael Noisternig. All rights reserved. + * Distributed under the terms of the NewOS License. + */ #include #include @@ -16,8 +16,71 @@ #include "syscall_numbers.h" #include "syscall_table.h" + #define FUNCTION(x) .global x; .type x, at function; x +#define UPDATE_THREAD_USER_TIME_COMMON() \ + movl %eax, %ebx; /* save for later */ \ + movl %edx, %ecx; \ + \ + /* thread->user_time += now - thread->last_time; */ \ + sub THREAD_last_time(%edi), %eax; \ + sbb (THREAD_last_time + 4)(%edi), %edx; \ + add %eax, THREAD_user_time(%edi); \ + adc %edx, (THREAD_user_time + 4)(%edi); \ + \ + /* thread->last_time = now; */ \ + movl %ebx, THREAD_last_time(%edi); \ + movl %ecx, (THREAD_last_time + 4)(%edi); \ + \ + /* thread->in_kernel = true; */ \ + movb $1, THREAD_in_kernel(%edi) + +#define UPDATE_THREAD_USER_TIME() \ + call system_time; \ + UPDATE_THREAD_USER_TIME_COMMON() + +#define UPDATE_THREAD_USER_TIME_PUSH_TIME() \ + call system_time; \ + push %edx; \ + push %eax; \ + UPDATE_THREAD_USER_TIME_COMMON() + +#define UPDATE_THREAD_KERNEL_TIME() \ + call system_time; \ + \ + movl %eax, %ebx; /* save for later */ \ + movl %edx, %ecx; + \ + /* thread->kernel_time += now - thread->last_time; */ \ + sub THREAD_last_time(%edi), %eax; \ + sbb (THREAD_last_time + 4)(%edi), %edx; \ + add %eax, THREAD_kernel_time(%edi); \ + adc %edx, (THREAD_kernel_time + 4)(%edi); \ + \ + /* thread->last_time = now; */ \ + movl %ebx, THREAD_last_time(%edi); \ + movl %ecx, (THREAD_last_time + 4)(%edi); \ + \ + /* thread->in_kernel = false; */ \ + movb $0, THREAD_in_kernel(%edi) + +#define POP_IFRAME_AND_RETURN() \ + /* skip iframe type */ \ + lea 4(%ebp), %esp; \ + \ + pop %gs; \ + addl $4, %esp; /* we skip %fs, as this contains the CPU \ + dependent TLS segment */ \ + pop %es; \ + pop %ds; \ + \ + popa; \ + addl $16,%esp; /* ignore the vector, error code, and \ + original eax/edx values */ \ + iret + + .text #define TRAP_ERRC(name, vector) \ @@ -97,6 +160,7 @@ TRAP(trap254, 254) TRAP(trap255, 255) + .align 16 .globl int_bottom int_bottom: @@ -106,53 +170,55 @@ push %fs push %gs push $IFRAME_TYPE_OTHER + + movl %esp, %ebp // frame pointer is the iframe + + cmp $USER_CODE_SEG, IFRAME_cs(%ebp) + je int_bottom_user + + pushl %ebp + movl IFRAME_vector(%ebp), %eax + call *gInterruptHandlerTable(, %eax, 4) + + POP_IFRAME_AND_RETURN() + + +int_bottom_user: movl $KERNEL_DATA_SEG,%eax cld movl %eax,%ds movl %eax,%es - movl %ss,%ebx - movl %esp,%esi // save the old stack pointer - cmpl %eax,%ebx // check if we changed the stack - jne custom_stack - kernel_stack: - movl %esp, %ebp // frame pointer is the iframe - call i386_handle_trap - addl $4, %esp // skip iframe type - pop %gs - addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment - pop %es - pop %ds - popa - addl $16,%esp // ignore the vector, error code, and original eax/edx values - iret - // custom stack -> copy registers to kernel stack and switch there - custom_stack: - movl %dr3,%edx // get current struct thread - movl %eax,%es // the iframe is on the wrong stack - addl _interrupt_stack_offset,%edx - lss (%edx),%esp - movl %ebx,%ds // point %ds to the user stack segment - subl $92,%esp - movl %esp,%edi // copy to the current stack - movl $21,%ecx // copy sizeof(iframe) - rep movsl // %esi still points to the old custom stack address - movl %eax,%ds - subl $84,%esi - movl %esi,(%edi) // save custom stack address and segment *after* the - movl %ebx,4(%edi) // iframe structure on the stack - movl %esp, %ebp // frame pointer is the iframe - call i386_handle_trap - lss 84(%esp),%esp // reload custom stack address - pop %gs - pop %fs // doesn't come from userland, doesn't need TLS, may have changed %fs - pop %es - pop %ds - popa - addl $16,%esp // ignore the vector, error code, and original eax/edx values - iret + // disable breakpoints, if installed + cli // disable interrupts + movl %dr3, %edi // thread pointer + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) + jz int_bottom_user_skip_debug_at_kernel_entry + call x86_exit_user_debug_at_kernel_entry + int_bottom_user_skip_debug_at_kernel_entry: + // update the thread's user time + UPDATE_THREAD_USER_TIME() + // leave interrupts disabled -- the handler will enable them, if + // necessary + + pushl %ebp + movl IFRAME_vector(%ebp), %eax + call *gInterruptHandlerTable(, %eax, 4) + + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + , THREAD_flags(%edi) + jnz kernel_exit_work + + cli // disable interrupts + + // update the thread's kernel time and return + UPDATE_THREAD_KERNEL_TIME() + POP_IFRAME_AND_RETURN() + + // test interrupt handler for performance measurements .align 16 .globl trap98 @@ -173,7 +239,7 @@ push %es push %fs push %gs - push $IFRAME_TYPE_OTHER + push $IFRAME_TYPE_SYSCALL // save %eax, the number of the syscall movl %eax, %esi @@ -190,32 +256,13 @@ movl %dr3, %edi // thread pointer testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) jz skip_debug_at_kernel_entry - call i386_exit_user_debug_at_kernel_entry + call x86_exit_user_debug_at_kernel_entry skip_debug_at_kernel_entry: // update the thread's user time - - call system_time - push %edx - push %eax + UPDATE_THREAD_USER_TIME_PUSH_TIME() // leave the time on the stack (needed for post syscall debugging) - movl %eax, %ebx // save for later - movl %edx, %ecx - - // thread->user_time += now - thread->last_time; - sub THREAD_last_time(%edi), %eax - sbb (THREAD_last_time + 4)(%edi), %edx - add %eax, THREAD_user_time(%edi) - adc %edx, (THREAD_user_time + 4)(%edi) - - // thread->last_time = now; - movl %ebx, THREAD_last_time(%edi) - movl %ecx, (THREAD_last_time + 4)(%edi) - - // thread->in_kernel = true; - movb $1, THREAD_in_kernel(%edi) - sti // enable interrupts cmp $SYSCALL_COUNT, %esi // check syscall number @@ -264,39 +311,10 @@ cli // disable interrupts - // update the thread's kernel time + // update the thread's kernel time and return + UPDATE_THREAD_KERNEL_TIME() + POP_IFRAME_AND_RETURN() - call system_time - - movl %eax, %ebx // save for later - movl %edx, %ecx - - // thread->kernel_time += now - thread->last_time; - sub THREAD_last_time(%edi), %eax - sbb (THREAD_last_time + 4)(%edi), %edx - add %eax, THREAD_kernel_time(%edi) - adc %edx, (THREAD_kernel_time + 4)(%edi) - - // thread->last_time = now; - movl %ebx, THREAD_last_time(%edi) - movl %ecx, (THREAD_last_time + 4)(%edi) - - // thread->in_kernel = false; - movb $0, THREAD_in_kernel(%edi) - -post_syscall_work_done: - movl %ebp, %esp // remove all parameters from the stack - - addl $4, %esp // skip iframe type - pop %gs - addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment - pop %es - pop %ds - - popa - addl $16,%esp // ignore the vector, error code, and original eax/edx values - iret - do_pre_syscall_debug: movl %esp, %eax // syscall parameters push %eax @@ -310,10 +328,8 @@ // post syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jz post_syscall_debug_done - movl -4(%ebp), %ecx // syscall start time - push %ecx - movl -8(%ebp), %ecx - push %ecx + pushl -4(%ebp) // syscall start time + pushl -8(%ebp) push %edx // syscall return value push %eax lea 16(%esp), %eax // syscall parameters @@ -326,6 +342,7 @@ bad_syscall_params: bad_syscall_number: + kernel_exit_work: // if no signals are pending and the thread shall not be debugged, we can // use the quick kernel exit function testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD) \ @@ -333,62 +350,28 @@ jnz kernel_exit_handle_signals cli // disable interrupts call thread_at_kernel_exit_no_signals - kernel_exit_done: + kernel_exit_work_done: // install breakpoints, if defined testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) - jz post_syscall_work_done + jz kernel_exit_skip_breakpoints push %ebp - call i386_init_user_debug_at_kernel_exit - jmp post_syscall_work_done + call x86_init_user_debug_at_kernel_exit + kernel_exit_skip_breakpoints: + POP_IFRAME_AND_RETURN() kernel_exit_handle_signals: call thread_at_kernel_exit cli // disable interrupts - jmp kernel_exit_done + jmp kernel_exit_work_done -_interrupt_stack_offset: -.long 0 - // this value will be maintained by the function below - -// void i386_stack_init(struct farcall *interrupt_stack_offset) - /* setup in arch_thread.c: arch_thread_init_thread_struct() */ -FUNCTION(i386_stack_init): - movl 4(%esp),%eax - movl %eax,_interrupt_stack_offset - ret - -// void i386_stack_switch(struct farcall new_stack) -FUNCTION(i386_stack_switch): - movl %dr3,%eax // get_current_thread - movl (%esp),%edx - pushf - popl %ecx - addl _interrupt_stack_offset,%eax - cli - pushl %ss - cmpl $KERNEL_DATA_SEG,(%esp) - je kernel_stack2 - popl %eax - jmp switch - kernel_stack2: - popl 4(%eax) - movl %esp,(%eax) - switch: - lss 4(%esp),%esp - pushl %ecx - popf - jmp *%edx - - -/** Is copied to the signal stack call to restore the original frame when - * the signal handler exits. - * The copying code (in arch_thread.c::arch_setup_signal_frame()) copies - * everything between the i386_return_from_signal and i386_end_return_from_signal - * symbols. - */ - +/*! Is copied to the signal stack call to restore the original frame when + the signal handler exits. + The copying code (in arch_thread.c::arch_setup_signal_frame()) copies + everything between the i386_return_from_signal and i386_end_return_from_signal + symbols. +*/ FUNCTION(i386_return_from_signal): addl $12, %esp // Flushes the 3 arguments to sa_handler movl $SYSCALL_RESTORE_SIGNAL_FRAME, %eax @@ -401,20 +384,21 @@ FUNCTION(i386_end_return_from_signal): -/** void i386_restore_frame_from_syscall(struct iframe iframe); - * Pops the regs of the iframe from the stack to make it current and then - * return to userland. - */ - +/*! void i386_restore_frame_from_syscall(struct iframe iframe); + Pops the regs of the iframe from the stack to make it current and then + return to userland. + Interrupts are disabled. +*/ FUNCTION(i386_restore_frame_from_syscall): - addl $8, %esp // make the iframe our current stack position (we don't need the - // return address anymore, as we will use the one of the frame) - // also skip iframe type - pop %gs // recreate the frame environment - addl $4, %esp // we skip %fs, as this contains the CPU dependent TLS segment - pop %es - pop %ds - popa - addl $16,%esp // ignore the vector, error code, and original eax/edx values - // (which contain the syscall number and argument pointer) - iret + lea 4(%esp), %ebp // iframe to %ebp + + // check, if any kernel exit work has to be done + movl %dr3, %edi + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + , THREAD_flags(%edi) + jnz kernel_exit_work + + // update the thread's kernel time and return + UPDATE_THREAD_KERNEL_TIME() + POP_IFRAME_AND_RETURN() Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-09 21:01:55 UTC (rev 23100) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-09 21:13:11 UTC (rev 23101) @@ -54,10 +54,6 @@ else i386_fnsave(sInitialState.fpu_state); - // let the asm function know the offset to the interrupt stack within struct thread - // I know no better ( = static) way to tell the asm function the offset - i386_stack_init(&((struct thread *)0)->arch_info.interrupt_stack); - return B_OK; } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-09 21:01:55 UTC (rev 23100) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_user_debugger.cpp 2007-12-09 21:13:11 UTC (rev 23101) @@ -710,7 +710,7 @@ * Interrupts are disabled. */ void -i386_init_user_debug_at_kernel_exit(struct iframe *frame) +x86_init_user_debug_at_kernel_exit(struct iframe *frame) { struct thread *thread = thread_get_current_thread(); @@ -738,7 +738,7 @@ * Interrupts are disabled. */ void -i386_exit_user_debug_at_kernel_entry() +x86_exit_user_debug_at_kernel_entry() { struct thread *thread = thread_get_current_thread(); @@ -768,8 +768,8 @@ /** * Interrupts are disabled and will be enabled by the function. */ -int -i386_handle_debug_exception(struct iframe *frame) +void +x86_handle_debug_exception(struct iframe *frame) { // get debug status and control registers uint32 dr6, dr7; @@ -781,7 +781,7 @@ if (frame->cs != USER_CODE_SEG) { panic("debug exception in kernel mode: dr6: 0x%lx, dr7: 0x%lx", dr6, dr7); - return B_HANDLED_INTERRUPT; + return; } [... truncated: 58 lines follow ...] From axeld at pinc-software.de Sun Dec 9 23:03:45 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 09 Dec 2007 23:03:45 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23100_-_in_haiku/trunk=3A_header?= =?iso-8859-15?q?s/private/kernel/arch/x86__src/system/boot/platform/bios?= =?iso-8859-15?q?=5Fia32?= In-Reply-To: <200712092101.lB9L1uwa006771@sheep.berlios.de> Message-ID: <2525070322-BeMail@zon> mmlr at BerliOS wrote: > + if (gKernelArgs.num_cpus > 2) { > menu->AddItem(item = new(nothrow) MenuItem("Disable SMP")); BTW that should probably be >= 2 (was obviously wrong before, too) :-) Nice changes! I originally planned to move the SMP stuff into the kernel for proper ACPI handling, if it works that way, too, why not :) Any idea why it does not work for you with more than 2 CPUs active? (MMU issue??) Bye, Axel. From axeld at pinc-software.de Sun Dec 9 23:04:39 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 09 Dec 2007 23:04:39 +0100 CET Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <2238244582-BeMail@primary> Message-ID: <2579263524-BeMail@zon> Hi Michael, "Michael Lotz" wrote: > > > + while (!fFirstExploreDone) > > > + snooze(100); > > snooze(100) is pretty expensive, though. Do you really need that > > granularity? If so, maybe a dedicated semaphore is the better > > solution. > I have set this pretty arbitrarily. Now that you mention it, the > explore will take quite a bit of time (due to grace time when > allocating and setting device address/configuration). So this could > probably be made to snooze(10000) or snooze(100000). Would this be > more > realistic? Sounds pretty good, I'd guess either of them would do :-) Bye, Axel. From mmlr at mlotz.ch Sun Dec 9 23:15:21 2007 From: mmlr at mlotz.ch (Michael Lotz) Date: Sun, 09 Dec 2007 23:15:21 +0100 Subject: [Haiku-commits] r23100 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/boot/platform/bios_ia32 In-Reply-To: <2525070322-BeMail@zon> Message-ID: <724300827-BeMail@primary> > mmlr at BerliOS wrote: > > + if (gKernelArgs.num_cpus > 2) { > > menu->AddItem(item = new(nothrow) MenuItem("Disable SMP")); > > BTW that should probably be >= 2 (was obviously wrong before, too) :- > ) ;-) > Nice changes! I originally planned to move the SMP stuff into the > kernel for proper ACPI handling, if it works that way, too, why not > :) > Any idea why it does not work for you with more than 2 CPUs active? > (MMU issue??) It's pretty simple to read out the APIC stuff from the ACPI tables, so this should work reliably for some time. I'm not sure why it doesn't work with more than 2 CPUs. It's reproducable with QEMU and "-smp < cpucount>" if you remove the limit I put there or if you specify "-no- acpi" to use the old MPS stuff. With 4 CPUs it just hangs somewhere after trampolining the other CPUs, with 8 CPUs it hangs before or while trampolining and with 3 CPUs it sometimes panics with "ran out of initial space". So maybe it is a memory issue, or it is a race condition when starting up APs. Under QEMU the CPU usage will just go up to 100% and it hangs, so I could imagine that it sits there spin- waiting for someone else to complete initialization. I will look into it as it is easily reproducable, but don't hold your breath as I'm not that experienced with debugging at this level. Regards Michael From mmlr at mail.berlios.de Sun Dec 9 23:21:09 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 9 Dec 2007 23:21:09 +0100 Subject: [Haiku-commits] r23102 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712092221.lB9ML9Md016961@sheep.berlios.de> Author: mmlr Date: 2007-12-09 23:21:09 +0100 (Sun, 09 Dec 2007) New Revision: 23102 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23102&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp Log: Removed wrong and now unnecessary condition to add safemode option. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-09 21:13:11 UTC (rev 23101) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-09 22:21:09 UTC (rev 23102) @@ -585,16 +585,14 @@ void smp_add_safemode_menus(Menu *menu) { - MenuItem *item; if (gKernelArgs.num_cpus < 2) return; - if (gKernelArgs.num_cpus > 2) { - menu->AddItem(item = new(nothrow) MenuItem("Disable SMP")); - item->SetData(B_SAFEMODE_DISABLE_SMP); - item->SetType(MENU_ITEM_MARKABLE); - } + MenuItem *item = new(nothrow) MenuItem("Disable SMP"); + menu->AddItem(item); + item->SetData(B_SAFEMODE_DISABLE_SMP); + item->SetType(MENU_ITEM_MARKABLE); } From mmlr at mail.berlios.de Sun Dec 9 23:22:45 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Sun, 9 Dec 2007 23:22:45 +0100 Subject: [Haiku-commits] r23103 - haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <200712092222.lB9MMjsS017466@sheep.berlios.de> Author: mmlr Date: 2007-12-09 23:22:45 +0100 (Sun, 09 Dec 2007) New Revision: 23103 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23103&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp Log: Use a more generous snooze time when waiting for the initial explore to complete. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-12-09 22:21:09 UTC (rev 23102) +++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp 2007-12-09 22:22:45 UTC (rev 23103) @@ -86,7 +86,7 @@ // is opening the module does not get rescanned while or before installing // its hooks. while (!fFirstExploreDone) - snooze(100); + snooze(100000); } From superstippi at gmx.de Sun Dec 9 23:28:57 2007 From: superstippi at gmx.de (Stephan Assmus) Date: Sun, 09 Dec 2007 23:28:57 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <200712092042.lB9Kgm3q005827@sheep.berlios.de> References: <200712092042.lB9Kgm3q005827@sheep.berlios.de> Message-ID: <20071209232857.692.1@stippis2.1197238950.fake> Hi Michael, mmlr at BerliOS wrote (2007-12-09, 21:42:48 [+0100]): > Author: mmlr > Date: 2007-12-09 21:42:47 +0100 (Sun, 09 Dec 2007) New Revision: 23099 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23099&view=rev > > Modified: > haiku/trunk/src/add-ons/kernel/bus_managers/usb/Pipe.cpp > haiku/trunk/src/add-ons/kernel/bus_managers/usb/Stack.cpp > Log: > * Use the rescan function when compiled for Haiku > // use the private devfs API under Haiku > - //devfs_rescan_driver(name); > + devfs_rescan_driver(rescanItem->name); with this change, Haiku detects my mouse and keyboard attached to a KVM switch working as hub. Unfortunately, moving the mouse causes a lot of CPU, the "uhci finisher thread" maxes out one CPU. Also, the "usb explore" thread almost maxes out one CPU every second. Using the KVM switch to switch to another computer and back to Haiku results in the mouse being non-usable (led is out too) and the keyboard processing events a couple of seconds later then I typed them (not sure if it does something at all, I didn't have a text view in focus when I typed). But anyways, getting closer, so that's cool! I will report with some results when I turned on syslog output. Best regards, -Stephan From stefano.ceccherini at gmail.com Mon Dec 10 08:39:20 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 10 Dec 2007 08:39:20 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <32057318245-BeMail@zon> References: <200712092042.lB9Kgm3q005827@sheep.berlios.de> <32057318245-BeMail@zon> Message-ID: <894b9700712092339lf97ae0ay71809ae8e5b955ea@mail.gmail.com> 2007/12/9, Axel D?rfler : > snooze(100) is pretty expensive, though. Do you really need that > granularity? If so, maybe a dedicated semaphore is the better solution. BTW Now that I remember... I've seen lots of snooze(1) in the media kit, I guess this should be changed. From axeld at pinc-software.de Mon Dec 10 10:20:10 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Mon, 10 Dec 2007 10:20:10 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23099_-_haiku/trunk/src/add-ons/?= =?iso-8859-15?q?kernel/bus=5Fmanagers/usb?= In-Reply-To: <894b9700712092339lf97ae0ay71809ae8e5b955ea@mail.gmail.com> Message-ID: <2718463960-BeMail@zon> "Stefano Ceccherini" wrote: > 2007/12/9, Axel D?rfler : > > snooze(100) is pretty expensive, though. Do you really need that > > granularity? If so, maybe a dedicated semaphore is the better > > solution. > BTW Now that I remember... I've seen lots of snooze(1) in the media > kit, I guess this should be changed. Probably - maybe we should just change the snooze code to not schedule an interrupt for a thread that does it, but use thread_yield() (at least later on, when that actually does what it should). Or automatically enforce a minimum value for now. Bye, Axel. From stefano.ceccherini at gmail.com Mon Dec 10 10:35:14 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 10 Dec 2007 10:35:14 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <2718463960-BeMail@zon> References: <894b9700712092339lf97ae0ay71809ae8e5b955ea@mail.gmail.com> <2718463960-BeMail@zon> Message-ID: <894b9700712100135r7ced5d8p1d493c3f6e129d31@mail.gmail.com> 2007/12/10, Axel D?rfler : > "Stefano Ceccherini" wrote: > Probably - maybe we should just change the snooze code to not schedule > an interrupt for a thread that does it, but use thread_yield() (at > least later on, when that actually does what it should). Yes, that's a nice idea. > Or automatically enforce a minimum value for now. But then this should be documented, at least. TimeSource.cpp is the offending file, btw. Maybe we should open a ticket for it ? From mmlr at mlotz.ch Mon Dec 10 10:57:16 2007 From: mmlr at mlotz.ch (Michael Lotz) Date: Mon, 10 Dec 2007 10:57:16 +0100 Subject: [Haiku-commits] r23099 - haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <894b9700712100135r7ced5d8p1d493c3f6e129d31@mail.gmail.com> References: <894b9700712092339lf97ae0ay71809ae8e5b955ea@mail.gmail.com> <2718463960-BeMail@zon> <894b9700712100135r7ced5d8p1d493c3f6e129d31@mail.gmail.com> Message-ID: <20071210095041.M13458@mlotz.ch> On Mon, 10 Dec 2007 10:35:14 +0100, Stefano Ceccherini wrote > 2007/12/10, Axel D?rfler : >> Or automatically enforce a minimum value for now. > > But then this should be documented, at least. > > TimeSource.cpp is the offending file, btw. > Maybe we should open a ticket for it ? Well, if you search through the sources (with the cross reference for example: http://haiku.it.su.se:8180/source/search?q=%22snooze(1)%22&defs=&refs=&path=&hist=) you find quite a bit of snooze(1) to snooze(10). Especially in drivers this is used often. If this really is a problem then we should probably open a ticked to investigate more of this usage. Enforcing a minimum could introduce problems on a wide front. Though I can imagine that the overhead of a snooze is big enough that it never satisfies such small values anyway. Regards Michael From marcusoverhagen at arcor.de Mon Dec 10 11:57:54 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Mon, 10 Dec 2007 11:57:54 +0100 (CET) Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <26285720.1197284274697.JavaMail.ngmail@webmail16> Stefano Ceccherini wrote: > 2007/12/9, Axel D?rfler : > > > snooze(100) is pretty expensive, though. Do you really need that > > granularity? If so, maybe a dedicated semaphore is the better solution. > > BTW Now that I remember... I've seen lots of snooze(1) in the media > kit, I guess this should be changed. I take this as a personal attack because I really doubt that there are "lots of" snooze(1) calls in the media kit. Please show evidence. Marcus 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 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From stefano.ceccherini at gmail.com Mon Dec 10 12:09:23 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 10 Dec 2007 12:09:23 +0100 Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <26285720.1197284274697.JavaMail.ngmail@webmail16> References: <26285720.1197284274697.JavaMail.ngmail@webmail16> Message-ID: <894b9700712100309r35605699qabe2d92049491a7@mail.gmail.com> 2007/12/10, Marcus Overhagen : > Stefano Ceccherini wrote: > > > 2007/12/9, Axel D?rfler : > > > > > snooze(100) is pretty expensive, though. Do you really need that > > > granularity? If so, maybe a dedicated semaphore is the better solution. > > > > BTW Now that I remember... I've seen lots of snooze(1) in the media > > kit, I guess this should be changed. > > I take this as a personal attack because I really doubt that there are "lots of" > snooze(1) calls in the media kit. Please show evidence. Sorry it wasn't meant as such. If it sounded like it, please forgive me. From stefano.ceccherini at gmail.com Mon Dec 10 12:12:47 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Mon, 10 Dec 2007 12:12:47 +0100 Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <894b9700712100309r35605699qabe2d92049491a7@mail.gmail.com> References: <26285720.1197284274697.JavaMail.ngmail@webmail16> <894b9700712100309r35605699qabe2d92049491a7@mail.gmail.com> Message-ID: <894b9700712100312s44d6e2a7o124ecad692c6c239@mail.gmail.com> 2007/12/10, Stefano Ceccherini : > 2007/12/10, Marcus Overhagen : > > Stefano Ceccherini wrote: > > > > > 2007/12/9, Axel D?rfler : > > > > > > > snooze(100) is pretty expensive, though. Do you really need that > > > > granularity? If so, maybe a dedicated semaphore is the better solution. > > > > > > BTW Now that I remember... I've seen lots of snooze(1) in the media > > > kit, I guess this should be changed. > > > > I take this as a personal attack because I really doubt that there are "lots of" > > snooze(1) calls in the media kit. Please show evidence. > > Sorry it wasn't meant as such. > If it sounded like it, please forgive me. BTW I obviously had a poor choice of words. Replace "lots" of with "a couple of". If you felt offended by my mail, please forgive me, again. From revol at free.fr Mon Dec 10 12:33:10 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Mon, 10 Dec 2007 12:33:10 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23099_-_haiku/trunk/src/add-ons?= =?windows-1252?q?/kernel/bus=5Fmanagers/usb?= In-Reply-To: <894b9700712092339lf97ae0ay71809ae8e5b955ea@mail.gmail.com> Message-ID: <1002167197-BeMail@laptop> > 2007/12/9, Axel D?rfler : > > > snooze(100) is pretty expensive, though. Do you really need that > > granularity? If so, maybe a dedicated semaphore is the better > > solution. > > BTW Now that I remember... I've seen lots of snooze(1) in the media > kit, I guess this should be changed. Lots of those are actually meant only to act as yield(), even though I'm not sure it ever worked this way. All other uses should be changed for a spin(). Fran?ois. From axeld at mail.berlios.de Mon Dec 10 19:42:14 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Mon, 10 Dec 2007 19:42:14 +0100 Subject: [Haiku-commits] r23104 - haiku/trunk/src/add-ons/accelerants/intel_extreme Message-ID: <200712101842.lBAIgEWM016629@sheep.berlios.de> Author: axeld Date: 2007-12-10 19:42:14 +0100 (Mon, 10 Dec 2007) New Revision: 23104 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23104&view=rev Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp Log: Now clears the frame buffer before setting the mode; at least when testing, one sometimes could still see previous contents of the screen during boot up for some time. Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-12-09 22:22:45 UTC (rev 23103) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/mode.cpp 2007-12-10 18:42:14 UTC (rev 23104) @@ -433,6 +433,9 @@ return B_NO_MEMORY; } + // clear frame buffer before using it + memset(sharedInfo.graphics_memory + offset, 0, + bytesPerRow * target.virtual_height); sharedInfo.frame_buffer_offset = offset; // make sure VGA display is disabled From mmlr at mail.berlios.de Mon Dec 10 21:37:21 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Mon, 10 Dec 2007 21:37:21 +0100 Subject: [Haiku-commits] r23105 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712102037.lBAKbLOl027633@sheep.berlios.de> Author: mmlr Date: 2007-12-10 21:37:20 +0100 (Mon, 10 Dec 2007) New Revision: 23105 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23105&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp Log: Avoid adding more CPUs than the kernel args can hold (and therefore overwriting other kernel args stuff). Doesn't fix my problems though as the current maximum is 4 CPUs. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-10 18:42:14 UTC (rev 23104) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-10 20:37:20 UTC (rev 23105) @@ -156,6 +156,12 @@ switch (*ptr) { case MP_BASE_PROCESSOR: { + if (gKernelArgs.num_cpus == MAX_BOOT_CPUS) { + TRACE(("smp: already reached maximum boot CPUs (%d)\n", MAX_BOOT_CPUS)); + ptr += sizeof(struct mp_base_processor); + break; + } + struct mp_base_processor *processor = (struct mp_base_processor *)ptr; gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = processor->apic_id; @@ -267,6 +273,11 @@ switch (apic->type) { case ACPI_MADT_LOCAL_APIC: { + if (gKernelArgs.num_cpus == MAX_BOOT_CPUS) { + TRACE(("smp: already reached maximum boot CPUs (%d)\n", MAX_BOOT_CPUS)); + break; + } + acpi_local_apic *localApic = (acpi_local_apic *)apic; TRACE(("smp: found local APIC with id %u\n", localApic->apic_id)); gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = localApic->apic_id; From jackburton at mail.berlios.de Mon Dec 10 22:20:26 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Mon, 10 Dec 2007 22:20:26 +0100 Subject: [Haiku-commits] r23106 - in haiku/trunk/src: add-ons/input_server/devices/keyboard add-ons/input_server/devices/mouse servers/input Message-ID: <200712102120.lBALKQDg029831@sheep.berlios.de> Author: jackburton Date: 2007-12-10 22:20:25 +0100 (Mon, 10 Dec 2007) New Revision: 23106 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23106&view=rev Modified: haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp haiku/trunk/src/servers/input/InputServerDevice.cpp Log: Some old changes I forgot to commit... BInputServerDevice::InitCheck() now checks if the fOwner allocation went fine (and returns B_NO_MEMORY in case it didn't). Since it can fail, inherited classes should call it as well (I modified MouseInputDevice's and KeyboardInputDevice's versions for now) Modified: haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp 2007-12-10 20:37:20 UTC (rev 23105) +++ haiku/trunk/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp 2007-12-10 21:20:25 UTC (rev 23106) @@ -445,6 +445,10 @@ KeyboardInputDevice::InitCheck() { CALLED(); + status_t status = BInputServerDevice::InitCheck(); + if (status < B_OK) + return status; + // TODO: this doesn't belong here! _RecursiveScan(kKeyboardDevicesDirectory); Modified: haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp 2007-12-10 20:37:20 UTC (rev 23105) +++ haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp 2007-12-10 21:20:25 UTC (rev 23106) @@ -1,9 +1,11 @@ /* - * Copyright 2004-2006, Haiku. + * Copyright 2004-2007, Haiku. * Distributed under the terms of the MIT License. * * Authors: - * Stefano Ceccherini + * Stefano Ceccherini (stefano.ceccherini at gmail.com) + * J?r?me Duval + * Axel D?rfler, axeld at pinc-software.de */ @@ -97,7 +99,7 @@ extern "C" BInputServerDevice * instantiate_input_device() { - return new MouseInputDevice(); + return new (std::nothrow) MouseInputDevice(); } @@ -443,7 +445,7 @@ MouseInputDevice::InitCheck() { CALLED(); - return B_OK; + return BInputServerDevice::InitCheck(); } Modified: haiku/trunk/src/servers/input/InputServerDevice.cpp =================================================================== --- haiku/trunk/src/servers/input/InputServerDevice.cpp 2007-12-10 20:37:20 UTC (rev 23105) +++ haiku/trunk/src/servers/input/InputServerDevice.cpp 2007-12-10 21:20:25 UTC (rev 23106) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Haiku, Inc. All Rights Reserved. + * Copyright 2002-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ @@ -8,10 +8,11 @@ #include +#include BInputServerDevice::BInputServerDevice() { - fOwner = new _BDeviceAddOn_(this); + fOwner = new (std::nothrow) _BDeviceAddOn_(this); } @@ -27,6 +28,8 @@ status_t BInputServerDevice::InitCheck() { + if (fOwner == NULL) + return B_NO_MEMORY; return B_OK; } From marcusoverhagen at mail.berlios.de Mon Dec 10 23:04:35 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 10 Dec 2007 23:04:35 +0100 Subject: [Haiku-commits] r23107 - haiku/trunk/src/kits/media Message-ID: <200712102204.lBAM4ZgU002380@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-10 23:04:34 +0100 (Mon, 10 Dec 2007) New Revision: 23107 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23107&view=rev Modified: haiku/trunk/src/kits/media/TimeSource.cpp Log: drop into debugger when things go wrong Modified: haiku/trunk/src/kits/media/TimeSource.cpp =================================================================== --- haiku/trunk/src/kits/media/TimeSource.cpp 2007-12-10 21:20:25 UTC (rev 23106) +++ haiku/trunk/src/kits/media/TimeSource.cpp 2007-12-10 22:04:34 UTC (rev 23107) @@ -119,8 +119,8 @@ bigtime_t last_real_time; float last_drift; - while (GetTime(&last_perf_time, &last_real_time, &last_drift) != B_OK) - snooze(1); + if (GetTime(&last_perf_time, &last_real_time, &last_drift) != B_OK) + debugger("BTimeSource::PerformanceTimeFor: GetTime failed"); return last_perf_time + (bigtime_t)((real_time - last_real_time) * last_drift); } @@ -140,8 +140,8 @@ bigtime_t last_real_time; float last_drift; - while (GetTime(&last_perf_time, &last_real_time, &last_drift) != B_OK) - snooze(1); + if (GetTime(&last_perf_time, &last_real_time, &last_drift) != B_OK) + debugger("BTimeSource::RealTimeFor: GetTime failed"); return last_real_time - with_latency + (bigtime_t)((performance_time - last_perf_time) / last_drift); } From leavengood at gmail.com Tue Dec 11 00:13:00 2007 From: leavengood at gmail.com (Ryan Leavengood) Date: Mon, 10 Dec 2007 18:13:00 -0500 Subject: [Haiku-commits] r23107 - haiku/trunk/src/kits/media In-Reply-To: <200712102204.lBAM4ZgU002380@sheep.berlios.de> References: <200712102204.lBAM4ZgU002380@sheep.berlios.de> Message-ID: On 12/10/07, marcusoverhagen at BerliOS wrote: > > Modified: > haiku/trunk/src/kits/media/TimeSource.cpp > Log: > drop into debugger when things go wrong No more snooze(1) in the media kit :) Now someone just needs to check out the various drivers that use it. Though if they are using it just to trigger the scheduler maybe it isn't that bad. Ryan From bonefish at mail.berlios.de Tue Dec 11 00:50:41 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 11 Dec 2007 00:50:41 +0100 Subject: [Haiku-commits] r23108 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel src/system/kernel Message-ID: <200712102350.lBANofKK013197@sheep.berlios.de> Author: bonefish Date: 2007-12-11 00:50:40 +0100 (Tue, 11 Dec 2007) New Revision: 23108 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23108&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp Log: Added thread::kernel_stack_top field. It is redundant (== kernel_stack_base + KERNEL_STACK_SIZE), but more comfortable to use in assembly. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-10 22:04:34 UTC (rev 23107) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-10 23:50:40 UTC (rev 23108) @@ -250,6 +250,7 @@ // stack area_id kernel_stack_area; addr_t kernel_stack_base; + addr_t kernel_stack_top; area_id user_stack_area; addr_t user_stack_base; size_t user_stack_size; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-10 22:04:34 UTC (rev 23107) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/thread.cpp 2007-12-10 23:50:40 UTC (rev 23108) @@ -409,6 +409,8 @@ return status; } + thread->kernel_stack_top = thread->kernel_stack_base + KERNEL_STACK_SIZE; + state = disable_interrupts(); GRAB_THREAD_LOCK(); From bonefish at mail.berlios.de Tue Dec 11 01:06:22 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 11 Dec 2007 01:06:22 +0100 Subject: [Haiku-commits] r23109 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <200712110006.lBB06MlK020890@sheep.berlios.de> Author: bonefish Date: 2007-12-11 01:06:20 +0100 (Tue, 11 Dec 2007) New Revision: 23109 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23109&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/syscall.S Log: Added Intel sysenter/sysexit support (commpage, handler). It seems to basically work, but ATM we trash edx on return, which is one half of the return value for syscalls returning 64 bit values. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-10 23:50:40 UTC (rev 23108) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-11 00:06:20 UTC (rev 23109) @@ -21,6 +21,9 @@ #define IA32_MSR_APIC_BASE 0x1b #define IA32_MSR_MTRR_CAPABILITIES 0xfe +#define IA32_MSR_SYSENTER_CS 0x174 +#define IA32_MSR_SYSENTER_ESP 0x175 +#define IA32_MSR_SYSENTER_EIP 0x176 #define IA32_MSR_MTRR_DEFAULT_TYPE 0x2ff #define IA32_MSR_MTRR_PHYSICAL_BASE_0 0x200 #define IA32_MSR_MTRR_PHYSICAL_MASK_0 0x201 Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-10 23:50:40 UTC (rev 23108) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 00:06:20 UTC (rev 23109) @@ -8,9 +8,10 @@ */ #include -#include #include #include +#include +#include #include "asm_offsets.h" #include "syscall_numbers.h" @@ -65,6 +66,21 @@ /* thread->in_kernel = false; */ \ movb $0, THREAD_in_kernel(%edi) +#define PUSH_IFRAME_BOTTOM(iframeType) \ + pusha; \ + push %ds; \ + push %es; \ + push %fs; \ + push %gs; \ + pushl $iframeType + +#define PUSH_IFRAME_BOTTOM_SYSCALL() \ + pushl $0; \ + pushl $99; \ + pushl %edx; \ + pushl %eax; \ + PUSH_IFRAME_BOTTOM(IFRAME_TYPE_SYSCALL) + #define POP_IFRAME_AND_RETURN() \ /* skip iframe type */ \ lea 4(%ebp), %esp; \ @@ -80,7 +96,10 @@ original eax/edx values */ \ iret +#define SYSENTER_RETURN_ADDRESS \ + (USER_COMMPAGE_ADDR + TABLE_ENTRIES * 4 + 4) + .text #define TRAP_ERRC(name, vector) \ @@ -164,18 +183,16 @@ .align 16 .globl int_bottom int_bottom: - pusha - push %ds - push %es - push %fs - push %gs - push $IFRAME_TYPE_OTHER + PUSH_IFRAME_BOTTOM(IFRAME_TYPE_OTHER) movl %esp, %ebp // frame pointer is the iframe cmp $USER_CODE_SEG, IFRAME_cs(%ebp) je int_bottom_user + // disable interrupts -- the handler will enable them, if necessary + cli + pushl %ebp movl IFRAME_vector(%ebp), %eax call *gInterruptHandlerTable(, %eax, 4) @@ -230,16 +247,7 @@ .globl trap99 trap99: // push error, vector, orig_edx, orig_eax, and other registers - pushl $0 - pushl $99 - pushl %edx - pushl %eax - pusha - push %ds - push %es - push %fs - push %gs - push $IFRAME_TYPE_SYSCALL + PUSH_IFRAME_BOTTOM_SYSCALL() // save %eax, the number of the syscall movl %eax, %esi @@ -364,8 +372,120 @@ call thread_at_kernel_exit cli // disable interrupts jmp kernel_exit_work_done - + +/*! Handler called by the sysenter instruction + ecx - user esp +*/ +FUNCTION(x86_sysenter): + // switch the stack + movl %dr3, %edx + movl THREAD_kernel_stack_top(%edx), %esp + + // push the iframe + pushl $USER_DATA_SEG // user_ss + pushl %ecx // user_esp + pushfl // eflags + orl $(1 << 9), (%esp) // set the IF (interrupts) bit + pushl $USER_CODE_SEG // user cs + pushl $SYSENTER_RETURN_ADDRESS // user_eip + + PUSH_IFRAME_BOTTOM_SYSCALL() + + // save %eax, the number of the syscall + movl %eax, %esi + + movl $KERNEL_DATA_SEG,%eax + cld + movl %eax,%ds + movl %eax,%es + + movl %esp, %ebp // frame pointer is the iframe + + // disable breakpoints, if installed + movl %dr3, %edi // thread pointer + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) + jz skip_debug_at_kernel_entry_sysenter + call x86_exit_user_debug_at_kernel_entry + skip_debug_at_kernel_entry_sysenter: + + // update the thread's user time + UPDATE_THREAD_USER_TIME_PUSH_TIME() + // leave the time on the stack (needed for post syscall debugging) + + sti // enable interrupts + + cmp $SYSCALL_COUNT, %esi // check syscall number + jae bad_syscall_number + movl $kSyscallInfos, %eax // get syscall info + lea (%eax, %esi, SYSCALL_INFO_sizeof), %esi + + // copy parameters onto this stack + subl $80, %esp // leave some room for the syscall params + + // get the address of the syscall parameters + movl IFRAME_user_esp(%ebp), %eax + addl $4, %eax + cmp $KERNEL_BASE, %eax // must not be a kernel address + jae bad_syscall_params + + // get and push the syscall parameter size + movl SYSCALL_INFO_parameter_size(%esi), %ebx + push %ebx + + push %eax + lea 8(%esp), %ebx // stack address where to copy the params + push %ebx + call user_memcpy + addl $12, %esp + test %eax, %eax + jne bad_syscall_params + + // pre syscall debugging + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) + jnz do_pre_syscall_debug + // if debugging is enabled, we take the slow syscall exit + + // call the syscall function + call *SYSCALL_INFO_function(%esi) + + // overwrite the values of %eax and %edx on the stack (the syscall return + // value) + movl %edx, IFRAME_edx(%ebp) + movl %eax, IFRAME_eax(%ebp) + + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + , THREAD_flags(%edi) + jnz post_syscall_work + // if any special work has to be done, we take the slow syscall exit + + cli // disable interrupts + + // update the thread's kernel time + UPDATE_THREAD_KERNEL_TIME() + + // pop the bottom of the iframe + lea 4(%ebp), %esp // skip iframe type + + pop %gs + addl $4, %esp /* we skip %fs, as this contains the CPU + dependent TLS segment */ + pop %es + pop %ds + + popa + + // pop eflags, which also reenables interrupts + addl $24, %esp // skip, orig_eax/edx, vector, error_code, eip, cs + popfl + + // ecx already contains the user esp -- load edx with the return address + movl $SYSENTER_RETURN_ADDRESS, %edx + + sysexit + + /*! Is copied to the signal stack call to restore the original frame when the signal handler exits. The copying code (in arch_thread.c::arch_setup_signal_frame()) copies Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-10 23:50:40 UTC (rev 23108) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-11 00:06:20 UTC (rev 23109) @@ -32,6 +32,7 @@ DEFINE_OFFSET_MACRO(THREAD, thread, last_time); DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); DEFINE_OFFSET_MACRO(THREAD, thread, flags); + DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top); // struct iframe DEFINE_OFFSET_MACRO(IFRAME, iframe, cs); @@ -39,6 +40,8 @@ DEFINE_OFFSET_MACRO(IFRAME, iframe, edx); DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax); DEFINE_OFFSET_MACRO(IFRAME, iframe, vector); + DEFINE_OFFSET_MACRO(IFRAME, iframe, eip); + DEFINE_OFFSET_MACRO(IFRAME, iframe, flags); DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp); // struct syscall_info Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c 2007-12-10 23:50:40 UTC (rev 23108) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c 2007-12-11 00:06:20 UTC (rev 23109) @@ -10,6 +10,8 @@ #include +#include +#include #include #include @@ -20,11 +22,16 @@ static unsigned long *user_comm_ptr; static void *next_comm_addr; -// user syscall assembly stub +// user syscall assembly stubs extern void _user_syscall_int(void); extern unsigned int _user_syscall_int_end; +extern void _user_syscall_sysenter(void); +extern unsigned int _user_syscall_sysenter_end; +// sysenter handler +extern void x86_sysenter(); + static inline addr_t commpage_ptr_to_user_ptr(const void *ptr) { @@ -32,15 +39,72 @@ } +static bool +all_cpus_have_feature(enum x86_feature_type type, int feature) +{ + int i; + int cpuCount = smp_get_num_cpus(); + + for (i = 0; i < cpuCount; i++) { + if (!(gCPU[i].arch.feature[type] & feature)) + return false; + } + + return true; +} + + +static void +init_intel_syscall_registers(void* dummy, int cpuNum) +{ + x86_write_msr(IA32_MSR_SYSENTER_CS, KERNEL_CODE_SEG); + x86_write_msr(IA32_MSR_SYSENTER_ESP, 0); + x86_write_msr(IA32_MSR_SYSENTER_EIP, (addr_t)x86_sysenter); +} + + +#if 0 +static void +init_amd_syscall_registers(void* dummy, int cpuNum) +{ + // TODO: ... +} +#endif + + static status_t initialize_commpage_syscall(void) { size_t len; - - // for now, we're hard coded to use the legacy method (int 99) - len = (size_t)((void *)&_user_syscall_int_end - (void *)&_user_syscall_int); - memcpy(next_comm_addr, &_user_syscall_int, len); + void* syscallCode = &_user_syscall_int; + void* syscallCodeEnd = &_user_syscall_int_end; + // check syscall + if (all_cpus_have_feature(FEATURE_COMMON, IA32_FEATURE_SEP) + && !(gCPU[0].arch.family == 6 && gCPU[0].arch.model < 3 + && gCPU[0].arch.stepping < 3)) { + // Intel sysenter/sysexit + dprintf("initialize_commpage_syscall(): sysenter/sysexit supported\n"); + + // the code to be used in userland + syscallCode = &_user_syscall_sysenter; + syscallCodeEnd = &_user_syscall_sysenter_end; + + // tell all CPUs to init their sysenter/sysexit related registers + call_all_cpus_sync(&init_intel_syscall_registers, NULL); + } else if (all_cpus_have_feature(FEATURE_EXT_AMD, + IA32_FEATURE_AMD_EXT_SYSCALL)) { + // AMD syscall/sysret + dprintf("initialize_commpage_syscall(): syscall/sysret supported " + "-- not yet by Haiku, though"); + } else { + // no special syscall support + dprintf("initialize_commpage_syscall(): no special syscall support\n"); + } + + len = (size_t)(syscallCodeEnd - syscallCode); + memcpy(next_comm_addr, syscallCode, len); + // fill in the table entry comm_ptr[COMMPAGE_ENTRY_SYSCALL] = commpage_ptr_to_user_ptr(next_comm_addr); next_comm_addr = (void *)((addr_t)next_comm_addr + ROUNDUP(len, 4)); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/syscall.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/syscall.S 2007-12-10 23:50:40 UTC (rev 23108) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/syscall.S 2007-12-11 00:06:20 UTC (rev 23109) @@ -9,11 +9,21 @@ .text /* user space half of the syscall mechanism, to be copied into the commpage */ + +// int 99 fallback FUNCTION(_user_syscall_int): int $99 ret SYM(_user_syscall_int_end): +// Intel sysenter/sysexit +FUNCTION(_user_syscall_sysenter): + // sysexit forces us to trash edx (-> eip) and ecx (-> esp), but they are + // scratch registers anyway. We use ecx right away to store esp. + movl %esp, %ecx + sysenter + ret +SYM(_user_syscall_sysenter_end): From bonefish at mail.berlios.de Tue Dec 11 02:46:39 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 11 Dec 2007 02:46:39 +0100 Subject: [Haiku-commits] r23110 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/kernel/fs Message-ID: <200712110146.lBB1kdmo005560@sheep.berlios.de> Author: bonefish Date: 2007-12-11 02:46:36 +0100 (Tue, 11 Dec 2007) New Revision: 23110 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23110&view=rev Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/thread.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/fd.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/syscalls.c Log: Introduced new thread::flags flag THREAD_FLAGS_64_BIT_SYSCALL_RETURN to indicate that the current syscall has a 64 bit return value and a macro to set the bit, if the architecture requires it. If set the sysenter handler will use iret to return to userland, so that edx is no longer clobbered. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/thread.h 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/thread.h 2007-12-11 01:46:36 UTC (rev 23110) @@ -46,6 +46,9 @@ void arch_store_fork_frame(struct arch_fork_arg *arg); void arch_restore_fork_frame(struct arch_fork_arg *arg); +#define arch_syscall_64_bit_return_value() + // overridden by architectures that need special handling + #ifdef __cplusplus } #endif Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_thread.h 2007-12-11 01:46:36 UTC (rev 23110) @@ -22,7 +22,11 @@ void i386_return_from_signal(); void i386_end_return_from_signal(); +// override empty macro +#undef arch_syscall_64_bit_return_value +void arch_syscall_64_bit_return_value(); + static inline struct thread * arch_thread_get_current_thread(void) Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread.h 2007-12-11 01:46:36 UTC (rev 23110) @@ -70,6 +70,8 @@ status_t select_thread(int32 object, struct select_info *info, bool kernel); status_t deselect_thread(int32 object, struct select_info *info, bool kernel); +#define syscall_64_bit_return_value() arch_syscall_64_bit_return_value() + // used in syscalls.c status_t _user_set_thread_priority(thread_id thread, int32 newPriority); status_t _user_rename_thread(thread_id thread, const char *name); Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/thread_types.h 2007-12-11 01:46:36 UTC (rev 23110) @@ -283,6 +283,7 @@ #define THREAD_FLAGS_DEBUGGER_INSTALLED 0x04 #define THREAD_FLAGS_BREAKPOINTS_DEFINED 0x08 #define THREAD_FLAGS_BREAKPOINTS_INSTALLED 0x10 +#define THREAD_FLAGS_64_BIT_SYSCALL_RETURN 0x20 #endif /* _KERNEL_THREAD_TYPES_H */ Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 01:46:36 UTC (rev 23110) @@ -332,6 +332,18 @@ addl $8, %esp jmp pre_syscall_debug_done + post_syscall_work_sysenter: + // if the 64 bit return value bit is set, we have to clear it + testl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, THREAD_flags(%edi) + jz post_syscall_work + post_syscall_work_clear_64_bit_flag: + movl THREAD_flags(%edi), %eax + movl %eax, %edx + orl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, %edx + lock + cmpxchgl %edx, THREAD_flags(%edi) + jnz post_syscall_work_clear_64_bit_flag + post_syscall_work: // post syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) @@ -455,9 +467,10 @@ movl %eax, IFRAME_eax(%ebp) testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | THREAD_FLAGS_SIGNALS_PENDING \ - | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED \ + | THREAD_FLAGS_64_BIT_SYSCALL_RETURN) \ , THREAD_flags(%edi) - jnz post_syscall_work + jnz post_syscall_work_sysenter // if any special work has to be done, we take the slow syscall exit cli // disable interrupts Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_thread.c 2007-12-11 01:46:36 UTC (rev 23110) @@ -565,3 +565,11 @@ i386_restore_frame_from_syscall(arg->iframe); } + + +void +arch_syscall_64_bit_return_value() +{ + struct thread* thread = thread_get_current_thread(); + atomic_or(&thread->flags, THREAD_FLAGS_64_BIT_SYSCALL_RETURN); +} Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/fd.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/fd.cpp 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/fd.cpp 2007-12-11 01:46:36 UTC (rev 23110) @@ -845,6 +845,8 @@ off_t _user_seek(int fd, off_t pos, int seekType) { + syscall_64_bit_return_value(); + struct file_descriptor *descriptor; descriptor = get_fd(get_current_io_context(false), fd); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c 2007-12-11 01:46:36 UTC (rev 23110) @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -242,6 +243,8 @@ bigtime_t _user_system_time(void) { + syscall_64_bit_return_value(); + return system_time(); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/signal.cpp 2007-12-11 01:46:36 UTC (rev 23110) @@ -703,6 +703,8 @@ bigtime_t _user_set_alarm(bigtime_t time, uint32 mode) { + syscall_64_bit_return_value(); + return set_alarm(time, mode); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/syscalls.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/syscalls.c 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/syscalls.c 2007-12-11 01:46:36 UTC (rev 23110) @@ -158,6 +158,8 @@ static inline int64 _user_restore_signal_frame() { + syscall_64_bit_return_value(); + return arch_restore_signal_frame(); } From marcusoverhagen at arcor.de Tue Dec 11 06:52:10 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Tue, 11 Dec 2007 06:52:10 +0100 (CET) Subject: [Haiku-commits] r23110 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/kernel/fs In-Reply-To: <200712110146.lBB1kdmo005560@sheep.berlios.de> References: <200712110146.lBB1kdmo005560@sheep.berlios.de> Message-ID: <3499464.1197352330063.JavaMail.ngmail@webmail11> bonefish at BerliOS wrote: > Introduced new thread::flags flag THREAD_FLAGS_64_BIT_SYSCALL_RETURN to > indicate that the current syscall has a 64 bit return value and a macro > to set the bit, if the architecture requires it. If set the sysenter > handler will use iret to return to userland, so that edx is no longer > clobbered. First I have to say that I'm not familiar with the code. However, it appears to me that the syscall return value is written in the iframe on the stack, and then set within POP_IFRAME_AND_RETURN() and thus doesn't need to be contained in eax and edx on sysexit. // overwrite the values of %eax and %edx on the stack (the syscall return value) movl %edx, IFRAME_edx(%ebp) movl %eax, IFRAME_eax(%ebp) regards Marcus 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 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From stefano.ceccherini at gmail.com Tue Dec 11 10:04:41 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Tue, 11 Dec 2007 10:04:41 +0100 Subject: [Haiku-commits] r23062 - haiku/trunk/src/kits/interface In-Reply-To: <9549572796-BeMail@zon> References: <200712051213.lB5CD1w3022862@sheep.berlios.de> <9549572796-BeMail@zon> Message-ID: <894b9700712110104y5c12fb10le34f2bf0e5f30359@mail.gmail.com> 2007/12/5, Axel D?rfler : > jackburton at BerliOS wrote: > > Log: > > Dispatch also the B_WINDOW_ACTIVATED messages. This fixes bug #613, > > but > > we need to check which other messages are handled by beos here. > > Actually, BeOS really only checks for drawing messages there. You are right. > So what > we do now is already deviating from this - I'm just not sure if that's > so bad :) Maybe this could bring some problems in some other places... > We definitely need to test this a bit more (ie. activation/focus in > different setups), but I currently don't have time and ideas to do so. Me neither. From marcusoverhagen at arcor.de Tue Dec 11 10:20:52 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Tue, 11 Dec 2007 10:20:52 +0100 (CET) Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb Message-ID: <20471764.1197364852803.JavaMail.ngmail@webmail15> Stefano Ceccherini wrote: > 2007/12/10, Stefano Ceccherini : > > 2007/12/10, Marcus Overhagen : > > > Stefano Ceccherini wrote: > > > > > > > 2007/12/9, Axel D?rfler : > > > > > > > > > snooze(100) is pretty expensive, though. Do you really need that > > > > > granularity? If so, maybe a dedicated semaphore is the better solution. > > > > > > > > BTW Now that I remember... I've seen lots of snooze(1) in the media > > > > kit, I guess this should be changed. > > > > > > I take this as a personal attack because I really doubt that there are "lots of" > > > snooze(1) calls in the media kit. Please show evidence. > > > > Sorry it wasn't meant as such. > > If it sounded like it, please forgive me. > BTW I obviously had a poor choice of words. Replace "lots" of with "a > couple of". > If you felt offended by my mail, please forgive me, again. Well, no hard feelings. The problem is, you comment wasn't very helpful. There are neither lots of, nor a couple of, there were exactly two snooze(1) calls in the entire media kit, and those weren't even executed normally. I now replaced them with a call into the debugger, which is probably more useful. I andorse doing a code audit, and will happily accept and comment on any potential problems or bugs you may find, but please don't make such generalizations. And please add filenames/line numbers for reference. There a some snooze(1) calls in the drivers, but I think they are there to avoid busy waiting when polling for a hardware event that is meant to happen immediatelly. I'll review the cx23882/i2c_core code later today, but nothing else. regards Marcus 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 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From ingo_weinhold at gmx.de Tue Dec 11 14:47:46 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Tue, 11 Dec 2007 14:47:46 +0100 Subject: [Haiku-commits] r23110 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/kernel/fs In-Reply-To: <3499464.1197352330063.JavaMail.ngmail@webmail11> References: <200712110146.lBB1kdmo005560@sheep.berlios.de> <3499464.1197352330063.JavaMail.ngmail@webmail11> Message-ID: <20071211144746.485.2@knochen-vm.nameserver> On 2007-12-11 at 06:52:10 [+0100], Marcus Overhagen wrote: > bonefish at BerliOS wrote: > > > > Introduced new thread::flags flag THREAD_FLAGS_64_BIT_SYSCALL_RETURN to > > indicate that the current syscall has a 64 bit return value and a macro > > to set the bit, if the architecture requires it. If set the sysenter > > handler will use iret to return to userland, so that edx is no longer > > clobbered. > > First I have to say that I'm not familiar with the code. > > However, it appears to me that the syscall return value is > written in the iframe on the stack, and then set within > POP_IFRAME_AND_RETURN() and thus doesn't need to > be contained in eax and edx on sysexit. sysexit is the last instruction executed in the kernel. The only registers it changes are cs/eip and ss/esp, i.e. if edx doesn't contain the right value at this point, it won't in userland, and unfortunately sysexit requires edx to contain the value to load into eip. So unless we load it from somewhere when back in userland (with sysexit also using ecx we're out of scratch registers), we can't use sysexit for syscalls returning 64 bit values. Hence in these cases we do now actually use iret (the POP_IFRAME_AND_RETURN() you mentioned) to return. CU, Ingo From bonefish at mail.berlios.de Tue Dec 11 15:18:21 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 11 Dec 2007 15:18:21 +0100 Subject: [Haiku-commits] r23111 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712111418.lBBEILNv003932@sheep.berlios.de> Author: bonefish Date: 2007-12-11 15:18:21 +0100 (Tue, 11 Dec 2007) New Revision: 23111 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23111&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp Log: * Some cleanup using local labels. * Inlined the user_memcpy() for copying the syscall parameters to the kernel stack. Yields about 1% speedup. * When returning with sysexit, load the return address from the iframe. Syscall restarts couldn't work before. Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 01:46:36 UTC (rev 23110) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 14:18:21 UTC (rev 23111) @@ -96,6 +96,41 @@ original eax/edx values */ \ iret +#define DISABLE_BREAKPOINTS() \ + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi); \ + jz 1f; \ + call x86_exit_user_debug_at_kernel_entry; \ + 1: + +#define COPY_SYSCALL_PARAMETERS() \ + /* make room for the syscall params */ \ + subl $80, %esp; \ + \ + /* get the address of the syscall parameters */ \ + movl IFRAME_user_esp(%ebp), %esi; \ + addl $4, %esi; \ + cmp $KERNEL_BASE, %esi; /* must not be a kernel address */ \ + jae bad_syscall_params; \ + \ + /* set the fault handler */ \ + movl $bad_syscall_params, THREAD_fault_handler(%edi); \ + \ + /* target address is our stack */ \ + movl %esp, %edi; \ + \ + /* number of syscall parameter words */ \ + movl SYSCALL_INFO_parameter_size(%edx), %ecx; \ + shrl $2, %ecx; \ + \ + /* copy */ \ + cld; \ + rep movsl; \ + \ + /* restore pointers and clear fault handler */ \ + movl %edx, %esi; /* syscall info pointer */ \ + movl %dr3, %edi; /* thread pointer */ \ + movl $0, THREAD_fault_handler(%edi) + #define SYSENTER_RETURN_ADDRESS \ (USER_COMMPAGE_ADDR + TABLE_ENTRIES * 4 + 4) @@ -207,12 +242,9 @@ movl %eax,%es // disable breakpoints, if installed - cli // disable interrupts movl %dr3, %edi // thread pointer - testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) - jz int_bottom_user_skip_debug_at_kernel_entry - call x86_exit_user_debug_at_kernel_entry - int_bottom_user_skip_debug_at_kernel_entry: + cli // disable interrupts + DISABLE_BREAKPOINTS() // update the thread's user time UPDATE_THREAD_USER_TIME() @@ -258,14 +290,11 @@ movl %eax,%es movl %esp, %ebp // frame pointer is the iframe + movl %dr3, %edi // thread pointer // disable breakpoints, if installed cli // disable interrupts - movl %dr3, %edi // thread pointer - testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) - jz skip_debug_at_kernel_entry - call x86_exit_user_debug_at_kernel_entry - skip_debug_at_kernel_entry: + DISABLE_BREAKPOINTS() // update the thread's user time UPDATE_THREAD_USER_TIME_PUSH_TIME() @@ -276,29 +305,11 @@ cmp $SYSCALL_COUNT, %esi // check syscall number jae bad_syscall_number movl $kSyscallInfos, %eax // get syscall info - lea (%eax, %esi, SYSCALL_INFO_sizeof), %esi + lea (%eax, %esi, SYSCALL_INFO_sizeof), %edx // copy parameters onto this stack - subl $80, %esp // leave some room for the syscall params + COPY_SYSCALL_PARAMETERS() - // get the address of the syscall parameters - movl IFRAME_user_esp(%ebp), %eax - addl $4, %eax - cmp $KERNEL_BASE, %eax // must not be a kernel address - jae bad_syscall_params - - // get and push the syscall parameter size - movl SYSCALL_INFO_parameter_size(%esi), %ebx - push %ebx - - push %eax - lea 8(%esp), %ebx // stack address where to copy the params - push %ebx - call user_memcpy - addl $12, %esp - test %eax, %eax - jne bad_syscall_params - // pre syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jnz do_pre_syscall_debug @@ -336,18 +347,18 @@ // if the 64 bit return value bit is set, we have to clear it testl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, THREAD_flags(%edi) jz post_syscall_work - post_syscall_work_clear_64_bit_flag: + 1: movl THREAD_flags(%edi), %eax movl %eax, %edx orl $THREAD_FLAGS_64_BIT_SYSCALL_RETURN, %edx lock cmpxchgl %edx, THREAD_flags(%edi) - jnz post_syscall_work_clear_64_bit_flag + jnz 1b post_syscall_work: // post syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) - jz post_syscall_debug_done + jz 1f pushl -4(%ebp) // syscall start time pushl -8(%ebp) push %edx // syscall return value @@ -358,9 +369,8 @@ push %eax call user_debug_post_syscall addl $8, %esp - post_syscall_debug_done: + 1: - bad_syscall_params: bad_syscall_number: kernel_exit_work: // if no signals are pending and the thread shall not be debugged, we can @@ -374,10 +384,10 @@ // install breakpoints, if defined testl $THREAD_FLAGS_BREAKPOINTS_DEFINED, THREAD_flags(%edi) - jz kernel_exit_skip_breakpoints + jz 1f push %ebp call x86_init_user_debug_at_kernel_exit - kernel_exit_skip_breakpoints: + 1: POP_IFRAME_AND_RETURN() kernel_exit_handle_signals: @@ -385,6 +395,11 @@ cli // disable interrupts jmp kernel_exit_work_done + bad_syscall_params: + // clear the fault handler and exit normally + movl %dr3, %edi + movl $0, THREAD_fault_handler(%edi) + jmp kernel_exit_work /*! Handler called by the sysenter instruction ecx - user esp @@ -413,13 +428,11 @@ movl %eax,%es movl %esp, %ebp // frame pointer is the iframe + movl %dr3, %edi // thread pointer // disable breakpoints, if installed - movl %dr3, %edi // thread pointer - testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) - jz skip_debug_at_kernel_entry_sysenter - call x86_exit_user_debug_at_kernel_entry - skip_debug_at_kernel_entry_sysenter: + cli // disable interrupts + DISABLE_BREAKPOINTS() // update the thread's user time UPDATE_THREAD_USER_TIME_PUSH_TIME() @@ -430,29 +443,11 @@ cmp $SYSCALL_COUNT, %esi // check syscall number jae bad_syscall_number movl $kSyscallInfos, %eax // get syscall info - lea (%eax, %esi, SYSCALL_INFO_sizeof), %esi + lea (%eax, %esi, SYSCALL_INFO_sizeof), %edx // copy parameters onto this stack - subl $80, %esp // leave some room for the syscall params + COPY_SYSCALL_PARAMETERS() - // get the address of the syscall parameters - movl IFRAME_user_esp(%ebp), %eax - addl $4, %eax - cmp $KERNEL_BASE, %eax // must not be a kernel address - jae bad_syscall_params - - // get and push the syscall parameter size - movl SYSCALL_INFO_parameter_size(%esi), %ebx - push %ebx - - push %eax - lea 8(%esp), %ebx // stack address where to copy the params - push %ebx - call user_memcpy - addl $12, %esp - test %eax, %eax - jne bad_syscall_params - // pre syscall debugging testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) jnz do_pre_syscall_debug @@ -489,13 +484,13 @@ popa + // ecx already contains the user esp -- load edx with the return address + movl 16(%esp), %edx + // pop eflags, which also reenables interrupts addl $24, %esp // skip, orig_eax/edx, vector, error_code, eip, cs popfl - // ecx already contains the user esp -- load edx with the return address - movl $SYSENTER_RETURN_ADDRESS, %edx - sysexit Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-11 01:46:36 UTC (rev 23110) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-11 14:18:21 UTC (rev 23111) @@ -33,6 +33,7 @@ DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); DEFINE_OFFSET_MACRO(THREAD, thread, flags); DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top); + DEFINE_OFFSET_MACRO(THREAD, thread, fault_handler); // struct iframe DEFINE_OFFSET_MACRO(IFRAME, iframe, cs); From korli at mail.berlios.de Tue Dec 11 17:56:17 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 11 Dec 2007 17:56:17 +0100 Subject: [Haiku-commits] r23112 - in haiku/trunk/src/add-ons/kernel/drivers/audio: ac97/auich ac97/auvia ac97/es1370 emuxki Message-ID: <200712111656.lBBGuHDD020161@sheep.berlios.de> Author: korli Date: 2007-12-11 17:56:17 +0100 (Tue, 11 Dec 2007) New Revision: 23112 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23112&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/io.c haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c Log: fixes misuses of snooze() 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-12-11 14:18:21 UTC (rev 23111) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auich/auich.c 2007-12-11 16:56:17 UTC (rev 23112) @@ -205,7 +205,7 @@ LOG(("channel reset finished, %x, %d\n", stream->base, i)); break; } - snooze(1); + spin(1); } if(i < 0) { @@ -375,7 +375,7 @@ LOG(("channel reset finished, %x, %d\n", stream->base, i)); break; } - snooze(1); + spin(1); } if(i < 0) { Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/io.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/io.c 2007-12-11 14:18:21 UTC (rev 23111) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/auvia/io.c 2007-12-11 16:56:17 UTC (rev 23112) @@ -85,7 +85,7 @@ /* poll until codec not busy */ for(i=0; (iread_io_32(config->nabmbar + AUVIA_CODEC_CTL) & AUVIA_CODEC_BUSY) ; i++) - snooze(1); + spin(1); if(i>=AUVIA_TIMEOUT) { //PRINT(("codec busy\n")); return B_ERROR; @@ -101,7 +101,7 @@ /* poll until codec valid */ for(i=0; (iread_io_32(config->nabmbar + AUVIA_CODEC_CTL) & AUVIA_CODEC_PRIVALID) ; i++) - snooze(1); + spin(1); if(i>=AUVIA_TIMEOUT) { //PRINT(("codec invalid\n")); return B_ERROR; Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c 2007-12-11 14:18:21 UTC (rev 23111) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/ac97/es1370/io.c 2007-12-11 16:56:17 UTC (rev 23112) @@ -68,7 +68,7 @@ if ((es1370_reg_read_32(config, ES1370_REG_STATUS) & STAT_CWRIP) == 0) return B_OK; if (i > 100) - snooze(1); + spin(1); } return B_TIMED_OUT; } Modified: haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-12-11 14:18:21 UTC (rev 23111) +++ haiku/trunk/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c 2007-12-11 16:56:17 UTC (rev 23112) @@ -96,7 +96,7 @@ LOG(("EMU_IPR = %#08x\n",emuxki_reg_read_32(config, EMU_IPR))); LOG(("EMU_INTE = %#08x\n",emuxki_reg_read_32(config, EMU_INTE))); LOG(("EMU_HCFG = %#08x\n",emuxki_reg_read_32(config, EMU_HCFG))); - snooze(100); + snooze(1000); /*emuxki_reg_write_8(config, EMU_AC97ADDRESS, EMU_AC97ADDRESS_READY); LOG(("EMU_AC97ADDRESS_READY = %#08x\n", emuxki_reg_read_16(config, EMU_AC97DATA)));*/ From korli at mail.berlios.de Tue Dec 11 21:20:46 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Tue, 11 Dec 2007 21:20:46 +0100 Subject: [Haiku-commits] r23113 - haiku/trunk/src/bin Message-ID: <200712112020.lBBKKkj8023719@sheep.berlios.de> Author: korli Date: 2007-12-11 21:20:45 +0100 (Tue, 11 Dec 2007) New Revision: 23113 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23113&view=rev Modified: haiku/trunk/src/bin/dstcheck.cpp Log: creates the dststatus file with 600 as permissions Modified: haiku/trunk/src/bin/dstcheck.cpp =================================================================== --- haiku/trunk/src/bin/dstcheck.cpp 2007-12-11 16:56:17 UTC (rev 23112) +++ haiku/trunk/src/bin/dstcheck.cpp 2007-12-11 20:20:45 UTC (rev 23113) @@ -103,7 +103,7 @@ strcat(path, "/time_dststatus"); bool newFile = false; bool dst = false; - int fd = open(path, O_RDWR | O_EXCL | O_CREAT); + int fd = open(path, O_RDWR | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR); if (fd < 0) { newFile = false; fd = open(path, O_RDWR); From axeld at mail.berlios.de Tue Dec 11 22:14:27 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Tue, 11 Dec 2007 22:14:27 +0100 Subject: [Haiku-commits] r23114 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712112114.lBBLERiW028689@sheep.berlios.de> Author: axeld Date: 2007-12-11 22:14:26 +0100 (Tue, 11 Dec 2007) New Revision: 23114 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23114&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp Log: * Print the resolution the boot loader has chosen. * Minor cleanup. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2007-12-11 20:20:45 UTC (rev 23113) +++ haiku/trunk/src/system/boot/platform/bios_ia32/video.cpp 2007-12-11 21:14:26 UTC (rev 23114) @@ -66,10 +66,9 @@ } -/** Insert the video mode into the list, sorted by resolution and bit depth. - * Higher resolutions/depths come first. - */ - +/*! Insert the video mode into the list, sorted by resolution and bit depth. + Higher resolutions/depths come first. +*/ static void add_video_mode(video_mode *videoMode) { @@ -202,7 +201,6 @@ // #pragma mark - vesa -// VESA functions static status_t @@ -329,17 +327,20 @@ modeInfo.memory_model, modeInfo.physical_base, modeInfo.num_planes, modeInfo.num_banks)); - const uint32 requiredAttributes = MODE_ATTR_AVAILABLE | MODE_ATTR_GRAPHICS_MODE - | MODE_ATTR_COLOR_MODE | MODE_ATTR_LINEAR_BUFFER; + const uint32 requiredAttributes = MODE_ATTR_AVAILABLE + | MODE_ATTR_GRAPHICS_MODE | MODE_ATTR_COLOR_MODE + | MODE_ATTR_LINEAR_BUFFER; if (modeInfo.width >= 640 && modeInfo.physical_base != 0 && modeInfo.num_planes == 1 && (modeInfo.memory_model == MODE_MEMORY_PACKED_PIXEL || modeInfo.memory_model == MODE_MEMORY_DIRECT_COLOR) - && (modeInfo.attributes & requiredAttributes) == requiredAttributes) { + && (modeInfo.attributes & requiredAttributes) + == requiredAttributes) { // this mode fits our needs - video_mode *videoMode = (video_mode *)malloc(sizeof(struct video_mode)); + video_mode *videoMode = (video_mode *)malloc( + sizeof(struct video_mode)); if (videoMode == NULL) continue; @@ -361,9 +362,11 @@ // for the standard mode, we prefer a bit depth of 16 // switch to the one with the higher resolution // ToDo: is that always a good idea? for now we'll use 800x600 - if (modeInfo.width >= standardMode->width && modeInfo.width <= 800) { + if (modeInfo.width >= standardMode->width + && modeInfo.width <= 800) { if (modeInfo.width != standardMode->width - || modeInfo.bits_per_pixel >= standardMode->bits_per_pixel) + || modeInfo.bits_per_pixel + >= standardMode->bits_per_pixel) standardMode = videoMode; } } @@ -500,9 +503,9 @@ menu->AddItem(item = new(nothrow) MenuItem("Default")); item->SetMarked(true); item->Select(true); - item->SetHelpText("The Default video mode is the one currently configured in " - "the system. If there is no mode configured yet, a viable mode will be chosen " - "automatically."); + item->SetHelpText("The Default video mode is the one currently configured " + "in the system. If there is no mode configured yet, a viable mode will " + "be chosen automatically."); menu->AddItem(new(nothrow) MenuItem("Standard VGA")); @@ -761,11 +764,15 @@ gKernelArgs.frame_buffer.height = 480; gKernelArgs.frame_buffer.bytes_per_row = 640 / 2; gKernelArgs.frame_buffer.depth = 4; - gKernelArgs.frame_buffer.physical_buffer.size = gKernelArgs.frame_buffer.width + gKernelArgs.frame_buffer.physical_buffer.size + = gKernelArgs.frame_buffer.width * gKernelArgs.frame_buffer.height / 2; gKernelArgs.frame_buffer.physical_buffer.start = 0xa0000; } + dprintf("video mode: %ux%ux%u\n", gKernelArgs.frame_buffer.width, + gKernelArgs.frame_buffer.height, gKernelArgs.frame_buffer.depth); + gKernelArgs.frame_buffer.enabled = true; // If the new frame buffer is either larger than the old one or located at @@ -785,13 +792,11 @@ } // clear the video memory - // ToDo: this shouldn't be necessary on real hardware (and Bochs), but - // at least booting with Qemu looks ugly when this is missing - memset((void *)sFrameBuffer, 0, gKernelArgs.frame_buffer.physical_buffer.size); + memset((void *)sFrameBuffer, 0, + gKernelArgs.frame_buffer.physical_buffer.size); - // ToDo: the boot image is only a temporary solution - it should be - // provided by the loader itself, as well as the blitting routines. - // The image should be compressed, too. + // TODO: The image should be compressed, and eventually added by + // the build process. blit_8bit_image(kImageData, kWidth, kHeight, kPalette, gKernelArgs.frame_buffer.width - kWidth - 40, @@ -837,7 +842,8 @@ edid1_info info; if (vesa_get_edid(&info) == B_OK) { - // we got EDID information from the monitor, try to find a new default mode + // we got EDID information from the monitor, try to find a new default + // mode video_mode *defaultMode = NULL; // try detailed timing first From mmlr at mail.berlios.de Tue Dec 11 22:54:55 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 11 Dec 2007 22:54:55 +0100 Subject: [Haiku-commits] r23115 - haiku/trunk/src/system/kernel/vm Message-ID: <200712112154.lBBLstLQ032502@sheep.berlios.de> Author: mmlr Date: 2007-12-11 22:54:54 +0100 (Tue, 11 Dec 2007) New Revision: 23115 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23115&view=rev Modified: haiku/trunk/src/system/kernel/vm/vm.cpp Log: Make the initial size of the slab depend on the CPU count. This avoids running out of initial space with more than two CPUs. I haven't fully tracked down the usage of this space, probably it is used to allocate some per CPU construct. Modified: haiku/trunk/src/system/kernel/vm/vm.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/vm.cpp 2007-12-11 21:14:26 UTC (rev 23114) +++ haiku/trunk/src/system/kernel/vm/vm.cpp 2007-12-11 21:54:54 UTC (rev 23115) @@ -3477,7 +3477,7 @@ vm_low_memory_init(); - size_t slabInitialSize = 2 * B_PAGE_SIZE; + size_t slabInitialSize = args->num_cpus * 2 * B_PAGE_SIZE; addr_t slabInitialBase = vm_allocate_early(args, slabInitialSize, slabInitialSize, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); slab_init(args, slabInitialBase, slabInitialSize); From mmlr at mail.berlios.de Tue Dec 11 22:57:02 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 11 Dec 2007 22:57:02 +0100 Subject: [Haiku-commits] r23116 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712112157.lBBLv2b9032570@sheep.berlios.de> Author: mmlr Date: 2007-12-11 22:57:02 +0100 (Tue, 11 Dec 2007) New Revision: 23116 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23116&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp Log: Remove 2 CPU limit from ACPI MP detection in the bootloader. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-11 21:54:54 UTC (rev 23115) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-11 21:57:02 UTC (rev 23116) @@ -304,10 +304,6 @@ break; } - // ToDo: remove CPU limit - if (gKernelArgs.num_cpus > 2) - gKernelArgs.num_cpus = 2; - return gKernelArgs.num_cpus > 0 ? B_OK : B_ERROR; } From bonefish at mail.berlios.de Wed Dec 12 00:04:50 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Wed, 12 Dec 2007 00:04:50 +0100 Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 Message-ID: <200712112304.lBBN4oUf003893@sheep.berlios.de> Author: bonefish Date: 2007-12-12 00:04:48 +0100 (Wed, 12 Dec 2007) New Revision: 23117 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23117&view=rev Added: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/commpage.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_commpage.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/commpage.cpp Removed: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S haiku/branches/developer/bonefish/optimization/src/system/kernel/main.c haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c haiku/branches/developer/bonefish/optimization/src/system/libroot/os/arch/x86/syscalls.inc haiku/branches/developer/bonefish/optimization/src/system/libroot/os/time.c Log: * Moved the x86 specific commpage support to the architecture independent code. Only a few details are still architecture dependent (address of the user area, specific table entries). * Got rid of the real_time_data area. We're using a commpage entry now. * In the sysenter handler: Don't hardcode the return address. We're actually reading the respective commpage entry now. Copied: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h (from rev 23070, haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h) =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h 2007-12-06 21:09:35 UTC (rev 23070) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h 2007-12-11 23:04:48 UTC (rev 23117) @@ -0,0 +1,16 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_ARCH_x86_COMMPAGE_H +#define _KERNEL_ARCH_x86_COMMPAGE_H + +#ifndef _KERNEL_COMMPAGE_H +# error Must not be included directly. Include instead! +#endif + +#define COMMPAGE_ENTRY_X86_SYSCALL COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + +#define ARCH_USER_COMMPAGE_ADDR (0xffff0000) + +#endif /* _KERNEL_ARCH_x86_COMMPAGE_H */ Deleted: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h Copied: haiku/branches/developer/bonefish/optimization/headers/private/kernel/commpage.h (from rev 23070, haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h) =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/commpage.h 2007-12-06 21:09:35 UTC (rev 23070) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/commpage.h 2007-12-11 23:04:48 UTC (rev 23117) @@ -0,0 +1,53 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _KERNEL_COMMPAGE_H +#define _KERNEL_COMMPAGE_H + +/*! 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 +#define COMMPAGE_ENTRY_REAL_TIME_DATA 2 +#define COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC 3 + +#define COMMPAGE_SIZE (0x8000) +#define COMMPAGE_TABLE_ENTRIES 64 + +#define COMMPAGE_SIGNATURE 'COMM' +#define COMMPAGE_VERSION 1 + +#define USER_COMMPAGE_ADDR ARCH_USER_COMMPAGE_ADDR + // set by the architecture specific implementation + +#ifndef _ASSEMBLER + +#define USER_COMMPAGE_TABLE ((void**)(USER_COMMPAGE_ADDR)) + +#ifdef __cplusplus +extern "C" { +#endif + +status_t commpage_init(void); +void* allocate_commpage_entry(int entry, size_t size); +void* fill_commpage_entry(int entry, const void* copyFrom, size_t size); + +status_t arch_commpage_init(void); + // implemented in the architecture specific part + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // ! _ASSEMBLER + +#include + +#endif /* _KERNEL_COMMPAGE_H */ Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/Jamfile 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/Jamfile 2007-12-11 23:04:48 UTC (rev 23117) @@ -16,6 +16,7 @@ KernelMergeObject kernel_core.o : boot_item.cpp + commpage.cpp condition_variable.cpp cpu.c elf.cpp Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-11 23:04:48 UTC (rev 23117) @@ -11,6 +11,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) $(DOTDOT) generic ] ; KernelStaticLibrary libx86 : + arch_commpage.cpp arch_cpu.c arch_debug.cpp arch_debug_console.c @@ -31,7 +32,6 @@ apm.cpp bios.cpp cpuid.S - commpage.c syscall.S generic_vm_physical_page_mapper.cpp Copied: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_commpage.cpp (from rev 23109, haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c) =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_commpage.cpp 2007-12-11 23:04:48 UTC (rev 23117) @@ -0,0 +1,105 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + +#include + +#include + +#include +#include + + +// user syscall assembly stubs +extern "C" void _user_syscall_int(void); +extern unsigned int _user_syscall_int_end; +extern "C" void _user_syscall_sysenter(void); +extern unsigned int _user_syscall_sysenter_end; + +// sysenter handler +extern "C" void x86_sysenter(); + + +static bool +all_cpus_have_feature(enum x86_feature_type type, int feature) +{ + int i; + int cpuCount = smp_get_num_cpus(); + + for (i = 0; i < cpuCount; i++) { + if (!(gCPU[i].arch.feature[type] & feature)) + return false; + } + + return true; +} + + +static void +init_intel_syscall_registers(void* dummy, int cpuNum) +{ + x86_write_msr(IA32_MSR_SYSENTER_CS, KERNEL_CODE_SEG); + x86_write_msr(IA32_MSR_SYSENTER_ESP, 0); + x86_write_msr(IA32_MSR_SYSENTER_EIP, (addr_t)x86_sysenter); +} + + +#if 0 +static void +init_amd_syscall_registers(void* dummy, int cpuNum) +{ + // TODO: ... +} +#endif + + +static status_t +initialize_commpage_syscall(void) +{ + void* syscallCode = &_user_syscall_int; + void* syscallCodeEnd = &_user_syscall_int_end; + + // check syscall + if (all_cpus_have_feature(FEATURE_COMMON, IA32_FEATURE_SEP) + && !(gCPU[0].arch.family == 6 && gCPU[0].arch.model < 3 + && gCPU[0].arch.stepping < 3)) { + // Intel sysenter/sysexit + dprintf("initialize_commpage_syscall(): sysenter/sysexit supported\n"); + + // the code to be used in userland + syscallCode = &_user_syscall_sysenter; + syscallCodeEnd = &_user_syscall_sysenter_end; + + // tell all CPUs to init their sysenter/sysexit related registers + call_all_cpus_sync(&init_intel_syscall_registers, NULL); + } else if (all_cpus_have_feature(FEATURE_EXT_AMD, + IA32_FEATURE_AMD_EXT_SYSCALL)) { + // AMD syscall/sysret + dprintf("initialize_commpage_syscall(): syscall/sysret supported " + "-- not yet by Haiku, though"); + } else { + // no special syscall support + dprintf("initialize_commpage_syscall(): no special syscall support\n"); + } + + // fill in the table entry + size_t len = (size_t)((addr_t)syscallCodeEnd - (addr_t)syscallCode); + fill_commpage_entry(COMMPAGE_ENTRY_X86_SYSCALL, syscallCode, len); + + return B_OK; +} + + +status_t +arch_commpage_init(void) +{ + // select the optimum syscall mechanism and patch the commpage + initialize_commpage_syscall(); + + return B_OK; +} + Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c 2007-12-11 23:04:48 UTC (rev 23117) @@ -21,7 +21,6 @@ #include #include #include -#include #include "interrupts.h" @@ -516,9 +515,6 @@ // setup SSE2/3 support init_sse(); - // initialize the commpage support - commpage_init(); - return B_OK; } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-11 23:04:48 UTC (rev 23117) @@ -7,11 +7,11 @@ * Distributed under the terms of the NewOS License. */ -#include #include #include -#include #include +#include +#include #include "asm_offsets.h" #include "syscall_numbers.h" @@ -131,10 +131,7 @@ movl %dr3, %edi; /* thread pointer */ \ movl $0, THREAD_fault_handler(%edi) -#define SYSENTER_RETURN_ADDRESS \ - (USER_COMMPAGE_ADDR + TABLE_ENTRIES * 4 + 4) - .text #define TRAP_ERRC(name, vector) \ @@ -401,6 +398,7 @@ movl $0, THREAD_fault_handler(%edi) jmp kernel_exit_work + /*! Handler called by the sysenter instruction ecx - user esp */ @@ -415,8 +413,12 @@ pushfl // eflags orl $(1 << 9), (%esp) // set the IF (interrupts) bit pushl $USER_CODE_SEG // user cs - pushl $SYSENTER_RETURN_ADDRESS // user_eip + // user_eip + movl USER_COMMPAGE_ADDR + 4 * COMMPAGE_ENTRY_X86_SYSCALL, %edx + addl $4, %edx // sysenter is at offset 2, 2 bytes long + pushl %edx + PUSH_IFRAME_BOTTOM_SYSCALL() // save %eax, the number of the syscall Deleted: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c Copied: haiku/branches/developer/bonefish/optimization/src/system/kernel/commpage.cpp (from rev 23109, haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c) =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/commpage.c 2007-12-11 00:06:20 UTC (rev 23109) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/commpage.cpp 2007-12-11 23:04:48 UTC (rev 23117) @@ -0,0 +1,75 @@ +/* + * Copyright 2007, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include + +#include + +#include + +#include +#include + + +static area_id sCommPageArea; +static area_id sUserCommPageArea; +static addr_t* sCommPageAddress; +static addr_t* sUserCommPageAddress; +static void* sFreeCommPageSpace; + + +#define ALIGN_ENTRY(pointer) (void*)ROUNDUP((addr_t)(pointer), 8) + + +void* +allocate_commpage_entry(int entry, size_t size) +{ + void* space = sFreeCommPageSpace; + sFreeCommPageSpace = ALIGN_ENTRY((addr_t)sFreeCommPageSpace + size); + sCommPageAddress[entry] = (addr_t)sUserCommPageAddress + + ((addr_t)space - (addr_t)sCommPageAddress); +dprintf("allocate_commpage_entry(%d, %lu) -> %p\n", entry, size, (void*)sCommPageAddress[entry]); + return space; +} + + +void* +fill_commpage_entry(int entry, const void* copyFrom, size_t size) +{ + void* space = allocate_commpage_entry(entry, size); + memcpy(space, copyFrom, size); + return space; +} + + +status_t +commpage_init(void) +{ + // create a read/write kernel area + sCommPageArea = create_area("commpage", (void **)&sCommPageAddress, + 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 + sUserCommPageAddress = (addr_t*)USER_COMMPAGE_ADDR; + sUserCommPageArea = clone_area("user_commpage", + (void **)&sUserCommPageAddress, B_EXACT_ADDRESS, + B_READ_AREA | B_EXECUTE_AREA, sCommPageArea); + + // zero it out + memset(sCommPageAddress, 0, COMMPAGE_SIZE); + + // fill in some of the table + sCommPageAddress[0] = COMMPAGE_SIGNATURE; + sCommPageAddress[1] = COMMPAGE_VERSION; + + // the next slot to allocate space is after the table + sFreeCommPageSpace = ALIGN_ENTRY(&sCommPageAddress[COMMPAGE_TABLE_ENTRIES]); + + arch_commpage_init(); + + return B_OK; +} + Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/main.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/main.c 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/main.c 2007-12-11 23:04:48 UTC (rev 23117) @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,7 @@ debug_init_post_vm(&sKernelArgs); int_init_post_vm(&sKernelArgs); cpu_init_post_vm(&sKernelArgs); + commpage_init(); TRACE("init system info\n"); system_info_init(&sKernelArgs); Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/real_time_clock.c 2007-12-11 23:04:48 UTC (rev 23117) @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -91,28 +92,9 @@ status_t rtc_init(kernel_args *args) { - void *clonedRealTimeData; + sRealTimeData = (struct real_time_data*)allocate_commpage_entry( + COMMPAGE_ENTRY_REAL_TIME_DATA, sizeof(struct real_time_data)); - area_id area = create_area("real time data", (void **)&sRealTimeData, - B_ANY_KERNEL_ADDRESS, PAGE_ALIGN(sizeof(struct real_time_data)), - B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); - if (area < B_OK) { - panic("rtc_init: error creating real time data area\n"); - return area; - } - - // On some systems like x86, a page cannot be read-only in userland and - // writable in the kernel. Therefore, we clone the real time data area - // here for user access; it doesn't hurt on other platforms, too. - // The area is used to share time critical information, such as the system - // time conversion factor which can change at any time. - - if (clone_area("real time data userland", &clonedRealTimeData, - B_ANY_KERNEL_ADDRESS, B_READ_AREA, area) < B_OK) { - dprintf("rtc_init: error creating real time data userland area\n"); - // we don't panic because it's not kernel critical - } - arch_rtc_init(args, sRealTimeData); rtc_hw_to_system(); Modified: haiku/branches/developer/bonefish/optimization/src/system/libroot/os/arch/x86/syscalls.inc =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/libroot/os/arch/x86/syscalls.inc 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/libroot/os/arch/x86/syscalls.inc 2007-12-11 23:04:48 UTC (rev 23117) @@ -14,7 +14,7 @@ * branch to the syscall vector in the commpage */ -#include +#include #define _SYSCALL(name, n) \ .globl name; \ @@ -22,7 +22,7 @@ .align 8; \ name: \ movl $n,%eax; \ - jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_SYSCALL * 4) + jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_SYSCALL * 4) #define SYSCALL0(name, n) _SYSCALL(name, n) #define SYSCALL1(name, n) _SYSCALL(name, n) Modified: haiku/branches/developer/bonefish/optimization/src/system/libroot/os/time.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/libroot/os/time.c 2007-12-11 21:57:02 UTC (rev 23116) +++ haiku/branches/developer/bonefish/optimization/src/system/libroot/os/time.c 2007-12-11 23:04:48 UTC (rev 23117) @@ -4,6 +4,7 @@ */ +#include #include #include #include @@ -16,26 +17,16 @@ #include -static struct real_time_data sRealTimeDefaults; static struct real_time_data *sRealTimeData; void __init_time(void) { - bool setDefaults = false; - area_id dataArea; - area_info info; + sRealTimeData = (struct real_time_data*) + USER_COMMPAGE_TABLE[COMMPAGE_ENTRY_REAL_TIME_DATA]; - dataArea = find_area("real time data userland"); - if (dataArea < 0 || get_area_info(dataArea, &info) < B_OK) { - syslog(LOG_ERR, "error finding real time data area: %s\n", strerror(dataArea)); - sRealTimeData = &sRealTimeDefaults; - setDefaults = true; - } else - sRealTimeData = (struct real_time_data *)info.address; - - __arch_init_time(sRealTimeData, setDefaults); + __arch_init_time(sRealTimeData, false); } From axeld at pinc-software.de Wed Dec 12 10:31:13 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 12 Dec 2007 10:31:13 +0100 CET Subject: [Haiku-commits] =?iso-8859-15?q?r23117_-_in_haiku/branches/develo?= =?iso-8859-15?q?per/bonefish/optimization=3A_headers/private/kernel_heade?= =?iso-8859-15?q?rs/private/kernel/arch/x86_src/system/kernel_src/system/k?= =?iso-8859-15?q?ernel/arch/x86_src/system/libroot/os__src/system/libroot/?= =?iso-8859-15?q?os/arch/x86?= In-Reply-To: <200712112304.lBBN4oUf003893@sheep.berlios.de> Message-ID: <920904966-BeMail@zon> bonefish at BerliOS wrote: > Log: > * Moved the x86 specific commpage support to the architecture > independent code. Only a few details are still architecture > dependent > (address of the user area, specific table entries). Not sure if that's really needed, as other architectures might not need a page like this at all (at least how we're currently using it). But it can't hurt, of course ;-) Bye, Axel. From geist at foobox.com Wed Dec 12 11:03:51 2007 From: geist at foobox.com (Travis Geiselbrecht) Date: Wed, 12 Dec 2007 02:03:51 -0800 Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: <920904966-BeMail@zon> References: <920904966-BeMail@zon> Message-ID: On Dec 12, 2007, at 1:31 AM, Axel D?rfler wrote: > bonefish at BerliOS wrote: >> Log: >> * Moved the x86 specific commpage support to the architecture >> independent code. Only a few details are still architecture >> dependent >> (address of the user area, specific table entries). > > Not sure if that's really needed, as other architectures might not > need > a page like this at all (at least how we're currently using it). > But it > can't hurt, of course ;-) > Can't really hurt, but yeah other arches probably don'tt need the syscall part of it at least. Glad to see it's getting used for something. Travis From geist at foobox.com Wed Dec 12 11:06:39 2007 From: geist at foobox.com (Travis Geiselbrecht) Date: Wed, 12 Dec 2007 02:06:39 -0800 Subject: [Haiku-commits] r23109 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 In-Reply-To: <200712110006.lBB06MlK020890@sheep.berlios.de> References: <200712110006.lBB06MlK020890@sheep.berlios.de> Message-ID: Yeah, i had gone through most of this before, but never finished it and checked it in. To solve this particular problem, I had the exit of the kernel in the sysexit case return to another handler in the commpage that restored edx before popping back to where user space called the syscall. It's pretty grody, but it basically worked. travis On Dec 10, 2007, at 4:06 PM, bonefish at BerliOS wrote: > Author: bonefish > Date: 2007-12-11 01:06:20 +0100 (Tue, 11 Dec 2007) > New Revision: 23109 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23109&view=rev > > Modified: > haiku/branches/developer/bonefish/optimization/headers/private/ > kernel/arch/x86/arch_cpu.h > haiku/branches/developer/bonefish/optimization/src/system/kernel/ > arch/x86/arch_interrupts.S > haiku/branches/developer/bonefish/optimization/src/system/kernel/ > arch/x86/asm_offsets.cpp > haiku/branches/developer/bonefish/optimization/src/system/kernel/ > arch/x86/commpage.c > haiku/branches/developer/bonefish/optimization/src/system/kernel/ > arch/x86/syscall.S > Log: > Added Intel sysenter/sysexit support (commpage, handler). It seems to > basically work, but ATM we trash edx on return, which is one half of > the return value for syscalls returning 64 bit values. > > > Modified: haiku/branches/developer/bonefish/optimization/headers/ > private/kernel/arch/x86/arch_cpu.h > =================================================================== > --- haiku/branches/developer/bonefish/optimization/headers/private/ > kernel/arch/x86/arch_cpu.h 2007-12-10 23:50:40 UTC (rev 23108) > +++ haiku/branches/developer/bonefish/optimization/headers/private/ > kernel/arch/x86/arch_cpu.h 2007-12-11 00:06:20 UTC (rev 23109) > @@ -21,6 +21,9 @@ > #define IA32_MSR_APIC_BASE 0x1b > > #define IA32_MSR_MTRR_CAPABILITIES 0xfe > +#define IA32_MSR_SYSENTER_CS 0x174 > +#define IA32_MSR_SYSENTER_ESP 0x175 > +#define IA32_MSR_SYSENTER_EIP 0x176 > #define IA32_MSR_MTRR_DEFAULT_TYPE 0x2ff > #define IA32_MSR_MTRR_PHYSICAL_BASE_0 0x200 > #define IA32_MSR_MTRR_PHYSICAL_MASK_0 0x201 > > Modified: haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/arch_interrupts.S > =================================================================== > --- haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/arch_interrupts.S 2007-12-10 23:50:40 UTC (rev 23108) > +++ haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/arch_interrupts.S 2007-12-11 00:06:20 UTC (rev 23109) > @@ -8,9 +8,10 @@ > */ > > #include > -#include > #include > #include > +#include > +#include > > #include "asm_offsets.h" > #include "syscall_numbers.h" > @@ -65,6 +66,21 @@ > /* thread->in_kernel = false; */ \ > movb $0, THREAD_in_kernel(%edi) > > +#define PUSH_IFRAME_BOTTOM(iframeType) \ > + pusha; \ > + push %ds; \ > + push %es; \ > + push %fs; \ > + push %gs; \ > + pushl $iframeType > + > +#define PUSH_IFRAME_BOTTOM_SYSCALL() \ > + pushl $0; \ > + pushl $99; \ > + pushl %edx; \ > + pushl %eax; \ > + PUSH_IFRAME_BOTTOM(IFRAME_TYPE_SYSCALL) > + > #define POP_IFRAME_AND_RETURN() \ > /* skip iframe type */ \ > lea 4(%ebp), %esp; \ > @@ -80,7 +96,10 @@ > original eax/edx values */ \ > iret > > +#define SYSENTER_RETURN_ADDRESS \ > + (USER_COMMPAGE_ADDR + TABLE_ENTRIES * 4 + 4) > > + > .text > > #define TRAP_ERRC(name, vector) \ > @@ -164,18 +183,16 @@ > .align 16 > .globl int_bottom > int_bottom: > - pusha > - push %ds > - push %es > - push %fs > - push %gs > - push $IFRAME_TYPE_OTHER > + PUSH_IFRAME_BOTTOM(IFRAME_TYPE_OTHER) > > movl %esp, %ebp // frame pointer is the iframe > > cmp $USER_CODE_SEG, IFRAME_cs(%ebp) > je int_bottom_user > > + // disable interrupts -- the handler will enable them, if necessary > + cli > + > pushl %ebp > movl IFRAME_vector(%ebp), %eax > call *gInterruptHandlerTable(, %eax, 4) > @@ -230,16 +247,7 @@ > .globl trap99 > trap99: > // push error, vector, orig_edx, orig_eax, and other registers > - pushl $0 > - pushl $99 > - pushl %edx > - pushl %eax > - pusha > - push %ds > - push %es > - push %fs > - push %gs > - push $IFRAME_TYPE_SYSCALL > + PUSH_IFRAME_BOTTOM_SYSCALL() > > // save %eax, the number of the syscall > movl %eax, %esi > @@ -364,8 +372,120 @@ > call thread_at_kernel_exit > cli // disable interrupts > jmp kernel_exit_work_done > - > > + > +/*! Handler called by the sysenter instruction > + ecx - user esp > +*/ > +FUNCTION(x86_sysenter): > + // switch the stack > + movl %dr3, %edx > + movl THREAD_kernel_stack_top(%edx), %esp > + > + // push the iframe > + pushl $USER_DATA_SEG // user_ss > + pushl %ecx // user_esp > + pushfl // eflags > + orl $(1 << 9), (%esp) // set the IF (interrupts) bit > + pushl $USER_CODE_SEG // user cs > + pushl $SYSENTER_RETURN_ADDRESS // user_eip > + > + PUSH_IFRAME_BOTTOM_SYSCALL() > + > + // save %eax, the number of the syscall > + movl %eax, %esi > + > + movl $KERNEL_DATA_SEG,%eax > + cld > + movl %eax,%ds > + movl %eax,%es > + > + movl %esp, %ebp // frame pointer is the iframe > + > + // disable breakpoints, if installed > + movl %dr3, %edi // thread pointer > + testl $THREAD_FLAGS_BREAKPOINTS_INSTALLED, THREAD_flags(%edi) > + jz skip_debug_at_kernel_entry_sysenter > + call x86_exit_user_debug_at_kernel_entry > + skip_debug_at_kernel_entry_sysenter: > + > + // update the thread's user time > + UPDATE_THREAD_USER_TIME_PUSH_TIME() > + // leave the time on the stack (needed for post syscall debugging) > + > + sti // enable interrupts > + > + cmp $SYSCALL_COUNT, %esi // check syscall number > + jae bad_syscall_number > + movl $kSyscallInfos, %eax // get syscall info > + lea (%eax, %esi, SYSCALL_INFO_sizeof), %esi > + > + // copy parameters onto this stack > + subl $80, %esp // leave some room for the syscall params > + > + // get the address of the syscall parameters > + movl IFRAME_user_esp(%ebp), %eax > + addl $4, %eax > + cmp $KERNEL_BASE, %eax // must not be a kernel address > + jae bad_syscall_params > + > + // get and push the syscall parameter size > + movl SYSCALL_INFO_parameter_size(%esi), %ebx > + push %ebx > + > + push %eax > + lea 8(%esp), %ebx // stack address where to copy the params > + push %ebx > + call user_memcpy > + addl $12, %esp > + test %eax, %eax > + jne bad_syscall_params > + > + // pre syscall debugging > + testl $THREAD_FLAGS_DEBUGGER_INSTALLED, THREAD_flags(%edi) > + jnz do_pre_syscall_debug > + // if debugging is enabled, we take the slow syscall exit > + > + // call the syscall function > + call *SYSCALL_INFO_function(%esi) > + > + // overwrite the values of %eax and %edx on the stack (the > syscall return > + // value) > + movl %edx, IFRAME_edx(%ebp) > + movl %eax, IFRAME_eax(%ebp) > + > + testl $(THREAD_FLAGS_DEBUGGER_INSTALLED | > THREAD_FLAGS_SIGNALS_PENDING \ > + | THREAD_FLAGS_DEBUG_THREAD | THREAD_FLAGS_BREAKPOINTS_DEFINED) \ > + , THREAD_flags(%edi) > + jnz post_syscall_work > + // if any special work has to be done, we take the slow syscall > exit > + > + cli // disable interrupts > + > + // update the thread's kernel time > + UPDATE_THREAD_KERNEL_TIME() > + > + // pop the bottom of the iframe > + lea 4(%ebp), %esp // skip iframe type > + > + pop %gs > + addl $4, %esp /* we skip %fs, as this contains the CPU > + dependent TLS segment */ > + pop %es > + pop %ds > + > + popa > + > + // pop eflags, which also reenables interrupts > + addl $24, %esp // skip, orig_eax/edx, vector, error_code, eip, cs > + popfl > + > + // ecx already contains the user esp -- load edx with the return > address > + movl $SYSENTER_RETURN_ADDRESS, %edx > + > + sysexit > + > + > /*! Is copied to the signal stack call to restore the original > frame when > the signal handler exits. > The copying code (in arch_thread.c::arch_setup_signal_frame()) > copies > > Modified: haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/asm_offsets.cpp > =================================================================== > --- haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/asm_offsets.cpp 2007-12-10 23:50:40 UTC (rev 23108) > +++ haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/asm_offsets.cpp 2007-12-11 00:06:20 UTC (rev 23109) > @@ -32,6 +32,7 @@ > DEFINE_OFFSET_MACRO(THREAD, thread, last_time); > DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); > DEFINE_OFFSET_MACRO(THREAD, thread, flags); > + DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top); > > // struct iframe > DEFINE_OFFSET_MACRO(IFRAME, iframe, cs); > @@ -39,6 +40,8 @@ > DEFINE_OFFSET_MACRO(IFRAME, iframe, edx); > DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax); > DEFINE_OFFSET_MACRO(IFRAME, iframe, vector); > + DEFINE_OFFSET_MACRO(IFRAME, iframe, eip); > + DEFINE_OFFSET_MACRO(IFRAME, iframe, flags); > DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp); > > // struct syscall_info > > Modified: haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/commpage.c > =================================================================== > --- haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/commpage.c 2007-12-10 23:50:40 UTC (rev 23108) > +++ haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/commpage.c 2007-12-11 00:06:20 UTC (rev 23109) > @@ -10,6 +10,8 @@ > > #include > > +#include > +#include > #include > #include > > @@ -20,11 +22,16 @@ > static unsigned long *user_comm_ptr; > static void *next_comm_addr; > > -// user syscall assembly stub > +// user syscall assembly stubs > extern void _user_syscall_int(void); > extern unsigned int _user_syscall_int_end; > +extern void _user_syscall_sysenter(void); > +extern unsigned int _user_syscall_sysenter_end; > > +// sysenter handler > +extern void x86_sysenter(); > > + > static inline addr_t > commpage_ptr_to_user_ptr(const void *ptr) > { > @@ -32,15 +39,72 @@ > } > > > +static bool > +all_cpus_have_feature(enum x86_feature_type type, int feature) > +{ > + int i; > + int cpuCount = smp_get_num_cpus(); > + > + for (i = 0; i < cpuCount; i++) { > + if (!(gCPU[i].arch.feature[type] & feature)) > + return false; > + } > + > + return true; > +} > + > + > +static void > +init_intel_syscall_registers(void* dummy, int cpuNum) > +{ > + x86_write_msr(IA32_MSR_SYSENTER_CS, KERNEL_CODE_SEG); > + x86_write_msr(IA32_MSR_SYSENTER_ESP, 0); > + x86_write_msr(IA32_MSR_SYSENTER_EIP, (addr_t)x86_sysenter); > +} > + > + > +#if 0 > +static void > +init_amd_syscall_registers(void* dummy, int cpuNum) > +{ > + // TODO: ... > +} > +#endif > + > + > static status_t > initialize_commpage_syscall(void) > { > size_t len; > - > - // for now, we're hard coded to use the legacy method (int 99) > - len = (size_t)((void *)&_user_syscall_int_end - (void *) > &_user_syscall_int); > - memcpy(next_comm_addr, &_user_syscall_int, len); > + void* syscallCode = &_user_syscall_int; > + void* syscallCodeEnd = &_user_syscall_int_end; > > + // check syscall > + if (all_cpus_have_feature(FEATURE_COMMON, IA32_FEATURE_SEP) > + && !(gCPU[0].arch.family == 6 && gCPU[0].arch.model < 3 > + && gCPU[0].arch.stepping < 3)) { > + // Intel sysenter/sysexit > + dprintf("initialize_commpage_syscall(): sysenter/sysexit > supported\n"); > + > + // the code to be used in userland > + syscallCode = &_user_syscall_sysenter; > + syscallCodeEnd = &_user_syscall_sysenter_end; > + > + // tell all CPUs to init their sysenter/sysexit related registers > + call_all_cpus_sync(&init_intel_syscall_registers, NULL); > + } else if (all_cpus_have_feature(FEATURE_EXT_AMD, > + IA32_FEATURE_AMD_EXT_SYSCALL)) { > + // AMD syscall/sysret > + dprintf("initialize_commpage_syscall(): syscall/sysret supported " > + "-- not yet by Haiku, though"); > + } else { > + // no special syscall support > + dprintf("initialize_commpage_syscall(): no special syscall > support\n"); > + } > + > + len = (size_t)(syscallCodeEnd - syscallCode); > + memcpy(next_comm_addr, syscallCode, len); > + > // fill in the table entry > comm_ptr[COMMPAGE_ENTRY_SYSCALL] = commpage_ptr_to_user_ptr > (next_comm_addr); > next_comm_addr = (void *)((addr_t)next_comm_addr + ROUNDUP(len, 4)); > > Modified: haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/syscall.S > =================================================================== > --- haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/syscall.S 2007-12-10 23:50:40 UTC (rev 23108) > +++ haiku/branches/developer/bonefish/optimization/src/system/ > kernel/arch/x86/syscall.S 2007-12-11 00:06:20 UTC (rev 23109) > @@ -9,11 +9,21 @@ > .text > > /* user space half of the syscall mechanism, to be copied into the > commpage */ > + > +// int 99 fallback > FUNCTION(_user_syscall_int): > int $99 > ret > SYM(_user_syscall_int_end): > > > +// Intel sysenter/sysexit > +FUNCTION(_user_syscall_sysenter): > + // sysexit forces us to trash edx (-> eip) and ecx (-> esp), but > they are > + // scratch registers anyway. We use ecx right away to store esp. > + movl %esp, %ecx > + sysenter > + ret > +SYM(_user_syscall_sysenter_end): > > > > _______________________________________________ > Haiku-commits mailing list > Haiku-commits at lists.berlios.de > https://lists.berlios.de/mailman/listinfo/haiku-commits From marcusoverhagen at arcor.de Wed Dec 12 11:53:23 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Wed, 12 Dec 2007 11:53:23 +0100 (CET) Subject: [Haiku-commits] r23109 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/kernel/arch/x86 Message-ID: <15667255.1197456803079.JavaMail.ngmail@webmail15> Travis Geiselbrecht wrote: > Yeah, i had gone through most of this before, but never finished it > and checked it in. To solve this particular problem, I had the exit > of the kernel in the sysexit case return to another handler in the > commpage that restored edx before popping back to where user space > called the syscall. It's pretty grody, but it basically worked. > Hi Travis and Ingo, I read the paper [1] yesterday and came up with a similar conclusion. On the compage, we need to setup a sysexit trampoline entry, that will pop edx from stack and do the return from there. Before calling sysexit, we need to manipulate the stack and esp so that we can savely place edx and the real return address on the stack. Then we need to return to the trampoline page instead of directly returning to the caller. [1] http://www.summitsoftconsulting.com/SysCallOpts.htm regards Marcus 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 29,95 ? inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From ingo_weinhold at gmx.de Wed Dec 12 14:53:58 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 12 Dec 2007 14:53:58 +0100 Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: References: <920904966-BeMail@zon> Message-ID: <20071212145358.400.2@knochen-vm.nameserver> On 2007-12-12 at 11:03:51 [+0100], Travis Geiselbrecht wrote: > On Dec 12, 2007, at 1:31 AM, Axel D?rfler wrote: > > bonefish at BerliOS wrote: > >> Log: > >> * Moved the x86 specific commpage support to the architecture > >> independent code. Only a few details are still architecture > >> dependent > >> (address of the user area, specific table entries). > > > > Not sure if that's really needed, as other architectures might not > > need > > a page like this at all (at least how we're currently using it). > > But it > > can't hurt, of course ;-) > > > Can't really hurt, but yeah other arches probably don'tt need the > syscall part of it at least. Yep, the syscall entry slot is defined in the x86 specific header only. The real time data entry is generic though (as was the real time data page), and I suppose on most architectures one will want to have model-specific optimized versions of common functions (memcpy() etc.), which would be another application for the commpage. CU, Ingo From revol at free.fr Wed Dec 12 15:22:32 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 12 Dec 2007 15:22:32 +0100 CET Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: <20071212145358.400.2@knochen-vm.nameserver> Message-ID: <815633834-BeMail@laptop> > > On 2007-12-12 at 11:03:51 [+0100], Travis Geiselbrecht < > geist at foobox.com> > wrote: > > On Dec 12, 2007, at 1:31 AM, Axel D?rfler wrote: > > > bonefish at BerliOS wrote: > > >> Log: > > >> * Moved the x86 specific commpage support to the architecture > > >> independent code. Only a few details are still architecture > > >> dependent > > >> (address of the user area, specific table entries). > > > > > > Not sure if that's really needed, as other architectures might > > > not > > > need > > > a page like this at all (at least how we're currently using it). > > > But it > > > can't hurt, of course ;-) > > > > > Can't really hurt, but yeah other arches probably don'tt need the > > syscall part of it at least. > > Yep, the syscall entry slot is defined in the x86 specific header > only. The > real time data entry is generic though (as was the real time data > page), > and I suppose on most architectures one will want to have model- > specific > optimized versions of common functions (memcpy() etc.), which would > be > another application for the commpage. On 68k I'd stuff 64 bit atomics in as the CAS2 opcode got removed from the 060, so we'll need syscalls for that one, but we can use (not inline though :^)) asm funcs for 030 and 040. System time stuff OTH will be tricky to do (no RDTSC like stuff). Fran?ois. From axeld at pinc-software.de Wed Dec 12 15:44:01 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 12 Dec 2007 15:44:01 +0100 CET Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: <815633834-BeMail@laptop> Message-ID: <19688801168-BeMail@zon> "Fran?ois Revol" wrote: > System time stuff OTH will be tricky to do (no RDTSC like stuff). But usually these old systems had dedicated timer processors, so that shouldn't be much of a problem (just lots of work :-)). Bye, Axel. From ingo_weinhold at gmx.de Wed Dec 12 15:57:33 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 12 Dec 2007 15:57:33 +0100 Subject: [Haiku-commits] r23109 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch /x86 src/system/kernel/arch/x86 In-Reply-To: <15667255.1197456803079.JavaMail.ngmail@webmail15> References: <15667255.1197456803079.JavaMail.ngmail@webmail15> Message-ID: <20071212155733.336.1@knochen-vm.nameserver> On 2007-12-12 at 11:53:23 [+0100], Marcus Overhagen wrote: > Travis Geiselbrecht wrote: > > > Yeah, i had gone through most of this before, but never finished it > > and checked it in. To solve this particular problem, I had the exit > > of the kernel in the sysexit case return to another handler in the > > commpage that restored edx before popping back to where user space > > called the syscall. It's pretty grody, but it basically worked. > > > Hi Travis and Ingo, > > I read the paper [1] yesterday and came up with a similar conclusion. > On the compage, we need to setup a sysexit trampoline entry, that > will pop edx from stack and do the return from there. > > Before calling sysexit, we need to manipulate the stack and esp so > that we can savely place edx and the real return address on the stack. > Then we need to return to the trampoline page instead of directly > returning to the caller. I considered this option, but then decided, that instead of doing extra work for all syscalls, I'd rather take the slow (iret) exit (which doesn't have the edx problem) in case of the three syscalls that actually return 64 bit values (_kern_restore_signal_frame(), _kern_set_alarm(), _kern_seek() (plus the unused _kern_system_time())). The other option I considered was to simply change the signatures of those syscall functions to return their value through a pointer parameter. That would also allow to drop the orig_edx field of the iframe. This solution would punish architectures that don't have a problem with returning 64 bit values via registers, though. If you have arguments for one of the options I haven't chosen, please shoot. I'm pretty passionless in this respect. BTW, the current statistics regarding the syscall performance. On my P4 3.2 GHz, measured with the syscall_time test (a slightly modified version under Linux and Windows, using close(-1) and gettimeofday()), in us/syscall: Linux: 0.261 Windows XP: 0.445 Haiku: 0.628 (was 4.68) Zeta: 1.46 So we're still 2.4 times slower than Linux. They don't update the thread's user and kernel times in the syscall, which we do, but that accounts only for about 0.05 us. They also -- magically -- don't need to copy the syscall parameters onto the kernel stack (at least I fail to see, how it is done, cf. arch/i386/kernel/entry.S:sysenter_entry in the Linux kernel sources). I'm pretty much out of options for more syscall related optimizations, so if anyone has suggestions, don't hesitate to throw them in. CU, Ingo PS: BTW, directing syscalls over the commpage is horribly slow under VMware (35 us vs. 2 us with an inline "int 99"). Any ideas why? From revol at free.fr Wed Dec 12 18:59:04 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 12 Dec 2007 18:59:04 +0100 CET Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: <19688801168-BeMail@zon> Message-ID: <289686607-BeMail@laptop> > "Fran?ois Revol" wrote: > > System time stuff OTH will be tricky to do (no RDTSC like stuff). > > But usually these old systems had dedicated timer processors, so that > shouldn't be much of a problem (just lots of work :-)). > Most use an MFP or similar chip yes, wich provide like 3 or 4 timers, which can be read, but they are 8 bit or at best 16. Implementing system_time without an atomic monotonic clocked counter will likely add quite some overhead. Fran?ois From mmlr at mail.berlios.de Wed Dec 12 19:39:41 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Wed, 12 Dec 2007 19:39:41 +0100 Subject: [Haiku-commits] r23118 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/boot/platform/bios_ia32 Message-ID: <200712121839.lBCIdfnL020637@sheep.berlios.de> Author: mmlr Date: 2007-12-12 19:39:41 +0100 (Wed, 12 Dec 2007) New Revision: 23118 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23118&view=rev Modified: haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp Log: Ignore disabled local APICs. Modified: haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h 2007-12-11 23:04:48 UTC (rev 23117) +++ haiku/trunk/headers/private/kernel/arch/x86/smp_acpi.h 2007-12-12 18:39:41 UTC (rev 23118) @@ -9,6 +9,8 @@ #define ACPI_RSDT_SIGNATURE "RSDT" #define ACPI_MADT_SIGNATURE "APIC" +#define ACPI_LOCAL_APIC_ENABLED 0x01 + struct acpi_rsdp { char signature[8]; /* "RSD PTR " including blank */ uint8 checksum; /* checksum of bytes 0-19 (per ACPI 1.0) */ Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-11 23:04:48 UTC (rev 23117) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-12 18:39:41 UTC (rev 23118) @@ -280,6 +280,11 @@ acpi_local_apic *localApic = (acpi_local_apic *)apic; TRACE(("smp: found local APIC with id %u\n", localApic->apic_id)); + if ((localApic->flags & ACPI_LOCAL_APIC_ENABLED) == 0) { + TRACE(("smp: APIC is disabled and will not be used\n")); + break; + } + gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = localApic->apic_id; gKernelArgs.arch_args.cpu_os_id[localApic->apic_id] = gKernelArgs.num_cpus; // ToDo: how to find out? putting 0x10 in to indicate a local apic From revol at free.fr Wed Dec 12 21:47:34 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 12 Dec 2007 21:47:34 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23118_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/private/kernel/arch/x86__src/system/boot/platform/bio?= =?windows-1252?q?s=5Fia32?= In-Reply-To: <200712121839.lBCIdfnL020637@sheep.berlios.de> Message-ID: <638833592-BeMail@laptop> > Ignore disabled local APICs. Talking about APIC, I'll add a boot setting to disable APICs (at least apic timer), to see if I can get my asus laptop cold boot with the regular timer and the same hack that was required in zeta. Haiku used to warm boot until apic timers got used... The hack requires forcing the trigger type (to level IIRC) to get clock IRQs from the buggy ATI IXP chipset. It works if I disable the APIC timer but seems to be required for it as well, but in that case the edge/level registers are elsewhere (and they aren't dealt with yet). I thought there was such an option but maybe it was only in zeta. I'll have to add a kernel setting to enable the hack as well (or install it when a flag is set from the pci enumeration when the chipset is seen maybe... that'd be better). Fran?ois. From axeld at pinc-software.de Wed Dec 12 22:33:09 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Wed, 12 Dec 2007 22:33:09 +0100 CET Subject: [Haiku-commits] r23117 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel headers/private/kernel/arch/x86 src/system/kernel src/system/kernel/arch/x86 src/system/libroot/os src/system/libroot/os/arch/x86 In-Reply-To: <289686607-BeMail@laptop> Message-ID: <44236818243-BeMail@zon> "Fran?ois Revol" wrote: > > "Fran?ois Revol" wrote: > > > System time stuff OTH will be tricky to do (no RDTSC like stuff). > > But usually these old systems had dedicated timer processors, so > > that > > shouldn't be much of a problem (just lots of work :-)). > Most use an MFP or similar chip yes, wich provide like 3 or 4 timers, > which can be read, but they are 8 bit or at best 16. > Implementing system_time without an atomic monotonic clocked counter > will likely add quite some overhead. Linux is still doing this via timer interrupts (if the tickless patch is not applied) either. Also, I think at least the Amiga has a monoton increasing timer with a better resolution. Don't remember, and I'm too lazy to look it up in my copy of the Amiga Hardware Reference Manual :- ) Bye, Axel. From stippi at mail.berlios.de Wed Dec 12 22:55:41 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 12 Dec 2007 22:55:41 +0100 Subject: [Haiku-commits] r23119 - haiku/trunk/src/add-ons/input_server/devices/mouse Message-ID: <200712122155.lBCLtfY7032705@sheep.berlios.de> Author: stippi Date: 2007-12-12 22:55:40 +0100 (Wed, 12 Dec 2007) New Revision: 23119 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23119&view=rev Modified: haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp Log: * I think I needed this change to compile this for ZETA Modified: haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp =================================================================== --- haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp 2007-12-12 18:39:41 UTC (rev 23118) +++ haiku/trunk/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp 2007-12-12 21:55:40 UTC (rev 23119) @@ -365,7 +365,7 @@ uint32 newButtons = 0; for (int32 i = 0; buttons; i++) { if (buttons & 0x1) { -#ifdef HAIKU_TARGET_PLATFORM_HAIKU +#if defined(HAIKU_TARGET_PLATFORM_HAIKU) || defined(HAIKU_TARGET_PLATFORM_DANO) newButtons |= fSettings.map.button[i]; #else if (i == 0) From axeld at mail.berlios.de Thu Dec 13 15:56:29 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 13 Dec 2007 15:56:29 +0100 Subject: [Haiku-commits] r23120 - in haiku/trunk: headers/private/graphics/intel_extreme src/add-ons/accelerants/intel_extreme Message-ID: <200712131456.lBDEuTvj021820@sheep.berlios.de> Author: axeld Date: 2007-12-13 15:56:28 +0100 (Thu, 13 Dec 2007) New Revision: 23120 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23120&view=rev Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h haiku/trunk/src/add-ons/accelerants/intel_extreme/commands.h haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp Log: * Made QueueCommands::Write() and MakeSpace() public. * Implemented MakeSpace() (not yet tested). * Changed intel_wait_engine_idle() to spin() between reads and to timeout after 1 second of waiting (could probably be done way earlier). Modified: haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h =================================================================== --- haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-12-12 21:55:40 UTC (rev 23119) +++ haiku/trunk/headers/private/graphics/intel_extreme/intel_extreme.h 2007-12-13 14:56:28 UTC (rev 23120) @@ -49,6 +49,7 @@ uint32 offset; uint32 size; uint32 position; + uint32 space_left; uint8 *base; }; Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/commands.h =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/commands.h 2007-12-12 21:55:40 UTC (rev 23119) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/commands.h 2007-12-13 14:56:28 UTC (rev 23120) @@ -28,10 +28,10 @@ void PutWaitFor(uint32 event); void PutOverlayFlip(uint32 code, bool updateCoefficients); + void MakeSpace(uint32 size); + void Write(uint32 data); + private: - void _MakeSpace(uint32 size); - void _Write(uint32 data); - ring_buffer &fRingBuffer; }; Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-12 21:55:40 UTC (rev 23119) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-13 14:56:28 UTC (rev 23120) @@ -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: @@ -7,11 +7,14 @@ */ +#include + #include "accelerant.h" #include "accelerant_protos.h" #include "commands.h" +#undef TRACE //#define TRACE_ENGINE #ifdef TRACE_ENGINE extern "C" void _sPrintf(const char *format, ...); @@ -36,7 +39,7 @@ { if (fRingBuffer.position & 0x07) { // make sure the command is properly aligned - _Write(COMMAND_NOOP); + Write(COMMAND_NOOP); } // We must make sure memory is written back in case the ring buffer @@ -58,10 +61,10 @@ uint32 count = size / sizeof(uint32); uint32 *data = command.Data(); - _MakeSpace(count); + MakeSpace(count); for (uint32 i = 0; i < count; i++) { - _Write(data[i]); + Write(data[i]); } } @@ -69,48 +72,66 @@ void QueueCommands::PutFlush() { - _MakeSpace(2); + MakeSpace(2); - _Write(COMMAND_FLUSH); - _Write(COMMAND_NOOP); + Write(COMMAND_FLUSH); + Write(COMMAND_NOOP); } void QueueCommands::PutWaitFor(uint32 event) { - _MakeSpace(2); + MakeSpace(2); - _Write(COMMAND_WAIT_FOR_EVENT | event); - _Write(COMMAND_NOOP); + Write(COMMAND_WAIT_FOR_EVENT | event); + Write(COMMAND_NOOP); } void QueueCommands::PutOverlayFlip(uint32 mode, bool updateCoefficients) { - _MakeSpace(2); + MakeSpace(2); - _Write(COMMAND_OVERLAY_FLIP | mode); - _Write((uint32)gInfo->shared_info->physical_overlay_registers + Write(COMMAND_OVERLAY_FLIP | mode); + Write((uint32)gInfo->shared_info->physical_overlay_registers | (updateCoefficients ? OVERLAY_UPDATE_COEFFICIENTS : 0)); } void -QueueCommands::_MakeSpace(uint32 size) +QueueCommands::MakeSpace(uint32 size) { - // TODO: make sure there is enough room to write the command! + ASSERT((size & 1) == 0); + size *= sizeof(uint32); + + while (fRingBuffer.space_left < size) { + // wait until more space is free + uint32 head = read32(fRingBuffer.register_base + RING_BUFFER_HEAD) + & INTEL_RING_BUFFER_HEAD_MASK; + + if (head < fRingBuffer.position) + head += fRingBuffer.size; + + fRingBuffer.space_left = head - fRingBuffer.position; + + if (fRingBuffer.space_left < size) + spin(10); + } + + fRingBuffer.space_left -= size; } void -QueueCommands::_Write(uint32 data) +QueueCommands::Write(uint32 data) { uint32 *target = (uint32 *)(fRingBuffer.base + fRingBuffer.position); *target = data; - fRingBuffer.position = (fRingBuffer.position + sizeof(uint32)) & (fRingBuffer.size - 1); + fRingBuffer.position = (fRingBuffer.position + sizeof(uint32)) + & (fRingBuffer.size - 1); } @@ -128,8 +149,8 @@ void setup_ring_buffer(ring_buffer &ringBuffer, const char *name) { - TRACE(("Setup ring buffer %s, offset %lx, size %lx\n", name, ringBuffer.offset, - ringBuffer.size)); + TRACE(("Setup ring buffer %s, offset %lx, size %lx\n", name, + ringBuffer.offset, ringBuffer.size)); if (init_lock(&ringBuffer.lock, name) < B_OK) { // disable ring buffer @@ -138,6 +159,9 @@ } uint32 ring = ringBuffer.register_base; + ringBuffer.position = 0; + ringBuffer.space_left = ringBuffer.size; + write32(ring + RING_BUFFER_TAIL, 0); write32(ring + RING_BUFFER_START, ringBuffer.offset); write32(ring + RING_BUFFER_CONTROL, @@ -149,8 +173,7 @@ // #pragma mark - engine management -/** Return number of hardware engines */ - +/*! Return number of hardware engines */ uint32 intel_accelerant_engine_count(void) { @@ -202,15 +225,27 @@ // a better way to do this would be to acquire the engine's lock and // sync to the latest token + bigtime_t start = system_time(); + ring_buffer &ring = gInfo->shared_info->primary_ring_buffer; uint32 head, tail; - do { - head = read32(ring.register_base + RING_BUFFER_HEAD) & INTEL_RING_BUFFER_HEAD_MASK; - tail = read32(ring.register_base + RING_BUFFER_TAIL) & INTEL_RING_BUFFER_HEAD_MASK; + while (true) { + head = read32(ring.register_base + RING_BUFFER_HEAD) + & INTEL_RING_BUFFER_HEAD_MASK; + tail = read32(ring.register_base + RING_BUFFER_TAIL) + & INTEL_RING_BUFFER_HEAD_MASK; - //snooze(100); - // Isn't a snooze() a bit too slow? At least it's called *very* often in Haiku... - } while (head != tail); + if (head == tail) + break; + + if (system_time() > start + 1000000LL) { + // the engine seems to be locked up! + TRACE(("intel_extreme: engine locked up!\n")); + break; + } + + spin(10); + } } @@ -235,7 +270,8 @@ void -intel_screen_to_screen_blit(engine_token *token, blit_params *params, uint32 count) +intel_screen_to_screen_blit(engine_token *token, blit_params *params, + uint32 count) { QueueCommands queue(gInfo->shared_info->primary_ring_buffer); @@ -254,8 +290,8 @@ void -intel_fill_rectangle(engine_token *token, uint32 color, fill_rect_params *params, - uint32 count) +intel_fill_rectangle(engine_token *token, uint32 color, + fill_rect_params *params, uint32 count) { QueueCommands queue(gInfo->shared_info->primary_ring_buffer); @@ -273,7 +309,8 @@ void -intel_invert_rectangle(engine_token *token, fill_rect_params *params, uint32 count) +intel_invert_rectangle(engine_token *token, fill_rect_params *params, + uint32 count) { QueueCommands queue(gInfo->shared_info->primary_ring_buffer); @@ -291,7 +328,8 @@ void -intel_fill_span(engine_token *token, uint32 color, uint16* _params, uint32 count) +intel_fill_span(engine_token *token, uint32 color, uint16* _params, + uint32 count) { struct params { uint16 top; From axeld at mail.berlios.de Thu Dec 13 16:44:41 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 13 Dec 2007 16:44:41 +0100 Subject: [Haiku-commits] r23121 - haiku/trunk/src/add-ons/accelerants/intel_extreme Message-ID: <200712131544.lBDFifZt025356@sheep.berlios.de> Author: axeld Date: 2007-12-13 16:44:41 +0100 (Thu, 13 Dec 2007) New Revision: 23121 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23121&view=rev Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp Log: Added the timeout to QueueCommand::MakeSpace() as well. Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-13 14:56:28 UTC (rev 23120) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-13 15:44:41 UTC (rev 23121) @@ -105,6 +105,7 @@ { ASSERT((size & 1) == 0); size *= sizeof(uint32); + bigtime_t start = system_time(); while (fRingBuffer.space_left < size) { // wait until more space is free @@ -116,8 +117,13 @@ fRingBuffer.space_left = head - fRingBuffer.position; - if (fRingBuffer.space_left < size) + if (fRingBuffer.space_left < size) { + if (system_time() > start + 1000000LL) { + TRACE(("intel_extreme: engine stalled\n")); + break; + } spin(10); + } } fRingBuffer.space_left -= size; From axeld at mail.berlios.de Thu Dec 13 20:27:06 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 13 Dec 2007 20:27:06 +0100 Subject: [Haiku-commits] r23122 - haiku/trunk/src/add-ons/accelerants/intel_extreme Message-ID: <200712131927.lBDJR66L023654@sheep.berlios.de> Author: axeld Date: 2007-12-13 20:27:05 +0100 (Thu, 13 Dec 2007) New Revision: 23122 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23122&view=rev Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp Log: There was no space when the buffer was completely empty... Modified: haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp =================================================================== --- haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-13 15:44:41 UTC (rev 23121) +++ haiku/trunk/src/add-ons/accelerants/intel_extreme/engine.cpp 2007-12-13 19:27:05 UTC (rev 23122) @@ -112,7 +112,7 @@ uint32 head = read32(fRingBuffer.register_base + RING_BUFFER_HEAD) & INTEL_RING_BUFFER_HEAD_MASK; - if (head < fRingBuffer.position) + if (head <= fRingBuffer.position) head += fRingBuffer.size; fRingBuffer.space_left = head - fRingBuffer.position; From mmu_man at mail.berlios.de Fri Dec 14 22:21:55 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 14 Dec 2007 22:21:55 +0100 Subject: [Haiku-commits] r23123 - haiku/trunk/build/jam Message-ID: <200712142121.lBELLtb3026769@sheep.berlios.de> Author: mmu_man Date: 2007-12-14 22:21:55 +0100 (Fri, 14 Dec 2007) New Revision: 23123 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23123&view=rev Modified: haiku/trunk/build/jam/FileRules Log: Use LC_ALL=C to really make sure the locale isn't used on svn info. Modified: haiku/trunk/build/jam/FileRules =================================================================== --- haiku/trunk/build/jam/FileRules 2007-12-13 19:27:05 UTC (rev 23122) +++ haiku/trunk/build/jam/FileRules 2007-12-14 21:21:55 UTC (rev 23123) @@ -247,7 +247,7 @@ actions CopySetHaikuRevision1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) - revision=`(LANG=C svn info $(HAIKU_TOP) 2> /dev/null || echo Revision: 0) | + revision=`(LC_ALL=C LANG=C svn info $(HAIKU_TOP) 2> /dev/null || echo Revision: 0) | grep Revision | awk '{printf $2}'` $(2[1]) --data $(2[3]) $(1) && $(2[2]) $(1) ${revision} From axeld at mail.berlios.de Sun Dec 16 11:56:40 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 16 Dec 2007 11:56:40 +0100 Subject: [Haiku-commits] r23124 - in haiku/trunk/src/add-ons/kernel/drivers/network: . broadcom_bcm570x broadcom_bcm570x/dev broadcom_bcm570x/dev/bge broadcom_bcm570x/dev/mii nforce nforce/dev nforce/dev/mii nforce/dev/nfe Message-ID: <200712161056.lBGAue1N029576@sheep.berlios.de> Author: axeld Date: 2007-12-16 11:56:30 +0100 (Sun, 16 Dec 2007) New Revision: 23124 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23124&view=rev Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bge.c haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bgereg.h haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/brgphyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/mii/ukphy_subr.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/ haiku/trunk/src/add-ons/kernel/drivers/network/nforce/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/ haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/ haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/ciphy.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/ciphyreg.h haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/miidevs.h haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/ukphy.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/mii/ukphy_subr.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/ haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/Jamfile haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/glue.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/if_nfe.c haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/if_nfereg.h haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/if_nfevar.h Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile Log: * Added Broadcom BCM570x driver from FreeBSD (bge). Does not compile yet, needs a bit more work on the compatibility layer. * Added nVidia nForce MCP driver (nfe) from FreeBSD. Compiles and might even work - please test. It would also be nice to know if your PHY is detected correctly (see syslog output). Modified: haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/Jamfile 2007-12-16 10:56:30 UTC (rev 23124) @@ -12,10 +12,12 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network vlance ; SubInclude HAIKU_TOP src add-ons kernel drivers network wb840 ; -# FreeBSD 6.2 drivers +# FreeBSD 7 drivers SubInclude HAIKU_TOP src add-ons kernel drivers network 3com ; +SubInclude HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x ; SubInclude HAIKU_TOP src add-ons kernel drivers network ipro100 ; SubInclude HAIKU_TOP src add-ons kernel drivers network marvell_yukon ; +SubInclude HAIKU_TOP src add-ons kernel drivers network nforce ; SubInclude HAIKU_TOP src add-ons kernel drivers network pcnet ; SubIncludeGPL HAIKU_TOP src add-ons kernel drivers network bcm440x ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/Jamfile 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/Jamfile 2007-12-16 10:56:30 UTC (rev 23124) @@ -0,0 +1,3 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x ; + +SubInclude HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x dev ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/Jamfile 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/Jamfile 2007-12-16 10:56:30 UTC (rev 23124) @@ -0,0 +1,4 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x dev ; + +SubInclude HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x dev bge ; +SubInclude HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x dev mii ; Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/Jamfile =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/Jamfile 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/Jamfile 2007-12-16 10:56:30 UTC (rev 23124) @@ -0,0 +1,18 @@ +SubDir HAIKU_TOP src add-ons kernel drivers network broadcom_bcm570x dev bge ; + +SubDirCcFlags -Wall ; + +UsePrivateHeaders kernel net ; + +UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ; +UseHeaders [ FDirName $(SUBDIR) .. mii ] : true ; +UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ; + +SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ; + +KernelAddon broadcom_bcm570x : + if_bge.c + glue.c + : libfreebsd_network.a broadcom_bcm570x_mii.a + ; + Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/glue.c 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/glue.c 2007-12-16 10:56:30 UTC (rev 23124) @@ -0,0 +1,27 @@ +/* + * Copyright 2007, Axel D?rfler, axeld at pinc-software.de. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ + + +#include + + +HAIKU_FBSD_DRIVER_GLUE(broadcom_bcm570x, bge, pci); +HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_SWI_TASKQUEUE); + + +extern driver_t *DRIVER_MODULE_NAME(ukphy, miibus); + + +driver_t * +__haiku_select_miibus_driver(device_t dev) +{ + driver_t *drivers[] = { + DRIVER_MODULE_NAME(ukphy, miibus), + NULL + }; + + return __haiku_probe_miibus(dev, drivers); +} + Added: haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bge.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bge.c 2007-12-14 21:21:55 UTC (rev 23123) +++ haiku/trunk/src/add-ons/kernel/drivers/network/broadcom_bcm570x/dev/bge/if_bge.c 2007-12-16 10:56:30 UTC (rev 23124) @@ -0,0 +1,4539 @@ +/*- + * Copyright (c) 2001 Wind River Systems + * Copyright (c) 1997, 1998, 1999, 2001 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/bge/if_bge.c,v 1.198 2007/09/30 11:05:14 marius Exp $"); + +/* + * Broadcom BCM570x family gigabit ethernet driver for FreeBSD. + * + * The Broadcom BCM5700 is based on technology originally developed by + * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet + * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has + * two on-board MIPS R4000 CPUs and can have as much as 16MB of external + * SSRAM. The BCM5700 supports TCP, UDP and IP checksum offload, jumbo + * frames, highly configurable RX filtering, and 16 RX and TX queues + * (which, along with RX filter rules, can be used for QOS applications). + * Other features, such as TCP segmentation, may be available as part + * of value-added firmware updates. Unlike the Tigon I and Tigon II, + * firmware images can be stored in hardware and need not be compiled + * into the driver. + * + * The BCM5700 supports the PCI v2.2 and PCI-X v1.0 standards, and will + * function in a 32-bit/64-bit 33/66Mhz bus, or a 64-bit/133Mhz bus. + * + * The BCM5701 is a single-chip solution incorporating both the BCM5700 + * MAC and a BCM5401 10/100/1000 PHY. Unlike the BCM5700, the BCM5701 + * does not support external SSRAM. + * + * Broadcom also produces a variation of the BCM5700 under the "Altima" + * brand name, which is functionally similar but lacks PCI-X support. + * + * Without external SSRAM, you can only have at most 4 TX rings, + * and the use of the mini RX ring is disabled. This seems to imply + * that these features are simply not available on the BCM5701. As a + * result, this driver does not implement any support for the mini RX + * ring. + */ + +#ifdef HAVE_KERNEL_OPTION_HEADERS +#include "opt_device_polling.h" +#endif + +#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 "miidevs.h" +#include + +#ifdef __sparc64__ +#include +#include +#include +#include +#endif + +#include +#include + +#include + +#define BGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) +#define ETHER_MIN_NOPAD (ETHER_MIN_LEN - ETHER_CRC_LEN) /* i.e., 60 */ + +MODULE_DEPEND(bge, pci, 1, 1, 1); +MODULE_DEPEND(bge, ether, 1, 1, 1); +MODULE_DEPEND(bge, miibus, 1, 1, 1); + +/* "device miibus" required. See GENERIC if you get errors here. */ +#include "miibus_if.h" + +/* + * Various supported device vendors/types and their names. Note: the + * spec seems to indicate that the hardware still has Alteon's vendor + * ID burned into it, though it will always be overriden by the vendor + * ID in the EEPROM. Just to be safe, we cover all possibilities. + */ +static struct bge_type { + uint16_t bge_vid; + uint16_t bge_did; +} bge_devs[] = { + { ALTEON_VENDORID, ALTEON_DEVICEID_BCM5700 }, + { ALTEON_VENDORID, ALTEON_DEVICEID_BCM5701 }, + + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC1000 }, + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC1002 }, + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC9100 }, + + { APPLE_VENDORID, APPLE_DEVICE_BCM5701 }, + + { BCOM_VENDORID, BCOM_DEVICEID_BCM5700 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5701 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702X }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703X }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704C }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705K }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5714C }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5714S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5715 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5715S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5720 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5721 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5750 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5750M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5752 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5752M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5754 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5754M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5755 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5755M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5780 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5780S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5781 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5782 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5786 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5787 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5787M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5788 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5789 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5901 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5901A2 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5903M }, + + { SK_VENDORID, SK_DEVICEID_ALTIMA }, + + { TC_VENDORID, TC_DEVICEID_3C996 }, + + { 0, 0 } +}; + +static const struct bge_vendor { + uint16_t v_id; + const char *v_name; +} bge_vendors[] = { + { ALTEON_VENDORID, "Alteon" }, + { ALTIMA_VENDORID, "Altima" }, + { APPLE_VENDORID, "Apple" }, + { BCOM_VENDORID, "Broadcom" }, + { SK_VENDORID, "SysKonnect" }, + { TC_VENDORID, "3Com" }, + + { 0, NULL } +}; + +static const struct bge_revision { + uint32_t br_chipid; + const char *br_name; +} bge_revisions[] = { + { BGE_CHIPID_BCM5700_A0, "BCM5700 A0" }, + { BGE_CHIPID_BCM5700_A1, "BCM5700 A1" }, + { BGE_CHIPID_BCM5700_B0, "BCM5700 B0" }, + { BGE_CHIPID_BCM5700_B1, "BCM5700 B1" }, + { BGE_CHIPID_BCM5700_B2, "BCM5700 B2" }, + { BGE_CHIPID_BCM5700_B3, "BCM5700 B3" }, + { BGE_CHIPID_BCM5700_ALTIMA, "BCM5700 Altima" }, + { BGE_CHIPID_BCM5700_C0, "BCM5700 C0" }, + { BGE_CHIPID_BCM5701_A0, "BCM5701 A0" }, + { BGE_CHIPID_BCM5701_B0, "BCM5701 B0" }, + { BGE_CHIPID_BCM5701_B2, "BCM5701 B2" }, + { BGE_CHIPID_BCM5701_B5, "BCM5701 B5" }, + { BGE_CHIPID_BCM5703_A0, "BCM5703 A0" }, + { BGE_CHIPID_BCM5703_A1, "BCM5703 A1" }, + { BGE_CHIPID_BCM5703_A2, "BCM5703 A2" }, + { BGE_CHIPID_BCM5703_A3, "BCM5703 A3" }, + { BGE_CHIPID_BCM5703_B0, "BCM5703 B0" }, + { BGE_CHIPID_BCM5704_A0, "BCM5704 A0" }, + { BGE_CHIPID_BCM5704_A1, "BCM5704 A1" }, + { BGE_CHIPID_BCM5704_A2, "BCM5704 A2" }, + { BGE_CHIPID_BCM5704_A3, "BCM5704 A3" }, + { BGE_CHIPID_BCM5704_B0, "BCM5704 B0" }, + { BGE_CHIPID_BCM5705_A0, "BCM5705 A0" }, + { BGE_CHIPID_BCM5705_A1, "BCM5705 A1" }, + { BGE_CHIPID_BCM5705_A2, "BCM5705 A2" }, + { BGE_CHIPID_BCM5705_A3, "BCM5705 A3" }, + { BGE_CHIPID_BCM5750_A0, "BCM5750 A0" }, + { BGE_CHIPID_BCM5750_A1, "BCM5750 A1" }, + { BGE_CHIPID_BCM5750_A3, "BCM5750 A3" }, + { BGE_CHIPID_BCM5750_B0, "BCM5750 B0" }, + { BGE_CHIPID_BCM5750_B1, "BCM5750 B1" }, + { BGE_CHIPID_BCM5750_C0, "BCM5750 C0" }, + { BGE_CHIPID_BCM5750_C1, "BCM5750 C1" }, + { BGE_CHIPID_BCM5750_C2, "BCM5750 C2" }, + { BGE_CHIPID_BCM5714_A0, "BCM5714 A0" }, + { BGE_CHIPID_BCM5752_A0, "BCM5752 A0" }, + { BGE_CHIPID_BCM5752_A1, "BCM5752 A1" }, + { BGE_CHIPID_BCM5752_A2, "BCM5752 A2" }, + { BGE_CHIPID_BCM5714_B0, "BCM5714 B0" }, + { BGE_CHIPID_BCM5714_B3, "BCM5714 B3" }, + { BGE_CHIPID_BCM5715_A0, "BCM5715 A0" }, + { BGE_CHIPID_BCM5715_A1, "BCM5715 A1" }, + { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, + { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, + { BGE_CHIPID_BCM5755_A1, "BCM5755 A1" }, + { BGE_CHIPID_BCM5755_A2, "BCM5755 A2" }, + /* 5754 and 5787 share the same ASIC ID */ + { BGE_CHIPID_BCM5787_A0, "BCM5754/5787 A0" }, + { BGE_CHIPID_BCM5787_A1, "BCM5754/5787 A1" }, + { BGE_CHIPID_BCM5787_A2, "BCM5754/5787 A2" }, + + { 0, NULL } +}; + +/* + * Some defaults for major revisions, so that newer steppings + * that we don't know about have a shot at working. + */ +static const struct bge_revision bge_majorrevs[] = { + { BGE_ASICREV_BCM5700, "unknown BCM5700" }, + { BGE_ASICREV_BCM5701, "unknown BCM5701" }, + { BGE_ASICREV_BCM5703, "unknown BCM5703" }, + { BGE_ASICREV_BCM5704, "unknown BCM5704" }, + { BGE_ASICREV_BCM5705, "unknown BCM5705" }, + { BGE_ASICREV_BCM5750, "unknown BCM5750" }, + { BGE_ASICREV_BCM5714_A0, "unknown BCM5714" }, + { BGE_ASICREV_BCM5752, "unknown BCM5752" }, + { BGE_ASICREV_BCM5780, "unknown BCM5780" }, + { BGE_ASICREV_BCM5714, "unknown BCM5714" }, + { BGE_ASICREV_BCM5755, "unknown BCM5755" }, + /* 5754 and 5787 share the same ASIC ID */ + { BGE_ASICREV_BCM5787, "unknown BCM5754/5787" }, + + { 0, NULL } +}; + +#define BGE_IS_JUMBO_CAPABLE(sc) ((sc)->bge_flags & BGE_FLAG_JUMBO) +#define BGE_IS_5700_FAMILY(sc) ((sc)->bge_flags & BGE_FLAG_5700_FAMILY) +#define BGE_IS_5705_PLUS(sc) ((sc)->bge_flags & BGE_FLAG_5705_PLUS) +#define BGE_IS_5714_FAMILY(sc) ((sc)->bge_flags & BGE_FLAG_5714_FAMILY) +#define BGE_IS_575X_PLUS(sc) ((sc)->bge_flags & BGE_FLAG_575X_PLUS) + +const struct bge_revision * bge_lookup_rev(uint32_t); +const struct bge_vendor * bge_lookup_vendor(uint16_t); +static int bge_probe(device_t); +static int bge_attach(device_t); +static int bge_detach(device_t); +static int bge_suspend(device_t); +static int bge_resume(device_t); +static void bge_release_resources(struct bge_softc *); +static void bge_dma_map_addr(void *, bus_dma_segment_t *, int, int); +static int bge_dma_alloc(device_t); +static void bge_dma_free(struct bge_softc *); + +static void bge_txeof(struct bge_softc *); +static void bge_rxeof(struct bge_softc *); + +static void bge_asf_driver_up (struct bge_softc *); +static void bge_tick(void *); +static void bge_stats_update(struct bge_softc *); +static void bge_stats_update_regs(struct bge_softc *); +static int bge_encap(struct bge_softc *, struct mbuf **, uint32_t *); + +static void bge_intr(void *); +static void bge_start_locked(struct ifnet *); +static void bge_start(struct ifnet *); +static int bge_ioctl(struct ifnet *, u_long, caddr_t); +static void bge_init_locked(struct bge_softc *); +static void bge_init(void *); +static void bge_stop(struct bge_softc *); +static void bge_watchdog(struct bge_softc *); +static void bge_shutdown(device_t); +static int bge_ifmedia_upd_locked(struct ifnet *); +static int bge_ifmedia_upd(struct ifnet *); +static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *); + +static uint8_t bge_eeprom_getbyte(struct bge_softc *, int, uint8_t *); +static int bge_read_eeprom(struct bge_softc *, caddr_t, int, int); + +static void bge_setpromisc(struct bge_softc *); +static void bge_setmulti(struct bge_softc *); +static void bge_setvlan(struct bge_softc *); + +static int bge_newbuf_std(struct bge_softc *, int, struct mbuf *); +static int bge_newbuf_jumbo(struct bge_softc *, int, struct mbuf *); +static int bge_init_rx_ring_std(struct bge_softc *); +static void bge_free_rx_ring_std(struct bge_softc *); +static int bge_init_rx_ring_jumbo(struct bge_softc *); +static void bge_free_rx_ring_jumbo(struct bge_softc *); +static void bge_free_tx_ring(struct bge_softc *); +static int bge_init_tx_ring(struct bge_softc *); + +static int bge_chipinit(struct bge_softc *); +static int bge_blockinit(struct bge_softc *); + +static int bge_has_eeprom(struct bge_softc *); +static uint32_t bge_readmem_ind(struct bge_softc *, int); +static void bge_writemem_ind(struct bge_softc *, int, int); +#ifdef notdef +static uint32_t bge_readreg_ind(struct bge_softc *, int); +#endif +static void bge_writemem_direct(struct bge_softc *, int, int); +static void bge_writereg_ind(struct bge_softc *, int, int); + +static int bge_miibus_readreg(device_t, int, int); +static int bge_miibus_writereg(device_t, int, int, int); +static void bge_miibus_statchg(device_t); +#ifdef DEVICE_POLLING +static void bge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count); +#endif + +#define BGE_RESET_START 1 +#define BGE_RESET_STOP 2 +static void bge_sig_post_reset(struct bge_softc *, int); +static void bge_sig_legacy(struct bge_softc *, int); +static void bge_sig_pre_reset(struct bge_softc *, int); +static int bge_reset(struct bge_softc *); +static void bge_link_upd(struct bge_softc *); + +/* + * The BGE_REGISTER_DEBUG option is only for low-level debugging. It may + * leak information to untrusted users. It is also known to cause alignment + * traps on certain architectures. + */ +#ifdef BGE_REGISTER_DEBUG +static int bge_sysctl_debug_info(SYSCTL_HANDLER_ARGS); +static int bge_sysctl_reg_read(SYSCTL_HANDLER_ARGS); +static int bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS); +#endif +static void bge_add_sysctls(struct bge_softc *); +static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS); + +static device_method_t bge_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, bge_probe), + DEVMETHOD(device_attach, bge_attach), + DEVMETHOD(device_detach, bge_detach), + DEVMETHOD(device_shutdown, bge_shutdown), + DEVMETHOD(device_suspend, bge_suspend), + DEVMETHOD(device_resume, bge_resume), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* MII interface */ + DEVMETHOD(miibus_readreg, bge_miibus_readreg), + DEVMETHOD(miibus_writereg, bge_miibus_writereg), + DEVMETHOD(miibus_statchg, bge_miibus_statchg), + + { 0, 0 } +}; + +static driver_t bge_driver = { + "bge", + bge_methods, + sizeof(struct bge_softc) +}; + +static devclass_t bge_devclass; + +DRIVER_MODULE(bge, pci, bge_driver, bge_devclass, 0, 0); +DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0); + +static int bge_allow_asf = 1; + +TUNABLE_INT("hw.bge.allow_asf", &bge_allow_asf); + +SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); +SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RD, &bge_allow_asf, 0, + "Allow ASF mode if available"); + +#define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" +#define SPARC64_BLADE_1500_PATH_BGE "/pci at 1f,700000/network at 2" +#define SPARC64_BLADE_2500_MODEL "SUNW,Sun-Blade-2500" +#define SPARC64_BLADE_2500_PATH_BGE "/pci at 1c,600000/network at 3" +#define SPARC64_OFW_SUBVENDOR "subsystem-vendor-id" + +static int +bge_has_eeprom(struct bge_softc *sc) +{ +#ifdef __sparc64__ + char buf[sizeof(SPARC64_BLADE_1500_PATH_BGE)]; + device_t dev; + uint32_t subvendor; + + dev = sc->bge_dev; + + /* + * The on-board BGEs found in sun4u machines aren't fitted with + * an EEPROM which means that we have to obtain the MAC address + * via OFW and that some tests will always fail. We distinguish + * such BGEs by the subvendor ID, which also has to be obtained + * from OFW instead of the PCI configuration space as the latter + * indicates Broadcom as the subvendor of the netboot interface. + * For early Blade 1500 and 2500 we even have to check the OFW + * device path as the subvendor ID always defaults to Broadcom + * there. + */ + if (OF_getprop(ofw_bus_get_node(dev), SPARC64_OFW_SUBVENDOR, + &subvendor, sizeof(subvendor)) == sizeof(subvendor) && + subvendor == SUN_VENDORID) + return (0); + memset(buf, 0, sizeof(buf)); + if (OF_package_to_path(ofw_bus_get_node(dev), buf, sizeof(buf)) > 0) { + if (strcmp(sparc64_model, SPARC64_BLADE_1500_MODEL) == 0 && + strcmp(buf, SPARC64_BLADE_1500_PATH_BGE) == 0) + return (0); + if (strcmp(sparc64_model, SPARC64_BLADE_2500_MODEL) == 0 && + strcmp(buf, SPARC64_BLADE_2500_PATH_BGE) == 0) + return (0); + } +#endif + return (1); +} + +static uint32_t +bge_readmem_ind(struct bge_softc *sc, int off) +{ + device_t dev; + uint32_t val; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); + val = pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4); + return (val); +} + +static void +bge_writemem_ind(struct bge_softc *sc, int off, int val) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_DATA, val, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4); +} + +#ifdef notdef +static uint32_t +bge_readreg_ind(struct bge_softc *sc, int off) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4); + return (pci_read_config(dev, BGE_PCI_REG_DATA, 4)); +} +#endif + +static void +bge_writereg_ind(struct bge_softc *sc, int off, int val) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4); + pci_write_config(dev, BGE_PCI_REG_DATA, val, 4); +} + +static void +bge_writemem_direct(struct bge_softc *sc, int off, int val) +{ + CSR_WRITE_4(sc, off, val); +} + +/* + * Map a single buffer address. + */ + +static void +bge_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) +{ + struct bge_dmamap_arg *ctx; + + if (error) + return; + + ctx = arg; + + if (nseg > ctx->bge_maxsegs) { + ctx->bge_maxsegs = 0; + return; + } + + ctx->bge_busaddr = segs->ds_addr; +} + +/* + * Read a byte of data stored in the EEPROM at address 'addr.' The + * BCM570x supports both the traditional bitbang interface and an + * auto access interface for reading the EEPROM. We use the auto + * access method. + */ +static uint8_t +bge_eeprom_getbyte(struct bge_softc *sc, int addr, uint8_t *dest) +{ + int i; + uint32_t byte = 0; + + /* + * Enable use of auto EEPROM access so we can avoid + * having to use the bitbang method. + */ + BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM); + + /* Reset the EEPROM, load the clock period. */ + CSR_WRITE_4(sc, BGE_EE_ADDR, + BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL)); + DELAY(20); + + /* Issue the read EEPROM command. */ + CSR_WRITE_4(sc, BGE_EE_ADDR, BGE_EE_READCMD | addr); + + /* Wait for completion */ + for(i = 0; i < BGE_TIMEOUT * 10; i++) { + DELAY(10); + if (CSR_READ_4(sc, BGE_EE_ADDR) & BGE_EEADDR_DONE) + break; + } + + if (i == BGE_TIMEOUT * 10) { + device_printf(sc->bge_dev, "EEPROM read timed out\n"); + return (1); + } + + /* Get result. */ + byte = CSR_READ_4(sc, BGE_EE_DATA); + + *dest = (byte >> ((addr % 4) * 8)) & 0xFF; + + return (0); +} + +/* + * Read a sequence of bytes from the EEPROM. + */ +static int +bge_read_eeprom(struct bge_softc *sc, caddr_t dest, int off, int cnt) +{ + int i, error = 0; + uint8_t byte = 0; + + for (i = 0; i < cnt; i++) { + error = bge_eeprom_getbyte(sc, off + i, &byte); + if (error) + break; + *(dest + i) = byte; + } + + return (error ? 1 : 0); +} + +static int +bge_miibus_readreg(device_t dev, int phy, int reg) +{ + struct bge_softc *sc; + uint32_t val, autopoll; + int i; + + sc = device_get_softc(dev); + + /* + * Broadcom's own driver always assumes the internal + * PHY is at GMII address 1. On some chips, the PHY responds + * to accesses at all addresses, which could cause us to + * bogusly attach the PHY 32 times at probe type. Always + * restricting the lookup to address 1 is simpler than + * trying to figure out which chips revisions should be + * special-cased. + */ + if (phy != 1) + return (0); + + /* Reading with autopolling on may trigger PCI errors */ + autopoll = CSR_READ_4(sc, BGE_MI_MODE); + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_READ | BGE_MICOMM_BUSY | + BGE_MIPHY(phy) | BGE_MIREG(reg)); + + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + val = CSR_READ_4(sc, BGE_MI_COMM); + if (!(val & BGE_MICOMM_BUSY)) + break; + } + + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "PHY read timed out\n"); + val = 0; + goto done; + } + + val = CSR_READ_4(sc, BGE_MI_COMM); + +done: + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + if (val & BGE_MICOMM_READFAIL) + return (0); + + return (val & 0xFFFF); +} + +static int +bge_miibus_writereg(device_t dev, int phy, int reg, int val) +{ + struct bge_softc *sc; + uint32_t autopoll; + int i; + + sc = device_get_softc(dev); + + /* Reading with autopolling on may trigger PCI errors */ + autopoll = CSR_READ_4(sc, BGE_MI_MODE); + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_WRITE | BGE_MICOMM_BUSY | + BGE_MIPHY(phy) | BGE_MIREG(reg) | val); + + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + if (!(CSR_READ_4(sc, BGE_MI_COMM) & BGE_MICOMM_BUSY)) + break; + } + + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "PHY write timed out\n"); + return (0); + } + + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + return (0); +} + +static void +bge_miibus_statchg(device_t dev) +{ + struct bge_softc *sc; + struct mii_data *mii; + sc = device_get_softc(dev); + mii = device_get_softc(sc->bge_miibus); + + BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE); + if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII); + else + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_MII); + + if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) + BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); + else + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); +} + +/* + * Intialize a standard receive ring descriptor. + */ +static int +bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m) +{ + struct mbuf *m_new = NULL; + struct bge_rx_bd *r; + struct bge_dmamap_arg ctx; + int error; + + if (m == NULL) { + m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m_new == NULL) + return (ENOBUFS); + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + } else { + m_new = m; + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + m_new->m_data = m_new->m_ext.ext_buf; + } + + if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0) + m_adj(m_new, ETHER_ALIGN); + sc->bge_cdata.bge_rx_std_chain[i] = m_new; + r = &sc->bge_ldata.bge_rx_std_ring[i]; + ctx.bge_maxsegs = 1; + ctx.sc = sc; + error = bus_dmamap_load(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i], mtod(m_new, void *), + m_new->m_len, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); + if (error || ctx.bge_maxsegs == 0) { + if (m == NULL) { + sc->bge_cdata.bge_rx_std_chain[i] = NULL; + m_freem(m_new); + } + return (ENOMEM); + } + r->bge_addr.bge_addr_lo = BGE_ADDR_LO(ctx.bge_busaddr); + r->bge_addr.bge_addr_hi = BGE_ADDR_HI(ctx.bge_busaddr); + r->bge_flags = BGE_RXBDFLAG_END; + r->bge_len = m_new->m_len; + r->bge_idx = i; + + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i], + BUS_DMASYNC_PREREAD); + + return (0); +} + +/* + * Initialize a jumbo receive ring descriptor. This allocates + * a jumbo buffer from the pool managed internally by the driver. + */ +static int +bge_newbuf_jumbo(struct bge_softc *sc, int i, struct mbuf *m) +{ + bus_dma_segment_t segs[BGE_NSEG_JUMBO]; + struct bge_extrx_bd *r; + struct mbuf *m_new = NULL; + int nsegs; + int error; + + if (m == NULL) { + MGETHDR(m_new, M_DONTWAIT, MT_DATA); + if (m_new == NULL) + return (ENOBUFS); + + m_cljget(m_new, M_DONTWAIT, MJUM9BYTES); + if (!(m_new->m_flags & M_EXT)) { + m_freem(m_new); + return (ENOBUFS); + } + m_new->m_len = m_new->m_pkthdr.len = MJUM9BYTES; + } else { + m_new = m; + m_new->m_len = m_new->m_pkthdr.len = MJUM9BYTES; + m_new->m_data = m_new->m_ext.ext_buf; + } + + if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0) + m_adj(m_new, ETHER_ALIGN); + + error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_mtag_jumbo, + sc->bge_cdata.bge_rx_jumbo_dmamap[i], + m_new, segs, &nsegs, BUS_DMA_NOWAIT); + if (error) { + if (m == NULL) + m_freem(m_new); + return (error); + } + sc->bge_cdata.bge_rx_jumbo_chain[i] = m_new; + + /* + * Fill in the extended RX buffer descriptor. + */ + r = &sc->bge_ldata.bge_rx_jumbo_ring[i]; + r->bge_flags = BGE_RXBDFLAG_JUMBO_RING | BGE_RXBDFLAG_END; + r->bge_idx = i; + r->bge_len3 = r->bge_len2 = r->bge_len1 = 0; + switch (nsegs) { + case 4: + r->bge_addr3.bge_addr_lo = BGE_ADDR_LO(segs[3].ds_addr); + r->bge_addr3.bge_addr_hi = BGE_ADDR_HI(segs[3].ds_addr); + r->bge_len3 = segs[3].ds_len; + case 3: + r->bge_addr2.bge_addr_lo = BGE_ADDR_LO(segs[2].ds_addr); + r->bge_addr2.bge_addr_hi = BGE_ADDR_HI(segs[2].ds_addr); + r->bge_len2 = segs[2].ds_len; + case 2: + r->bge_addr1.bge_addr_lo = BGE_ADDR_LO(segs[1].ds_addr); + r->bge_addr1.bge_addr_hi = BGE_ADDR_HI(segs[1].ds_addr); + r->bge_len1 = segs[1].ds_len; + case 1: + r->bge_addr0.bge_addr_lo = BGE_ADDR_LO(segs[0].ds_addr); + r->bge_addr0.bge_addr_hi = BGE_ADDR_HI(segs[0].ds_addr); + r->bge_len0 = segs[0].ds_len; + break; + default: + panic("%s: %d segments\n", __func__, nsegs); + } + + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_jumbo_dmamap[i], + BUS_DMASYNC_PREREAD); + + return (0); +} + +/* + * The standard receive ring has 512 entries in it. At 2K per mbuf cluster, + * that's 1MB or memory, which is a lot. For now, we fill only the first + * 256 ring entries and hope that our CPU is fast enough to keep up with + * the NIC. + */ +static int +bge_init_rx_ring_std(struct bge_softc *sc) +{ + int i; + + for (i = 0; i < BGE_SSLOTS; i++) { + if (bge_newbuf_std(sc, i, NULL) == ENOBUFS) + return (ENOBUFS); + }; + + bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag, + sc->bge_cdata.bge_rx_std_ring_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + sc->bge_std = i - 1; + CSR_WRITE_4(sc, BGE_MBX_RX_STD_PROD_LO, sc->bge_std); + + return (0); +} + +static void +bge_free_rx_ring_std(struct bge_softc *sc) +{ + int i; + + for (i = 0; i < BGE_STD_RX_RING_CNT; i++) { [... truncated: 11911 lines follow ...] From axeld at mail.berlios.de Sun Dec 16 12:00:35 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 16 Dec 2007 12:00:35 +0100 Subject: [Haiku-commits] r23125 - in haiku/vendor/freebsd/current/dev: . bge nfe Message-ID: <200712161100.lBGB0ZQd029754@sheep.berlios.de> Author: axeld Date: 2007-12-16 12:00:30 +0100 (Sun, 16 Dec 2007) New Revision: 23125 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23125&view=rev Added: haiku/vendor/freebsd/current/dev/bge/ haiku/vendor/freebsd/current/dev/bge/if_bge.c haiku/vendor/freebsd/current/dev/bge/if_bgereg.h haiku/vendor/freebsd/current/dev/nfe/ haiku/vendor/freebsd/current/dev/nfe/if_nfe.c haiku/vendor/freebsd/current/dev/nfe/if_nfereg.h haiku/vendor/freebsd/current/dev/nfe/if_nfevar.h Log: Added nfe and bge drivers to the FreeBSD vendor branch. Added: haiku/vendor/freebsd/current/dev/bge/if_bge.c =================================================================== --- haiku/vendor/freebsd/current/dev/bge/if_bge.c 2007-12-16 10:56:30 UTC (rev 23124) +++ haiku/vendor/freebsd/current/dev/bge/if_bge.c 2007-12-16 11:00:30 UTC (rev 23125) @@ -0,0 +1,4539 @@ +/*- + * Copyright (c) 2001 Wind River Systems + * Copyright (c) 1997, 1998, 1999, 2001 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD: src/sys/dev/bge/if_bge.c,v 1.198 2007/09/30 11:05:14 marius Exp $"); + +/* + * Broadcom BCM570x family gigabit ethernet driver for FreeBSD. + * + * The Broadcom BCM5700 is based on technology originally developed by + * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet + * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has + * two on-board MIPS R4000 CPUs and can have as much as 16MB of external + * SSRAM. The BCM5700 supports TCP, UDP and IP checksum offload, jumbo + * frames, highly configurable RX filtering, and 16 RX and TX queues + * (which, along with RX filter rules, can be used for QOS applications). + * Other features, such as TCP segmentation, may be available as part + * of value-added firmware updates. Unlike the Tigon I and Tigon II, + * firmware images can be stored in hardware and need not be compiled + * into the driver. + * + * The BCM5700 supports the PCI v2.2 and PCI-X v1.0 standards, and will + * function in a 32-bit/64-bit 33/66Mhz bus, or a 64-bit/133Mhz bus. + * + * The BCM5701 is a single-chip solution incorporating both the BCM5700 + * MAC and a BCM5401 10/100/1000 PHY. Unlike the BCM5700, the BCM5701 + * does not support external SSRAM. + * + * Broadcom also produces a variation of the BCM5700 under the "Altima" + * brand name, which is functionally similar but lacks PCI-X support. + * + * Without external SSRAM, you can only have at most 4 TX rings, + * and the use of the mini RX ring is disabled. This seems to imply + * that these features are simply not available on the BCM5701. As a + * result, this driver does not implement any support for the mini RX + * ring. + */ + +#ifdef HAVE_KERNEL_OPTION_HEADERS +#include "opt_device_polling.h" +#endif + +#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 "miidevs.h" +#include + +#ifdef __sparc64__ +#include +#include +#include +#include +#endif + +#include +#include + +#include + +#define BGE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) +#define ETHER_MIN_NOPAD (ETHER_MIN_LEN - ETHER_CRC_LEN) /* i.e., 60 */ + +MODULE_DEPEND(bge, pci, 1, 1, 1); +MODULE_DEPEND(bge, ether, 1, 1, 1); +MODULE_DEPEND(bge, miibus, 1, 1, 1); + +/* "device miibus" required. See GENERIC if you get errors here. */ +#include "miibus_if.h" + +/* + * Various supported device vendors/types and their names. Note: the + * spec seems to indicate that the hardware still has Alteon's vendor + * ID burned into it, though it will always be overriden by the vendor + * ID in the EEPROM. Just to be safe, we cover all possibilities. + */ +static struct bge_type { + uint16_t bge_vid; + uint16_t bge_did; +} bge_devs[] = { + { ALTEON_VENDORID, ALTEON_DEVICEID_BCM5700 }, + { ALTEON_VENDORID, ALTEON_DEVICEID_BCM5701 }, + + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC1000 }, + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC1002 }, + { ALTIMA_VENDORID, ALTIMA_DEVICE_AC9100 }, + + { APPLE_VENDORID, APPLE_DEVICE_BCM5701 }, + + { BCOM_VENDORID, BCOM_DEVICEID_BCM5700 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5701 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5702X }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5703X }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704C }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5704S_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705K }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5705M_ALT }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5714C }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5714S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5715 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5715S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5720 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5721 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5750 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5750M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5751M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5752 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5752M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753F }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5753M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5754 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5754M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5755 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5755M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5780 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5780S }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5781 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5782 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5786 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5787 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5787M }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5788 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5789 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5901 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5901A2 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5903M }, + + { SK_VENDORID, SK_DEVICEID_ALTIMA }, + + { TC_VENDORID, TC_DEVICEID_3C996 }, + + { 0, 0 } +}; + +static const struct bge_vendor { + uint16_t v_id; + const char *v_name; +} bge_vendors[] = { + { ALTEON_VENDORID, "Alteon" }, + { ALTIMA_VENDORID, "Altima" }, + { APPLE_VENDORID, "Apple" }, + { BCOM_VENDORID, "Broadcom" }, + { SK_VENDORID, "SysKonnect" }, + { TC_VENDORID, "3Com" }, + + { 0, NULL } +}; + +static const struct bge_revision { + uint32_t br_chipid; + const char *br_name; +} bge_revisions[] = { + { BGE_CHIPID_BCM5700_A0, "BCM5700 A0" }, + { BGE_CHIPID_BCM5700_A1, "BCM5700 A1" }, + { BGE_CHIPID_BCM5700_B0, "BCM5700 B0" }, + { BGE_CHIPID_BCM5700_B1, "BCM5700 B1" }, + { BGE_CHIPID_BCM5700_B2, "BCM5700 B2" }, + { BGE_CHIPID_BCM5700_B3, "BCM5700 B3" }, + { BGE_CHIPID_BCM5700_ALTIMA, "BCM5700 Altima" }, + { BGE_CHIPID_BCM5700_C0, "BCM5700 C0" }, + { BGE_CHIPID_BCM5701_A0, "BCM5701 A0" }, + { BGE_CHIPID_BCM5701_B0, "BCM5701 B0" }, + { BGE_CHIPID_BCM5701_B2, "BCM5701 B2" }, + { BGE_CHIPID_BCM5701_B5, "BCM5701 B5" }, + { BGE_CHIPID_BCM5703_A0, "BCM5703 A0" }, + { BGE_CHIPID_BCM5703_A1, "BCM5703 A1" }, + { BGE_CHIPID_BCM5703_A2, "BCM5703 A2" }, + { BGE_CHIPID_BCM5703_A3, "BCM5703 A3" }, + { BGE_CHIPID_BCM5703_B0, "BCM5703 B0" }, + { BGE_CHIPID_BCM5704_A0, "BCM5704 A0" }, + { BGE_CHIPID_BCM5704_A1, "BCM5704 A1" }, + { BGE_CHIPID_BCM5704_A2, "BCM5704 A2" }, + { BGE_CHIPID_BCM5704_A3, "BCM5704 A3" }, + { BGE_CHIPID_BCM5704_B0, "BCM5704 B0" }, + { BGE_CHIPID_BCM5705_A0, "BCM5705 A0" }, + { BGE_CHIPID_BCM5705_A1, "BCM5705 A1" }, + { BGE_CHIPID_BCM5705_A2, "BCM5705 A2" }, + { BGE_CHIPID_BCM5705_A3, "BCM5705 A3" }, + { BGE_CHIPID_BCM5750_A0, "BCM5750 A0" }, + { BGE_CHIPID_BCM5750_A1, "BCM5750 A1" }, + { BGE_CHIPID_BCM5750_A3, "BCM5750 A3" }, + { BGE_CHIPID_BCM5750_B0, "BCM5750 B0" }, + { BGE_CHIPID_BCM5750_B1, "BCM5750 B1" }, + { BGE_CHIPID_BCM5750_C0, "BCM5750 C0" }, + { BGE_CHIPID_BCM5750_C1, "BCM5750 C1" }, + { BGE_CHIPID_BCM5750_C2, "BCM5750 C2" }, + { BGE_CHIPID_BCM5714_A0, "BCM5714 A0" }, + { BGE_CHIPID_BCM5752_A0, "BCM5752 A0" }, + { BGE_CHIPID_BCM5752_A1, "BCM5752 A1" }, + { BGE_CHIPID_BCM5752_A2, "BCM5752 A2" }, + { BGE_CHIPID_BCM5714_B0, "BCM5714 B0" }, + { BGE_CHIPID_BCM5714_B3, "BCM5714 B3" }, + { BGE_CHIPID_BCM5715_A0, "BCM5715 A0" }, + { BGE_CHIPID_BCM5715_A1, "BCM5715 A1" }, + { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, + { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, + { BGE_CHIPID_BCM5755_A1, "BCM5755 A1" }, + { BGE_CHIPID_BCM5755_A2, "BCM5755 A2" }, + /* 5754 and 5787 share the same ASIC ID */ + { BGE_CHIPID_BCM5787_A0, "BCM5754/5787 A0" }, + { BGE_CHIPID_BCM5787_A1, "BCM5754/5787 A1" }, + { BGE_CHIPID_BCM5787_A2, "BCM5754/5787 A2" }, + + { 0, NULL } +}; + +/* + * Some defaults for major revisions, so that newer steppings + * that we don't know about have a shot at working. + */ +static const struct bge_revision bge_majorrevs[] = { + { BGE_ASICREV_BCM5700, "unknown BCM5700" }, + { BGE_ASICREV_BCM5701, "unknown BCM5701" }, + { BGE_ASICREV_BCM5703, "unknown BCM5703" }, + { BGE_ASICREV_BCM5704, "unknown BCM5704" }, + { BGE_ASICREV_BCM5705, "unknown BCM5705" }, + { BGE_ASICREV_BCM5750, "unknown BCM5750" }, + { BGE_ASICREV_BCM5714_A0, "unknown BCM5714" }, + { BGE_ASICREV_BCM5752, "unknown BCM5752" }, + { BGE_ASICREV_BCM5780, "unknown BCM5780" }, + { BGE_ASICREV_BCM5714, "unknown BCM5714" }, + { BGE_ASICREV_BCM5755, "unknown BCM5755" }, + /* 5754 and 5787 share the same ASIC ID */ + { BGE_ASICREV_BCM5787, "unknown BCM5754/5787" }, + + { 0, NULL } +}; + +#define BGE_IS_JUMBO_CAPABLE(sc) ((sc)->bge_flags & BGE_FLAG_JUMBO) +#define BGE_IS_5700_FAMILY(sc) ((sc)->bge_flags & BGE_FLAG_5700_FAMILY) +#define BGE_IS_5705_PLUS(sc) ((sc)->bge_flags & BGE_FLAG_5705_PLUS) +#define BGE_IS_5714_FAMILY(sc) ((sc)->bge_flags & BGE_FLAG_5714_FAMILY) +#define BGE_IS_575X_PLUS(sc) ((sc)->bge_flags & BGE_FLAG_575X_PLUS) + +const struct bge_revision * bge_lookup_rev(uint32_t); +const struct bge_vendor * bge_lookup_vendor(uint16_t); +static int bge_probe(device_t); +static int bge_attach(device_t); +static int bge_detach(device_t); +static int bge_suspend(device_t); +static int bge_resume(device_t); +static void bge_release_resources(struct bge_softc *); +static void bge_dma_map_addr(void *, bus_dma_segment_t *, int, int); +static int bge_dma_alloc(device_t); +static void bge_dma_free(struct bge_softc *); + +static void bge_txeof(struct bge_softc *); +static void bge_rxeof(struct bge_softc *); + +static void bge_asf_driver_up (struct bge_softc *); +static void bge_tick(void *); +static void bge_stats_update(struct bge_softc *); +static void bge_stats_update_regs(struct bge_softc *); +static int bge_encap(struct bge_softc *, struct mbuf **, uint32_t *); + +static void bge_intr(void *); +static void bge_start_locked(struct ifnet *); +static void bge_start(struct ifnet *); +static int bge_ioctl(struct ifnet *, u_long, caddr_t); +static void bge_init_locked(struct bge_softc *); +static void bge_init(void *); +static void bge_stop(struct bge_softc *); +static void bge_watchdog(struct bge_softc *); +static void bge_shutdown(device_t); +static int bge_ifmedia_upd_locked(struct ifnet *); +static int bge_ifmedia_upd(struct ifnet *); +static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *); + +static uint8_t bge_eeprom_getbyte(struct bge_softc *, int, uint8_t *); +static int bge_read_eeprom(struct bge_softc *, caddr_t, int, int); + +static void bge_setpromisc(struct bge_softc *); +static void bge_setmulti(struct bge_softc *); +static void bge_setvlan(struct bge_softc *); + +static int bge_newbuf_std(struct bge_softc *, int, struct mbuf *); +static int bge_newbuf_jumbo(struct bge_softc *, int, struct mbuf *); +static int bge_init_rx_ring_std(struct bge_softc *); +static void bge_free_rx_ring_std(struct bge_softc *); +static int bge_init_rx_ring_jumbo(struct bge_softc *); +static void bge_free_rx_ring_jumbo(struct bge_softc *); +static void bge_free_tx_ring(struct bge_softc *); +static int bge_init_tx_ring(struct bge_softc *); + +static int bge_chipinit(struct bge_softc *); +static int bge_blockinit(struct bge_softc *); + +static int bge_has_eeprom(struct bge_softc *); +static uint32_t bge_readmem_ind(struct bge_softc *, int); +static void bge_writemem_ind(struct bge_softc *, int, int); +#ifdef notdef +static uint32_t bge_readreg_ind(struct bge_softc *, int); +#endif +static void bge_writemem_direct(struct bge_softc *, int, int); +static void bge_writereg_ind(struct bge_softc *, int, int); + +static int bge_miibus_readreg(device_t, int, int); +static int bge_miibus_writereg(device_t, int, int, int); +static void bge_miibus_statchg(device_t); +#ifdef DEVICE_POLLING +static void bge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count); +#endif + +#define BGE_RESET_START 1 +#define BGE_RESET_STOP 2 +static void bge_sig_post_reset(struct bge_softc *, int); +static void bge_sig_legacy(struct bge_softc *, int); +static void bge_sig_pre_reset(struct bge_softc *, int); +static int bge_reset(struct bge_softc *); +static void bge_link_upd(struct bge_softc *); + +/* + * The BGE_REGISTER_DEBUG option is only for low-level debugging. It may + * leak information to untrusted users. It is also known to cause alignment + * traps on certain architectures. + */ +#ifdef BGE_REGISTER_DEBUG +static int bge_sysctl_debug_info(SYSCTL_HANDLER_ARGS); +static int bge_sysctl_reg_read(SYSCTL_HANDLER_ARGS); +static int bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS); +#endif +static void bge_add_sysctls(struct bge_softc *); +static int bge_sysctl_stats(SYSCTL_HANDLER_ARGS); + +static device_method_t bge_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, bge_probe), + DEVMETHOD(device_attach, bge_attach), + DEVMETHOD(device_detach, bge_detach), + DEVMETHOD(device_shutdown, bge_shutdown), + DEVMETHOD(device_suspend, bge_suspend), + DEVMETHOD(device_resume, bge_resume), + + /* bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + + /* MII interface */ + DEVMETHOD(miibus_readreg, bge_miibus_readreg), + DEVMETHOD(miibus_writereg, bge_miibus_writereg), + DEVMETHOD(miibus_statchg, bge_miibus_statchg), + + { 0, 0 } +}; + +static driver_t bge_driver = { + "bge", + bge_methods, + sizeof(struct bge_softc) +}; + +static devclass_t bge_devclass; + +DRIVER_MODULE(bge, pci, bge_driver, bge_devclass, 0, 0); +DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0); + +static int bge_allow_asf = 1; + +TUNABLE_INT("hw.bge.allow_asf", &bge_allow_asf); + +SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); +SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RD, &bge_allow_asf, 0, + "Allow ASF mode if available"); + +#define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" +#define SPARC64_BLADE_1500_PATH_BGE "/pci at 1f,700000/network at 2" +#define SPARC64_BLADE_2500_MODEL "SUNW,Sun-Blade-2500" +#define SPARC64_BLADE_2500_PATH_BGE "/pci at 1c,600000/network at 3" +#define SPARC64_OFW_SUBVENDOR "subsystem-vendor-id" + +static int +bge_has_eeprom(struct bge_softc *sc) +{ +#ifdef __sparc64__ + char buf[sizeof(SPARC64_BLADE_1500_PATH_BGE)]; + device_t dev; + uint32_t subvendor; + + dev = sc->bge_dev; + + /* + * The on-board BGEs found in sun4u machines aren't fitted with + * an EEPROM which means that we have to obtain the MAC address + * via OFW and that some tests will always fail. We distinguish + * such BGEs by the subvendor ID, which also has to be obtained + * from OFW instead of the PCI configuration space as the latter + * indicates Broadcom as the subvendor of the netboot interface. + * For early Blade 1500 and 2500 we even have to check the OFW + * device path as the subvendor ID always defaults to Broadcom + * there. + */ + if (OF_getprop(ofw_bus_get_node(dev), SPARC64_OFW_SUBVENDOR, + &subvendor, sizeof(subvendor)) == sizeof(subvendor) && + subvendor == SUN_VENDORID) + return (0); + memset(buf, 0, sizeof(buf)); + if (OF_package_to_path(ofw_bus_get_node(dev), buf, sizeof(buf)) > 0) { + if (strcmp(sparc64_model, SPARC64_BLADE_1500_MODEL) == 0 && + strcmp(buf, SPARC64_BLADE_1500_PATH_BGE) == 0) + return (0); + if (strcmp(sparc64_model, SPARC64_BLADE_2500_MODEL) == 0 && + strcmp(buf, SPARC64_BLADE_2500_PATH_BGE) == 0) + return (0); + } +#endif + return (1); +} + +static uint32_t +bge_readmem_ind(struct bge_softc *sc, int off) +{ + device_t dev; + uint32_t val; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); + val = pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4); + return (val); +} + +static void +bge_writemem_ind(struct bge_softc *sc, int off, int val) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_DATA, val, 4); + pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4); +} + +#ifdef notdef +static uint32_t +bge_readreg_ind(struct bge_softc *sc, int off) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4); + return (pci_read_config(dev, BGE_PCI_REG_DATA, 4)); +} +#endif + +static void +bge_writereg_ind(struct bge_softc *sc, int off, int val) +{ + device_t dev; + + dev = sc->bge_dev; + + pci_write_config(dev, BGE_PCI_REG_BASEADDR, off, 4); + pci_write_config(dev, BGE_PCI_REG_DATA, val, 4); +} + +static void +bge_writemem_direct(struct bge_softc *sc, int off, int val) +{ + CSR_WRITE_4(sc, off, val); +} + +/* + * Map a single buffer address. + */ + +static void +bge_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) +{ + struct bge_dmamap_arg *ctx; + + if (error) + return; + + ctx = arg; + + if (nseg > ctx->bge_maxsegs) { + ctx->bge_maxsegs = 0; + return; + } + + ctx->bge_busaddr = segs->ds_addr; +} + +/* + * Read a byte of data stored in the EEPROM at address 'addr.' The + * BCM570x supports both the traditional bitbang interface and an + * auto access interface for reading the EEPROM. We use the auto + * access method. + */ +static uint8_t +bge_eeprom_getbyte(struct bge_softc *sc, int addr, uint8_t *dest) +{ + int i; + uint32_t byte = 0; + + /* + * Enable use of auto EEPROM access so we can avoid + * having to use the bitbang method. + */ + BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM); + + /* Reset the EEPROM, load the clock period. */ + CSR_WRITE_4(sc, BGE_EE_ADDR, + BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL)); + DELAY(20); + + /* Issue the read EEPROM command. */ + CSR_WRITE_4(sc, BGE_EE_ADDR, BGE_EE_READCMD | addr); + + /* Wait for completion */ + for(i = 0; i < BGE_TIMEOUT * 10; i++) { + DELAY(10); + if (CSR_READ_4(sc, BGE_EE_ADDR) & BGE_EEADDR_DONE) + break; + } + + if (i == BGE_TIMEOUT * 10) { + device_printf(sc->bge_dev, "EEPROM read timed out\n"); + return (1); + } + + /* Get result. */ + byte = CSR_READ_4(sc, BGE_EE_DATA); + + *dest = (byte >> ((addr % 4) * 8)) & 0xFF; + + return (0); +} + +/* + * Read a sequence of bytes from the EEPROM. + */ +static int +bge_read_eeprom(struct bge_softc *sc, caddr_t dest, int off, int cnt) +{ + int i, error = 0; + uint8_t byte = 0; + + for (i = 0; i < cnt; i++) { + error = bge_eeprom_getbyte(sc, off + i, &byte); + if (error) + break; + *(dest + i) = byte; + } + + return (error ? 1 : 0); +} + +static int +bge_miibus_readreg(device_t dev, int phy, int reg) +{ + struct bge_softc *sc; + uint32_t val, autopoll; + int i; + + sc = device_get_softc(dev); + + /* + * Broadcom's own driver always assumes the internal + * PHY is at GMII address 1. On some chips, the PHY responds + * to accesses at all addresses, which could cause us to + * bogusly attach the PHY 32 times at probe type. Always + * restricting the lookup to address 1 is simpler than + * trying to figure out which chips revisions should be + * special-cased. + */ + if (phy != 1) + return (0); + + /* Reading with autopolling on may trigger PCI errors */ + autopoll = CSR_READ_4(sc, BGE_MI_MODE); + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_READ | BGE_MICOMM_BUSY | + BGE_MIPHY(phy) | BGE_MIREG(reg)); + + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + val = CSR_READ_4(sc, BGE_MI_COMM); + if (!(val & BGE_MICOMM_BUSY)) + break; + } + + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "PHY read timed out\n"); + val = 0; + goto done; + } + + val = CSR_READ_4(sc, BGE_MI_COMM); + +done: + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + if (val & BGE_MICOMM_READFAIL) + return (0); + + return (val & 0xFFFF); +} + +static int +bge_miibus_writereg(device_t dev, int phy, int reg, int val) +{ + struct bge_softc *sc; + uint32_t autopoll; + int i; + + sc = device_get_softc(dev); + + /* Reading with autopolling on may trigger PCI errors */ + autopoll = CSR_READ_4(sc, BGE_MI_MODE); + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_CLRBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_WRITE | BGE_MICOMM_BUSY | + BGE_MIPHY(phy) | BGE_MIREG(reg) | val); + + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + if (!(CSR_READ_4(sc, BGE_MI_COMM) & BGE_MICOMM_BUSY)) + break; + } + + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "PHY write timed out\n"); + return (0); + } + + if (autopoll & BGE_MIMODE_AUTOPOLL) { + BGE_SETBIT(sc, BGE_MI_MODE, BGE_MIMODE_AUTOPOLL); + DELAY(40); + } + + return (0); +} + +static void +bge_miibus_statchg(device_t dev) +{ + struct bge_softc *sc; + struct mii_data *mii; + sc = device_get_softc(dev); + mii = device_get_softc(sc->bge_miibus); + + BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE); + if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T) + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII); + else + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_MII); + + if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) + BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); + else + BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_HALF_DUPLEX); +} + +/* + * Intialize a standard receive ring descriptor. + */ +static int +bge_newbuf_std(struct bge_softc *sc, int i, struct mbuf *m) +{ + struct mbuf *m_new = NULL; + struct bge_rx_bd *r; + struct bge_dmamap_arg ctx; + int error; + + if (m == NULL) { + m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m_new == NULL) + return (ENOBUFS); + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + } else { + m_new = m; + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + m_new->m_data = m_new->m_ext.ext_buf; + } + + if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0) + m_adj(m_new, ETHER_ALIGN); + sc->bge_cdata.bge_rx_std_chain[i] = m_new; + r = &sc->bge_ldata.bge_rx_std_ring[i]; + ctx.bge_maxsegs = 1; + ctx.sc = sc; + error = bus_dmamap_load(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i], mtod(m_new, void *), + m_new->m_len, bge_dma_map_addr, &ctx, BUS_DMA_NOWAIT); + if (error || ctx.bge_maxsegs == 0) { + if (m == NULL) { + sc->bge_cdata.bge_rx_std_chain[i] = NULL; + m_freem(m_new); + } + return (ENOMEM); + } + r->bge_addr.bge_addr_lo = BGE_ADDR_LO(ctx.bge_busaddr); + r->bge_addr.bge_addr_hi = BGE_ADDR_HI(ctx.bge_busaddr); + r->bge_flags = BGE_RXBDFLAG_END; + r->bge_len = m_new->m_len; + r->bge_idx = i; + + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i], + BUS_DMASYNC_PREREAD); + + return (0); +} + +/* + * Initialize a jumbo receive ring descriptor. This allocates + * a jumbo buffer from the pool managed internally by the driver. + */ +static int +bge_newbuf_jumbo(struct bge_softc *sc, int i, struct mbuf *m) +{ + bus_dma_segment_t segs[BGE_NSEG_JUMBO]; + struct bge_extrx_bd *r; + struct mbuf *m_new = NULL; + int nsegs; + int error; + + if (m == NULL) { + MGETHDR(m_new, M_DONTWAIT, MT_DATA); + if (m_new == NULL) + return (ENOBUFS); + + m_cljget(m_new, M_DONTWAIT, MJUM9BYTES); + if (!(m_new->m_flags & M_EXT)) { + m_freem(m_new); + return (ENOBUFS); + } + m_new->m_len = m_new->m_pkthdr.len = MJUM9BYTES; + } else { + m_new = m; + m_new->m_len = m_new->m_pkthdr.len = MJUM9BYTES; + m_new->m_data = m_new->m_ext.ext_buf; + } + + if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0) + m_adj(m_new, ETHER_ALIGN); + + error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_mtag_jumbo, + sc->bge_cdata.bge_rx_jumbo_dmamap[i], + m_new, segs, &nsegs, BUS_DMA_NOWAIT); + if (error) { + if (m == NULL) + m_freem(m_new); + return (error); + } + sc->bge_cdata.bge_rx_jumbo_chain[i] = m_new; + + /* + * Fill in the extended RX buffer descriptor. + */ + r = &sc->bge_ldata.bge_rx_jumbo_ring[i]; + r->bge_flags = BGE_RXBDFLAG_JUMBO_RING | BGE_RXBDFLAG_END; + r->bge_idx = i; + r->bge_len3 = r->bge_len2 = r->bge_len1 = 0; + switch (nsegs) { + case 4: + r->bge_addr3.bge_addr_lo = BGE_ADDR_LO(segs[3].ds_addr); + r->bge_addr3.bge_addr_hi = BGE_ADDR_HI(segs[3].ds_addr); + r->bge_len3 = segs[3].ds_len; + case 3: + r->bge_addr2.bge_addr_lo = BGE_ADDR_LO(segs[2].ds_addr); + r->bge_addr2.bge_addr_hi = BGE_ADDR_HI(segs[2].ds_addr); + r->bge_len2 = segs[2].ds_len; + case 2: + r->bge_addr1.bge_addr_lo = BGE_ADDR_LO(segs[1].ds_addr); + r->bge_addr1.bge_addr_hi = BGE_ADDR_HI(segs[1].ds_addr); + r->bge_len1 = segs[1].ds_len; + case 1: + r->bge_addr0.bge_addr_lo = BGE_ADDR_LO(segs[0].ds_addr); + r->bge_addr0.bge_addr_hi = BGE_ADDR_HI(segs[0].ds_addr); + r->bge_len0 = segs[0].ds_len; + break; + default: + panic("%s: %d segments\n", __func__, nsegs); + } + + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_jumbo_dmamap[i], + BUS_DMASYNC_PREREAD); + + return (0); +} + +/* + * The standard receive ring has 512 entries in it. At 2K per mbuf cluster, + * that's 1MB or memory, which is a lot. For now, we fill only the first + * 256 ring entries and hope that our CPU is fast enough to keep up with + * the NIC. + */ +static int +bge_init_rx_ring_std(struct bge_softc *sc) +{ + int i; + + for (i = 0; i < BGE_SSLOTS; i++) { + if (bge_newbuf_std(sc, i, NULL) == ENOBUFS) + return (ENOBUFS); + }; + + bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag, + sc->bge_cdata.bge_rx_std_ring_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + sc->bge_std = i - 1; + CSR_WRITE_4(sc, BGE_MBX_RX_STD_PROD_LO, sc->bge_std); + + return (0); +} + +static void +bge_free_rx_ring_std(struct bge_softc *sc) +{ + int i; + + for (i = 0; i < BGE_STD_RX_RING_CNT; i++) { + if (sc->bge_cdata.bge_rx_std_chain[i] != NULL) { + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i], + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_rx_std_dmamap[i]); + m_freem(sc->bge_cdata.bge_rx_std_chain[i]); + sc->bge_cdata.bge_rx_std_chain[i] = NULL; + } + bzero((char *)&sc->bge_ldata.bge_rx_std_ring[i], + sizeof(struct bge_rx_bd)); + } +} + +static int +bge_init_rx_ring_jumbo(struct bge_softc *sc) +{ + struct bge_rcb *rcb; + int i; + + for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) { + if (bge_newbuf_jumbo(sc, i, NULL) == ENOBUFS) + return (ENOBUFS); + }; + + bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag, + sc->bge_cdata.bge_rx_jumbo_ring_map, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + sc->bge_jumbo = i - 1; + + rcb = &sc->bge_ldata.bge_info.bge_jumbo_rx_rcb; + rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, + BGE_RCB_FLAG_USE_EXT_RX_BD); + CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags); + + CSR_WRITE_4(sc, BGE_MBX_RX_JUMBO_PROD_LO, sc->bge_jumbo); + + return (0); +} + +static void +bge_free_rx_ring_jumbo(struct bge_softc *sc) +{ + int i; + + for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) { + if (sc->bge_cdata.bge_rx_jumbo_chain[i] != NULL) { + bus_dmamap_sync(sc->bge_cdata.bge_mtag_jumbo, + sc->bge_cdata.bge_rx_jumbo_dmamap[i], + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(sc->bge_cdata.bge_mtag_jumbo, + sc->bge_cdata.bge_rx_jumbo_dmamap[i]); + m_freem(sc->bge_cdata.bge_rx_jumbo_chain[i]); + sc->bge_cdata.bge_rx_jumbo_chain[i] = NULL; + } + bzero((char *)&sc->bge_ldata.bge_rx_jumbo_ring[i], + sizeof(struct bge_extrx_bd)); + } +} + +static void +bge_free_tx_ring(struct bge_softc *sc) +{ + int i; + + if (sc->bge_ldata.bge_tx_ring == NULL) + return; + + for (i = 0; i < BGE_TX_RING_CNT; i++) { + if (sc->bge_cdata.bge_tx_chain[i] != NULL) { + bus_dmamap_sync(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_tx_dmamap[i], + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->bge_cdata.bge_mtag, + sc->bge_cdata.bge_tx_dmamap[i]); + m_freem(sc->bge_cdata.bge_tx_chain[i]); + sc->bge_cdata.bge_tx_chain[i] = NULL; + } + bzero((char *)&sc->bge_ldata.bge_tx_ring[i], + sizeof(struct bge_tx_bd)); + } +} + +static int +bge_init_tx_ring(struct bge_softc *sc) +{ + sc->bge_txcnt = 0; + sc->bge_tx_saved_considx = 0; + + /* Initialize transmit producer index for host-memory send ring. */ + sc->bge_tx_prodidx = 0; + CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, sc->bge_tx_prodidx); + + /* 5700 b2 errata */ [... truncated: 9763 lines follow ...] From axeld at mail.berlios.de Sun Dec 16 12:01:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 16 Dec 2007 12:01:34 +0100 Subject: [Haiku-commits] r23126 - haiku/vendor/freebsd/RELENG_7_BP/dev Message-ID: <200712161101.lBGB1Y49029862@sheep.berlios.de> Author: axeld Date: 2007-12-16 12:01:34 +0100 (Sun, 16 Dec 2007) New Revision: 23126 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23126&view=rev Added: haiku/vendor/freebsd/RELENG_7_BP/dev/bge/ haiku/vendor/freebsd/RELENG_7_BP/dev/nfe/ Log: Tagged bge and nfe drivers with RELENG_7_BP. Copied: haiku/vendor/freebsd/RELENG_7_BP/dev/bge (from rev 23125, haiku/vendor/freebsd/current/dev/bge) Copied: haiku/vendor/freebsd/RELENG_7_BP/dev/nfe (from rev 23125, haiku/vendor/freebsd/current/dev/nfe) From fekdahl at gmail.com Sun Dec 16 12:10:33 2007 From: fekdahl at gmail.com (Fredrik Ekdahl) Date: Sun, 16 Dec 2007 12:10:33 +0100 Subject: [Haiku-commits] r23124 - in haiku/trunk/src/add-ons/kernel/drivers/network: . broadcom_bcm570x broadcom_bcm570x/dev broadcom_bcm570x/dev/bge broadcom_bcm570x/dev/mii nforce nforce/dev nforce/dev/mii nforce/dev/nfe In-Reply-To: <200712161056.lBGAue1N029576@sheep.berlios.de> References: <200712161056.lBGAue1N029576@sheep.berlios.de> Message-ID: <1197803433.6093.2.camel@ekdahl> s?n 2007-12-16 klockan 11:56 +0100 skrev axeld at BerliOS: > Log: > * Added nVidia nForce MCP driver (nfe) from FreeBSD. Compiles and > might even > work - please test. It would also be nice to know if your PHY is > detected > correctly (see syslog output). Yes! Thank you very much! I've been waiting for this. Gonna try asap. /Fredrik Ekdahl From korli at mail.berlios.de Sun Dec 16 18:27:37 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 18:27:37 +0100 Subject: [Haiku-commits] r23127 - buildtools/trunk/legacy/gcc/gcc Message-ID: <200712161727.lBGHRbTx007684@sheep.berlios.de> Author: korli Date: 2007-12-16 18:27:36 +0100 (Sun, 16 Dec 2007) New Revision: 23127 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23127&view=rev Modified: buildtools/trunk/legacy/gcc/gcc/configure buildtools/trunk/legacy/gcc/gcc/configure.in Log: we need to set float_format for the target i586-beos-pc to i386. If not, we default to i64, which means long double equals double. this finally fixes bug #1608 and enables to print correctly long double values. It should now be possible to revert r21883. I hope this change has no consequences on binary compatibility (it shouldn't). Oliver, please review. Modified: buildtools/trunk/legacy/gcc/gcc/configure =================================================================== --- buildtools/trunk/legacy/gcc/gcc/configure 2007-12-16 11:01:34 UTC (rev 23126) +++ buildtools/trunk/legacy/gcc/gcc/configure 2007-12-16 17:27:36 UTC (rev 23127) @@ -3562,6 +3562,7 @@ extra_objs=winnt.o extra_parts='crtbegin.o crtend.o' fixincludes=Makefile.in + float_format=i386 ;; i[34567]86-*-bsdi* | i[34567]86-*-bsd386*) tm_file=i386/bsd386.h Modified: buildtools/trunk/legacy/gcc/gcc/configure.in =================================================================== --- buildtools/trunk/legacy/gcc/gcc/configure.in 2007-12-16 11:01:34 UTC (rev 23126) +++ buildtools/trunk/legacy/gcc/gcc/configure.in 2007-12-16 17:27:36 UTC (rev 23127) @@ -1160,6 +1160,7 @@ extra_objs=winnt.o extra_parts='crtbegin.o crtend.o' fixincludes=Makefile.in + float_format=i386 ;; changequote(,)dnl i[34567]86-*-bsdi* | i[34567]86-*-bsd386*) From korli at mail.berlios.de Sun Dec 16 18:40:16 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 18:40:16 +0100 Subject: [Haiku-commits] r23128 - haiku/trunk/src/bin/coreutils/src Message-ID: <200712161740.lBGHeGpZ029360@sheep.berlios.de> Author: korli Date: 2007-12-16 18:40:14 +0100 (Sun, 16 Dec 2007) New Revision: 23128 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23128&view=rev Removed: haiku/trunk/src/bin/coreutils/src/seq-old.c Modified: haiku/trunk/src/bin/coreutils/src/Jamfile Log: reverted r21883. the bug #1368 is now fixed for real in r23127 (needs to rebuild of gcc2.95 or a manual fix of its float.h) Modified: haiku/trunk/src/bin/coreutils/src/Jamfile =================================================================== --- haiku/trunk/src/bin/coreutils/src/Jamfile 2007-12-16 17:27:36 UTC (rev 23127) +++ haiku/trunk/src/bin/coreutils/src/Jamfile 2007-12-16 17:40:14 UTC (rev 23128) @@ -51,6 +51,7 @@ ptx.c readlink.c rmdir.c + seq.c shred.c shuf.c split.c @@ -102,13 +103,6 @@ # users.c # who.c -local seq_src = seq.c ; -if $(HAIKU_GCC_VERSION[1]) < 3 { - seq_src = seq-old.c ; -} - -BinCommand seq : $(seq_src) : libfetish.a : $(coreutils_rsrc) ; - BinCommand "[" : lbracket.c : libfetish.a : $(coreutils_rsrc) ; BinCommand ls : Deleted: haiku/trunk/src/bin/coreutils/src/seq-old.c From zooey at hirschkaefer.de Sun Dec 16 18:36:40 2007 From: zooey at hirschkaefer.de (Oliver Tappe) Date: Sun, 16 Dec 2007 18:36:40 +0100 Subject: [Haiku-commits] r23127 - buildtools/trunk/legacy/gcc/gcc In-Reply-To: <200712161727.lBGHRbTx007684@sheep.berlios.de> References: <200712161727.lBGHRbTx007684@sheep.berlios.de> Message-ID: <20071216183640.1748.1@bee.hirschkaefer.site> Hi Korli, On 2007-12-16 at 18:27:37 [+0100], korli at BerliOS wrote: > Author: korli > Date: 2007-12-16 18:27:36 +0100 (Sun, 16 Dec 2007) > New Revision: 23127 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23127&view=rev > > Modified: > buildtools/trunk/legacy/gcc/gcc/configure > buildtools/trunk/legacy/gcc/gcc/configure.in > Log: > we need to set float_format for the target i586-beos-pc to i386. If not, we > default to i64, which means long double equals double. > this finally fixes bug #1608 and enables to print correctly long double > values. > It should now be possible to revert r21883. > I hope this change has no consequences on binary compatibility (it > shouldn't). Oliver, please review. Without pretending to know much about it, I'd say since your change fixes the problem, it should be ok. When I looked up float.h in the different gcc-versions that exist for BeOS, all of them seem to imply double == long double. I find it weird that this has not triggered many more errors when these compilers are used on BeOS. Well, then again, maybe it has and we just never noticed the real cause ... ;-) cheers, Oliver From korli at mail.berlios.de Sun Dec 16 19:10:48 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 19:10:48 +0100 Subject: [Haiku-commits] r23129 - in haiku/vendor/coreutils/current: . doc lib man src Message-ID: <200712161810.lBGIAmhE002562@sheep.berlios.de> Author: korli Date: 2007-12-16 19:08:56 +0100 (Sun, 16 Dec 2007) New Revision: 23129 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23129&view=rev Added: haiku/vendor/coreutils/current/lib/acl-internal.h haiku/vendor/coreutils/current/lib/acl_entries.c haiku/vendor/coreutils/current/lib/c-ctype.c haiku/vendor/coreutils/current/lib/c-ctype.h haiku/vendor/coreutils/current/lib/c-strcase.h haiku/vendor/coreutils/current/lib/c-strcasecmp.c haiku/vendor/coreutils/current/lib/c-strncasecmp.c haiku/vendor/coreutils/current/lib/dirent_.h haiku/vendor/coreutils/current/lib/fchdir.c haiku/vendor/coreutils/current/lib/fchownat.c haiku/vendor/coreutils/current/lib/file-has-acl.c haiku/vendor/coreutils/current/lib/mbscasecmp.c haiku/vendor/coreutils/current/lib/mpsort.c haiku/vendor/coreutils/current/lib/mpsort.h haiku/vendor/coreutils/current/lib/netinet_in_.h haiku/vendor/coreutils/current/lib/stdio_.h haiku/vendor/coreutils/current/lib/stdlib_.h haiku/vendor/coreutils/current/lib/string_.h haiku/vendor/coreutils/current/lib/sys_time_.h haiku/vendor/coreutils/current/lib/time_.h haiku/vendor/coreutils/current/lib/unistd_.h haiku/vendor/coreutils/current/lib/wchar_.h haiku/vendor/coreutils/current/lib/wctype_.h haiku/vendor/coreutils/current/lib/xreadlink-with-size.c Removed: haiku/vendor/coreutils/current/lib/exit.h haiku/vendor/coreutils/current/lib/fchdir-stub.c haiku/vendor/coreutils/current/lib/getcwd.h haiku/vendor/coreutils/current/lib/mempcpy.h haiku/vendor/coreutils/current/lib/memrchr.h haiku/vendor/coreutils/current/lib/mkstemp.h haiku/vendor/coreutils/current/lib/snprintf.h haiku/vendor/coreutils/current/lib/stpcpy.h haiku/vendor/coreutils/current/lib/strcase.h haiku/vendor/coreutils/current/lib/strcasecmp.c haiku/vendor/coreutils/current/lib/strdup.h haiku/vendor/coreutils/current/lib/strncasecmp.c haiku/vendor/coreutils/current/lib/strndup.h haiku/vendor/coreutils/current/lib/strnlen.h haiku/vendor/coreutils/current/lib/strpbrk.h haiku/vendor/coreutils/current/lib/time_r.h Modified: haiku/vendor/coreutils/current/ChangeLog haiku/vendor/coreutils/current/Makefile.am haiku/vendor/coreutils/current/Makefile.cfg haiku/vendor/coreutils/current/Makefile.in haiku/vendor/coreutils/current/Makefile.maint haiku/vendor/coreutils/current/NEWS haiku/vendor/coreutils/current/README haiku/vendor/coreutils/current/THANKS haiku/vendor/coreutils/current/TODO haiku/vendor/coreutils/current/aclocal.m4 haiku/vendor/coreutils/current/bootstrap haiku/vendor/coreutils/current/bootstrap.conf haiku/vendor/coreutils/current/configure haiku/vendor/coreutils/current/configure.ac haiku/vendor/coreutils/current/doc/ChangeLog haiku/vendor/coreutils/current/doc/Makefile.in haiku/vendor/coreutils/current/doc/coreutils.info haiku/vendor/coreutils/current/doc/coreutils.texi haiku/vendor/coreutils/current/doc/stamp-vti haiku/vendor/coreutils/current/doc/version.texi haiku/vendor/coreutils/current/lib/ChangeLog haiku/vendor/coreutils/current/lib/Makefile.in haiku/vendor/coreutils/current/lib/acl.c haiku/vendor/coreutils/current/lib/acl.h haiku/vendor/coreutils/current/lib/allocsa.h haiku/vendor/coreutils/current/lib/argmatch.c haiku/vendor/coreutils/current/lib/backupfile.c haiku/vendor/coreutils/current/lib/base64.c haiku/vendor/coreutils/current/lib/base64.h haiku/vendor/coreutils/current/lib/canon-host.c haiku/vendor/coreutils/current/lib/canonicalize.c haiku/vendor/coreutils/current/lib/canonicalize.h haiku/vendor/coreutils/current/lib/chdir-long.c haiku/vendor/coreutils/current/lib/chown.c haiku/vendor/coreutils/current/lib/config.hin haiku/vendor/coreutils/current/lib/dirname.h haiku/vendor/coreutils/current/lib/dup-safer.c haiku/vendor/coreutils/current/lib/dup2.c haiku/vendor/coreutils/current/lib/exclude.c haiku/vendor/coreutils/current/lib/exitfail.c haiku/vendor/coreutils/current/lib/fcntl_.h haiku/vendor/coreutils/current/lib/fnmatch.c haiku/vendor/coreutils/current/lib/fnmatch_.h haiku/vendor/coreutils/current/lib/fnmatch_loop.c haiku/vendor/coreutils/current/lib/fsusage.c haiku/vendor/coreutils/current/lib/ftruncate.c haiku/vendor/coreutils/current/lib/fts.c haiku/vendor/coreutils/current/lib/fts_.h haiku/vendor/coreutils/current/lib/gai_strerror.c haiku/vendor/coreutils/current/lib/getaddrinfo.c haiku/vendor/coreutils/current/lib/getcwd.c haiku/vendor/coreutils/current/lib/getdate.c haiku/vendor/coreutils/current/lib/getdate.h haiku/vendor/coreutils/current/lib/getdate.y haiku/vendor/coreutils/current/lib/gethrxtime.c haiku/vendor/coreutils/current/lib/getopt_.h haiku/vendor/coreutils/current/lib/getpagesize.h haiku/vendor/coreutils/current/lib/gettime.c haiku/vendor/coreutils/current/lib/gettimeofday.c haiku/vendor/coreutils/current/lib/gnulib.mk haiku/vendor/coreutils/current/lib/hard-locale.c haiku/vendor/coreutils/current/lib/inttypes_.h haiku/vendor/coreutils/current/lib/mbchar.h haiku/vendor/coreutils/current/lib/mbswidth.c haiku/vendor/coreutils/current/lib/mbswidth.h haiku/vendor/coreutils/current/lib/mbuiter.h haiku/vendor/coreutils/current/lib/mempcpy.c haiku/vendor/coreutils/current/lib/memrchr.c haiku/vendor/coreutils/current/lib/mkdir-p.c haiku/vendor/coreutils/current/lib/mkstemp-safer.c haiku/vendor/coreutils/current/lib/mkstemp.c haiku/vendor/coreutils/current/lib/mktime.c haiku/vendor/coreutils/current/lib/mountlist.c haiku/vendor/coreutils/current/lib/nanosleep.c haiku/vendor/coreutils/current/lib/openat-proc.c haiku/vendor/coreutils/current/lib/openat.c haiku/vendor/coreutils/current/lib/posixtm.c haiku/vendor/coreutils/current/lib/posixtm.h haiku/vendor/coreutils/current/lib/printf-args.c haiku/vendor/coreutils/current/lib/printf-args.h haiku/vendor/coreutils/current/lib/printf-parse.c haiku/vendor/coreutils/current/lib/putenv.c haiku/vendor/coreutils/current/lib/quotearg.c haiku/vendor/coreutils/current/lib/randperm.c haiku/vendor/coreutils/current/lib/readlink.c haiku/vendor/coreutils/current/lib/readutmp.h haiku/vendor/coreutils/current/lib/regcomp.c haiku/vendor/coreutils/current/lib/regex.h haiku/vendor/coreutils/current/lib/regex_internal.c haiku/vendor/coreutils/current/lib/regex_internal.h haiku/vendor/coreutils/current/lib/regexec.c haiku/vendor/coreutils/current/lib/safe-read.h haiku/vendor/coreutils/current/lib/savedir.c haiku/vendor/coreutils/current/lib/savewd.c haiku/vendor/coreutils/current/lib/setenv.c haiku/vendor/coreutils/current/lib/setenv.h haiku/vendor/coreutils/current/lib/settime.c haiku/vendor/coreutils/current/lib/snprintf.c haiku/vendor/coreutils/current/lib/socket_.h haiku/vendor/coreutils/current/lib/stat-time.h haiku/vendor/coreutils/current/lib/stdbool_.h haiku/vendor/coreutils/current/lib/stdint_.h haiku/vendor/coreutils/current/lib/stdlib--.h haiku/vendor/coreutils/current/lib/strdup.c haiku/vendor/coreutils/current/lib/strftime.c haiku/vendor/coreutils/current/lib/strndup.c haiku/vendor/coreutils/current/lib/strnlen.c haiku/vendor/coreutils/current/lib/strtol.c haiku/vendor/coreutils/current/lib/tempname.c haiku/vendor/coreutils/current/lib/time_r.c haiku/vendor/coreutils/current/lib/timespec.h haiku/vendor/coreutils/current/lib/userspec.c haiku/vendor/coreutils/current/lib/utime.c haiku/vendor/coreutils/current/lib/utimecmp.c haiku/vendor/coreutils/current/lib/utimens.c haiku/vendor/coreutils/current/lib/utimens.h haiku/vendor/coreutils/current/lib/vasnprintf.c haiku/vendor/coreutils/current/lib/vasnprintf.h haiku/vendor/coreutils/current/lib/vasprintf.h haiku/vendor/coreutils/current/lib/version-etc.c haiku/vendor/coreutils/current/lib/wcwidth.h haiku/vendor/coreutils/current/lib/xalloc.h haiku/vendor/coreutils/current/lib/xfts.c haiku/vendor/coreutils/current/lib/xgetcwd.c haiku/vendor/coreutils/current/lib/xnanosleep.c haiku/vendor/coreutils/current/lib/xreadlink.c haiku/vendor/coreutils/current/lib/xreadlink.h haiku/vendor/coreutils/current/lib/xstrndup.c haiku/vendor/coreutils/current/lib/yesno.c haiku/vendor/coreutils/current/man/Makefile.am haiku/vendor/coreutils/current/man/Makefile.in haiku/vendor/coreutils/current/man/base64.1 haiku/vendor/coreutils/current/man/basename.1 haiku/vendor/coreutils/current/man/cat.1 haiku/vendor/coreutils/current/man/chgrp.1 haiku/vendor/coreutils/current/man/chmod.1 haiku/vendor/coreutils/current/man/chown.1 haiku/vendor/coreutils/current/man/chroot.1 haiku/vendor/coreutils/current/man/cksum.1 haiku/vendor/coreutils/current/man/comm.1 haiku/vendor/coreutils/current/man/cp.1 haiku/vendor/coreutils/current/man/csplit.1 haiku/vendor/coreutils/current/man/cut.1 haiku/vendor/coreutils/current/man/date.1 haiku/vendor/coreutils/current/man/dd.1 haiku/vendor/coreutils/current/man/df.1 haiku/vendor/coreutils/current/man/dir.1 haiku/vendor/coreutils/current/man/dircolors.1 haiku/vendor/coreutils/current/man/dirname.1 haiku/vendor/coreutils/current/man/du.1 haiku/vendor/coreutils/current/man/echo.1 haiku/vendor/coreutils/current/man/env.1 haiku/vendor/coreutils/current/man/expand.1 haiku/vendor/coreutils/current/man/expr.1 haiku/vendor/coreutils/current/man/factor.1 haiku/vendor/coreutils/current/man/false.1 haiku/vendor/coreutils/current/man/fmt.1 haiku/vendor/coreutils/current/man/fold.1 haiku/vendor/coreutils/current/man/groups.1 haiku/vendor/coreutils/current/man/head.1 haiku/vendor/coreutils/current/man/hostid.1 haiku/vendor/coreutils/current/man/hostname.1 haiku/vendor/coreutils/current/man/id.1 haiku/vendor/coreutils/current/man/install.1 haiku/vendor/coreutils/current/man/join.1 haiku/vendor/coreutils/current/man/kill.1 haiku/vendor/coreutils/current/man/link.1 haiku/vendor/coreutils/current/man/ln.1 haiku/vendor/coreutils/current/man/logname.1 haiku/vendor/coreutils/current/man/ls.1 haiku/vendor/coreutils/current/man/md5sum.1 haiku/vendor/coreutils/current/man/mkdir.1 haiku/vendor/coreutils/current/man/mkfifo.1 haiku/vendor/coreutils/current/man/mknod.1 haiku/vendor/coreutils/current/man/mv.1 haiku/vendor/coreutils/current/man/nice.1 haiku/vendor/coreutils/current/man/nl.1 haiku/vendor/coreutils/current/man/nohup.1 haiku/vendor/coreutils/current/man/od.1 haiku/vendor/coreutils/current/man/paste.1 haiku/vendor/coreutils/current/man/pathchk.1 haiku/vendor/coreutils/current/man/pinky.1 haiku/vendor/coreutils/current/man/pr.1 haiku/vendor/coreutils/current/man/printenv.1 haiku/vendor/coreutils/current/man/printf.1 haiku/vendor/coreutils/current/man/ptx.1 haiku/vendor/coreutils/current/man/pwd.1 haiku/vendor/coreutils/current/man/readlink.1 haiku/vendor/coreutils/current/man/rm.1 haiku/vendor/coreutils/current/man/rmdir.1 haiku/vendor/coreutils/current/man/seq.1 haiku/vendor/coreutils/current/man/sha1sum.1 haiku/vendor/coreutils/current/man/sha224sum.1 haiku/vendor/coreutils/current/man/sha256sum.1 haiku/vendor/coreutils/current/man/sha384sum.1 haiku/vendor/coreutils/current/man/sha512sum.1 haiku/vendor/coreutils/current/man/shred.1 haiku/vendor/coreutils/current/man/shuf.1 haiku/vendor/coreutils/current/man/sleep.1 haiku/vendor/coreutils/current/man/sort.1 haiku/vendor/coreutils/current/man/split.1 haiku/vendor/coreutils/current/man/stat.1 haiku/vendor/coreutils/current/man/stty.1 haiku/vendor/coreutils/current/man/su.1 haiku/vendor/coreutils/current/man/sum.1 haiku/vendor/coreutils/current/man/sync.1 haiku/vendor/coreutils/current/man/tac.1 haiku/vendor/coreutils/current/man/tail.1 haiku/vendor/coreutils/current/man/tee.1 haiku/vendor/coreutils/current/man/test.1 haiku/vendor/coreutils/current/man/touch.1 haiku/vendor/coreutils/current/man/tr.1 haiku/vendor/coreutils/current/man/true.1 haiku/vendor/coreutils/current/man/tsort.1 haiku/vendor/coreutils/current/man/tty.1 haiku/vendor/coreutils/current/man/uname.1 haiku/vendor/coreutils/current/man/unexpand.1 haiku/vendor/coreutils/current/man/uniq.1 haiku/vendor/coreutils/current/man/unlink.1 haiku/vendor/coreutils/current/man/uptime.1 haiku/vendor/coreutils/current/man/users.1 haiku/vendor/coreutils/current/man/vdir.1 haiku/vendor/coreutils/current/man/wc.1 haiku/vendor/coreutils/current/man/who.1 haiku/vendor/coreutils/current/man/whoami.1 haiku/vendor/coreutils/current/man/yes.1 haiku/vendor/coreutils/current/src/Makefile.am haiku/vendor/coreutils/current/src/Makefile.in haiku/vendor/coreutils/current/src/base64.c haiku/vendor/coreutils/current/src/c99-to-c89.diff haiku/vendor/coreutils/current/src/chgrp.c haiku/vendor/coreutils/current/src/chmod.c haiku/vendor/coreutils/current/src/chown-core.c haiku/vendor/coreutils/current/src/chown.c haiku/vendor/coreutils/current/src/copy.c haiku/vendor/coreutils/current/src/cp.c haiku/vendor/coreutils/current/src/csplit.c haiku/vendor/coreutils/current/src/cut.c haiku/vendor/coreutils/current/src/date.c haiku/vendor/coreutils/current/src/dd.c haiku/vendor/coreutils/current/src/df.c haiku/vendor/coreutils/current/src/dircolors.c haiku/vendor/coreutils/current/src/dircolors.h haiku/vendor/coreutils/current/src/dircolors.hin haiku/vendor/coreutils/current/src/du.c haiku/vendor/coreutils/current/src/env.c haiku/vendor/coreutils/current/src/expr.c haiku/vendor/coreutils/current/src/fmt.c haiku/vendor/coreutils/current/src/groups.sh haiku/vendor/coreutils/current/src/install.c haiku/vendor/coreutils/current/src/join.c haiku/vendor/coreutils/current/src/ls.c haiku/vendor/coreutils/current/src/mv.c haiku/vendor/coreutils/current/src/nl.c haiku/vendor/coreutils/current/src/od.c haiku/vendor/coreutils/current/src/pr.c haiku/vendor/coreutils/current/src/printf.c haiku/vendor/coreutils/current/src/readlink.c haiku/vendor/coreutils/current/src/remove.c haiku/vendor/coreutils/current/src/remove.h haiku/vendor/coreutils/current/src/rm.c haiku/vendor/coreutils/current/src/shuf.c haiku/vendor/coreutils/current/src/sort.c haiku/vendor/coreutils/current/src/stat.c haiku/vendor/coreutils/current/src/system.h haiku/vendor/coreutils/current/src/tail.c haiku/vendor/coreutils/current/src/tee.c haiku/vendor/coreutils/current/src/uniq.c Log: updating coreutils vendor with version 6.9 (with c99-to-c89.diff patch) Modified: haiku/vendor/coreutils/current/ChangeLog =================================================================== --- haiku/vendor/coreutils/current/ChangeLog 2007-12-16 17:40:14 UTC (rev 23128) +++ haiku/vendor/coreutils/current/ChangeLog 2007-12-16 18:08:56 UTC (rev 23129) @@ -1,3 +1,1098 @@ +2007-03-22 Jim Meyering + + Version 6.9. + * NEWS: Record release date and new version number. + * configure.ac (AC_INIT): New version number. + + * tests/mv/hard-3: Correct the preceding change: $3 -> $2. + +2007-03-22 Paul Eggert + + Improve a test script. + * tests/mv/hard-3: Check for 'ls' failure, too. + Generate more-useful debugging output when 'ls' fails. + +2007-03-21 Jim Meyering + + Fix a test script not to claim an ext2 file system is of type xfs. + * tests/du/slink: When using df --local and df --type=TYPE, + test only the exit code. Don't bother with stdout. + Prompted by a report by Thomas Schwinge of an inaccurate diagnostic. + + * gl/lib/savewd.c: Remove this file, since the savewd_save change + is now in gnulib. The other wasn't useful. + +2007-03-20 Jim Meyering + + * gl/lib/acl.c: Remove this file, now that gnulib's version subsumes it. + + Skip part of this test when "." is not a local file system. + * tests/install/basic-1: Otherwise, it would fail on some NFS + file systems. + * tests/mkdir/p-3: Likewise. + +2007-03-19 Paul Eggert + + * src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): + Add $(LIB_ACL_TRIVIAL). + +2007-03-18 Jim Meyering + + Fix a generic NFS-related test failure. + * tests/mkdir/p-3: When setting up an unreadable "." in an + inaccessible parent, make the parent inaccessible *after* making "." + unreadable. Otherwise, running "chmod a-r ." in an already- + inaccessible parent would fail on NFS with "Stale NFS file handle". + + Fix a bug in how pr -m -s works. + * NEWS: Describe how the fix affects pr. + * src/pr.c (init_parameters): The --merge (-m) option does + not imply --expand-tabs (-e), so don't set "untabify_input". + Reported by Wis Macomson. + * tests/misc/pr: New file. Test for the above fix. + * tests/misc/Makefile.am (TESTS): Add pr. + * THANKS: Update. + +2007-03-17 Jim Meyering + + Detect use of AC_CONFIG_AUX_DIR also when its argument is quoted. + * bootstrap: Put ""s around use of $build_aux, in case + someone uses a name containing shell meta-characters. + Reported by Alfred M. Szmidt. + * tests/misc/tty-eof: Add shuf to the list of tested commands. + + Avoid test failure on NFS-mounted Solaris ZFS file system. + * tests/du/basic: Skip a test if "." is on a non-local file system. + + Avoid an obscure build failure, prefer waitpid over wait. + * src/install.c (strip): Use waitpid, not wait. It's equivalent, + but feels less obsolescent. + + * bootstrap: Don't use \> in grep regexp. For HP-UX. + +2007-03-16 Jim Meyering + + Begin adding support for Solaris ZFS (4 entries per trivial ACL) + * gl/lib/acl.c (ACL_NOT_WELL_SUPPORTED): New macro. + (file_has_acl, copy_acl): Use it, rather than enumerating errno values. + (is_trivial_acl): New function. Incomplete, for now. + (file_has_acl, copy_acl): Use the new function, rather than + counting the number of entries in an ACL. + + * bootstrap: Update from gnulib. + + * .x-sc_prohibit_atoi_atof: Add TODO here, too. + +2007-03-16 Paul Eggert + + * src/copy.c: Include filemode.h. + (overwrite_prompt): Say "try to overwrite", not "overwrite", to + make it clearer that the attempt may fail. Problem reported by + Dan Jacobson in: + http://lists.gnu.org/archive/html/bug-coreutils/2007-03/msg00130.html + Output symbolic mode as well as numeric. + * tests/mv/i-2 (fail): Adjust to new prompt format. + +2007-03-15 Jim Meyering + + Enforce policy: don't use *scanf functions. + * Makefile.maint (sc_prohibit_atoi_atof): Add to regexp and diagnostic. + * .x-sc_prohibit_atoi_atof: Give stty a temporary pass. + * TODO: note that stty.c needs this small clean-up. + +2007-03-13 Jim Meyering + + Prepare to work on ACL-related failure when using Solaris ZFS. + * gl/lib/acl.c: New file, copied from gnulib. + + Work around a failing test due to an NFS-based race condition. + * tests/cp/sparse: Accept a report that the copy is *smaller*. + +2007-03-12 Jim Meyering + + Make bootstrap.conf a tiny bit more generic. + * bootstrap.conf (XGETTEXT_OPTIONS): Exclude gettext-related .m4 + files when e.g., AM_GNU_GETTEXT([external] appears in configure.ac. + +2007-03-10 Jim Meyering + + Try to fix today's NFS-related failure: Treat ESTALE like EACCES. + * gl/lib/savewd.c: Copy this file from gnulib, then change + "errno != EACCES" to (errno != EACCES && errno != ESTALE). + The symptom was this failure in tests/install/basic-1: + ginstall: cannot create directory `rel/a': Stale NFS file handle + + The preceding change solved part of the problem. Now ginstall fails. + * tests/install/basic-1: Temporarily, don't redirect ginstall's + stderr to /dev/null, so I can see why the NFS autobuilder's NFS test + is failing. + + * tests/install/basic-1: When setting up an unreadable "." in an + inaccessible parent, make the parent inaccessible *after* making "." + unreadable. Otherwise, running "chmod a-r ." in an already- + inaccessible parent would fail on NFS with "Stale NFS file handle". + Reported by Bob Proulx. + + * Makefile.maint (po-check): Exclude c99-to-c89.diff. + +2007-03-09 Jim Meyering + + Avoid test failures on Darwin 7.9.0 (MacOS X 10.3.9) + * tests/chgrp/basic: Don't let failure by chgrp to set the + group of a symlink make this test fail. Do give a diagnostic. + In the chgrp-no-change-ctime test, add darwin7.9.0 as another + known-failing system. + When failing on some other system, print $host_triplet, too. + Also avoid test failures on Darwin 8.8.x (MacOS X 10.4). + Reported by Peter Fales. + +2007-03-08 Jim Meyering + + * src/c99-to-c89.diff: Reflect the new c99'ism, update offsets. + +2007-03-08 Paul Eggert + + rm without -f: give a better diagnostic when euidaccess fails. + * src/remove.c (write_protected_non_symlink): Return int, not bool, + so that we can indicate failure too (as a postive error number). + (prompt): If write_protected_non_symlink fails, report that error + number and fail rather than charging ahead and removing the dubious + entry. Redo the logic of printing a diagnostic so that we need to + invoke quote (full_filename (...)) only once. More details at: + + +2007-03-08 Jim Meyering + + Generalize a few more cvs-isms. + * bootstrap (checkout_only_file): Rename from CVS_only_file. + Change comments and diagnostics not to say "CVS". + + * bootstrap: Run libtool, if necessary. + + Make bootstrap a little more general. + * bootstrap (build_aux): Factor out/use this definition. + Formally require a "AC_CONFIG_AUX_DIR($build_aux)" line in configure.ac. + (insert_sorted_if_absent): Move function definition "up", to + precede new first use. + If $build_aux/ doesn't exist initially, create it, and + mark it as ignored. + +2007-03-03 Andrew Church (tiny change) + Paul Eggert + + Fix a bug: cp -x would fail to set mount point permissions. + * NEWS: mention cp -x bug fix + * src/copy.c (copy_internal): Don't return immediately after + copying a mount point that we do not intend to recurse under. + Based on a patch by Andrew Church. + +2007-03-03 Jim Meyering + + pwd-unreadable-parent: Skip test on ia64/Linux, too. + * tests/misc/pwd-unreadable-parent: Also skip when $REPLACE_GETCWD. + Reported by Bob Proulx. + +2007-03-02 Jim Meyering + + pwd-unreadable-parent: Skip test on non-Linux/GNU systems. + * tests/misc/pwd-unreadable-parent: Rather than trying to decide + whether this test has a chance of succeeding, run it only when + $(host_os) is linux-gnu. It was failing on powerpc-apple-darwin8.8.0 + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Add host_os=$(host_os). + + * tests/misc/pwd-long: Also allow "+" in $PWD. + + Remove another coreutils-ism. Formatting cleanup. + * Makefile.maint (my-distcheck): Update an outdated comment. + (emit_upload_commands): Use $(PACKAGE) rather than "coreutils". + (my-distcheck): Skip the c99/c89 check if there's no such .diff file. + +2007-03-01 Jim Meyering + + * Makefile.maint (warn_cflags): Hoist, adding "-Dlint -O". + (my-distcheck): Use the new variable, instead of too-long literal. + + Make "make syntax-check" rules less coreutils-specific. + * Makefile.maint (sc_cast_of_x_alloc_return_value): Use CVS_LIST_EXCEPT. + (sc_cast_of_alloca_return_value): Likewise. + (sc_root_tests): Do nothing if there is no check-root target + in tests/Makefile.am. + + Run the writable-files check only for release-building targets. + * Makefile.maint (local-checks-available): Remove writable-files. + (alpha beta major): Put it here, instead. + + "make syntax-check" now runs only Makefile.cfg-selected tests + * Makefile.maint (syntax-check-rules): Hoist this definition so that + it precedes the indirect use in the definition of $(local-check). + (local-check): Use :=, not just "=". + (syntax-check): Depend on $(local-check), not $(syntax-check-rules). + +2007-02-28 Bruno Haible + + * bootstrap.conf (gnulib_modules): Replace xreadlink with + xreadlink-with-size. Add xreadlink. + * src/copy.c (copy_internal): Update. + * src/ls.c (is_directory): Update. + * src/stat.c (print_stat): Update. + * src/readlink.c (main): Use the one-argument xreadlink function. + +2007-02-28 Paul Eggert + + * doc/coreutils.texi (Common options): --si outputs "M", not "MB". + Problem reported by Philip Rowlands in + . + +2007-02-28 Jim Meyering + + * .x-sc_file_system: Add the new test, tests/misc/df-P, to this + list of exceptions, for the "make distcheck" sc_file_system rule. + + * Makefile.maint (gnulib_snapshot_date): Remove now-unused definition. + +2007-02-27 Paul Eggert + + Make df -P immune to effects of e.g., the BLOCK_SIZE envvar. + * NEWS: With -P, the default block size and output format is not + affected by DF_BLOCK_SIZE, BLOCK_SIZE, or BLOCKSIZE. + * src/df.c (main): Implement this. + +2007-02-27 Jim Meyering + + Add a test for the above. + * tests/misc/df-P: New file. + * tests/misc/Makefile.am (TESTS): Add df-P. + +2007-02-25 Jim Meyering + + * Makefile.maint (announcement): Adjust so that it works with + announce-gen's --gnulib-snapshot-time-stamp option. + Indent one of the command lines using TAB, not 8 spaces. + + Post-release version change. + * NEWS: Add a line for 6.8+. + * configure.ac (AC_INIT): Set new version string. + +2007-02-24 Jim Meyering + + Version 6.8. + * NEWS: Record release date and new version number. + * configure.ac (AC_INIT): New version number. + + Don't skip this test on new-enough Linux/GNU systems. + * tests/misc/pwd-unreadable-parent: Test $REPLACE_GETCWD = 0, + rather than for __GETCWD_PREFIX in config.h (the latter is no + longer defined, ever, due to gnulib changes). + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define REPLACE_GETCWD. + + Remove the "gnits" option; it prohibits my using "+" as a version + string suffix, and all it does (beyond the default "gnu" option) + is to _require_ the THANKS file. + * configure.ac (AM_INIT_AUTOMAKE): Remove it. + + Remove all AUTOMAKE_OPTIONS settings in Makefile.am files. + * tests/chgrp/Makefile.am, tests/chmod/Makefile.am: + * tests/chown/Makefile.am, tests/cp/Makefile.am: + * tests/du/Makefile.am, tests/expr/Makefile.am: + * tests/factor/Makefile.am, tests/general/Makefile.am: + * tests/install/Makefile.am, tests/ln/Makefile.am: + * tests/ls/Makefile.am, tests/mkdir/Makefile.am: + * tests/mv/Makefile.am, tests/readlink/Makefile.am: + * tests/rm/Makefile.am, tests/rmdir/Makefile.am: + * tests/seq/Makefile.am, tests/stty/Makefile.am: + * tests/tee/Makefile.am, tests/touch/Makefile.am: + + * README: Document the OSF/1 4.0d build failure and work-around. + Reported by Bruno Haible. + + * NEWS: Use a simple "+" suffix to denote pre-release, not "-dirty". + Nicer connotations. + * configure.ac: Use 6.7+, not 6.7-dirty. + +2007-02-24 Paul Eggert + + * NEWS: sort no longer compresses temporaries by default. + * bootstrap.conf: Remove findprog. + * doc/coreutils.texi (sort invocation): The default is to not + compress. Don't treat "" specially. + * src/sort.c: Don't include findprog.h. + (create_temp): Compress only if the user specified --compress-program. + * tests/misc/sort-compress: Adjusts tests to match new behavior. + +2007-02-24 Jim Meyering + + Avoid a shell syntax error, when building with an inadequate Perl. + * man/Makefile.am (.x.1): Add quotes around $(PERL) in case, since + it can expand to "/.../missing perl". + + * man/Makefile.am (.x.1): Warn when unable to update a man page. + Suggestion from Bruno Haible. + +2007-02-23 Bruno Haible + + Handle better the combination of old Perl and a pre-c99 compiler. + * man/Makefile.am (.x.1): If the autoconf test has determined that + perl is missing or not a sufficient version, do nothing. + + * tests/readlink/can-e: Put the closing double-quote at the end of a + backquoted word, not in the middle. Works around a bug in sh on + OSF/1 4.0d. + * tests/readlink/can-f: Likewise. + * tests/readlink/can-m: Likewise. + + * tests/du/slink: Skip the test if executing on an nfsv3 file system. + This avoids a test failure at least on OSF/1 4.0d. + +2007-02-23 Jim Meyering + + * src/date.c (usage): Split a diagnostic that had grown to be + longer than the C89 maximum of 509 bytes. + +2007-02-23 Ed Santiago + + * src/date.c (usage): Mention that --rfc-3339 uses space, not 'T', + for a separator. Include sample RFC 2822 and 3339 output. + +2007-02-23 Jim Meyering + + With -Dlint, make shuf free all heap-allocated storage. + * src/shuf.c (main): Move declaration of input_lines to + function scope, and initialize to NULL, so we can free it. + [lint]: Free all malloc'd memory. + * tests/misc/shuf: Also test shuf's -e and -i options. + +2007-02-22 Jim Meyering + + Merge in a change from some other incarnation of this file (gzip?) + * bootstrap (gnulib_tool): Skip get_translations if there is no po/ dir. + + Adjust preceding change not to perform an unaligned access. + * src/copy.c (copy_reg): Undo previous change. Instead, make + it clearer that we're using a single-byte sentinel, and + [lint]: Initialize sizeof (uintptr_t) - 1 bytes after the sentinel. + Reported by Andreas Schwab. + + Placate valgrind, wrt ./cp --sparse=always + * src/copy.c (copy_reg): Place the sentinel by setting a + full word's worth of bits, not just a single byte's worth. + This avoids a harmless (but distracting) case of memory being + used-uninitialized. + +2007-02-21 Paul Eggert + + Honor dd's noatime flag if possible, even if not supported on build fs + * doc/coreutils.texi (dd invocation): Warn that noatime might not be + reliable. + * src/dd.c (flags, usage): Look at O_NOATIME, not + HAVE_WORKING_O_NOATIME, to decide whether to support the noatime + flag, so that dd attempts O_NOATIME even if the build file system + does not support it. Problem reported by Jim Meyering today in + bug-coreutils. + * tests/dd/misc: Generate a warning, not a failure, if noatime + exists but fails. + +2007-02-21 Jim Meyering + + * tests/misc/date: Remove vestigial use of Data::Dumper. + +2007-02-20 Paul Eggert + + * src/copy.c (cached_umask): Cast -1 to mode_t to avoid a warning + about out-of-range initializer with Sun C 5.8. + +2007-02-20 Jim Meyering + + * bootstrap (CVS_only_file): Use README-hacking. + + Now that we use GIT, not cvs, rename README-cvs. + * README-hacking: Renamed from... + Update to reflect that we now use git. + + * README-cvs: ...this. + + * src/env.c (main): When invoked with no arguments (i.e. when printing + the environment), use a local variable to iterate through the global + "environ" array, rather than "environ" itself. This is solely to + avoid changing the environment for an LD_PRELOAD-substituted "puts" + or "exit" function. Tiny patch by Harvey Eneman. See + . + * THANKS: Update. + + * bootstrap: Move definitions of temporary directory names and the + new bt_regex "up" to precede all uses, so it's clearer what their + scope is. Also, use [.], rather than \\., since the former works + even if eval'd. + + * bootstrap: Remove occurrences of $bt (._bootmp) from lib/Makefile. + Based on the bison 2007-02-19 change by Joel E. Denny. + +2007-02-19 Paul Eggert + + * NEWS: sort now uses a --compress-program option rather than + an environment variable. + * doc/coreutils.texi (sort invocation): Document this. + * src/sort.c (usage): Likewise. + (COMPRESS_PROGRAM_OPTION): New const. + (long_options, create_temp, main): Support new option. + * tests/misc/sort-compress: Test it. + +2007-02-19 Jim Meyering + + * bootstrap: Fix typo s/dowloading/downloading/ in --help output. + +2007-02-18 Jim Meyering + + * src/system.h: Don't include exit.h, now that it's subsumed + by the gnulib-generated stdlib.h. + + * tests/rm/fail-eacces: Skip this test when running as root. + Reported by Matthew Woehlke. + + * bootstrap: Use "._bootmp" as the temporary directory name, + not ".#bootmp". The latter's "#" caused trouble with the new, + gnulib-added "LINK_WARNING_H = $(top_srcdir)/.#bootmp/..." line. + +2007-02-14 Paul Eggert + + * bootstrap.conf (gnulib_modules): Add c-strcase. Remove strcase. + * src/dircolors.c: Include c-strcase.h. + (dc_parse_stream): Use c_strcasecmp rather than + strcasecmp to avoid unreliable results in locales like Turkish + where strcasecmp is incompatible with the C locale. + +2007-02-13 Jim Meyering + + Also check for and print stderr output, in case a program fails. + * tests/misc/tty-eof: Occasionally (not reproducible), this + test would fail, with one or more programs exiting nonzero, e.g., + tty-eof: sha224sum exited with status 1 (expected 0) + Now, maybe we'll get a clue, the next time that happens. + +2007-02-12 Jim Meyering + + * .x-sc_useless_cpp_parens: Ignore a false-positive in a shell script. + + * tests/misc/pwd-unreadable-parent: Skip the test if we're + definitely using the replacement. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define CONFIG_HEADER. + +2007-02-10 Jim Meyering + + Remove excess leading spaces that would make help2man misbehave. + * src/printf.c (usage): Remove excess spaces on 2nd line of %b desc. + * src/nl.c (usage): Remove excess spaces on 2nd line of pBRE desc. + * src/dd.c (usage): Remove excess spaces on 2nd line of sync desc. + * src/date.c (usage): Use two spaces after each optional flag, not one. + Reported by Thomas Huriaux in . + + * Makefile.maint (longopt_re): Relax the regexp, making square + brackets optional, so it matches the newly reported violations, too. + + * src/csplit.c (usage): Use two spaces (not one) to separate + each option string from its description, so help2man formats + the derived man page properly. Reported by Thomas Huriaux in + . + * src/df.c (usage): Likewise. + * src/du.c (usage): Likewise. + * src/install.c (usage): Likewise. + * src/ls.c (usage): Likewise. + +2007-02-03 Jim Meyering + + Test for today's gnulib/lib/getcwd.c fix affecting pwd and readlink + * NEWS: Mention the bug fix. + * tests/misc/pwd-unreadable-parent: New file. + * tests/misc/Makefile.am (TESTS): Ad pwd-unreadable-parent. + +2007-02-02 Paul Eggert + + * NEWS: Document fix for cp --preserve=mode. + * src/copy.c (copy_internal): Omit the group- or other-writeable + permissions when creating a directory, to avoid a race condition + if the special mode bits aren't right just after the directory is + created. + * src/cp.c (make_dir_parents_private): Likewise. + * tests/cp/parent-perm-race: Test for the "cp --preserve=mode" + race fix in copy.c. + + * NEWS: Document fix for cp --parents. + * src/cp.c (make_dir_parents_private): Report the error sooner with + "cp --parents DIR/FILE DEST" when DIR is a non-directory, thus not + creating the directory, DEST/DIR. + * tests/cp/cp-parents: Test for the non-race-condition bug fixed + by the above change. + +2007-02-02 Jim Meyering + + * src/nl.c (proc_text): Use "NULL", not "(struct re_registers *) 0". + + * src/c99-to-c89.diff: Make shred.c Index: and a/b prefixes + consistent, so this can be applied with patch -p0. + Reported by Matthew Woehlke. + + * Makefile.maint (patch-check): Use patch with its -p2 option, + since that makes this check slightly more strict. + +2007-01-29 Jim Meyering + + Plug a leak in ls. + * src/ls.c (print_dir): Don't leak a "DIR"+fd upon failure to + determine dev/inode or upon detecting a symlink loop. + + * src/ls.c: Rename three global variables. + (cwd_file): Rename from 'files'. + (cwd_n_alloc): Rename from 'nfiles'. + (cwd_n_used): Rename from 'files_index'. + + Shave 8 bytes off the size of "struct fileinfo". + * src/ls.c (fileinfo): Put all members of type "bool" together. + +2007-01-28 Paul Eggert + + Modify "ls" to sort its data faster, using the new gnulib mpsort + module rather than qsort. This is particularly a win in + environments where strcoll is slow, since mpsort typically calls + strcoll less often than qsort does. + * bootstrap.conf (gnulib_modules): Add mpsort. + * src/ls.c: Include mpsort.h. + (sorted_file, sorted_file_alloc): New vars, for a new vector of + pointers to the file info, for speed. + (clear_files, extract_dirs_from_files, sort_files, print_current_files): + (print_many_per_line, print_horizontal, print_with_commas): + (calculate_columns): Set and use new vector. + (initialize_ordering_vector): New function. + +2007-01-26 Paul Eggert + + Adjust to today's change to gnulib, which added a module for + string.h to replace the little include files like strcase.h. + * src/dircolors.c: Don't include strcase.h. + * src/system.h: Don't include mempcpy.h, memrchr.h, stpcpy.h, strpbrk.h. + +2007-01-26 Jim Meyering + + * src/dd.c (advance_input_after_read_error): Change diagnostic to + say "invalid file offset" rather than "screwy file offset". + + * .x-sc_cast_of_argument_to_free: Remove this file. + * Makefile.am (EXTRA_DIST): Likewise. + +2007-01-25 Dan Hipschman + + * src/sort.c (create_temp): Remove superfluous access-X_OK + check. find_in_path does this for us. + +2007-01-24 Jim Meyering + + Remove usually-skipped test. + * tests/cp/open-perm-race: Remove this file. It is subsumed + by parent-perm-race. + * tests/cp/Makefile.am (TESTS): Remove open-perm-race. + * tests/sort/Makefile.am: Regenerate. + + Pass "make distcheck" again. + * src/sort.c (usage): Split a diagnostic that had grown to be + longer than the C89 maximum of 509 bytes. + * .x-sc_cast_of_argument_to_free: New file. Allow a cast in sort.c. + FIXME: this is just temporary, while we wait to remove the offending + access-calling code. + * Makefile.am (EXTRA_DIST): Add .x-sc_cast_of_argument_to_free. + * Makefile.maint (sc_cast_of_argument_to_free): Use the + canonical, $$($(CVS_LIST_EXCEPT)). + * m4/.gitignore, m4/.cvsignore, lib/.gitignore, lib/.cvsignore: Update. + +2007-01-24 Paul Eggert + + * NEWS: New option sort -C, proposed by XCU ERN 127, which looks + like it will be approved. Also add --check=quiet, --check=silent + as long aliases, and --check=diagnose-first as an alias for -c. + * doc/coreutils.texi (sort invocation): Document this. + Also, mention that sort -c can take at most one file. + * src/sort.c: Implement this. + Include argmatch.h. + (usage): Document the change. + (CHECK_OPTION): New constant. + (long_options): --check now takes an optional argument, and is now + treated differently from 'c'. + (check_args, check_types): New constant arrays. + (check): New arg CHECKONLY, which suppresses diagnostic if -C. + (main): Parse the new options. + * tests/sort/Test.pm (02d, 02d, incompat5, incompat6): + New tests for -C. + +2007-01-24 Jim Meyering + + Fix a typo. + * tests/misc/sort-compress: Use $abs_top_builddir, not $top_builddir. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Likewise. + + Don't depend on "which". + * tests/misc/sort-compress (SORT): Use $abs_builddir, now which. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Export top_builddir. + +2007-01-24 Dan Hipschman + + Test sort compression. + * tests/misc/Makefile.am: Add the test. + * tests/misc/sort-compress: New file containing the tests. + +2007-01-24 Jim Meyering + + * NEWS: sort temp file compression: tweak wording. + * src/sort.c (struct sortfile) [name]: Declare member to be const. + +2007-01-21 Jim Meyering + + * src/sort.c (MAX_FORK_RETRIES_COMPRESS, MAX_FORK_RETRIES_DECOMPRESS): + In pipe_fork callers, use these named constants, not "2" and "8". + (proctab, nprocs): Declare to be "static". + (pipe_fork) [lint]: Initialize local, pid, + to avoid unwarranted may-be-used-uninitialized warning. + (create_temp): Use the active voice. Describe parameters, too. + +2007-01-21 James Youngman + + Centralize all the uses of sigprocmask(). Don't restore an invalid + saved mask. + * src/sort.c (enter_cs, leave_cs): New functions for protecting + code sequences against signal delivery. + * (exit_cleanup): Use enter_cs and leave_cs instead of + calling sigprocmask directly. + (create_temp_file, pipe_fork, zaptemp): Likewise + +2007-01-21 Dan Hipschman + + Add compression of temp files to sort. + * NEWS: Mention this. + * bootstrap.conf: Import findprog. + * configure.ac: Add AC_FUNC_FORK. + * doc/coreutils.texi: Document GNUSORT_COMPRESSOR environment + variable. + * src/sort.c (compress_program): New global, holds the name of the + external compression program. + (struct sortfile): New type used by mergepfs and friends instead + of filenames to hold PIDs of compressor processes. + (proctab): New global, holds compressor PIDs on which to wait. + (enum procstate, struct procnode): New types used by proctab. + (proctab_hasher, proctab_comparator): New functions for proctab. + (nprocs): New global, number of forked but unreaped children. + (reap, reap_some): New function, wait for/cleanup forked processes. + (register_proc, update_proc, wait_proc): New functions for adding, + modifying and removing proctab entries. + (create_temp_file): Change parameter type to pointer to file + descriptor, and return type to pointer to struct tempnode. + (dup2_or_die): New function used in create_temp and open_temp. + (pipe_fork): New function, creates a pipe and child process. + (create_temp): Creates a temp file and possibly a compression + program to which we filter output. + (open_temp): Opens a compressed temp file and creates a + decompression process through which to filter the input. + (mergefps): Change FILES parameter type to struct sortfile array + and update access accordingly. Use open_temp and reap_some. + (avoid_trashing_input, merge): Change FILES parameter like + mergefps and call create_temp instead of create_temp_file. + (sort): Call create_temp instead of create_temp_file. + Use reap_some. + (avoid_trashing_input, merge, sort, main): Adapt to mergefps. + + The idea of compressing sorts temporary files was first + suggested/implemented by Jay Soffian in 1998, and again + by Charles Randall in 2001. + +2007-01-20 Jim Meyering + + * tests/misc/pwd-long: Work properly even when run from the + wrong one of two or more bind-mounted sibling directories. + Suggestion from Mike Stone in . + +2007-01-20 Paul Eggert + + Standardize on list of signals when an app catches signals. + * src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL, + SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ. + * src/ls.c (main): Likewise (except SIGPIPE was already caught). + Note that ls.c is special, as it also catches SIGTSTP. + * src/sort.c (main): Likewise. Also catch SIGQUIT. More details in + . + +2007-01-19 Dan Hipschman + and Paul Eggert + + * src/sort.c (cleanup): Clear temphead at the end. + (exit_cleanup): New function. + (main): Don't invoke atexit until we're ready. + Invoke it with exit_cleanup, not with cleanup and close_stdout, + to avoid a race condition with cleanup and signal handling. More + details: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9508 + +2007-01-18 Jim Meyering + + * src/c99-to-c89.diff: Adjust remove.c offsets. + +2007-01-17 Jim Meyering + + Make "rm --interactive=never ..." never prompt. + * NEWS: Mention this. + * src/remove.h (enum rm_interactive): New ternary type. + (struct rm_options) [interactive]: Use it, here -- rather than bool. + * src/remove.c (prompt): Reflect type change. + * src/mv.c (rm_option_init): Initialize to RMI_NEVER now. + * src/rm.c (main): Add a FIXME comment for '-d' option. + Adapt to type change of rm_options.interactive. + + * tests/rm/i-never: New file. Test for the above fix. + * tests/rm/Makefile.am (TESTS): Add i-never. + +2007-01-15 Jim Meyering + + * bootstrap (gnulib_tool): When adding to .cvsignore and .gitignore, + emit foo.h, for each foo_.h. This yields one false-positive, fts.h, + but that's ok, since fts_.h will eventually be renamed. + + * src/remove.c (remove_dir): Don't use errno in diagnostic. + Root-only test failure reported by Alex van Hout and Jon Grosshart in + . + + * bootstrap.conf (avoided_gnulib_modules): Fix my typo: + s/--avoid=canonicalize-lgpl/--avoid=canonicalize-gpl/ + +2007-01-14 Bruno Haible + + Enable use of gnulib's new fchdir module. + * bootstrap.conf (avoided_gnulib_modules): Avoid canonicalize-lgpl, + since we use canonicalize. + (gnulib_modules): Add fchdir. + * m4/jm-macros.m4 (coreutils_MACROS): Remove fchdir-stub. + +2007-01-13 Jim Meyering + + * Transform all Makefile.am files so that when running "make check", + CU_TEST_NAME is set to the name of the test. This is so that when I + run valgrind-enabled (--log-file-qualifier=CU_TEST_NAME) "make check" + on the entire package it is more convenient to map a leak or error + found in a valgrind log file back to the offending test. + Use this command: + (echo tests/Makefile.am.in; find tests -name Makefile.am) \ + |xargs perl -pi -e '/^(\s*)PATH=...VG_PATH_PREFIX/ and ' \ + -e 'print $1,q|CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst |,"\\\n"' + +2007-01-11 Jim Meyering + + Avoid a leak in expr's implementation of the ":" (match) operator. + * src/expr.c (docolon): Free the regexp buffer using regfree, rather + than doing it manually, being careful to set fastmap to NULL first. + Free any re_regs.start and .end members, if necessary. + + * tests/misc/test-diag: Work also when libc's error function + reports the entire program name ("../../src/test"), rather than + just the final component. + +2007-01-10 Jim Meyering + + Don't use fts_statp uninitialized for "chown -RLh --preserve-root ...". + * src/chown-core.c (FTSENT_IS_DIRECTORY): New macro. + (change_file_owner): Perform the ROOT_DEV_INO_CHECK only for a + directory. Non-directory entries lack fts_statp data when using + the FTS_NOSTAT option. + +2007-01-07 Jim Meyering + + * tests/sample-test: Update copyright date to 2007. + * Makefile.maint (copyright-check): Also check the copyright date + in tests/sample-test. + +2007-01-06 Jim Meyering + + * tests/fmt/basic (pfx-only, pfx-of-pfx): New tests, + based on examples from G.P. Halkes in + . + +2007-01-06 G.P. Halkes + + * src/fmt.c (copy_rest): Correct prefix handling. + Don't elide a line with the prefix followed by only white space. + (get_line): Move EOF-check to loop-termination condition. + * tests/fmt/basic (pfx-1): Adjust test to expect desired result. + (pfx-2): Remove test; its premise was contrary to the documentation. + +2007-01-05 Jim Meyering + + Avoid a used-uninitialized bug for invalid input, i.e., when the size + of the input, not counting newlines, is 1 % 4. + * gl/lib/base64.c (base64_decode): Don't hard-code inlen==4. + It may be smaller when flushing. + +2007-01-05 Mike Frysinger + + * src/dircolors.hin: Add a TERM directive for cons25. + +2007-01-04 Jim Meyering + + * Makefile.cfg (local-checks-to-skip): Skip strftime-check, in + case you don't have convenient access to glibc info documentation. + + Use the release year, not the current year. + * src/groups.sh (version): Use a better name: @RELEASE_YEAR at . + * src/Makefile.am (RELEASE_YEAR): Define it. + (.sh): Use it. + Thanks to a prod from Eric Blake. + + Ensure that "group --version" always prints the current year. + * src/groups.sh (version): Use @CURRENT_YEAR@, rather than 2006. + * src/Makefile.am (.sh): Also substitute for @CURRENT_YEAR at . + Suggestion from Eric Blake. + + When decoding, always allow newlines in input, with almost no + performance impact. + * src/base64.c (do_decode): Initialize decode context. + Call base64_decode one more time, after all input is processed. + (usage): When decoding, newlines are always accepted. + + * tests/misc/base64: Add a bunch of tests, for the above. + * gl/lib/base64.c: Include . + (base64_decode_ctx_init, get_4, decode_4): New functions. + (base64_decode): Efficiently handle interspersed newlines. + (base64_decode_alloc): Update signature. + * gl/lib/base64.h (struct base64_decode_context): Define. + (base64_decode_ctx_init): Add prototype. + (base64_decode, base64_decode_alloc): Update prototypes. + + * gl/lib/base64.c: Copied from gnulib. + * gl/lib/base64.h: Likewise. + +2007-01-03 Jim Meyering + + * THANKS: Add Evan Hunt. + +2007-01-03 Bruno Haible + + Avoid spurious test failures on MacOS X 10.3.9, in a German locale. + * tests/chown/deref: Apply lang-default. + * tests/misc/split-a: Likewise. + * tests/mv/reply-no: Likewise. + + * src/copy.c (copy_internal): Use mkfifo as a fallback if mknod fails. + Needed on MacOS X. + +2007-01-02 Paul Eggert + + Now, "ls -FRL" always follows symbolic links on Linux. + * NEWS: Mention this bug fix. + * src/ls.c (gobble_file): Fix bug reported by + Nobuyuki Tsuchimura in + http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00152.html + where "ls -FRL" didn't follow a symbolic link in some cases on Linux. + * tests/ls/follow-slink: Add a test for this case. + +2007-01-01 Jim Meyering + + * tests/rm/fail-eperm: Revert last change. The PATH=... setting + is not honored at least on HP-UX 11.23 systems. + Instead, simply transform the actual output diagnostic. + Test failure reported by Bob Proulx. + +2006-12-30 Jim Meyering + + * bootstrap (gnulib_extra_files): Remove announce-gen. + * bootstrap.conf (gnulib_modules): Add it here instead, now that + it's a module. + + * tests/misc/base64: Factor a long, repetitive string. + + * src/c99-to-c89.diff: Adjust remove.c offsets. + + Clean up after the change of 2006-12-28. + * src/remove.c (AD_pop_and_chdir): Change **DIRP parameter to *DIRP, + now that this function never modifies the pointer. Adjust comments + and code accordingly. + (remove_dir): Set "dirp" to NULL right after AD_pop_and_chdir call, + now that AD_pop_and_chdir no longer does that. + + * tests/rm/fail-eperm: Avoid spurious differences (the error function + from latest glibc no longer prints the full program_name): so don't + invoke rm via ../../src/rm. Instead, invoke it via "PATH=../../src rm". + + * tests/mv/acl (skip): Skip this test also if the destination + directory, which is on a different file system, lacks ACL support. + + * src/copy.c (copy_reg): Rewrite a comment that was rendered + inaccurate by the 2006-10-18 change. + +2006-12-28 Jim Meyering + + When moving "up" the hierarchy, be careful to remove a just-emptied + directory before opening ".", to avoid trouble with file system + implementations that cache readdir results at opendir-time. + * src/remove.c (AD_pop_and_chdir): Add a file descriptor parameter. + Don't update **DIRP. Don't call fdopendir here. + (remove_dir): Call fdopendir here instead. + Report and patch from Mikulas Patocka: + + +2006-12-27 Jim Meyering + + * src/tail.c (usage): Mention +N for --bytes and --lines. + Suggestion from Evan Hunt. + +2006-12-26 Jim Meyering + + * configure.ac: Require autoconf-2.61 and automake-1.10. + Without the former (even with autoconf-2.60), "make distcheck" + would fail (without the 2006-09-26 autoconf AC_CHECK_DECL fix), + due to an inttypes.h generated with CFLAGS including -pedantic. + With the old decl check, @HAVE_DECL_STRTOUMAX@ would be 0. + + * Makefile.maint (VC-tag): Define, so as to gpg-sign each release + tag, using the release version number as the message. + (vc-dist): Use $(VC-tag), rather than "$(VC) tag". + +2006-12-21 Paul Eggert + + * NEWS: dd bs= operands now silently override later ibs= and obs=, + as POSIX requires. + * src/dd.c (scanargs): Implement it. + * tests/dd/misc (outbytes): Test it. + * doc/coreutils.texi (dd invocation): Specify that bs=N + overrides later ibs and obs, undoing part of the + previous change. (The behavior was wrong.) + +2006-12-20 Jim Meyering + + "rm -rf /etc/motd" (run by non-root) now prints a diagnostic. + * src/remove.c (remove_entry): Handle EACCES for a non-directory, too. + Don't let a non-directory get by with errno == EPERM, either. + Check the file type directly (using cached stat value), rather + than trying to guess it from errno values. + Karl Berry reported that a cross-partition "mv /etc/issue ~" + failed with the um,... suboptimal diagnostic, + "mv: cannot remove `/etc/issue': Not a directory". + * tests/rm/Makefile.am (TESTS): Add fail-eacces. + * tests/rm/fail-eacces: New file. + * NEWS: Mention that both mv and rm are affected. + + "cut -f 2- A B" no longer triggers a double-free bug + * src/cut.c (cut_fields): Set file-scoped global to NULL after + freeing it. This avoids a double-free (and core dump on some systems) + for this usage: "echo 1>a; echo 2>b; cut -f2- a b". Reported by + James Hunt in . + * NEWS: List this bug fix. + * THANKS: Mention him. + * tests/misc/cut: New file. + * tests/misc/Makefile.am (TESTS): Add cut. + +2006-12-15 Jim Meyering + + * tests/cp/open-perm-race: Correct the gdb-existence check. + Don't run either subsequent gdb command in a sub-shell. + Reported by Thomas Schwinge. + * THANKS: bring up to date. + +2006-12-14 Paul Eggert + + Make sure cp -p isn't too generous with file permissions. + * tests/cp/Makefile.am (TESTS): Add file-perm-race. + * tests/cp/file-perm-race: New file. + [... truncated: 67189 lines follow ...] From korli at mail.berlios.de Sun Dec 16 19:31:06 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 19:31:06 +0100 Subject: [Haiku-commits] r23130 - haiku/vendor/coreutils Message-ID: <200712161831.lBGIV6VO028782@sheep.berlios.de> Author: korli Date: 2007-12-16 19:31:05 +0100 (Sun, 16 Dec 2007) New Revision: 23130 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23130&view=rev Added: haiku/vendor/coreutils/6.9/ Log: tagging coreutils-6.9 Copied: haiku/vendor/coreutils/6.9 (from rev 23129, haiku/vendor/coreutils/current) From korli at mail.berlios.de Sun Dec 16 19:34:12 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 19:34:12 +0100 Subject: [Haiku-commits] r23131 - in haiku/trunk/src/bin/coreutils: . doc lib man src Message-ID: <200712161834.lBGIYCtA028970@sheep.berlios.de> Author: korli Date: 2007-12-16 19:32:10 +0100 (Sun, 16 Dec 2007) New Revision: 23131 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23131&view=rev Added: haiku/trunk/src/bin/coreutils/lib/acl-internal.h haiku/trunk/src/bin/coreutils/lib/acl_entries.c haiku/trunk/src/bin/coreutils/lib/c-ctype.c haiku/trunk/src/bin/coreutils/lib/c-ctype.h haiku/trunk/src/bin/coreutils/lib/c-strcase.h haiku/trunk/src/bin/coreutils/lib/c-strcasecmp.c haiku/trunk/src/bin/coreutils/lib/c-strncasecmp.c haiku/trunk/src/bin/coreutils/lib/dirent_.h haiku/trunk/src/bin/coreutils/lib/fchdir.c haiku/trunk/src/bin/coreutils/lib/fchownat.c haiku/trunk/src/bin/coreutils/lib/file-has-acl.c haiku/trunk/src/bin/coreutils/lib/mbscasecmp.c haiku/trunk/src/bin/coreutils/lib/mpsort.c haiku/trunk/src/bin/coreutils/lib/mpsort.h haiku/trunk/src/bin/coreutils/lib/netinet_in_.h haiku/trunk/src/bin/coreutils/lib/stdio_.h haiku/trunk/src/bin/coreutils/lib/stdlib_.h haiku/trunk/src/bin/coreutils/lib/string_.h haiku/trunk/src/bin/coreutils/lib/sys_time_.h haiku/trunk/src/bin/coreutils/lib/time_.h haiku/trunk/src/bin/coreutils/lib/unistd_.h haiku/trunk/src/bin/coreutils/lib/wchar_.h haiku/trunk/src/bin/coreutils/lib/wctype_.h haiku/trunk/src/bin/coreutils/lib/xreadlink-with-size.c Removed: haiku/trunk/src/bin/coreutils/lib/exit.h haiku/trunk/src/bin/coreutils/lib/fchdir-stub.c haiku/trunk/src/bin/coreutils/lib/getcwd.h haiku/trunk/src/bin/coreutils/lib/mempcpy.h haiku/trunk/src/bin/coreutils/lib/memrchr.h haiku/trunk/src/bin/coreutils/lib/mkstemp.h haiku/trunk/src/bin/coreutils/lib/snprintf.h haiku/trunk/src/bin/coreutils/lib/stpcpy.h haiku/trunk/src/bin/coreutils/lib/strcase.h haiku/trunk/src/bin/coreutils/lib/strcasecmp.c haiku/trunk/src/bin/coreutils/lib/strdup.h haiku/trunk/src/bin/coreutils/lib/strncasecmp.c haiku/trunk/src/bin/coreutils/lib/strndup.h haiku/trunk/src/bin/coreutils/lib/strnlen.h haiku/trunk/src/bin/coreutils/lib/strpbrk.h haiku/trunk/src/bin/coreutils/lib/time_r.h Modified: haiku/trunk/src/bin/coreutils/ChangeLog haiku/trunk/src/bin/coreutils/Makefile.am haiku/trunk/src/bin/coreutils/Makefile.cfg haiku/trunk/src/bin/coreutils/Makefile.in haiku/trunk/src/bin/coreutils/Makefile.maint haiku/trunk/src/bin/coreutils/NEWS haiku/trunk/src/bin/coreutils/README haiku/trunk/src/bin/coreutils/THANKS haiku/trunk/src/bin/coreutils/TODO haiku/trunk/src/bin/coreutils/aclocal.m4 haiku/trunk/src/bin/coreutils/bootstrap haiku/trunk/src/bin/coreutils/bootstrap.conf haiku/trunk/src/bin/coreutils/configure haiku/trunk/src/bin/coreutils/configure.ac haiku/trunk/src/bin/coreutils/doc/ChangeLog haiku/trunk/src/bin/coreutils/doc/Makefile.in haiku/trunk/src/bin/coreutils/doc/coreutils.info haiku/trunk/src/bin/coreutils/doc/coreutils.texi haiku/trunk/src/bin/coreutils/doc/stamp-vti haiku/trunk/src/bin/coreutils/doc/version.texi haiku/trunk/src/bin/coreutils/lib/ChangeLog haiku/trunk/src/bin/coreutils/lib/Jamfile haiku/trunk/src/bin/coreutils/lib/Makefile.in haiku/trunk/src/bin/coreutils/lib/acl.c haiku/trunk/src/bin/coreutils/lib/acl.h haiku/trunk/src/bin/coreutils/lib/allocsa.h haiku/trunk/src/bin/coreutils/lib/argmatch.c haiku/trunk/src/bin/coreutils/lib/backupfile.c haiku/trunk/src/bin/coreutils/lib/base64.c haiku/trunk/src/bin/coreutils/lib/base64.h haiku/trunk/src/bin/coreutils/lib/canon-host.c haiku/trunk/src/bin/coreutils/lib/canonicalize.c haiku/trunk/src/bin/coreutils/lib/canonicalize.h haiku/trunk/src/bin/coreutils/lib/chdir-long.c haiku/trunk/src/bin/coreutils/lib/chown.c haiku/trunk/src/bin/coreutils/lib/config.h haiku/trunk/src/bin/coreutils/lib/config.hin haiku/trunk/src/bin/coreutils/lib/dirname.h haiku/trunk/src/bin/coreutils/lib/dup-safer.c haiku/trunk/src/bin/coreutils/lib/dup2.c haiku/trunk/src/bin/coreutils/lib/exclude.c haiku/trunk/src/bin/coreutils/lib/exitfail.c haiku/trunk/src/bin/coreutils/lib/fcntl_.h haiku/trunk/src/bin/coreutils/lib/fnmatch.c haiku/trunk/src/bin/coreutils/lib/fnmatch_.h haiku/trunk/src/bin/coreutils/lib/fnmatch_loop.c haiku/trunk/src/bin/coreutils/lib/fsusage.c haiku/trunk/src/bin/coreutils/lib/ftruncate.c haiku/trunk/src/bin/coreutils/lib/fts.c haiku/trunk/src/bin/coreutils/lib/fts_.h haiku/trunk/src/bin/coreutils/lib/gai_strerror.c haiku/trunk/src/bin/coreutils/lib/getaddrinfo.c haiku/trunk/src/bin/coreutils/lib/getcwd.c haiku/trunk/src/bin/coreutils/lib/getdate.c haiku/trunk/src/bin/coreutils/lib/getdate.h haiku/trunk/src/bin/coreutils/lib/getdate.y haiku/trunk/src/bin/coreutils/lib/gethrxtime.c haiku/trunk/src/bin/coreutils/lib/getopt_.h haiku/trunk/src/bin/coreutils/lib/getpagesize.h haiku/trunk/src/bin/coreutils/lib/gettime.c haiku/trunk/src/bin/coreutils/lib/gettimeofday.c haiku/trunk/src/bin/coreutils/lib/gnulib.mk haiku/trunk/src/bin/coreutils/lib/hard-locale.c haiku/trunk/src/bin/coreutils/lib/inttypes_.h haiku/trunk/src/bin/coreutils/lib/mbchar.h haiku/trunk/src/bin/coreutils/lib/mbswidth.c haiku/trunk/src/bin/coreutils/lib/mbswidth.h haiku/trunk/src/bin/coreutils/lib/mbuiter.h haiku/trunk/src/bin/coreutils/lib/mempcpy.c haiku/trunk/src/bin/coreutils/lib/memrchr.c haiku/trunk/src/bin/coreutils/lib/mkdir-p.c haiku/trunk/src/bin/coreutils/lib/mkstemp-safer.c haiku/trunk/src/bin/coreutils/lib/mkstemp.c haiku/trunk/src/bin/coreutils/lib/mktime.c haiku/trunk/src/bin/coreutils/lib/mountlist.c haiku/trunk/src/bin/coreutils/lib/nanosleep.c haiku/trunk/src/bin/coreutils/lib/openat-proc.c haiku/trunk/src/bin/coreutils/lib/openat.c haiku/trunk/src/bin/coreutils/lib/posixtm.c haiku/trunk/src/bin/coreutils/lib/posixtm.h haiku/trunk/src/bin/coreutils/lib/printf-args.c haiku/trunk/src/bin/coreutils/lib/printf-args.h haiku/trunk/src/bin/coreutils/lib/printf-parse.c haiku/trunk/src/bin/coreutils/lib/putenv.c haiku/trunk/src/bin/coreutils/lib/quotearg.c haiku/trunk/src/bin/coreutils/lib/randperm.c haiku/trunk/src/bin/coreutils/lib/readlink.c haiku/trunk/src/bin/coreutils/lib/readutmp.h haiku/trunk/src/bin/coreutils/lib/regcomp.c haiku/trunk/src/bin/coreutils/lib/regex.h haiku/trunk/src/bin/coreutils/lib/regex_internal.c haiku/trunk/src/bin/coreutils/lib/regex_internal.h haiku/trunk/src/bin/coreutils/lib/regexec.c haiku/trunk/src/bin/coreutils/lib/safe-read.h haiku/trunk/src/bin/coreutils/lib/savedir.c haiku/trunk/src/bin/coreutils/lib/savewd.c haiku/trunk/src/bin/coreutils/lib/setenv.c haiku/trunk/src/bin/coreutils/lib/setenv.h haiku/trunk/src/bin/coreutils/lib/settime.c haiku/trunk/src/bin/coreutils/lib/snprintf.c haiku/trunk/src/bin/coreutils/lib/socket_.h haiku/trunk/src/bin/coreutils/lib/stat-time.h haiku/trunk/src/bin/coreutils/lib/stdbool_.h haiku/trunk/src/bin/coreutils/lib/stdint_.h haiku/trunk/src/bin/coreutils/lib/stdlib--.h haiku/trunk/src/bin/coreutils/lib/strdup.c haiku/trunk/src/bin/coreutils/lib/strftime.c haiku/trunk/src/bin/coreutils/lib/strndup.c haiku/trunk/src/bin/coreutils/lib/strnlen.c haiku/trunk/src/bin/coreutils/lib/strtol.c haiku/trunk/src/bin/coreutils/lib/tempname.c haiku/trunk/src/bin/coreutils/lib/time_r.c haiku/trunk/src/bin/coreutils/lib/timespec.h haiku/trunk/src/bin/coreutils/lib/userspec.c haiku/trunk/src/bin/coreutils/lib/utime.c haiku/trunk/src/bin/coreutils/lib/utimecmp.c haiku/trunk/src/bin/coreutils/lib/utimens.c haiku/trunk/src/bin/coreutils/lib/utimens.h haiku/trunk/src/bin/coreutils/lib/vasnprintf.c haiku/trunk/src/bin/coreutils/lib/vasnprintf.h haiku/trunk/src/bin/coreutils/lib/vasprintf.h haiku/trunk/src/bin/coreutils/lib/version-etc.c haiku/trunk/src/bin/coreutils/lib/wcwidth.h haiku/trunk/src/bin/coreutils/lib/xalloc.h haiku/trunk/src/bin/coreutils/lib/xfts.c haiku/trunk/src/bin/coreutils/lib/xgetcwd.c haiku/trunk/src/bin/coreutils/lib/xnanosleep.c haiku/trunk/src/bin/coreutils/lib/xreadlink.c haiku/trunk/src/bin/coreutils/lib/xreadlink.h haiku/trunk/src/bin/coreutils/lib/xstrndup.c haiku/trunk/src/bin/coreutils/lib/yesno.c haiku/trunk/src/bin/coreutils/man/Makefile.am haiku/trunk/src/bin/coreutils/man/Makefile.in haiku/trunk/src/bin/coreutils/man/base64.1 haiku/trunk/src/bin/coreutils/man/basename.1 haiku/trunk/src/bin/coreutils/man/cat.1 haiku/trunk/src/bin/coreutils/man/chgrp.1 haiku/trunk/src/bin/coreutils/man/chmod.1 haiku/trunk/src/bin/coreutils/man/chown.1 haiku/trunk/src/bin/coreutils/man/chroot.1 haiku/trunk/src/bin/coreutils/man/cksum.1 haiku/trunk/src/bin/coreutils/man/comm.1 haiku/trunk/src/bin/coreutils/man/cp.1 haiku/trunk/src/bin/coreutils/man/csplit.1 haiku/trunk/src/bin/coreutils/man/cut.1 haiku/trunk/src/bin/coreutils/man/date.1 haiku/trunk/src/bin/coreutils/man/dd.1 haiku/trunk/src/bin/coreutils/man/df.1 haiku/trunk/src/bin/coreutils/man/dir.1 haiku/trunk/src/bin/coreutils/man/dircolors.1 haiku/trunk/src/bin/coreutils/man/dirname.1 haiku/trunk/src/bin/coreutils/man/du.1 haiku/trunk/src/bin/coreutils/man/echo.1 haiku/trunk/src/bin/coreutils/man/env.1 haiku/trunk/src/bin/coreutils/man/expand.1 haiku/trunk/src/bin/coreutils/man/expr.1 haiku/trunk/src/bin/coreutils/man/factor.1 haiku/trunk/src/bin/coreutils/man/false.1 haiku/trunk/src/bin/coreutils/man/fmt.1 haiku/trunk/src/bin/coreutils/man/fold.1 haiku/trunk/src/bin/coreutils/man/groups.1 haiku/trunk/src/bin/coreutils/man/head.1 haiku/trunk/src/bin/coreutils/man/hostid.1 haiku/trunk/src/bin/coreutils/man/hostname.1 haiku/trunk/src/bin/coreutils/man/id.1 haiku/trunk/src/bin/coreutils/man/install.1 haiku/trunk/src/bin/coreutils/man/join.1 haiku/trunk/src/bin/coreutils/man/kill.1 haiku/trunk/src/bin/coreutils/man/link.1 haiku/trunk/src/bin/coreutils/man/ln.1 haiku/trunk/src/bin/coreutils/man/logname.1 haiku/trunk/src/bin/coreutils/man/ls.1 haiku/trunk/src/bin/coreutils/man/md5sum.1 haiku/trunk/src/bin/coreutils/man/mkdir.1 haiku/trunk/src/bin/coreutils/man/mkfifo.1 haiku/trunk/src/bin/coreutils/man/mknod.1 haiku/trunk/src/bin/coreutils/man/mv.1 haiku/trunk/src/bin/coreutils/man/nice.1 haiku/trunk/src/bin/coreutils/man/nl.1 haiku/trunk/src/bin/coreutils/man/nohup.1 haiku/trunk/src/bin/coreutils/man/od.1 haiku/trunk/src/bin/coreutils/man/paste.1 haiku/trunk/src/bin/coreutils/man/pathchk.1 haiku/trunk/src/bin/coreutils/man/pinky.1 haiku/trunk/src/bin/coreutils/man/pr.1 haiku/trunk/src/bin/coreutils/man/printenv.1 haiku/trunk/src/bin/coreutils/man/printf.1 haiku/trunk/src/bin/coreutils/man/ptx.1 haiku/trunk/src/bin/coreutils/man/pwd.1 haiku/trunk/src/bin/coreutils/man/readlink.1 haiku/trunk/src/bin/coreutils/man/rm.1 haiku/trunk/src/bin/coreutils/man/rmdir.1 haiku/trunk/src/bin/coreutils/man/seq.1 haiku/trunk/src/bin/coreutils/man/sha1sum.1 haiku/trunk/src/bin/coreutils/man/sha224sum.1 haiku/trunk/src/bin/coreutils/man/sha256sum.1 haiku/trunk/src/bin/coreutils/man/sha384sum.1 haiku/trunk/src/bin/coreutils/man/sha512sum.1 haiku/trunk/src/bin/coreutils/man/shred.1 haiku/trunk/src/bin/coreutils/man/shuf.1 haiku/trunk/src/bin/coreutils/man/sleep.1 haiku/trunk/src/bin/coreutils/man/sort.1 haiku/trunk/src/bin/coreutils/man/split.1 haiku/trunk/src/bin/coreutils/man/stat.1 haiku/trunk/src/bin/coreutils/man/stty.1 haiku/trunk/src/bin/coreutils/man/su.1 haiku/trunk/src/bin/coreutils/man/sum.1 haiku/trunk/src/bin/coreutils/man/sync.1 haiku/trunk/src/bin/coreutils/man/tac.1 haiku/trunk/src/bin/coreutils/man/tail.1 haiku/trunk/src/bin/coreutils/man/tee.1 haiku/trunk/src/bin/coreutils/man/test.1 haiku/trunk/src/bin/coreutils/man/touch.1 haiku/trunk/src/bin/coreutils/man/tr.1 haiku/trunk/src/bin/coreutils/man/true.1 haiku/trunk/src/bin/coreutils/man/tsort.1 haiku/trunk/src/bin/coreutils/man/tty.1 haiku/trunk/src/bin/coreutils/man/uname.1 haiku/trunk/src/bin/coreutils/man/unexpand.1 haiku/trunk/src/bin/coreutils/man/uniq.1 haiku/trunk/src/bin/coreutils/man/unlink.1 haiku/trunk/src/bin/coreutils/man/uptime.1 haiku/trunk/src/bin/coreutils/man/users.1 haiku/trunk/src/bin/coreutils/man/vdir.1 haiku/trunk/src/bin/coreutils/man/wc.1 haiku/trunk/src/bin/coreutils/man/who.1 haiku/trunk/src/bin/coreutils/man/whoami.1 haiku/trunk/src/bin/coreutils/man/yes.1 haiku/trunk/src/bin/coreutils/src/Makefile.am haiku/trunk/src/bin/coreutils/src/Makefile.in haiku/trunk/src/bin/coreutils/src/base64.c haiku/trunk/src/bin/coreutils/src/c99-to-c89.diff haiku/trunk/src/bin/coreutils/src/chgrp.c haiku/trunk/src/bin/coreutils/src/chmod.c haiku/trunk/src/bin/coreutils/src/chown-core.c haiku/trunk/src/bin/coreutils/src/chown.c haiku/trunk/src/bin/coreutils/src/copy.c haiku/trunk/src/bin/coreutils/src/cp.c haiku/trunk/src/bin/coreutils/src/csplit.c haiku/trunk/src/bin/coreutils/src/cut.c haiku/trunk/src/bin/coreutils/src/date.c haiku/trunk/src/bin/coreutils/src/dd.c haiku/trunk/src/bin/coreutils/src/df.c haiku/trunk/src/bin/coreutils/src/dircolors.c haiku/trunk/src/bin/coreutils/src/dircolors.h haiku/trunk/src/bin/coreutils/src/dircolors.hin haiku/trunk/src/bin/coreutils/src/du.c haiku/trunk/src/bin/coreutils/src/env.c haiku/trunk/src/bin/coreutils/src/expr.c haiku/trunk/src/bin/coreutils/src/fmt.c haiku/trunk/src/bin/coreutils/src/groups.sh haiku/trunk/src/bin/coreutils/src/install.c haiku/trunk/src/bin/coreutils/src/join.c haiku/trunk/src/bin/coreutils/src/ls.c haiku/trunk/src/bin/coreutils/src/mv.c haiku/trunk/src/bin/coreutils/src/nl.c haiku/trunk/src/bin/coreutils/src/od.c haiku/trunk/src/bin/coreutils/src/pr.c haiku/trunk/src/bin/coreutils/src/printf.c haiku/trunk/src/bin/coreutils/src/readlink.c haiku/trunk/src/bin/coreutils/src/remove.c haiku/trunk/src/bin/coreutils/src/remove.h haiku/trunk/src/bin/coreutils/src/rm.c haiku/trunk/src/bin/coreutils/src/shuf.c haiku/trunk/src/bin/coreutils/src/sort.c haiku/trunk/src/bin/coreutils/src/stat.c haiku/trunk/src/bin/coreutils/src/system.h haiku/trunk/src/bin/coreutils/src/tail.c haiku/trunk/src/bin/coreutils/src/tee.c haiku/trunk/src/bin/coreutils/src/uniq.c Log: merging coreutils-6.9 into trunk Modified: haiku/trunk/src/bin/coreutils/ChangeLog =================================================================== --- haiku/trunk/src/bin/coreutils/ChangeLog 2007-12-16 18:31:05 UTC (rev 23130) +++ haiku/trunk/src/bin/coreutils/ChangeLog 2007-12-16 18:32:10 UTC (rev 23131) @@ -1,3 +1,1098 @@ +2007-03-22 Jim Meyering + + Version 6.9. + * NEWS: Record release date and new version number. + * configure.ac (AC_INIT): New version number. + + * tests/mv/hard-3: Correct the preceding change: $3 -> $2. + +2007-03-22 Paul Eggert + + Improve a test script. + * tests/mv/hard-3: Check for 'ls' failure, too. + Generate more-useful debugging output when 'ls' fails. + +2007-03-21 Jim Meyering + + Fix a test script not to claim an ext2 file system is of type xfs. + * tests/du/slink: When using df --local and df --type=TYPE, + test only the exit code. Don't bother with stdout. + Prompted by a report by Thomas Schwinge of an inaccurate diagnostic. + + * gl/lib/savewd.c: Remove this file, since the savewd_save change + is now in gnulib. The other wasn't useful. + +2007-03-20 Jim Meyering + + * gl/lib/acl.c: Remove this file, now that gnulib's version subsumes it. + + Skip part of this test when "." is not a local file system. + * tests/install/basic-1: Otherwise, it would fail on some NFS + file systems. + * tests/mkdir/p-3: Likewise. + +2007-03-19 Paul Eggert + + * src/Makefile.am (dir_LDADD, ls_LDADD, vdir_LDADD): + Add $(LIB_ACL_TRIVIAL). + +2007-03-18 Jim Meyering + + Fix a generic NFS-related test failure. + * tests/mkdir/p-3: When setting up an unreadable "." in an + inaccessible parent, make the parent inaccessible *after* making "." + unreadable. Otherwise, running "chmod a-r ." in an already- + inaccessible parent would fail on NFS with "Stale NFS file handle". + + Fix a bug in how pr -m -s works. + * NEWS: Describe how the fix affects pr. + * src/pr.c (init_parameters): The --merge (-m) option does + not imply --expand-tabs (-e), so don't set "untabify_input". + Reported by Wis Macomson. + * tests/misc/pr: New file. Test for the above fix. + * tests/misc/Makefile.am (TESTS): Add pr. + * THANKS: Update. + +2007-03-17 Jim Meyering + + Detect use of AC_CONFIG_AUX_DIR also when its argument is quoted. + * bootstrap: Put ""s around use of $build_aux, in case + someone uses a name containing shell meta-characters. + Reported by Alfred M. Szmidt. + * tests/misc/tty-eof: Add shuf to the list of tested commands. + + Avoid test failure on NFS-mounted Solaris ZFS file system. + * tests/du/basic: Skip a test if "." is on a non-local file system. + + Avoid an obscure build failure, prefer waitpid over wait. + * src/install.c (strip): Use waitpid, not wait. It's equivalent, + but feels less obsolescent. + + * bootstrap: Don't use \> in grep regexp. For HP-UX. + +2007-03-16 Jim Meyering + + Begin adding support for Solaris ZFS (4 entries per trivial ACL) + * gl/lib/acl.c (ACL_NOT_WELL_SUPPORTED): New macro. + (file_has_acl, copy_acl): Use it, rather than enumerating errno values. + (is_trivial_acl): New function. Incomplete, for now. + (file_has_acl, copy_acl): Use the new function, rather than + counting the number of entries in an ACL. + + * bootstrap: Update from gnulib. + + * .x-sc_prohibit_atoi_atof: Add TODO here, too. + +2007-03-16 Paul Eggert + + * src/copy.c: Include filemode.h. + (overwrite_prompt): Say "try to overwrite", not "overwrite", to + make it clearer that the attempt may fail. Problem reported by + Dan Jacobson in: + http://lists.gnu.org/archive/html/bug-coreutils/2007-03/msg00130.html + Output symbolic mode as well as numeric. + * tests/mv/i-2 (fail): Adjust to new prompt format. + +2007-03-15 Jim Meyering + + Enforce policy: don't use *scanf functions. + * Makefile.maint (sc_prohibit_atoi_atof): Add to regexp and diagnostic. + * .x-sc_prohibit_atoi_atof: Give stty a temporary pass. + * TODO: note that stty.c needs this small clean-up. + +2007-03-13 Jim Meyering + + Prepare to work on ACL-related failure when using Solaris ZFS. + * gl/lib/acl.c: New file, copied from gnulib. + + Work around a failing test due to an NFS-based race condition. + * tests/cp/sparse: Accept a report that the copy is *smaller*. + +2007-03-12 Jim Meyering + + Make bootstrap.conf a tiny bit more generic. + * bootstrap.conf (XGETTEXT_OPTIONS): Exclude gettext-related .m4 + files when e.g., AM_GNU_GETTEXT([external] appears in configure.ac. + +2007-03-10 Jim Meyering + + Try to fix today's NFS-related failure: Treat ESTALE like EACCES. + * gl/lib/savewd.c: Copy this file from gnulib, then change + "errno != EACCES" to (errno != EACCES && errno != ESTALE). + The symptom was this failure in tests/install/basic-1: + ginstall: cannot create directory `rel/a': Stale NFS file handle + + The preceding change solved part of the problem. Now ginstall fails. + * tests/install/basic-1: Temporarily, don't redirect ginstall's + stderr to /dev/null, so I can see why the NFS autobuilder's NFS test + is failing. + + * tests/install/basic-1: When setting up an unreadable "." in an + inaccessible parent, make the parent inaccessible *after* making "." + unreadable. Otherwise, running "chmod a-r ." in an already- + inaccessible parent would fail on NFS with "Stale NFS file handle". + Reported by Bob Proulx. + + * Makefile.maint (po-check): Exclude c99-to-c89.diff. + +2007-03-09 Jim Meyering + + Avoid test failures on Darwin 7.9.0 (MacOS X 10.3.9) + * tests/chgrp/basic: Don't let failure by chgrp to set the + group of a symlink make this test fail. Do give a diagnostic. + In the chgrp-no-change-ctime test, add darwin7.9.0 as another + known-failing system. + When failing on some other system, print $host_triplet, too. + Also avoid test failures on Darwin 8.8.x (MacOS X 10.4). + Reported by Peter Fales. + +2007-03-08 Jim Meyering + + * src/c99-to-c89.diff: Reflect the new c99'ism, update offsets. + +2007-03-08 Paul Eggert + + rm without -f: give a better diagnostic when euidaccess fails. + * src/remove.c (write_protected_non_symlink): Return int, not bool, + so that we can indicate failure too (as a postive error number). + (prompt): If write_protected_non_symlink fails, report that error + number and fail rather than charging ahead and removing the dubious + entry. Redo the logic of printing a diagnostic so that we need to + invoke quote (full_filename (...)) only once. More details at: + + +2007-03-08 Jim Meyering + + Generalize a few more cvs-isms. + * bootstrap (checkout_only_file): Rename from CVS_only_file. + Change comments and diagnostics not to say "CVS". + + * bootstrap: Run libtool, if necessary. + + Make bootstrap a little more general. + * bootstrap (build_aux): Factor out/use this definition. + Formally require a "AC_CONFIG_AUX_DIR($build_aux)" line in configure.ac. + (insert_sorted_if_absent): Move function definition "up", to + precede new first use. + If $build_aux/ doesn't exist initially, create it, and + mark it as ignored. + +2007-03-03 Andrew Church (tiny change) + Paul Eggert + + Fix a bug: cp -x would fail to set mount point permissions. + * NEWS: mention cp -x bug fix + * src/copy.c (copy_internal): Don't return immediately after + copying a mount point that we do not intend to recurse under. + Based on a patch by Andrew Church. + +2007-03-03 Jim Meyering + + pwd-unreadable-parent: Skip test on ia64/Linux, too. + * tests/misc/pwd-unreadable-parent: Also skip when $REPLACE_GETCWD. + Reported by Bob Proulx. + +2007-03-02 Jim Meyering + + pwd-unreadable-parent: Skip test on non-Linux/GNU systems. + * tests/misc/pwd-unreadable-parent: Rather than trying to decide + whether this test has a chance of succeeding, run it only when + $(host_os) is linux-gnu. It was failing on powerpc-apple-darwin8.8.0 + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Add host_os=$(host_os). + + * tests/misc/pwd-long: Also allow "+" in $PWD. + + Remove another coreutils-ism. Formatting cleanup. + * Makefile.maint (my-distcheck): Update an outdated comment. + (emit_upload_commands): Use $(PACKAGE) rather than "coreutils". + (my-distcheck): Skip the c99/c89 check if there's no such .diff file. + +2007-03-01 Jim Meyering + + * Makefile.maint (warn_cflags): Hoist, adding "-Dlint -O". + (my-distcheck): Use the new variable, instead of too-long literal. + + Make "make syntax-check" rules less coreutils-specific. + * Makefile.maint (sc_cast_of_x_alloc_return_value): Use CVS_LIST_EXCEPT. + (sc_cast_of_alloca_return_value): Likewise. + (sc_root_tests): Do nothing if there is no check-root target + in tests/Makefile.am. + + Run the writable-files check only for release-building targets. + * Makefile.maint (local-checks-available): Remove writable-files. + (alpha beta major): Put it here, instead. + + "make syntax-check" now runs only Makefile.cfg-selected tests + * Makefile.maint (syntax-check-rules): Hoist this definition so that + it precedes the indirect use in the definition of $(local-check). + (local-check): Use :=, not just "=". + (syntax-check): Depend on $(local-check), not $(syntax-check-rules). + +2007-02-28 Bruno Haible + + * bootstrap.conf (gnulib_modules): Replace xreadlink with + xreadlink-with-size. Add xreadlink. + * src/copy.c (copy_internal): Update. + * src/ls.c (is_directory): Update. + * src/stat.c (print_stat): Update. + * src/readlink.c (main): Use the one-argument xreadlink function. + +2007-02-28 Paul Eggert + + * doc/coreutils.texi (Common options): --si outputs "M", not "MB". + Problem reported by Philip Rowlands in + . + +2007-02-28 Jim Meyering + + * .x-sc_file_system: Add the new test, tests/misc/df-P, to this + list of exceptions, for the "make distcheck" sc_file_system rule. + + * Makefile.maint (gnulib_snapshot_date): Remove now-unused definition. + +2007-02-27 Paul Eggert + + Make df -P immune to effects of e.g., the BLOCK_SIZE envvar. + * NEWS: With -P, the default block size and output format is not + affected by DF_BLOCK_SIZE, BLOCK_SIZE, or BLOCKSIZE. + * src/df.c (main): Implement this. + +2007-02-27 Jim Meyering + + Add a test for the above. + * tests/misc/df-P: New file. + * tests/misc/Makefile.am (TESTS): Add df-P. + +2007-02-25 Jim Meyering + + * Makefile.maint (announcement): Adjust so that it works with + announce-gen's --gnulib-snapshot-time-stamp option. + Indent one of the command lines using TAB, not 8 spaces. + + Post-release version change. + * NEWS: Add a line for 6.8+. + * configure.ac (AC_INIT): Set new version string. + +2007-02-24 Jim Meyering + + Version 6.8. + * NEWS: Record release date and new version number. + * configure.ac (AC_INIT): New version number. + + Don't skip this test on new-enough Linux/GNU systems. + * tests/misc/pwd-unreadable-parent: Test $REPLACE_GETCWD = 0, + rather than for __GETCWD_PREFIX in config.h (the latter is no + longer defined, ever, due to gnulib changes). + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define REPLACE_GETCWD. + + Remove the "gnits" option; it prohibits my using "+" as a version + string suffix, and all it does (beyond the default "gnu" option) + is to _require_ the THANKS file. + * configure.ac (AM_INIT_AUTOMAKE): Remove it. + + Remove all AUTOMAKE_OPTIONS settings in Makefile.am files. + * tests/chgrp/Makefile.am, tests/chmod/Makefile.am: + * tests/chown/Makefile.am, tests/cp/Makefile.am: + * tests/du/Makefile.am, tests/expr/Makefile.am: + * tests/factor/Makefile.am, tests/general/Makefile.am: + * tests/install/Makefile.am, tests/ln/Makefile.am: + * tests/ls/Makefile.am, tests/mkdir/Makefile.am: + * tests/mv/Makefile.am, tests/readlink/Makefile.am: + * tests/rm/Makefile.am, tests/rmdir/Makefile.am: + * tests/seq/Makefile.am, tests/stty/Makefile.am: + * tests/tee/Makefile.am, tests/touch/Makefile.am: + + * README: Document the OSF/1 4.0d build failure and work-around. + Reported by Bruno Haible. + + * NEWS: Use a simple "+" suffix to denote pre-release, not "-dirty". + Nicer connotations. + * configure.ac: Use 6.7+, not 6.7-dirty. + +2007-02-24 Paul Eggert + + * NEWS: sort no longer compresses temporaries by default. + * bootstrap.conf: Remove findprog. + * doc/coreutils.texi (sort invocation): The default is to not + compress. Don't treat "" specially. + * src/sort.c: Don't include findprog.h. + (create_temp): Compress only if the user specified --compress-program. + * tests/misc/sort-compress: Adjusts tests to match new behavior. + +2007-02-24 Jim Meyering + + Avoid a shell syntax error, when building with an inadequate Perl. + * man/Makefile.am (.x.1): Add quotes around $(PERL) in case, since + it can expand to "/.../missing perl". + + * man/Makefile.am (.x.1): Warn when unable to update a man page. + Suggestion from Bruno Haible. + +2007-02-23 Bruno Haible + + Handle better the combination of old Perl and a pre-c99 compiler. + * man/Makefile.am (.x.1): If the autoconf test has determined that + perl is missing or not a sufficient version, do nothing. + + * tests/readlink/can-e: Put the closing double-quote at the end of a + backquoted word, not in the middle. Works around a bug in sh on + OSF/1 4.0d. + * tests/readlink/can-f: Likewise. + * tests/readlink/can-m: Likewise. + + * tests/du/slink: Skip the test if executing on an nfsv3 file system. + This avoids a test failure at least on OSF/1 4.0d. + +2007-02-23 Jim Meyering + + * src/date.c (usage): Split a diagnostic that had grown to be + longer than the C89 maximum of 509 bytes. + +2007-02-23 Ed Santiago + + * src/date.c (usage): Mention that --rfc-3339 uses space, not 'T', + for a separator. Include sample RFC 2822 and 3339 output. + +2007-02-23 Jim Meyering + + With -Dlint, make shuf free all heap-allocated storage. + * src/shuf.c (main): Move declaration of input_lines to + function scope, and initialize to NULL, so we can free it. + [lint]: Free all malloc'd memory. + * tests/misc/shuf: Also test shuf's -e and -i options. + +2007-02-22 Jim Meyering + + Merge in a change from some other incarnation of this file (gzip?) + * bootstrap (gnulib_tool): Skip get_translations if there is no po/ dir. + + Adjust preceding change not to perform an unaligned access. + * src/copy.c (copy_reg): Undo previous change. Instead, make + it clearer that we're using a single-byte sentinel, and + [lint]: Initialize sizeof (uintptr_t) - 1 bytes after the sentinel. + Reported by Andreas Schwab. + + Placate valgrind, wrt ./cp --sparse=always + * src/copy.c (copy_reg): Place the sentinel by setting a + full word's worth of bits, not just a single byte's worth. + This avoids a harmless (but distracting) case of memory being + used-uninitialized. + +2007-02-21 Paul Eggert + + Honor dd's noatime flag if possible, even if not supported on build fs + * doc/coreutils.texi (dd invocation): Warn that noatime might not be + reliable. + * src/dd.c (flags, usage): Look at O_NOATIME, not + HAVE_WORKING_O_NOATIME, to decide whether to support the noatime + flag, so that dd attempts O_NOATIME even if the build file system + does not support it. Problem reported by Jim Meyering today in + bug-coreutils. + * tests/dd/misc: Generate a warning, not a failure, if noatime + exists but fails. + +2007-02-21 Jim Meyering + + * tests/misc/date: Remove vestigial use of Data::Dumper. + +2007-02-20 Paul Eggert + + * src/copy.c (cached_umask): Cast -1 to mode_t to avoid a warning + about out-of-range initializer with Sun C 5.8. + +2007-02-20 Jim Meyering + + * bootstrap (CVS_only_file): Use README-hacking. + + Now that we use GIT, not cvs, rename README-cvs. + * README-hacking: Renamed from... + Update to reflect that we now use git. + + * README-cvs: ...this. + + * src/env.c (main): When invoked with no arguments (i.e. when printing + the environment), use a local variable to iterate through the global + "environ" array, rather than "environ" itself. This is solely to + avoid changing the environment for an LD_PRELOAD-substituted "puts" + or "exit" function. Tiny patch by Harvey Eneman. See + . + * THANKS: Update. + + * bootstrap: Move definitions of temporary directory names and the + new bt_regex "up" to precede all uses, so it's clearer what their + scope is. Also, use [.], rather than \\., since the former works + even if eval'd. + + * bootstrap: Remove occurrences of $bt (._bootmp) from lib/Makefile. + Based on the bison 2007-02-19 change by Joel E. Denny. + +2007-02-19 Paul Eggert + + * NEWS: sort now uses a --compress-program option rather than + an environment variable. + * doc/coreutils.texi (sort invocation): Document this. + * src/sort.c (usage): Likewise. + (COMPRESS_PROGRAM_OPTION): New const. + (long_options, create_temp, main): Support new option. + * tests/misc/sort-compress: Test it. + +2007-02-19 Jim Meyering + + * bootstrap: Fix typo s/dowloading/downloading/ in --help output. + +2007-02-18 Jim Meyering + + * src/system.h: Don't include exit.h, now that it's subsumed + by the gnulib-generated stdlib.h. + + * tests/rm/fail-eacces: Skip this test when running as root. + Reported by Matthew Woehlke. + + * bootstrap: Use "._bootmp" as the temporary directory name, + not ".#bootmp". The latter's "#" caused trouble with the new, + gnulib-added "LINK_WARNING_H = $(top_srcdir)/.#bootmp/..." line. + +2007-02-14 Paul Eggert + + * bootstrap.conf (gnulib_modules): Add c-strcase. Remove strcase. + * src/dircolors.c: Include c-strcase.h. + (dc_parse_stream): Use c_strcasecmp rather than + strcasecmp to avoid unreliable results in locales like Turkish + where strcasecmp is incompatible with the C locale. + +2007-02-13 Jim Meyering + + Also check for and print stderr output, in case a program fails. + * tests/misc/tty-eof: Occasionally (not reproducible), this + test would fail, with one or more programs exiting nonzero, e.g., + tty-eof: sha224sum exited with status 1 (expected 0) + Now, maybe we'll get a clue, the next time that happens. + +2007-02-12 Jim Meyering + + * .x-sc_useless_cpp_parens: Ignore a false-positive in a shell script. + + * tests/misc/pwd-unreadable-parent: Skip the test if we're + definitely using the replacement. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define CONFIG_HEADER. + +2007-02-10 Jim Meyering + + Remove excess leading spaces that would make help2man misbehave. + * src/printf.c (usage): Remove excess spaces on 2nd line of %b desc. + * src/nl.c (usage): Remove excess spaces on 2nd line of pBRE desc. + * src/dd.c (usage): Remove excess spaces on 2nd line of sync desc. + * src/date.c (usage): Use two spaces after each optional flag, not one. + Reported by Thomas Huriaux in . + + * Makefile.maint (longopt_re): Relax the regexp, making square + brackets optional, so it matches the newly reported violations, too. + + * src/csplit.c (usage): Use two spaces (not one) to separate + each option string from its description, so help2man formats + the derived man page properly. Reported by Thomas Huriaux in + . + * src/df.c (usage): Likewise. + * src/du.c (usage): Likewise. + * src/install.c (usage): Likewise. + * src/ls.c (usage): Likewise. + +2007-02-03 Jim Meyering + + Test for today's gnulib/lib/getcwd.c fix affecting pwd and readlink + * NEWS: Mention the bug fix. + * tests/misc/pwd-unreadable-parent: New file. + * tests/misc/Makefile.am (TESTS): Ad pwd-unreadable-parent. + +2007-02-02 Paul Eggert + + * NEWS: Document fix for cp --preserve=mode. + * src/copy.c (copy_internal): Omit the group- or other-writeable + permissions when creating a directory, to avoid a race condition + if the special mode bits aren't right just after the directory is + created. + * src/cp.c (make_dir_parents_private): Likewise. + * tests/cp/parent-perm-race: Test for the "cp --preserve=mode" + race fix in copy.c. + + * NEWS: Document fix for cp --parents. + * src/cp.c (make_dir_parents_private): Report the error sooner with + "cp --parents DIR/FILE DEST" when DIR is a non-directory, thus not + creating the directory, DEST/DIR. + * tests/cp/cp-parents: Test for the non-race-condition bug fixed + by the above change. + +2007-02-02 Jim Meyering + + * src/nl.c (proc_text): Use "NULL", not "(struct re_registers *) 0". + + * src/c99-to-c89.diff: Make shred.c Index: and a/b prefixes + consistent, so this can be applied with patch -p0. + Reported by Matthew Woehlke. + + * Makefile.maint (patch-check): Use patch with its -p2 option, + since that makes this check slightly more strict. + +2007-01-29 Jim Meyering + + Plug a leak in ls. + * src/ls.c (print_dir): Don't leak a "DIR"+fd upon failure to + determine dev/inode or upon detecting a symlink loop. + + * src/ls.c: Rename three global variables. + (cwd_file): Rename from 'files'. + (cwd_n_alloc): Rename from 'nfiles'. + (cwd_n_used): Rename from 'files_index'. + + Shave 8 bytes off the size of "struct fileinfo". + * src/ls.c (fileinfo): Put all members of type "bool" together. + +2007-01-28 Paul Eggert + + Modify "ls" to sort its data faster, using the new gnulib mpsort + module rather than qsort. This is particularly a win in + environments where strcoll is slow, since mpsort typically calls + strcoll less often than qsort does. + * bootstrap.conf (gnulib_modules): Add mpsort. + * src/ls.c: Include mpsort.h. + (sorted_file, sorted_file_alloc): New vars, for a new vector of + pointers to the file info, for speed. + (clear_files, extract_dirs_from_files, sort_files, print_current_files): + (print_many_per_line, print_horizontal, print_with_commas): + (calculate_columns): Set and use new vector. + (initialize_ordering_vector): New function. + +2007-01-26 Paul Eggert + + Adjust to today's change to gnulib, which added a module for + string.h to replace the little include files like strcase.h. + * src/dircolors.c: Don't include strcase.h. + * src/system.h: Don't include mempcpy.h, memrchr.h, stpcpy.h, strpbrk.h. + +2007-01-26 Jim Meyering + + * src/dd.c (advance_input_after_read_error): Change diagnostic to + say "invalid file offset" rather than "screwy file offset". + + * .x-sc_cast_of_argument_to_free: Remove this file. + * Makefile.am (EXTRA_DIST): Likewise. + +2007-01-25 Dan Hipschman + + * src/sort.c (create_temp): Remove superfluous access-X_OK + check. find_in_path does this for us. + +2007-01-24 Jim Meyering + + Remove usually-skipped test. + * tests/cp/open-perm-race: Remove this file. It is subsumed + by parent-perm-race. + * tests/cp/Makefile.am (TESTS): Remove open-perm-race. + * tests/sort/Makefile.am: Regenerate. + + Pass "make distcheck" again. + * src/sort.c (usage): Split a diagnostic that had grown to be + longer than the C89 maximum of 509 bytes. + * .x-sc_cast_of_argument_to_free: New file. Allow a cast in sort.c. + FIXME: this is just temporary, while we wait to remove the offending + access-calling code. + * Makefile.am (EXTRA_DIST): Add .x-sc_cast_of_argument_to_free. + * Makefile.maint (sc_cast_of_argument_to_free): Use the + canonical, $$($(CVS_LIST_EXCEPT)). + * m4/.gitignore, m4/.cvsignore, lib/.gitignore, lib/.cvsignore: Update. + +2007-01-24 Paul Eggert + + * NEWS: New option sort -C, proposed by XCU ERN 127, which looks + like it will be approved. Also add --check=quiet, --check=silent + as long aliases, and --check=diagnose-first as an alias for -c. + * doc/coreutils.texi (sort invocation): Document this. + Also, mention that sort -c can take at most one file. + * src/sort.c: Implement this. + Include argmatch.h. + (usage): Document the change. + (CHECK_OPTION): New constant. + (long_options): --check now takes an optional argument, and is now + treated differently from 'c'. + (check_args, check_types): New constant arrays. + (check): New arg CHECKONLY, which suppresses diagnostic if -C. + (main): Parse the new options. + * tests/sort/Test.pm (02d, 02d, incompat5, incompat6): + New tests for -C. + +2007-01-24 Jim Meyering + + Fix a typo. + * tests/misc/sort-compress: Use $abs_top_builddir, not $top_builddir. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Likewise. + + Don't depend on "which". + * tests/misc/sort-compress (SORT): Use $abs_builddir, now which. + * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Export top_builddir. + +2007-01-24 Dan Hipschman + + Test sort compression. + * tests/misc/Makefile.am: Add the test. + * tests/misc/sort-compress: New file containing the tests. + +2007-01-24 Jim Meyering + + * NEWS: sort temp file compression: tweak wording. + * src/sort.c (struct sortfile) [name]: Declare member to be const. + +2007-01-21 Jim Meyering + + * src/sort.c (MAX_FORK_RETRIES_COMPRESS, MAX_FORK_RETRIES_DECOMPRESS): + In pipe_fork callers, use these named constants, not "2" and "8". + (proctab, nprocs): Declare to be "static". + (pipe_fork) [lint]: Initialize local, pid, + to avoid unwarranted may-be-used-uninitialized warning. + (create_temp): Use the active voice. Describe parameters, too. + +2007-01-21 James Youngman + + Centralize all the uses of sigprocmask(). Don't restore an invalid + saved mask. + * src/sort.c (enter_cs, leave_cs): New functions for protecting + code sequences against signal delivery. + * (exit_cleanup): Use enter_cs and leave_cs instead of + calling sigprocmask directly. + (create_temp_file, pipe_fork, zaptemp): Likewise + +2007-01-21 Dan Hipschman + + Add compression of temp files to sort. + * NEWS: Mention this. + * bootstrap.conf: Import findprog. + * configure.ac: Add AC_FUNC_FORK. + * doc/coreutils.texi: Document GNUSORT_COMPRESSOR environment + variable. + * src/sort.c (compress_program): New global, holds the name of the + external compression program. + (struct sortfile): New type used by mergepfs and friends instead + of filenames to hold PIDs of compressor processes. + (proctab): New global, holds compressor PIDs on which to wait. + (enum procstate, struct procnode): New types used by proctab. + (proctab_hasher, proctab_comparator): New functions for proctab. + (nprocs): New global, number of forked but unreaped children. + (reap, reap_some): New function, wait for/cleanup forked processes. + (register_proc, update_proc, wait_proc): New functions for adding, + modifying and removing proctab entries. + (create_temp_file): Change parameter type to pointer to file + descriptor, and return type to pointer to struct tempnode. + (dup2_or_die): New function used in create_temp and open_temp. + (pipe_fork): New function, creates a pipe and child process. + (create_temp): Creates a temp file and possibly a compression + program to which we filter output. + (open_temp): Opens a compressed temp file and creates a + decompression process through which to filter the input. + (mergefps): Change FILES parameter type to struct sortfile array + and update access accordingly. Use open_temp and reap_some. + (avoid_trashing_input, merge): Change FILES parameter like + mergefps and call create_temp instead of create_temp_file. + (sort): Call create_temp instead of create_temp_file. + Use reap_some. + (avoid_trashing_input, merge, sort, main): Adapt to mergefps. + + The idea of compressing sorts temporary files was first + suggested/implemented by Jay Soffian in 1998, and again + by Charles Randall in 2001. + +2007-01-20 Jim Meyering + + * tests/misc/pwd-long: Work properly even when run from the + wrong one of two or more bind-mounted sibling directories. + Suggestion from Mike Stone in . + +2007-01-20 Paul Eggert + + Standardize on list of signals when an app catches signals. + * src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL, + SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ. + * src/ls.c (main): Likewise (except SIGPIPE was already caught). + Note that ls.c is special, as it also catches SIGTSTP. + * src/sort.c (main): Likewise. Also catch SIGQUIT. More details in + . + +2007-01-19 Dan Hipschman + and Paul Eggert + + * src/sort.c (cleanup): Clear temphead at the end. + (exit_cleanup): New function. + (main): Don't invoke atexit until we're ready. + Invoke it with exit_cleanup, not with cleanup and close_stdout, + to avoid a race condition with cleanup and signal handling. More + details: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9508 + +2007-01-18 Jim Meyering + + * src/c99-to-c89.diff: Adjust remove.c offsets. + +2007-01-17 Jim Meyering + + Make "rm --interactive=never ..." never prompt. + * NEWS: Mention this. + * src/remove.h (enum rm_interactive): New ternary type. + (struct rm_options) [interactive]: Use it, here -- rather than bool. + * src/remove.c (prompt): Reflect type change. + * src/mv.c (rm_option_init): Initialize to RMI_NEVER now. + * src/rm.c (main): Add a FIXME comment for '-d' option. + Adapt to type change of rm_options.interactive. + + * tests/rm/i-never: New file. Test for the above fix. + * tests/rm/Makefile.am (TESTS): Add i-never. + +2007-01-15 Jim Meyering + + * bootstrap (gnulib_tool): When adding to .cvsignore and .gitignore, + emit foo.h, for each foo_.h. This yields one false-positive, fts.h, + but that's ok, since fts_.h will eventually be renamed. + + * src/remove.c (remove_dir): Don't use errno in diagnostic. + Root-only test failure reported by Alex van Hout and Jon Grosshart in + . + + * bootstrap.conf (avoided_gnulib_modules): Fix my typo: + s/--avoid=canonicalize-lgpl/--avoid=canonicalize-gpl/ + +2007-01-14 Bruno Haible + + Enable use of gnulib's new fchdir module. + * bootstrap.conf (avoided_gnulib_modules): Avoid canonicalize-lgpl, + since we use canonicalize. + (gnulib_modules): Add fchdir. + * m4/jm-macros.m4 (coreutils_MACROS): Remove fchdir-stub. + +2007-01-13 Jim Meyering + + * Transform all Makefile.am files so that when running "make check", + CU_TEST_NAME is set to the name of the test. This is so that when I + run valgrind-enabled (--log-file-qualifier=CU_TEST_NAME) "make check" + on the entire package it is more convenient to map a leak or error + found in a valgrind log file back to the offending test. + Use this command: + (echo tests/Makefile.am.in; find tests -name Makefile.am) \ + |xargs perl -pi -e '/^(\s*)PATH=...VG_PATH_PREFIX/ and ' \ + -e 'print $1,q|CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst |,"\\\n"' + +2007-01-11 Jim Meyering + + Avoid a leak in expr's implementation of the ":" (match) operator. + * src/expr.c (docolon): Free the regexp buffer using regfree, rather + than doing it manually, being careful to set fastmap to NULL first. + Free any re_regs.start and .end members, if necessary. + + * tests/misc/test-diag: Work also when libc's error function + reports the entire program name ("../../src/test"), rather than + just the final component. + +2007-01-10 Jim Meyering + + Don't use fts_statp uninitialized for "chown -RLh --preserve-root ...". + * src/chown-core.c (FTSENT_IS_DIRECTORY): New macro. + (change_file_owner): Perform the ROOT_DEV_INO_CHECK only for a + directory. Non-directory entries lack fts_statp data when using + the FTS_NOSTAT option. + +2007-01-07 Jim Meyering + + * tests/sample-test: Update copyright date to 2007. + * Makefile.maint (copyright-check): Also check the copyright date + in tests/sample-test. + +2007-01-06 Jim Meyering + + * tests/fmt/basic (pfx-only, pfx-of-pfx): New tests, + based on examples from G.P. Halkes in + . + +2007-01-06 G.P. Halkes + + * src/fmt.c (copy_rest): Correct prefix handling. + Don't elide a line with the prefix followed by only white space. + (get_line): Move EOF-check to loop-termination condition. + * tests/fmt/basic (pfx-1): Adjust test to expect desired result. + (pfx-2): Remove test; its premise was contrary to the documentation. + +2007-01-05 Jim Meyering + + Avoid a used-uninitialized bug for invalid input, i.e., when the size + of the input, not counting newlines, is 1 % 4. + * gl/lib/base64.c (base64_decode): Don't hard-code inlen==4. + It may be smaller when flushing. + +2007-01-05 Mike Frysinger + + * src/dircolors.hin: Add a TERM directive for cons25. + +2007-01-04 Jim Meyering + + * Makefile.cfg (local-checks-to-skip): Skip strftime-check, in + case you don't have convenient access to glibc info documentation. + + Use the release year, not the current year. + * src/groups.sh (version): Use a better name: @RELEASE_YEAR at . + * src/Makefile.am (RELEASE_YEAR): Define it. + (.sh): Use it. + Thanks to a prod from Eric Blake. + + Ensure that "group --version" always prints the current year. + * src/groups.sh (version): Use @CURRENT_YEAR@, rather than 2006. + * src/Makefile.am (.sh): Also substitute for @CURRENT_YEAR at . + Suggestion from Eric Blake. + + When decoding, always allow newlines in input, with almost no + performance impact. + * src/base64.c (do_decode): Initialize decode context. + Call base64_decode one more time, after all input is processed. + (usage): When decoding, newlines are always accepted. + + * tests/misc/base64: Add a bunch of tests, for the above. + * gl/lib/base64.c: Include . + (base64_decode_ctx_init, get_4, decode_4): New functions. + (base64_decode): Efficiently handle interspersed newlines. + (base64_decode_alloc): Update signature. + * gl/lib/base64.h (struct base64_decode_context): Define. + (base64_decode_ctx_init): Add prototype. + (base64_decode, base64_decode_alloc): Update prototypes. + + * gl/lib/base64.c: Copied from gnulib. + * gl/lib/base64.h: Likewise. + +2007-01-03 Jim Meyering + + * THANKS: Add Evan Hunt. + +2007-01-03 Bruno Haible + + Avoid spurious test failures on MacOS X 10.3.9, in a German locale. + * tests/chown/deref: Apply lang-default. + * tests/misc/split-a: Likewise. + * tests/mv/reply-no: Likewise. + + * src/copy.c (copy_internal): Use mkfifo as a fallback if mknod fails. + Needed on MacOS X. + +2007-01-02 Paul Eggert + + Now, "ls -FRL" always follows symbolic links on Linux. + * NEWS: Mention this bug fix. + * src/ls.c (gobble_file): Fix bug reported by + Nobuyuki Tsuchimura in + http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00152.html + where "ls -FRL" didn't follow a symbolic link in some cases on Linux. + * tests/ls/follow-slink: Add a test for this case. + +2007-01-01 Jim Meyering + + * tests/rm/fail-eperm: Revert last change. The PATH=... setting + is not honored at least on HP-UX 11.23 systems. + Instead, simply transform the actual output diagnostic. + Test failure reported by Bob Proulx. + +2006-12-30 Jim Meyering + + * bootstrap (gnulib_extra_files): Remove announce-gen. + * bootstrap.conf (gnulib_modules): Add it here instead, now that + it's a module. + + * tests/misc/base64: Factor a long, repetitive string. + + * src/c99-to-c89.diff: Adjust remove.c offsets. + + Clean up after the change of 2006-12-28. + * src/remove.c (AD_pop_and_chdir): Change **DIRP parameter to *DIRP, + now that this function never modifies the pointer. Adjust comments + and code accordingly. + (remove_dir): Set "dirp" to NULL right after AD_pop_and_chdir call, + now that AD_pop_and_chdir no longer does that. + + * tests/rm/fail-eperm: Avoid spurious differences (the error function + from latest glibc no longer prints the full program_name): so don't + invoke rm via ../../src/rm. Instead, invoke it via "PATH=../../src rm". + + * tests/mv/acl (skip): Skip this test also if the destination + directory, which is on a different file system, lacks ACL support. + + * src/copy.c (copy_reg): Rewrite a comment that was rendered + inaccurate by the 2006-10-18 change. + +2006-12-28 Jim Meyering + + When moving "up" the hierarchy, be careful to remove a just-emptied + directory before opening ".", to avoid trouble with file system + implementations that cache readdir results at opendir-time. + * src/remove.c (AD_pop_and_chdir): Add a file descriptor parameter. + Don't update **DIRP. Don't call fdopendir here. + (remove_dir): Call fdopendir here instead. + Report and patch from Mikulas Patocka: + + +2006-12-27 Jim Meyering + + * src/tail.c (usage): Mention +N for --bytes and --lines. + Suggestion from Evan Hunt. + +2006-12-26 Jim Meyering + + * configure.ac: Require autoconf-2.61 and automake-1.10. + Without the former (even with autoconf-2.60), "make distcheck" + would fail (without the 2006-09-26 autoconf AC_CHECK_DECL fix), + due to an inttypes.h generated with CFLAGS including -pedantic. + With the old decl check, @HAVE_DECL_STRTOUMAX@ would be 0. + + * Makefile.maint (VC-tag): Define, so as to gpg-sign each release + tag, using the release version number as the message. + (vc-dist): Use $(VC-tag), rather than "$(VC) tag". + +2006-12-21 Paul Eggert + + * NEWS: dd bs= operands now silently override later ibs= and obs=, + as POSIX requires. + * src/dd.c (scanargs): Implement it. + * tests/dd/misc (outbytes): Test it. + * doc/coreutils.texi (dd invocation): Specify that bs=N + overrides later ibs and obs, undoing part of the + previous change. (The behavior was wrong.) + +2006-12-20 Jim Meyering + + "rm -rf /etc/motd" (run by non-root) now prints a diagnostic. + * src/remove.c (remove_entry): Handle EACCES for a non-directory, too. + Don't let a non-directory get by with errno == EPERM, either. + Check the file type directly (using cached stat value), rather + than trying to guess it from errno values. + Karl Berry reported that a cross-partition "mv /etc/issue ~" + failed with the um,... suboptimal diagnostic, + "mv: cannot remove `/etc/issue': Not a directory". + * tests/rm/Makefile.am (TESTS): Add fail-eacces. + * tests/rm/fail-eacces: New file. + * NEWS: Mention that both mv and rm are affected. + + "cut -f 2- A B" no longer triggers a double-free bug + * src/cut.c (cut_fields): Set file-scoped global to NULL after + freeing it. This avoids a double-free (and core dump on some systems) + for this usage: "echo 1>a; echo 2>b; cut -f2- a b". Reported by + James Hunt in . + * NEWS: List this bug fix. + * THANKS: Mention him. + * tests/misc/cut: New file. + * tests/misc/Makefile.am (TESTS): Add cut. + +2006-12-15 Jim Meyering + + * tests/cp/open-perm-race: Correct the gdb-existence check. + Don't run either subsequent gdb command in a sub-shell. + Reported by Thomas Schwinge. + * THANKS: bring up to date. + +2006-12-14 Paul Eggert + + Make sure cp -p isn't too generous with file permissions. + * tests/cp/Makefile.am (TESTS): Add file-perm-race. + * tests/cp/file-perm-race: New file. + [... truncated: 63949 lines follow ...] From bonefish at mail.berlios.de Sun Dec 16 19:35:55 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 16 Dec 2007 19:35:55 +0100 Subject: [Haiku-commits] r23132 - haiku/branches/developer/bonefish/optimization/build/jam Message-ID: <200712161835.lBGIZtPZ029047@sheep.berlios.de> Author: bonefish Date: 2007-12-16 19:35:54 +0100 (Sun, 16 Dec 2007) New Revision: 23132 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23132&view=rev Modified: haiku/branches/developer/bonefish/optimization/build/jam/BuildSetup haiku/branches/developer/bonefish/optimization/build/jam/KernelRules Log: Introduced {HAIKU,HOST,TARGET}_KERNEL_DEFINES and moved the _KERNEL_MODE macros from the *_KERNEL_{CC,C++}_FLAGS variables. SetupKernel additionally sets DEFINES on the objects, now. These changes cause _KERNEL_MODE to be defined in kernel assembly code as well. Modified: haiku/branches/developer/bonefish/optimization/build/jam/BuildSetup =================================================================== --- haiku/branches/developer/bonefish/optimization/build/jam/BuildSetup 2007-12-16 18:32:10 UTC (rev 23131) +++ haiku/branches/developer/bonefish/optimization/build/jam/BuildSetup 2007-12-16 18:35:54 UTC (rev 23132) @@ -193,9 +193,10 @@ HAIKU_C++FLAGS += -Wno-multichar ; HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin -Wno-multichar - -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions -Wno-multichar - -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; +HAIKU_KERNEL_DEFINES += _KERNEL_MODE ; if $(HAIKU_GCC_VERSION[1]) >= 3 { HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ; @@ -432,6 +433,7 @@ -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; HOST_KERNEL_C++FLAGS += $(HOST_GCC_BASE_FLAGS) -finline -fno-builtin -fno-exceptions -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; +HOST_KERNEL_DEFINES += _KERNEL_MODE ; HOST_KERNEL_PIC_CCFLAGS = -fno-pic ; HOST_KERNEL_PIC_LINKFLAGS = ; @@ -647,6 +649,7 @@ HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES ARFLAGS UNARFLAGS + KERNEL_DEFINES KERNEL_CCFLAGS KERNEL_C++FLAGS KERNEL_PIC_CCFLAGS KERNEL_PIC_LINKFLAGS Modified: haiku/branches/developer/bonefish/optimization/build/jam/KernelRules =================================================================== --- haiku/branches/developer/bonefish/optimization/build/jam/KernelRules 2007-12-16 18:32:10 UTC (rev 23131) +++ haiku/branches/developer/bonefish/optimization/build/jam/KernelRules 2007-12-16 18:35:54 UTC (rev 23132) @@ -20,6 +20,7 @@ # add kernel flags for the object ObjectCcFlags $(object) : $(TARGET_KERNEL_CCFLAGS) $(2) ; ObjectC++Flags $(object) : $(TARGET_KERNEL_C++FLAGS) $(2) ; + ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ; # override warning flags TARGET_WARNING_CCFLAGS on $(object) = $(TARGET_KERNEL_WARNING_CCFLAGS) ; From korli at mail.berlios.de Sun Dec 16 19:38:28 2007 From: korli at mail.berlios.de (korli at BerliOS) Date: Sun, 16 Dec 2007 19:38:28 +0100 Subject: [Haiku-commits] r23133 - in haiku/trunk/src/bin/coreutils: lib src Message-ID: <200712161838.lBGIcSww029188@sheep.berlios.de> Author: korli Date: 2007-12-16 19:38:28 +0100 (Sun, 16 Dec 2007) New Revision: 23133 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23133&view=rev Modified: haiku/trunk/src/bin/coreutils/lib/config.h haiku/trunk/src/bin/coreutils/src/coreutils.rdef Log: forgot to update version info Modified: haiku/trunk/src/bin/coreutils/lib/config.h =================================================================== --- haiku/trunk/src/bin/coreutils/lib/config.h 2007-12-16 18:35:54 UTC (rev 23132) +++ haiku/trunk/src/bin/coreutils/lib/config.h 2007-12-16 18:38:28 UTC (rev 23133) @@ -1512,13 +1512,13 @@ #define PACKAGE_NAME "GNU coreutils" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU coreutils 6.7" +#define PACKAGE_STRING "GNU coreutils 6.9" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "coreutils" /* Define to the version of this package. */ -#define PACKAGE_VERSION "6.7" +#define PACKAGE_VERSION "6.9" /* the number of pending output bytes on stream `fp' */ #define PENDING_OUTPUT_N_BYTES fp->_IO_write_ptr - fp->_IO_write_base @@ -1658,7 +1658,7 @@ #define USE_UNLOCKED_IO 1 /* Version number of package */ -#define VERSION "6.7" +#define VERSION "6.9" /* Define if unsetenv() returns void, not int. */ /* #undef VOID_UNSETENV */ Modified: haiku/trunk/src/bin/coreutils/src/coreutils.rdef =================================================================== --- haiku/trunk/src/bin/coreutils/src/coreutils.rdef 2007-12-16 18:35:54 UTC (rev 23132) +++ haiku/trunk/src/bin/coreutils/src/coreutils.rdef 2007-12-16 18:38:28 UTC (rev 23133) @@ -1,10 +1,10 @@ resource app_version { major = 6, - middle = 7, + middle = 9, minor = 0, variety = B_APPV_FINAL, internal = 0, short_info = "coreutils", - long_info = "coreutils ?2006 The Free Software Foundation" + long_info = "coreutils ?2007 The Free Software Foundation" }; From bonefish at mail.berlios.de Sun Dec 16 19:46:10 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Sun, 16 Dec 2007 19:46:10 +0100 Subject: [Haiku-commits] r23134 - in haiku/branches/developer/bonefish/optimization: headers/private/kernel/arch/x86 src/system/boot src/system/boot/arch/m68k src/system/boot/arch/ppc src/system/boot/arch/x86 src/system/kernel/arch/x86 src/system/kernel/lib src/system/libroot/posix/string src/system/libroot/posix/string/arch/x86 Message-ID: <200712161846.lBGIkA0Z029618@sheep.berlios.de> Author: bonefish Date: 2007-12-16 19:46:08 +0100 (Sun, 16 Dec 2007) New Revision: 23134 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23134&view=rev Added: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_string.S Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h haiku/branches/developer/bonefish/optimization/src/system/boot/Jamfile haiku/branches/developer/bonefish/optimization/src/system/boot/arch/m68k/Jamfile haiku/branches/developer/bonefish/optimization/src/system/boot/arch/ppc/Jamfile haiku/branches/developer/bonefish/optimization/src/system/boot/arch/x86/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp haiku/branches/developer/bonefish/optimization/src/system/kernel/lib/Jamfile haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/Jamfile haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S Log: * Added optional get_optimized_functions() hook to x86_cpu_module_info. The modules can use it to provide processor-optimized versions of common functions (currently only memcpy()). * Moved the x86 memcpy() implementation into the kernel. The userland uses code provided via the commpage. * Added a level of indirection (jmp *...) for x86 memcpy() in the kernel. When the respective CPU module is available and provides an optimized version, that one will be used instead of the generic one. Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_commpage.h 2007-12-16 18:46:08 UTC (rev 23134) @@ -9,7 +9,8 @@ # error Must not be included directly. Include instead! #endif -#define COMMPAGE_ENTRY_X86_SYSCALL COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC +#define COMMPAGE_ENTRY_X86_SYSCALL (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0) +#define COMMPAGE_ENTRY_X86_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1) #define ARCH_USER_COMMPAGE_ADDR (0xffff0000) Modified: haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h =================================================================== --- haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/headers/private/kernel/arch/x86/arch_cpu.h 2007-12-16 18:46:08 UTC (rev 23134) @@ -97,6 +97,11 @@ #ifndef _ASSEMBLER +typedef struct x86_optimized_functions { + void (*memcpy)(void* dest, const void* source, size_t count); + void* memcpy_end; +} x86_optimized_functions; + typedef struct x86_cpu_module_info { module_info info; uint32 (*count_mtrrs)(void); @@ -105,6 +110,8 @@ void (*set_mtrr)(uint32 index, uint64 base, uint64 length, uint8 type); status_t (*get_mtrr)(uint32 index, uint64 *_base, uint64 *_length, uint8 *_type); + + void (*get_optimized_functions)(x86_optimized_functions* functions); } x86_cpu_module_info; Modified: haiku/branches/developer/bonefish/optimization/src/system/boot/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/boot/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/boot/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -22,14 +22,8 @@ strchr.o strrchr.o strtol.o - arch_string.o ; -local platformObjects = ; -if $(TARGET_ARCH) = x86 { - platformObjects += cpuid.o ; -} - AddResources zbeos : boot_loader.rdef ; KernelLd boot_loader_$(TARGET_BOOT_PLATFORM) : @@ -50,9 +44,6 @@ # kernel) $(librootFunctions:G=src!system!kernel!lib) - # platform specific objects - $(platformObjects) - : $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/boot_loader_$(TARGET_BOOT_PLATFORM).ld : -Bstatic ; Modified: haiku/branches/developer/bonefish/optimization/src/system/boot/arch/m68k/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/boot/arch/m68k/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/boot/arch/m68k/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -1,17 +1,14 @@ SubDir HAIKU_TOP src system boot arch m68k ; -{ - local defines = - _BOOT_MODE - ; +DEFINES += _BOOT_MODE ; - defines = [ FDefines $(defines) ] ; - SubDirCcFlags $(defines) -Wall -Wno-multichar ; - SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; -} +local librootArchObjects = + arch_string.o +; KernelMergeObject boot_arch_m68k.o : arch_elf.cpp + $(librootArchObjects) ; SEARCH on [ FGristFiles arch_elf.cpp ] Modified: haiku/branches/developer/bonefish/optimization/src/system/boot/arch/ppc/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/boot/arch/ppc/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/boot/arch/ppc/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -1,17 +1,14 @@ SubDir HAIKU_TOP src system boot arch ppc ; -{ - local defines = - _BOOT_MODE - ; +DEFINES += _BOOT_MODE ; - defines = [ FDefines $(defines) ] ; - SubDirCcFlags $(defines) -Wall -Wno-multichar ; - SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; -} +local librootArchObjects = + arch_string.o +; KernelMergeObject boot_arch_ppc.o : arch_elf.cpp + $(librootArchObjects) ; SEARCH on [ FGristFiles arch_elf.cpp ] Modified: haiku/branches/developer/bonefish/optimization/src/system/boot/arch/x86/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/boot/arch/x86/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/boot/arch/x86/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -1,18 +1,22 @@ SubDir HAIKU_TOP src system boot arch x86 ; -{ - local defines = - _BOOT_MODE - ; +DEFINES += _BOOT_MODE ; - defines = [ FDefines $(defines) ] ; - SubDirCcFlags $(defines) -Wall -Wno-multichar ; - SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-rtti ; -} +local kernelArchSources = + arch_elf.c + arch_string.S +; +local kernelArchObjects = + cpuid.o +; + KernelMergeObject boot_arch_x86.o : - arch_elf.c + $(kernelArchSources) + : # additional flags + : + $(kernelArchObjects) ; -SEARCH on [ FGristFiles arch_elf.c ] +SEARCH on [ FGristFiles $(kernelArchSources) ] = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_ARCH) ] ; Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -21,6 +21,7 @@ # arch_selector.c arch_real_time_clock.c arch_smp.c + arch_string.S arch_thread.c arch_timer.c arch_vm.cpp Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_cpu.c 2007-12-16 18:46:08 UTC (rev 23134) @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,16 @@ static x86_cpu_module_info *sCpuModule; + +extern void memcpy_generic(void* dest, const void* source, size_t count); +extern int memcpy_generic_end; + +x86_optimized_functions gOptimizedFunctions = { + .memcpy = memcpy_generic, + .memcpy_end = &memcpy_generic_end +}; + + /** Disable CPU caches, and invalidate them. */ static void @@ -541,6 +552,24 @@ if (x86_count_mtrrs() > 0) call_all_cpus(&init_mtrrs, NULL); + // get optimized functions from the CPU module + if (sCpuModule != NULL && sCpuModule->get_optimized_functions != NULL) { + x86_optimized_functions functions; + memset(&functions, 0, sizeof(functions)); + + sCpuModule->get_optimized_functions(&functions); + + if (functions.memcpy != NULL) { + gOptimizedFunctions.memcpy = functions.memcpy; + gOptimizedFunctions.memcpy_end = functions.memcpy_end; + } + } + + // put the optimized functions into the commpage + fill_commpage_entry(COMMPAGE_ENTRY_X86_MEMCPY, gOptimizedFunctions.memcpy, + (addr_t)gOptimizedFunctions.memcpy_end + - (addr_t)gOptimizedFunctions.memcpy); + return B_OK; } Copied: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_string.S (from rev 23070, haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S) =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S 2007-12-06 21:09:35 UTC (rev 23070) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_string.S 2007-12-16 18:46:08 UTC (rev 23134) @@ -0,0 +1,54 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ + +#if !_BOOT_MODE +# include "asm_offsets.h" +#endif + + +#define FUNCTION(x) .global x; .type x, at function; x +#define SYM(x) .global x; x + + +// We don't need the indirection in the boot loader. +#if _BOOT_MODE +# define memcpy_generic memcpy +#endif + + +.align 4 +FUNCTION(memcpy_generic): + pushl %esi + pushl %edi + movl 12(%esp),%edi /* dest */ + movl %edi,%eax /* save dest ptr as return address */ + movl 16(%esp),%esi /* source */ + movl 20(%esp),%ecx /* count */ + + /* move by words */ + cld + shrl $2,%ecx + rep + movsl + + /* move any remaining data by bytes */ + movl 20(%esp),%ecx + andl $3,%ecx + rep + movsb + + popl %edi + popl %esi + ret +SYM(memcpy_generic_end): + + +#if !_BOOT_MODE + +.align 4 +FUNCTION(memcpy): + jmp *(gOptimizedFunctions + X86_OPTIMIZED_FUNCTIONS_memcpy) + +#endif // !_BOOT_MODE Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/asm_offsets.cpp 2007-12-16 18:46:08 UTC (rev 23134) @@ -49,4 +49,8 @@ DEFINE_SIZEOF_MACRO(SYSCALL_INFO, syscall_info); DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, function); DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, parameter_size); + + // struct x86_optimized_functions + DEFINE_OFFSET_MACRO(X86_OPTIMIZED_FUNCTIONS, x86_optimized_functions, + memcpy); } Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/lib/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/lib/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/lib/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -113,6 +113,8 @@ : $(TARGET_KERNEL_PIC_CCFLAGS) ; +# TODO: Move the following arch specific part into arch/$(TARGET_ARCH) subdirs! + SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : @@ -132,7 +134,7 @@ siglongjmp.S sigsetjmp.S kernel_setjmp_save_sigs.c - arch_string.S + arch_string.S # TODO: Not needed for X86! : $(TARGET_KERNEL_PIC_CCFLAGS) ; Modified: haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/Jamfile =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/Jamfile 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/Jamfile 2007-12-16 18:46:08 UTC (rev 23134) @@ -39,6 +39,8 @@ SubDir HAIKU_TOP src system libroot posix string arch $(TARGET_ARCH) ; +UsePrivateKernelHeaders ; + MergeObject posix_string_arch_$(TARGET_ARCH).o : arch_string.S ; Modified: haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S 2007-12-16 18:38:28 UTC (rev 23133) +++ haiku/branches/developer/bonefish/optimization/src/system/libroot/posix/string/arch/x86/arch_string.S 2007-12-16 18:46:08 UTC (rev 23134) @@ -3,29 +3,16 @@ ** Distributed under the terms of the NewOS License. */ +#if !_KERNEL_MODE + // TODO: This should not even be compiled for the kernel. Fix the TODO in + // src/system/kernel/lib/Jamfile! + +#include + #define FUNCTION(x) .global x; .type x, at function; x .align 4 FUNCTION(memcpy): - pushl %esi - pushl %edi - movl 12(%esp),%edi /* dest */ - movl %edi,%eax /* save dest ptr as return address */ - movl 16(%esp),%esi /* source */ - movl 20(%esp),%ecx /* count */ - - /* move by words */ - cld - shrl $2,%ecx - rep - movsl + jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_MEMCPY * 4) - /* move any remaining data by bytes */ - movl 20(%esp),%ecx - andl $3,%ecx - rep - movsb - - popl %edi - popl %esi - ret +#endif // !_KERNEL_MODE From axeld at mail.berlios.de Sun Dec 16 20:42:27 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 16 Dec 2007 20:42:27 +0100 Subject: [Haiku-commits] r23135 - haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe Message-ID: <200712161942.lBGJgRLL032454@sheep.berlios.de> Author: axeld Date: 2007-12-16 20:42:26 +0100 (Sun, 16 Dec 2007) New Revision: 23135 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23135&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/glue.c Log: Forgot to add the SWI taskqueues - this should fix #1668. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/glue.c 2007-12-16 18:46:08 UTC (rev 23134) +++ haiku/trunk/src/add-ons/kernel/drivers/network/nforce/dev/nfe/glue.c 2007-12-16 19:42:26 UTC (rev 23135) @@ -9,7 +9,7 @@ HAIKU_FBSD_DRIVER_GLUE(nforce, nfe, pci) -HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE); +HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_FAST_TASKQUEUE | FBSD_SWI_TASKQUEUE); NO_HAIKU_CHECK_DISABLE_INTERRUPTS(); NO_HAIKU_REENABLE_INTERRUPTS(); From korli at users.berlios.de Sun Dec 16 21:22:42 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Sun, 16 Dec 2007 21:22:42 +0100 Subject: [Haiku-commits] r23127 - buildtools/trunk/legacy/gcc/gcc In-Reply-To: <20071216183640.1748.1@bee.hirschkaefer.site> References: <200712161727.lBGHRbTx007684@sheep.berlios.de> <20071216183640.1748.1@bee.hirschkaefer.site> Message-ID: Hi Oliver, 2007/12/16, Oliver Tappe : > Without pretending to know much about it, I'd say since your change fixes the > problem, it should be ok. When I looked up float.h in the different > gcc-versions that exist for BeOS, all of them seem to imply double == long > double. I tested briefly on BeOS and the libc provided by BeOS exposes the long double printf bug. BTW it would be cool to have a new gcc 2.95 release for people building Haiku on BeOS, maybe next year :) > > I find it weird that this has not triggered many more errors when these > compilers are used on BeOS. Well, then again, maybe it has and we just never > noticed the real cause ... ;-) > If only the BeOS libc (and Haiku's one) was impacted by the bug, one can't change anything when building BeOS user apps (long double printf won't work). Bye, J?r?me From marcusoverhagen at mail.berlios.de Sun Dec 16 23:15:46 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 16 Dec 2007 23:15:46 +0100 Subject: [Haiku-commits] r23136 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200712162215.lBGMFkP6008141@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-16 23:15:46 +0100 (Sun, 16 Dec 2007) New Revision: 23136 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23136&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: preserve IRQ when splitting Jmicron devices Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-16 19:42:26 UTC (rev 23135) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-16 22:15:46 UTC (rev 23136) @@ -38,6 +38,7 @@ dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); uint32 val = pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4); if (!(val & (1 << 30))) { + uint8 irq = pci->ReadPciConfig(domain, bus, device, function, 0x3c, 1); dprintf("jmicron_fixup_ahci: enabling split device mode\n"); val &= ~(1 << 24); val |= (1 << 25) | (1 << 30); @@ -46,6 +47,7 @@ val &= ~(1 << 16); val |= (1 << 1) | (1 << 17) | (1 << 22); pci->WritePciConfig(domain, bus, device, function, 0x40, 4, val); + pci->WritePciConfig(domain, bus, device, function, 0x3c, 1, irq); } dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); From marcusoverhagen at mail.berlios.de Sun Dec 16 23:49:46 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 16 Dec 2007 23:49:46 +0100 Subject: [Haiku-commits] r23137 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200712162249.lBGMnkLM009706@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-16 23:49:45 +0100 (Sun, 16 Dec 2007) New Revision: 23137 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23137&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h Log: PCI bus enumeration shouldn't be required on x86, thus enable it only for PPC an M68k Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-12-16 22:15:46 UTC (rev 23136) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-12-16 22:49:45 UTC (rev 23137) @@ -310,7 +310,11 @@ PCI::PCI() : fRootBus(0) , fDomainCount(0) + , fBusEnumeration(false) { + #if defined(__POWERPC__) || defined(__M68K__) + fBusEnumeration = true; + #endif } @@ -329,9 +333,17 @@ ppnext = &bus->next; } - for (int i = 0; i < fDomainCount; i++) { - EnumerateBus(i, 0); + if (fBusEnumeration) { + for (int i = 0; i < fDomainCount; i++) { + EnumerateBus(i, 0); + } } + + if (1) { + for (int i = 0; i < fDomainCount; i++) { + FixupDevices(i, 0); + } + } if (fRootBus) { DiscoverBus(fRootBus); @@ -508,8 +520,6 @@ if (device_id == 0xffff) continue; - pci_fixup_device(this, domain, bus, dev, func); - uint8 base_class = ReadPciConfig(domain, bus, dev, func, PCI_class_base, 1); uint8 sub_class = ReadPciConfig(domain, bus, dev, func, PCI_class_sub, 1); if (base_class != PCI_bridge || sub_class != PCI_pci) @@ -555,7 +565,42 @@ } +void +PCI::FixupDevices(int domain, uint8 bus) +{ + TRACE(("PCI: FixupDevices domain %u, bus %u\n", domain, bus)); + int maxBusDevices = GetDomainData(domain)->max_bus_devices; + + for (int dev = 0; dev < maxBusDevices; dev++) { + uint16 vendorId = ReadPciConfig(domain, bus, dev, 0, PCI_vendor_id, 2); + if (vendorId == 0xffff) + continue; + + uint8 type = ReadPciConfig(domain, bus, dev, 0, PCI_header_type, 1); + int nfunc = (type & PCI_multifunction) ? 8 : 1; + for (int func = 0; func < nfunc; func++) { + uint16 deviceId = ReadPciConfig(domain, bus, dev, func, PCI_device_id, 2); + if (deviceId == 0xffff) + continue; + + pci_fixup_device(this, domain, bus, dev, func); + + uint8 base_class = ReadPciConfig(domain, bus, dev, func, PCI_class_base, 1); + if (base_class != PCI_bridge) + continue; + uint8 sub_class = ReadPciConfig(domain, bus, dev, func, PCI_class_sub, 1); + if (sub_class != PCI_pci) + continue; + + int busBehindBridge = ReadPciConfig(domain, bus, dev, func, PCI_secondary_bus, 1); + + FixupDevices(domain, busBehindBridge); + } + } +} + + void PCI::DiscoverBus(PCIBus *bus) { Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2007-12-16 22:15:46 UTC (rev 23136) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.h 2007-12-16 22:49:45 UTC (rev 23137) @@ -83,6 +83,8 @@ void EnumerateBus(int domain, uint8 bus, uint8 *subordinate_bus = NULL); + void FixupDevices(int domain, uint8 bus); + void DiscoverBus(PCIBus *bus); void DiscoverDevice(PCIBus *bus, uint8 dev, uint8 func); @@ -111,6 +113,7 @@ domain_data fDomainData[MAX_PCI_DOMAINS]; int fDomainCount; + bool fBusEnumeration; }; #endif // __cplusplus From korli at users.berlios.de Mon Dec 17 08:50:01 2007 From: korli at users.berlios.de (=?ISO-8859-1?Q?J=E9r=F4me_Duval?=) Date: Mon, 17 Dec 2007 08:50:01 +0100 Subject: [Haiku-commits] r23137 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: <200712162249.lBGMnkLM009706@sheep.berlios.de> References: <200712162249.lBGMnkLM009706@sheep.berlios.de> Message-ID: Hi Marcus, 2007/12/16, marcusoverhagen at BerliOS : > + void FixupDevices(int domain, uint8 bus); Seems you forgot to explain what does this function. Bye, J?r?me From bonefish at mail.berlios.de Tue Dec 18 00:24:42 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 18 Dec 2007 00:24:42 +0100 Subject: [Haiku-commits] r23138 - haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86 Message-ID: <200712172324.lBHNOgnd012016@sheep.berlios.de> Author: bonefish Date: 2007-12-18 00:24:41 +0100 (Tue, 18 Dec 2007) New Revision: 23138 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23138&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S Log: Make sure thread_at_kernel_exit() is called with interrupts enabled. This isn't already the case when the interrupt handler function didn't enable interrupts (happens for hardware interrupt handlers). Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-16 22:49:45 UTC (rev 23137) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/arch/x86/arch_interrupts.S 2007-12-17 23:24:41 UTC (rev 23138) @@ -388,6 +388,9 @@ POP_IFRAME_AND_RETURN() kernel_exit_handle_signals: + // make sure interrupts are enabled (they are, when coming from a syscall + // but otherwise they might be disabled) + sti call thread_at_kernel_exit cli // disable interrupts jmp kernel_exit_work_done From bonefish at mail.berlios.de Tue Dec 18 01:25:27 2007 From: bonefish at mail.berlios.de (bonefish at BerliOS) Date: Tue, 18 Dec 2007 01:25:27 +0100 Subject: [Haiku-commits] r23139 - haiku/branches/developer/bonefish/optimization/src/system/kernel/fs Message-ID: <200712180025.lBI0PR60001986@sheep.berlios.de> Author: bonefish Date: 2007-12-18 01:25:26 +0100 (Tue, 18 Dec 2007) New Revision: 23139 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23139&view=rev Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/vfs.cpp Log: Fixed build with tracing enabled. Not that it does any good to enable it, though... Modified: haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/vfs.cpp =================================================================== --- haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/vfs.cpp 2007-12-17 23:24:41 UTC (rev 23138) +++ haiku/branches/developer/bonefish/optimization/src/system/kernel/fs/vfs.cpp 2007-12-18 00:25:26 UTC (rev 23139) @@ -4184,7 +4184,7 @@ file_select(struct file_descriptor *descriptor, uint8 event, struct selectsync *sync) { - FUNCTION(("file_select(%p, %u, %lu, %p)\n", descriptor, event, ref, sync)); + FUNCTION(("file_select(%p, %u, %p)\n", descriptor, event, sync)); struct vnode *vnode = descriptor->u.vnode; From marcusoverhagen at arcor.de Tue Dec 18 14:49:59 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Tue, 18 Dec 2007 14:49:59 +0100 (CET) Subject: [Haiku-commits] r23137 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: References: <200712162249.lBGMnkLM009706@sheep.berlios.de> Message-ID: <11636099.1197985799505.JavaMail.ngmail@webmail16> J?r?me Duval wrote: > Hi Marcus, > > 2007/12/16, marcusoverhagen at BerliOS : > > + void FixupDevices(int domain, uint8 bus); > > Seems you forgot to explain what does this function. Previously, EnumerateBus() was calling pci_fixup_device(this, domain, bus, dev, func) while walking the pci busses. This has been relocated into a separate bus walking done by the new FixupDevices(). See http://svn.berlios.de/viewcvs/haiku?rev=23137&view=rev for detail. Generally, we have to apply some workaounrds, similar to linux drivers/pci/quirks.c I plan on working on PCI device resource assignment (io, memory, irq) and configuration during the next days. This should also improve IDE/ATA functionality. regards Marcus 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 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From revol at free.fr Tue Dec 18 15:43:59 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Tue, 18 Dec 2007 15:43:59 +0100 CET Subject: [Haiku-commits] r23137 - haiku/trunk/src/add-ons/kernel/bus_managers/pci In-Reply-To: <11636099.1197985799505.JavaMail.ngmail@webmail16> Message-ID: <864076458-BeMail@laptop> > Generally, we have to apply some workaounrds, similar to linux > drivers/pci/quirks.c > Maybe I should add the ati ixp hack there as well, but I'm not sure irq is initialized enough at that time... actually for the pit timer it shouldn't matter as it's just a bit mask on the trigger-edge level register that isn't touched elsewhere (only read). But for apic timer I'm not sure. > I plan on working on PCI device resource assignment (io, memory, irq) > and configuration > during the next days. This should also improve IDE/ATA functionality. I started axing into the config manager for the 68k port, to be able to register fake devices (to emulate a pci and isa bus by faking system devices on them in ordre to be able to reuse generic drivers as much as possible). I'll have to dig that again. Fran?ois. From axeld at pinc-software.de Tue Dec 18 17:48:10 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Tue, 18 Dec 2007 17:48:10 +0100 CET Subject: [Haiku-commits] r23118 - in haiku/trunk: headers/private/kernel/arch/x86 src/system/boot/platform/bios_ia32 In-Reply-To: <638833592-BeMail@laptop> Message-ID: <27806577643-BeMail@zon> "Fran?ois Revol" wrote: > > Ignore disabled local APICs. > Talking about APIC, I'll add a boot setting to disable APICs (at > least > apic timer), to see if I can get my asus laptop cold boot with the > regular timer and the same hack that was required in zeta. > Haiku used to warm boot until apic timers got used... > The hack requires forcing the trigger type (to level IIRC) to get > clock > IRQs from the buggy ATI IXP chipset. It works if I disable the APIC You mean the BIOS incorrectly sets the IRQ mode of a legacy interrupt to edge when it would need to be level? If that's the case, we could just always manually reconfigure all legacy interrupts to level, and we're done, right? Bye, Axel. From mmlr at mail.berlios.de Tue Dec 18 19:48:51 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 18 Dec 2007 19:48:51 +0100 Subject: [Haiku-commits] r23140 - haiku/trunk/src/add-ons/kernel/drivers/misc Message-ID: <200712181848.lBIImpWk006796@sheep.berlios.de> Author: mmlr Date: 2007-12-18 19:48:50 +0100 (Tue, 18 Dec 2007) New Revision: 23140 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23140&view=rev Modified: haiku/trunk/src/add-ons/kernel/drivers/misc/mem.c Log: * Fix the mem driver to not always return invalid argument * Cleanup Modified: haiku/trunk/src/add-ons/kernel/drivers/misc/mem.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/misc/mem.c 2007-12-18 00:25:26 UTC (rev 23139) +++ haiku/trunk/src/add-ons/kernel/drivers/misc/mem.c 2007-12-18 18:48:50 UTC (rev 23140) @@ -2,8 +2,6 @@ * Copyright 2007, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ - - #include #include #include @@ -21,11 +19,11 @@ static status_t mem_open(const char*, uint32, void**); static status_t mem_close(void*); static status_t mem_free(void*); -//static status_t mem_control(void*, uint32, void*, size_t); static status_t mem_read(void*, off_t, void*, size_t*); static status_t mem_write(void*, off_t, const void*, size_t*); -static area_id mem_map_target(off_t position, size_t len, uint32 protection, void **va); +static area_id mem_map_target(off_t position, size_t length, uint32 protection, + void **virtualAddress); static const char* mem_name[] = { DEVICE_NAME, @@ -86,7 +84,6 @@ { // not really needed. *cookie = NULL; - return B_OK; } @@ -104,87 +101,81 @@ return B_OK; } -/* -status_t -mem_control(void* cookie, uint32 op, void* arg, size_t length) -{ - return ENOSYS; -} -*/ status_t mem_read(void* cookie, off_t position, void* buffer, size_t* numBytes) { - status_t err; - void *va; + void *virtualAddress; area_id area; - - /* check perms */ - err = EPERM; - if (getuid() != 0 && geteuid() != 0) - goto err1; - err = area = mem_map_target(position, *numBytes, B_READ_AREA, &va); - if (err < 0) - goto err1; - memcpy(buffer, va, *numBytes); + + /* check permissions */ + if (getuid() != 0 && geteuid() != 0) { + *numBytes = 0; + return EPERM; + } + + area = mem_map_target(position, *numBytes, B_READ_AREA, &virtualAddress); + if (area < 0) { + *numBytes = 0; + return area; + } + + memcpy(buffer, virtualAddress, *numBytes); delete_area(area); return B_OK; -err1: - *numBytes = 0; - return err; } status_t mem_write(void* cookie, off_t position, const void* buffer, size_t* numBytes) { - status_t err; - void *va; + void *virtualAddress; area_id area; - - /* check perms */ - err = EPERM; - if (getuid() != 0 && geteuid() != 0) - goto err1; - err = area = mem_map_target(position, *numBytes, B_WRITE_AREA, &va); - if (err < 0) - goto err1; - memcpy(va, buffer, *numBytes); + + /* check permissions */ + if (getuid() != 0 && geteuid() != 0) { + *numBytes = 0; + return EPERM; + } + + area = mem_map_target(position, *numBytes, B_WRITE_AREA, &virtualAddress); + if (area < 0) { + *numBytes = 0; + return area; + } + + memcpy(virtualAddress, buffer, *numBytes); delete_area(area); return B_OK; -err1: - *numBytes = 0; - return err; } + area_id -mem_map_target(off_t position, size_t len, uint32 protection, void **va) +mem_map_target(off_t position, size_t length, uint32 protection, + void **virtualAddress) { area_id area; - void *paddr; - void *vaddr; - int offset; + void *physicalAddress; + size_t offset; size_t size; - + /* SIZE_MAX actually but 2G should be enough anyway */ - if (len > SSIZE_MAX - B_PAGE_SIZE) + if (length > SSIZE_MAX - B_PAGE_SIZE) return EINVAL; - + /* the first page address */ - paddr = (void *)(addr_t)(position & ~((off_t)B_PAGE_SIZE - 1)); + physicalAddress = (void *)(addr_t)(position & ~((off_t)B_PAGE_SIZE - 1)); + /* offset of target into it */ - offset = position - (off_t)(addr_t)paddr; + offset = position - (off_t)(addr_t)physicalAddress; + /* size of the whole mapping (page rounded) */ - size = (offset + len + B_PAGE_SIZE - 1) & ~((size_t)B_PAGE_SIZE - 1); - - area = map_physical_memory("mem_driver_temp", - paddr, size, B_ANY_KERNEL_ADDRESS, - protection, &vaddr); - + size = (offset + length + B_PAGE_SIZE - 1) & ~((size_t)B_PAGE_SIZE - 1); + area = map_physical_memory("mem_driver_temp", physicalAddress, size, + B_ANY_KERNEL_ADDRESS, protection, virtualAddress); if (area < 0) return area; - - *va = vaddr + offset; - - return EINVAL; + + *virtualAddress += offset; + return area; } From mmlr at mail.berlios.de Tue Dec 18 20:46:27 2007 From: mmlr at mail.berlios.de (mmlr at BerliOS) Date: Tue, 18 Dec 2007 20:46:27 +0100 Subject: [Haiku-commits] r23141 - in haiku/trunk/src/system: boot/platform/bios_ia32 kernel kernel/arch/x86 Message-ID: <200712181946.lBIJkR4P014150@sheep.berlios.de> Author: mmlr Date: 2007-12-18 20:46:26 +0100 (Tue, 18 Dec 2007) New Revision: 23141 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23141&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c haiku/trunk/src/system/kernel/arch/x86/arch_smp.c haiku/trunk/src/system/kernel/smp.c haiku/trunk/src/system/kernel/timer.c Log: * Update the PAUSE macro from "rep; nop;" to "pause;" which is the same bytecode wise but more readable * Insert the pause op in all spin wait loops (as macro for platform independent sources or as inline assembly on x86 only files) * Fix some warnings with tracing on and extended some output * Minor cleanups here and there The pause instruction is implemented since P4 systems but is fully backwards compatible (it's a no-op prior to P4). According to Intel specs it reduces performance penalties as memory order violations can be avoided. Also power consumption is reduced. Most of all this will be beneficial to hyper-threading systems as it frees resources to the other logical processor when one logical processor executes a fast spinning loop. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-18 18:48:50 UTC (rev 23140) +++ haiku/trunk/src/system/boot/platform/bios_ia32/smp.cpp 2007-12-18 19:46:26 UTC (rev 23141) @@ -442,7 +442,7 @@ t1 = system_time(); apic_write(APIC_INITIAL_TIMER_COUNT, 0xffffffff); // start the counter - execute_n_instructions(128*20000); + execute_n_instructions(128 * 20000); count = apic_read(APIC_CURRENT_TIMER_COUNT); t2 = system_time(); @@ -544,7 +544,7 @@ dprintf("wait for delivery\n"); // wait for pending to end while ((apic_read(APIC_INTR_COMMAND_1) & APIC_DELIVERY_STATUS) != 0) - ; + asm volatile ("pause;"); dprintf("deassert INIT\n"); /* deassert INIT */ @@ -558,7 +558,7 @@ dprintf("wait for delivery\n"); // wait for pending to end while ((apic_read(APIC_INTR_COMMAND_1) & APIC_DELIVERY_STATUS) != 0) - ; + asm volatile ("pause;"); /* wait 10ms */ spin(10000); @@ -586,7 +586,7 @@ dprintf("wait for delivery\n"); while ((apic_read(APIC_INTR_COMMAND_1) & APIC_DELIVERY_STATUS) != 0) - ; + asm volatile ("pause;"); } } Modified: haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2007-12-18 18:48:50 UTC (rev 23140) +++ haiku/trunk/src/system/kernel/arch/x86/arch_cpu.c 2007-12-18 19:46:26 UTC (rev 23141) @@ -106,7 +106,7 @@ // wait until all CPUs have arrived here atomic_add(&sWaitAllCPUs, 1); while (sWaitAllCPUs != smp_get_num_cpus()) - ; + asm volatile ("pause;"); disable_caches(); @@ -118,7 +118,7 @@ // wait until all CPUs have arrived here atomic_add(&sWaitAllCPUs, -1); while (sWaitAllCPUs != 0) - ; + asm volatile ("pause;"); } @@ -128,7 +128,7 @@ // wait until all CPUs have arrived here atomic_add(&sWaitAllCPUs, 1); while (sWaitAllCPUs != smp_get_num_cpus()) - ; + asm volatile ("pause;"); disable_caches(); @@ -139,7 +139,7 @@ // wait until all CPUs have arrived here atomic_add(&sWaitAllCPUs, -1); while (sWaitAllCPUs != 0) - ; + asm volatile ("pause;"); } Modified: haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c 2007-12-18 18:48:50 UTC (rev 23140) +++ haiku/trunk/src/system/kernel/arch/x86/arch_debug_console.c 2007-12-18 19:46:26 UTC (rev 23141) @@ -111,7 +111,7 @@ // wait until the transmitter empty bit is set while ((in8(sSerialBasePort + SERIAL_LINE_STATUS) & 0x20) == 0) - ; + asm volatile ("pause;"); out8(c, sSerialBasePort + SERIAL_TRANSMIT_BUFFER); } @@ -275,7 +275,7 @@ #endif while ((in8(sSerialBasePort + SERIAL_LINE_STATUS) & 0x1) == 0) - ; + asm volatile ("pause;"); return in8(sSerialBasePort + SERIAL_RECEIVE_BUFFER); } Modified: haiku/trunk/src/system/kernel/arch/x86/arch_smp.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_smp.c 2007-12-18 18:48:50 UTC (rev 23140) +++ haiku/trunk/src/system/kernel/arch/x86/arch_smp.c 2007-12-18 19:46:26 UTC (rev 23141) @@ -254,7 +254,8 @@ timeout = 100000000; // wait for message to be sent while ((apic_read(APIC_INTR_COMMAND_1) & APIC_DELIVERY_STATUS) != 0 && --timeout != 0) - ; + asm volatile ("pause;"); + if (timeout == 0) panic("arch_smp_send_ici: timeout, target_cpu %ld", target_cpu); Modified: haiku/trunk/src/system/kernel/smp.c =================================================================== --- haiku/trunk/src/system/kernel/smp.c 2007-12-18 18:48:50 UTC (rev 23140) +++ haiku/trunk/src/system/kernel/smp.c 2007-12-18 19:46:26 UTC (rev 23141) @@ -30,9 +30,9 @@ #endif #if __INTEL__ - #define PAUSE() asm volatile ("rep; nop;") +# define PAUSE() asm volatile ("pause;") #else - #define PAUSE() +# define PAUSE() #endif #define MSG_POOL_SIZE (SMP_MAX_CPUS * 4) @@ -248,7 +248,7 @@ if (msg != NULL) { smp_msgs[currentCPU] = msg->next; release_spinlock(&cpu_msg_spinlock[currentCPU]); - TRACE((" found msg %p in cpu mailbox\n", msg)); + TRACE((" cpu %d: found msg %p in cpu mailbox\n", currentCPU, msg)); *source_mailbox = MAILBOX_LOCAL; } else { // try getting one from the broadcast mailbox @@ -270,7 +270,7 @@ break; } release_spinlock(&broadcast_msg_spinlock); - TRACE((" found msg %p in broadcast mailbox\n", msg)); + TRACE((" cpu %d: found msg %p in broadcast mailbox\n", currentCPU, msg)); } return msg; } @@ -355,7 +355,7 @@ if (msg == NULL) return retval; - TRACE((" cpu %d message = %d\n", currentCPU, msg->message)); + TRACE((" cpu %ld message = %ld\n", currentCPU, msg->message)); switch (msg->message) { case SMP_MSG_INVALIDATE_PAGE_RANGE: @@ -396,7 +396,7 @@ cpu_status state = disable_interrupts(); while (*haltValue != 0) - ; + PAUSE(); restore_interrupts(state); } @@ -430,7 +430,7 @@ { struct smp_msg *msg; - TRACE(("smp_send_ici: target 0x%x, mess 0x%x, data 0x%lx, data2 0x%lx, data3 0x%lx, ptr %p, flags 0x%x\n", + TRACE(("smp_send_ici: target 0x%lx, mess 0x%lx, data 0x%lx, data2 0x%lx, data3 0x%lx, ptr %p, flags 0x%lx\n", targetCPU, message, data, data2, data3, data_ptr, flags)); if (sICIEnabled) { @@ -489,7 +489,7 @@ { struct smp_msg *msg; - TRACE(("smp_send_broadcast_ici: cpu %d mess 0x%x, data 0x%lx, data2 0x%lx, data3 0x%lx, ptr %p, flags 0x%x\n", + TRACE(("smp_send_broadcast_ici: cpu %ld mess 0x%lx, data 0x%lx, data2 0x%lx, data3 0x%lx, ptr %p, flags 0x%lx\n", smp_get_current_cpu(), message, data, data2, data3, data_ptr, flags)); if (sICIEnabled) { @@ -512,7 +512,7 @@ msg->done = false; TRACE(("smp_send_broadcast_ici%d: inserting msg %p into broadcast mbox\n", - smp_get_current_cpu(), msg)); + currentCPU, msg)); // stick it in the appropriate cpu's mailbox acquire_spinlock_nocheck(&broadcast_msg_spinlock); @@ -555,7 +555,6 @@ if (cpu > 0) { boot_cpu_spin[cpu] = 1; acquire_spinlock_nocheck(&boot_cpu_spin[cpu]); - return false; } @@ -582,10 +581,10 @@ void smp_cpu_rendezvous(volatile uint32 *var, int current_cpu) { - atomic_or(var, 1< Message-ID: <1445509308-BeMail@laptop> > "Fran?ois Revol" wrote: > > > Ignore disabled local APICs. > > Talking about APIC, I'll add a boot setting to disable APICs (at > > least > > apic timer), to see if I can get my asus laptop cold boot with the > > regular timer and the same hack that was required in zeta. > > Haiku used to warm boot until apic timers got used... > > The hack requires forcing the trigger type (to level IIRC) to get > > clock > > IRQs from the buggy ATI IXP chipset. It works if I disable the APIC > > You mean the BIOS incorrectly sets the IRQ mode of a legacy interrupt > to edge when it would need to be level? > If that's the case, we could just always manually reconfigure all > legacy interrupts to level, and we're done, right? > I never dug into that, so I'm not sure. I just happened to worked this way. I always thought it was a bug in the chipset, maybe the BIOS incorrectly sets this reg, but it works with other OSes (except they don't use the PIT in the same mode, an ATI guy once asked WTH zeta was using the PIT in mode 0... guess they probably never tried it because all other OS just use it in the fixed interval mode). Fran?ois. From marcusoverhagen at mail.berlios.de Wed Dec 19 22:33:31 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 19 Dec 2007 22:33:31 +0100 Subject: [Haiku-commits] r23142 - in haiku/trunk/src/add-ons/kernel: busses/ide/ide_isa generic/ide_adapter Message-ID: <200712192133.lBJLXV2N023560@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-19 22:33:30 +0100 (Wed, 19 Dec 2007) New Revision: 23142 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23142&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c Log: Moved masking of PCI ressource bits into a single place. Improved debug output and error reporting for I/O and interrupts resources. Init of ISA IDE or PCI IDE driver can now be seen in debug output, too. Verified that both still work with Vmware 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-12-18 19:46:26 UTC (rev 23141) +++ haiku/trunk/src/add-ons/kernel/busses/ide/ide_isa/ide_isa.c 2007-12-19 21:33:30 UTC (rev 23142) @@ -27,6 +27,7 @@ #define debug_level_info 2 #define DEBUG_MSG_PREFIX "IDE ISA -- " +#define TRACE dprintf #include "wrapper.h" @@ -262,6 +263,8 @@ uint8 irq; status_t res; + TRACE("ISA-IDE: channel init\n"); + // get device data if (pnp->get_attr_uint16(node, IDE_ISA_COMMAND_BLOCK_BASE, &command_block_base, false) != B_OK || pnp->get_attr_uint16(node, IDE_ISA_CONTROL_BLOCK_BASE, &control_block_base, false) != B_OK @@ -277,6 +280,9 @@ goto err0; } + TRACE("ISA-IDE: channel init, resources %#x %#x %d\n", + command_block_base, control_block_base, irq); + channel->isa = isa; channel->node = node; channel->lost = false; @@ -289,7 +295,7 @@ inthand, channel, 0); if (res < 0) { - SHOW_ERROR( 0, "couldn't install irq handler @%d", irq); + TRACE("ISA-IDE: couldn't install irq handler for int %d\n", irq); goto err; } @@ -313,6 +319,9 @@ uninit_channel(void *channel_cookie) { channel_info *channel = channel_cookie; + + TRACE("ISA-IDE: channel uninit\n"); + // disable IRQs write_device_control(channel, ide_devctrl_bit3 | ide_devctrl_nien); @@ -365,6 +374,9 @@ SHOW_FLOW0(2, ""); + TRACE("ISA-IDE: publishing %s, resources %#x %#x %d\n", + name, command_block_base, control_block_base, intnum); + return pnp->register_device(parent, attrs, resources, &node); } @@ -386,8 +398,11 @@ // we aren't upset if io-ports are in use already - only // the PCI IDE driver can own them, and if it does, we exit silently - if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) + if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) { + TRACE("ISA-IDE: can't acquire resources %#x and %#x\n", + command_block_base, control_block_base); return B_OK; + } // we assume that every modern PC has an IDE controller, so no // further testing is done (well - I don't really know how to detect the 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-12-18 19:46:26 UTC (rev 23141) +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-12-19 21:33:30 UTC (rev 23142) @@ -30,7 +30,9 @@ #include "wrapper.h" +#define TRACE dprintf + static ide_for_controller_interface *ide; static device_manager_info *pnp; @@ -330,6 +332,8 @@ uint8 is_primary; status_t res; + TRACE("PCI-IDE: init channel...\n"); + // get device data if (pnp->get_attr_uint16(node, IDE_ADAPTER_COMMAND_BLOCK_BASE, &command_block_base, false) != B_OK || pnp->get_attr_uint16(node, IDE_ADAPTER_CONTROL_BLOCK_BASE, &control_block_base, false) != B_OK @@ -380,6 +384,7 @@ goto err3; } + TRACE("PCI-IDE: init channel done\n"); // enable interrupts so the channel is ready to run ide_adapter_write_device_control(channel, ide_devctrl_bit3); @@ -484,25 +489,31 @@ command_block_base = 0x1f0; control_block_base = 0x3f6; intnum = 14; + TRACE("PCI-IDE: Controller in legacy mode: cmd %#x, ctrl %#x, irq %d\n", + command_block_base, control_block_base, intnum); } else if (supports_compatibility_mode && !is_primary && (api & IDE_API_PRIMARY_NATIVE) == 0) { command_block_base = 0x170; control_block_base = 0x376; intnum = 15; + TRACE("PCI-IDE: Controller in legacy mode: cmd %#x, ctrl %#x, irq %d\n", + command_block_base, control_block_base, intnum); } else { - if ((command_block_base & PCI_address_space) != PCI_address_space - || (control_block_base & PCI_address_space) != PCI_address_space) { - SHOW_ERROR0( 2, "Command/Control Block base is not configured" ); + if (command_block_base == 0 || control_block_base == 0) { + TRACE("PCI-IDE: Command/Control Block base is not configured\n"); return B_ERROR; } + if (intnum == 0 || intnum == 0xff) { + TRACE("PCI-IDE: Interrupt is not configured\n"); + return B_ERROR; + } - command_block_base &= ~PCI_address_space; - control_block_base &= ~PCI_address_space; - // historically, they start at 3f6h/376h, but PCI spec requires registers // to be aligned at 4 bytes, so only 3f4h/374h can be specified; thus // PCI IDE defines that control block starts at offset 2 control_block_base += 2; + TRACE("PCI-IDE: Controller in native mode: cmd %#x, ctrl %#x, irq %d\n", + command_block_base, control_block_base, intnum); } if (supports_compatibility_mode) { @@ -516,13 +527,15 @@ // better were to use a controller lock, but this had to be done in the IDE // bus manager, and I don't see any reason to add extra code for old // simplex controllers - SHOW_INFO0( 2, "Simplex controller - disabling DMA of secondary channel" ); + TRACE("PCI-IDE: Simplex controller - disabling DMA of secondary channel\n"); controller_can_dma = false; } } bus_master_base += is_primary ? 0 : 8; + TRACE("PCI-IDE: bus master base %#x\n", bus_master_base); + { // allocate channel's I/O resources io_resource resources[3] = { @@ -532,7 +545,8 @@ }; if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) { - SHOW_ERROR( 2, "Couldn't acquire channel resources %d and %d\n", command_block_base, control_block_base); + TRACE("PCI-IDE: Couldn't acquire channel resources %#x and %#x\n", + command_block_base, control_block_base); return B_ERROR; } } @@ -658,10 +672,10 @@ SHOW_FLOW0( 3, "" ); - if ((bus_master_base & PCI_address_space) != 1) - return B_OK; - - bus_master_base &= ~PCI_address_space; + if (bus_master_base == 0) { + TRACE("PCI-IDE: Controller detection failed! bus master base not configured\n"); + return B_ERROR; + } { io_resource resources[2] = { @@ -670,7 +684,7 @@ }; if (pnp->acquire_io_resources(resources, resource_handles) != B_OK) { - SHOW_ERROR( 2, "Couldn't acquire controller resource %d\n", bus_master_base); + TRACE("PCI-IDE: Couldn't acquire controller resource %#x\n", bus_master_base); return B_ERROR; } } @@ -708,6 +722,12 @@ bus_master_base = pci->read_pci_config(device, PCI_base_registers + 16, 4); intnum = pci->read_pci_config(device, PCI_interrupt_line, 1); + command_block_base[0] &= ~PCI_address_space; + control_block_base[0] &= ~PCI_address_space; + command_block_base[1] &= ~PCI_address_space; + control_block_base[1] &= ~PCI_address_space; + bus_master_base &= ~PCI_address_space; + res = ide_adapter_detect_controller(pci, device, parent, bus_master_base, controller_driver, controller_driver_type, controller_name, can_dma, can_cq, dma_alignment, dma_boundary, max_sg_block_size, &controller_node); @@ -716,8 +736,6 @@ if (res != B_OK || controller_node == NULL) goto err; - bus_master_base &= ~PCI_address_space; - // ignore errors during registration of channels - could be a simple rescan collision ide_adapter_detect_channel(pci, device, controller_node, channel_module_name, can_dma, command_block_base[0], control_block_base[0], bus_master_base, From marcusoverhagen at mail.berlios.de Wed Dec 19 23:22:23 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 19 Dec 2007 23:22:23 +0100 Subject: [Haiku-commits] r23143 - haiku/trunk/src/add-ons/kernel/generic/ide_adapter Message-ID: <200712192222.lBJMMN9H027031@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-19 23:22:23 +0100 (Wed, 19 Dec 2007) New Revision: 23143 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23143&view=rev Modified: haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c Log: Although this should simply enable IO decoding and bus master functionality when not set by bios, it currently crashes. 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-12-19 21:33:30 UTC (rev 23142) +++ haiku/trunk/src/add-ons/kernel/generic/ide_adapter/ide_adapter.c 2007-12-19 22:22:23 UTC (rev 23143) @@ -565,6 +565,7 @@ pci_device device; ide_adapter_controller_info *controller; uint16 bus_master_base; + uint16 pcicmd; // get device data if (pnp->get_attr_uint16(node, IDE_ADAPTER_BUS_MASTER_BASE, &bus_master_base, false) != B_OK) @@ -577,6 +578,21 @@ if (controller == NULL) return B_NO_MEMORY; +#if 0 + pcicmd = pci->read_pci_config(node, PCI_command, 2); + TRACE("PCI-IDE: adapter init: pcicmd old setting 0x%04x\n", pcicmd); + if ((pcicmd & PCI_command_io) == 0) { + TRACE("PCI-IDE: adapter init: enabling io decoder\n"); + pcicmd |= PCI_command_io; + } + if ((pcicmd & PCI_command_master) == 0) { + TRACE("PCI-IDE: adapter init: enabling bus mastering\n"); + pcicmd |= PCI_command_master; + } + pci->write_pci_config(node, PCI_command, 2, pcicmd); + TRACE("PCI-IDE: adapter init: pcicmd new setting 0x%04x\n", pci->read_pci_config(node, PCI_command, 2)); +#endif + controller->node = node; controller->pci = pci; controller->device = device; From mmu_man at mail.berlios.de Fri Dec 21 00:29:09 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 21 Dec 2007 00:29:09 +0100 Subject: [Haiku-commits] r23144 - in haiku/trunk/src/apps: . bsnow Message-ID: <200712202329.lBKNT9UY015637@sheep.berlios.de> Author: mmu_man Date: 2007-12-21 00:29:09 +0100 (Fri, 21 Dec 2007) New Revision: 23144 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23144&view=rev Added: haiku/trunk/src/apps/bsnow/ haiku/trunk/src/apps/bsnow/BSnow.rdef haiku/trunk/src/apps/bsnow/Flakes.cpp haiku/trunk/src/apps/bsnow/Flakes.h haiku/trunk/src/apps/bsnow/Jamfile haiku/trunk/src/apps/bsnow/README.html haiku/trunk/src/apps/bsnow/SnowApp.cpp haiku/trunk/src/apps/bsnow/SnowView.cpp haiku/trunk/src/apps/bsnow/SnowView.h haiku/trunk/src/apps/bsnow/makefile Log: A small demo app I wrote that is quite appropriate for the season :) Added: haiku/trunk/src/apps/bsnow/BSnow.rdef =================================================================== --- haiku/trunk/src/apps/bsnow/BSnow.rdef 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/BSnow.rdef 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,91 @@ +/* +** BSnow.rdef +** +** Automatically generated by BResourceParser on +** Friday, December 21, 2007 at 00:15:36. +** +*/ + +resource(1, "BEOS:APP_FLAGS") (#'APPF') $"00000000"; + +resource(1, "BEOS:APP_VERSION") #'APPV' array { + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000000000000000000000000000000000000000000000000000" + $"0000000000000000" +}; + +resource(101, "BEOS:L:STD_ICON") #'ICON' array { + $"FFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFF3FFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFF" + $"FFFFFF3F3F3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFFFFFF" + $"FFFF3FFF3FFF3FFFFFFFFFFFFFFFFF3FFF3FFFFFFFFFFFFFFFFFFF3FFF3FFFFF" + $"FFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3F3F3FFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFF3FFFFFFFFFFFFFFF3FFF3FFFFF" + $"FFFFFFFFFFFFFF3FFFFFFFFFFFFFFFFFFF3FFFFFFFFFFFFFFFFFFFFF3FFFFFFF" + $"FFFFFFFFFF3FFF3FFF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFF" + $"FFFFFFFFFFFF3F3F3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFF3FFF3FFF3FFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFF3FFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF0000FFFF0000FFFFFF00FFFF00FFFFFF00FFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFF00FF00FF00FF00FF00FF00FF00FF00FFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF0000FFFF00FF00FFFF00FFFFFF00FF00FFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFFFFFFFFFFFF3FFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFF3FFFFFFFFFFFFF3FFF3FFF3FFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFFFFFFFFFF3F3F3FFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3FFF3FFF3FFFFFFFFFFFFF3F" + $"FFFFFFFF3F3F3F3F3F3F3F3F3F3F3FFFFFFFFFFFFFFF3FFFFFFFFFFFFF3F3F3F" + $"FFFF3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3FFFFFFFFFFFFFFF3F3F3F3F3F" + $"FF3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" + $"3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" +}; + +resource(101, "BEOS:M:STD_ICON") #'MICN' array { + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFFFFFF3FFF3FFFFF" + $"FFFFFFFF3FFFFFFFFFFFFFFF3FFFFFFF" + $"FFFF3FFF3FFF3FFFFFFFFF3FFF3FFFFF" + $"FFFFFF3F3F3FFFFFFFFFFFFFFFFFFFFF" + $"FFFF3FFF3FFF3FFFFF3FFF3FFFFFFFFF" + $"FFFFFFFF3FFFFFFFFFFF3FFFFFFFFFFF" + $"FFFFFFFFFFFFFFFFFF3FFF3FFFFFFFFF" + $"FFFF0000FFFFFFFFFFFFFFFFFFFFFFFF" + $"FF0000FFFFFFFFFFFFFFFFFFFFFFFFFF" + $"FFFF0000FF0013FF0000FF001313FFFF" + $"FF0000FFFF0000FF0000FFFF0000FFFF" + $"FFFFFFFFFFFFFFFFFFFFFFFFFFFF3F3F" + $"FFFF3F3F3F3F3F3F3F3F3FFFFF3F3F3F" + $"FF3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" + $"3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F" +}; + +resource(1, "BEOS:APP_SIG") (#'MIMS') "application/x-vnd.mmu_man.BSnow"; + Added: haiku/trunk/src/apps/bsnow/Flakes.cpp =================================================================== --- haiku/trunk/src/apps/bsnow/Flakes.cpp 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/Flakes.cpp 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,40 @@ +#include "Flakes.h" + +#define TRAN 0xFF +#define WHIT 0x3F + +const char gFlakeBits[NUM_PATTERNS][64] = { +{ +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN +}, +{ +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, +TRAN, WHIT, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, +TRAN, TRAN, WHIT, WHIT, WHIT, TRAN, TRAN, TRAN, +TRAN, WHIT, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, +TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN +} +/* +{ +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, WHIT, TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, +TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, +TRAN, WHIT, WHIT, WHIT, WHIT, WHIT, TRAN, TRAN, +TRAN, TRAN, WHIT, TRAN, WHIT, TRAN, TRAN, TRAN, +TRAN, WHIT, TRAN, TRAN, TRAN, WHIT, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, +TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN, TRAN +} +*/ +}; + Added: haiku/trunk/src/apps/bsnow/Flakes.h =================================================================== --- haiku/trunk/src/apps/bsnow/Flakes.h 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/Flakes.h 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,12 @@ +#ifndef _FLAKES_H +#define _FLAKES_H +#include + +#define NUM_PATTERNS 2 + +#define PAT_HOTSPOT 3,3 + +extern const char gFlakeBits[NUM_PATTERNS][64]; + + +#endif Added: haiku/trunk/src/apps/bsnow/Jamfile =================================================================== --- haiku/trunk/src/apps/bsnow/Jamfile 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/Jamfile 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,11 @@ +SubDir HAIKU_TOP src apps bsnow ; + +SetSubDirSupportedPlatformsBeOSCompatible ; + +Application BSnow : + Flakes.cpp + SnowView.cpp + SnowApp.cpp + : be + : BSnow.rdef + ; Added: haiku/trunk/src/apps/bsnow/README.html =================================================================== --- haiku/trunk/src/apps/bsnow/README.html 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/README.html 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,38 @@ + + + +BSnow - winter weather for BeOS + + + +              *        .                .            .
+  .                         *                             .        *                 +BSnow - winter weather for BeOS,                         *                 .
+              *     .              *               .
+ +
+
+
+
+
+ +© 2003 François Revol. +
+
+Features: +
    +
  • adapts the number of snow flakes to the CPU frequency to avoid hogging it, +
  • random wind change, +
  • the fallen snow accumulates on the windows and bottom of the screen, +
+
+
+Limitations: +
    +
  • lot of flicker, +
  • it needs to set the desktop view flags to B_DRAW_ON_CHILDREN, which might gives weird drawing with some replicants afterwards, +
+
+Sources released under the MIT licence. + + Added: haiku/trunk/src/apps/bsnow/SnowApp.cpp =================================================================== --- haiku/trunk/src/apps/bsnow/SnowApp.cpp 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/SnowApp.cpp 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,23 @@ +#include +#include +#include +#include "SnowView.h" + +int main(int argc, char **argv) +{ + BApplication app(APP_SIG); + BWindow *win; + bool draggersShown = BDragger::AreDraggersDrawn(); + win = new BWindow(BRect(SNOW_VIEW_RECT), "BSnow", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE|B_NOT_RESIZABLE); + SnowView *view = new SnowView(); + win->AddChild(view); + win->MoveTo(50, 50); + win->Show(); + win->SetPulseRate(500000); + BDragger::ShowAllDraggers(); + app.Run(); + if (!draggersShown) + BDragger::HideAllDraggers(); + return 0; +} + Added: haiku/trunk/src/apps/bsnow/SnowView.cpp =================================================================== --- haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,618 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SnowView.h" +#include "Flakes.h" +#include + +#include + +#define FORWARD_TO_PARENT + +SnowView::SnowView() + : BView(BRect(SNOW_VIEW_RECT), "BSnow", B_FOLLOW_NONE, B_WILL_DRAW|B_PULSE_NEEDED) +{ + fAttached = false; + fMsgRunner = NULL; + fCachedParent = NULL; + fFallenBmp = NULL; + fFallenView = NULL; + fFallenReg = NULL; + fInvalidator = -1; + fShowClickMe = false; + for (int i = 0; i < WORKSPACES_COUNT; i++) + fFlakes[i] = NULL; + for (int i = 0; i < NUM_PATTERNS; i++) + fFlakeBitmaps[i] = NULL; + BRect r(Frame()); + r.left = r.right - 7; + r.top = r.bottom - 7; + fDragger = new BDragger(r, this); + AddChild(fDragger); + SetHighColor(255,255,255); +} +/* +filter_result msgfilter(BMessage *message, BHandler **target, BMessageFilter *filter) +{ + switch (message->what) { + case B_MOUSE_DOWN: + case B_MOUSE_UP: + case B_MOUSE_MOVED: + case '_EVP': + case '_UPD': + case '_PUL': + case 'NTCH': + case 'NMDN': + break; + default: + printf("For: 0x%08lx: %s\n", *target, (*target)->Name()); + message->PrintToStream(); + } + return B_DISPATCH_MESSAGE; +} +*/ + +SnowView::SnowView(BMessage *archive) + : BView(archive) +{ + system_info si; + //printf("SnowView()\n"); + //archive->PrintToStream(); + fDragger = NULL; + fAttached = false; + fMsgRunner = NULL; + fFallenBmp = NULL; + fFallenView = NULL; + fFallenReg = NULL; + fCachedParent = NULL; + fShowClickMe = false; + SetFlags(Flags() & ~B_PULSE_NEEDED); /* it's only used when in the app */ + get_system_info(&si); + fNumFlakes = ((int32)(si.cpu_clock_speed/1000000)) * si.cpu_count / 3; //; + printf("BSnow: using %d flakes\n", fNumFlakes); + for (int i = 0; i < WORKSPACES_COUNT; i++) { + fFlakes[i] = new flake[fNumFlakes]; + memset(fFlakes[i], 0, fNumFlakes * sizeof(flake)); + } + for (int i = 0; i < NUM_PATTERNS; i++) { + fFlakeBitmaps[i] = new BBitmap(BRect(0,0,7,7), B_CMAP8); + fFlakeBitmaps[i]->SetBits(gFlakeBits[i], 8*8, 0, B_CMAP8); + } + fCurrentWorkspace = 0; + SetHighColor(255,255,255); + SetDrawingMode(B_OP_OVER); +} + +SnowView::~SnowView() +{ + for (int i = 0; i < WORKSPACES_COUNT; i++) + if (fFlakes[i]) + delete [] fFlakes[i]; + if (fFallenBmp) + delete fFallenBmp; /* the view goes away with it */ +} + +BArchivable *SnowView::Instantiate(BMessage *data) +{ + return new SnowView(data); +} + +status_t SnowView::Archive(BMessage *data, bool deep) const +{ + status_t err; + err = BView::Archive(data, deep); + if (err < B_OK) + return err; + data->AddString("add_on", APP_SIG); + return B_OK; +} + +void SnowView::AttachedToWindow() +{ + BView *p; + rgb_color col; + fAttached = true; +/* if (!fMsgRunner) + fMsgRunner = new BMessageRunner(BMessenger(this), + new BMessage(MSG_PULSE_ME), + INTERVAL); +*/ + p = Parent(); + if (p) + col = B_TRANSPARENT_32_BIT;//Parent()->ViewColor(); + else + col = ui_color(B_PANEL_BACKGROUND_COLOR); + SetViewColor(col); +// BScreen bs; +// fCachedWsWidth = bs.Frame().IntegerWidth(); +// fCachedWsHeight = bs.Frame().IntegerHeight(); + fDragger = dynamic_cast(FindView("_dragger_")); + if (fDragger && p) { + fCachedParent = p; + fCachedWsWidth = p->Frame().IntegerWidth(); + fCachedWsHeight = p->Frame().IntegerHeight(); + fDragger->SetViewColor(col); + if (fDragger->InShelf()) { + p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); + ResizeTo(p->Bounds().Width(), p->Bounds().Height()); + MoveTo(0,0); + fDragger->MoveTo(p->Bounds().Width()-7, p->Bounds().Height()-7); + } + BRect fallenRect(p->Bounds()); + fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT; + fFallenBmp = new BBitmap(fallenRect, B_BITMAP_ACCEPTS_VIEWS, B_CMAP8); + memset(fFallenBmp->Bits(), B_TRANSPARENT_MAGIC_CMAP8, (size_t)(fallenRect.Height()*fFallenBmp->BytesPerRow())); + fFallenView = new BView(fallenRect, "offscreen fallen snow", B_FOLLOW_NONE, 0); + fFallenBmp->AddChild(fFallenView); + fFallenReg = new BRegion; + fInvalidator = spawn_thread(SnowMakerThread, INVALIDATOR_THREAD_NAME, B_LOW_PRIORITY, (void *)this); + resume_thread(fInvalidator); + printf("BSnow: OK: ws = %ld x %ld\n", fCachedWsWidth, fCachedWsHeight); + //Window()->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, msgfilter)); + } +} + +void SnowView::DetachedFromWindow() +{ + fAttached = false; +/* + if (Parent()) { + Parent()->Invalidate(Parent()->Bounds()); + } +*/ + if (fMsgRunner) + delete fMsgRunner; + fMsgRunner = NULL; + status_t err; + fCachedParent = NULL; + if (fInvalidator > B_OK) + wait_for_thread(fInvalidator, &err); + fInvalidator = -1; + if (fFallenReg) + delete fFallenReg; +} + +void SnowView::MessageReceived(BMessage *msg) +{ + BAlert *info; + //msg->PrintToStream(); + switch (msg->what) { + case MSG_PULSE_ME: + if (Parent()) { + Calc(); + InvalFlakes(); + } + break; + case B_ABOUT_REQUESTED: + info = new BAlert("BSnow info", + "BSnow, just in case you don't have real one...\n" + "" B_UTF8_COPYRIGHT " 2003, Fran?ois Revol.", + "Where is Santa ??"); + info->SetFeel(B_NORMAL_WINDOW_FEEL); + info->SetLook(B_FLOATING_WINDOW_LOOK); + info->SetFlags(info->Flags()|B_NOT_ZOOMABLE); + info->Go(NULL); + break; + default: +//#ifdef FORWARD_TO_PARENT +/* + if (fAttached && Parent()) + Parent()->MessageReceived(msg); + else +*/ +//#endif + BView::MessageReceived(msg); + } +} + +void SnowView::Draw(BRect ur) +{ + int i; + if (!fCachedParent) { + if (!fShowClickMe) { /* show "drag me" */ + SetLowColor(ViewColor()); + SetHighColor(0,0,0); + SetFontSize(12); + DrawString(MSG_DRAG_ME, BPoint(15,25)); + BPoint arrowHead(Bounds().RightBottom()+BPoint(-10,-10)); + StrokeLine(arrowHead, arrowHead - BPoint(7,0)); + StrokeLine(arrowHead, arrowHead - BPoint(0,7)); + StrokeLine(arrowHead, arrowHead - BPoint(12,12)); + return; + } else { + SetLowColor(ViewColor()); + SetHighColor(0,0,0); + SetFontSize(12); + DrawString(MSG_CLICK_ME, BPoint(15,25)); + return; + } + } + //printf("Draw()\n"); + uint32 cw = fCurrentWorkspace; + if (fFlakes[cw] == NULL) + return; + /* draw the snow already fallen */ +// BRect fallenRect(Bounds()); +// fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT; +// if (ur.Intersects(fallenRect)) { + //if (fFallenBmp->Lock()) { + // DrawBitmap(fFallenBmp, fallenRect); + // fFallenBmp->Unlock(); + //} + int32 cnt = fFallenReg->CountRects(); +// drawing_mode oldmode = DrawingMode(); +// SetDrawingMode(B_OP_ADD); + + for (i=0; iRectAt(i); +// SetHighColor(245, 245, 245, 200); +// FillRect(r); +// SetHighColor(255, 255, 255, 255); +// r.InsetBy(1,1); + FillRect(r); + } +// SetDrawingMode(oldmode); +// } + /* draw our flakes */ + for (i=0; i3)?1:0; + //FillRect(BRect(fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT),fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)+BPoint(7,7)), gFlakePatterns[pat]); +/* + StrokeLine(fFlakes[cw][i].pos+BPoint(-1,-1), + fFlakes[cw][i].pos+BPoint(1,1)); + StrokeLine(fFlakes[cw][i].pos+BPoint(-1,1), + fFlakes[cw][i].pos+BPoint(1,-1)); +*/ + DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)); + } +} + +void SnowView::Pulse() +{ + if (fShowClickMe) + return; /* done */ + if (fCachedParent) + return; /* we are in Tracker! */ + BMessenger msgr("application/x-vnd.Be-TRAK"); + BMessage msg(B_GET_PROPERTY), reply; + msg.AddSpecifier("Frame"); + msg.AddSpecifier("View", "BSnow"); + msg.AddSpecifier("Window", 1); /* 0 is Twitcher */ + if (msgr.SendMessage(&msg, &reply) == B_OK && reply.what == B_REPLY) { + //reply.PrintToStream(); + Invalidate(Bounds()); + fShowClickMe = true; + } +} + +void SnowView::Calc() +{ + int i; + uint32 cw = fCurrentWorkspace; + + /* check if the parent changed size */ + BRect pFrame = fCachedParent->Frame(); + if (fCachedWsWidth != pFrame.Width() || fCachedWsHeight != pFrame.Height()) { + fCachedWsWidth = pFrame.IntegerWidth(); + fCachedWsHeight = pFrame.IntegerHeight(); + printf("BSnow: Parent resized to %ld %ld\n", fCachedWsWidth, fCachedWsHeight); + fFallenReg->MakeEmpty(); /* remove all the fallen snow */ + ResizeTo(pFrame.IntegerWidth(), pFrame.IntegerHeight()); + fDragger->MoveTo(pFrame.IntegerWidth()-7, pFrame.IntegerHeight()-7); + } + + /* make new flakes */ + for (i=0; i 0) + fFlakes[cw][i].pos.x = 0; + else + fFlakes[cw][i].pos.x = fCachedWsWidth; + } + if (fFlakes[cw][i].pos.x > fCachedWsWidth+10) { + fFlakes[cw][i].pos.y = fFlakes[cw][i].pos.x - fCachedWsWidth; + if (fWind > 0) + fFlakes[cw][i].pos.x = 0; + else + fFlakes[cw][i].pos.x = fCachedWsWidth; + } + } + } + + /* like a candle in the wind... */ + if (fWindDuration < system_time()) { + fWindDuration = system_time() + ((((bigtime_t)rand())*1000) % WIND_MAX_DURATION); + fWind = (rand() % WIND_SPAN) - WIND_SPAN/2; + printf("BSnow: wind change: %f\n", fWind); + } + + +// if (fFallenView->LockLooperWithTimeout(5000)) { +// if (fFallenBmp) { +// uint8 *fallenBits = (uint8 *)fFallenBmp->Bits(); + + BRegion desktopReg; + GetClippingRegion(&desktopReg); + + /* let's add some gravity and wind */ + for (i=0; i (fCachedWsHeight-FALLEN_HEIGHT)) { + + bool fallen = false; + bool keepfalling = false; + + /* fallen on the flour */ + if (fFlakes[cw][i].pos.y > fCachedWsHeight-2) + fallen = true; + /* fallon on another fallen flake */ + else if (fFallenReg->Intersects(BRect(fFlakes[cw][i].pos - BPoint(0,1), + fFlakes[cw][i].pos + BPoint(0,1)))) { + /* don't accumulate too much */ + if ((fFlakes[cw][i].pos.y > fCachedWsHeight-30) || + !desktopReg.Intersects( + BRect(fFlakes[cw][i].pos + BPoint(0,6), + fFlakes[cw][i].pos + BPoint(0,10)))) + fallen = true; + /* fallen on a window */ + } else if (!desktopReg.Intersects( + BRect(fFlakes[cw][i].pos + BPoint(-1,-1-2), + fFlakes[cw][i].pos + BPoint(1,1-1))) && + desktopReg.Intersects( + BRect(fFlakes[cw][i].pos + BPoint(-1,-1-3), + fFlakes[cw][i].pos + BPoint(1,1-3)))) { + //printf("fallen3 @ %f %f\n", fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y); + fFlakes[cw][i].pos = fFlakes[cw][i].opos; + fallen = true; + keepfalling = true; /* but keep one falling */ + } + +/* else if (fallenBits[ (long)(fFlakes[cw][i].pos.y + * fFallenBmp->BytesPerRow() + + fFlakes[cw][i].pos.y + - (fCachedWsHeight-FALLEN_HEIGHT)) ] != B_TRANSPARENT_MAGIC_CMAP8) { + fallen = true; + }*/ + +// if (fallen) { +// int pat = (fFlakes[cw][i].weight>3)?1:0; +// if (fFlakes[cw][i].pos.y > fCachedWsHeight-1) +// fFlakes[cw][i].pos.y = fCachedWsHeight-(rand()%4); + //fFallenView->DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)); +// fallenBits[ (long)(fFlakes[cw][i].pos.y * fFallenBmp->BytesPerRow() +// + fFlakes[cw][i].pos.y-(fCachedWsHeight-FALLEN_HEIGHT)) ] = 0x56; +// printf("fallen @ %f, %f\n", fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y); +// } + if (fallen) { + if (!keepfalling) + fFlakes[cw][i].weight = 0; + fFallenReg->Include(BRect(fFlakes[cw][i].pos - BPoint(2,0), + fFlakes[cw][i].pos + BPoint(2,2))); + if (keepfalling) { + fFlakes[cw][i].pos += BPoint(0,10); + /* except if under the desktop */ + if (fFlakes[cw][i].pos.y > fCachedWsHeight-1) + fFlakes[cw][i].weight = 0; + } + } + + /* cleanup, when a window hides the snow */ + fFallenReg->IntersectWith(&desktopReg); + + /* cleanup, when a window is moved */ + /* seems to lockup Tracker */ +/* + int32 cnt = fFallenReg->CountRects(); + for (i=0; iRectAt(i); + if (desktopReg.Intersects(r.OffsetByCopy(0,15))) { + fFallenReg->Exclude(r); + cnt--; + } + } +*/ + /* add the effect of the wind */ + fFlakes[cw][i].pos.x += fWind + (rand() % 6 - 3); + if ((fFlakes[cw][i].pos.x > fCachedWsWidth+50)||(fFlakes[cw][i].pos.x < -50)) + fFlakes[cw][i].weight = 0; + } +// fFallenView->UnlockLooper(); +// } +#if 0 + for (i=0; i<10; i++) + printf("f[%d] = {%f, %f}, {%f, %f}, %d\n", i, + fFlakes[cw][i].opos.x, fFlakes[cw][i].opos.y, + fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y, + fFlakes[cw][i].weight); +#endif +} + +void SnowView::InvalFlakes() +{ + int i; + BView *p = Parent(); + if (!p) + return; + //printf("InvalFlakes()\n"); + uint32 cw = fCurrentWorkspace; + + for (i=0; iMouseDown(where); +#endif +} + +void SnowView::MouseUp(BPoint where) +{ +#ifdef FORWARD_TO_PARENT + if (fAttached && Parent()) + Parent()->MouseUp(where); +#endif + if (fCachedParent) + return; /* we are *inside* the Tracker, + * don't even try talking to ourselve + * with the window locked + */ + BMessenger msgr("application/x-vnd.Be-TRAK"); + BMessage msg(B_DELETE_PROPERTY), reply; + msg.AddSpecifier("Replicant", "BSnow"); + msg.AddSpecifier("Shelf"); + msg.AddSpecifier("View", "PoseView"); + msg.AddSpecifier("Window", 1); /* 0 is Twitcher */ + if ((msgr.SendMessage(&msg, &reply) == B_OK) && + (reply.what == B_NO_REPLY || reply.what == B_REPLY)) { + //reply.PrintToStream(); + fShowClickMe = false; + Invalidate(Bounds()); + } + /* + BMessage: what = JAHA (0x4a414841, or 1245792321) + entry index, type='LONG', c=1, size= 4, data[0]: 0x2 (2, '') + entry when, type='LLNG', c=1, size= 8, data[0]: 0xf6a1b09ac (66204666284, '') + entry source, type='PNTR', c=1, size= 4, + entry be:sender, type='MSNG', c=1, size=24, + */ +} + +void SnowView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message) +{ +#ifdef FORWARD_TO_PARENT + if (fAttached && Parent()) + Parent()->MouseMoved(where, code, a_message); +#endif +} + +void SnowView::KeyDown(const char *bytes, int32 numBytes) +{ +#ifdef FORWARD_TO_PARENT + if (fAttached && Parent()) + Parent()->KeyDown(bytes, numBytes); +#endif +} + +void SnowView::KeyUp(const char *bytes, int32 numBytes) +{ +#ifdef FORWARD_TO_PARENT + if (fAttached && Parent()) + Parent()->KeyUp(bytes, numBytes); +#endif +} + +#define PORTION_GRAN 20 + +int32 SnowView::SnowMakerThread(void *p_this) +{ + SnowView *_this = (SnowView *)p_this; + bigtime_t nextDraw = 0LL; + int current=0; + BView *p = _this->Parent(); + BRect portion(0,0,(_this->fCachedWsWidth/PORTION_GRAN)-1, (_this->fCachedWsHeight/PORTION_GRAN)-1); + int nf = _this->fNumFlakes; + BRegion reg(BRect(-1,-1,-1,-1)); + while (p && _this->fAttached) { + snooze(INTERVAL/(10*(nf?nf:1))); + int32 cw = _this->fCurrentWorkspace; + bool drawThisOne = false; +//printf("processing flake %d...\n", current); + //for (; (current%(fNumFlakes/4); current++) + if (reg.Intersects(portion)) { + for (int i = 0; !drawThisOne && i < nf; i++) { + /* if we find at least one flake in this rect, draw it */ + if ((_this->fFlakes[cw][i].weight) && ( + portion.Intersects(BRect(_this->fFlakes[cw][i].opos - BPoint(4,4), _this->fFlakes[cw][i].opos + BPoint(4,4))) || + portion.Intersects(BRect(_this->fFlakes[cw][i].pos - BPoint(4,4), _this->fFlakes[cw][i].pos + BPoint(4,4))))) { + drawThisOne = true; + } + } + } + //if (!drawThisOne) + //printf("!Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom); + /* avoid deadlock on exit */ + if (drawThisOne && (_this->LockLooperWithTimeout(2000) == B_OK)) { +// printf("Invalidate(%f, %f, %f, %f)\n", portion.left, portion.top, portion.right, portion.bottom); + p->Invalidate(portion); + _this->UnlockLooper(); + } + portion.OffsetBy(_this->fCachedWsWidth/PORTION_GRAN, 0); + if (portion.left >= _this->fCachedWsWidth) { /* right wrap */ + //printf("rigth wrap to %ld\n", _this->fCachedWsWidth); + portion.OffsetTo(0, portion.top+(_this->fCachedWsHeight/PORTION_GRAN)); + } + if (portion.top >= _this->fCachedWsHeight) { + portion.OffsetTo(0,0); + /* avoid deadlock on exit */ + if (_this->LockLooperWithTimeout(5000) == B_OK) { +//printf("calculating flakes...\n"); + _this->Calc(); +//printf("done calculating flakes.\n"); + _this->GetClippingRegion(®); + //printf("Region:\n"); + //reg.PrintToStream(); + _this->UnlockLooper(); + } + } + } +#if 0 + BView *p = _this->Parent(); + while (p && _this->fAttached) { + snooze(INTERVAL/_this->fNumFlakes); +//printf("processing flake %d...\n", current); + //for (; (current%(fNumFlakes/4); current++) + /* avoid deadlock on exit */ + if (_this->LockLooperWithTimeout(2000) == B_OK) { + if (_this->fFlakes[_this->fCurrentWorkspace][current].weight) { + p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].opos - BPoint(4,4), + _this->fFlakes[_this->fCurrentWorkspace][current].opos + BPoint(4,4))); + p->Invalidate(BRect(_this->fFlakes[_this->fCurrentWorkspace][current].pos - BPoint(4,4), + _this->fFlakes[_this->fCurrentWorkspace][current].pos + BPoint(4,4))); + } + _this->UnlockLooper(); + current++; + current %= _this->fNumFlakes; + if (!current) { + /* avoid deadlock on exit */ + if (_this->LockLooperWithTimeout(2000) == B_OK) { +printf("calculating flakes...\n"); + _this->Calc(); +printf("done calculating flakes.\n"); + _this->UnlockLooper(); + } + } + } + } +#endif + return B_OK; +} Added: haiku/trunk/src/apps/bsnow/SnowView.h =================================================================== --- haiku/trunk/src/apps/bsnow/SnowView.h 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/SnowView.h 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,79 @@ +#ifndef _SNOW_VIEW_H +#define _SNOW_VIEW_H +#include +#include +#include +#include +#include +#include +#include "Flakes.h" + +#define APP_SIG "application/x-vnd.mmu_man.BSnow" +#define SNOW_VIEW_RECT 0,0,200,40 +#define NUM_FLAKES 200 +#define INTERVAL 200000 +#define MSG_PULSE_ME 'PulS' +#define MSG_DRAW_ME 'DraW' +#define WORKSPACES_COUNT 32 +#define WEIGHT_SPAN 50 +#define WEIGHT_GRAN 10 +#define WIND_SPAN 25 +#define WIND_MAX_DURATION 10000000 +#define FALLEN_HEIGHT 30 +#define INVALIDATOR_THREAD_NAME "You're Neo? I'm the Snow Maker!" + + +#define MSG_DRAG_ME "Drag me on your desktop..." +#define MSG_CLICK_ME "Click me to remove BSnow..." + +typedef struct flake { + BPoint pos; + BPoint opos; + float weight; +} flake; + +class SnowView : public BView +{ +public: + SnowView(); + SnowView(BMessage *archive); + ~SnowView(); +static BArchivable *Instantiate(BMessage *data); +virtual status_t Archive(BMessage *data, bool deep = true) const; +void AttachedToWindow(); +void DetachedFromWindow(); +void MessageReceived(BMessage *msg); +void Draw(BRect ur); +void Pulse(); + +virtual void MouseDown(BPoint where); +virtual void MouseUp(BPoint where); +virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message); +virtual void KeyDown(const char *bytes, int32 numBytes); +virtual void KeyUp(const char *bytes, int32 numBytes); + +static int32 SnowMakerThread(void *p_this); +void Calc(); +void InvalFlakes(); +private: + BMessageRunner *fMsgRunner; + BDragger *fDragger; + long fNumFlakes; + flake *fFlakes[WORKSPACES_COUNT]; + BList *fFallenFlakes[WORKSPACES_COUNT]; + uint32 fCurrentWorkspace; + uint32 fCachedWsWidth; + uint32 fCachedWsHeight; + float fWind; + bigtime_t fWindDuration; + bool fAttached; + BBitmap *fFlakeBitmaps[NUM_PATTERNS]; + thread_id fInvalidator; + BView *fCachedParent; + BBitmap *fFallenBmp; + BView *fFallenView; + BRegion *fFallenReg; + bool fShowClickMe; +}; + +#endif Added: haiku/trunk/src/apps/bsnow/makefile =================================================================== --- haiku/trunk/src/apps/bsnow/makefile 2007-12-19 22:22:23 UTC (rev 23143) +++ haiku/trunk/src/apps/bsnow/makefile 2007-12-20 23:29:09 UTC (rev 23144) @@ -0,0 +1,120 @@ +## BeOS Generic Makefile v2.2 ## + +## Fill in this file to specify the project being created, and the referenced +## makefile-engine will do all of the hard work for you. This handles both +## Intel and PowerPC builds of the BeOS. + +## Application Specific Settings --------------------------------------------- + +# specify the name of the binary +NAME= BSnow + +# specify the type of binary +# APP: Application +# SHARED: Shared library or add-on +# STATIC: Static library archive +# DRIVER: Kernel Driver +TYPE= APP + +# add support for new Pe and Eddie features +# to fill in generic makefile + +#%{ +# @src->@ + +# specify the source files to use +# full paths or paths relative to the makefile can be included +# all files, regardless of directory, will have their object +# files created in the common object directory. +# Note that this means this makefile will not work correctly +# if two source files with the same name (source.c or source.cpp) +# are included from different directories. Also note that spaces +# in folder names do not work well with this makefile. +SRCS= SnowApp.cpp SnowView.cpp Flakes.cpp + +# specify the resource files to use [... truncated: 86 lines follow ...] From mmu_man at mail.berlios.de Fri Dec 21 00:29:55 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 21 Dec 2007 00:29:55 +0100 Subject: [Haiku-commits] r23145 - haiku/trunk/src/apps Message-ID: <200712202329.lBKNTtZJ015726@sheep.berlios.de> Author: mmu_man Date: 2007-12-21 00:29:55 +0100 (Fri, 21 Dec 2007) New Revision: 23145 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23145&view=rev Modified: haiku/trunk/src/apps/Jamfile Log: Add 2dmov and BSnow to the build. Modified: haiku/trunk/src/apps/Jamfile =================================================================== --- haiku/trunk/src/apps/Jamfile 2007-12-20 23:29:09 UTC (rev 23144) +++ haiku/trunk/src/apps/Jamfile 2007-12-20 23:29:55 UTC (rev 23145) @@ -1,6 +1,8 @@ SubDir HAIKU_TOP src apps ; +SubInclude HAIKU_TOP src apps 3dmov ; SubInclude HAIKU_TOP src apps aboutsystem ; +SubInclude HAIKU_TOP src apps bsnow ; SubInclude HAIKU_TOP src apps cdplayer ; SubInclude HAIKU_TOP src apps clock ; SubInclude HAIKU_TOP src apps codycam ; From mmu_man at mail.berlios.de Fri Dec 21 00:31:42 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 21 Dec 2007 00:31:42 +0100 Subject: [Haiku-commits] r23146 - haiku/trunk/build/jam Message-ID: <200712202331.lBKNVgRh019179@sheep.berlios.de> Author: mmu_man Date: 2007-12-21 00:31:41 +0100 (Fri, 21 Dec 2007) New Revision: 23146 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23146&view=rev Modified: haiku/trunk/build/jam/HaikuImage Log: Add BSnow to the image, as a demo app, it actually demonstrates an unusual application of replicants, as well as scripting. Modified: haiku/trunk/build/jam/HaikuImage =================================================================== --- haiku/trunk/build/jam/HaikuImage 2007-12-20 23:29:55 UTC (rev 23145) +++ haiku/trunk/build/jam/HaikuImage 2007-12-20 23:31:41 UTC (rev 23146) @@ -56,7 +56,7 @@ FileTypes Fonts Keyboard Keymap Media Menu Mouse Network Printers Screen ScreenSaver Sounds Time VirtualMemory ; -BEOS_DEMOS = BitmapDrawing Chart Clock $(X86_ONLY)Cortex FontDemo +BEOS_DEMOS = BitmapDrawing BSnow Chart Clock $(X86_ONLY)Cortex FontDemo $(X86_ONLY)GLDirectMode $(X86_ONLY)GLTeapot Mandelbrot PictureTest Playground Pulse Sudoku ; From marcusoverhagen at mail.berlios.de Sun Dec 23 23:21:25 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Sun, 23 Dec 2007 23:21:25 +0100 Subject: [Haiku-commits] r23147 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200712232221.lBNMLP5L002616@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-23 23:21:25 +0100 (Sun, 23 Dec 2007) New Revision: 23147 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23147&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp Log: disabled some debug output Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-12-20 23:31:41 UTC (rev 23146) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci.cpp 2007-12-23 22:21:25 UTC (rev 23147) @@ -1,5 +1,5 @@ /* - * Copyright 2006, Marcus Overhagen. All rights reserved. + * Copyright 2006-2007, Marcus Overhagen. All rights reserved. * Copyright 2005, Axel D?rfler, axeld at pinc-software.de. All rights reserved. * Copyright 2003, Marcus Overhagen. All rights reserved. * @@ -18,6 +18,8 @@ #include "pci.h" #define TRACE_CAP(x...) dprintf(x) +#define FLOW(x...) +//#define FLOW(x...) dprintf(x) static PCI *sPCI; @@ -568,7 +570,7 @@ void PCI::FixupDevices(int domain, uint8 bus) { - TRACE(("PCI: FixupDevices domain %u, bus %u\n", domain, bus)); + FLOW("PCI: FixupDevices domain %u, bus %u\n", domain, bus); int maxBusDevices = GetDomainData(domain)->max_bus_devices; @@ -604,7 +606,7 @@ void PCI::DiscoverBus(PCIBus *bus) { - TRACE(("PCI: DiscoverBus, domain %u, bus %u\n", bus->domain, bus->bus)); + FLOW("PCI: DiscoverBus, domain %u, bus %u\n", bus->domain, bus->bus); int max_bus_devices = GetDomainData(bus->domain)->max_bus_devices; @@ -627,7 +629,7 @@ void PCI::DiscoverDevice(PCIBus *bus, uint8 dev, uint8 func) { - TRACE(("PCI: DiscoverDevice, domain %u, bus %u, dev %u, func %u\n", bus->domain, bus->bus, dev, func)); + FLOW("PCI: DiscoverDevice, domain %u, bus %u, dev %u, func %u\n", bus->domain, bus->bus, dev, func); uint16 device_id = ReadPciConfig(bus->domain, bus->bus, dev, func, PCI_device_id, 2); if (device_id == 0xffff) @@ -665,7 +667,7 @@ PCIDev * PCI::CreateDevice(PCIBus *parent, uint8 dev, uint8 func) { - TRACE(("PCI: CreateDevice, domain %u, bus %u, dev %u, func %u:\n", parent->domain, parent->bus, dev, func)); + FLOW("PCI: CreateDevice, domain %u, bus %u, dev %u, func %u:\n", parent->domain, parent->bus, dev, func); PCIDev *newdev = new PCIDev; newdev->next = NULL; @@ -678,8 +680,8 @@ ReadPciBasicInfo(newdev); - TRACE(("PCI: vendor 0x%04x, device 0x%04x, class_base 0x%02x, class_sub 0x%02x\n", - newdev->info.vendor_id, newdev->info.device_id, newdev->info.class_base, newdev->info.class_sub)); + FLOW("PCI: CreateDevice, vendor 0x%04x, device 0x%04x, class_base 0x%02x, class_sub 0x%02x\n", + newdev->info.vendor_id, newdev->info.device_id, newdev->info.class_base, newdev->info.class_sub); // append if (parent->child == 0) { From marcusoverhagen at mail.berlios.de Mon Dec 24 00:22:54 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 24 Dec 2007 00:22:54 +0100 Subject: [Haiku-commits] r23148 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200712232322.lBNNMsMW005140@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-24 00:22:54 +0100 (Mon, 24 Dec 2007) New Revision: 23148 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23148&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Properly restore IRQ setting for JMicron PATA function. No longer reconfigure JMB360 and JMB362, those have no PATA function. Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-23 22:21:25 UTC (rev 23147) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-23 23:22:54 UTC (rev 23148) @@ -20,12 +20,12 @@ jmicron_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { switch (deviceId) { - case 0x2360: - case 0x2361: - case 0x2362: - case 0x2363: - case 0x2366: + case 0x2361: // 1 SATA, 1 PATA + case 0x2363: // 2 SATA, 1 PATA + case 0x2366: // 2 SATA, 2 PATA break; + // case 0x2360: // 1 SATA + // case 0x2362: // 2 SATA default: return; } @@ -47,7 +47,10 @@ val &= ~(1 << 16); val |= (1 << 1) | (1 << 17) | (1 << 22); pci->WritePciConfig(domain, bus, device, function, 0x40, 4, val); - pci->WritePciConfig(domain, bus, device, function, 0x3c, 1, irq); + if (function == 0) + pci->WritePciConfig(domain, bus, device, 1, 0x3c, 1, irq); + else + dprintf("jmicron_fixup_ahci: can't assign IRQ\n"); } dprintf("jmicron_fixup_ahci: 0x40: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0x40, 4)); dprintf("jmicron_fixup_ahci: 0xdc: 0x%08lx\n", pci->ReadPciConfig(domain, bus, device, function, 0xdc, 4)); @@ -60,10 +63,10 @@ { switch (deviceId) { case 0x2825: // ICH8 Desktop when in IDE emulation mode - dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825"); + dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825\n"); return; case 0x2926: // ICH9 Desktop when in IDE emulation mode - dprintf("intel_fixup_ahci: WARNING found ICH9 device id 0x2926"); + dprintf("intel_fixup_ahci: WARNING found ICH9 device id 0x2926\n"); return; case 0x27c0: // ICH7 Desktop non-AHCI and non-RAID mode @@ -124,6 +127,8 @@ uint16 vendorId = pci->ReadPciConfig(domain, bus, device, function, PCI_vendor_id, 2); uint16 deviceId = pci->ReadPciConfig(domain, bus, device, function, PCI_device_id, 2); +// dprintf("pci_fixup_device: domain %u, bus %u, device %u, function %u\n", domain, bus, device, function); + switch (vendorId) { case 0x197b: jmicron_fixup_ahci(pci, domain, bus, device, function, deviceId); From marcusoverhagen at mail.berlios.de Mon Dec 24 01:36:08 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 24 Dec 2007 01:36:08 +0100 Subject: [Haiku-commits] r23149 - haiku/trunk/src/add-ons/kernel/bus_managers/ide Message-ID: <200712240036.lBO0a8rO026496@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-24 01:36:07 +0100 (Mon, 24 Dec 2007) New Revision: 23149 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23149&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c Log: better debug output during device scanning Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-12-23 23:22:54 UTC (rev 23148) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-12-24 00:36:07 UTC (rev 23149) @@ -1,4 +1,5 @@ /* +** Copyright 2007, Marcus Overhagen. All rights reserved. ** Copyright 2002/03, Thomas Kurschel. All rights reserved. ** Distributed under the terms of the Haiku License. */ @@ -21,6 +22,7 @@ #include #include +#define TRACE(x...) dprintf("IDE: " x) /** cleanup links devices on one bus when is deleted */ @@ -29,6 +31,8 @@ { ide_bus_info *bus = device->bus; + TRACE("cleanup_device_links: device %p\n", device); + bus->devices[device->is_device1] = NULL; if (device->other_device) { @@ -48,7 +52,7 @@ static void destroy_device(ide_device_info *device) { - SHOW_FLOW( 4, "%p", device ); + TRACE("destroy_device: device %p\n", device); // paranoia device->exec_io = NULL; @@ -71,7 +75,7 @@ static void setup_device_links(ide_bus_info *bus, ide_device_info *device) { - SHOW_FLOW0( 4, "" ); + TRACE("setup_device_links: bus %p, device %p\n", bus, device); device->bus = bus; bus->devices[device->is_device1] = device; @@ -102,7 +106,7 @@ { ide_device_info *device; - SHOW_FLOW(4, "is_device1=%d", (int)is_device1); + TRACE("create_device: bus %p, device-number %d\n", bus, is_device1); device = (ide_device_info *)malloc(sizeof(*device)); if (device == NULL) @@ -188,7 +192,7 @@ ide_bus_info *bus = device->bus; int status; - FAST_LOG1(bus->log, ev_ide_scan_device_int, (uint32)atapi); + TRACE("scan_device_int: device %p, atapi %d\n", device, atapi); device->tf_param_mask = 0; device->tf.write.command = atapi ? IDE_CMD_IDENTIFY_PACKET_DEVICE @@ -203,7 +207,7 @@ device->tf.lba.device = device->is_device1; if (!send_command(device, NULL, atapi ? false : true, 20, ide_state_sync_waiting)) { - FAST_LOG0(bus->log, ev_ide_scan_device_int_cant_send); + TRACE("scan_device_int: send_command failed\n"); return false; } @@ -213,30 +217,32 @@ if (acquire_sem_etc(bus->sync_wait_sem, 1, B_RELATIVE_TIMEOUT, 100000) == B_TIMED_OUT) { bool cont; - SHOW_FLOW0( 3, "no fast response to inquiry" ); + TRACE("scan_device_int: no fast response to inquiry\n"); // check the busy flag - if it's still set, there's probably no device IDE_LOCK(bus); status = bus->controller->get_altstatus(bus->channel_cookie); - SHOW_FLOW(3, "status=%x", (int)status); cont = (status & ide_status_bsy) == ide_status_bsy; IDE_UNLOCK(bus); + TRACE("scan_device_int: status %#04x\n", status); + if (!cont) { - SHOW_FLOW0( 3, "no busy bit set after 100ms - probably noone there" ); + TRACE("scan_device_int: busy bit not set after 100ms - probably noone there\n"); // no reaction -> abort waiting cancel_irq_timeout(bus); // timeout or irq may have been fired, reset semaphore just is case acquire_sem_etc(bus->sync_wait_sem, 1, B_RELATIVE_TIMEOUT, 0); - FAST_LOG0(bus->log, ev_ide_scan_device_int_keeps_busy); + TRACE("scan_device_int: aborting because busy bit not set\n"); return false; } - SHOW_FLOW0( 3, "busy bit set, give device more time" ); + TRACE("scan_device_int: busy bit set, give device more time\n"); + // there is something, so wait for it acquire_sem(bus->sync_wait_sem); } @@ -245,8 +251,10 @@ // we've used the wait semaphore directly cancel_irq_timeout(bus); - if (bus->sync_wait_timeout) + if (bus->sync_wait_timeout) { + TRACE("scan_device_int: aborting on sync_wait_timeout\n"); return false; + } ide_wait(device, ide_status_drq, ide_status_bsy, true, 1000); @@ -254,7 +262,7 @@ if ((status & ide_status_err) != 0) { // if there's no device, all bits including the error bit are set - SHOW_FLOW( 3, "err set - no device or wrong type (status: %x)", status ); + TRACE("scan_device_int: error bit set - no device or wrong type (status: %#04x)\n", status); return false; } @@ -262,13 +270,13 @@ bus->controller->read_pio(bus->channel_cookie, (uint16 *)&device->infoblock, sizeof(device->infoblock) / sizeof(uint16), false); - if (!wait_for_drqdown(device)) + if (!wait_for_drqdown(device)) { + TRACE("scan_device_int: wait_for_drqdown failed\n"); return false; + } - SHOW_FLOW0( 3, "device found" ); + TRACE("scan_device_int: device found\n"); - FAST_LOG0(bus->log, ev_ide_scan_device_int_found); - prep_infoblock(device); return true; } @@ -282,7 +290,7 @@ int is_device1 = (int)arg; ide_device_info *device; - SHOW_FLOW(4, "is_device1: %d", is_device1); + TRACE("scan_device_worker: bus %p, device-number %d\n", bus, is_device1); // forget everything we know about the device; // don't care about peripheral drivers using this device From marcusoverhagen at mail.berlios.de Mon Dec 24 01:38:06 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Mon, 24 Dec 2007 01:38:06 +0100 Subject: [Haiku-commits] r23150 - haiku/trunk/src/add-ons/kernel/bus_managers/pci Message-ID: <200712240038.lBO0c6xi026559@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-24 01:38:06 +0100 (Mon, 24 Dec 2007) New Revision: 23150 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23150&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp Log: Disabled setting Intel IDE mode to AHCI until the PCI manager can assign new resources Modified: haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-24 00:36:07 UTC (rev 23149) +++ haiku/trunk/src/add-ons/kernel/bus_managers/pci/pci_fixup.cpp 2007-12-24 00:38:06 UTC (rev 23150) @@ -61,6 +61,8 @@ static void intel_fixup_ahci(PCI *pci, int domain, uint8 bus, uint8 device, uint8 function, uint16 deviceId) { + return; /* disabled until the PCI manager can assign new resources */ + switch (deviceId) { case 0x2825: // ICH8 Desktop when in IDE emulation mode dprintf("intel_fixup_ahci: WARNING found ICH8 device id 0x2825\n"); From stippi at mail.berlios.de Tue Dec 25 01:51:26 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 25 Dec 2007 01:51:26 +0100 Subject: [Haiku-commits] r23151 - haiku/trunk/src/apps/mail Message-ID: <200712250051.lBP0pQ3X006757@sheep.berlios.de> Author: stippi Date: 2007-12-25 01:51:26 +0100 (Tue, 25 Dec 2007) New Revision: 23151 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23151&view=rev Modified: haiku/trunk/src/apps/mail/Jamfile Log: * remove Mail from the libbe_test/install-test-apps target, it was not correctly setup anyways, since libmail.so was not part of it (at least not commited to the repo) Modified: haiku/trunk/src/apps/mail/Jamfile =================================================================== --- haiku/trunk/src/apps/mail/Jamfile 2007-12-24 00:38:06 UTC (rev 23150) +++ haiku/trunk/src/apps/mail/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src apps mail ; SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; if $(TARGET_PLATFORM) != haiku { UsePublicHeaders mail ; @@ -41,8 +40,3 @@ Mail : boot beos apps ; - -if ( $(TARGET_PLATFORM) = libbe_test ) { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Mail - : tests!apps ; -} From stippi at mail.berlios.de Tue Dec 25 02:21:34 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 25 Dec 2007 02:21:34 +0100 Subject: [Haiku-commits] r23152 - in haiku/trunk/src: apps/deskcalc apps/launchbox preferences/backgrounds preferences/joysticks preferences/time Message-ID: <200712250121.lBP1LY0s009513@sheep.berlios.de> Author: stippi Date: 2007-12-25 02:21:32 +0100 (Tue, 25 Dec 2007) New Revision: 23152 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23152&view=rev Modified: haiku/trunk/src/apps/deskcalc/Jamfile haiku/trunk/src/apps/launchbox/Jamfile haiku/trunk/src/preferences/backgrounds/Jamfile haiku/trunk/src/preferences/joysticks/Jamfile haiku/trunk/src/preferences/time/Jamfile Log: * remove these targets from the app_server test environment, they are not really needed in this context anymore Modified: haiku/trunk/src/apps/deskcalc/Jamfile =================================================================== --- haiku/trunk/src/apps/deskcalc/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) +++ haiku/trunk/src/apps/deskcalc/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) @@ -2,8 +2,6 @@ SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; - Application DeskCalc : CalcApplication.cpp CalcOptionsWindow.cpp @@ -17,7 +15,3 @@ : DeskCalc.rdef ; -if $(TARGET_PLATFORM) = libbe_test { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : DeskCalc - : tests!apps ; -} Modified: haiku/trunk/src/apps/launchbox/Jamfile =================================================================== --- haiku/trunk/src/apps/launchbox/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) +++ haiku/trunk/src/apps/launchbox/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) @@ -1,7 +1,5 @@ SubDir HAIKU_TOP src apps launchbox ; -AddSubDirSupportedPlatforms libbe_test ; - UsePrivateHeaders shared ; Application LaunchBox : @@ -18,7 +16,3 @@ : LaunchBox.rdef ; -if $(TARGET_PLATFORM) = libbe_test { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : LaunchBox - : tests!apps ; -} Modified: haiku/trunk/src/preferences/backgrounds/Jamfile =================================================================== --- haiku/trunk/src/preferences/backgrounds/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) +++ haiku/trunk/src/preferences/backgrounds/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src preferences backgrounds ; SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; UsePrivateHeaders shared ; @@ -14,7 +13,3 @@ : Backgrounds.rdef ; -if $(TARGET_PLATFORM) = libbe_test { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Backgrounds - : tests!apps ; -} Modified: haiku/trunk/src/preferences/joysticks/Jamfile =================================================================== --- haiku/trunk/src/preferences/joysticks/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) +++ haiku/trunk/src/preferences/joysticks/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src preferences joysticks ; SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; Preference Joysticks : CalibWin.cpp @@ -12,7 +11,3 @@ : Joysticks.rdef ; -if $(TARGET_PLATFORM) = libbe_test { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Joysticks - : tests!apps ; -} Modified: haiku/trunk/src/preferences/time/Jamfile =================================================================== --- haiku/trunk/src/preferences/time/Jamfile 2007-12-25 00:51:26 UTC (rev 23151) +++ haiku/trunk/src/preferences/time/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src preferences time ; SetSubDirSupportedPlatformsBeOSCompatible ; -AddSubDirSupportedPlatforms libbe_test ; UsePrivateHeaders kernel ; UseArchHeaders $(TARGET_ARCH) ; @@ -24,7 +23,3 @@ : Time.rdef ; -if $(TARGET_PLATFORM) = libbe_test { - HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Time - : tests!apps ; -} From stippi at mail.berlios.de Tue Dec 25 12:58:13 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 25 Dec 2007 12:58:13 +0100 Subject: [Haiku-commits] r23153 - in haiku/trunk/src/tests/servers/app: . draw_after_children Message-ID: <200712251158.lBPBwD2o000440@sheep.berlios.de> Author: stippi Date: 2007-12-25 12:58:11 +0100 (Tue, 25 Dec 2007) New Revision: 23153 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23153&view=rev Added: haiku/trunk/src/tests/servers/app/draw_after_children/ haiku/trunk/src/tests/servers/app/draw_after_children/DrawAfterChildren.cpp haiku/trunk/src/tests/servers/app/draw_after_children/Jamfile haiku/trunk/src/tests/servers/app/draw_after_children/run Modified: haiku/trunk/src/tests/servers/app/Jamfile Log: * added a test for B_DRAW_ON_CHILDREN view flag and documented the observed behaviour in R5 and my conclusions. Modified: haiku/trunk/src/tests/servers/app/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) +++ haiku/trunk/src/tests/servers/app/Jamfile 2007-12-25 11:58:11 UTC (rev 23153) @@ -165,6 +165,7 @@ SubInclude HAIKU_TOP src tests servers app copy_bits ; SubInclude HAIKU_TOP src tests servers app cursor_test ; SubInclude HAIKU_TOP src tests servers app desktop_window ; +SubInclude HAIKU_TOP src tests servers app draw_after_children ; SubInclude HAIKU_TOP src tests servers app event_mask ; SubInclude HAIKU_TOP src tests servers app following ; SubInclude HAIKU_TOP src tests servers app idle_test ; Added: haiku/trunk/src/tests/servers/app/draw_after_children/DrawAfterChildren.cpp =================================================================== --- haiku/trunk/src/tests/servers/app/draw_after_children/DrawAfterChildren.cpp 2007-12-25 01:21:32 UTC (rev 23152) +++ haiku/trunk/src/tests/servers/app/draw_after_children/DrawAfterChildren.cpp 2007-12-25 11:58:11 UTC (rev 23153) @@ -0,0 +1,174 @@ + +#include + +#include +#include +#include + +/*----------------------------------------------------------------------------- + +OBSERVATION on R5 behaviour: + +* The hook function DrawAfterChildren is not called at all if the + view flags don't include B_DRAW_ON_CHILDREN. + +* If the view flags include B_DRAW_ON_CHILDREN, then any drawing commands + executed in Draw() AND DrawAfterChildren() will paint on top of children. + +* The background of a view with the B_DRAW_ON_CHILDREN flag set will not + be painted by the app_server when child views change position and areas + in the parent view are "exposed". If the expose events have other reasons, + the background is painted as usual. + +* The app_server side background painting of child views does not occur + after the Draw() hook of the parent view with B_DRAW_ON_CHILDREN has been + called. So while DrawAfterChildren() may be called after the Draw() hooks + of all children have been called, the background has been painted earlier. + +* It looks like the background painting inside app_server of a view with + B_DRAW_ON_CHILDREN paints over the background of any children, though + the background of the children is later painted too. Therefor, if a child + has B_TRANSPARENT_COLOR background, the background of the parent with + B_DRAW_ON_CHILDREN stays visible in the area of that child. + +* Both Draw() and DrawAfterChildren() appear to push their own graphics + states onto the state stack. + + +CONCLUSION: + +It looks like the B_DRAW_ON_CHILDREN flag causes two effects: + +* The local view clipping region inside the app_server simply ignores + any children, this effects any drawing commands, those from Draw() + and those from DrawAfterChildren() + +* The DrawAfterChildren() hook is called after the children have drawn, + so that the user may move all drawing functions there which he does not + wish to have painted over by children. + +That areas exposed by moving child views are not repainted could +be considered a bug of the R5 implementation. + +-----------------------------------------------------------------------------*/ + + + +class TestView : public BView { +public: + TestView(BRect frame); + ~TestView(); + + virtual void Draw(BRect updateRect); + virtual void DrawAfterChildren(BRect updateRect); +}; + + +TestView::TestView(BRect frame) + : BView(frame, "TestView", B_FOLLOW_ALL, + B_WILL_DRAW | B_DRAW_ON_CHILDREN | B_FULL_UPDATE_ON_RESIZE) +{ + SetViewColor(200, 220, 255); +} + + +TestView::~TestView() +{ +} + + +void +TestView::Draw(BRect updateRect) +{ + printf("Draw(BRect(%.1f, %.1f, %.1f, %.1f))\n", + updateRect.left, updateRect.top, updateRect.right, updateRect.bottom); + + printf("pensize: %.2f\n", PenSize()); + + SetHighColor(0, 0, 255); + StrokeLine(Bounds().LeftBottom(), Bounds().RightTop()); + + SetPenSize(5); +} + +void +TestView::DrawAfterChildren(BRect updateRect) +{ + printf("DrawAfterChildren(BRect(%.1f, %.1f, %.1f, %.1f))\n", + updateRect.left, updateRect.top, updateRect.right, updateRect.bottom); + + printf("pensize: %.2f\n", PenSize()); + + SetHighColor(255, 0, 0); + StrokeLine(Bounds().LeftTop(), Bounds().RightBottom()); + Sync(); + + SetPenSize(7); +} + + +// #pragma mark - + +class ChildView : public BView { +public: + ChildView(BRect frame, const char* name, rgb_color viewColor); + ~ChildView(); + + virtual void Draw(BRect updateRect); +}; + + +ChildView::ChildView(BRect frame, const char* name, rgb_color viewColor) + : BView(frame, name, B_FOLLOW_ALL, 0) +{ + SetLowColor(200, 200, 200); + SetViewColor(viewColor); + if (*(int32*)&viewColor == *(int32*)&B_TRANSPARENT_COLOR) + SetFlags(Flags() | B_WILL_DRAW); +} + + +ChildView::~ChildView() +{ +} + + +void +ChildView::Draw(BRect updateRect) +{ + FillRect(updateRect, B_SOLID_LOW); +} + + +// #pragma mark - + + +int +main(int argc, char** argv) +{ + BApplication app("application/x-vnd.Haiku-DrawAfterChildren"); + + BRect frame(100, 100, 700, 400); + BWindow* window = new BWindow(frame, "Window", + B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE); + + frame.OffsetTo(B_ORIGIN); + TestView* view = new TestView(frame); + window->AddChild(view); + + frame.InsetBy(20, 20); + frame.right = frame.left + frame.Width() / 2 - 10; + BView* child = new ChildView(frame, "child 1", + (rgb_color){ 200, 200, 200, 255 }); + view->AddChild(child); + + frame.OffsetBy(frame.Width() + 20, 0); + child = new ChildView(frame, "child 2", B_TRANSPARENT_COLOR); + view->AddChild(child); + + window->Show(); + + app.Run(); + return 0; +} + Added: haiku/trunk/src/tests/servers/app/draw_after_children/Jamfile =================================================================== --- haiku/trunk/src/tests/servers/app/draw_after_children/Jamfile 2007-12-25 01:21:32 UTC (rev 23152) +++ haiku/trunk/src/tests/servers/app/draw_after_children/Jamfile 2007-12-25 11:58:11 UTC (rev 23153) @@ -0,0 +1,18 @@ +SubDir HAIKU_TOP src tests servers app draw_after_children ; + +SetSubDirSupportedPlatformsBeOSCompatible ; +AddSubDirSupportedPlatforms libbe_test ; + +UseHeaders [ FDirName os app ] ; +UseHeaders [ FDirName os interface ] ; + +Application DrawAfterChildren : + DrawAfterChildren.cpp + : be $(TARGET_LIBSTDC++) +; + +if $(TARGET_PLATFORM) = libbe_test { + HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : DrawAfterChildren + : tests!apps ; +} + Added: haiku/trunk/src/tests/servers/app/draw_after_children/run =================================================================== --- haiku/trunk/src/tests/servers/app/draw_after_children/run 2007-12-25 01:21:32 UTC (rev 23152) +++ haiku/trunk/src/tests/servers/app/draw_after_children/run 2007-12-25 11:58:11 UTC (rev 23153) @@ -0,0 +1,18 @@ +#!/bin/sh + +../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit + +if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then + ../../../../../generated/tests/libbe_test/x86/apps//haiku_app_server & +else + echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." +fi + +sleep 1s + +if test -f ../../../../../generated/tests/libbe_test/x86/apps/DrawAfterChildren; then + ../../../../../generated/tests/libbe_test/x86/apps/DrawAfterChildren +else + echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." +fi + Property changes on: haiku/trunk/src/tests/servers/app/draw_after_children/run ___________________________________________________________________ Name: svn:executable + * From stippi at mail.berlios.de Tue Dec 25 15:47:08 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 25 Dec 2007 15:47:08 +0100 Subject: [Haiku-commits] r23154 - in haiku/trunk: headers/os/interface src/kits/interface src/servers/app Message-ID: <200712251447.lBPEl8hl016828@sheep.berlios.de> Author: stippi Date: 2007-12-25 15:47:06 +0100 (Tue, 25 Dec 2007) New Revision: 23154 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23154&view=rev Modified: haiku/trunk/headers/os/interface/View.h haiku/trunk/src/kits/interface/View.cpp haiku/trunk/src/kits/interface/Window.cpp haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/ViewLayer.h Log: * removed declarations for methods which are not used/implemented in View.h * improved naming of some private BView functions and used our underscore prefix * added a _DrawAfterChildren method to BView which does the necessary setup and calls the DrawAfterChildren hook * call the new _DrawAfterChildren method in the BWindow implementation, this was easy since the view tokens are already hierachically sorted * implement support for B_DRAW_ON_CHILDREN in the app_server's ViewLayer, it simply means that children are ignored for the views clipping region, any drawing methods will paint over children (therefor the B_DRAW_ON_CHILDREN flag is even properly named) With these changes, support for B_DRAW_ON_CHILDREN and the DrawAfterChildren() hook are implemented and behave exactly as on R5 as far as I can tell, also for the view background painting. Modified: haiku/trunk/headers/os/interface/View.h =================================================================== --- haiku/trunk/headers/os/interface/View.h 2007-12-25 11:58:11 UTC (rev 23153) +++ haiku/trunk/headers/os/interface/View.h 2007-12-25 14:47:06 UTC (rev 23154) @@ -565,35 +565,30 @@ BView(const BView&); BView& operator=(const BView&); - void _InitData(BRect frame, const char* name, uint32 resizeMask, - uint32 flags); - status_t _SetViewBitmap(const BBitmap* bitmap,BRect srcRect, - BRect dstRect, uint32 followFlags, uint32 options); - void DoBezier(int32 gr, BPoint* controlPoints, pattern p); - void DoShape(int32 gr, BShape* shape, pattern p); - void DoPictureClip(BPicture* picture, BPoint where, bool invert, - bool sync); + void _InitData(BRect frame, const char* name, + uint32 resizeMask, uint32 flags); + status_t _SetViewBitmap(const BBitmap* bitmap, + BRect srcRect, BRect dstRect, + uint32 followFlags, uint32 options); + void _ClipToPicture(BPicture* picture, BPoint where, + bool invert, bool sync); - bool do_owner_check() const; - bool do_owner_check_no_pick() const; - void check_lock() const; - void check_lock_no_pick() const; + bool _CheckOwnerLockAndSwitchCurrent() const; + bool _CheckOwnerLock() const; + void _CheckLockAndSwitchCurrent() const; + void _CheckLock() const; + void _SwitchServerCurrentView() const; void _SetOwner(BWindow* newOwner); - void handle_tick(); - char* test_area(int32 length); - void removeCommArray(); - void SetScroller(BScrollBar* sb); - void UnsetScroller(BScrollBar* sb); - void RealScrollTo(BPoint); - void fetch_font(); - uchar font_encoding() const; + void _RemoveCommArray(); + BShelf* _Shelf() const; void _SetShelf(BShelf* shelf); void _MoveTo(int32 x, int32 y); void _ResizeBy(int32 deltaWidth, int32 deltaHeight); - void _ParentResizedBy(int32 x, int32 y); + void _ParentResizedBy(int32 deltaWidth, + int32 deltaHeight); void _ConvertToScreen(BPoint* pt, bool checkLock) const; void _ConvertFromScreen(BPoint* pt, bool checkLock) const; @@ -605,7 +600,8 @@ void _Activate(bool state); void _Attach(); void _Detach(); - void _Draw(BRect updateRect); + void _Draw(BRect screenUpdateRect); + void _DrawAfterChildren(BRect screenUpdateRect); void _Pulse(); void _UpdateStateForRemove(); @@ -621,8 +617,8 @@ bool _RemoveSelf(); // Debugging methods - void PrintToStream(); - void PrintTree(); + void _PrintToStream(); + void _PrintTree(); int32 server_token; uint32 fFlags; Modified: haiku/trunk/src/kits/interface/View.cpp =================================================================== --- haiku/trunk/src/kits/interface/View.cpp 2007-12-25 11:58:11 UTC (rev 23153) +++ haiku/trunk/src/kits/interface/View.cpp 2007-12-25 14:47:06 UTC (rev 23154) @@ -55,7 +55,7 @@ #ifdef DEBUG_BVIEW # include # define STRACE(x) printf x -# define BVTRACE PrintToStream() +# define BVTRACE _PrintToStream() #else # define STRACE(x) ; # define BVTRACE ; @@ -596,7 +596,7 @@ SetName(NULL); - removeCommArray(); + _RemoveCommArray(); delete fState; } @@ -609,7 +609,7 @@ // TODO: why should our frame be out of sync ever? /* if (!fState->IsValid(B_VIEW_FRAME_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_COORD); @@ -633,7 +633,7 @@ return; if (checkLock) - check_lock_no_pick(); + _CheckLock(); // - our scrolling offset // + our bounds location within the parent @@ -664,7 +664,7 @@ return; if (checkLock) - check_lock_no_pick(); + _CheckLock(); // - our bounds location within the parent // + our scrolling offset @@ -694,7 +694,7 @@ if (!fParent) return; - check_lock_no_pick(); + _CheckLock(); // - our scrolling offset // + our bounds location within the parent @@ -718,7 +718,7 @@ if (!fParent) return; - check_lock_no_pick(); + _CheckLock(); // - our bounds location within the parent // + our scrolling offset @@ -747,7 +747,7 @@ } if (checkLock) - do_owner_check_no_pick(); + _CheckOwnerLock(); _ConvertToParent(pt, false); fParent->_ConvertToScreen(pt, false); @@ -781,7 +781,7 @@ } if (checkLock) - do_owner_check_no_pick(); + _CheckOwnerLock(); _ConvertFromParent(pt, false); fParent->_ConvertFromScreen(pt, false); @@ -842,7 +842,7 @@ uint32 BView::Flags() const { - check_lock_no_pick(); + _CheckLock(); return fFlags & ~_RESIZE_MASK_; } @@ -855,14 +855,14 @@ if (fOwner) { if (flags & B_PULSE_NEEDED) { - check_lock_no_pick(); + _CheckLock(); if (fOwner->fPulseRunner == NULL) fOwner->SetPulseRate(fOwner->PulseRate()); } if (flags & (B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_SUBPIXEL_PRECISE)) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_FLAGS); fOwner->fLink->Attach(flags); @@ -885,7 +885,7 @@ BRect BView::Frame() const { - check_lock_no_pick(); + _CheckLock(); return Bounds().OffsetToCopy(fParentOffset.x, fParentOffset.y); } @@ -895,7 +895,7 @@ BView::Hide() { if (fOwner && fShowLevel == 0) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_HIDE); } fShowLevel++; @@ -910,7 +910,7 @@ { fShowLevel--; if (fOwner && fShowLevel == 0) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SHOW); } @@ -923,7 +923,7 @@ BView::IsFocus() const { if (fOwner) { - check_lock_no_pick(); + _CheckLock(); return fOwner->CurrentFocus() == this; } else return false; @@ -993,7 +993,7 @@ fState->origin.x = x; fState->origin.y = y; - if (do_owner_check()) { + if (_CheckOwnerLockAndSwitchCurrent()) { fOwner->fLink->StartMessage(AS_LAYER_SET_ORIGIN); fOwner->fLink->Attach(x); fOwner->fLink->Attach(y); @@ -1012,7 +1012,7 @@ if (!fState->IsValid(B_VIEW_ORIGIN_BIT)) { // we don't keep graphics state information, therefor // we need to ask the server for the origin after PopState() - do_owner_check(); + _CheckOwnerLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_ORIGIN); @@ -1033,7 +1033,7 @@ BView::SetResizingMode(uint32 mode) { if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_RESIZE_MODE); fOwner->fLink->Attach(mode); @@ -1057,7 +1057,7 @@ if (cursor == NULL || fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_CURSOR); fOwner->fLink->Attach(cursor->fServerToken); @@ -1090,7 +1090,7 @@ void BView::Sync() const { - do_owner_check_no_pick(); + _CheckOwnerLock(); if (fOwner) fOwner->Sync(); } @@ -1271,7 +1271,7 @@ void BView::BeginRectTracking(BRect startRect, uint32 style) { - if (do_owner_check()) { + if (_CheckOwnerLockAndSwitchCurrent()) { fOwner->fLink->StartMessage(AS_LAYER_BEGIN_RECT_TRACK); fOwner->fLink->Attach(startRect); fOwner->fLink->Attach(style); @@ -1282,7 +1282,7 @@ void BView::EndRectTracking() { - if (do_owner_check()) + if (_CheckOwnerLockAndSwitchCurrent()) fOwner->fLink->StartMessage(AS_LAYER_END_RECT_TRACK); } @@ -1293,7 +1293,7 @@ if (!message) return; - do_owner_check_no_pick(); + _CheckOwnerLock(); // calculate the offset BPoint offset; @@ -1370,7 +1370,7 @@ if (replyTo->Looper() == NULL) debugger("DragMessage: warning - the Handler needs a looper"); - do_owner_check_no_pick(); + _CheckOwnerLock(); if (!message->HasInt32("buttons")) { BMessage *msg = fOwner->CurrentMessage(); @@ -1419,7 +1419,7 @@ void BView::GetMouse(BPoint *location, uint32 *buttons, bool checkMessageQueue) { - do_owner_check(); + _CheckOwnerLockAndSwitchCurrent(); if (checkMessageQueue) { Window()->UpdateIfNeeded(); @@ -1551,7 +1551,7 @@ deltaY = max - fBounds.top; } - check_lock(); + _CheckLockAndSwitchCurrent(); // if we're attached to a window tell app_server about this change if (fOwner) { @@ -1594,7 +1594,7 @@ fState->archiving_flags |= B_VIEW_EVENT_MASK_BIT; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_EVENT_MASK); fOwner->fLink->Attach(mask); @@ -1620,7 +1620,7 @@ if (fOwner != NULL && fOwner->CurrentMessage() != NULL && fOwner->CurrentMessage()->what == B_MOUSE_DOWN) { - check_lock(); + _CheckLockAndSwitchCurrent(); fMouseEventOptions = options; fOwner->fLink->StartMessage(AS_LAYER_SET_MOUSE_EVENT_MASK); @@ -1646,7 +1646,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_LINE_MODE); fOwner->fLink->Attach((int8)lineCap); @@ -1690,7 +1690,7 @@ BView::LineMiterLimit() const { if (!fState->IsValid(B_VIEW_LINE_MODES_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_LINE_MODE); @@ -1716,7 +1716,7 @@ void BView::PushState() { - do_owner_check(); + _CheckOwnerLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_PUSH_STATE); @@ -1730,7 +1730,7 @@ void BView::PopState() { - do_owner_check(); + _CheckOwnerLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_POP_STATE); @@ -1746,7 +1746,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_SCALE); fOwner->fLink->Attach(scale); @@ -1763,7 +1763,7 @@ BView::Scale() const { if (!fState->IsValid(B_VIEW_SCALE_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_SCALE); @@ -1787,7 +1787,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_DRAWING_MODE); fOwner->fLink->Attach((int8)mode); @@ -1804,7 +1804,7 @@ BView::DrawingMode() const { if (!fState->IsValid(B_VIEW_DRAWING_MODE_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_DRAWING_MODE); @@ -1832,7 +1832,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_BLENDING_MODE); fOwner->fLink->Attach((int8)sourceAlpha); @@ -1853,7 +1853,7 @@ alpha_function *_alphaFunction) const { if (!fState->IsValid(B_VIEW_BLENDING_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_BLENDING_MODE); @@ -1894,7 +1894,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_PEN_LOC); fOwner->fLink->Attach(x); @@ -1925,7 +1925,7 @@ BView::PenLocation() const { if (!fState->IsValid(B_VIEW_PEN_LOCATION_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_PEN_LOC); @@ -1949,7 +1949,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_PEN_SIZE); fOwner->fLink->Attach(size); @@ -1966,7 +1966,7 @@ BView::PenSize() const { if (!fState->IsValid(B_VIEW_PEN_SIZE_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_PEN_SIZE); @@ -1992,7 +1992,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_HIGH_COLOR); fOwner->fLink->Attach(color); @@ -2010,7 +2010,7 @@ BView::HighColor() const { if (!fState->IsValid(B_VIEW_HIGH_COLOR_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_HIGH_COLOR); @@ -2035,7 +2035,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_LOW_COLOR); fOwner->fLink->Attach(color); @@ -2053,7 +2053,7 @@ BView::LowColor() const { if (!fState->IsValid(B_VIEW_LOW_COLOR_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_LOW_COLOR); @@ -2077,7 +2077,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_SET_VIEW_COLOR); fOwner->fLink->Attach(color); @@ -2095,7 +2095,7 @@ BView::ViewColor() const { if (!fState->IsValid(B_VIEW_VIEW_COLOR_BIT) && fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_VIEW_COLOR); @@ -2119,7 +2119,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_PRINT_ALIASING); fOwner->fLink->Attach(enable); @@ -2173,7 +2173,7 @@ fState->font_flags |= mask; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fState->UpdateServerFontState(*fOwner->fLink); } @@ -2237,7 +2237,7 @@ void BView::ClipToPicture(BPicture *picture, BPoint where, bool sync) { - DoPictureClip(picture, where, false, sync); + _ClipToPicture(picture, where, false, sync); } @@ -2245,7 +2245,7 @@ BView::ClipToInversePicture(BPicture *picture, BPoint where, bool sync) { - DoPictureClip(picture, where, true, sync); + _ClipToPicture(picture, where, true, sync); } @@ -2260,7 +2260,7 @@ region->MakeEmpty(); if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_GET_CLIP_REGION); int32 code; @@ -2276,7 +2276,7 @@ void BView::ConstrainClippingRegion(BRegion* region) { - if (do_owner_check()) { + if (_CheckOwnerLockAndSwitchCurrent()) { fOwner->fLink->StartMessage(AS_LAYER_SET_CLIP_REGION); if (region) { @@ -2309,7 +2309,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_DRAW_BITMAP); fOwner->fLink->Attach(bitmap->_ServerToken()); @@ -2342,7 +2342,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_DRAW_BITMAP); fOwner->fLink->Attach(bitmap->_ServerToken()); @@ -2439,7 +2439,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); // quite often delta will be NULL if (delta) @@ -2477,7 +2477,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_ELLIPSE); @@ -2502,7 +2502,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_FILL_ELLIPSE); @@ -2528,7 +2528,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_ARC); @@ -2556,7 +2556,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_FILL_ARC); @@ -2574,7 +2574,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_BEZIER); @@ -2593,7 +2593,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_FILL_BEZIER); @@ -2634,7 +2634,7 @@ || fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); BPolygon polygon(ptArray, numPoints); @@ -2664,7 +2664,7 @@ || fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); if (fOwner->fLink->StartMessage(AS_FILL_POLYGON, @@ -2712,7 +2712,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_RECT); @@ -2733,7 +2733,7 @@ if (!rect.IsValid()) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_FILL_RECT); @@ -2750,7 +2750,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_ROUNDRECT); @@ -2769,7 +2769,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); @@ -2788,7 +2788,7 @@ if (region == NULL || fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); @@ -2808,7 +2808,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); @@ -2907,7 +2907,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_FILL_TRIANGLE); @@ -2933,7 +2933,7 @@ if (fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); fOwner->fLink->StartMessage(AS_STROKE_LINE); @@ -2957,7 +2957,7 @@ if (sd->opCount == 0 || sd->ptCount == 0) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); if ((sd->opCount * sizeof(uint32)) + (sd->ptCount * sizeof(BPoint)) < MAX_ATTACHMENT_SIZE) { @@ -2985,7 +2985,7 @@ if (sd->opCount == 0 || sd->ptCount == 0) return; - check_lock(); + _CheckLockAndSwitchCurrent(); _UpdatePattern(pattern); if ((sd->opCount * sizeof(uint32)) + (sd->ptCount * sizeof(BPoint)) < MAX_ATTACHMENT_SIZE) { @@ -3013,7 +3013,7 @@ if (count <= 0) debugger("Calling BeginLineArray with a count <= 0"); - check_lock_no_pick(); + _CheckLock(); if (comm) { debugger("Can't nest BeginLineArray calls"); @@ -3041,7 +3041,7 @@ if (!comm) debugger("BeginLineArray must be called before using AddLine"); - check_lock_no_pick(); + _CheckLock(); if (comm->count < comm->maxCount) { comm->array[comm->count].startX = pt0.x; @@ -3064,7 +3064,7 @@ if (!comm) debugger("Can't call EndLineArray before BeginLineArray"); - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_STROKE_LINEARRAY); fOwner->fLink->Attach(comm->count); @@ -3072,7 +3072,7 @@ _FlushIfNotInTransaction(); - removeCommArray(); + _RemoveCommArray(); } @@ -3092,7 +3092,7 @@ void BView::BeginPicture(BPicture *picture) { - if (do_owner_check() && picture && picture->fUsurped == NULL) { + if (_CheckOwnerLockAndSwitchCurrent() && picture && picture->fUsurped == NULL) { picture->Usurp(cpicture); cpicture = picture; @@ -3104,7 +3104,7 @@ void BView::AppendToPicture(BPicture *picture) { - check_lock(); + _CheckLockAndSwitchCurrent(); if (picture && picture->fUsurped == NULL) { int32 token = picture->Token(); @@ -3125,7 +3125,7 @@ BPicture * BView::EndPicture() { - if (do_owner_check() && cpicture) { + if (_CheckOwnerLockAndSwitchCurrent() && cpicture) { int32 token; fOwner->fLink->StartMessage(AS_LAYER_END_PICTURE); @@ -3222,7 +3222,7 @@ if (!src.IsValid() || !dst.IsValid()) return; - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_COPY_BITS); fOwner->fLink->Attach(src); @@ -3281,7 +3281,7 @@ if (picture == NULL) return; - if (do_owner_check() && picture->Token() > 0) { + if (_CheckOwnerLockAndSwitchCurrent() && picture->Token() > 0) { fOwner->fLink->StartMessage(AS_LAYER_DRAW_PICTURE); fOwner->fLink->Attach(picture->Token()); fOwner->fLink->Attach(where); @@ -3331,7 +3331,7 @@ if (!invalRect.IsValid()) return; - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_INVALIDATE_RECT); fOwner->fLink->Attach(invalRect); @@ -3345,7 +3345,7 @@ if (region == NULL || fOwner == NULL) return; - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_INVALIDATE_REGION); fOwner->fLink->AttachRegion(*region); @@ -3365,7 +3365,7 @@ BView::InvertRect(BRect rect) { if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_INVERT_RECT); fOwner->fLink->Attach(rect); @@ -3429,7 +3429,7 @@ } if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); child->_SetOwner(fOwner); child->_CreateSelf(); @@ -3459,7 +3459,7 @@ int32 BView::CountChildren() const { - check_lock_no_pick(); + _CheckLock(); uint32 count = 0; BView *child = fFirstChild; @@ -3476,7 +3476,7 @@ BView * BView::ChildAt(int32 index) const { - check_lock_no_pick(); + _CheckLock(); BView *child = fFirstChild; while (child != NULL && index-- > 0) { @@ -3519,7 +3519,7 @@ // Remove this child from its parent BWindow* owner = fOwner; - check_lock_no_pick(); + _CheckLock(); if (owner != NULL) { _UpdateStateForRemove(); @@ -3601,7 +3601,7 @@ y = roundf(y); if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_MOVE_TO); fOwner->fLink->Attach(x); fOwner->fLink->Attach(y); @@ -3626,7 +3626,7 @@ return; if (fOwner) { - check_lock(); + _CheckLockAndSwitchCurrent(); fOwner->fLink->StartMessage(AS_LAYER_RESIZE_TO); fOwner->fLink->Attach(fBounds.Width() + deltaWidth); @@ -4235,7 +4235,7 @@ void -BView::removeCommArray() +BView::_RemoveCommArray() { if (comm) { delete [] comm->array; @@ -4249,7 +4249,7 @@ BView::_SetOwner(BWindow *newOwner) { if (!newOwner) - removeCommArray(); + _RemoveCommArray(); if (fOwner != newOwner && fOwner) { if (fOwner->fFocus == this) @@ -4282,13 +4282,13 @@ void -BView::DoPictureClip(BPicture *picture, BPoint where, +BView::_ClipToPicture(BPicture *picture, BPoint where, bool invert, bool sync) { if (!picture) return; - if (do_owner_check()) { + if (_CheckOwnerLockAndSwitchCurrent()) { fOwner->fLink->StartMessage(AS_LAYER_CLIP_TO_PICTURE); fOwner->fLink->Attach(picture->Token()); fOwner->fLink->Attach(where); @@ -4387,7 +4387,7 @@ BView::_CreateSelf() { // AS_LAYER_CREATE & AS_LAYER_CREATE_ROOT do not use the - // current view mechanism via check_lock() - the token + // current view mechanism via _CheckLockAndSwitchCurrent() - the token // of the view and its parent are both send to the server. if (fTopLevelView) @@ -4411,7 +4411,7 @@ fOwner->fLink->Attach(_get_object_token_(fParent)); fOwner->fLink->Flush(); - do_owner_check(); + _CheckOwnerLockAndSwitchCurrent(); fState->UpdateServerState(*fOwner->fLink); // we create all its children, too @@ -4557,7 +4557,7 @@ // window set's up the pulse messaging if (fOwner) { if (fFlags & B_PULSE_NEEDED) { - check_lock_no_pick(); + _CheckLock(); if (fOwner->fPulseRunner == NULL) fOwner->SetPulseRate(fOwner->PulseRate()); } @@ -4590,7 +4590,7 @@ AllDetached(); if (fOwner) { - check_lock_no_pick(); + _CheckLock(); if (!fOwner->IsHidden()) Invalidate(); @@ -4618,52 +4618,49 @@ [... truncated: 347 lines follow ...] From marcusoverhagen at mail.berlios.de Tue Dec 25 15:52:49 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Tue, 25 Dec 2007 15:52:49 +0100 Subject: [Haiku-commits] r23155 - in haiku/trunk/src/system/kernel: . arch/x86 Message-ID: <200712251452.lBPEqnIU017041@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-25 15:52:49 +0100 (Tue, 25 Dec 2007) New Revision: 23155 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23155&view=rev Modified: haiku/trunk/src/system/kernel/arch/x86/arch_timer.c haiku/trunk/src/system/kernel/timer.c Log: added more debug output Modified: haiku/trunk/src/system/kernel/arch/x86/arch_timer.c =================================================================== --- haiku/trunk/src/system/kernel/arch/x86/arch_timer.c 2007-12-25 14:47:06 UTC (rev 23154) +++ haiku/trunk/src/system/kernel/arch/x86/arch_timer.c 2007-12-25 14:52:49 UTC (rev 23155) @@ -25,7 +25,14 @@ #include "interrupts.h" +//#define TRACE_TIMER +#ifdef TRACE_TIMER +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + #define PIT_CLOCK_RATE 1193180 #define PIT_MAX_TIMER_INTERVAL (0xffff * 1000000ll / PIT_CLOCK_RATE) @@ -75,6 +82,7 @@ void arch_timer_set_hardware_timer(bigtime_t timeout) { + TRACE(("arch_timer_set_hardware_timer: timeout %lld\n", timeout)); // try the apic timer first if (arch_smp_set_apic_timer(timeout) != B_OK) set_isa_hardware_timer(timeout); @@ -84,6 +92,7 @@ void arch_timer_clear_hardware_timer(void) { + TRACE(("arch_timer_clear_hardware_timer\n")); if (arch_smp_clear_apic_timer() != B_OK) clear_isa_hardware_timer(); } Modified: haiku/trunk/src/system/kernel/timer.c =================================================================== --- haiku/trunk/src/system/kernel/timer.c 2007-12-25 14:47:06 UTC (rev 23154) +++ haiku/trunk/src/system/kernel/timer.c 2007-12-25 14:52:49 UTC (rev 23155) @@ -93,6 +93,8 @@ release_spinlock(spinlock); + TRACE(("timer_interrupt: calling hook %p for event %p\n", event->hook, event)); + // call the callback // note: if the event is not periodic, it is ok // to delete the event structure inside the callback @@ -140,6 +142,8 @@ if (event == NULL || hook == NULL || period < 0) return B_BAD_VALUE; + TRACE(("add_timer: event %p\n", event)); + scheduleTime = period; if (flags != B_ONE_SHOT_ABSOLUTE_TIMER) scheduleTime += currentTime; @@ -214,6 +218,8 @@ int currentCPU = smp_get_current_cpu(); cpu_status state; + TRACE(("cancel_timer: event %p\n", event)); + state = disable_interrupts(); // walk through all of the cpu's timer queues From stippi at mail.berlios.de Tue Dec 25 22:56:14 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Tue, 25 Dec 2007 22:56:14 +0100 Subject: [Haiku-commits] r23156 - haiku/trunk/src/kits/interface/textview_support Message-ID: <200712252156.lBPLuEiN027818@sheep.berlios.de> Author: stippi Date: 2007-12-25 22:56:14 +0100 (Tue, 25 Dec 2007) New Revision: 23156 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23156&view=rev Modified: haiku/trunk/src/kits/interface/textview_support/UndoBuffer.cpp Log: * I am pretty sure this was a bug... spotted by pure chance, should have caused messed up undo/redo when removing multibyte UTF8 glyphs via forward backspace Modified: haiku/trunk/src/kits/interface/textview_support/UndoBuffer.cpp =================================================================== --- haiku/trunk/src/kits/interface/textview_support/UndoBuffer.cpp 2007-12-25 14:52:49 UTC (rev 23155) +++ haiku/trunk/src/kits/interface/textview_support/UndoBuffer.cpp 2007-12-25 21:56:14 UTC (rev 23156) @@ -392,7 +392,7 @@ if (fTextLength < newLength) { // store the erased character for (int32 x = 0; x < charLen; x++) - buffer[fTextLength] = fTextView->ByteAt(start + x); + buffer[fTextLength + x] = fTextView->ByteAt(start + x); } fTextLength = newLength; From jackburton at mail.berlios.de Tue Dec 25 23:47:20 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Tue, 25 Dec 2007 23:47:20 +0100 Subject: [Haiku-commits] r23157 - haiku/trunk/src/kits/interface Message-ID: <200712252247.lBPMlKGq030039@sheep.berlios.de> Author: jackburton Date: 2007-12-25 23:47:19 +0100 (Tue, 25 Dec 2007) New Revision: 23157 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23157&view=rev Modified: haiku/trunk/src/kits/interface/PrintJob.cpp Log: call Draw() between PushState/PopState. Added some Todo. Modified: haiku/trunk/src/kits/interface/PrintJob.cpp =================================================================== --- haiku/trunk/src/kits/interface/PrintJob.cpp 2007-12-25 21:56:14 UTC (rev 23156) +++ haiku/trunk/src/kits/interface/PrintJob.cpp 2007-12-25 22:47:19 UTC (rev 23157) @@ -266,8 +266,9 @@ fCurrentPageHeader = NULL; } -static -status_t ConfigPageThread(void *data) + +static status_t +ConfigPageThread(void *data) { BPrivate::Configuration* configuration = static_cast(data); @@ -581,6 +582,7 @@ return valid; } + // Either SetSettings() or ConfigPage() has to be called prior // to any of the getters otherwise they return undefined values. BRect @@ -654,10 +656,14 @@ BPicture *picture, BRect rect) { ASSERT(picture != NULL); - + // TODO: test what happens if views don't have + // the B_WILL_DRAW flag or have B_DRAW_ON_CHILDREN + view->AppendToPicture(picture); view->f_is_printing = true; + view->PushState(); view->Draw(rect); + view->PopState(); view->f_is_printing = false; view->EndPicture(); From jackburton at mail.berlios.de Wed Dec 26 00:09:23 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Wed, 26 Dec 2007 00:09:23 +0100 Subject: [Haiku-commits] r23158 - haiku/trunk/src/kits/interface Message-ID: <200712252309.lBPN9Nx5030928@sheep.berlios.de> Author: jackburton Date: 2007-12-26 00:09:22 +0100 (Wed, 26 Dec 2007) New Revision: 23158 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23158&view=rev Modified: haiku/trunk/src/kits/interface/MenuBar.cpp Log: After some testing on beos, I fixed bug #952. Please check but I think it's correct now. Modified: haiku/trunk/src/kits/interface/MenuBar.cpp =================================================================== --- haiku/trunk/src/kits/interface/MenuBar.cpp 2007-12-25 22:47:19 UTC (rev 23157) +++ haiku/trunk/src/kits/interface/MenuBar.cpp 2007-12-25 23:09:22 UTC (rev 23158) @@ -558,7 +558,7 @@ fState = MENU_STATE_CLOSED; } } else if (menuItem == NULL && fSelected != NULL - && !_IsStickyMode() && fState != MENU_STATE_TRACKING_SUBMENU) { + && !_IsStickyMode() && Bounds().Contains(where)) { _SelectItem(NULL); fState = MENU_STATE_TRACKING; } From revol at free.fr Wed Dec 26 14:35:24 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Wed, 26 Dec 2007 14:35:24 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23154_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/os/interface_src/kits/interface_src/servers/app?= In-Reply-To: <200712251447.lBPEl8hl016828@sheep.berlios.de> Message-ID: <1498779702-BeMail@laptop> > With these changes, support for B_DRAW_ON_CHILDREN and > the DrawAfterChildren() > hook are implemented and behave exactly as on R5 as far as I can > tell, also > for the view background painting. Oh, that will certainly help BSnow, thx ;) Fran?ois. From stippi at mail.berlios.de Wed Dec 26 15:12:12 2007 From: stippi at mail.berlios.de (stippi at BerliOS) Date: Wed, 26 Dec 2007 15:12:12 +0100 Subject: [Haiku-commits] r23159 - haiku/trunk/src/servers/app Message-ID: <200712261412.lBQECCrf029714@sheep.berlios.de> Author: stippi Date: 2007-12-26 15:12:12 +0100 (Wed, 26 Dec 2007) New Revision: 23159 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23159&view=rev Modified: haiku/trunk/src/servers/app/ViewLayer.cpp haiku/trunk/src/servers/app/ViewLayer.h Log: * small cleanups for more coding style consistency Modified: haiku/trunk/src/servers/app/ViewLayer.cpp =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.cpp 2007-12-25 23:09:22 UTC (rev 23158) +++ haiku/trunk/src/servers/app/ViewLayer.cpp 2007-12-26 14:12:12 UTC (rev 23159) @@ -1142,16 +1142,17 @@ void ViewLayer::SetCursor(ServerCursor *cursor) { - if (cursor != fCursor) { - if (fCursor) - fCursor->Release(); + if (cursor == fCursor) + return; - fCursor = cursor; + if (fCursor) + fCursor->Release(); - if (fCursor) { - fCursor->Acquire(); - fCursor->SetPendingViewCursor(false); - } + fCursor = cursor; + + if (fCursor) { + fCursor->Acquire(); + fCursor->SetPendingViewCursor(false); } } @@ -1163,13 +1164,6 @@ } -ServerPicture * -ViewLayer::Picture() const -{ - return fPicture; -} - - void ViewLayer::Draw(DrawingEngine* drawingEngine, BRegion* effectiveClipping, BRegion* windowContentClipping, bool deep) Modified: haiku/trunk/src/servers/app/ViewLayer.h =================================================================== --- haiku/trunk/src/servers/app/ViewLayer.h 2007-12-25 23:09:22 UTC (rev 23158) +++ haiku/trunk/src/servers/app/ViewLayer.h 2007-12-26 14:12:12 UTC (rev 23159) @@ -37,8 +37,8 @@ class ViewLayer { public: ViewLayer(IntRect frame, IntPoint scrollingOffset, - const char* name, int32 token, uint32 resizeMode, - uint32 flags); + const char* name, int32 token, + uint32 resizeMode, uint32 flags); virtual ~ViewLayer(); @@ -164,8 +164,9 @@ ServerBitmap* ViewBitmap() const { return fViewBitmap; } - void SetViewBitmap(ServerBitmap* bitmap, IntRect sourceRect, - IntRect destRect, int32 resizingMode, int32 options); + void SetViewBitmap(ServerBitmap* bitmap, + IntRect sourceRect, IntRect destRect, + int32 resizingMode, int32 options); void PushState(); void PopState(); @@ -177,11 +178,12 @@ uint32 EventOptions() const { return fEventOptions; } + void SetCursor(ServerCursor* cursor); ServerCursor* Cursor() const { return fCursor; } - void SetCursor(ServerCursor* cursor); - ServerPicture* Picture() const; void SetPicture(ServerPicture* picture); + ServerPicture* Picture() const + { return fPicture; } // for background clearing virtual void Draw(DrawingEngine* drawingEngine, @@ -223,7 +225,7 @@ // clipping void RebuildClipping(bool deep); BRegion& ScreenClipping(BRegion* windowContentClipping, - bool force = false) const; + bool force = false) const; void InvalidateScreenClipping(); inline bool IsScreenClippingValid() const { return fScreenClippingValid; } @@ -233,7 +235,7 @@ protected: void _MoveScreenClipping(int32 x, int32 y, - bool deep); + bool deep); Overlay* _Overlay() const; void _UpdateOverlayView() const; From mmu_man at mail.berlios.de Wed Dec 26 15:19:49 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 26 Dec 2007 15:19:49 +0100 Subject: [Haiku-commits] r23160 - haiku/trunk/src/apps/bsnow Message-ID: <200712261419.lBQEJne9029865@sheep.berlios.de> Author: mmu_man Date: 2007-12-26 15:19:49 +0100 (Wed, 26 Dec 2007) New Revision: 23160 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23160&view=rev Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp Log: This helps, but only on Dano. Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp =================================================================== --- haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 14:12:12 UTC (rev 23159) +++ haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 14:19:49 UTC (rev 23160) @@ -140,6 +140,9 @@ fDragger->SetViewColor(col); if (fDragger->InShelf()) { p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); +#ifdef B_UPDATE_INVALIDATED + p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED); +#endif ResizeTo(p->Bounds().Width(), p->Bounds().Height()); MoveTo(0,0); fDragger->MoveTo(p->Bounds().Width()-7, p->Bounds().Height()-7); From marcusoverhagen at mail.berlios.de Wed Dec 26 16:25:05 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 16:25:05 +0100 Subject: [Haiku-commits] r23161 - haiku/trunk/src/system/kernel/fs Message-ID: <200712261525.lBQFP5xw031942@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 16:25:05 +0100 (Wed, 26 Dec 2007) New Revision: 23161 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23161&view=rev Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp Log: dump all found devices and partitions to serial debug output Modified: haiku/trunk/src/system/kernel/fs/vfs_boot.cpp =================================================================== --- haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-12-26 14:19:49 UTC (rev 23160) +++ haiku/trunk/src/system/kernel/fs/vfs_boot.cpp 2007-12-26 15:25:05 UTC (rev 23161) @@ -370,6 +370,14 @@ return status; } + if (1 /* dump devices and partitions */) { + KDiskDevice *device; + int32 cookie = 0; + while ((device = manager->NextDevice(&cookie)) != NULL) { + device->Dump(true, 0); + } + } + struct BootPartitionVisitor : KPartitionVisitor { BootPartitionVisitor(BootMethod* bootMethod, PartitionStack &stack) : fPartitions(stack), From marcusoverhagen at mail.berlios.de Wed Dec 26 16:26:38 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 16:26:38 +0100 Subject: [Haiku-commits] r23162 - haiku/trunk/src/add-ons/kernel/bus_managers/ide Message-ID: <200712261526.lBQFQcpp032067@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 16:26:38 +0100 (Wed, 26 Dec 2007) New Revision: 23162 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23162&view=rev Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c haiku/trunk/src/add-ons/kernel/bus_managers/ide/sync.c Log: improved debug output Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-12-26 15:25:05 UTC (rev 23161) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/devices.c 2007-12-26 15:26:38 UTC (rev 23162) @@ -201,8 +201,10 @@ // initialize device selection flags, // this is the only place where this bit gets initialized in the task file if (bus->controller->read_command_block_regs(bus->channel_cookie, &device->tf, - ide_mask_device_head) != B_OK) + ide_mask_device_head) != B_OK) { + TRACE("scan_device_int: read_command_block_regs failed\n"); return false; + } device->tf.lba.device = device->is_device1; Modified: haiku/trunk/src/add-ons/kernel/bus_managers/ide/sync.c =================================================================== --- haiku/trunk/src/add-ons/kernel/bus_managers/ide/sync.c 2007-12-26 15:25:05 UTC (rev 23161) +++ haiku/trunk/src/add-ons/kernel/bus_managers/ide/sync.c 2007-12-26 15:26:38 UTC (rev 23162) @@ -98,9 +98,6 @@ { ide_device_info *device; - TRACE(("\n")); - FAST_LOG0(bus->log, ev_ide_irq_handle); - // we need to lock bus to have a solid bus state // (side effect: we lock out the timeout handler and get // delayed if the IRQ happens at the same time as a command is @@ -131,11 +128,9 @@ return B_UNHANDLED_INTERRUPT; } - TRACE(("state: %d\n", bus->state)); - switch (bus->state) { case ide_state_async_waiting: - TRACE(("async waiting\n")); + TRACE(("state: async waiting\n")); bus->state = ide_state_accessing; @@ -145,7 +140,7 @@ return B_INVOKE_SCHEDULER; case ide_state_idle: - TRACE(("idle\n")); + TRACE(("state: idle, num_running_reqs %d\n", bus->num_running_reqs)); // this must be a service request; // if no request is pending, the IRQ was fired wrongly @@ -162,7 +157,7 @@ return B_INVOKE_SCHEDULER; case ide_state_sync_waiting: - TRACE(("sync waiting\n")); + TRACE(("state: sync waiting\n")); bus->state = ide_state_accessing; bus->sync_wait_timeout = false; @@ -173,7 +168,7 @@ return B_INVOKE_SCHEDULER; case ide_state_accessing: - TRACE(("spurious IRQ - there is a command being executed\n")); + TRACE(("state: spurious IRQ - there is a command being executed\n")); IDE_UNLOCK(bus); return B_UNHANDLED_INTERRUPT; From ingo_weinhold at gmx.de Wed Dec 26 16:31:04 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Wed, 26 Dec 2007 16:31:04 +0100 Subject: [Haiku-commits] r23160 - haiku/trunk/src/apps/bsnow In-Reply-To: <200712261419.lBQEJne9029865@sheep.berlios.de> References: <200712261419.lBQEJne9029865@sheep.berlios.de> Message-ID: <20071226163104.400.1@knochen-vm.nameserver> On 2007-12-26 at 15:19:49 [+0100], mmu_man at BerliOS wrote: > Author: mmu_man > Date: 2007-12-26 15:19:49 +0100 (Wed, 26 Dec 2007) > New Revision: 23160 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23160&view=rev > > Modified: > haiku/trunk/src/apps/bsnow/SnowView.cpp > Log: > This helps, but only on Dano. > > > Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp > =================================================================== > --- haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 14:12:12 UTC (rev > 23159) > +++ haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 14:19:49 UTC (rev > 23160) > @@ -140,6 +140,9 @@ > fDragger->SetViewColor(col); > if (fDragger->InShelf()) { > p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); > +#ifdef B_UPDATE_INVALIDATED > + p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED); > +#endif B_UPDATE_INVALIDATED is an enum element. CU, Ingo From stefano.ceccherini at gmail.com Wed Dec 26 22:37:51 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Wed, 26 Dec 2007 22:37:51 +0100 Subject: [Haiku-commits] r23154 - in haiku/trunk: headers/os/interface src/kits/interface src/servers/app In-Reply-To: <1498779702-BeMail@laptop> References: <200712251447.lBPEl8hl016828@sheep.berlios.de> <1498779702-BeMail@laptop> Message-ID: <894b9700712261337q4f56f6aavd831e157e0542a82@mail.gmail.com> 2007/12/26, Fran?ois Revol : > > With these changes, support for B_DRAW_ON_CHILDREN and > > the DrawAfterChildren() > > hook are implemented and behave exactly as on R5 as far as I can > > tell, also > > for the view background painting. > > Oh, that will certainly help BSnow, thx ;) > Is it supposed to cover the desktop only partially or it's a bug of BShelf ? From mmu_man at mail.berlios.de Wed Dec 26 22:46:17 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Wed, 26 Dec 2007 22:46:17 +0100 Subject: [Haiku-commits] r23163 - haiku/trunk/src/apps/bsnow Message-ID: <200712262146.lBQLkHSC004771@sheep.berlios.de> Author: mmu_man Date: 2007-12-26 22:46:11 +0100 (Wed, 26 Dec 2007) New Revision: 23163 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23163&view=rev Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp Log: Don't ifdef on an enum. Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp =================================================================== --- haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 15:26:38 UTC (rev 23162) +++ haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 21:46:11 UTC (rev 23163) @@ -140,7 +140,7 @@ fDragger->SetViewColor(col); if (fDragger->InShelf()) { p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); -#ifdef B_UPDATE_INVALIDATED +#ifdef B_BEOS_VERSION_DANO p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED); #endif ResizeTo(p->Bounds().Width(), p->Bounds().Height()); From marcusoverhagen at mail.berlios.de Wed Dec 26 23:24:41 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 23:24:41 +0100 Subject: [Haiku-commits] r23164 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712262224.lBQMOfU4007194@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 23:24:40 +0100 (Wed, 26 Dec 2007) New Revision: 23164 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23164&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp Log: added more debug output Modified: haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-12-26 21:46:11 UTC (rev 23163) +++ haiku/trunk/src/system/boot/platform/bios_ia32/mmu.cpp 2007-12-26 22:24:40 UTC (rev 23164) @@ -133,6 +133,9 @@ static uint32 * get_next_page_table() { + TRACE(("get_next_page_table, sNextPageTableAddress %p, kPageTableRegionEnd %p\n", + sNextPageTableAddress, kPageTableRegionEnd)); + addr_t address = sNextPageTableAddress; if (address >= kPageTableRegionEnd) return (uint32 *)get_next_physical_page(); @@ -210,9 +213,16 @@ // map the page to the correct page table uint32 *pageTable = (uint32 *)(sPageDirectory[virtualAddress / (B_PAGE_SIZE * 1024)] & 0xfffff000); - pageTable[(virtualAddress % (B_PAGE_SIZE * 1024)) / B_PAGE_SIZE] = physicalAddress | flags; + uint32 tableEntry = (virtualAddress % (B_PAGE_SIZE * 1024)) / B_PAGE_SIZE; + + TRACE(("map_page: inserting pageTable %p, tableEntry %ld, physicalAddress %p\n", + pageTable, tableEntry, physicalAddress)); + pageTable[tableEntry] = physicalAddress | flags; + asm volatile("invlpg (%0)" : : "r" (virtualAddress)); + + TRACE(("map_page: done\n")); } @@ -275,6 +285,8 @@ static void init_page_directory(void) { + TRACE(("init_page_directory\n")); + // allocate a new pgdir sPageDirectory = (uint32 *)get_next_physical_page(); gKernelArgs.arch_args.phys_pgdir = (uint32)sPageDirectory; @@ -417,6 +429,7 @@ extern "C" void mmu_init_for_kernel(void) { + TRACE(("mmu_init_for_kernel\n")); // set up a new idt { struct gdt_idt_descr idtDescriptor; @@ -536,6 +549,8 @@ extern "C" void mmu_init(void) { + TRACE(("mmu_init\n")); + gKernelArgs.physical_allocated_range[0].start = sNextPhysicalAddress; gKernelArgs.physical_allocated_range[0].size = 0; gKernelArgs.num_physical_allocated_ranges = 1; From marcusoverhagen at mail.berlios.de Wed Dec 26 23:26:08 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 23:26:08 +0100 Subject: [Haiku-commits] r23165 - in haiku/trunk: headers/private/kernel/boot src/system/boot/loader Message-ID: <200712262226.lBQMQ8DP007679@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 23:26:08 +0100 (Wed, 26 Dec 2007) New Revision: 23165 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23165&view=rev Modified: haiku/trunk/headers/private/kernel/boot/partitions.h haiku/trunk/src/system/boot/loader/partitions.cpp Log: Added more debugging code. The partition code appears to be using objects that have been destroyed. Modified: haiku/trunk/headers/private/kernel/boot/partitions.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/partitions.h 2007-12-26 22:24:40 UTC (rev 23164) +++ haiku/trunk/headers/private/kernel/boot/partitions.h 2007-12-26 22:26:08 UTC (rev 23165) @@ -30,8 +30,8 @@ status_t Mount(Directory **_fileSystem = NULL, bool isBootDevice = false); status_t Scan(bool mountFileSystems, bool isBootDevice = false); - void SetParent(Partition *parent) { fParent = parent; } - Partition *Parent() const { return fParent; } + void SetParent(Partition *parent); + Partition *Parent() const; bool IsFileSystem() const { return fIsFileSystem; } bool IsPartitioningSystem() const { return fIsPartitioningSystem; } Modified: haiku/trunk/src/system/boot/loader/partitions.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/partitions.cpp 2007-12-26 22:24:40 UTC (rev 23164) +++ haiku/trunk/src/system/boot/loader/partitions.cpp 2007-12-26 22:26:08 UTC (rev 23165) @@ -104,6 +104,8 @@ fIsFileSystem(false), fIsPartitioningSystem(false) { + TRACE(("%p Partition::Partition\n", this)); + memset((partition_data *)this, 0, sizeof(partition_data)); id = (partition_id)this; @@ -114,10 +116,27 @@ Partition::~Partition() { + TRACE(("%p Partition::~Partition\n", this)); close(fFD); } +void +Partition::SetParent(Partition *parent) +{ + TRACE(("%p Partition::SetParent %p\n", this, parent)); + fParent = parent; +} + + +Partition * +Partition::Parent() const +{ + TRACE(("%p Partition::Parent is %p\n", this, fParent)); + return fParent; +} + + ssize_t Partition::ReadAt(void *cookie, off_t position, void *buffer, size_t bufferSize) { @@ -174,6 +193,7 @@ Partition::AddChild() { Partition *child = new Partition(fFD); + TRACE(("%p Partition::AddChild %p\n", this, child)); if (child == NULL) return NULL; @@ -188,7 +208,8 @@ status_t Partition::_Mount(file_system_module_info *module, Directory **_fileSystem) { - TRACE(("check for file_system: %s\n", module->pretty_name)); + TRACE(("%p Partition::_Mount check for file_system: %s\n", + this, module->pretty_name)); Directory *fileSystem; if (module->get_file_system(this, &fileSystem) == B_OK) { @@ -230,7 +251,7 @@ { // scan for partitions first (recursively all eventual children as well) - TRACE(("Partition::Scan()\n")); + TRACE(("%p Partition::Scan()\n", this)); // if we were not booted from the real boot device, we won't scan // the device we were booted from (which is likely to be a slow @@ -314,8 +335,8 @@ Partition *child = NULL; while ((child = (Partition *)iterator.Next()) != NULL) { - TRACE(("*** scan child %p (start = %Ld, size = %Ld, parent = %p)!\n", - child, child->offset, child->size, child->Parent())); + TRACE(("%p Partition::Scan: *** scan child %p (start = %Ld, size = %Ld, parent = %p)!\n", + this, child, child->offset, child->size, child->Parent())); child->Scan(mountFileSystems); From marcusoverhagen at mail.berlios.de Wed Dec 26 23:30:42 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 23:30:42 +0100 Subject: [Haiku-commits] r23166 - haiku/trunk/src/system/boot/platform/bios_ia32 Message-ID: <200712262230.lBQMUgAn008620@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 23:30:41 +0100 (Wed, 26 Dec 2007) New Revision: 23166 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23166&view=rev Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c Log: Increased keypress detection time to 750ms. The old 50ms value never worked for me. Modified: haiku/trunk/src/system/boot/platform/bios_ia32/start.c =================================================================== --- haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2007-12-26 22:26:08 UTC (rev 23165) +++ haiku/trunk/src/system/boot/platform/bios_ia32/start.c 2007-12-26 22:30:41 UTC (rev 23166) @@ -122,8 +122,8 @@ cpu_init(); mmu_init(); - spin(50000); - // wait a bit to give the user the opportunity to press a key + // wait a bit to give the user the opportunity to press a key + spin(750000); // reading the keyboard doesn't seem to work in graphics mode (maybe a bochs problem) sBootOptions = check_for_boot_keys(); From marcusoverhagen at mail.berlios.de Wed Dec 26 23:35:26 2007 From: marcusoverhagen at mail.berlios.de (marcusoverhagen at BerliOS) Date: Wed, 26 Dec 2007 23:35:26 +0100 Subject: [Haiku-commits] r23167 - haiku/trunk/src/system/boot/loader Message-ID: <200712262235.lBQMZQtx008805@sheep.berlios.de> Author: marcusoverhagen Date: 2007-12-26 23:35:26 +0100 (Wed, 26 Dec 2007) New Revision: 23167 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23167&view=rev Modified: haiku/trunk/src/system/boot/loader/menu.cpp Log: added more debug output Modified: haiku/trunk/src/system/boot/loader/menu.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/menu.cpp 2007-12-26 22:30:41 UTC (rev 23166) +++ haiku/trunk/src/system/boot/loader/menu.cpp 2007-12-26 22:35:26 UTC (rev 23167) @@ -21,6 +21,12 @@ #include +#define TRACE_MENU +#ifdef TRACE_MENU +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif MenuItem::MenuItem(const char *label, Menu *subMenu) : @@ -496,6 +502,8 @@ Menu *safeModeMenu = NULL; MenuItem *item; + TRACE(("user_menu: enter\n")); + // Add boot volume menu->AddItem(item = new(nothrow) MenuItem("Select boot volume", add_boot_volume_menu(*_bootVolume))); @@ -528,6 +536,8 @@ apply_safe_mode_options(safeModeMenu); delete menu; + TRACE(("user_menu: leave\n")); + return B_OK; } From nielx at mail.berlios.de Thu Dec 27 14:17:20 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Thu, 27 Dec 2007 14:17:20 +0100 Subject: [Haiku-commits] r23168 - in haiku/trunk/docs/user: . app Message-ID: <200712271317.lBRDHKvN017203@sheep.berlios.de> Author: nielx Date: 2007-12-27 14:17:20 +0100 (Thu, 27 Dec 2007) New Revision: 23168 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23168&view=rev Added: haiku/trunk/docs/user/app/Handler.dox Modified: haiku/trunk/docs/user/Doxyfile Log: Phase I of the BHandler documentation. Modified: haiku/trunk/docs/user/Doxyfile =================================================================== --- haiku/trunk/docs/user/Doxyfile 2007-12-26 22:35:26 UTC (rev 23167) +++ haiku/trunk/docs/user/Doxyfile 2007-12-27 13:17:20 UTC (rev 23168) @@ -276,7 +276,7 @@ # If set to NO (the default) these declarations will be included in the # documentation. -HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = YES # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. Added: haiku/trunk/docs/user/app/Handler.dox =================================================================== --- haiku/trunk/docs/user/app/Handler.dox 2007-12-26 22:35:26 UTC (rev 23167) +++ haiku/trunk/docs/user/app/Handler.dox 2007-12-27 13:17:20 UTC (rev 23168) @@ -0,0 +1,609 @@ +/* + * Copyright 2007, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Niels Sascha Reedijk, niels.reedijk at gmail.com + * + * Corresponds to: + * /trunk/headers/os/app/Handler.h rev 22577 + * /trunk/src/kits/app/Message.cpp rev 21332 + */ + +/*! + \file Handler.h + \brief Provides the BHandler class. +*/ + +///// Globals ///// + +/*! + \def B_OBSERVE_WHAT_CHANGE + \brief Internal. +*/ + + +/*! + \def B_OBSERVE_ORIGINAL_WHAT + \brief Constant for a message data field in observer messages. + + If you have called one of the flavors of BHandler::StartWachting(), and + you receive a notification, sometimes there can be send a BMessage to go + with that notification. The message you receive is a copy of that message, + but with the what constant set to \c B_OBSERVER_NOTICE_CHANGE. The original + \c what constant of the transmitted data message is stored behind the + label defined by this constant. +*/ + + +/*! + \var B_OBSERVER_OBSERVE_ALL + \brief Parameter to BHandler::StartWatching(). + + \note Specifying this parameter as the \a what value, leads to the same + results as calling BHandler::StartWatchingAll(). +*/ + + +///// BHandler ///// + + +/*! + \class BHandler + \ingroup app + \brief Handles messages that are passed on by a BLooper. + + The BHandler class implements two important pieces of functionality. It + provides the foundations for handling messages, and it serves as a + state machine that sends out notifications of the state changes. + + The most common use of this class is to handle messages. Handlers + can be tied to loopers, which are the objects that send and receive + messages. As soon as a message is received, the looper passes through its + list of associated handlers and tries them in a certain order until the + message is handled, or the options are exhausted. + + You should know that a looper is a subclass of a handler, and as such, + loopers can be self-contained and do not need additional handlers. In many + cases, this construction will suffice. You will simply subclass the looper, + override its MessageReceived() hook and handle the messages you receive. In + some cases, you might opt in for a more ingenious construction. A + real-world example is the interface kit. Within that kit, the windows are + represented by a BLooper, and all the views and controls in that kit are + derived from BHandler. If you put a control in a window, then whenever + messages such as clicks are received, the window loops the handlers until + there is a handler that is at the screen position the click was in. It is + not unlikely that you will some day want to use this functionality of the + API. + + If your handler is limited to a certain type of messages, you can set a + filter that the looper will apply to your message before passing it on to + your overridden MessageReceived() method. The BMessageFilter class provides + the framework for the flexible filtering options, and using AddFilter() you + can apply filters to this handler. Note that a filter object should only be + applied to one handler. They cannot be shared. + + For more information on the handling chain, have a look at the + documentation of the BLooper class. + + Using BHandler as a state machine is a second area of functionality. + Since handlers process messages, and perform actions associated with those, + they are the center of keeping track on the current state of things within + an application. If you want to synchronize these states between different + parts of your application, you could perform this manually by sending + messages to the interested components, or you can use the more flexible + approach with observers. + + Observers watch a certain state. A handler can track one or more different + states. Each state is represented by a four byte constant - just like the + \c what property of a message. Using the StartWatching() methods, you can + register observers both within your team, and in other applications. As an + argument of that method, you can supply the state you want to watch, or you + can register an observer using StartWatchingAll() to watch all the states + the handler tracks. When the handler needs to emit a state change, you can + use SendNotices(). You can specify the exact state change, and some data + that you want to be send to the observers. This data is in the form of the + very flexible BMessage, as such you are almost free to pass anything you + want. + + Whenever SendNotices() is called, all interested observers will receive a + message of the \a B_OBSERVER_NOTICE_CHANGE type. Please note that the + constant that is associated with the state itself is not transmitted. If + you require this information, consider using the message that is passed + on to describe the state change. + + BHandler is a part of the chain in the eloquent messaging structure. For a + proper understanding of all its facets, have a look at the \ref app_messaging + "messaging overview". +*/ + + +/*! + \fn BHandler::BHandler(const char* name = NULL) + \brief Construct a new handler with a \a name. + + The newly constructed handler is not associated with a looper until you + explicitly request this to happen. To associate this handler with a looper, + use BLooper::AddHandler(). +*/ + + +/*! + \fn BHandler::~BHandler() + \brief Free the filters of this handler, as well as the list of observers. + + This method does not remove the handler from the looper to which this + handler is associated. You should do this yourself, using + BLooper::RemoveHandler(). +*/ + + +/*! + \fn BArchivable *BHandler::Instantiate(BMessage *data) + \brief Static method to instantiate a handler from an archived message. + + \return A pointer to the instantiated handler, or \c NULL if the \a data + is not a valid archived BHandler object. + \see BHandler(BMessage* data) +*/ + + +///// Archiving ///// + +/*! + \name Archiving + BHandler inherits the BArchivable class, and as such implements support for + archiving and unarchiving handlers. +*/ + + +//! @{ + + +/*! + \fn BHandler::BHandler(BMessage* data) + \brief Construct a handler from an archived message. + + This \a data has to be created using the BHandler::Archive() method. + Note that only the name is stored. The filters, the associated looper and + the observers are not stored, and should be manually added when you are + using this object. +*/ + + +/*! + \fn status_t BHandler::Archive(BMessage *data, bool deep) const + \brief Archive a handler to a message + + Currently, only the name is archived. The filters, the associated looper + and the observers are not stored. + + \param data The message to archive the object in. + \param deep This parameter is ignored, as BHandler does not have children. + \retval B_OK Archiving succeeded. + \retval B_BAD_VALUE The \a data parameter is not a valid message. + \see BHandler::Instantiate(BMessage *data) +*/ + + +//! @} + + +///// The guts of BHandler ///// + + +/*! + \name Core Functionality +*/ + + +//! @{ + + +/*! + \fn void BHandler::MessageReceived(BMessage *message) + \brief Handle a message that has been received by the associated looper. + + This method is reimplemented in your subclasses. If the messages that have + been received by a looper pass through the filters, then they end up in + the MessageReceived() methods. + + The example shows a very common way to handle message. Usually, this + involves parsing the BMessage::what constant and then perform an action + based on that. + +\code +void +ShowImageApp::MessageReceived(BMessage *message) +{ + switch (message->what) { + case MSG_FILE_OPEN: + fOpenPanel->Show(); + break; + + case B_CANCEL: + // File open panel was closed, + // start checking count of open windows. + StartPulse(); + break; + + default: + // We do not handle this message, pass it on to the base class. + BApplication::MessageReceived(message); + break; + } +} +\endcode + + If your handler cannot process this message, you should pass it on to the + base class. Eventually, it will reach the default implementation, which + will reply with a \c B_MESSAGE_NOT_UNDERSTOOD constant. + + \warning Do not delete or otherwise cripple the \a message argument. It + does not belong to you. + + \param message The message that needs to be handled. +*/ + + +/*! + \fn BLooper *BHandler::Looper() const + \brief Return a pointer to the looper that this handler is associated with. + + \return If the handler is not yet associated with a looper, it will return + \c NULL. + \see BLooper::AddHandler() + \see LockLooper() +*/ + + +/*! + \fn void BHandler::SetName(const char *name) + \brief Set or change the name of this handler. + \see Name() +*/ + + +/*! + \fn const char *BHandler::Name() const + \brief Return the name of this handler. + \see SetName() +*/ + + +/*! + \fn void BHandler::SetNextHandler(BHandler *handler) + \brief Set the next handler in the chain that the message is passed on to + if this handler cannot process it. + + This method has three requirements: + -# This handler should belong to a looper. + -# The looper needs to be locked. See LockLooper(). + -# The \a handler that you pass must be associated with the same looper. + + Failure to meet any of these requirements will result in your application + crashing. + + By default, the handlers are chained in order that they were associated to + a looper with BLooper::AddHander(). + + \see NextHandler() +*/ + + +/*! + \fn BHandler *BHandler::NextHandler() const + \brief Return the next hander in the chain to which the message is passed + on. + \see SetNextHandler() +*/ + + +//! @} + + +///// Message Filtering ///// + + +/*! + \name Message Filtering +*/ + + +//! @{ + + +/*! + \fn void BHandler::AddFilter(BMessageFilter *filter) + \brief Add a filter as a prerequisite to this handler. + + If the handler is associated with a looper, this looper needs to be locked + in order for this operation to succeed. + + Note that the filter is not copied, rather a pointer to the filter is + stored. As such, you need to make sure that the filter object exists as + long as it is added to this handler. + + \see RemoveFilter(), SetFilterList() +*/ + + +/*! + \fn bool BHandler::RemoveFilter(BMessageFilter *filter) + \brief Remove a filter from the filter list. + + If the handler is associated with a looper, this looper needs to be locked + in order for this operation to succeed. + + Note that the filter is not deleted, merely removed from the list. You need + to take care of the memory yourself. + + \retval true The filter was in the filter list and is removed. + \retval false The filter was not found in the filter list. + + \see AddFilter(), FilterList() +*/ + + +/*! + \fn void BHandler::SetFilterList(BList* filters) + \brief Set the internal list of filters to \a filters. + + If the handler is associated with a looper, this looper needs to be locked + in order for this operation to succeed. + + The internal list will be replaced with the new list of \a filters. All the + existing filters will be \b deleted. + + \see AddFilter(), FilterList() +*/ + + +/*! + \fn BList *BHandler::FilterList() + \brief Return a pointer to the list of filters. + + \return A pointer to the list of filters. Do not manipulate the list of + filters directly, but use the methods provided by this class, in order + to maintain internal consistency. + + \see AddFilter(), RemoveFilter(), SetFilterList(). +*/ + + +//! @} + + +///// Locking ///// + + +/*! + \name Locking + + This class provides some utility functions to look the looper associated + with this handler. +*/ + + +//! @{ + + +/*! + \fn bool BHandler::LockLooper() + \brief Lock the looper associated with this handler. + + \retval true The looper is locked. + \retval false There was an error acquiring the lock. + + \see LockLooperWithTimeout(), UnlockLooper() +*/ + + +/*! + \fn status_t BHandler::LockLooperWithTimeout(bigtime_t timeout) + \brief Lock the looper associated with this handler, with a time out value. + + \param timeout The time to wait for acquiring the lock in microseconds. You + may also use B_INFINITE_TIMEOUT, in which this method will wait as long + as it takes to acquire the lock. + + \retval B_OK Locking succeeded. + \retval B_BAD_VALUE This handler is not associated with a looper (anymore). + \retval B_TIMED_OUT The time specified in \a timeout has passed without + locking the looper. + + \see LockLooper(), UnlockLooper() +*/ + + +/*! + \fn void BHandler::UnlockLooper() + \brief Unlock the looper. +*/ + + +//! @} + + +///// Scripting ////// + + +/*! + \name Scripting +*/ + + +//! @{ + + +/*! + \fn BHandler * BHandler::ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, const char *property) + \brief Undocumented. +*/ + + +/*! + \fn status_t BHandler::GetSupportedSuites(BMessage *data) + \brief Undocumented. +*/ + + +//! @} + + +///// Observing ///// + + +/*! + \name Observing + + Handlers can function as state machines, which emit messages to observers + when the state changes. Use the following methods to subscribe to these + notifications. +*/ + + +//! @{ + + +/*! + \fn status_t BHandler::StartWatching(BMessenger target, uint32 what) + \brief Subscribe a \a target to watch a specific state change. + + Use this method to subscribe messengers. This means that also observers + from other teams can be subscribed. + + \param target The messenger to which notifications need to be send. + \param what The state that needs to be watched. + \return During the call of this method, a notification will be transmitted + using the \a target. If this works, then this method will return + \c B_OK. + \see StartWatchingAll(BMessenger), StopWatching(BMessenger, uint32) +*/ + + +/*! + \fn status_t BHandler::StartWatchingAll(BMessenger target) + \brief Subscribe a \a target to all events. + + This method performs the same task as StartWatching(BMessenger, uint32), + but it will subscribe the target to all the state changes this handler + knows. + \see StartWatching(BMessenger, uint32), StopWatchingAll(BMessenger) +*/ + + +/*! + \fn status_t BHandler::StopWatching(BMessenger target, uint32 what) + \brief Unsubscribe an observer from watching a specific state. + + This method will unsubscribe the \a target from watching a specific event. + + \see StartWatching(BMessenger, uint32) +*/ + + +/*! + \fn status_t BHandler::StopWatchingAll(BMessenger target) + \brief Unsubscribe an observer from watching all states. + + This method will unsubscribe the \a target from watching all state changes. + + \see StartWatchingAll(BMessenger) +*/ + + +/*! + \fn status_t BHandler::StartWatching(BHandler* handler, uint32 what) + \brief Subscribe another \a handler to watch a specific state change. + + Use this method to subscribe handlers. Since pointers to handlers can only + exist in the local namespace, have a look at + StartWatching(BMessenger, uint32) for inter-team watching. + + \param handler The handler to which notifications need to be send. + \param what The state that needs to be watched. + \return During the call of this method, a notification will be transmitted + using the \a handler. If this works, then this method will return + \c B_OK. + + \see StartWatchingAll(BHandler), StopWatching(BHandler, uint32) +*/ + + +/*! + \fn status_t BHandler::StartWatchingAll(BHandler* handler) + \brief Subscribe another \a handler to watch all state changes. + + + This method performs the same task as StartWatching(BHandler, uint32), + but it will subscribe the target to all the state changes this handler + knows. + \see StartWatching(BHandler, uint32), StopWatchingAll(BHandler) +*/ + + +/*! + \fn status_t BHandler::StopWatching(BHandler* handler, uint32 what) + \brief Unsubscribe an observer from watching a specific state. + + This method will unsubscribe the \a handler from watching a specific event. + + \see StartWatching(BHandler, uint32) +*/ + + +/*! + \fn status_t BHandler::StopWatchingAll(BHandler* handler) + \brief Unsubscribe an observer from watching all states. + + This method will unsubscribe the \a handler from watching all state changes. + + \see StartWatchingAll(BHandler) +*/ + + +//! @} + + +///// State changes ///// + + +/*! + \name Emitting State Changes + If your handler functions as a state machine, and it has observers (which + subscribed using the StartWatching() method), you can emit these state + changes. +*/ + + +//! @{ + + +/*! + \fn void BHandler::SendNotices(uint32 what, const BMessage *msg) + \brief Emit a state change to the observers. + + The actual state (specified by \a what) will not be transmitted. This is + merely for internal bookkeeping. It is not entirely unimaginable that you + still want to inform the observers of what actually took place. You can + use the \a msg to transmit this, and any other data you want. Note that the + message will be copied and slightly altered: the \c what member of the + message will be \c B_OBSERVER_NOTICE_CHANGE, and the \c what constant you + specified will be stored in the #B_OBSERVE_ORIGINAL_WHAT label. + + \param what The identifier of the state. + \param msg Any data associated with the state change. You retain ownership + of this data, so make sure you dispose it when you are done. +*/ + + +/*! + \fn bool BHandler::IsWatched() const + \brief Check if there are any observers watching this handler. +*/ + + +//! @} + From nielx at mail.berlios.de Thu Dec 27 14:19:46 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Thu, 27 Dec 2007 14:19:46 +0100 Subject: [Haiku-commits] r23169 - haiku/trunk/docs/user/app Message-ID: <200712271319.lBRDJkGp017339@sheep.berlios.de> Author: nielx Date: 2007-12-27 14:19:45 +0100 (Thu, 27 Dec 2007) New Revision: 23169 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23169&view=rev Modified: haiku/trunk/docs/user/app/Handler.dox Log: Small typo Modified: haiku/trunk/docs/user/app/Handler.dox =================================================================== --- haiku/trunk/docs/user/app/Handler.dox 2007-12-27 13:17:20 UTC (rev 23168) +++ haiku/trunk/docs/user/app/Handler.dox 2007-12-27 13:19:45 UTC (rev 23169) @@ -7,7 +7,7 @@ * * Corresponds to: * /trunk/headers/os/app/Handler.h rev 22577 - * /trunk/src/kits/app/Message.cpp rev 21332 + * /trunk/src/kits/app/Handler.cpp rev 21332 */ /*! From nielx at mail.berlios.de Thu Dec 27 14:30:30 2007 From: nielx at mail.berlios.de (nielx at BerliOS) Date: Thu, 27 Dec 2007 14:30:30 +0100 Subject: [Haiku-commits] r23170 - haiku/trunk/docs/user/app Message-ID: <200712271330.lBRDUU6O017905@sheep.berlios.de> Author: nielx Date: 2007-12-27 14:30:30 +0100 (Thu, 27 Dec 2007) New Revision: 23170 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23170&view=rev Modified: haiku/trunk/docs/user/app/Message.dox Log: Add a note about using messages for data storage. Thanks to mlotz for telling me this functionality was underexposed in the current docs. Modified: haiku/trunk/docs/user/app/Message.dox =================================================================== --- haiku/trunk/docs/user/app/Message.dox 2007-12-27 13:19:45 UTC (rev 23169) +++ haiku/trunk/docs/user/app/Message.dox 2007-12-27 13:30:30 UTC (rev 23170) @@ -95,17 +95,24 @@ This class is at the center of the web of messaging classes, in the sense that it defines the actual structure of the messages. Messages have two - important elements: the #what identifer, and the data members. The first - can be directly manipulated, the latter can be manipulated through + important elements: the #what identifer, and the data members. The + first can be directly manipulated, the latter can be manipulated through AddData(), FindData() and ReplaceData() and their deratives. Neither of these elements are mandatory. - The second important role of BMessage is that it stores meta data: who sent - the message and with what intention? The methods of BMessage will disclose - if the message was a reply (IsReply()), where it came from + The second important role of BMessage is that it stores meta data: + who sent the message and with what intention? The methods of BMessage will + disclose if the message was a reply (IsReply()), where it came from (IsSourceRemote()), whether a reply is expected (IsSourceWaiting()), and in case the message is a reply, what it's a reply to (Previous()). + Mostly, messages are used to pass information between the the objects in + your application, but because messages are such flexible data containers, + they are also often used for other data storage purposes. Many + applications store their settings as messages. Because messages can be + flattened to data streams (such as files), they provide an easy but + powerful tool for data storage. + All methods can be classified in these areas: - Adding, Finding, Replacing and Removing Data. - Statistics and Miscelanous information. From revol at free.fr Thu Dec 27 15:04:23 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 27 Dec 2007 15:04:23 +0100 CET Subject: [Haiku-commits] r23160 - haiku/trunk/src/apps/bsnow In-Reply-To: <20071226163104.400.1@knochen-vm.nameserver> Message-ID: <224603023-BeMail@laptop> > > +#ifdef B_UPDATE_INVALIDATED > > + p->SetDoubleBuffering(p->DoubleBuffering() | > > B_UPDATE_EXPOSED); > > +#endif > > B_UPDATE_INVALIDATED is an enum element. Oops, right ;) Fran?ois. From revol at free.fr Thu Dec 27 15:10:58 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Thu, 27 Dec 2007 15:10:58 +0100 CET Subject: [Haiku-commits] =?windows-1252?q?r23154_-_in_haiku/trunk=3A_heade?= =?windows-1252?q?rs/os/interface_src/kits/interface_src/servers/app?= In-Reply-To: <894b9700712261337q4f56f6aavd831e157e0542a82@mail.gmail.com> Message-ID: <619508294-BeMail@laptop> > 2007/12/26, Fran?ois Revol : > > > With these changes, support for B_DRAW_ON_CHILDREN and > > > the DrawAfterChildren() > > > hook are implemented and behave exactly as on R5 as far as I can > > > tell, also > > > for the view background painting. > > > > Oh, that will certainly help BSnow, thx ;) > > > > Is it supposed to cover the desktop only partially or it's a bug of > BShelf ? It's certainly a bug somewhere. From ingo_weinhold at gmx.de Thu Dec 27 15:16:18 2007 From: ingo_weinhold at gmx.de (Ingo Weinhold) Date: Thu, 27 Dec 2007 15:16:18 +0100 Subject: [Haiku-commits] r23163 - haiku/trunk/src/apps/bsnow In-Reply-To: <200712262146.lBQLkHSC004771@sheep.berlios.de> References: <200712262146.lBQLkHSC004771@sheep.berlios.de> Message-ID: <20071227151618.504.1@knochen-vm.nameserver> On 2007-12-26 at 22:46:17 [+0100], mmu_man at BerliOS wrote: > Author: mmu_man > Date: 2007-12-26 22:46:11 +0100 (Wed, 26 Dec 2007) > New Revision: 23163 > ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23163&view=rev > > Modified: > haiku/trunk/src/apps/bsnow/SnowView.cpp > Log: > Don't ifdef on an enum. > > > Modified: haiku/trunk/src/apps/bsnow/SnowView.cpp > =================================================================== > --- haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 15:26:38 UTC (rev > 23162) > +++ haiku/trunk/src/apps/bsnow/SnowView.cpp 2007-12-26 21:46:11 UTC (rev > 23163) > @@ -140,7 +140,7 @@ > fDragger->SetViewColor(col); > if (fDragger->InShelf()) { > p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN); > -#ifdef B_UPDATE_INVALIDATED > +#ifdef B_BEOS_VERSION_DANO > p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED); > #endif AFAIK, the correct check is #if defined(B_BEOS_VERSION_DANO) && B_BEOS_VERSION >= B_BEOS_VERSION_DANO although B_BEOS_VERSION_DANO is likely only defined on post Dan0 machines. CU, Ingo From axeld at mail.berlios.de Thu Dec 27 17:56:29 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 27 Dec 2007 17:56:29 +0100 Subject: [Haiku-commits] r23171 - haiku/trunk/src/system/boot/loader Message-ID: <200712271656.lBRGuTka002243@sheep.berlios.de> Author: axeld Date: 2007-12-27 17:56:28 +0100 (Thu, 27 Dec 2007) New Revision: 23171 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23171&view=rev Modified: haiku/trunk/src/system/boot/loader/heap.cpp Log: * If DEBUG_ALLOCATIONS is defined, freed memory is now filled with 0xcc, and it's checked if a chunk is already in the free list, and if any chunk has an invalid size. It's defined for now. * Minor cleanup. Modified: haiku/trunk/src/system/boot/loader/heap.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/heap.cpp 2007-12-27 13:30:30 UTC (rev 23170) +++ haiku/trunk/src/system/boot/loader/heap.cpp 2007-12-27 16:56:28 UTC (rev 23171) @@ -1,7 +1,7 @@ -/* -** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2003-2007, Axel D?rfler, axeld at pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include @@ -31,6 +31,8 @@ * size 0 that can't be allocated. */ +#define DEBUG_ALLOCATIONS + // if defined, freed memory is filled with 0xcc struct free_chunk { uint32 size; @@ -53,10 +55,9 @@ static free_chunk sFreeAnchor; -/** Returns the amount of bytes that can be allocated - * in this chunk. - */ - +/*! Returns the amount of bytes that can be allocated + in this chunk. +*/ uint32 free_chunk::Size() const { @@ -64,10 +65,9 @@ } -/** Splits the upper half at the requested location - * and returns it. - */ - +/*! Splits the upper half at the requested location + and returns it. +*/ free_chunk * free_chunk::Split(uint32 splitSize) { @@ -81,10 +81,9 @@ } -/** Checks if the specified chunk touches this chunk, so - * that they could be joined. - */ - +/*! Checks if the specified chunk touches this chunk, so + that they could be joined. +*/ bool free_chunk::IsTouching(free_chunk *chunk) { @@ -94,14 +93,13 @@ } -/** Joins the chunk to this chunk and returns the pointer - * to the new chunk - which will either be one of the - * two chunks. - * Note, the chunks must be joinable, or else this method - * doesn't work correctly. Use free_chunk::IsTouching() - * to check if this method can be applied. - */ - +/*! Joins the chunk to this chunk and returns the pointer + to the new chunk - which will either be one of the + two chunks. + Note, the chunks must be joinable, or else this method + doesn't work correctly. Use free_chunk::IsTouching() + to check if this method can be applied. +*/ free_chunk * free_chunk::Join(free_chunk *chunk) { @@ -151,6 +149,10 @@ this->next = chunk; last->next = this; + +#ifdef DEBUG_ALLOCATIONS + memset((uint8*)this + sizeof(free_chunk), 0xcc, this->size - sizeof(free_chunk)); +#endif } @@ -322,6 +324,20 @@ return; free_chunk *freedChunk = free_chunk::SetToAllocated(allocated); + +#ifdef DEBUG_ALLOCATIONS + if (freedChunk->size > 65536) + panic("freed chunk %p clobbered (%lx)!\n", freedChunk, freedChunk->size); +{ + free_chunk *chunk = sFreeAnchor.next; + while (chunk) { + if (chunk->size > 65536 || freedChunk == chunk) + panic("invalid chunk in free list, or double free\n"); + chunk = chunk->next; + } +} +#endif + sAvailable += freedChunk->size; // try to join the new free chunk with an existing one From marcusoverhagen at arcor.de Thu Dec 27 19:00:42 2007 From: marcusoverhagen at arcor.de (Marcus Overhagen) Date: Thu, 27 Dec 2007 19:00:42 +0100 (CET) Subject: [Haiku-commits] r23171 - haiku/trunk/src/system/boot/loader In-Reply-To: <200712271656.lBRGuTka002243@sheep.berlios.de> References: <200712271656.lBRGuTka002243@sheep.berlios.de> Message-ID: <8751629.1198778442330.JavaMail.ngmail@webmail18> axeld at BerliOS wrote: > * If DEBUG_ALLOCATIONS is defined, freed memory is now filled with 0xcc, Thats nice, although I think we don't a a IDT installed, so any access using invalid pointers will trigger a triple fault and reboot. regards Marcus 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 29,95 Euro inkl. DSL- und ISDN-Grundgeb?hr! http://www.arcor.de/rd/emf-dsl-2 From axeld at mail.berlios.de Thu Dec 27 19:20:34 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 27 Dec 2007 19:20:34 +0100 Subject: [Haiku-commits] r23172 - haiku/trunk/src/system/boot/loader Message-ID: <200712271820.lBRIKY5a021958@sheep.berlios.de> Author: axeld Date: 2007-12-27 19:20:33 +0100 (Thu, 27 Dec 2007) New Revision: 23172 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23172&view=rev Modified: haiku/trunk/src/system/boot/loader/partitions.cpp Log: * Moved code to remove the parent to the Partition destructor - this should fix the problem that the parent partition was still referenced in some cases. * Minor cleanup. Modified: haiku/trunk/src/system/boot/loader/partitions.cpp =================================================================== --- haiku/trunk/src/system/boot/loader/partitions.cpp 2007-12-27 16:56:28 UTC (rev 23171) +++ haiku/trunk/src/system/boot/loader/partitions.cpp 2007-12-27 18:20:33 UTC (rev 23172) @@ -44,7 +44,8 @@ &gApplePartitionModule, #endif }; -static const int32 sNumPartitionModules = sizeof(sPartitionModules) / sizeof(partition_module_info *); +static const int32 sNumPartitionModules = sizeof(sPartitionModules) + / sizeof(partition_module_info *); /* supported file system modules */ @@ -65,17 +66,17 @@ &gTarFileSystemModule, #endif }; -static const int32 sNumFileSystemModules = sizeof(sFileSystemModules) / sizeof(file_system_module_info *); +static const int32 sNumFileSystemModules = sizeof(sFileSystemModules) + / sizeof(file_system_module_info *); extern NodeList gPartitions; namespace boot { -/** A convenience class to automatically close a - * file descriptor upon deconstruction. - */ - +/*! A convenience class to automatically close a + file descriptor upon deconstruction. +*/ class NodeOpener { public: NodeOpener(Node *node, int mode) @@ -117,6 +118,17 @@ Partition::~Partition() { TRACE(("%p Partition::~Partition\n", this)); + + // Tell the children that their parent is gone + + NodeIterator iterator = gPartitions.GetIterator(); + Partition *child; + + while ((child = (Partition *)iterator.Next()) != NULL) { + if (child->Parent() == this) + child->SetParent(NULL); + } + close(fFD); } @@ -132,7 +144,7 @@ Partition * Partition::Parent() const { - TRACE(("%p Partition::Parent is %p\n", this, fParent)); + //TRACE(("%p Partition::Parent is %p\n", this, fParent)); return fParent; } @@ -153,7 +165,8 @@ ssize_t -Partition::WriteAt(void *cookie, off_t position, const void *buffer, size_t bufferSize) +Partition::WriteAt(void *cookie, off_t position, const void *buffer, + size_t bufferSize) { if (position > this->size) return 0; @@ -250,7 +263,7 @@ Partition::Scan(bool mountFileSystems, bool isBootDevice) { // scan for partitions first (recursively all eventual children as well) - + TRACE(("%p Partition::Scan()\n", this)); // if we were not booted from the real boot device, we won't scan @@ -277,6 +290,7 @@ if (priority < 0.0) continue; + TRACE((" priority: %ld\n", (int32)(priority * 1000))); if (priority <= bestPriority) { // the disk system recognized the partition worse than the currently // best one @@ -292,7 +306,6 @@ bestPriority = priority; } - // find the best FS module const file_system_module_info *bestFSModule = NULL; float bestFSPriority = -1; @@ -335,13 +348,15 @@ Partition *child = NULL; while ((child = (Partition *)iterator.Next()) != NULL) { - TRACE(("%p Partition::Scan: *** scan child %p (start = %Ld, size = %Ld, parent = %p)!\n", - this, child, child->offset, child->size, child->Parent())); + TRACE(("%p Partition::Scan: *** scan child %p (start = %Ld, size " + "= %Ld, parent = %p)!\n", this, child, child->offset, + child->size, child->Parent())); child->Scan(mountFileSystems); if (!mountFileSystems || child->IsFileSystem()) { - // move the partitions containing file systems to the partition list + // move the partitions containing file systems to the partition + // list fChildren.Remove(child); gPartitions.Add(child); } @@ -377,15 +392,15 @@ // #pragma mark - -/** Scans the device passed in for partitioning systems. If none are found, - * a partition containing the whole device is created. - * All created partitions are added to the gPartitions list. - */ - +/*! Scans the device passed in for partitioning systems. If none are found, + a partition containing the whole device is created. + All created partitions are added to the gPartitions list. +*/ status_t add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice) { - TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd, mountFileSystems ? "yes" : "no")); + TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd, + mountFileSystems ? "yes" : "no")); Partition *partition = new Partition(fd); @@ -395,22 +410,14 @@ // add this partition to the list of partitions, if it contains // or might contain a file system - if ((partition->Scan(mountFileSystems, isBootDevice) == B_OK && partition->IsFileSystem()) + if ((partition->Scan(mountFileSystems, isBootDevice) == B_OK + && partition->IsFileSystem()) || (!partition->IsPartitioningSystem() && !mountFileSystems)) { gPartitions.Add(partition); return B_OK; } - // if not, we'll need to tell the children that their parent is gone - - NodeIterator iterator = gPartitions.GetIterator(); - Partition *child = NULL; - - while ((child = (Partition *)iterator.Next()) != NULL) { - if (child->Parent() == partition) - child->SetParent(NULL); - } - + // if not, we no longer need the partition delete partition; return B_OK; } @@ -419,7 +426,8 @@ status_t add_partitions_for(Node *device, bool mountFileSystems, bool isBootDevice) { - TRACE(("add_partitions_for(%p, mountFS = %s)\n", device, mountFileSystems ? "yes" : "no")); + TRACE(("add_partitions_for(%p, mountFS = %s)\n", device, + mountFileSystems ? "yes" : "no")); int fd = open_node(device, O_RDONLY); if (fd < B_OK) From mmu_man at mail.berlios.de Thu Dec 27 22:11:55 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 27 Dec 2007 22:11:55 +0100 Subject: [Haiku-commits] r23173 - haiku/trunk/src/apps/aboutsystem Message-ID: <200712272111.lBRLBttc002792@sheep.berlios.de> Author: mmu_man Date: 2007-12-27 22:11:55 +0100 (Thu, 27 Dec 2007) New Revision: 23173 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23173&view=rev Modified: haiku/trunk/src/apps/aboutsystem/Jamfile Log: make it buildable under R5/dano. Modified: haiku/trunk/src/apps/aboutsystem/Jamfile =================================================================== --- haiku/trunk/src/apps/aboutsystem/Jamfile 2007-12-27 18:20:33 UTC (rev 23172) +++ haiku/trunk/src/apps/aboutsystem/Jamfile 2007-12-27 21:11:55 UTC (rev 23173) @@ -2,9 +2,17 @@ UsePrivateHeaders shared ; +SetSubDirSupportedPlatformsBeOSCompatible ; + +if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { + UseHeaders [ FDirName $(HAIKU_TOP) headers os kernel ] : true ; +} if $(TARGET_PLATFORM) = r5 { SubDirC++Flags -DR5_COMPATIBLE ; } +if $(TARGET_PLATFORM) = dano { + SubDirC++Flags -DR5_COMPATIBLE ; +} Application AboutSystem : AboutSystem.cpp From mmu_man at mail.berlios.de Thu Dec 27 22:50:33 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Thu, 27 Dec 2007 22:50:33 +0100 Subject: [Haiku-commits] r23174 - haiku/trunk/src/apps/aboutsystem Message-ID: <200712272150.lBRLoXDe005148@sheep.berlios.de> Author: mmu_man Date: 2007-12-27 22:50:32 +0100 (Thu, 27 Dec 2007) New Revision: 23174 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23174&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Clean up and factor out adding the copyrights. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-27 21:11:55 UTC (rev 23173) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-27 21:50:32 UTC (rev 23174) @@ -41,7 +41,13 @@ static const char *UptimeToString(char string[], size_t size); static const char *MemUsageToString(char string[], size_t size); +static const rgb_color kDarkGrey = { 100, 100, 100, 255 }; +static const rgb_color kHaikuGreen = { 42, 131, 36, 255 }; +static const rgb_color kHaikuOrange = { 255, 69, 0, 255 }; +static const rgb_color kHaikuYellow = { 255, 176, 0, 255 }; +static const rgb_color kLinkBlue = { 80, 80, 200, 255 }; + class AboutApp : public BApplication { public: AboutApp(void); @@ -65,6 +71,8 @@ virtual void Draw(BRect update); virtual void MessageReceived(BMessage *msg); virtual void MouseDown(BPoint pt); + + void AddCopyrightEntry(const char *name, const char *text, const char *url=NULL); private: BStringView *fMemView; @@ -305,16 +313,10 @@ fCreditsView, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_PLAIN_BORDER); AddChild(creditsScroller); - rgb_color darkgrey = { 100, 100, 100, 255 }; - rgb_color haikuGreen = { 42, 131, 36, 255 }; - rgb_color haikuOrange = { 255, 69, 0, 255 }; - rgb_color haikuYellow = { 255, 176, 0, 255 }; - rgb_color linkBlue = { 80, 80, 200, 255 }; - BFont font(be_bold_font); font.SetSize(font.Size() + 4); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuGreen); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("Haiku\n"); font.SetSize(be_bold_font->Size()); @@ -328,16 +330,16 @@ snprintf(string, sizeof(string), "Copyright " B_UTF8_COPYRIGHT "2001-%ld Haiku, Inc.\n", year); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert(string); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); fCreditsView->Insert("http://haiku-os.org\n\n"); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuOrange); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert("Team Leads:\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Axel D?rfler\n" "Phil Greenway\n" @@ -348,10 +350,10 @@ "Jonathan Yoder\n" "\n"); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuOrange); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert("Developers:\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Ithamar R. Adema\n" "Stephan A?mus\n" @@ -370,10 +372,10 @@ "Siarzhuk Zharski\n" "\n"); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuOrange); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert("Contributors:\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Bruno G. Albuquerque\n" "Andrea Anzani\n" @@ -442,154 +444,131 @@ "\n" B_UTF8_ELLIPSIS " and probably some more we forgot to mention (sorry!)" "\n\n"); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuOrange); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert("Special Thanks To:\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert("Travis Geiselbrecht (and his NewOS kernel)\n"); fCreditsView->Insert("Michael Phipps (project founder)\n\n"); font.SetSize(be_bold_font->Size() + 4); font.SetFace(B_BOLD_FACE); - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuGreen); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("\nCopyrights\n\n"); font.SetSize(be_bold_font->Size()); font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + // copyrights for various projects we use + // GNU copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("The GNU Project\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert("Contains software from the GNU Project, " - "released under the GPL and LGPL licences:\n"); - fCreditsView->Insert(" - GNU C Library,\n"); - fCreditsView->Insert(" - GNU coretools, diffutils, findutils, gawk, bison, m4, make,\n"); - fCreditsView->Insert(" - Bourne Again Shell.\n"); - fCreditsView->Insert("Copyright " B_UTF8_COPYRIGHT " The Free Software Foundation.\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.gnu.org\n\n"); + AddCopyrightEntry("The GNU Project", + "Contains software from the GNU Project, " + "released under the GPL and LGPL licences:\n" + " - GNU C Library,\n" + " - GNU coretools, diffutils, findutils, gawk, bison, m4, make,\n" + " - Bourne Again Shell.\n" + "Copyright " B_UTF8_COPYRIGHT " The Free Software Foundation.", + "www.gnu.org"); // FFMpeg copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("FFMpeg libavcodec\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert("Copyright " B_UTF8_COPYRIGHT " 2000-2007 Fabrice Bellard, et al.\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.ffmpeg.org\n\n"); + AddCopyrightEntry("FFMpeg libavcodec", + "Copyright " B_UTF8_COPYRIGHT " 2000-2007 Fabrice Bellard, et al.", + "www.ffmpeg.org"); // AGG copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("AntiGrain Geometry\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert("Copyright " B_UTF8_COPYRIGHT " 2002-2006 Maxim Shemanarev (McSeem).\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.antigrain.com\n\n"); + AddCopyrightEntry("AntiGrain Geometry", + "Copyright " B_UTF8_COPYRIGHT " 2002-2006 Maxim Shemanarev (McSeem).", + "www.antigrain.com"); // PDFLib copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("PDFLib\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("PDFLib", "Copyright " B_UTF8_COPYRIGHT " 1997-2006 PDFlib GmbH and Thomas Merz. " "All rights reserved.\n" - "PDFlib and the PDFlib logo are registered trademarks of PDFlib GmbH.\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.pdflib.com\n\n"); + "PDFlib and the PDFlib logo are registered trademarks of PDFlib GmbH.", + "www.pdflib.com"); // FreeType copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("FreeType2\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert("Portions of this software are copyright " B_UTF8_COPYRIGHT " 1996-2006 The FreeType" - " Project. All rights reserved.\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.freetype.org\n\n"); + AddCopyrightEntry("FreeType2", + "Portions of this software are copyright " B_UTF8_COPYRIGHT " 1996-2006 The FreeType" + " Project. All rights reserved.", + "www.freetype.org"); // Mesa3D (http://www.mesa3d.org) copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("Mesa\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("Mesa", "Copyright " B_UTF8_COPYRIGHT " 1999-2006 Brian Paul. " - "Mesa3D project. All rights reserved.\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &linkBlue); - fCreditsView->Insert("www.mesa3d.org\n\n"); + "Mesa3D project. All rights reserved.", + "www.mesa3d.org"); // SGI's GLU implementation copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("GLU\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("GLU", "Copyright " B_UTF8_COPYRIGHT " 1991-2000 Silicon Graphics, Inc. " - "SGI's Software FreeB license. All rights reserved.\n\n"); + "SGI's Software FreeB license. All rights reserved."); // GLUT implementation copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("GLUT\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("GLUT", "Copyright " B_UTF8_COPYRIGHT " 1994-1997 Mark Kilgard. " "All rights reserved.\n" "Copyright " B_UTF8_COPYRIGHT " 1997 Be Inc.\n" - "Copyright " B_UTF8_COPYRIGHT " 1999 Jake Hamby. \n\n"); + "Copyright " B_UTF8_COPYRIGHT " 1999 Jake Hamby."); // OpenGroup & DEC (BRegion backend) copyright - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("BRegion backend (XFree86)\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("BRegion backend (XFree86)", "Copyright " B_UTF8_COPYRIGHT " 1987, 1988, 1998 The Open Group.\n" "Copyright " B_UTF8_COPYRIGHT " 1987, 1988 Digital Equipment Corporation, Maynard, Massachusetts.\n" - "All rights reserved.\n\n"); + "All rights reserved."); // Konatu font - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("Konatu font\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("Konatu font", "Copyright " B_UTF8_COPYRIGHT " 2002- MASUDA mitiya.\n" - "MIT license. All rights reserved.\n\n"); + "MIT license. All rights reserved."); // expat copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("expat\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( + AddCopyrightEntry("expat", "Copyright " B_UTF8_COPYRIGHT " 1998, 1999, 2000 Thai Open Source Software Center Ltd and Clark Cooper.\n" - "Copyright " B_UTF8_COPYRIGHT " 2001, 2002, 2003 Expat maintainers.\n\n"); + "Copyright " B_UTF8_COPYRIGHT " 2001, 2002, 2003 Expat maintainers."); // zlib copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("zlib\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( - "Copyright " B_UTF8_COPYRIGHT " 1995-2004 Jean-loup Gailly and Mark Adler.\n\n"); + AddCopyrightEntry("zlib", + "Copyright " B_UTF8_COPYRIGHT " 1995-2004 Jean-loup Gailly and Mark Adler."); // zip copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("Info-ZIP\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( - "Copyright " B_UTF8_COPYRIGHT " 1990-2002 Info-ZIP. All rights reserved.\n\n"); + AddCopyrightEntry("Info-ZIP", + "Copyright " B_UTF8_COPYRIGHT " 1990-2002 Info-ZIP. All rights reserved."); // bzip2 copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("bzip2\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( - "Copyright " B_UTF8_COPYRIGHT " 1996-2005 Julian R Seward. All rights reserved.\n\n"); + AddCopyrightEntry("bzip2", + "Copyright " B_UTF8_COPYRIGHT " 1996-2005 Julian R Seward. All rights reserved."); // VIM copyrights - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &haikuYellow); - fCreditsView->Insert("Vi IMproved\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &darkgrey); - fCreditsView->Insert( - "Copyright " B_UTF8_COPYRIGHT " Bram Moolenaar et al.\n\n"); + AddCopyrightEntry("Vi IMproved", + "Copyright " B_UTF8_COPYRIGHT " Bram Moolenaar et al."); } +void +AboutView::AddCopyrightEntry(const char *name, const char *text, const char *url) +{ + BFont font(be_bold_font); + //font.SetSize(be_bold_font->Size()); + font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuYellow); + fCreditsView->Insert(name); + fCreditsView->Insert("\n"); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); + fCreditsView->Insert(text); + fCreditsView->Insert("\n"); + if (url) { + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); + fCreditsView->Insert(url); + fCreditsView->Insert("\n"); + } + fCreditsView->Insert("\n"); +} + + AboutView::~AboutView(void) { delete fScrollRunner; From axeld at pinc-software.de Thu Dec 27 23:15:48 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Thu, 27 Dec 2007 23:15:48 +0100 CET Subject: [Haiku-commits] r23171 - haiku/trunk/src/system/boot/loader In-Reply-To: <8751629.1198778442330.JavaMail.ngmail@webmail18> Message-ID: <40116831404-BeMail@zon> Marcus Overhagen wrote: > axeld at BerliOS wrote: > > * If DEBUG_ALLOCATIONS is defined, freed memory is now filled with > > 0xcc, > Thats nice, although I think we don't a a IDT installed, so any > access using invalid > pointers will trigger a triple fault and reboot. Right, but at least it will now always fail, and as early as possible. Bye, Axel. From sbenedetto at mail.berlios.de Thu Dec 27 23:26:30 2007 From: sbenedetto at mail.berlios.de (sbenedetto at BerliOS) Date: Thu, 27 Dec 2007 23:26:30 +0100 Subject: [Haiku-commits] r23175 - haiku/trunk/src/add-ons/kernel/busses/usb Message-ID: <200712272226.lBRMQU0g006853@sheep.berlios.de> Author: sbenedetto Date: 2007-12-27 23:26:29 +0100 (Thu, 27 Dec 2007) New Revision: 23175 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23175&view=rev Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp Log: * Partially implemented interrupt handler routine Modified: haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp =================================================================== --- haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-12-27 21:50:32 UTC (rev 23174) +++ haiku/trunk/src/add-ons/kernel/busses/usb/ohci.cpp 2007-12-27 22:26:29 UTC (rev 23175) @@ -346,10 +346,62 @@ static spinlock lock = 0; acquire_spinlock(&lock); - int32 result = B_UNHANDLED_INTERRUPT; + uint32 status = 0; + uint32 acknowledge = 0; + bool finishTransfers = false; + int32 result = B_HANDLED_INTERRUPT; + // The LSb of done_head is used to inform the HCD that an interrupt + // condition exists for both the done list and for another event recorded in + // the HcInterruptStatus register. If done_head is 0, then the interrupt + // was caused by other than the HccaDoneHead update and the + // HcInterruptStatus register needs to be accessed to determine that exact + // interrupt cause. If HccDoneHead is nonzero, then a done list update + // interrupt is indicated and if the LSb of the Dword is nonzero, then an + // additional interrupt event is indicated and HcInterruptStatus shuold be + // checked to determine its cause. + uint32 doneHead = fHcca->done_head; + if (doneHead != 0) { + status = OHCI_WRITEBACK_DONE_HEAD; + if (doneHead & OHCI_DONE_INTERRUPTS) + status |= _ReadReg(OHCI_INTERRUPT_STATUS) + & _ReadReg(OHCI_INTERRUPT_ENABLE); + } else { + status = _ReadReg(OHCI_INTERRUPT_STATUS) & _ReadReg(OHCI_INTERRUPT_ENABLE) + & ~OHCI_WRITEBACK_DONE_HEAD; + if (status == 0) { + // Nothing to be done (PCI shared interrupt) + release_spinlock(&lock); + return B_UNHANDLED_INTERRUPT; + } + } + + if (status & OHCI_SCHEDULING_OVERRUN) { + // TODO + } + + if (status & OHCI_WRITEBACK_DONE_HEAD) { + // TODO + finishTransfers = true; + } + + if (status & OHCI_RESUME_DETECTED) { + // TODO + } + + if (status & OHCI_UNRECOVERABLE_ERROR) { + // TODO + } + + if (status & OHCI_ROOT_HUB_STATUS_CHANGE) { + // TODO + } + release_spinlock(&lock); + if (finishTransfers) + release_sem_etc(fFinishTransfersSem, 1, B_DO_NOT_RESCHEDULE); + return result; } @@ -368,6 +420,9 @@ while (!fStopFinishThread) { if (acquire_sem(fFinishTransfersSem) < B_OK) continue; + // We have to acknowledge here after we get the TD list + // fHcca->done_head = 0; + // Write back WDH bit in the interrupt status register } } @@ -491,9 +546,14 @@ _LinkDescriptors(setupDescriptor, statusDescriptor); } - // TODO // 1. Insert the chain descriptors to the endpoint + ohci_endpoint_descriptor *endpoint + = (ohci_endpoint_descriptor *)transfer->TransferPipe()->ControllerCookie(); + endpoint->tail_physical_descriptor = statusDescriptor->physical_address; + endpoint->head_physical_descriptor = setupDescriptor->physical_address; // 2. Clear the Skip bit in the enpoint + endpoint->flags &= ~OHCI_ENDPOINT_SKIP; + // 3. Tell the controller to process the control list _WriteReg(OHCI_COMMAND_STATUS, OHCI_CONTROL_LIST_FILLED); return B_OK; @@ -934,6 +994,7 @@ } Lock(); + pipe->SetControllerCookie((void *)endpoint); endpoint->next_logical_endpoint = head->next_logical_endpoint; endpoint->next_physical_endpoint = head->next_physical_endpoint; head->next_logical_endpoint = (void *)endpoint; From axeld at mail.berlios.de Thu Dec 27 23:56:45 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Thu, 27 Dec 2007 23:56:45 +0100 Subject: [Haiku-commits] r23176 - haiku/trunk/src/tests/system/boot/loader Message-ID: <200712272256.lBRMujZO008324@sheep.berlios.de> Author: axeld Date: 2007-12-27 23:56:44 +0100 (Thu, 27 Dec 2007) New Revision: 23176 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23176&view=rev Modified: haiku/trunk/src/tests/system/boot/loader/Jamfile Log: Fixed build. Modified: haiku/trunk/src/tests/system/boot/loader/Jamfile =================================================================== --- haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-12-27 22:26:29 UTC (rev 23175) +++ haiku/trunk/src/tests/system/boot/loader/Jamfile 2007-12-27 22:56:44 UTC (rev 23176) @@ -111,6 +111,7 @@ strlcat.c strlcpy.c driver_settings.c + KMessage.cpp : boottest_bfs.a boottest_amiga_ffs.a boottest_tarfs.a libz.a ; @@ -120,6 +121,9 @@ SEARCH on [ FGristFiles list.c ] = [ FDirName $(HAIKU_TOP) src system kernel util ] ; +SEARCH on [ FGristFiles KMessage.cpp ] + = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ; + SEARCH on [ FGristFiles strlcat.c strlcpy.c ] = [ FDirName $(HAIKU_TOP) src system libroot posix string ] ; From mmu_man at mail.berlios.de Fri Dec 28 01:05:28 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 28 Dec 2007 01:05:28 +0100 Subject: [Haiku-commits] r23177 - haiku/trunk/src/apps/aboutsystem Message-ID: <200712280005.lBS05SBV029993@sheep.berlios.de> Author: mmu_man Date: 2007-12-28 01:05:27 +0100 (Fri, 28 Dec 2007) New Revision: 23177 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23177&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Add a list of installed apps and their copyrights to the credits view, using a query. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-27 22:56:44 UTC (rev 23176) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-28 00:05:27 UTC (rev 23177) @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -36,6 +39,7 @@ #define SCROLL_CREDITS_VIEW 'mviv' +#define READ_APP_QUERY_ENT 'raqe' static const char *UptimeToString(char string[], size_t size); @@ -86,6 +90,7 @@ bigtime_t fLastActionTime; BMessageRunner *fScrollRunner; + BQuery fAppsQuery; }; @@ -107,7 +112,13 @@ : BWindow(BRect(0, 0, 500, 300), "About This System", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { - AddChild(new AboutView(Bounds())); + AboutView *view = new AboutView(Bounds()); + AddChild(view); + + // start reading from the app query + BMessage msg(READ_APP_QUERY_ENT); + BMessenger msgr(view); + msgr.SendMessage(&msg); MoveTo((BScreen().Frame().Width() - Bounds().Width()) / 2, (BScreen().Frame().Height() - Bounds().Height()) / 2 ); @@ -451,16 +462,13 @@ fCreditsView->Insert("Travis Geiselbrecht (and his NewOS kernel)\n"); fCreditsView->Insert("Michael Phipps (project founder)\n\n"); + // copyrights for various projects we use + font.SetSize(be_bold_font->Size() + 4); font.SetFace(B_BOLD_FACE); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("\nCopyrights\n\n"); - font.SetSize(be_bold_font->Size()); - font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); - - // copyrights for various projects we use - // GNU copyrights AddCopyrightEntry("The GNU Project", "Contains software from the GNU Project, " @@ -544,6 +552,22 @@ AddCopyrightEntry("Vi IMproved", "Copyright " B_UTF8_COPYRIGHT " Bram Moolenaar et al."); + // Build a list of installed applications and show their + // long version info. Well-behaved apps usually give + // copyright info there. + + font.SetSize(be_bold_font->Size() + 4); + font.SetFace(B_BOLD_FACE); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); + fCreditsView->Insert("\nInstalled applications\n\n"); + + BVolume bootVolume; + BVolumeRoster().GetBootVolume(&bootVolume); + fAppsQuery.SetVolume(&bootVolume); + if (fAppsQuery.SetPredicate("((BEOS:APP_SIG==\"**\")&&(name!=\"*.so\")&&(name!=\"*.rsrc\")&&" + "(BEOS:TYPE==\"application/x-vnd.Be-elfexecutable\"))") >= B_OK) { + fAppsQuery.Fetch(); + } } @@ -649,6 +673,59 @@ break; } + case READ_APP_QUERY_ENT: + { + BEntry ent; + if (fAppsQuery.GetNextEntry(&ent) < B_OK) { + fAppsQuery.Clear(); + break; + } + BFile file; + BPath path; + if (ent.Exists() && + ent.GetPath(&path) >= B_OK && + file.SetTo(&ent, B_READ_ONLY) >= B_OK) { + /* filter only apps */ + if (strncmp(path.Path(), "/boot/apps", 10) == 0) { + BAppFileInfo appFileInfo(&file); + uint32 flags; + version_info version; + if (appFileInfo.InitCheck() >= B_OK && + appFileInfo.GetAppFlags(&flags) >= B_OK && + appFileInfo.GetVersionInfo(&version, B_APP_VERSION_KIND) >= B_OK) { + //printf("AppFileInfo for %s :\n", path.Path()); + //printf("flags: %08x\n", flags); + BString name; + BString info; + name << path.Leaf(); + if (strlen(version.short_info) && + strcmp(version.short_info, path.Leaf())) + name << " (" << version.short_info << ")"; + /* + info << "\tVersion: "; + info << version.major << "."; + info << version.middle << "."; + info << version.minor; + char varieties[] = "dabgmf"; + if (version.variety > B_FINAL_VERSION) + info << "?"; + else + info << varieties[version.variety]; + info << version.internal; + info << "\n"; + */ + info << version.long_info; + AddCopyrightEntry(name.String(), info.String()); + + } + } + } + // note for self: read next entry :) + BMessage m(READ_APP_QUERY_ENT); + BMessenger(this).SendMessage(&m); + break; + } + default: BView::MessageReceived(msg); break; From mmu_man at mail.berlios.de Fri Dec 28 02:22:17 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 28 Dec 2007 02:22:17 +0100 Subject: [Haiku-commits] r23178 - haiku/trunk/src/apps/aboutsystem Message-ID: <200712280122.lBS1MHV9001969@sheep.berlios.de> Author: mmu_man Date: 2007-12-28 02:22:16 +0100 (Fri, 28 Dec 2007) New Revision: 23178 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23178&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Any reason not to use ui_color() there ?? Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-28 00:05:27 UTC (rev 23177) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-28 01:22:16 UTC (rev 23178) @@ -163,7 +163,9 @@ r.OffsetBy(0, fLogo->Bounds().Height()); fInfoView = new BView(r, "infoview", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW); - fInfoView->SetViewColor(235, 235, 235); + fInfoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + fInfoView->SetLowColor(fInfoView->ViewColor()); + fInfoView->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); AddChild(fInfoView); // Add all the various labels for system infomation From mmu_man at mail.berlios.de Fri Dec 28 03:42:53 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 28 Dec 2007 03:42:53 +0100 Subject: [Haiku-commits] r23179 - haiku/trunk/src/apps/aboutsystem Message-ID: <200712280242.lBS2gr7F010266@sheep.berlios.de> Author: mmu_man Date: 2007-12-28 03:42:53 +0100 (Fri, 28 Dec 2007) New Revision: 23179 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23179&view=rev Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp Log: Bored at 4 am, Into this cold winder, Here comes an easter egg. Modified: haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp =================================================================== --- haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-28 01:22:16 UTC (rev 23178) +++ haiku/trunk/src/apps/aboutsystem/AboutSystem.cpp 2007-12-28 02:42:53 UTC (rev 23179) @@ -77,6 +77,7 @@ virtual void MouseDown(BPoint pt); void AddCopyrightEntry(const char *name, const char *text, const char *url=NULL); + void PickRandomHaiku(); private: BStringView *fMemView; @@ -573,28 +574,6 @@ } -void -AboutView::AddCopyrightEntry(const char *name, const char *text, const char *url) -{ - BFont font(be_bold_font); - //font.SetSize(be_bold_font->Size()); - font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); - - fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuYellow); - fCreditsView->Insert(name); - fCreditsView->Insert("\n"); - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); - fCreditsView->Insert(text); - fCreditsView->Insert("\n"); - if (url) { - fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); - fCreditsView->Insert(url); - fCreditsView->Insert("\n"); - } - fCreditsView->Insert("\n"); -} - - AboutView::~AboutView(void) { delete fScrollRunner; @@ -614,8 +593,10 @@ AboutView::MouseDown(BPoint pt) { BRect r(92, 26, 105, 31); - if (r.Contains(pt)) + if (r.Contains(pt)) { printf("Easter Egg\n"); + PickRandomHaiku(); + } if (Bounds().Contains(pt)) { fLastActionTime = system_time(); @@ -735,6 +716,78 @@ } +void +AboutView::AddCopyrightEntry(const char *name, const char *text, const char *url) +{ + BFont font(be_bold_font); + //font.SetSize(be_bold_font->Size()); + font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuYellow); + fCreditsView->Insert(name); + fCreditsView->Insert("\n"); + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); + fCreditsView->Insert(text); + fCreditsView->Insert("\n"); + if (url) { + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); + fCreditsView->Insert(url); + fCreditsView->Insert("\n"); + } + fCreditsView->Insert("\n"); +} + +void +AboutView::PickRandomHaiku() +{ + BFile fortunes( +#ifdef __HAIKU__ + "/etc/fortunes/Haiku", +#else + "data/etc/fortunes/Haiku", +#endif + B_READ_ONLY); + struct stat st; + if (fortunes.InitCheck() < B_OK) + return; + if (fortunes.GetStat(&st) < B_OK) + return; + char *buff = (char *)malloc((size_t)st.st_size + 1); + if (!buff) + return; + buff[(size_t)st.st_size] = '\0'; + BList haikuList; + if (fortunes.Read(buff, (size_t)st.st_size) == (ssize_t)st.st_size) { + char *p = buff; + while (p && *p) { + char *e = strchr(p, '%'); + BString *s = new BString(p, e ? (e - p) : -1); + haikuList.AddItem(s); + p = e; + if (p && (*p == '%')) + p++; + if (p && (*p == '\n')) + p++; + } + } + free(buff); + if (haikuList.CountItems() < 1) + return; + BString *s = (BString *)haikuList.ItemAt(rand() % haikuList.CountItems()); + BFont font(be_bold_font); + font.SetSize(be_bold_font->Size()); + font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); + fCreditsView->SelectAll(); + fCreditsView->Delete(); + fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kDarkGrey); + fCreditsView->Insert(s->String()); + fCreditsView->Insert("\n"); + while ((s = (BString *)haikuList.RemoveItem((int32)0))) { + delete s; + } +} + + // #pragma mark - From jackburton at mail.berlios.de Fri Dec 28 09:20:39 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 28 Dec 2007 09:20:39 +0100 Subject: [Haiku-commits] r23180 - haiku/trunk/src/kits/interface Message-ID: <200712280820.lBS8KdQT008302@sheep.berlios.de> Author: jackburton Date: 2007-12-28 09:20:39 +0100 (Fri, 28 Dec 2007) New Revision: 23180 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23180&view=rev Modified: haiku/trunk/src/kits/interface/Shelf.cpp Log: Added a comment about the bug in BSnow Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 02:42:53 UTC (rev 23179) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 08:20:39 UTC (rev 23180) @@ -1178,7 +1178,7 @@ } else { // Replicant is parent of the dragger replicant = view; - dragger = dynamic_cast(replicant->FindView("_dragger_")); + dragger = dynamic_cast(replicant->FindView("_dragger_")); if (dragger) dragger->_SetViewToDrag(replicant); @@ -1217,7 +1217,8 @@ BPoint adjust = AdjustReplicantBy(frame, data); // TODO: that's probably not correct for all relations (or any?) - view->MoveTo(point + adjust); + // At least, commenting this line fixes a bug in BSnow + view->MoveTo(point + adjust); // if it's a sibling or a child, we need to add the dragger if (relation == BDragger::TARGET_IS_SIBLING From jackburton at mail.berlios.de Fri Dec 28 11:49:05 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 28 Dec 2007 11:49:05 +0100 Subject: [Haiku-commits] r23181 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200712281049.lBSAn5dB017886@sheep.berlios.de> Author: jackburton Date: 2007-12-28 11:49:04 +0100 (Fri, 28 Dec 2007) New Revision: 23181 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23181&view=rev Modified: haiku/trunk/headers/os/interface/Shelf.h haiku/trunk/src/kits/interface/Shelf.cpp Log: Split BShelf::_AddReplicant() functionality into smaller methods. Not yet done, but I hope it's getting better Modified: haiku/trunk/headers/os/interface/Shelf.h =================================================================== --- haiku/trunk/headers/os/interface/Shelf.h 2007-12-28 08:20:39 UTC (rev 23180) +++ haiku/trunk/headers/os/interface/Shelf.h 2007-12-28 10:49:04 UTC (rev 23181) @@ -6,6 +6,7 @@ #define _SHELF_H +#include #include #include @@ -13,6 +14,7 @@ class BPoint; class BView; class BEntry; +class _BZombieReplicantView_; struct entry_ref; namespace BPrivate { @@ -99,8 +101,11 @@ status_t _DeleteReplicant(BPrivate::replicant_data* replicant); status_t _AddReplicant(BMessage* data, BPoint* location, uint32 uniqueID); + _BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger); + status_t _GetProperty(BMessage* message, BMessage* reply); - + static void _GetReplicantData(BMessage *message, BView *view, BView *&replicant, + BDragger *&dragger, BDragger::relation &relation); static BArchivable* _InstantiateObject(BMessage *archive, image_id *image); private: Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 08:20:39 UTC (rev 23180) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 10:49:04 UTC (rev 23181) @@ -178,6 +178,25 @@ } +static bool +find_replicant(BList &list, const char *className, const char *addOn) +{ + int32 i = 0; + replicant_data *item; + while ((item = (replicant_data *)list.ItemAt(i++)) != NULL) { + const char *replicantClassName; + const char *replicantAddOn; + if (item->message->FindString("class", &replicantClassName) == B_OK + && item->message->FindString("add_on", &replicantAddOn) == B_OK + && !strcmp(className, replicantClassName) + && addOn != NULL && replicantAddOn != NULL + && !strcmp(addOn, replicantAddOn)) + return true; + } + return false; +} + + // #pragma mark - @@ -1105,7 +1124,7 @@ // Check if we can accept this message if (!CanAcceptReplicantMessage(data)) { - printf("Replicant was rejected by BShelf: CanAcceptReplicant() returned false"); + printf("Replicant was rejected by BShelf::CanAcceptReplicantMessage()"); return send_reply(data, B_ERROR, uniqueID); } @@ -1115,22 +1134,11 @@ const char *addOn = NULL; if (data->FindString("class", &className) == B_OK - && data->FindString("add_on", &addOn) == B_OK) { - int32 i = 0; - replicant_data *item; - const char *replicantClassName = NULL; - const char *replicantAddOn = NULL; - - while ((item = (replicant_data*)fReplicants.ItemAt(i++)) != NULL) { - if (item->message->FindString("class", &replicantClassName) == B_OK - && item->message->FindString("add_on", &replicantAddOn) == B_OK - && !strcmp(className, replicantClassName) - && addOn != NULL && replicantAddOn != NULL - && !strcmp(addOn, replicantAddOn)) { - printf("Replicant was rejected. Unique replicant already exists. class=%s, signature=%s", - replicantClassName, replicantAddOn); - return send_reply(data, B_ERROR, uniqueID); - } + && data->FindString("add_on", &addOn) == B_OK) { + if (find_replicant(fReplicants, className, addOn)) { + printf("Replicant was rejected. Unique replicant already exists. class=%s, signature=%s", + className, addOn); + return send_reply(data, B_ERROR, uniqueID); } } } @@ -1158,44 +1166,18 @@ // TODO: test me -- there seems to be lots of bugs parked here! - // Check if we have a dragger archived as "__widget" inside the message - BMessage widget; - if (data->FindMessage("__widget", &widget) == B_OK) { - image_id draggerImage = B_ERROR; - replicant = view; - dragger = dynamic_cast(_InstantiateObject(&widget, &draggerImage)); - if (dragger != NULL) { - // Replicant is either a sibling or unknown - dragger->_SetViewToDrag(replicant); - relation = BDragger::TARGET_IS_SIBLING; - } - } else { - // Replicant is child of the dragger - if ((dragger = dynamic_cast(view)) != NULL) { - replicant = dragger->ChildAt(0); - dragger->_SetViewToDrag(replicant); - relation = BDragger::TARGET_IS_CHILD; - } else { - // Replicant is parent of the dragger - replicant = view; - dragger = dynamic_cast(replicant->FindView("_dragger_")); + _GetReplicantData(data, view, replicant, dragger, relation); - if (dragger) - dragger->_SetViewToDrag(replicant); - - relation = BDragger::TARGET_IS_PARENT; - } - } - if (dragger != NULL) dragger->_SetShelf(this); BRect frame; - if (relation != BDragger::TARGET_IS_CHILD) { + if (relation == BDragger::TARGET_IS_CHILD) + frame = dragger->Frame().OffsetToCopy(point); + else { frame = replicant->Frame().OffsetToCopy(point); fContainerView->AddChild(replicant); - } else - frame = dragger->Frame().OffsetToCopy(point); + } if (!CanAcceptReplicantView(frame, replicant, data)) { // the view has not been accepted @@ -1205,6 +1187,7 @@ replicant->RemoveSelf(); delete replicant; } + if (relation == BDragger::TARGET_IS_CHILD || relation == BDragger::TARGET_IS_SIBLING) { dragger->RemoveSelf(); @@ -1226,34 +1209,10 @@ fContainerView->AddChild(dragger); replicant->AddFilter(new ReplicantViewFilter(this, replicant)); - } else if (fDisplayZombies && fAllowZombies) { - // TODO: the zombies must be adjusted and moved as well! - BRect frame; - if (data->FindRect("_frame", &frame) != B_OK) - frame = BRect(); + } else if (fDisplayZombies && fAllowZombies) + zombie = _CreateZombie(data, dragger); - if (data->WasDropped()) { - BPoint dropPoint, offset; - dropPoint = data->DropPoint(&offset); - - frame.OffsetTo(B_ORIGIN); - frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset); - - zombie = new _BZombieReplicantView_(frame, B_ERROR); - - frame.OffsetTo(B_ORIGIN); - - dragger = new BDragger(frame, zombie); - dragger->_SetShelf(this); - dragger->_SetZombied(true); - - zombie->AddChild(dragger); - zombie->SetArchive(data); - zombie->AddFilter(new ReplicantViewFilter(this, zombie)); - - fContainerView->AddChild(zombie); - } - } else if (!fAllowZombies) { + else if (!fAllowZombies) { // There was no view, and we're not allowed to have any zombies // in the house return send_reply(data, B_ERROR, uniqueID); @@ -1274,6 +1233,41 @@ } +_BZombieReplicantView_ * +BShelf::_CreateZombie(BMessage *data, BDragger *&dragger) +{ + // TODO: the zombies must be adjusted and moved as well! + BRect frame; + if (data->FindRect("_frame", &frame) != B_OK) + frame = BRect(); + + _BZombieReplicantView_ *zombie = NULL; + if (data->WasDropped()) { + BPoint dropPoint, offset; + dropPoint = data->DropPoint(&offset); + + frame.OffsetTo(B_ORIGIN); + frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset); + + zombie = new _BZombieReplicantView_(frame, B_ERROR); + + frame.OffsetTo(B_ORIGIN); + + dragger = new BDragger(frame, zombie); + dragger->_SetShelf(this); + dragger->_SetZombied(true); + + zombie->AddChild(dragger); + zombie->SetArchive(data); + zombie->AddFilter(new ReplicantViewFilter(this, zombie)); + + fContainerView->AddChild(zombie); + } + + return zombie; +} + + status_t BShelf::_GetProperty(BMessage *msg, BMessage *reply) { @@ -1344,6 +1338,42 @@ /* static */ +void +BShelf::_GetReplicantData(BMessage *data, BView *view, BView *&replicant, + BDragger *&dragger, BDragger::relation &relation) +{ + // Check if we have a dragger archived as "__widget" inside the message + BMessage widget; + if (data->FindMessage("__widget", &widget) == B_OK) { + image_id draggerImage = B_ERROR; + replicant = view; + dragger = dynamic_cast(_InstantiateObject(&widget, &draggerImage)); + if (dragger != NULL) { + // Replicant is either a sibling or unknown + dragger->_SetViewToDrag(replicant); + relation = BDragger::TARGET_IS_SIBLING; + } + } else { + // Replicant is child of the dragger + if ((dragger = dynamic_cast(view)) != NULL) { + replicant = dragger->ChildAt(0); + dragger->_SetViewToDrag(replicant); + relation = BDragger::TARGET_IS_CHILD; + } else { + // Replicant is parent of the dragger + replicant = view; + dragger = dynamic_cast(replicant->FindView("_dragger_")); + + if (dragger) + dragger->_SetViewToDrag(replicant); + + relation = BDragger::TARGET_IS_PARENT; + } + } +} + + +/* static */ BArchivable * BShelf::_InstantiateObject(BMessage *archive, image_id *image) { From jackburton at mail.berlios.de Fri Dec 28 12:07:29 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 28 Dec 2007 12:07:29 +0100 Subject: [Haiku-commits] r23182 - in haiku/trunk: headers/os/interface src/kits/interface Message-ID: <200712281107.lBSB7TDo021080@sheep.berlios.de> Author: jackburton Date: 2007-12-28 12:07:28 +0100 (Fri, 28 Dec 2007) New Revision: 23182 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23182&view=rev Modified: haiku/trunk/headers/os/interface/Shelf.h haiku/trunk/src/kits/interface/Shelf.cpp Log: Put the code to Extract a replicant into its own function. BShelf::_AddReplicant() is finally getting acceptable. Modified: haiku/trunk/headers/os/interface/Shelf.h =================================================================== --- haiku/trunk/headers/os/interface/Shelf.h 2007-12-28 10:49:04 UTC (rev 23181) +++ haiku/trunk/headers/os/interface/Shelf.h 2007-12-28 11:07:28 UTC (rev 23182) @@ -101,6 +101,8 @@ status_t _DeleteReplicant(BPrivate::replicant_data* replicant); status_t _AddReplicant(BMessage* data, BPoint* location, uint32 uniqueID); + BView *_GetReplicant(BMessage *data, BView *view, const BPoint &point, + BDragger *&dragger, BDragger::relation &relation); _BZombieReplicantView_ *_CreateZombie(BMessage *data, BDragger *&dragger); status_t _GetProperty(BMessage* message, BMessage* reply); Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 10:49:04 UTC (rev 23181) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 11:07:28 UTC (rev 23182) @@ -1142,11 +1142,6 @@ } } } - - BDragger* dragger = NULL; - BView* replicant = NULL; - BDragger::relation relation = BDragger::TARGET_UNKNOWN; - _BZombieReplicantView_* zombie = NULL; // Instantiate the object, if this fails we have a zombie image_id image; @@ -1157,58 +1152,16 @@ return send_reply(data, B_ERROR, uniqueID); } + BDragger* dragger = NULL; + BView* replicant = NULL; + BDragger::relation relation = BDragger::TARGET_UNKNOWN; + _BZombieReplicantView_* zombie = NULL; if (view != NULL) { - BPoint point; - if (location) - point = *location; - else - point = view->Frame().LeftTop(); + const BPoint point = location ? *location : view->Frame().LeftTop(); + replicant = _GetReplicant(data, view, point, dragger, relation); + if (replicant == NULL) + send_reply(data, B_ERROR, uniqueID); - // TODO: test me -- there seems to be lots of bugs parked here! - - _GetReplicantData(data, view, replicant, dragger, relation); - - if (dragger != NULL) - dragger->_SetShelf(this); - - BRect frame; - if (relation == BDragger::TARGET_IS_CHILD) - frame = dragger->Frame().OffsetToCopy(point); - else { - frame = replicant->Frame().OffsetToCopy(point); - fContainerView->AddChild(replicant); - } - - if (!CanAcceptReplicantView(frame, replicant, data)) { - // the view has not been accepted - - if (relation == BDragger::TARGET_IS_PARENT - || relation == BDragger::TARGET_IS_SIBLING) { - replicant->RemoveSelf(); - delete replicant; - } - - if (relation == BDragger::TARGET_IS_CHILD - || relation == BDragger::TARGET_IS_SIBLING) { - dragger->RemoveSelf(); - delete dragger; - } - - return send_reply(data, B_ERROR, uniqueID); - } - - BPoint adjust = AdjustReplicantBy(frame, data); - - // TODO: that's probably not correct for all relations (or any?) - // At least, commenting this line fixes a bug in BSnow - view->MoveTo(point + adjust); - - // if it's a sibling or a child, we need to add the dragger - if (relation == BDragger::TARGET_IS_SIBLING - || relation == BDragger::TARGET_IS_CHILD) - fContainerView->AddChild(dragger); - - replicant->AddFilter(new ReplicantViewFilter(this, replicant)); } else if (fDisplayZombies && fAllowZombies) zombie = _CreateZombie(data, dragger); @@ -1233,6 +1186,60 @@ } +BView * +BShelf::_GetReplicant(BMessage *data, BView *view, const BPoint &point, + BDragger *&dragger, BDragger::relation &relation) +{ + // TODO: test me -- there seems to be lots of bugs parked here! + BView *replicant = NULL; + _GetReplicantData(data, view, replicant, dragger, relation); + + if (dragger != NULL) + dragger->_SetShelf(this); + + BRect frame; + if (relation == BDragger::TARGET_IS_CHILD) + frame = dragger->Frame().OffsetToCopy(point); + else { + frame = replicant->Frame().OffsetToCopy(point); + fContainerView->AddChild(replicant); + } + + if (!CanAcceptReplicantView(frame, replicant, data)) { + // the view has not been accepted + + if (relation == BDragger::TARGET_IS_PARENT + || relation == BDragger::TARGET_IS_SIBLING) { + replicant->RemoveSelf(); + delete replicant; + } + + if (relation == BDragger::TARGET_IS_CHILD + || relation == BDragger::TARGET_IS_SIBLING) { + dragger->RemoveSelf(); + delete dragger; + } + + return NULL; + } + + BPoint adjust = AdjustReplicantBy(frame, data); + + // TODO: that's probably not correct for all relations (or any?) + // At least, commenting this line fixes a bug in BSnow + view->MoveTo(point + adjust); + + // if it's a sibling or a child, we need to add the dragger + if (relation == BDragger::TARGET_IS_SIBLING + || relation == BDragger::TARGET_IS_CHILD) + fContainerView->AddChild(dragger); + + replicant->AddFilter(new ReplicantViewFilter(this, replicant)); + + return replicant; +} + + _BZombieReplicantView_ * BShelf::_CreateZombie(BMessage *data, BDragger *&dragger) { From jackburton at mail.berlios.de Fri Dec 28 12:48:36 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 28 Dec 2007 12:48:36 +0100 Subject: [Haiku-commits] r23183 - haiku/trunk/src/kits/interface Message-ID: <200712281148.lBSBmaYS026480@sheep.berlios.de> Author: jackburton Date: 2007-12-28 12:48:35 +0100 (Fri, 28 Dec 2007) New Revision: 23183 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23183&view=rev Modified: haiku/trunk/src/kits/interface/Shelf.cpp Log: removed useless OffsetTo() Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 11:07:28 UTC (rev 23182) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 11:48:35 UTC (rev 23183) @@ -1250,10 +1250,9 @@ _BZombieReplicantView_ *zombie = NULL; if (data->WasDropped()) { - BPoint dropPoint, offset; - dropPoint = data->DropPoint(&offset); + BPoint offset; + BPoint dropPoint = data->DropPoint(&offset); - frame.OffsetTo(B_ORIGIN); frame.OffsetTo(fContainerView->ConvertFromScreen(dropPoint) - offset); zombie = new _BZombieReplicantView_(frame, B_ERROR); From mmu_man at mail.berlios.de Fri Dec 28 15:38:45 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Fri, 28 Dec 2007 15:38:45 +0100 Subject: [Haiku-commits] r23184 - in haiku/trunk/3rdparty: . onlinedemo Message-ID: <200712281438.lBSEcjAu018485@sheep.berlios.de> Author: mmu_man Date: 2007-12-28 15:38:45 +0100 (Fri, 28 Dec 2007) New Revision: 23184 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23184&view=rev Added: haiku/trunk/3rdparty/onlinedemo/ haiku/trunk/3rdparty/onlinedemo/haiku.php Log: The php script I wrote to demo Haiku online with a VNC applet... Not as slick as http://live.oszoo.org/ but does the job. Maybe we should consider submitting an image to oszoo... Added: haiku/trunk/3rdparty/onlinedemo/haiku.php =================================================================== --- haiku/trunk/3rdparty/onlinedemo/haiku.php 2007-12-28 11:48:35 UTC (rev 23183) +++ haiku/trunk/3rdparty/onlinedemo/haiku.php 2007-12-28 14:38:45 UTC (rev 23184) @@ -0,0 +1,235 @@ + 8bpp): +// on debian, apt-get install tightvnc-java will put them in +// /usr/share/tightvnc-java +define("VNCJAVA_PATH", "tightvnc-java"); +define("VNCJAR", "VncViewer.jar"); +define("VNCCLASS", "VncViewer.class"); + +// maximum count of qemu instances. +define("MAX_QEMUS", 8); + +// size of the java applet, must match the default resolution of the image. +define("APPLET_WIDTH", "800"); +define("APPLET_HEIGHT", "600"); +// vnc protocol base port. +define("VNCPORTBASE", 5900); + +// timeout before the demo session is killed, as argument to /bin/sleep +define("SESSION_TIMEOUT", "10m"); + +// path to qemu binary +define("QEMU_BIN", "/usr/bin/qemu"); +// default arguments: no network, emulate tablet, readonly image file. +define("QEMU_ARGS","-net none -usbdevice tablet -snapshot"); +// absolute path to the image. +define("QEMU_IMAGE_PATH","/home/revol/haiku/trunk/generated/haiku.image"); + +// name of session and pid files in /tmp +define("QEMU_SESSFILE_TMPL", "qemu-haiku-session-"); +define("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-"); +// name of session variable holding the qemu slot; not yet used correctly +define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR"); + +session_start(); + +if (isset($_GET['frame'])) { +} + +?> + + +Haiku Test + + +"; +} else + echo ""; + +function dbg($str) +{ + echo "
$str
\n"; +} + +function err($str) +{ + echo "
$str
\n"; +} + +function make_qemu_sessionfile_name($idx) +{ + return "/tmp/" . QEMU_SESSFILE_TMPL . $idx; +} + +function make_qemu_pidfile_name($idx) +{ + return "/tmp/" . QEMU_PIDFILE_TMPL . $idx; +} + +function find_qemu_slot() +{ + for ($idx = 0; $idx < MAX_QEMUS; $idx++) { + $pidfile = make_qemu_pidfile_name($idx); + $sessfile = make_qemu_sessionfile_name($idx); + dbg("checking \"$pidfile\", \"$sessfile\"..."); + if (!file_exists($pidfile) && !file_exists($sessfile)) { + file_put_contents($sessfile, session_id()); + $sid = file_get_contents($sessfile); + if ($sid != session_id()) + continue; + $_SESSION[QEMU_IDX_VAR] = $idx; + return $idx; + } + } + return -1; +} + +function qemu_slot() +{ + return $_SESSION[QEMU_IDX_VAR]; +} + +function vnc_display() +{ + return qemu_slot(); +} + +function vnc_port() +{ + return VNCPORTBASE + vnc_display(); +} + +function is_my_session_valid() +{ + if (!isset($_SESSION[QEMU_IDX_VAR])) + return 0; + $idx = $_SESSION[QEMU_IDX_VAR]; + $sessfile = make_qemu_sessionfile_name($idx); + if (!file_exists($sessfile)) + return 0; + $qemusession=file_get_contents($sessfile); + // has expired + if ($qemusession != session_id()) { + return 0; + } + return 1; +} + + +function start_qemu() +{ + $idx = find_qemu_slot(); + if ($idx < 0) { + err("No available qemu slot, please try later."); + return $idx; + } + $pidfile = make_qemu_pidfile_name($idx); + $cmd = QEMU_BIN . " " . QEMU_ARGS . " -vnc " . vnc_display() . " -pidfile " . $pidfile . " " . QEMU_IMAGE_PATH; + + if (file_exists($pidfile)) + unlink($pidfile); + dbg("Starting " . $cmd . "..."); + + $descriptorspec = array( + // 0 => array("pipe", "r"), // stdin + // 1 => array("pipe", "w"), // stdout + // 2 => array("pipe", "w") // stderr + ); + //$cmd="/bin/ls"; + //passthru($cmd, $ret); + //dbg("ret=$ret"); + $cmd .= " &"; + $process = proc_open($cmd, $descriptorspec, $pipes); + sleep(1); + proc_close($process); + + dbg("Started QEMU."); + $sessfile = make_qemu_sessionfile_name($idx); + $cmd = "(sleep " . SESSION_TIMEOUT . "; kill -9 `cat " . $pidfile . "`; rm " . $pidfile . " " . $sessfile . ") &"; + + $process = proc_open($cmd, $descriptorspec, $wkpipes); + sleep(1); + proc_close($process); + + dbg("Started timed kill."); + dbg("Ready for a " . SESSION_TIMEOUT . " session."); +} + + +function output_applet_code() +{ + $w = APPLET_WIDTH; + $h = APPLET_HEIGHT; + $port = vnc_port(); + $vncjpath = VNCJAVA_PATH; + $jar = VNCJAR; + $class = VNCCLASS; + echo " + + + + + There should be a java applet here... make sure you have a JVM and it's enabled! + "; +} + +dbg("Checking if session is running..."); + +if (is_my_session_valid()) { + dbg("Session running"); + $qemuidx = qemu_slot(); +} else if ($closing != 1) { + dbg("Need to start qemu"); + + $qemuidx = start_qemu(); +} + +if ($qemuidx >= 0) { + if ($closing) { + dbg("closing..."); + unlink(make_qemu_sessionfile_name($qemuidx)); + //unlink(make_qemu_sessionfile_name($qemuidx)); + sleep(1); + //echo ""; + } else { + dbg("Waiting for vnc server..."); + sleep(5); + output_applet_code(); + } +} + + + +?> + + + Property changes on: haiku/trunk/3rdparty/onlinedemo/haiku.php ___________________________________________________________________ Name: svn:executable + * From jackburton at mail.berlios.de Fri Dec 28 16:37:51 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Fri, 28 Dec 2007 16:37:51 +0100 Subject: [Haiku-commits] r23185 - haiku/trunk/src/kits/interface Message-ID: <200712281537.lBSFbpHJ021512@sheep.berlios.de> Author: jackburton Date: 2007-12-28 16:37:51 +0100 (Fri, 28 Dec 2007) New Revision: 23185 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23185&view=rev Modified: haiku/trunk/src/kits/interface/Shelf.cpp Log: AddChild() was called too early for the replicant and the dragger, in BShelf::_AddReplicant(). Now it's called near the end of the function. This way we don't have to call RemoveSelf() in case BShelf::CanAcceptReplicantView() return false. This also fixes a glitch in BSnow, which calls MoveTo() in AttachedToWindow(). Simplified the code. Modified: haiku/trunk/src/kits/interface/Shelf.cpp =================================================================== --- haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 14:38:45 UTC (rev 23184) +++ haiku/trunk/src/kits/interface/Shelf.cpp 2007-12-28 15:37:51 UTC (rev 23185) @@ -1193,53 +1193,76 @@ // TODO: test me -- there seems to be lots of bugs parked here! BView *replicant = NULL; _GetReplicantData(data, view, replicant, dragger, relation); - + if (dragger != NULL) - dragger->_SetShelf(this); + dragger->_SetViewToDrag(replicant); - BRect frame; - if (relation == BDragger::TARGET_IS_CHILD) - frame = dragger->Frame().OffsetToCopy(point); - else { - frame = replicant->Frame().OffsetToCopy(point); - fContainerView->AddChild(replicant); - } - + BRect frame = view->Frame().OffsetToCopy(point); if (!CanAcceptReplicantView(frame, replicant, data)) { // the view has not been accepted - if (relation == BDragger::TARGET_IS_PARENT - || relation == BDragger::TARGET_IS_SIBLING) { - replicant->RemoveSelf(); + || relation == BDragger::TARGET_IS_SIBLING) { delete replicant; } - if (relation == BDragger::TARGET_IS_CHILD - || relation == BDragger::TARGET_IS_SIBLING) { - dragger->RemoveSelf(); + || relation == BDragger::TARGET_IS_SIBLING) { delete dragger; } - return NULL; } BPoint adjust = AdjustReplicantBy(frame, data); - // TODO: that's probably not correct for all relations (or any?) - // At least, commenting this line fixes a bug in BSnow + if (dragger != NULL) + dragger->_SetShelf(this); + + // TODO: could be not correct for some relations view->MoveTo(point + adjust); // if it's a sibling or a child, we need to add the dragger if (relation == BDragger::TARGET_IS_SIBLING || relation == BDragger::TARGET_IS_CHILD) fContainerView->AddChild(dragger); - + + if (relation != BDragger::TARGET_IS_CHILD) + fContainerView->AddChild(replicant); + replicant->AddFilter(new ReplicantViewFilter(this, replicant)); return replicant; } +/* static */ +void +BShelf::_GetReplicantData(BMessage *data, BView *view, BView *&replicant, + BDragger *&dragger, BDragger::relation &relation) +{ + // Check if we have a dragger archived as "__widget" inside the message + BMessage widget; + if (data->FindMessage("__widget", &widget) == B_OK) { + image_id draggerImage = B_ERROR; + replicant = view; + dragger = dynamic_cast(_InstantiateObject(&widget, &draggerImage)); + // Replicant is a sibling, or unknown, if there isn't a dragger + if (dragger != NULL) + relation = BDragger::TARGET_IS_SIBLING; + + } else if ((dragger = dynamic_cast(view)) != NULL) { + // Replicant is child of the dragger + relation = BDragger::TARGET_IS_CHILD; + replicant = dragger->ChildAt(0); + + } else { + // Replicant is parent of the dragger + relation = BDragger::TARGET_IS_PARENT; + replicant = view; + dragger = dynamic_cast(replicant->FindView("_dragger_")); + // can be NULL, the replicant could not have a dragger at all + } +} + + _BZombieReplicantView_ * BShelf::_CreateZombie(BMessage *data, BDragger *&dragger) { @@ -1344,42 +1367,6 @@ /* static */ -void -BShelf::_GetReplicantData(BMessage *data, BView *view, BView *&replicant, - BDragger *&dragger, BDragger::relation &relation) -{ - // Check if we have a dragger archived as "__widget" inside the message - BMessage widget; - if (data->FindMessage("__widget", &widget) == B_OK) { - image_id draggerImage = B_ERROR; - replicant = view; - dragger = dynamic_cast(_InstantiateObject(&widget, &draggerImage)); - if (dragger != NULL) { - // Replicant is either a sibling or unknown - dragger->_SetViewToDrag(replicant); - relation = BDragger::TARGET_IS_SIBLING; - } - } else { - // Replicant is child of the dragger - if ((dragger = dynamic_cast(view)) != NULL) { - replicant = dragger->ChildAt(0); - dragger->_SetViewToDrag(replicant); - relation = BDragger::TARGET_IS_CHILD; - } else { - // Replicant is parent of the dragger - replicant = view; - dragger = dynamic_cast(replicant->FindView("_dragger_")); - - if (dragger) - dragger->_SetViewToDrag(replicant); - - relation = BDragger::TARGET_IS_PARENT; - } - } -} - - -/* static */ BArchivable * BShelf::_InstantiateObject(BMessage *archive, image_id *image) { From axeld at pinc-software.de Fri Dec 28 18:44:35 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Fri, 28 Dec 2007 18:44:35 +0100 CET Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <20471764.1197364852803.JavaMail.ngmail@webmail15> Message-ID: <25643975702-BeMail@zon> Marcus Overhagen wrote: > There a some snooze(1) calls in the drivers, but I think > they are there to avoid busy waiting when polling for > a hardware event that is meant to happen immediatelly. The question is if that isn't more expensive than busy waiting. I guess we should do some measurements with our and Be's scheduler to see what the outcome is. Bye, Axel. From revol at free.fr Fri Dec 28 19:18:37 2007 From: revol at free.fr (=?windows-1252?q?Fran=E7ois?= Revol) Date: Fri, 28 Dec 2007 19:18:37 +0100 CET Subject: [Haiku-commits] r23099 haiku/trunk/src/add-ons/kernel/bus_managers/usb In-Reply-To: <25643975702-BeMail@zon> Message-ID: <15139215558-BeMail@laptop> > Marcus Overhagen wrote: > > There a some snooze(1) calls in the drivers, but I think > > they are there to avoid busy waiting when polling for > > a hardware event that is meant to happen immediatelly. > > The question is if that isn't more expensive than busy waiting. I > guess > we should do some measurements with our and Be's scheduler to see > what > the outcome is. > I recall Ithamar fixing the zeta version of the ide driver where he originally had the irq handler force a resched each time... perf was horrible. Fran?ois. From mmu_man at mail.berlios.de Sat Dec 29 13:58:33 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 13:58:33 +0100 Subject: [Haiku-commits] r23186 - in haiku/trunk/headers/private/kernel/boot/platform: . atari_m68k Message-ID: <200712291258.lBTCwXY6018657@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 13:58:32 +0100 (Sat, 29 Dec 2007) New Revision: 23186 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23186&view=rev Added: haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/ haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_kernel_args.h haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_stage2_args.h Log: Minimal headers for atari_m68k Added: haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_kernel_args.h 2007-12-28 15:37:51 UTC (rev 23185) +++ haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_kernel_args.h 2007-12-29 12:58:32 UTC (rev 23186) @@ -0,0 +1,23 @@ +/* +** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_PLATFORM_ATARI_KERNEL_ARGS_H +#define KERNEL_BOOT_PLATFORM_ATARI_KERNEL_ARGS_H + +#ifndef KERNEL_BOOT_KERNEL_ARGS_H +# error This file is included from only +#endif + +// must match SMP_MAX_CPUS in arch_smp.h +#define MAX_BOOT_CPUS 1 +#define MAX_PHYSICAL_MEMORY_RANGE 4 +#define MAX_PHYSICAL_ALLOCATED_RANGE 8 +#define MAX_VIRTUAL_ALLOCATED_RANGE 32 + + +typedef struct { + int dummy; // nothing yet XXX +} platform_kernel_args; + +#endif /* KERNEL_BOOT_PLATFORM_ATARI_KERNEL_ARGS_H */ Added: haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_stage2_args.h =================================================================== --- haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_stage2_args.h 2007-12-28 15:37:51 UTC (rev 23185) +++ haiku/trunk/headers/private/kernel/boot/platform/atari_m68k/platform_stage2_args.h 2007-12-29 12:58:32 UTC (rev 23186) @@ -0,0 +1,15 @@ +/* +** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_PLATFORM_ATARI_M68K_STAGE2_ARGS_H +#define KERNEL_BOOT_PLATFORM_ATARI_M68K_STAGE2_ARGS_H + +#ifndef KERNEL_BOOT_STAGE2_ARGS_H +# error This file is included from only +#endif + +struct platform_stage2_args { +}; + +#endif /* KERNEL_BOOT_PLATFORM_ATARI_M68K_STAGE2_ARGS_H */ From mmu_man at mail.berlios.de Sat Dec 29 14:01:14 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 14:01:14 +0100 Subject: [Haiku-commits] r23187 - haiku/trunk/headers/private/kernel/arch/m68k Message-ID: <200712291301.lBTD1EG9018984@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 14:01:14 +0100 (Sat, 29 Dec 2007) New Revision: 23187 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23187&view=rev Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h Log: Some more fields that helps compiling, but I'll have to sort that out later. Modified: haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h 2007-12-29 12:58:32 UTC (rev 23186) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_kernel_args.h 2007-12-29 13:01:14 UTC (rev 23187) @@ -24,6 +24,10 @@ uint64 bus_frequency; uint64 time_base_frequency; + // page root table + uint32 phys_pgroot; + uint32 vir_pgroot; +//XXX: addr_range page_table; // virtual address and size of the page table addr_range exception_handlers; addr_range framebuffer; // maps where the framebuffer is located, in physical memory From mmu_man at mail.berlios.de Sat Dec 29 15:44:48 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 15:44:48 +0100 Subject: [Haiku-commits] r23188 - haiku/trunk/headers/private/kernel/arch/m68k Message-ID: <200712291444.lBTEimRa024300@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 15:44:47 +0100 (Sat, 29 Dec 2007) New Revision: 23188 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23188&view=rev Added: haiku/trunk/headers/private/kernel/arch/m68k/arch_030_mmu.h Log: Move mmu definitions to a header so the bootloader can also use them. Added: haiku/trunk/headers/private/kernel/arch/m68k/arch_030_mmu.h =================================================================== --- haiku/trunk/headers/private/kernel/arch/m68k/arch_030_mmu.h 2007-12-29 13:01:14 UTC (rev 23187) +++ haiku/trunk/headers/private/kernel/arch/m68k/arch_030_mmu.h 2007-12-29 14:44:47 UTC (rev 23188) @@ -0,0 +1,204 @@ +/* +** Copyright 2003, Axel D?rfler, axeld at pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _KERNEL_ARCH_M68K_030_MMU_H +#define _KERNEL_ARCH_M68K_030_MMU_H + + +#include +#include + +#include + +enum descriptor_types { + DT_INVALID = 0, // invalid entry + DT_PAGE, // page descriptor + DT_VALID_4, // short page table descriptor + DT_VALID_8, // long page table descriptor +}; + +// global pages only available on 040/060 +//#define MMU_HAS_GLOBAL_PAGES + +/* This is the normal layout of the descriptors, as per documentation. + * When page size > 256, several bits are unused in the LSB of page + * addresses, which we can use in addition of other unused bits. + * the structs dedlared later reflect this for 4K pages. + */ + // = names in MC user's manual + // or comments +struct short_page_directory_entry { + // upper 32 bits + uint32 type : 2; // DT_* + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 addr : 28; // address +}; + +struct long_page_directory_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 _zero1 : 4; + uint32 supervisor : 1; + uint32 _zero2 : 1; + uint32 _ones : 6; + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 4; // + uint32 addr : 28; // address +}; + +struct short_page_table_entry { + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 dirty : 1; // = modified + uint32 _zero1 : 1; + uint32 cache_disabled : 1; // = cache_inhibit + uint32 _zero2 : 1; + uint32 addr : 24; // address +}; + +struct long_page_table_entry { + // upper 32 bits + uint32 type : 2; + uint32 write_protect : 1; + uint32 accessed : 1; // = used + uint32 dirty : 1; // = modified + uint32 _zero1 : 1; + uint32 cache_disabled : 1; // = cache_inhibit + uint32 _zero2 : 1; + uint32 supervisor : 1; + uint32 _zero3 : 1; + uint32 _ones : 6; + // limit only used on early table terminators, else unused + uint32 limit : 15; + uint32 low_up : 1; // limit is lower(1)/upper(0) + // lower 32 bits + uint32 unused : 8; // + uint32 addr : 24; // address +}; + +/* rarely used */ +struct short_indirect_entry { + // upper 32 bits + uint32 type : 2; // DT_* + uint32 addr : 30; // address +}; + +struct long_indirect_entry { + // upper 32 bits + uint32 type : 2; + uint32 unused1 : 30; + // lower 32 bits + uint32 unused2 : 2; // + uint32 addr : 30; // address +}; + +/* for clarity: + - the top level page directory will be called "page root", (root or rtdir) + - the 2nd level will be "page directory" like on x86, (pgdir) + - the 3rd level is a "page table" as on x86. (pgtbl) +*/ + +typedef struct short_page_directory_entry page_root_entry; +typedef struct short_page_directory_entry page_directory_entry; +typedef struct long_page_table_entry page_table_entry; +typedef struct long_indirect_entry page_indirect_entry; + +/* scalar storage type that maps them */ +typedef uint32 page_root_entry_scalar; +typedef uint32 page_directory_entry_scalar; +typedef uint64 page_table_entry_scalar; +typedef uint64 page_indirect_entry_scalar; + +#define DT_ROOT DT_VALID_4 +#define DT_DIR DT_VALID_8 +//#define DT_PAGE DT_PAGE :) +#define DT_INDIRECT DT_VALID_8 + +/* default scalar values for entries */ +#define DFL_ROOTENT_VAL 0x00000000 +#define DFL_DIRENT_VAL 0x00000000 +// limit disabled, 6bits at 1 +// (limit isn't used on that level, but just in case) +#define DFL_PAGEENT_VAL 0x7FFFFC0000000000LL + +#define NUM_ROOTENT_PER_TBL 128 +#define NUM_DIRENT_PER_TBL 128 +#define NUM_PAGEENT_PER_TBL 64 + +/* unlike x86, the root/dir/page table sizes are different than B_PAGE_SIZE + * so we will have to fit more than one on a page to avoid wasting space. + * We will allocate a group of tables with the one we want inside, and + * add them from the aligned index needed, to make it easy to free them. + */ + +#define SIZ_ROOTTBL (128 * sizeof(page_root_entry)) +#define SIZ_DIRTBL (128 * sizeof(page_directory_entry)) +#define SIZ_PAGETBL (64 * sizeof(page_table_entry)) + +//#define NUM_ROOTTBL_PER_PAGE (B_PAGE_SIZE / SIZ_ROOTTBL) +#define NUM_DIRTBL_PER_PAGE (B_PAGE_SIZE / SIZ_DIRTBL) +#define NUM_PAGETBL_PER_PAGE (B_PAGE_SIZE / SIZ_PAGETBL) + +/* macros to get the physical page or table number and address of tables from + * descriptors */ +#if 0 +/* XXX: + suboptimal: + struct foo { + int a:2; + int b:30; + } v = {...}; + *(int *)0 = (v.b) << 2; + generates: + sarl $2, %eax + sall $2, %eax + We use a cast + bitmasking, since all address fields are already shifted +*/ +// from a root entry +#define PREA_TO_TA(a) ((a) << 4) +#define PREA_TO_PN(a) ((a) >> (12-4)) +#define PREA_TO_PA(a) ((a) << 4) +#define TA_TO_PREA(a) ((a) >> 4) +//... +#endif + +// TA: table address +// PN: page number +// PA: page address +// PO: page offset (offset of table in page) +// PI: page index (index of table relative to page start) + +// from a root entry +#define PRE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) +#define PRE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) +#define PRE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) +//#define PRE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) +//#define PRE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_DIRTBL) +#define TA_TO_PREA(a) ((a) >> 4) +// from a directory entry +#define PDE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) +#define PDE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) +#define PDE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) +//#define PDE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) +//#define PDE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_PAGETBL) +#define TA_TO_PDEA(a) ((a) >> 4) +// from a table entry +#define PTE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<8)-1)) +#define PTE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) +#define PTE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) +#define TA_TO_PTEA(a) ((a) >> 8) +// from an indirect entry +#define PIE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<2)-1)) +#define PIE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) +#define PIE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) +#define PIE_TO_PO(e) ((((uint32 *)(&(e)))[1]) & ((1<<12)-(1<<2))) +#define TA_TO_PIEA(a) ((a) >> 2) + +#endif /* _KERNEL_ARCH_M68K_030_MMU_H */ From mmu_man at mail.berlios.de Sat Dec 29 15:46:02 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 15:46:02 +0100 Subject: [Haiku-commits] r23189 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200712291446.lBTEk2VH024409@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 15:46:01 +0100 (Sat, 29 Dec 2007) New Revision: 23189 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23189&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp Log: Moved the guts to a header. Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp 2007-12-29 14:44:47 UTC (rev 23188) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_030_mmu.cpp 2007-12-29 14:46:01 UTC (rev 23189) @@ -8,192 +8,10 @@ #include +#include #define ARCH_M68K_MMU_TYPE MMU_68030 -enum descriptor_types { - DT_INVALID = 0, // invalid entry - DT_PAGE, // page descriptor - DT_VALID_4, // short page table descriptor - DT_VALID_8, // long page table descriptor -}; - - - // = names in MC user's manual - // or comments -struct short_page_directory_entry { - // upper 32 bits - uint32 type : 2; // DT_* - uint32 write_protect : 1; - uint32 accessed : 1; // = used - uint32 addr : 28; // address -}; - -struct long_page_directory_entry { - // upper 32 bits - uint32 type : 2; - uint32 write_protect : 1; - uint32 accessed : 1; // = used - uint32 _zero1 : 4; - uint32 supervisor : 1; - uint32 _zero2 : 1; - uint32 _ones : 6; - uint32 limit : 15; - uint32 low_up : 1; // limit is lower(1)/upper(0) - // lower 32 bits - uint32 unused : 4; // - uint32 addr : 28; // address -}; - -struct short_page_table_entry { - uint32 type : 2; - uint32 write_protect : 1; - uint32 accessed : 1; // = used - uint32 dirty : 1; // = modified - uint32 _zero1 : 1; - uint32 cache_disabled : 1; // = cache_inhibit - uint32 _zero2 : 1; - uint32 addr : 24; // address -}; - -struct long_page_table_entry { - // upper 32 bits - uint32 type : 2; - uint32 write_protect : 1; - uint32 accessed : 1; // = used - uint32 dirty : 1; // = modified - uint32 _zero1 : 1; - uint32 cache_disabled : 1; // = cache_inhibit - uint32 _zero2 : 1; - uint32 supervisor : 1; - uint32 _zero3 : 1; - uint32 _ones : 6; - // limit only used on early table terminators, else unused - uint32 limit : 15; - uint32 low_up : 1; // limit is lower(1)/upper(0) - // lower 32 bits - uint32 unused : 8; // - uint32 addr : 24; // address -}; - -/* rarely used */ -struct short_indirect_entry { - // upper 32 bits - uint32 type : 2; // DT_* - uint32 addr : 30; // address -}; - -struct long_indirect_entry { - // upper 32 bits - uint32 type : 2; - uint32 unused1 : 30; - // lower 32 bits - uint32 unused2 : 2; // - uint32 addr : 30; // address -}; - -/* for clarity: - - the top level page directory will be called "page root", (root or rtdir) - - the 2nd level will be "page directory" like on x86, (pgdir) - - the 3rd level is a "page table" as on x86. (pgtbl) -*/ - -typedef struct short_page_directory_entry page_root_entry; -typedef struct short_page_directory_entry page_directory_entry; -typedef struct long_page_table_entry page_table_entry; -typedef struct long_indirect_entry page_indirect_entry; - -/* scalar storage type that maps them */ -typedef uint32 page_root_entry_scalar; -typedef uint32 page_directory_entry_scalar; -typedef uint64 page_table_entry_scalar; -typedef uint64 page_indirect_entry_scalar; - -#define DT_ROOT DT_VALID_4 -#define DT_DIR DT_VALID_8 -//#define DT_PAGE DT_PAGE :) -#define DT_INDIRECT DT_VALID_8 - -/* default scalar values for entries */ -#define DFL_ROOTENT_VAL 0x00000000 -#define DFL_DIRENT_VAL 0x00000000 -// limit disabled, 6bits at 1 -// (limit isn't used on that level, but just in case) -#define DFL_PAGEENT_VAL 0x7FFFFC0000000000LL - -#define NUM_ROOTENT_PER_TBL 128 -#define NUM_DIRENT_PER_TBL 128 -#define NUM_PAGEENT_PER_TBL 64 - -/* unlike x86, the root/dir/page table sizes are different than B_PAGE_SIZE - * so we will have to fit more than one on a page to avoid wasting space. - * We will allocate a group of tables with the one we want inside, and - * add them from the aligned index needed, to make it easy to free them. - */ - -#define SIZ_ROOTTBL (128 * sizeof(page_root_entry)) -#define SIZ_DIRTBL (128 * sizeof(page_directory_entry)) -#define SIZ_PAGETBL (64 * sizeof(page_table_entry)) - -//#define NUM_ROOTTBL_PER_PAGE (B_PAGE_SIZE / SIZ_ROOTTBL) -#define NUM_DIRTBL_PER_PAGE (B_PAGE_SIZE / SIZ_DIRTBL) -#define NUM_PAGETBL_PER_PAGE (B_PAGE_SIZE / SIZ_PAGETBL) - -/* macros to get the physical page or table number and address of tables from - * descriptors */ -#if 0 -/* XXX: - suboptimal: - struct foo { - int a:2; - int b:30; - } v = {...}; - *(int *)0 = (v.b) << 2; - generates: - sarl $2, %eax - sall $2, %eax - We use a cast + bitmasking, since all address fields are already shifted -*/ -// from a root entry -#define PREA_TO_TA(a) ((a) << 4) -#define PREA_TO_PN(a) ((a) >> (12-4)) -#define PREA_TO_PA(a) ((a) << 4) -#define TA_TO_PREA(a) ((a) >> 4) -//... -#endif - -// TA: table address -// PN: page number -// PA: page address -// PO: page offset (offset of table in page) -// PI: page index (index of table relative to page start) - -// from a root entry -#define PRE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) -#define PRE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) -#define PRE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) -#define PRE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) -#define PRE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_DIRTBL) -#define TA_TO_PREA(a) ((a) >> 4) -// from a directory entry -#define PDE_TO_TA(a) ((*(uint32 *)(&(a))) & ~((1<<4)-1)) -#define PDE_TO_PN(e) ((*(uint32 *)(&(e))) >> 12) -#define PDE_TO_PA(e) ((*(uint32 *)(&(e))) & ~((1<<12)-1)) -#define PDE_TO_PO(e) ((*(uint32 *)(&(e))) & ((1<<12)-1)) -#define PDE_TO_PI(e) (((*(uint32 *)(&(e))) & ((1<<12)-1)) / SIZ_PAGETBL) -#define TA_TO_PDEA(a) ((a) >> 4) -// from a table entry -#define PTE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<8)-1)) -#define PTE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) -#define PTE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) -#define TA_TO_PTEA(a) ((a) >> 8) -// from an indirect entry -#define PIE_TO_TA(a) ((((uint32 *)(&(a)))[1]) & ~((1<<2)-1)) -#define PIE_TO_PN(e) ((((uint32 *)(&(e)))[1]) >> 12) -#define PIE_TO_PA(e) ((((uint32 *)(&(e)))[1]) & ~((1<<12)-1)) -#define TA_TO_PIEA(a) ((a) >> 2) - - #include "arch_vm_translation_map_impl.cpp" struct m68k_vm_ops m68030_vm_ops = { From mmu_man at mail.berlios.de Sat Dec 29 15:47:25 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 15:47:25 +0100 Subject: [Haiku-commits] r23190 - haiku/trunk/src/system/kernel/arch/m68k Message-ID: <200712291447.lBTElPGu024502@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 15:47:25 +0100 (Sat, 29 Dec 2007) New Revision: 23190 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23190&view=rev Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp Log: WIP; Implemented most of vm stuff. Modified: haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp =================================================================== --- haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2007-12-29 14:46:01 UTC (rev 23189) +++ haiku/trunk/src/system/kernel/arch/m68k/arch_vm_translation_map_impl.cpp 2007-12-29 14:47:25 UTC (rev 23190) @@ -83,12 +83,12 @@ addr_t pages_to_invalidate[PAGE_INVALIDATE_CACHE_SIZE]; } vm_translation_map_arch_info; -#if 0 +#if 1//XXX ? static page_table_entry *page_hole = NULL; static page_directory_entry *page_hole_pgdir = NULL; #endif -static page_root_entry *sKernelPhysicalPageDirectory = NULL; -static page_root_entry *sKernelVirtualPageDirectory = NULL; +static page_root_entry *sKernelPhysicalPageRoot = NULL; +static page_root_entry *sKernelVirtualPageRoot = NULL; static addr_t sQueryPage = NULL; //static page_table_entry *sQueryPageTable; //static page_directory_entry *sQueryPageDir; @@ -200,6 +200,29 @@ } +// 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)].type != DT_DIR) { + // no pagetable here + return B_ERROR; + } +#warning M68K: va or VADDR_TO_PTENT(va) ?? + pentry = page_hole + va / B_PAGE_SIZE; + if (pentry->type != DT_PAGE) { + // page mapping not valid + return B_ERROR; + } + + *_physicalAddress = PTE_TO_PA(*pentry); + return B_OK; +} + + /*! Acquires the map's recursive lock, and resets the invalidate pages counter in case it's the first locking recursion. */ @@ -484,7 +507,7 @@ } while (err < 0); pd = (page_directory_entry *)pd_pg; // we want the table at rindex, not at rindex%(tbl/page) - pd += rindex % NUM_DIRTBL_PER_PAGE; + pd += (rindex % NUM_DIRTBL_PER_PAGE) * NUM_DIRENT_PER_TBL; // check to see if a page table exists for this range dindex = VADDR_TO_PDENT(va); @@ -528,7 +551,7 @@ } while (err < 0); pt = (page_table_entry *)pt_pg; // we want the table at rindex, not at rindex%(tbl/page) - pt += dindex % NUM_PAGETBL_PER_PAGE; + pt += (dindex % NUM_PAGETBL_PER_PAGE) * NUM_PAGEENT_PER_TBL; pindex = VADDR_TO_PTENT(va); @@ -580,7 +603,8 @@ &pd_pg, PHYSICAL_PAGE_NO_WAIT); } while (status < B_OK); pd = (page_directory_entry *)pd_pg; - pd += index % NUM_DIRTBL_PER_PAGE; + // we want the table at rindex, not at rindex%(tbl/page) + pd += (index % NUM_DIRTBL_PER_PAGE) * NUM_DIRENT_PER_TBL; index = VADDR_TO_PDENT(start); if (pd[index].type != DT_DIR) { @@ -595,9 +619,11 @@ &pt_pg, PHYSICAL_PAGE_NO_WAIT); } while (status < B_OK); pt = (page_table_entry *)pt_pg; - pt += index % NUM_PAGETBL_PER_PAGE; + // we want the table at rindex, not at rindex%(tbl/page) + pt += (index % NUM_PAGETBL_PER_PAGE) * NUM_PAGEENT_PER_TBL; - for (index = VADDR_TO_PTENT(start); (index < NUM_PAGEENT_PER_TBL) && (start < end); + for (index = VADDR_TO_PTENT(start); + (index < NUM_PAGEENT_PER_TBL) && (start < end); index++, start += B_PAGE_SIZE) { if (pt[index].type != DT_PAGE && pt[index].type != DT_INDIRECT) { // page mapping not valid @@ -687,7 +713,10 @@ 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->rtdir_virt; + page_indirect_entry *pi; + page_directory_entry *pd; + page_directory_entry *pr = map->arch_data->rtdir_virt; + addr_t pd_pg, pt_pg, pi_pg; status_t status; int32 index; @@ -695,30 +724,67 @@ *_flags = 0; *_physical = 0; - index = VADDR_TO_PDENT(va); - if (pd[index].present == 0) { + index = VADDR_TO_PRENT(va); + if (pr[index].type != DT_ROOT) { // 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); + status = get_physical_page_tmap(PRE_TO_PA(pr[index]), + &pd_pg, PHYSICAL_PAGE_NO_WAIT); } while (status < B_OK); + pd = (page_directory_entry *)pd_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pd += (index % NUM_DIRTBL_PER_PAGE) * NUM_DIRENT_PER_TBL; + + + index = VADDR_TO_PDENT(start); + if (pd[index].type != DT_DIR) { + // no pagetable here + put_physical_page_tmap(pd_pg); + return B_NO_ERROR; + } + + do { + status = get_physical_page_tmap(PDE_TO_PA(pd[index]), + &pt_pg, PHYSICAL_PAGE_NO_WAIT); + } while (status < B_OK); + pt = (page_table_entry *)pt_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pt += (index % NUM_PAGETBL_PER_PAGE) * NUM_PAGEENT_PER_TBL; + index = VADDR_TO_PTENT(va); - *_physical = ADDR_REVERSE_SHIFT(pt[index].addr); + // handle indirect descriptor + if (pt[index].type == DT_INDIRECT) { + pi = pt; + pi_pg = pt_pg; + do { + status = get_physical_page_tmap(PIE_TO_PA(pi[index]), + &pt_pg, PHYSICAL_PAGE_NO_WAIT); + } while (status < B_OK); + pt = (page_table_entry *)pt_pg; + // add offset from start of page + pt += PIE_TO_PO(pi[index]) / sizeof(page_table_entry); + // release the indirect table page + put_physical_page_tmap(pi_pg); + } + *_physical = PTE_TO_PA(pt[index]); + // read in the page state flags - if (pt[index].user) - *_flags |= (pt[index].rw ? B_WRITE_AREA : 0) | B_READ_AREA; + if (!pt[index].supervisor) + *_flags |= (pt[index].write_protect ? 0 : B_WRITE_AREA) | B_READ_AREA; - *_flags |= ((pt[index].rw ? B_KERNEL_WRITE_AREA : 0) | B_KERNEL_READ_AREA) + *_flags |= (pt[index].write_protect ? 0 : B_KERNEL_WRITE_AREA) + | B_KERNEL_READ_AREA | (pt[index].dirty ? PAGE_MODIFIED : 0) | (pt[index].accessed ? PAGE_ACCESSED : 0) - | (pt[index].present ? PAGE_PRESENT : 0); + | ((pt[index].type == DT_PAGE) ? PAGE_PRESENT : 0); - put_physical_page_tmap((addr_t)pt); + put_physical_page_tmap(pt_pg); + put_physical_page_tmap(pd_pg); TRACE(("query_tmap: returning pa 0x%lx for va 0x%lx\n", *_physical, va)); @@ -737,7 +803,9 @@ 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->rtdir_virt; + page_directory_entry *pd; + page_root_entry *pr = map->arch_data->rtdir_virt; + addr_t pd_pg, pt_pg; status_t status; int index; @@ -749,32 +817,54 @@ restart: if (start >= end) return B_OK; + + index = VADDR_TO_PRENT(start); + if (pr[index].type != DT_ROOT) { + // no pagedir 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(PRE_TO_PA(pr[index]), + &pd_pg, PHYSICAL_PAGE_NO_WAIT); + } while (status < B_OK); + pd = (page_directory_entry *)pd_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pd += (index % NUM_DIRTBL_PER_PAGE) * NUM_DIRENT_PER_TBL; + index = VADDR_TO_PDENT(start); - if (pd[index].present == 0) { + if (pd[index].type != DT_DIR) { // no pagetable here, move the start up to access the next page table start = ROUNDUP(start + 1, B_PAGE_SIZE); + put_physical_page_tmap(pd_pg); goto restart; } do { - status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr), - (addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT); + status = get_physical_page_tmap(PDE_TO_PA(pd[index]), + &pt_pg, PHYSICAL_PAGE_NO_WAIT); } while (status < B_OK); + pt = (page_table_entry *)pt_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pt += (index % NUM_PAGETBL_PER_PAGE) * NUM_PAGEENT_PER_TBL; - for (index = VADDR_TO_PTENT(start); index < 1024 && start < end; index++, start += B_PAGE_SIZE) { - if (pt[index].present == 0) { + for (index = VADDR_TO_PTENT(start); + (index < NUM_PAGEENT_PER_TBL) && (start < end); + index++, start += B_PAGE_SIZE) { + // XXX: handle indirect ? + if (pt[index].type != DT_PAGE /*&& pt[index].type != DT_INDIRECT*/) { // page mapping not valid continue; } TRACE(("protect_tmap: protect page 0x%lx\n", start)); - pt[index].user = (attributes & B_USER_PROTECTION) != 0; + pt[index].supervisor = (attributes & B_USER_PROTECTION) == 0; if ((attributes & B_USER_PROTECTION) != 0) - pt[index].rw = (attributes & B_WRITE_AREA) != 0; + pt[index].write_protect = (attributes & B_WRITE_AREA) == 0; else - pt[index].rw = (attributes & B_KERNEL_WRITE_AREA) != 0; + pt[index].write_protect = (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; @@ -782,7 +872,8 @@ map->arch_data->num_invalidate_pages++; } - put_physical_page_tmap((addr_t)pt); + put_physical_page_tmap(pt_pg); + put_physical_page_tmap(pd_pg); goto restart; } @@ -792,23 +883,61 @@ clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags) { page_table_entry *pt; - page_directory_entry *pd = map->arch_data->rtdir_virt; + page_indirect_entry *pi; + page_directory_entry *pd; + page_root_entry *pr = map->arch_data->rtdir_virt; + addr_t pd_pg, pt_pg, pi_pg; status_t status; int index; int tlb_flush = false; - index = VADDR_TO_PDENT(va); - if (pd[index].present == 0) { + index = VADDR_TO_PRENT(va); + if (pr[index].type != DT_ROOT) { // no pagetable here - return B_OK; + return B_NO_ERROR; } do { - status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr), - (addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT); + status = get_physical_page_tmap(PRE_TO_PA(pr[index]), + &pd_pg, PHYSICAL_PAGE_NO_WAIT); } while (status < B_OK); + pd = (page_directory_entry *)pd_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pd += (index % NUM_DIRTBL_PER_PAGE) * NUM_DIRENT_PER_TBL; + + + index = VADDR_TO_PDENT(start); + if (pd[index].type != DT_DIR) { + // no pagetable here + put_physical_page_tmap(pd_pg); + return B_NO_ERROR; + } + + do { + status = get_physical_page_tmap(PDE_TO_PA(pd[index]), + &pt_pg, PHYSICAL_PAGE_NO_WAIT); + } while (status < B_OK); + pt = (page_table_entry *)pt_pg; + // we want the table at rindex, not at rindex%(tbl/page) + pt += (index % NUM_PAGETBL_PER_PAGE) * NUM_PAGEENT_PER_TBL; + index = VADDR_TO_PTENT(va); + // handle indirect descriptor + if (pt[index].type == DT_INDIRECT) { + pi = pt; + pi_pg = pt_pg; + do { + status = get_physical_page_tmap(PIE_TO_PA(pi[index]), + &pt_pg, PHYSICAL_PAGE_NO_WAIT); + } while (status < B_OK); + pt = (page_table_entry *)pt_pg; + // add offset from start of page + pt += PIE_TO_PO(pi[index]) / sizeof(page_table_entry); + // release the indirect table page + put_physical_page_tmap(pi_pg); + } + // clear out the flags we've been requested to clear if (flags & PAGE_MODIFIED) { pt[index].dirty = 0; @@ -819,7 +948,8 @@ tlb_flush = true; } - put_physical_page_tmap((addr_t)pt); + put_physical_page_tmap(pt_pg); + put_physical_page_tmap(pd_pg); if (tlb_flush) { if (map->arch_data->num_invalidate_pages < PAGE_INVALIDATE_CACHE_SIZE) @@ -878,7 +1008,6 @@ { int i; page_table_entry *pt; - addr_t ppn; int state; pa &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned @@ -886,15 +1015,17 @@ if (va < sIOSpaceBase || va >= (sIOSpaceBase + IOSPACE_SIZE)) panic("map_iospace_chunk: passed invalid va 0x%lx\n", va); - ppn = ADDR_SHIFT(pa); pt = &iospace_pgtables[(va - sIOSpaceBase) / B_PAGE_SIZE]; - for (i = 0; i < 1024; i++) { + for (i = 0; i < 1024; i++, pa += B_PAGE_SIZE) { init_page_table_entry(&pt[i]); - pt[i].addr = ppn + i; - pt[i].user = 0; - pt[i].rw = 1; - pt[i].present = 1; + pt[i].addr = TA_TO_PTEA(pa); + pt[i].supervisor = 1; + pt[i].write_protect = 0; + pt[i].type = DT_PAGE; + // 040 or 060 only +#ifdef MMU_HAS_GLOBAL_PAGES pt[i].global = 1; +#endif } state = disable_interrupts(); @@ -976,9 +1107,9 @@ if (!kernel) { // user - // allocate a pgdir - map->arch_data->rtdir_virt = (page_directory_entry *)memalign( - B_PAGE_SIZE, B_PAGE_SIZE); + // allocate a rtdir + map->arch_data->rtdir_virt = (page_root_entry *)memalign( + SIZ_ROOTTBL, SIZ_ROOTTBL); if (map->arch_data->rtdir_virt == NULL) { free(map->arch_data); recursive_lock_destroy(&map->lock); @@ -989,23 +1120,23 @@ } else { // kernel // we already know the kernel pgdir mapping - map->arch_data->rtdir_virt = sKernelVirtualPageDirectory; - map->arch_data->rtdir_phys = sKernelPhysicalPageDirectory; + map->arch_data->rtdir_virt = sKernelVirtualPageRoot; + map->arch_data->rtdir_phys = sKernelPhysicalPageRoot; } - // zero out the bottom portion of the new pgdir - memset(map->arch_data->rtdir_virt + FIRST_USER_PGDIR_ENT, 0, - NUM_USER_PGDIR_ENTS * sizeof(page_directory_entry)); + // zero out the bottom portion of the new rtdir + memset(map->arch_data->rtdir_virt + FIRST_USER_PGROOT_ENT, 0, + NUM_USER_PGROOT_ENTS * sizeof(page_root_entry)); // insert this new map into the map list { int state = disable_interrupts(); acquire_spinlock(&tmap_list_lock); - // copy the top portion of the pgdir from the current one - memcpy(map->arch_data->rtdir_virt + FIRST_KERNEL_PGDIR_ENT, - sKernelVirtualPageDirectory + FIRST_KERNEL_PGDIR_ENT, - NUM_KERNEL_PGDIR_ENTS * sizeof(page_directory_entry)); + // copy the top portion of the rtdir from the current one + memcpy(map->arch_data->rtdir_virt + FIRST_KERNEL_PGROOT_ENT, + sKernelVirtualPageRoot + FIRST_KERNEL_PGROOT_ENT, + NUM_KERNEL_PGROOT_ENTS * sizeof(page_root_entry)); map->next = tmap_list; tmap_list = map; @@ -1043,8 +1174,8 @@ memset(page_hole_pgdir + FIRST_USER_PGDIR_ENT, 0, sizeof(page_directory_entry) * NUM_USER_PGDIR_ENTS); #endif - sKernelPhysicalPageDirectory = (page_directory_entry *)args->arch_args.phys_pgdir; - sKernelVirtualPageDirectory = (page_directory_entry *)args->arch_args.vir_pgdir; + sKernelPhysicalPageRoot = (page_root_entry *)args->arch_args.phys_pgroot; + sKernelVirtualPageRoot = (page_root_entry *)args->arch_args.vir_pgroot; sQueryDesc.type = DT_INVALID; @@ -1052,8 +1183,10 @@ tmap_list = NULL; // allocate some space to hold physical page mapping info + //XXX: check page count +#error XXXXXXXXXXXX pt + pd? pd = memalign ? iospace_pgtables = (page_table_entry *)vm_allocate_early(args, - B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * 1024)), ~0L, + B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * NUM_PAGEENT_PER_TBL * NUM_PAGETBL_PER_PAGE)), ~0L, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); TRACE(("iospace_pgtables %p\n", iospace_pgtables)); @@ -1072,6 +1205,7 @@ // put the array of pgtables directly into the kernel pagedir // these will be wired and kept mapped into virtual space to be easy to get to { +#error XXXXXXXXXXXX addr_t phys_pgtable; addr_t virt_pgtable; page_directory_entry *e; @@ -1085,12 +1219,6 @@ } } - // enable global page feature if available - if (x86_check_feature(IA32_FEATURE_PGE, FEATURE_COMMON)) { - // this prevents kernel pages from being flushed from TLB on context-switch - x86_write_cr4(x86_read_cr4() | IA32_CR4_GLOBAL_PAGES); - } - TRACE(("vm_translation_map_init: done\n")); return B_OK; @@ -1116,11 +1244,11 @@ TRACE(("vm_translation_map_init_post_area: entry\n")); // unmap the page hole hack we were using before - sKernelVirtualPageDirectory[1023].present = 0; + sKernelVirtualPageRoot[1023].present = 0; page_hole_pgdir = NULL; page_hole = NULL; - temp = (void *)sKernelVirtualPageDirectory; + temp = (void *)sKernelVirtualPageRoot; area = create_area("kernel_pgdir", &temp, B_EXACT_ADDRESS, B_PAGE_SIZE, B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); if (area < B_OK) @@ -1159,7 +1287,7 @@ sQueryPageTable = (page_indirect_entry *)(sQueryPage); index = VADDR_TO_PRENT((addr_t)sQueryPageTable); - physicalPageTable = ADDR_REVERSE_SHIFT(sKernelVirtualPageDirectory[index].addr); + physicalPageTable = ADDR_REVERSE_SHIFT(sKernelVirtualPageRoot[index].addr); get_physical_page_tmap(physicalPageTable, (addr_t *)&pageTableEntry, PHYSICAL_PAGE_NO_WAIT); @@ -1167,7 +1295,7 @@ sQueryPageTable = (page_table_entry *)(sQueryPages); index = VADDR_TO_PDENT((addr_t)sQueryPageTable); - physicalPageTable = ADDR_REVERSE_SHIFT(sKernelVirtualPageDirectory[index].addr); + physicalPageTable = ADDR_REVERSE_SHIFT(sKernelVirtualPageRoot[index].addr); get_physical_page_tmap(physicalPageTable, (addr_t *)&pageTableEntry, PHYSICAL_PAGE_NO_WAIT); From mmu_man at mail.berlios.de Sat Dec 29 15:49:55 2007 From: mmu_man at mail.berlios.de (mmu_man at BerliOS) Date: Sat, 29 Dec 2007 15:49:55 +0100 Subject: [Haiku-commits] r23191 - haiku/trunk/src/system/boot/platform Message-ID: <200712291449.lBTEnt5c024619@sheep.berlios.de> Author: mmu_man Date: 2007-12-29 15:49:54 +0100 (Sat, 29 Dec 2007) New Revision: 23191 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23191&view=rev Added: haiku/trunk/src/system/boot/platform/atari_m68k/ Log: Here goes falcon specific boot code. From jackburton at mail.berlios.de Sat Dec 29 16:26:39 2007 From: jackburton at mail.berlios.de (jackburton at BerliOS) Date: Sat, 29 Dec 2007 16:26:39 +0100 Subject: [Haiku-commits] r23192 - haiku/trunk/src/kits/interface Message-ID: <200712291526.lBTFQdeg026731@sheep.berlios.de> Author: jackburton Date: 2007-12-29 16:26:37 +0100 (Sat, 29 Dec 2007) New Revision: 23192 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23192&view=rev Modified: haiku/trunk/src/kits/interface/ColorControl.cpp Log: Patch by cl21 (I really hope this isn't your real name :P ) which fixes the BColorControl flickering reported in bug #503. Thanks! Modified: haiku/trunk/src/kits/interface/ColorControl.cpp =================================================================== --- haiku/trunk/src/kits/interface/ColorControl.cpp 2007-12-29 14:49:54 UTC (rev 23191) +++ haiku/trunk/src/kits/interface/ColorControl.cpp 2007-12-29 15:26:37 UTC (rev 23192) @@ -222,26 +222,46 @@ c2.blue = (value & 0x0000FF00) >> 8; char string[4]; + // values for calculating the selector rectangles for invalidation + // analogous to selector drawing in _DrawColorArea + float rampXGradient = (ceil(fColumns * fCellSize) - 4 - 7) / 255; + float rampSize = (Bounds().bottom - 2) / 4.0; + float x, y; + if (c1.red != c2.red) { sprintf(string, "%d", c2.red); fRedText->SetText(string); + + y = rampSize * 1.5; + x = 2 + c1.red * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.red * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); } if (c1.green != c2.green) { sprintf(string, "%d", c2.green); fGreenText->SetText(string); + + y = rampSize * 2.5; + x = 2 + c1.green * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.green * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); } - if (c1.blue != c2.blue) { sprintf(string, "%d", c2.blue); fBlueText->SetText(string); + + y = rampSize * 3.5; + x = 2 + c1.blue * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); + x = 2 + c2.blue * rampXGradient; + Invalidate(BRect(x - 2, y - 2, x + 6, y + 6)); } BControl::SetValueNoUpdate(value); - // TODO: This causes lot of flickering - Invalidate(); - if (LockLooper()) { Window()->UpdateIfNeeded(); UnlockLooper(); From laplace at mail.berlios.de Sun Dec 30 11:06:47 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 30 Dec 2007 11:06:47 +0100 Subject: [Haiku-commits] r23193 - in haiku/trunk: headers/private/graphics/vmware src/add-ons/accelerants/vmware src/add-ons/kernel/drivers/graphics/vmware Message-ID: <200712301006.lBUA6lsh002577@sheep.berlios.de> Author: laplace Date: 2007-12-30 11:06:46 +0100 (Sun, 30 Dec 2007) New Revision: 23193 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23193&view=rev Modified: haiku/trunk/headers/private/graphics/vmware/DriverInterface.h haiku/trunk/src/add-ons/accelerants/vmware/Acceleration.c haiku/trunk/src/add-ons/accelerants/vmware/Cursor.c haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/device.c Log: - Fixed HW cursor issues: - in order to set cursor position SVGA_CURSOR_ON_SHOW has to be written to register SVGA_REG_CURSOR_ON. - do not use alpha cursor because it does not support inverting of source pixels. - Fixed wrong usage of if-statement inside switch-statement - Sync at end of SCREEN_TO_SCREEN_BLIT so that app_server does not write to frame buffer while accelerated operation is still running. Modified: haiku/trunk/headers/private/graphics/vmware/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/vmware/DriverInterface.h 2007-12-29 15:26:37 UTC (rev 23192) +++ haiku/trunk/headers/private/graphics/vmware/DriverInterface.h 2007-12-30 10:06:46 UTC (rev 23193) @@ -6,6 +6,7 @@ * Authors: * Be Incorporated * Eric Petit + * Michael Pfeiffer */ #ifndef DRIVERINTERFACE_H @@ -14,6 +15,7 @@ #include #include #include +#include #include #include @@ -99,6 +101,7 @@ /* For registers access */ uint16 indexPort; uint16 valuePort; + spinlock portLock; /* Mapped areas */ area_id fbArea; @@ -116,6 +119,11 @@ Benaphore engineLock; Benaphore fifoLock; uint32 fifoNext; + + /* Cursor state */ + bool cursorShow; + uint16 cursorX; + uint16 cursorY; } SharedInfo; #endif Modified: haiku/trunk/src/add-ons/accelerants/vmware/Acceleration.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/vmware/Acceleration.c 2007-12-29 15:26:37 UTC (rev 23192) +++ haiku/trunk/src/add-ons/accelerants/vmware/Acceleration.c 2007-12-30 10:06:46 UTC (rev 23193) @@ -6,6 +6,7 @@ * Authors: * Be Incorporated * Eric Petit + * Michael Pfeiffer */ @@ -18,13 +19,13 @@ uint32 i; blit_params *b; + FifoBeginWrite(); for (i = 0; i < count; i++) { b = &list[i]; #if 0 TRACE("BLIT %dx%d, %dx%d->%dx%d\n", b->width + 1, b->height + 1, b->src_left, b->src_top, b->dest_left, b->dest_top); #endif - FifoBeginWrite(); FifoWrite(SVGA_CMD_RECT_COPY); FifoWrite(b->src_left); FifoWrite(b->src_top); @@ -32,8 +33,9 @@ FifoWrite(b->dest_top); FifoWrite(b->width + 1); FifoWrite(b->height + 1); - FifoEndWrite(); } + FifoEndWrite(); + FifoSync(); } Modified: haiku/trunk/src/add-ons/accelerants/vmware/Cursor.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/vmware/Cursor.c 2007-12-29 15:26:37 UTC (rev 23192) +++ haiku/trunk/src/add-ons/accelerants/vmware/Cursor.c 2007-12-30 10:06:46 UTC (rev 23193) @@ -6,55 +6,103 @@ * Authors: * Be Incorporated * Eric Petit + * Michael Pfeiffer */ #include "GlobalData.h" + +static void +WriteScanline(void * scanline, uint16 sizeInBytes) +{ + uint32* words = (uint32*)scanline; + /* sizeInBytes must be a multiple of 4 */ + uint16 sizeInWords = sizeInBytes / 4; + uint16 i; + for (i = 0; i < sizeInWords; i ++) + FifoWrite(words[i]); +} + + +static void +WriteAndMask(uint8 * andMask, uint16 width, uint16 height, uint8 * scanline, + uint16 scanlineSize) +{ + uint16 y; + uint16 bpr = (width + 7) / 8; + for (y = 0; y < height; y ++) { + // copy andMask into scanline to avoid + // out of bounds access at last row + memcpy(scanline, &andMask[y * bpr], bpr); + WriteScanline(scanline, scanlineSize); + } +} + + +static void +WriteXorMask(uint8 * andMask, uint8 * xorMask, uint16 width, uint16 height, + uint8 * scanline, uint16 scanlineSize) +{ + uint16 x; + uint16 y; + uint16 bpr = (width + 7) / 8; + for (y = 0; y < height; y ++) { + uint8 * andMaskRow = &andMask[y * bpr]; + // copy xorMask into scanline to avoid + // out of bounds access at last row + memcpy(scanline, &xorMask[y * bpr], bpr); + // in case of a 1 bit in andMask + // the meaning of the corresponding bit + // in xorMask is the opposite in the + // emulated graphics HW (1 = white, 0 = + // black). Be API: 1 = black, 0 = white. + for (x = 0; x < width; x ++) { + uint8 bit = 7 - x % 8; + uint8 bitMask = 1 << bit; + uint16 byte = x / 8; + if ((andMaskRow[byte] & bitMask) == 0) + scanline[byte] = scanline[byte] ^ bitMask; + } + WriteScanline(scanline, scanlineSize); + } +} + + status_t SET_CURSOR_SHAPE(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y, uint8 * andMask, uint8 * xorMask) { - int i, shift; - uint32 * alphaCursor; + uint16 scanlineSize; + uint8 * scanline; + TRACE("SET_CURSOR_SHAPE (%d, %d, %d, %d)\n", width, height, hot_x, hot_y); /* Sanity check */ if (hot_x >= width || hot_y >= height) return B_ERROR; - /* Build ARGB image */ - alphaCursor = calloc(1, height * width * sizeof(uint32)); - shift = 7; - for (i = 0; i < height * width; i++) { - if (!((*andMask >> shift) & 1)) { - /* Opaque */ - alphaCursor[i] |= 0xFF000000; - if (!((*xorMask >> shift) & 1)) - /* White */ - alphaCursor[i] |= 0x00FFFFFF; - } - if (--shift < 0) { - shift = 7; - andMask++; - xorMask++; - } - } - - /* Give it to VMware */ + scanlineSize = 4 * ((width + 31) / 32); + scanline = calloc(1, scanlineSize); + if (calloc == NULL) + return B_ERROR; + FifoBeginWrite(); - FifoWrite(SVGA_CMD_DEFINE_ALPHA_CURSOR); + FifoWrite(SVGA_CMD_DEFINE_CURSOR); FifoWrite(CURSOR_ID); FifoWrite(hot_x); FifoWrite(hot_y); FifoWrite(width); FifoWrite(height); - for (i = 0; i < height * width; i++) - FifoWrite(alphaCursor[i]); + FifoWrite(1); + FifoWrite(1); + WriteAndMask(andMask, width, height, scanline, scanlineSize); + WriteXorMask(andMask, xorMask, width, height, scanline, scanlineSize); FifoEndWrite(); + FifoSync(); + + free(scanline); - free(alphaCursor); - return B_OK; } Modified: haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c 2007-12-29 15:26:37 UTC (rev 23192) +++ haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c 2007-12-30 10:06:46 UTC (rev 23193) @@ -6,6 +6,7 @@ * Authors: * Be Incorporated * Eric Petit + * Michael Pfeiffer */ #include "GlobalData.h" @@ -17,6 +18,7 @@ switch (feature) { #define HOOK(x) case B_##x: return (void *)x #define ZERO(x) case B_##x: return (void *)0 +#define HOOK_IF(x, cap) case B_##x: if (gSi->capabilities & cap) return (void *)x; else return (void *)0 /* initialization */ HOOK(INIT_ACCELERANT); @@ -46,13 +48,9 @@ HOOK(SET_DPMS_MODE); /* Cursor managment (Cursor.c) */ -#if 0 - if (gSi->capabilities & SVGA_CAP_ALPHA_CURSOR) { - HOOK(SET_CURSOR_SHAPE); - HOOK(MOVE_CURSOR); - HOOK(SHOW_CURSOR); - } -#endif + HOOK_IF(SET_CURSOR_SHAPE, SVGA_CAP_ALPHA_CURSOR); + HOOK_IF(MOVE_CURSOR, SVGA_CAP_ALPHA_CURSOR); + HOOK_IF(SHOW_CURSOR, SVGA_CAP_ALPHA_CURSOR); /* synchronization */ HOOK(ACCELERANT_ENGINE_COUNT); @@ -63,8 +61,7 @@ HOOK(SYNC_TO_TOKEN); /* 2D acceleration (Acceleration.c) */ - if (gSi->capabilities & SVGA_CAP_RECT_COPY) - HOOK(SCREEN_TO_SCREEN_BLIT); + HOOK_IF(SCREEN_TO_SCREEN_BLIT, SVGA_CAP_RECT_COPY); ZERO(FILL_RECTANGLE); ZERO(INVERT_RECTANGLE); ZERO(FILL_SPAN); Modified: haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/device.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/device.c 2007-12-29 15:26:37 UTC (rev 23192) +++ haiku/trunk/src/add-ons/kernel/drivers/graphics/vmware/device.c 2007-12-30 10:06:46 UTC (rev 23193) @@ -4,6 +4,7 @@ * * Authors: * Eric Petit + * Michael Pfeiffer */ @@ -259,6 +260,17 @@ } +static void +UpdateCursor(SharedInfo *si) +{ + WriteReg(SVGA_REG_CURSOR_ID, CURSOR_ID); + WriteReg(SVGA_REG_CURSOR_X, si->cursorX); + WriteReg(SVGA_REG_CURSOR_Y, si->cursorY); + WriteReg(SVGA_REG_CURSOR_ON, si->cursorShow ? SVGA_CURSOR_ON_SHOW : + SVGA_CURSOR_ON_HIDE); +} + + /*--------------------------------------------------------------------*/ /* ControlHook: responds the the ioctl from the accelerant */ @@ -325,17 +337,16 @@ case VMWARE_MOVE_CURSOR: { uint16 *pos = buf; - WriteReg(SVGA_REG_CURSOR_ID, CURSOR_ID); - WriteReg(SVGA_REG_CURSOR_X, pos[0]); - WriteReg(SVGA_REG_CURSOR_Y, pos[1]); + si->cursorX = pos[0]; + si->cursorY = pos[1]; + UpdateCursor(si); return B_OK; } case VMWARE_SHOW_CURSOR: { - bool show = *((bool *)buf); - WriteReg(SVGA_REG_CURSOR_ON, show ? SVGA_CURSOR_ON_HIDE : - SVGA_CURSOR_ON_SHOW); + si->cursorShow = *((bool *)buf); + UpdateCursor(si); return B_OK; } From laplace at mail.berlios.de Sun Dec 30 11:32:28 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 30 Dec 2007 11:32:28 +0100 Subject: [Haiku-commits] r23194 - haiku/trunk/src/add-ons/accelerants/vmware Message-ID: <200712301032.lBUAWSwt003605@sheep.berlios.de> Author: laplace Date: 2007-12-30 11:32:27 +0100 (Sun, 30 Dec 2007) New Revision: 23194 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23194&view=rev Modified: haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c Log: Check correct capability flags. Modified: haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c =================================================================== --- haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c 2007-12-30 10:06:46 UTC (rev 23193) +++ haiku/trunk/src/add-ons/accelerants/vmware/GetAccelerantHook.c 2007-12-30 10:32:27 UTC (rev 23194) @@ -48,9 +48,9 @@ HOOK(SET_DPMS_MODE); /* Cursor managment (Cursor.c) */ - HOOK_IF(SET_CURSOR_SHAPE, SVGA_CAP_ALPHA_CURSOR); - HOOK_IF(MOVE_CURSOR, SVGA_CAP_ALPHA_CURSOR); - HOOK_IF(SHOW_CURSOR, SVGA_CAP_ALPHA_CURSOR); + HOOK_IF(SET_CURSOR_SHAPE, SVGA_CAP_CURSOR_BYPASS); + HOOK_IF(MOVE_CURSOR, SVGA_CAP_CURSOR_BYPASS); + HOOK_IF(SHOW_CURSOR, SVGA_CAP_CURSOR_BYPASS); /* synchronization */ HOOK(ACCELERANT_ENGINE_COUNT); From laplace at mail.berlios.de Sun Dec 30 11:33:32 2007 From: laplace at mail.berlios.de (laplace at BerliOS) Date: Sun, 30 Dec 2007 11:33:32 +0100 Subject: [Haiku-commits] r23195 - haiku/trunk/headers/private/graphics/vmware Message-ID: <200712301033.lBUAXWhO003654@sheep.berlios.de> Author: laplace Date: 2007-12-30 11:33:31 +0100 (Sun, 30 Dec 2007) New Revision: 23195 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23195&view=rev Modified: haiku/trunk/headers/private/graphics/vmware/DriverInterface.h Log: Checked in too soon. Modified: haiku/trunk/headers/private/graphics/vmware/DriverInterface.h =================================================================== --- haiku/trunk/headers/private/graphics/vmware/DriverInterface.h 2007-12-30 10:32:27 UTC (rev 23194) +++ haiku/trunk/headers/private/graphics/vmware/DriverInterface.h 2007-12-30 10:33:31 UTC (rev 23195) @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -101,7 +100,6 @@ /* For registers access */ uint16 indexPort; uint16 valuePort; - spinlock portLock; /* Mapped areas */ area_id fbArea; From axeld at mail.berlios.de Sun Dec 30 13:46:30 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 30 Dec 2007 13:46:30 +0100 Subject: [Haiku-commits] r23196 - haiku/trunk/src/kits/interface Message-ID: <200712301246.lBUCkU2u027347@sheep.berlios.de> Author: axeld Date: 2007-12-30 13:46:30 +0100 (Sun, 30 Dec 2007) New Revision: 23196 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23196&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: * DispatchMessage()'s B_WINDOW_ACTIVATED now checks if there are any pending activation messages, and always retrieves the information from the latest. * Reverted r23062, as the above should fix bug #613 as well. * This should also fix bug #1674. Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2007-12-30 10:33:31 UTC (rev 23195) +++ haiku/trunk/src/kits/interface/Window.cpp 2007-12-30 12:46:30 UTC (rev 23196) @@ -874,22 +874,18 @@ // combine with pending resize notifications BMessage* pendingMessage; while ((pendingMessage = MessageQueue()->FindMessage(B_WINDOW_RESIZED, 0))) { - if (pendingMessage != msg) { - int32 nextWidth; - if (pendingMessage->FindInt32("width", &nextWidth) == B_OK) - width = nextWidth; + int32 nextWidth; + if (pendingMessage->FindInt32("width", &nextWidth) == B_OK) + width = nextWidth; - int32 nextHeight; - if (pendingMessage->FindInt32("height", &nextHeight) == B_OK) - height = nextHeight; + int32 nextHeight; + if (pendingMessage->FindInt32("height", &nextHeight) == B_OK) + height = nextHeight; - MessageQueue()->RemoveMessage(pendingMessage); - delete pendingMessage; - // this deletes the first *additional* message - // fCurrentMessage is safe - } else { - MessageQueue()->RemoveMessage(pendingMessage); - } + MessageQueue()->RemoveMessage(pendingMessage); + delete pendingMessage; + // this deletes the first *additional* message + // fCurrentMessage is safe } if (width != fFrame.Width() || height != fFrame.Height()) { // NOTE: we might have already handled the resize @@ -932,33 +928,53 @@ } case B_WINDOW_ACTIVATED: - if (target == this) { - bool active; - if (msg->FindBool("active", &active) == B_OK - && active != fActive) { - fActive = active; + if (target != this) { + target->MessageReceived(msg); + break; + } - WindowActivated(active); + bool active; + if (msg->FindBool("active", &active) != B_OK) + break; - // call hook function 'WindowActivated(bool)' for all - // views attached to this window. - fTopView->_Activate(active); + // find latest activation message - // we notify the input server if we are gaining or losing focus - // from a view which has the B_INPUT_METHOD_AWARE on a window - // (de)activation - bool inputMethodAware = false; - if (fFocus) - inputMethodAware = fFocus->Flags() & B_INPUT_METHOD_AWARE; - BMessage msg(active && inputMethodAware ? IS_FOCUS_IM_AWARE_VIEW : IS_UNFOCUS_IM_AWARE_VIEW); - BMessenger messenger(fFocus); - BMessage reply; - if (fFocus) - msg.AddMessenger("view", messenger); - _control_input_server_(&msg, &reply); - } - } else - target->MessageReceived(msg); + while (true) { + BMessage* pendingMessage = MessageQueue()->FindMessage( + B_WINDOW_RESIZED, 0); + if (pendingMessage == NULL) + break; + + bool nextActive; + if (pendingMessage->FindBool("active", &nextActive) == B_OK) + active = nextActive; + + MessageQueue()->RemoveMessage(pendingMessage); + delete pendingMessage; + } + + if (active != fActive) { + fActive = active; + + WindowActivated(active); + + // call hook function 'WindowActivated(bool)' for all + // views attached to this window. + fTopView->_Activate(active); + + // we notify the input server if we are gaining or losing focus + // from a view which has the B_INPUT_METHOD_AWARE on a window + // (de)activation + bool inputMethodAware = false; + if (fFocus) + inputMethodAware = fFocus->Flags() & B_INPUT_METHOD_AWARE; + BMessage msg(active && inputMethodAware ? IS_FOCUS_IM_AWARE_VIEW : IS_UNFOCUS_IM_AWARE_VIEW); + BMessenger messenger(fFocus); + BMessage reply; + if (fFocus) + msg.AddMessenger("view", messenger); + _control_input_server_(&msg, &reply); + } break; case B_SCREEN_CHANGED: @@ -1686,8 +1702,7 @@ BMessage *msg; for (int32 i = 0; (msg = queue->FindMessage(i)) != NULL; i++) { - // TODO: Dispatch more messages ?!?!? Check what beos does. - if (msg->what == _UPDATE_ || msg->what == B_WINDOW_ACTIVATED) { + if (msg->what == _UPDATE_) { BWindow::DispatchMessage(msg, this); // we need to make sure that no overridden method is called // here; for BWindow::DispatchMessage() we now exactly what @@ -1695,8 +1710,8 @@ queue->RemoveMessage(msg); delete msg; break; - // NOTE: "i" would have to be decreased if there were - // multiple _UPDATE_ messages and we would not break! + // NOTE: "i" would have to be decreased if there were + // multiple _UPDATE_ messages and we would not break! } } From stefano.ceccherini at gmail.com Sun Dec 30 13:58:13 2007 From: stefano.ceccherini at gmail.com (Stefano Ceccherini) Date: Sun, 30 Dec 2007 13:58:13 +0100 Subject: [Haiku-commits] r23196 - haiku/trunk/src/kits/interface In-Reply-To: <200712301246.lBUCkU2u027347@sheep.berlios.de> References: <200712301246.lBUCkU2u027347@sheep.berlios.de> Message-ID: <894b9700712300458y18ff1a00v8bfb7f569bf857cc@mail.gmail.com> 2007/12/30, axeld at BerliOS : > Author: axeld > while ((pendingMessage = MessageQueue()->FindMessage(B_WINDOW_RESIZED, 0))) { Shoulndn't this be B_WINDOW_ACTIVATED ? From axeld at mail.berlios.de Sun Dec 30 14:02:13 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 30 Dec 2007 14:02:13 +0100 Subject: [Haiku-commits] r23197 - haiku/trunk/src/kits/interface Message-ID: <200712301302.lBUD2Div028138@sheep.berlios.de> Author: axeld Date: 2007-12-30 14:02:13 +0100 (Sun, 30 Dec 2007) New Revision: 23197 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23197&view=rev Modified: haiku/trunk/src/kits/interface/Window.cpp Log: Fixed copy&paste bug, thanks Stefano! Modified: haiku/trunk/src/kits/interface/Window.cpp =================================================================== --- haiku/trunk/src/kits/interface/Window.cpp 2007-12-30 12:46:30 UTC (rev 23196) +++ haiku/trunk/src/kits/interface/Window.cpp 2007-12-30 13:02:13 UTC (rev 23197) @@ -941,7 +941,7 @@ while (true) { BMessage* pendingMessage = MessageQueue()->FindMessage( - B_WINDOW_RESIZED, 0); + B_WINDOW_ACTIVATED, 0); if (pendingMessage == NULL) break; From axeld at pinc-software.de Sun Dec 30 14:02:30 2007 From: axeld at pinc-software.de (Axel =?iso-8859-15?q?D=F6rfler?=) Date: Sun, 30 Dec 2007 14:02:30 +0100 CET Subject: [Haiku-commits] r23196 - haiku/trunk/src/kits/interface In-Reply-To: <894b9700712300458y18ff1a00v8bfb7f569bf857cc@mail.gmail.com> Message-ID: <13113422996-BeMail@zon> "Stefano Ceccherini" wrote: > 2007/12/30, axeld at BerliOS : > > while ((pendingMessage = > > MessageQueue()->FindMessage(B_WINDOW_RESIZED, 0))) { > Shoulndn't this be B_WINDOW_ACTIVATED ? Yes, definitely, thanks! Bye, Axel. From axeld at mail.berlios.de Sun Dec 30 14:31:46 2007 From: axeld at mail.berlios.de (axeld at BerliOS) Date: Sun, 30 Dec 2007 14:31:46 +0100 Subject: [Haiku-commits] r23198 - in haiku/trunk/src: kits/interface preferences/drivesetup Message-ID: <200712301331.lBUDVkFh029621@sheep.berlios.de> Author: axeld Date: 2007-12-30 14:31:45 +0100 (Sun, 30 Dec 2007) New Revision: 23198 ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=23198&view=rev Modified: haiku/trunk/src/kits/interface/Jamfile haiku/trunk/src/preferences/drivesetup/Jamfile Log: Removed the experimental BColumnListView class from libbe.so, and moved it into its own archive (libcolumnlistview.a). Only DriveSetup is using it at the moment, anyway. IMO we should reimplement and completely redesign a class with this functionality before considering making it public. Modified: haiku/trunk/src/kits/interface/Jamfile =================================================================== --- haiku/trunk/src/kits/interface/Jamfile 2007-12-30 13:02:13 UTC (rev 23197) +++ haiku/trunk/src/kits/interface/Jamfile 2007-12-30 13:31:45 UTC (rev 23198) @@ -44,8 +44,6 @@ ChannelControl.cpp ChannelSlider.cpp CheckBox.cpp - ColumnListView.cpp - ColumnTypes.cpp ColorConversion.cpp ColorControl.cpp ColorTools.cpp @@ -128,3 +126,8 @@ OneElementLayouter.cpp SimpleLayouter.cpp ; + +StaticLibrary libcolumnlistview.a : + ColumnListView.cpp + ColumnTypes.cpp +; Modified: haiku/trunk/src/preferences/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/preferences/drivesetup/Jamfile 2007-12-30 13:02:13 UTC (rev 23197) +++ haiku/trunk/src/preferences/drivesetup/Jamfile 2007-12-30 13:31:45 UTC (rev 23198) @@ -10,9 +10,9 @@ MainWindow.cpp PartitionList.cpp Support.cpp + + : be libcolumnlistview.a : - be - : DriveSetup.rdef ;